@cesium/engine 18.3.1-ion.1 → 20.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (192) hide show
  1. package/Build/ThirdParty/Workers/pako_deflate.min.js +3 -3
  2. package/Build/ThirdParty/Workers/pako_inflate.min.js +3 -3
  3. package/Build/ThirdParty/Workers/z-worker-pako.js +80 -89
  4. package/Build/Workers/{chunk-G7F2CKBW.js → chunk-22LUVCO3.js} +2 -2
  5. package/Build/Workers/{chunk-AIBIEA2N.js → chunk-3BO4XBWM.js} +12 -12
  6. package/Build/Workers/{chunk-LPLMZKZS.js → chunk-3SQPZVG4.js} +1 -1
  7. package/Build/Workers/{chunk-KQ7OYXT6.js → chunk-4O5SZ2RE.js} +3 -3
  8. package/Build/Workers/{chunk-EF747DYS.js → chunk-4UIKSIEZ.js} +9 -9
  9. package/Build/Workers/{chunk-LDFRBRJO.js → chunk-5FZEM66Y.js} +12 -12
  10. package/Build/Workers/{chunk-Z7UO3S7L.js → chunk-5G56VVL3.js} +10 -10
  11. package/Build/Workers/{chunk-KUVAFSVU.js → chunk-5GKRDXYJ.js} +12 -12
  12. package/Build/Workers/{chunk-GIRJEZHU.js → chunk-5W4EBNO3.js} +14 -14
  13. package/Build/Workers/{chunk-XMFKOU5X.js → chunk-67RLCIDP.js} +7 -7
  14. package/Build/Workers/{chunk-ACOAKTBU.js → chunk-74VODBWB.js} +4 -4
  15. package/Build/Workers/{chunk-QTFE5TBC.js → chunk-7HOD2LGH.js} +10 -10
  16. package/Build/Workers/{chunk-GOSJZP7N.js → chunk-D25QOWHR.js} +1 -1
  17. package/Build/Workers/{chunk-5UWLMG6V.js → chunk-D63DK275.js} +7 -7
  18. package/Build/Workers/{chunk-4JMMKZ4N.js → chunk-EHOOC4HJ.js} +5 -5
  19. package/Build/Workers/{chunk-PFTYXAVG.js → chunk-ELI5ZYDR.js} +5 -5
  20. package/Build/Workers/{chunk-RQRKALHB.js → chunk-FGF4ETPY.js} +9 -9
  21. package/Build/Workers/{chunk-YPMSP4IH.js → chunk-FKWL63D4.js} +5 -5
  22. package/Build/Workers/{chunk-IC5M3JRR.js → chunk-FLH3ZH2X.js} +4 -4
  23. package/Build/Workers/{chunk-5DF22LFV.js → chunk-HDOFAYEE.js} +16 -16
  24. package/Build/Workers/{chunk-37V6UO2J.js → chunk-HHUHFFYN.js} +5 -5
  25. package/Build/Workers/{chunk-GSLSXQGX.js → chunk-IHUXLSNT.js} +5 -4
  26. package/Build/Workers/{chunk-K4HUWRWA.js → chunk-IJM2HVTV.js} +1 -1
  27. package/Build/Workers/{chunk-AKLRSDAY.js → chunk-IPXMWP5Z.js} +6 -6
  28. package/Build/Workers/{chunk-G6I5XO4E.js → chunk-IWKYS6RV.js} +6 -6
  29. package/Build/Workers/{chunk-RVQ7LHW3.js → chunk-JMX3P7DE.js} +8 -8
  30. package/Build/Workers/{chunk-OQNQNBEM.js → chunk-JQSMAZAT.js} +9 -9
  31. package/Build/Workers/{chunk-GGNZKIG3.js → chunk-JRLT2FQV.js} +8 -8
  32. package/Build/Workers/{chunk-GK5WVMVN.js → chunk-KRXL3KZL.js} +13 -13
  33. package/Build/Workers/{chunk-OVXYMPQ7.js → chunk-KWB7PPVO.js} +2 -2
  34. package/Build/Workers/{chunk-DG4CHTQN.js → chunk-M62PWLGC.js} +16 -16
  35. package/Build/Workers/{chunk-T3UE5LOS.js → chunk-MSLO3MQF.js} +5 -5
  36. package/Build/Workers/{chunk-ZGH3R3CO.js → chunk-MZZK44UI.js} +6 -6
  37. package/Build/Workers/{chunk-3T2QV5NN.js → chunk-NB2NKFJL.js} +6 -6
  38. package/Build/Workers/{chunk-W2EMENZQ.js → chunk-NJYFQE5B.js} +1 -1
  39. package/Build/Workers/{chunk-GG2NLIC6.js → chunk-O2O4FYNI.js} +2 -2
  40. package/Build/Workers/{chunk-6HT3OW6S.js → chunk-PZEPLREA.js} +2 -2
  41. package/Build/Workers/{chunk-MYMBUYST.js → chunk-S2RSJJQI.js} +4 -4
  42. package/Build/Workers/{chunk-QBRCP474.js → chunk-S3UYLP3X.js} +8 -8
  43. package/Build/Workers/{chunk-JVSY3BGV.js → chunk-TH3P77KJ.js} +5 -5
  44. package/Build/Workers/{chunk-4HDG7AFU.js → chunk-UGSQJYGE.js} +6 -6
  45. package/Build/Workers/{chunk-SMVRX64E.js → chunk-UUXOFY6G.js} +12 -12
  46. package/Build/Workers/{chunk-DPG3EG2U.js → chunk-V36BVRDX.js} +11 -11
  47. package/Build/Workers/{chunk-3HRMP3V7.js → chunk-VJ2DNCFT.js} +4 -4
  48. package/Build/Workers/{chunk-DH3XQXDD.js → chunk-VQUVJWBK.js} +4 -4
  49. package/Build/Workers/{chunk-AJANTRVW.js → chunk-VWQWZ7OL.js} +5 -5
  50. package/Build/Workers/{chunk-XPXBRZXF.js → chunk-VXBNLAG4.js} +7 -7
  51. package/Build/Workers/{chunk-GXEQK7P4.js → chunk-W3KNMQT2.js} +6 -6
  52. package/Build/Workers/{chunk-5RUDB5R4.js → chunk-WIGH3CPD.js} +2 -2
  53. package/Build/Workers/{chunk-GMNXNBM4.js → chunk-XVHLXVN3.js} +1 -1
  54. package/Build/Workers/{chunk-KSNUH6WJ.js → chunk-YHB3RNF2.js} +4 -4
  55. package/Build/Workers/{chunk-BTXGNWFF.js → chunk-ZSHDRKLT.js} +4 -4
  56. package/Build/Workers/combineGeometry.js +21 -21
  57. package/Build/Workers/createBoxGeometry.js +15 -15
  58. package/Build/Workers/createBoxOutlineGeometry.js +13 -13
  59. package/Build/Workers/createCircleGeometry.js +23 -23
  60. package/Build/Workers/createCircleOutlineGeometry.js +16 -16
  61. package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
  62. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
  63. package/Build/Workers/createCorridorGeometry.js +26 -26
  64. package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
  65. package/Build/Workers/createCylinderGeometry.js +17 -17
  66. package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
  67. package/Build/Workers/createEllipseGeometry.js +23 -23
  68. package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
  69. package/Build/Workers/createEllipsoidGeometry.js +16 -16
  70. package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
  71. package/Build/Workers/createFrustumGeometry.js +15 -15
  72. package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
  73. package/Build/Workers/createGeometry.js +21 -21
  74. package/Build/Workers/createGroundPolylineGeometry.js +19 -19
  75. package/Build/Workers/createPlaneGeometry.js +13 -13
  76. package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
  77. package/Build/Workers/createPolygonGeometry.js +29 -29
  78. package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
  79. package/Build/Workers/createPolylineGeometry.js +22 -22
  80. package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
  81. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
  82. package/Build/Workers/createRectangleGeometry.js +24 -24
  83. package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
  84. package/Build/Workers/createSimplePolylineGeometry.js +20 -20
  85. package/Build/Workers/createSphereGeometry.js +16 -16
  86. package/Build/Workers/createSphereOutlineGeometry.js +15 -15
  87. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  88. package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
  89. package/Build/Workers/createVectorTileGeometries.js +21 -21
  90. package/Build/Workers/createVectorTilePoints.js +11 -11
  91. package/Build/Workers/createVectorTilePolygons.js +19 -19
  92. package/Build/Workers/createVectorTilePolylines.js +12 -12
  93. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
  94. package/Build/Workers/createVerticesFromHeightmap.js +25 -25
  95. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
  96. package/Build/Workers/createWallGeometry.js +21 -21
  97. package/Build/Workers/createWallOutlineGeometry.js +20 -20
  98. package/Build/Workers/decodeDraco.js +10 -10
  99. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  100. package/Build/Workers/decodeI3S.js +9 -9
  101. package/Build/Workers/gaussianSplatSorter.js +4 -4
  102. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  103. package/Build/Workers/transcodeKTX2.js +17 -16
  104. package/Build/Workers/transferTypedArrayTest.js +1 -1
  105. package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
  106. package/LICENSE.md +32 -25
  107. package/Source/Core/Ellipsoid.js +9 -0
  108. package/Source/Core/ITwinPlatform.js +8 -1
  109. package/Source/Core/Ion.js +1 -1
  110. package/Source/Core/IonResource.js +14 -8
  111. package/Source/Core/ScreenSpaceEventHandler.js +3 -3
  112. package/Source/Core/addAllToArray.js +40 -0
  113. package/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +54 -26
  114. package/Source/Renderer/Context.js +8 -4
  115. package/Source/Renderer/Renderbuffer.js +4 -2
  116. package/Source/Renderer/Sampler.js +13 -0
  117. package/Source/Renderer/ShaderBuilder.js +7 -6
  118. package/Source/Renderer/SharedContext.js +186 -0
  119. package/Source/Renderer/Texture.js +4 -5
  120. package/Source/Renderer/Texture3D.js +17 -7
  121. package/Source/Scene/ArcGisMapService.js +1 -1
  122. package/Source/Scene/BillboardCollection.js +1 -1
  123. package/Source/Scene/BingMapsImageryProvider.js +1 -1
  124. package/Source/Scene/Cesium3DTileBatchTable.js +6 -4
  125. package/Source/Scene/Cesium3DTileContentFactory.js +7 -16
  126. package/Source/Scene/Cesium3DTileStyle.js +4 -3
  127. package/Source/Scene/Cesium3DTileset.js +2 -2
  128. package/Source/Scene/ConditionsExpression.js +3 -2
  129. package/Source/Scene/GaussianSplat3DTileContent.js +253 -9
  130. package/Source/Scene/GaussianSplatPrimitive.js +167 -15
  131. package/Source/Scene/GltfLoader.js +23 -4
  132. package/Source/Scene/GltfPipeline/ForEach.js +7 -7
  133. package/Source/Scene/GltfPipeline/addDefaults.js +1 -2
  134. package/Source/Scene/GltfPipeline/addToArray.js +2 -0
  135. package/Source/Scene/GltfPipeline/findAccessorMinMax.js +1 -1
  136. package/Source/Scene/GltfPipeline/getComponentReader.js +16 -16
  137. package/Source/Scene/GltfPipeline/moveTechniqueRenderStates.js +1 -1
  138. package/Source/Scene/GltfPipeline/moveTechniquesToExtension.js +3 -3
  139. package/Source/Scene/GltfPipeline/parseGlb.js +1 -1
  140. package/Source/Scene/GltfPipeline/readAccessorPacked.js +2 -2
  141. package/Source/Scene/GltfPipeline/removeUnusedElements.js +5 -6
  142. package/Source/Scene/GltfPipeline/updateAccessorComponentTypes.js +1 -1
  143. package/Source/Scene/GltfPipeline/updateVersion.js +13 -13
  144. package/Source/Scene/GltfSpzLoader.js +3 -1
  145. package/Source/Scene/GltfVertexBufferLoader.js +56 -2
  146. package/Source/Scene/HeightReference.js +1 -1
  147. package/Source/Scene/ITwinData.js +49 -25
  148. package/Source/Scene/ImageBasedLighting.js +6 -2
  149. package/Source/Scene/ImageryLayer.js +10 -10
  150. package/Source/Scene/MetadataTableProperty.js +2 -1
  151. package/Source/Scene/Model/ClassificationModelDrawCommand.js +7 -6
  152. package/Source/Scene/Model/GeoJsonLoader.js +3 -1
  153. package/Source/Scene/Model/ImageryConfiguration.js +1 -0
  154. package/Source/Scene/Model/ImageryPipelineStage.js +8 -2
  155. package/Source/Scene/Model/InstancingPipelineStage.js +3 -8
  156. package/Source/Scene/Model/MaterialPipelineStage.js +10 -1
  157. package/Source/Scene/Model/Model.js +3 -0
  158. package/Source/Scene/Model/ModelClippingPolygonsPipelineStage.js +8 -2
  159. package/Source/Scene/Model/ModelImagery.js +3 -0
  160. package/Source/Scene/Model/ModelSceneGraph.js +2 -1
  161. package/Source/Scene/Model/ModelUtility.js +1 -0
  162. package/Source/Scene/Model/PntsLoader.js +7 -3
  163. package/Source/Scene/Picking.js +41 -1
  164. package/Source/Scene/PntsParser.js +6 -3
  165. package/Source/Scene/Primitive.js +0 -1
  166. package/Source/Scene/PrimitiveCollection.js +32 -6
  167. package/Source/Scene/PrimitiveLoadPlan.js +1 -37
  168. package/Source/Scene/PropertyTable.js +7 -12
  169. package/Source/Scene/Scene.js +41 -32
  170. package/Source/Scene/ScreenSpaceCameraController.js +2 -0
  171. package/Source/Scene/VertexAttributeSemantic.js +4 -2
  172. package/Source/Scene/WebMapServiceImageryProvider.js +3 -2
  173. package/Source/Scene/WebMapTileServiceImageryProvider.js +0 -22
  174. package/Source/Scene/getMeshPrimitives.js +72 -0
  175. package/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.glsl +2 -1
  176. package/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.js +2 -1
  177. package/Source/Shaders/EllipsoidVS.glsl +4 -4
  178. package/Source/Shaders/EllipsoidVS.js +4 -4
  179. package/Source/Shaders/FXAA3_11.glsl +2 -0
  180. package/Source/Shaders/FXAA3_11.js +2 -0
  181. package/Source/Shaders/GlobeVS.glsl +2 -1
  182. package/Source/Shaders/GlobeVS.js +2 -1
  183. package/Source/Shaders/PrimitiveGaussianSplatFS.glsl +5 -5
  184. package/Source/Shaders/PrimitiveGaussianSplatFS.js +5 -5
  185. package/Source/Shaders/PrimitiveGaussianSplatVS.glsl +102 -5
  186. package/Source/Shaders/PrimitiveGaussianSplatVS.js +102 -5
  187. package/Source/Shaders/SkyAtmosphereVS.glsl +2 -1
  188. package/Source/Shaders/SkyAtmosphereVS.js +2 -1
  189. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  190. package/index.d.ts +191 -54
  191. package/index.js +93 -90
  192. package/package.json +4 -4
@@ -16,6 +16,9 @@ import Event from "../Core/Event.js";
16
16
  * @param {object} [options] Object with the following properties:
17
17
  * @param {boolean} [options.show=true] Determines if the primitives in the collection will be shown.
18
18
  * @param {boolean} [options.destroyPrimitives=true] Determines if primitives in the collection are destroyed when they are removed.
19
+ * @privateParam {boolean} [options.countReferences=false] Specifies whether adding and removing primitives from this collection alters their reference counts. If so, adding a
20
+ * primitive to this collection increments its reference count. Removing the primitive decrements its reference count and - if the count reaches zero **and** destroyPrimitives is true - destroys the primitive.
21
+ * This permits primitives to be shared between multiple collections.
19
22
  *
20
23
  * @example
21
24
  * const billboards = new Cesium.BillboardCollection();
@@ -71,6 +74,8 @@ function PrimitiveCollection(options) {
71
74
  * labels = labels.destroy(); // explicitly destroy
72
75
  */
73
76
  this.destroyPrimitives = options.destroyPrimitives ?? true;
77
+
78
+ this._countReferences = options.countReferences ?? false;
74
79
  }
75
80
 
76
81
  Object.defineProperties(PrimitiveCollection.prototype, {
@@ -160,6 +165,14 @@ PrimitiveCollection.prototype.add = function (primitive, index) {
160
165
  this._primitives.splice(index, 0, primitive);
161
166
  }
162
167
 
168
+ if (this._countReferences) {
169
+ if (!defined(external._referenceCount)) {
170
+ external._referenceCount = 1;
171
+ } else {
172
+ ++external._referenceCount;
173
+ }
174
+ }
175
+
163
176
  this._primitiveAdded.raiseEvent(primitive);
164
177
 
165
178
  return primitive;
@@ -188,8 +201,14 @@ PrimitiveCollection.prototype.remove = function (primitive) {
188
201
  this._primitives.splice(index, 1);
189
202
 
190
203
  delete primitive._external._composites[this._guid];
204
+ if (this._countReferences) {
205
+ primitive._external._referenceCount--;
206
+ }
191
207
 
192
- if (this.destroyPrimitives) {
208
+ if (
209
+ this.destroyPrimitives &&
210
+ (!this._countReferences || primitive._external._referenceCount <= 0)
211
+ ) {
193
212
  primitive.destroy();
194
213
  }
195
214
 
@@ -204,7 +223,7 @@ PrimitiveCollection.prototype.remove = function (primitive) {
204
223
  };
205
224
 
206
225
  /**
207
- * Removes and destroys a primitive, regardless of destroyPrimitives setting.
226
+ * Removes and destroys a primitive, regardless of destroyPrimitives or countReferences setting.
208
227
  * @private
209
228
  */
210
229
  PrimitiveCollection.prototype.removeAndDestroy = function (primitive) {
@@ -226,13 +245,20 @@ PrimitiveCollection.prototype.removeAll = function () {
226
245
  const primitives = this._primitives;
227
246
  const length = primitives.length;
228
247
  for (let i = 0; i < length; ++i) {
229
- delete primitives[i]._external._composites[this._guid];
248
+ const primitive = primitives[i];
249
+ delete primitive._external._composites[this._guid];
250
+ if (this._countReferences) {
251
+ primitive._external._referenceCount--;
252
+ }
230
253
 
231
- if (this.destroyPrimitives) {
232
- primitives[i].destroy();
254
+ if (
255
+ this.destroyPrimitives &&
256
+ (!this._countReferences || primitive._external._referenceCount <= 0)
257
+ ) {
258
+ primitive.destroy();
233
259
  }
234
260
 
235
- this._primitiveRemoved.raiseEvent(primitives[i]);
261
+ this._primitiveRemoved.raiseEvent(primitive);
236
262
  }
237
263
  this._primitives = [];
238
264
  };
@@ -7,8 +7,6 @@ import BufferUsage from "../Renderer/BufferUsage.js";
7
7
  import AttributeType from "./AttributeType.js";
8
8
  import ModelComponents from "./ModelComponents.js";
9
9
  import PrimitiveOutlineGenerator from "./Model/PrimitiveOutlineGenerator.js";
10
- import VertexAttributeSemantic from "./VertexAttributeSemantic.js";
11
- import ModelUtility from "./Model/ModelUtility.js";
12
10
 
13
11
  /**
14
12
  * Simple struct for tracking whether an attribute will be loaded as a buffer
@@ -162,7 +160,7 @@ function PrimitiveLoadPlan(primitive) {
162
160
 
163
161
  /**
164
162
  * Set this true to indicate that the primitive has the
165
- * KHR_gaussian_splatting extension and needs to be post-processed
163
+ * KHR_gaussian_splatting and KHR_gaussian_splatting_compression_spz_2 extension and needs to be post-processed
166
164
  *
167
165
  * @type {boolean}
168
166
  * @private
@@ -187,7 +185,6 @@ PrimitiveLoadPlan.prototype.postProcess = function (context) {
187
185
  }
188
186
 
189
187
  if (this.needsGaussianSplats) {
190
- prepareSpzData(this, context);
191
188
  setupGaussianSplatBuffers(this, context);
192
189
  }
193
190
  };
@@ -242,39 +239,6 @@ function makeOutlineCoordinatesAttribute(outlineCoordinatesTypedArray) {
242
239
  return attribute;
243
240
  }
244
241
 
245
- function prepareSpzData(loadPlan, context) {
246
- const position = ModelUtility.getAttributeBySemantic(
247
- loadPlan.primitive,
248
- VertexAttributeSemantic.POSITION,
249
- );
250
-
251
- for (let i = 0; i < position.typedArray.length; i += 3) {
252
- position.typedArray[i + 1] = -position.typedArray[i + 1];
253
- position.typedArray[i + 2] = -position.typedArray[i + 2];
254
- }
255
-
256
- const rotations = ModelUtility.getAttributeBySemantic(
257
- loadPlan.primitive,
258
- VertexAttributeSemantic.ROTATION,
259
- );
260
-
261
- //180* rotation around X.
262
- //Temporary until we can get SPZ supporting Z-up assets natively
263
- const rots = rotations.typedArray;
264
- for (let q = 0; q < rots.length; q += 4) {
265
- const w = rots[q];
266
- const x = -rots[q + 3];
267
- const y = rots[q + 2];
268
- const z = -rots[q + 1];
269
-
270
- rots[q] = y;
271
- rots[q + 1] = -x;
272
- rots[q + 2] = w;
273
- rots[q + 3] = -z;
274
- }
275
- rotations.typedArray = rots;
276
- }
277
-
278
242
  function setupGaussianSplatBuffers(loadPlan, context) {
279
243
  const attributePlans = loadPlan.attributePlans;
280
244
  const attrLen = attributePlans.length;
@@ -3,6 +3,7 @@ import Frozen from "../Core/Frozen.js";
3
3
  import DeveloperError from "../Core/DeveloperError.js";
4
4
  import defined from "../Core/defined.js";
5
5
  import JsonMetadataTable from "./JsonMetadataTable.js";
6
+ import addAllToArray from "../Core/addAllToArray.js";
6
7
 
7
8
  /**
8
9
  * A property table for use with the <code>EXT_structural_metadata</code> extension or
@@ -296,24 +297,18 @@ PropertyTable.prototype.getPropertyIds = function (index, results) {
296
297
 
297
298
  if (defined(this._metadataTable)) {
298
299
  // concat in place to avoid unnecessary array allocation
299
- results.push.apply(
300
- results,
301
- this._metadataTable.getPropertyIds(scratchResults),
302
- );
300
+ const ids = this._metadataTable.getPropertyIds(scratchResults);
301
+ addAllToArray(results, ids);
303
302
  }
304
303
 
305
304
  if (defined(this._batchTableHierarchy)) {
306
- results.push.apply(
307
- results,
308
- this._batchTableHierarchy.getPropertyIds(index, scratchResults),
309
- );
305
+ const ids = this._batchTableHierarchy.getPropertyIds(index, scratchResults);
306
+ addAllToArray(results, ids);
310
307
  }
311
308
 
312
309
  if (defined(this._jsonMetadataTable)) {
313
- results.push.apply(
314
- results,
315
- this._jsonMetadataTable.getPropertyIds(scratchResults),
316
- );
310
+ const ids = this._jsonMetadataTable.getPropertyIds(scratchResults);
311
+ addAllToArray(results, ids);
317
312
  }
318
313
 
319
314
  return results;
@@ -68,6 +68,7 @@ import SceneTransforms from "./SceneTransforms.js";
68
68
  import SceneTransitioner from "./SceneTransitioner.js";
69
69
  import ScreenSpaceCameraController from "./ScreenSpaceCameraController.js";
70
70
  import ShadowMap from "./ShadowMap.js";
71
+ import SharedContext from "../Renderer/SharedContext.js";
71
72
  import SpecularEnvironmentCubeMap from "./SpecularEnvironmentCubeMap.js";
72
73
  import StencilConstants from "./StencilConstants.js";
73
74
  import SunLight from "./SunLight.js";
@@ -132,15 +133,22 @@ function Scene(options) {
132
133
  let creditContainer = options.creditContainer;
133
134
  let creditViewport = options.creditViewport;
134
135
 
135
- const contextOptions = clone(options.contextOptions);
136
-
137
136
  //>>includeStart('debug', pragmas.debug);
138
137
  if (!defined(canvas)) {
139
138
  throw new DeveloperError("options and options.canvas are required.");
140
139
  }
141
140
  //>>includeEnd('debug');
141
+
142
+ const countReferences = options.contextOptions instanceof SharedContext;
143
+ if (countReferences) {
144
+ this._context = options.contextOptions.createSceneContext(canvas);
145
+ } else {
146
+ const contextOptions = clone(options.contextOptions);
147
+ this._context = new Context(canvas, contextOptions);
148
+ }
149
+ const context = this._context;
150
+
142
151
  const hasCreditContainer = defined(creditContainer);
143
- const context = new Context(canvas, contextOptions);
144
152
  if (!hasCreditContainer) {
145
153
  creditContainer = document.createElement("div");
146
154
  creditContainer.style.position = "absolute";
@@ -167,14 +175,13 @@ function Scene(options) {
167
175
  this._creditContainer = creditContainer;
168
176
 
169
177
  this._canvas = canvas;
170
- this._context = context;
171
178
  this._computeEngine = new ComputeEngine(context);
172
179
 
173
180
  this._ellipsoid = options.ellipsoid ?? Ellipsoid.default;
174
181
  this._globe = undefined;
175
182
  this._globeTranslucencyState = new GlobeTranslucencyState();
176
- this._primitives = new PrimitiveCollection();
177
- this._groundPrimitives = new PrimitiveCollection();
183
+ this._primitives = new PrimitiveCollection({ countReferences });
184
+ this._groundPrimitives = new PrimitiveCollection({ countReferences });
178
185
 
179
186
  this._globeHeight = undefined;
180
187
  this._globeHeightDirty = true;
@@ -276,7 +283,7 @@ function Scene(options) {
276
283
  /**
277
284
  * The {@link SkyBox} used to draw the stars.
278
285
  *
279
- * @type {SkyBox}
286
+ * @type {SkyBox | undefined}
280
287
  * @default undefined
281
288
  *
282
289
  * @see Scene#backgroundColor
@@ -286,7 +293,7 @@ function Scene(options) {
286
293
  /**
287
294
  * The sky atmosphere drawn around the globe.
288
295
  *
289
- * @type {SkyAtmosphere}
296
+ * @type {SkyAtmosphere | undefined}
290
297
  * @default undefined
291
298
  */
292
299
  this.skyAtmosphere = undefined;
@@ -294,7 +301,7 @@ function Scene(options) {
294
301
  /**
295
302
  * The {@link Sun}.
296
303
  *
297
- * @type {Sun}
304
+ * @type {Sun | undefined}
298
305
  * @default undefined
299
306
  */
300
307
  this.sun = undefined;
@@ -311,13 +318,13 @@ function Scene(options) {
311
318
  /**
312
319
  * The {@link Moon}
313
320
  *
314
- * @type Moon
321
+ * @type {Moon | undefined}
315
322
  * @default undefined
316
323
  */
317
324
  this.moon = undefined;
318
325
 
319
326
  /**
320
- * The background color, which is only visible if there is no sky box, i.e., {@link Scene#skyBox} is undefined.
327
+ * The background color, which is only visible if there is no sky box, i.e., {@link Scene#skyBox} is <code>undefined</code>.
321
328
  *
322
329
  * @type {Color}
323
330
  * @default {@link Color.BLACK}
@@ -406,7 +413,7 @@ function Scene(options) {
406
413
  * The default is <code>undefined</code>, indicating that all commands are executed.
407
414
  * </p>
408
415
  *
409
- * @type Function
416
+ * @type {Function | undefined}
410
417
  *
411
418
  * @default undefined
412
419
  *
@@ -1306,11 +1313,11 @@ Object.defineProperties(Scene.prototype, {
1306
1313
  },
1307
1314
 
1308
1315
  /**
1309
- * Gets the simulation time when the scene was last rendered. Returns undefined if the scene has not yet been
1310
- * rendered.
1316
+ * Gets the simulation time when the scene was last rendered. Returns <code>undefined</code>
1317
+ * if the scene has not yet been rendered.
1311
1318
  * @memberof Scene.prototype
1312
1319
  *
1313
- * @type {JulianDate}
1320
+ * @type {JulianDate | undefined}
1314
1321
  * @readonly
1315
1322
  */
1316
1323
  lastRenderTime: {
@@ -1343,7 +1350,7 @@ Object.defineProperties(Scene.prototype, {
1343
1350
  *
1344
1351
  * @memberof Scene.prototype
1345
1352
  *
1346
- * @type {object}
1353
+ * @type {Object | undefined}
1347
1354
  * @readonly
1348
1355
  *
1349
1356
  * @default undefined
@@ -4202,6 +4209,8 @@ function render(scene) {
4202
4209
  passState.scissorTest = undefined;
4203
4210
  passState.viewport = BoundingRectangle.clone(viewport, passState.viewport);
4204
4211
 
4212
+ context.beginFrame();
4213
+
4205
4214
  if (defined(scene.globe)) {
4206
4215
  scene.globe.beginFrame(frameState);
4207
4216
  }
@@ -4371,8 +4380,8 @@ Scene.prototype.clampLineWidth = function (width) {
4371
4380
  };
4372
4381
 
4373
4382
  /**
4374
- * Returns an object with a `primitive` property that contains the first (top) primitive in the scene
4375
- * at a particular window coordinate or undefined if nothing is at the location. Other properties may
4383
+ * Returns an object with a <code>primitive</code> property that contains the first (top) primitive in the scene
4384
+ * at a particular window coordinate or <code>undefined</code> if nothing is at the location. Other properties may
4376
4385
  * potentially be set depending on the type of primitive and may be used to further identify the picked object.
4377
4386
  * <p>
4378
4387
  * When a feature of a 3D Tiles tileset is picked, <code>pick</code> returns a {@link Cesium3DTileFeature} object.
@@ -4390,7 +4399,7 @@ Scene.prototype.clampLineWidth = function (width) {
4390
4399
  * @param {Cartesian2} windowPosition Window coordinates to perform picking on.
4391
4400
  * @param {number} [width=3] Width of the pick rectangle.
4392
4401
  * @param {number} [height=3] Height of the pick rectangle.
4393
- * @returns {object} Object containing the picked primitive.
4402
+ * @returns {Object | undefined} Object containing the picked primitive or <code>undefined</code> if nothing is at the location.
4394
4403
  */
4395
4404
  Scene.prototype.pick = function (windowPosition, width, height) {
4396
4405
  return this._picking.pick(this, windowPosition, width, height);
@@ -4398,7 +4407,7 @@ Scene.prototype.pick = function (windowPosition, width, height) {
4398
4407
 
4399
4408
  /**
4400
4409
  * Returns a {@link VoxelCell} for the voxel sample rendered at a particular window coordinate,
4401
- * or undefined if no voxel is rendered at that position.
4410
+ * or <code>undefined</code> if no voxel is rendered at that position.
4402
4411
  *
4403
4412
  * @example
4404
4413
  * On left click, report the value of the "color" property at that voxel sample.
@@ -4412,7 +4421,7 @@ Scene.prototype.pick = function (windowPosition, width, height) {
4412
4421
  * @param {Cartesian2} windowPosition Window coordinates to perform picking on.
4413
4422
  * @param {number} [width=3] Width of the pick rectangle.
4414
4423
  * @param {number} [height=3] Height of the pick rectangle.
4415
- * @returns {VoxelCell|undefined} Information about the voxel cell rendered at the picked position.
4424
+ * @returns {VoxelCell|undefined} Information about the voxel cell rendered at the picked position or <code>undefined</code> if no voxel is rendered at that position.
4416
4425
  *
4417
4426
  * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
4418
4427
  */
@@ -4454,13 +4463,13 @@ Scene.prototype.pickVoxel = function (windowPosition, width, height) {
4454
4463
  *
4455
4464
  * @param {Cartesian2} windowPosition Window coordinates to perform picking on.
4456
4465
  * @param {string|undefined} schemaId The ID of the metadata schema to pick values
4457
- * from. If this is `undefined`, then it will pick the values from the object
4466
+ * from. If this is <code>undefined</code>, then it will pick the values from the object
4458
4467
  * that match the given class- and property name, regardless of the schema ID.
4459
4468
  * @param {string} className The name of the metadata class to pick
4460
4469
  * values from
4461
4470
  * @param {string} propertyName The name of the metadata property to pick
4462
4471
  * values from
4463
- * @returns {MetadataValue|undefined} The metadata value, or `undefined` when
4472
+ * @returns {MetadataValue|undefined} The metadata value, or <code>undefined</code> when
4464
4473
  * no matching metadata was found at the given position
4465
4474
  *
4466
4475
  * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
@@ -4529,7 +4538,7 @@ Scene.prototype.pickMetadata = function (
4529
4538
  * Pick the schema of the metadata of the object at the given position
4530
4539
  *
4531
4540
  * @param {Cartesian2} windowPosition Window coordinates to perform picking on.
4532
- * @returns {MetadataSchema} The metadata schema, or `undefined` if there is no object with
4541
+ * @returns {MetadataSchema | undefined} The metadata schema, or <code>undefined</code> if there is no object with
4533
4542
  * associated metadata at the given position.
4534
4543
  *
4535
4544
  * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
@@ -4598,7 +4607,7 @@ Scene.prototype.pickPosition = function (windowPosition, result) {
4598
4607
  };
4599
4608
 
4600
4609
  /**
4601
- * Returns a list of objects, each containing a `primitive` property, for all primitives at
4610
+ * Returns a list of objects, each containing a <code>primitive</code> property, for all primitives at
4602
4611
  * a particular window coordinate position. Other properties may also be set depending on the
4603
4612
  * type of primitive and may be used to further identify the picked object. The primitives in
4604
4613
  * the list are ordered by their visual order in the scene (front to back).
@@ -4667,7 +4676,7 @@ function updateRequestRenderModeDeferCheckPass(scene) {
4667
4676
  * @param {Ray} ray The ray.
4668
4677
  * @param {Object[]} [objectsToExclude] A list of primitives, entities, or 3D Tiles features to exclude from the ray intersection.
4669
4678
  * @param {number} [width=0.1] Width of the intersection volume in meters.
4670
- * @returns {object} An object containing the object and position of the first intersection.
4679
+ * @returns {object | undefined} An object containing the object and position of the first intersection or <code>undefined</code> if there are no intersections.
4671
4680
  *
4672
4681
  * @exception {DeveloperError} Ray intersections are only supported in 3D mode.
4673
4682
  */
@@ -4778,7 +4787,7 @@ Scene.prototype.drillPickFromRayMostDetailed = function (
4778
4787
  * @param {Cartographic} position The cartographic position to sample height from.
4779
4788
  * @param {Object[]} [objectsToExclude] A list of primitives, entities, or 3D Tiles features to not sample height from.
4780
4789
  * @param {number} [width=0.1] Width of the intersection volume in meters.
4781
- * @returns {number} The height. This may be <code>undefined</code> if there was no scene geometry to sample height from.
4790
+ * @returns {number | undefined} The height. This may be <code>undefined</code> if there was no scene geometry to sample height from.
4782
4791
  *
4783
4792
  * @example
4784
4793
  * const position = new Cesium.Cartographic(-1.31968, 0.698874);
@@ -4809,7 +4818,7 @@ Scene.prototype.sampleHeight = function (position, objectsToExclude, width) {
4809
4818
  * @param {Object[]} [objectsToExclude] A list of primitives, entities, or 3D Tiles features to not clamp to.
4810
4819
  * @param {number} [width=0.1] Width of the intersection volume in meters.
4811
4820
  * @param {Cartesian3} [result] An optional object to return the clamped position.
4812
- * @returns {Cartesian3} The modified result parameter or a new Cartesian3 instance if one was not provided. This may be <code>undefined</code> if there was no scene geometry to clamp to.
4821
+ * @returns {Cartesian3 | undefined} The modified result parameter or a new Cartesian3 instance if one was not provided. This may be <code>undefined</code> if there was no scene geometry to clamp to.
4813
4822
  *
4814
4823
  * @example
4815
4824
  * // Clamp an entity to the underlying scene geometry
@@ -4843,12 +4852,12 @@ Scene.prototype.clampToHeight = function (
4843
4852
  * using the maximum level of detail for 3D Tilesets in the scene. The height of the input positions is ignored.
4844
4853
  * Returns a promise that is resolved when the query completes. Each point height is modified in place.
4845
4854
  * If a height cannot be determined because no geometry can be sampled at that location, or another error occurs,
4846
- * the height is set to undefined.
4855
+ * the height is set to <code>undefined</code>.
4847
4856
  *
4848
4857
  * @param {Cartographic[]} positions The cartographic positions to update with sampled heights.
4849
4858
  * @param {Object[]} [objectsToExclude] A list of primitives, entities, or 3D Tiles features to not sample height from.
4850
4859
  * @param {number} [width=0.1] Width of the intersection volume in meters.
4851
- * @returns {Promise<Cartographic[]>} A promise that resolves to the provided list of positions when the query has completed.
4860
+ * @returns {Promise<Array<Cartographic | undefined>>} A promise that resolves to the provided list of positions when the query has completed. Positions may become <code>undefined</code> if the height cannot be determined.
4852
4861
  *
4853
4862
  * @example
4854
4863
  * const positions = [
@@ -4888,7 +4897,7 @@ Scene.prototype.sampleHeightMostDetailed = function (
4888
4897
  * @param {Cartesian3[]} cartesians The cartesian positions to update with clamped positions.
4889
4898
  * @param {Object[]} [objectsToExclude] A list of primitives, entities, or 3D Tiles features to not clamp to.
4890
4899
  * @param {number} [width=0.1] Width of the intersection volume in meters.
4891
- * @returns {Promise<Cartesian3[]>} A promise that resolves to the provided list of positions when the query has completed.
4900
+ * @returns {Promise<Array<Cartesian3 | undefined>>} A promise that resolves to the provided list of positions when the query has completed. Positions may become <code>undefined</code> if they cannot be clamped.
4892
4901
  *
4893
4902
  * @example
4894
4903
  * const cartesians = [
@@ -4925,7 +4934,7 @@ Scene.prototype.clampToHeightMostDetailed = function (
4925
4934
  *
4926
4935
  * @param {Cartesian3} position The position in cartesian coordinates.
4927
4936
  * @param {Cartesian2} [result] An optional object to return the input position transformed to canvas coordinates.
4928
- * @returns {Cartesian2} The modified result parameter or a new Cartesian2 instance if one was not provided. This may be <code>undefined</code> if the input position is near the center of the ellipsoid.
4937
+ * @returns {Cartesian2 | undefined} The modified result parameter or a new Cartesian2 instance if one was not provided. This may be <code>undefined</code> if the input position is near the center of the ellipsoid.
4929
4938
  *
4930
4939
  * @example
4931
4940
  * // Output the canvas position of longitude/latitude (0, 0) every time the mouse moves.
@@ -266,6 +266,8 @@ function ScreenSpaceCameraController(scene) {
266
266
  this._minimumTrackBallHeight = this.minimumTrackBallHeight;
267
267
  /**
268
268
  * When disabled, the values of <code>maximumZoomDistance</code> and <code>minimumZoomDistance</code> are ignored.
269
+ * Also used in conjunction with {@link Cesium3DTileset#enableCollision} to prevent the camera from moving through or below a 3D Tileset surface.
270
+ * This may also affect clamping behavior when using {@link HeightReference.CLAMP_TO_GROUND} on 3D Tiles.
269
271
  * @type {boolean}
270
272
  * @default true
271
273
  */
@@ -79,14 +79,14 @@ const VertexAttributeSemantic = {
79
79
  * @type {string}
80
80
  * @constant
81
81
  */
82
- SCALE: "_SCALE",
82
+ SCALE: "KHR_gaussian_splatting:SCALE",
83
83
  /**
84
84
  * Gaussian Splat Rotation
85
85
  *
86
86
  * @type {string}
87
87
  * @constant
88
88
  */
89
- ROTATION: "_ROTATION",
89
+ ROTATION: "KHR_gaussian_splatting:ROTATION",
90
90
  };
91
91
 
92
92
  function semanticToVariableName(semantic) {
@@ -192,8 +192,10 @@ VertexAttributeSemantic.fromGltfSemantic = function (gltfSemantic) {
192
192
  return VertexAttributeSemantic.WEIGHTS;
193
193
  case "_FEATURE_ID":
194
194
  return VertexAttributeSemantic.FEATURE_ID;
195
+ case "KHR_gaussian_splatting:SCALE":
195
196
  case "_SCALE":
196
197
  return VertexAttributeSemantic.SCALE;
198
+ case "KHR_gaussian_splatting:ROTATION":
197
199
  case "_ROTATION":
198
200
  return VertexAttributeSemantic.ROTATION;
199
201
  }
@@ -88,12 +88,13 @@ const excludesReverseAxis = [
88
88
  * @see WebMapTileServiceImageryProvider
89
89
  * @see UrlTemplateImageryProvider
90
90
  *
91
- * @see {@link http://resources.esri.com/help/9.3/arcgisserver/apis/rest/|ArcGIS Server REST API}
91
+ * @see {@link https://enterprise.arcgis.com/en/server/latest/publish-services/linux/wms-services.htm|ArcGIS Server WMS Services}
92
92
  * @see {@link http://www.w3.org/TR/cors/|Cross-Origin Resource Sharing}
93
93
  *
94
94
  * @example
95
+ * // WMS servers operated by the US government https://apps.nationalmap.gov/services/
95
96
  * const provider = new Cesium.WebMapServiceImageryProvider({
96
- * url : 'https://sampleserver1.arcgisonline.com/ArcGIS/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/WMSServer',
97
+ * url : 'https://basemap.nationalmap.gov:443/arcgis/services/USGSHydroCached/MapServer/WMSServer',
97
98
  * layers : '0',
98
99
  * proxy: new Cesium.DefaultProxy('/proxy/')
99
100
  * });
@@ -4,7 +4,6 @@ import Frozen from "../Core/Frozen.js";
4
4
  import defined from "../Core/defined.js";
5
5
  import DeveloperError from "../Core/DeveloperError.js";
6
6
  import Event from "../Core/Event.js";
7
- import Rectangle from "../Core/Rectangle.js";
8
7
  import Resource from "../Core/Resource.js";
9
8
  import WebMercatorTilingScheme from "../Core/WebMercatorTilingScheme.js";
10
9
  import ImageryProvider from "./ImageryProvider.js";
@@ -208,27 +207,6 @@ function WebMapTileServiceImageryProvider(options) {
208
207
  });
209
208
  }
210
209
 
211
- // Check the number of tiles at the minimum level. If it's more than four,
212
- // throw an exception, because starting at the higher minimum
213
- // level will cause too many tiles to be downloaded and rendered.
214
- const swTile = this._tilingScheme.positionToTileXY(
215
- Rectangle.southwest(this._rectangle),
216
- this._minimumLevel,
217
- );
218
- const neTile = this._tilingScheme.positionToTileXY(
219
- Rectangle.northeast(this._rectangle),
220
- this._minimumLevel,
221
- );
222
- const tileCount =
223
- (Math.abs(neTile.x - swTile.x) + 1) * (Math.abs(neTile.y - swTile.y) + 1);
224
- //>>includeStart('debug', pragmas.debug);
225
- if (tileCount > 4) {
226
- throw new DeveloperError(
227
- `The imagery provider's rectangle and minimumLevel indicate that there are ${tileCount} tiles at the minimum level. Imagery providers with more than four tiles at the minimum level are not supported.`,
228
- );
229
- }
230
- //>>includeEnd('debug');
231
-
232
210
  this._errorEvent = new Event();
233
211
 
234
212
  const credit = options.credit;
@@ -0,0 +1,72 @@
1
+ import addAllToArray from "../Core/addAllToArray.js";
2
+ import defined from "../Core/defined.js";
3
+ import Frozen from "../Core/Frozen.js";
4
+ import WebGLConstants from "../Core/WebGLConstants.js";
5
+
6
+ /**
7
+ * Get an array of primitives for a given mesh. If the EXT_mesh_primitive_restart extension is present, use it to combine groups of primitives.
8
+ * If the extension is not present or its spec is violated, return the original mesh.primitives.
9
+ * @param {object} mesh A mesh from the glTF meshes array
10
+ * @returns {object[]} An array of mesh primitives
11
+ * @private
12
+ */
13
+ function getMeshPrimitives(mesh) {
14
+ const meshExtensions = mesh.extensions ?? Frozen.EMPTY_OBJECT;
15
+ const primitiveRestartExtension = meshExtensions.EXT_mesh_primitive_restart;
16
+ const meshPrimitives = mesh.primitives;
17
+
18
+ if (!defined(primitiveRestartExtension)) {
19
+ return meshPrimitives;
20
+ }
21
+
22
+ // Note: per the spec, any violation of the extension's specification should cause us to fall back to mesh.primitives, if detecting the violation is feasible.
23
+
24
+ // Start with a copy of mesh.primitives. For each group, replace the first primitive in the group with a primitive representing the entire group,
25
+ // and set the rest of the primitives in the group to `undefined`.
26
+ // This allows us to identify which remaining primitives do not use primitive restart, and any errors involving a primitive appearing in more than one group.
27
+ const primitives = [];
28
+ addAllToArray(primitives, meshPrimitives);
29
+ for (const group of primitiveRestartExtension.primitiveGroups) {
30
+ // Spec: the group must not be empty and all indices must be valid array indices into mesh.primitives.
31
+ const firstPrimitiveIndex = group.primitives[0];
32
+ if (!defined(firstPrimitiveIndex) || !meshPrimitives[firstPrimitiveIndex]) {
33
+ return meshPrimitives;
34
+ }
35
+
36
+ const primitive = {
37
+ ...meshPrimitives[firstPrimitiveIndex],
38
+ indices: group.indices,
39
+ };
40
+
41
+ // Spec: primitive restart only supported for these topologies.
42
+ switch (primitive.mode) {
43
+ case WebGLConstants.TRIANGLE_FAN:
44
+ case WebGLConstants.TRIANGLE_STRIP:
45
+ case WebGLConstants.LINE_STRIP:
46
+ case WebGLConstants.LINE_LOOP:
47
+ break;
48
+ default:
49
+ return meshPrimitives;
50
+ }
51
+
52
+ for (const primitiveIndex of group.primitives) {
53
+ const thisPrimitive = primitives[primitiveIndex];
54
+
55
+ // Spec: all primitives must use indexed geometry and a given primitive may appear in at most one group.
56
+ // Spec: all primitives must have same topology.
57
+ if (
58
+ !defined(thisPrimitive?.indices) ||
59
+ thisPrimitive.mode !== primitive.mode
60
+ ) {
61
+ return meshPrimitives;
62
+ }
63
+
64
+ primitives[primitiveIndex] = undefined;
65
+ }
66
+
67
+ primitives[firstPrimitiveIndex] = primitive;
68
+ }
69
+
70
+ return primitives.filter(defined);
71
+ }
72
+ export default getMeshPrimitives;
@@ -30,7 +30,8 @@
30
30
  */
31
31
  vec4 czm_modelToWindowCoordinates(vec4 position)
32
32
  {
33
- vec4 q = czm_modelViewProjection * position; // clip coordinates
33
+ vec4 positionEC = czm_modelView * position;
34
+ vec4 q = czm_projection * positionEC;
34
35
  q.xyz /= q.w; // normalized device coordinates
35
36
  q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates
36
37
  return q;
@@ -31,7 +31,8 @@ export default "/**\n\
31
31
  */\n\
32
32
  vec4 czm_modelToWindowCoordinates(vec4 position)\n\
33
33
  {\n\
34
- vec4 q = czm_modelViewProjection * position; // clip coordinates\n\
34
+ vec4 positionEC = czm_modelView * position;\n\
35
+ vec4 q = czm_projection * positionEC;\n\
35
36
  q.xyz /= q.w; // normalized device coordinates\n\
36
37
  q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates\n\
37
38
  return q;\n\
@@ -11,10 +11,10 @@ void main()
11
11
  // but doing it here allows us to change the radii without rewriting the vertex data, and
12
12
  // allows all ellipsoids to reuse the same vertex data.
13
13
  vec4 p = vec4(u_radii * position, 1.0);
14
-
15
- v_positionEC = (czm_modelView * p).xyz; // position in eye coordinates
16
- gl_Position = czm_modelViewProjection * p; // position in clip coordinates
17
-
14
+
15
+ vec4 pEC = czm_modelView * p;
16
+ v_positionEC = pEC.xyz; // position in eye coordinates
17
+ gl_Position = czm_projection * pEC;
18
18
  // With multi-frustum, when the ellipsoid primitive is positioned on the intersection of two frustums
19
19
  // and close to terrain, the terrain (writes depth) in the closest frustum can overwrite part of the
20
20
  // ellipsoid (does not write depth) that was rendered in the farther frustum.