@cesium/engine 18.3.1-ion.0 → 19.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 (171) hide show
  1. package/Build/ThirdParty/Workers/z-worker-pako.js +75 -91
  2. package/Build/Workers/{chunk-VOGSSU24.js → chunk-23FRF5ZP.js} +9 -9
  3. package/Build/Workers/{chunk-AZK5KSZ4.js → chunk-25USKS4R.js} +6 -6
  4. package/Build/Workers/{chunk-4B4HLHFO.js → chunk-34DFERFC.js} +12 -12
  5. package/Build/Workers/{chunk-HTB5PIYZ.js → chunk-37IYBZDZ.js} +9 -9
  6. package/Build/Workers/{chunk-NZVPOOOT.js → chunk-4NRFVAG2.js} +5 -5
  7. package/Build/Workers/{chunk-QXOWDZYZ.js → chunk-4QWLEG4L.js} +14 -14
  8. package/Build/Workers/{chunk-XW6DEZZE.js → chunk-5VPO47LB.js} +8 -8
  9. package/Build/Workers/{chunk-FKO2XRXZ.js → chunk-5YCDPN3O.js} +1 -1
  10. package/Build/Workers/{chunk-HRF2GFMF.js → chunk-6T2PQKYP.js} +4 -4
  11. package/Build/Workers/{chunk-IDHHSZTD.js → chunk-AABNX23Q.js} +5 -5
  12. package/Build/Workers/{chunk-6FY4D6KD.js → chunk-AZPKFL5X.js} +5 -5
  13. package/Build/Workers/{chunk-HQCLIHYE.js → chunk-C36VNKTH.js} +4 -4
  14. package/Build/Workers/{chunk-AX3B4SGH.js → chunk-DAHXCIOX.js} +8 -8
  15. package/Build/Workers/{chunk-QKYGO6XL.js → chunk-DNCRKMCI.js} +6 -6
  16. package/Build/Workers/{chunk-S2BFGC4W.js → chunk-DPFAUGBE.js} +2 -2
  17. package/Build/Workers/{chunk-ADA7OX2I.js → chunk-DXYAD4ED.js} +1 -1
  18. package/Build/Workers/{chunk-Z2GDV3MT.js → chunk-E6NMEKSS.js} +4 -4
  19. package/Build/Workers/{chunk-52DTHTKR.js → chunk-ECWQXDZY.js} +16 -16
  20. package/Build/Workers/{chunk-NGFYQUAX.js → chunk-ESDVZ4QL.js} +10 -10
  21. package/Build/Workers/{chunk-BF2HFWMG.js → chunk-ETCPCGKC.js} +2 -2
  22. package/Build/Workers/{chunk-SKVVOFGK.js → chunk-EV4PBU7O.js} +1 -1
  23. package/Build/Workers/{chunk-XLDLCV2F.js → chunk-FQNSMOZT.js} +4 -4
  24. package/Build/Workers/{chunk-76WKZOUK.js → chunk-GO3IRH6U.js} +6 -6
  25. package/Build/Workers/{chunk-UXCG22U4.js → chunk-GVO3YIU2.js} +4 -4
  26. package/Build/Workers/{chunk-SMLHKQNB.js → chunk-HHHBRTSW.js} +9 -9
  27. package/Build/Workers/{chunk-UHLWUS37.js → chunk-HJ6KFRM7.js} +16 -16
  28. package/Build/Workers/{chunk-JUYK3CDA.js → chunk-IE2BEHLE.js} +12 -12
  29. package/Build/Workers/{chunk-IYXAFSJX.js → chunk-JZVUMRYA.js} +13 -13
  30. package/Build/Workers/{chunk-E7KSST7M.js → chunk-K5VGMGFM.js} +7 -7
  31. package/Build/Workers/{chunk-DILVD7VK.js → chunk-KTDHOEXR.js} +1 -1
  32. package/Build/Workers/{chunk-TLR6NX6R.js → chunk-MBDKO456.js} +5 -5
  33. package/Build/Workers/{chunk-WMSBRWGI.js → chunk-MUL374P3.js} +2 -2
  34. package/Build/Workers/{chunk-QREBKKN5.js → chunk-NKM2EV46.js} +1 -1
  35. package/Build/Workers/{chunk-2XJLU3UN.js → chunk-NMAT4IJ6.js} +7 -7
  36. package/Build/Workers/{chunk-7G2O6QH3.js → chunk-PAH73ETP.js} +5 -5
  37. package/Build/Workers/{chunk-G2VBRELF.js → chunk-Q2QXUN33.js} +2 -2
  38. package/Build/Workers/{chunk-B3LHDD7Q.js → chunk-RIQM3XY5.js} +4 -4
  39. package/Build/Workers/{chunk-ILTPHRDS.js → chunk-RZJA77TX.js} +6 -6
  40. package/Build/Workers/{chunk-MIUZNGES.js → chunk-SO2Z6H6F.js} +2 -2
  41. package/Build/Workers/{chunk-UX2S2KIQ.js → chunk-SOYVF5RC.js} +2 -2
  42. package/Build/Workers/{chunk-VFEUHPSM.js → chunk-SVGHDIZG.js} +5 -5
  43. package/Build/Workers/{chunk-NL2YZDVI.js → chunk-SXMHGVZ7.js} +12 -12
  44. package/Build/Workers/{chunk-S2JHBHWB.js → chunk-T7C73J6H.js} +4 -4
  45. package/Build/Workers/{chunk-KGB6H3RI.js → chunk-UPU755HO.js} +12 -12
  46. package/Build/Workers/{chunk-IHRAESIS.js → chunk-VCCR35R6.js} +11 -11
  47. package/Build/Workers/{chunk-QMKOMHVM.js → chunk-W32QSECR.js} +6 -6
  48. package/Build/Workers/{chunk-3UEVA4NO.js → chunk-WUMTX3FI.js} +6 -6
  49. package/Build/Workers/{chunk-2Y2IF6ZP.js → chunk-XUYCCEG6.js} +5 -5
  50. package/Build/Workers/{chunk-Q6SJKTTQ.js → chunk-Y3PM6G2V.js} +3 -3
  51. package/Build/Workers/{chunk-FBPIDRZN.js → chunk-Y6LLFNXN.js} +10 -10
  52. package/Build/Workers/{chunk-ERTHACXD.js → chunk-YPNIIVIF.js} +6 -6
  53. package/Build/Workers/{chunk-EZUKH7KU.js → chunk-ZNEIUXBK.js} +7 -7
  54. package/Build/Workers/combineGeometry.js +21 -21
  55. package/Build/Workers/createBoxGeometry.js +15 -15
  56. package/Build/Workers/createBoxOutlineGeometry.js +13 -13
  57. package/Build/Workers/createCircleGeometry.js +23 -23
  58. package/Build/Workers/createCircleOutlineGeometry.js +16 -16
  59. package/Build/Workers/createCoplanarPolygonGeometry.js +30 -30
  60. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +28 -28
  61. package/Build/Workers/createCorridorGeometry.js +26 -26
  62. package/Build/Workers/createCorridorOutlineGeometry.js +25 -25
  63. package/Build/Workers/createCylinderGeometry.js +17 -17
  64. package/Build/Workers/createCylinderOutlineGeometry.js +15 -15
  65. package/Build/Workers/createEllipseGeometry.js +23 -23
  66. package/Build/Workers/createEllipseOutlineGeometry.js +16 -16
  67. package/Build/Workers/createEllipsoidGeometry.js +16 -16
  68. package/Build/Workers/createEllipsoidOutlineGeometry.js +15 -15
  69. package/Build/Workers/createFrustumGeometry.js +15 -15
  70. package/Build/Workers/createFrustumOutlineGeometry.js +15 -15
  71. package/Build/Workers/createGeometry.js +21 -21
  72. package/Build/Workers/createGroundPolylineGeometry.js +19 -19
  73. package/Build/Workers/createPlaneGeometry.js +13 -13
  74. package/Build/Workers/createPlaneOutlineGeometry.js +12 -12
  75. package/Build/Workers/createPolygonGeometry.js +29 -29
  76. package/Build/Workers/createPolygonOutlineGeometry.js +27 -27
  77. package/Build/Workers/createPolylineGeometry.js +22 -22
  78. package/Build/Workers/createPolylineVolumeGeometry.js +28 -28
  79. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +24 -24
  80. package/Build/Workers/createRectangleGeometry.js +24 -24
  81. package/Build/Workers/createRectangleOutlineGeometry.js +17 -17
  82. package/Build/Workers/createSimplePolylineGeometry.js +20 -20
  83. package/Build/Workers/createSphereGeometry.js +16 -16
  84. package/Build/Workers/createSphereOutlineGeometry.js +15 -15
  85. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  86. package/Build/Workers/createVectorTileClampedPolylines.js +12 -12
  87. package/Build/Workers/createVectorTileGeometries.js +21 -21
  88. package/Build/Workers/createVectorTilePoints.js +11 -11
  89. package/Build/Workers/createVectorTilePolygons.js +19 -19
  90. package/Build/Workers/createVectorTilePolylines.js +12 -12
  91. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +19 -19
  92. package/Build/Workers/createVerticesFromHeightmap.js +19 -19
  93. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +16 -16
  94. package/Build/Workers/createWallGeometry.js +21 -21
  95. package/Build/Workers/createWallOutlineGeometry.js +20 -20
  96. package/Build/Workers/decodeDraco.js +10 -10
  97. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  98. package/Build/Workers/decodeI3S.js +9 -9
  99. package/Build/Workers/gaussianSplatSorter.js +4 -4
  100. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  101. package/Build/Workers/transcodeKTX2.js +6 -6
  102. package/Build/Workers/transferTypedArrayTest.js +1 -1
  103. package/Build/Workers/upsampleQuantizedTerrainMesh.js +19 -19
  104. package/LICENSE.md +32 -25
  105. package/Source/Core/ITwinPlatform.js +8 -1
  106. package/Source/Core/Ion.js +1 -1
  107. package/Source/Core/ScreenSpaceEventHandler.js +3 -3
  108. package/Source/Core/addAllToArray.js +40 -0
  109. package/Source/DataSources/StaticGroundGeometryPerMaterialBatch.js +54 -26
  110. package/Source/Renderer/Context.js +8 -4
  111. package/Source/Renderer/Renderbuffer.js +4 -2
  112. package/Source/Renderer/Sampler.js +13 -0
  113. package/Source/Renderer/ShaderBuilder.js +7 -6
  114. package/Source/Renderer/SharedContext.js +186 -0
  115. package/Source/Renderer/Texture.js +4 -5
  116. package/Source/Renderer/Texture3D.js +17 -7
  117. package/Source/Scene/ArcGisMapService.js +1 -1
  118. package/Source/Scene/BillboardCollection.js +1 -1
  119. package/Source/Scene/Cesium3DTileBatchTable.js +6 -4
  120. package/Source/Scene/Cesium3DTileStyle.js +4 -3
  121. package/Source/Scene/Cesium3DTileset.js +1 -1
  122. package/Source/Scene/ConditionsExpression.js +3 -2
  123. package/Source/Scene/GaussianSplatPrimitive.js +1 -1
  124. package/Source/Scene/GltfLoader.js +3 -2
  125. package/Source/Scene/GltfPipeline/ForEach.js +7 -7
  126. package/Source/Scene/GltfPipeline/addDefaults.js +1 -2
  127. package/Source/Scene/GltfPipeline/addToArray.js +2 -0
  128. package/Source/Scene/GltfPipeline/findAccessorMinMax.js +1 -1
  129. package/Source/Scene/GltfPipeline/getComponentReader.js +16 -16
  130. package/Source/Scene/GltfPipeline/moveTechniqueRenderStates.js +1 -1
  131. package/Source/Scene/GltfPipeline/moveTechniquesToExtension.js +3 -3
  132. package/Source/Scene/GltfPipeline/parseGlb.js +1 -1
  133. package/Source/Scene/GltfPipeline/readAccessorPacked.js +2 -2
  134. package/Source/Scene/GltfPipeline/removeUnusedElements.js +5 -6
  135. package/Source/Scene/GltfPipeline/updateAccessorComponentTypes.js +1 -1
  136. package/Source/Scene/GltfPipeline/updateVersion.js +13 -13
  137. package/Source/Scene/GltfSpzLoader.js +3 -1
  138. package/Source/Scene/HeightReference.js +1 -1
  139. package/Source/Scene/ITwinData.js +97 -34
  140. package/Source/Scene/ImageBasedLighting.js +6 -2
  141. package/Source/Scene/ImageryLayer.js +10 -10
  142. package/Source/Scene/MetadataTableProperty.js +2 -1
  143. package/Source/Scene/Model/ClassificationModelDrawCommand.js +7 -6
  144. package/Source/Scene/Model/GeoJsonLoader.js +3 -1
  145. package/Source/Scene/Model/ImageryConfiguration.js +1 -0
  146. package/Source/Scene/Model/ImageryPipelineStage.js +8 -2
  147. package/Source/Scene/Model/InstancingPipelineStage.js +3 -8
  148. package/Source/Scene/Model/MaterialPipelineStage.js +10 -1
  149. package/Source/Scene/Model/ModelImagery.js +3 -0
  150. package/Source/Scene/Model/ModelSceneGraph.js +2 -1
  151. package/Source/Scene/Picking.js +41 -1
  152. package/Source/Scene/Primitive.js +0 -1
  153. package/Source/Scene/PrimitiveCollection.js +32 -6
  154. package/Source/Scene/PrimitiveLoadPlan.js +0 -36
  155. package/Source/Scene/PropertyTable.js +7 -12
  156. package/Source/Scene/Scene.js +41 -32
  157. package/Source/Scene/ScreenSpaceCameraController.js +2 -0
  158. package/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.glsl +2 -1
  159. package/Source/Shaders/Builtin/Functions/modelToWindowCoordinates.js +2 -1
  160. package/Source/Shaders/EllipsoidVS.glsl +4 -4
  161. package/Source/Shaders/EllipsoidVS.js +4 -4
  162. package/Source/Shaders/FXAA3_11.glsl +2 -0
  163. package/Source/Shaders/FXAA3_11.js +2 -0
  164. package/Source/Shaders/GlobeVS.glsl +2 -1
  165. package/Source/Shaders/GlobeVS.js +2 -1
  166. package/Source/Shaders/SkyAtmosphereVS.glsl +2 -1
  167. package/Source/Shaders/SkyAtmosphereVS.js +2 -1
  168. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  169. package/index.d.ts +82 -53
  170. package/index.js +244 -242
  171. package/package.json +3 -3
@@ -23,24 +23,18 @@ function Batch(
23
23
  usingSphericalTextureCoordinates,
24
24
  zIndex,
25
25
  ) {
26
- this.primitives = primitives; // scene level primitive collection
26
+ this.primitives = primitives; // scene level primitive collection (each Batch manages its own Primitive from this collection)
27
27
  this.classificationType = classificationType;
28
28
  this.appearanceType = appearanceType;
29
29
  this.materialProperty = materialProperty;
30
- this.updaters = new AssociativeArray();
30
+ this.updaters = new AssociativeArray(); // GeometryUpdaters that manage the visual representation of the primitive.
31
31
  this.createPrimitive = true;
32
32
  this.primitive = undefined; // a GroundPrimitive encapsulating all the entities
33
- this.oldPrimitive = undefined;
33
+ this.oldPrimitive = undefined; // a GroundPrimitive that is being replaced by the current primitive, but will still be shown until the current primitive is ready.
34
34
  this.geometry = new AssociativeArray();
35
35
  this.material = undefined;
36
36
  this.updatersWithAttributes = new AssociativeArray();
37
37
  this.attributes = new AssociativeArray();
38
- this.invalidated = false;
39
- this.removeMaterialSubscription =
40
- materialProperty.definitionChanged.addEventListener(
41
- Batch.prototype.onMaterialChanged,
42
- this,
43
- );
44
38
  this.subscriptions = new AssociativeArray();
45
39
  this.showsUpdated = new AssociativeArray();
46
40
  this.usingSphericalTextureCoordinates = usingSphericalTextureCoordinates;
@@ -48,10 +42,6 @@ function Batch(
48
42
  this.rectangleCollisionCheck = new RectangleCollisionChecker();
49
43
  }
50
44
 
51
- Batch.prototype.onMaterialChanged = function () {
52
- this.invalidated = true;
53
- };
54
-
55
45
  Batch.prototype.overlapping = function (rectangle) {
56
46
  return this.rectangleCollisionCheck.collides(rectangle);
57
47
  };
@@ -71,6 +61,13 @@ Batch.prototype.isMaterial = function (updater) {
71
61
  return defined(material) && material.equals(updaterMaterial);
72
62
  };
73
63
 
64
+ /**
65
+ * Adds an updater to the Batch, and signals for a new Primitive to be created on the next update.
66
+ * @param {JulianDate} time
67
+ * @param {GeometryUpdater} updater
68
+ * @param {GeometryInstance} geometryInstance
69
+ * @private
70
+ */
74
71
  Batch.prototype.add = function (time, updater, geometryInstance) {
75
72
  const id = updater.id;
76
73
  this.updaters.set(id, updater);
@@ -100,6 +97,13 @@ Batch.prototype.add = function (time, updater, geometryInstance) {
100
97
  this.createPrimitive = true;
101
98
  };
102
99
 
100
+ /**
101
+ * Remove an updater from the Batch, and potentially signals for a new Primitive to be created
102
+ * on the next update.
103
+ * @param {GeometryUpdater} updater
104
+ * @returns true if the updater was removed, false if it was not found.
105
+ * @private
106
+ */
103
107
  Batch.prototype.remove = function (updater) {
104
108
  const id = updater.id;
105
109
  const geometryInstance = this.geometry.get(id);
@@ -120,6 +124,13 @@ Batch.prototype.remove = function (updater) {
120
124
  return false;
121
125
  };
122
126
 
127
+ /**
128
+ * Update a Batch, creating a new primitive, if necessary, or swapping out an old primitive for a new one that's ready.
129
+ * A new primitive is created whenever an updater is added to or removed from a Batch.
130
+ * @param {JulianDate} time
131
+ * @returns a boolean indicating whether the Batch was updated.
132
+ * @private
133
+ */
123
134
  Batch.prototype.update = function (time) {
124
135
  let isUpdated = true;
125
136
  let primitive = this.primitive;
@@ -295,6 +306,10 @@ Batch.prototype.getBoundingSphere = function (updater, result) {
295
306
  return BoundingSphereState.DONE;
296
307
  };
297
308
 
309
+ /**
310
+ * Removes a Batch's primitive (and oldPrimitive, if it exists).
311
+ * @private
312
+ */
298
313
  Batch.prototype.destroy = function () {
299
314
  const primitive = this.primitive;
300
315
  const primitives = this.primitives;
@@ -305,10 +320,11 @@ Batch.prototype.destroy = function () {
305
320
  if (defined(oldPrimitive)) {
306
321
  primitives.remove(oldPrimitive);
307
322
  }
308
- this.removeMaterialSubscription();
309
323
  };
310
324
 
311
325
  /**
326
+ * A container of Batch objects of ground geometry primitives, where a Batch is grouped by material,
327
+ * texture coordinate type, and spatial overlap.
312
328
  * @private
313
329
  */
314
330
  function StaticGroundGeometryPerMaterialBatch(
@@ -316,12 +332,20 @@ function StaticGroundGeometryPerMaterialBatch(
316
332
  classificationType,
317
333
  appearanceType,
318
334
  ) {
319
- this._items = [];
320
- this._primitives = primitives;
335
+ this._items = []; // array of Batch objects, each containing representing a primitive and a set of updaters that manage the visual representation of the primitive.
336
+ this._primitives = primitives; // scene level primitive collection
321
337
  this._classificationType = classificationType;
322
338
  this._appearanceType = appearanceType;
323
339
  }
324
340
 
341
+ /**
342
+ * Adds an geometry updater to a Batch. Tries to find a preexisting compatible Batch, or else creates a new Batch.
343
+ * Used by Visualizer classes to add and update (remove->add) a primitive's Updater set.
344
+ *
345
+ * @param {JulianDate} time
346
+ * @param {GeometryUpdater} updater A GeometryUpdater that manages the visual representation of a primitive.
347
+ * @private
348
+ */
325
349
  StaticGroundGeometryPerMaterialBatch.prototype.add = function (time, updater) {
326
350
  const items = this._items;
327
351
  const length = items.length;
@@ -361,21 +385,30 @@ StaticGroundGeometryPerMaterialBatch.prototype.add = function (time, updater) {
361
385
  items.push(batch);
362
386
  };
363
387
 
388
+ /**
389
+ * Removes an updater from a Batch. Defers potential deletion until the next update.
390
+ * @param {GeometryUpdater} updater A GeometryUpdater that manages the visual representation of a primitive.
391
+ * @private
392
+ */
364
393
  StaticGroundGeometryPerMaterialBatch.prototype.remove = function (updater) {
365
394
  const items = this._items;
366
395
  const length = items.length;
367
396
  for (let i = length - 1; i >= 0; i--) {
368
397
  const item = items[i];
369
398
  if (item.remove(updater)) {
370
- if (item.updaters.length === 0) {
371
- items.splice(i, 1);
372
- item.destroy();
373
- }
399
+ // If the item is now empty, delete it (deferred until the next update,
400
+ // in case a new updater is added to the same item first).
374
401
  break;
375
402
  }
376
403
  }
377
404
  };
378
405
 
406
+ /**
407
+ * Updates all the items (Batches) in the collection, and deletes any that are empty.
408
+ * @param {JulianDate} time
409
+ * @returns a boolean indicating whether any of the items (Batches) were updated.
410
+ * @private
411
+ */
379
412
  StaticGroundGeometryPerMaterialBatch.prototype.update = function (time) {
380
413
  let i;
381
414
  const items = this._items;
@@ -383,13 +416,8 @@ StaticGroundGeometryPerMaterialBatch.prototype.update = function (time) {
383
416
 
384
417
  for (i = length - 1; i >= 0; i--) {
385
418
  const item = items[i];
386
- if (item.invalidated) {
419
+ if (item.updaters.length === 0) {
387
420
  items.splice(i, 1);
388
- const updaters = item.updaters.values;
389
- const updatersLength = updaters.length;
390
- for (let h = 0; h < updatersLength; h++) {
391
- this.add(time, updaters[h]);
392
- }
393
421
  item.destroy();
394
422
  }
395
423
  }
@@ -1415,6 +1415,10 @@ Context.prototype.draw = function (
1415
1415
  continueDraw(this, drawCommand, shaderProgram, uniformMap);
1416
1416
  };
1417
1417
 
1418
+ Context.prototype.beginFrame = function () {
1419
+ // A no-op. Overridden when drawing to a SharedContext.
1420
+ };
1421
+
1418
1422
  Context.prototype.endFrame = function () {
1419
1423
  const gl = this._gl;
1420
1424
  gl.useProgram(null);
@@ -1442,8 +1446,8 @@ Context.prototype.endFrame = function () {
1442
1446
  * @param {object} readState An object with the following properties:
1443
1447
  * @param {number} [readState.x=0] The x offset of the rectangle to read from.
1444
1448
  * @param {number} [readState.y=0] The y offset of the rectangle to read from.
1445
- * @param {number} [readState.width=gl.drawingBufferWidth] The width of the rectangle to read from.
1446
- * @param {number} [readState.height=gl.drawingBufferHeight] The height of the rectangle to read from.
1449
+ * @param {number} [readState.width=this.drawingBufferWidth] The width of the rectangle to read from.
1450
+ * @param {number} [readState.height=this.drawingBufferHeight] The height of the rectangle to read from.
1447
1451
  * @param {Framebuffer} [readState.framebuffer] The framebuffer to read from. If undefined, the read will be from the default framebuffer.
1448
1452
  * @returns {Uint8Array|Uint16Array|Float32Array|Uint32Array} The pixels in the specified rectangle.
1449
1453
  */
@@ -1453,8 +1457,8 @@ Context.prototype.readPixels = function (readState) {
1453
1457
  readState = readState ?? Frozen.EMPTY_OBJECT;
1454
1458
  const x = Math.max(readState.x ?? 0, 0);
1455
1459
  const y = Math.max(readState.y ?? 0, 0);
1456
- const width = readState.width ?? gl.drawingBufferWidth;
1457
- const height = readState.height ?? gl.drawingBufferHeight;
1460
+ const width = readState.width ?? this.drawingBufferWidth;
1461
+ const height = readState.height ?? this.drawingBufferHeight;
1458
1462
  const framebuffer = readState.framebuffer;
1459
1463
 
1460
1464
  //>>includeStart('debug', pragmas.debug);
@@ -21,10 +21,12 @@ function Renderbuffer(options) {
21
21
  const maximumRenderbufferSize = ContextLimits.maximumRenderbufferSize;
22
22
 
23
23
  const format = options.format ?? RenderbufferFormat.RGBA4;
24
- const width = defined(options.width) ? options.width : gl.drawingBufferWidth;
24
+ const width = defined(options.width)
25
+ ? options.width
26
+ : context.drawingBufferWidth;
25
27
  const height = defined(options.height)
26
28
  ? options.height
27
- : gl.drawingBufferHeight;
29
+ : context.drawingBufferHeight;
28
30
  const numSamples = options.numSamples ?? 1;
29
31
 
30
32
  //>>includeStart('debug', pragmas.debug);
@@ -13,6 +13,7 @@ function Sampler(options) {
13
13
  options = options ?? Frozen.EMPTY_OBJECT;
14
14
 
15
15
  const {
16
+ wrapR = TextureWrap.CLAMP_TO_EDGE,
16
17
  wrapS = TextureWrap.CLAMP_TO_EDGE,
17
18
  wrapT = TextureWrap.CLAMP_TO_EDGE,
18
19
  minificationFilter = TextureMinificationFilter.LINEAR,
@@ -21,6 +22,10 @@ function Sampler(options) {
21
22
  } = options;
22
23
 
23
24
  //>>includeStart('debug', pragmas.debug);
25
+ if (!TextureWrap.validate(wrapR)) {
26
+ throw new DeveloperError("Invalid sampler.wrapR.");
27
+ }
28
+
24
29
  if (!TextureWrap.validate(wrapS)) {
25
30
  throw new DeveloperError("Invalid sampler.wrapS.");
26
31
  }
@@ -44,6 +49,7 @@ function Sampler(options) {
44
49
  );
45
50
  //>>includeEnd('debug');
46
51
 
52
+ this._wrapR = wrapR;
47
53
  this._wrapS = wrapS;
48
54
  this._wrapT = wrapT;
49
55
  this._minificationFilter = minificationFilter;
@@ -52,6 +58,11 @@ function Sampler(options) {
52
58
  }
53
59
 
54
60
  Object.defineProperties(Sampler.prototype, {
61
+ wrapR: {
62
+ get: function () {
63
+ return this._wrapR;
64
+ },
65
+ },
55
66
  wrapS: {
56
67
  get: function () {
57
68
  return this._wrapS;
@@ -84,6 +95,7 @@ Sampler.equals = function (left, right) {
84
95
  left === right ||
85
96
  (defined(left) &&
86
97
  defined(right) &&
98
+ left._wrapR === right._wrapR &&
87
99
  left._wrapS === right._wrapS &&
88
100
  left._wrapT === right._wrapT &&
89
101
  left._minificationFilter === right._minificationFilter &&
@@ -94,6 +106,7 @@ Sampler.equals = function (left, right) {
94
106
 
95
107
  Sampler.NEAREST = Object.freeze(
96
108
  new Sampler({
109
+ wrapR: TextureWrap.CLAMP_TO_EDGE,
97
110
  wrapS: TextureWrap.CLAMP_TO_EDGE,
98
111
  wrapT: TextureWrap.CLAMP_TO_EDGE,
99
112
  minificationFilter: TextureMinificationFilter.NEAREST,
@@ -7,6 +7,7 @@ import ShaderProgram from "./ShaderProgram.js";
7
7
  import ShaderSource from "./ShaderSource.js";
8
8
  import ShaderStruct from "./ShaderStruct.js";
9
9
  import ShaderFunction from "./ShaderFunction.js";
10
+ import addAllToArray from "../Core/addAllToArray.js";
10
11
 
11
12
  /**
12
13
  * An object that makes it easier to build the text of a {@link ShaderProgram}. This tracks GLSL code for both the vertex shader and the fragment shader.
@@ -413,7 +414,7 @@ ShaderBuilder.prototype.addVertexLines = function (lines) {
413
414
 
414
415
  const vertexLines = this._vertexShaderParts.shaderLines;
415
416
  if (Array.isArray(lines)) {
416
- vertexLines.push.apply(vertexLines, lines);
417
+ addAllToArray(vertexLines, lines);
417
418
  } else {
418
419
  // Single string case
419
420
  vertexLines.push(lines);
@@ -448,7 +449,7 @@ ShaderBuilder.prototype.addFragmentLines = function (lines) {
448
449
 
449
450
  const fragmentLines = this._fragmentShaderParts.shaderLines;
450
451
  if (Array.isArray(lines)) {
451
- fragmentLines.push.apply(fragmentLines, lines);
452
+ addAllToArray(fragmentLines, lines);
452
453
  } else {
453
454
  // Single string case
454
455
  fragmentLines.push(lines);
@@ -533,7 +534,7 @@ function generateStructLines(shaderBuilder) {
533
534
  structId = structIds[i];
534
535
  struct = shaderBuilder._structs[structId];
535
536
  structLines = struct.generateGlslLines();
536
- vertexLines.push.apply(vertexLines, structLines);
537
+ addAllToArray(vertexLines, structLines);
537
538
  }
538
539
 
539
540
  structIds = shaderBuilder._fragmentShaderParts.structIds;
@@ -541,7 +542,7 @@ function generateStructLines(shaderBuilder) {
541
542
  structId = structIds[i];
542
543
  struct = shaderBuilder._structs[structId];
543
544
  structLines = struct.generateGlslLines();
544
- fragmentLines.push.apply(fragmentLines, structLines);
545
+ addAllToArray(fragmentLines, structLines);
545
546
  }
546
547
 
547
548
  return {
@@ -576,7 +577,7 @@ function generateFunctionLines(shaderBuilder) {
576
577
  functionId = functionIds[i];
577
578
  func = shaderBuilder._functions[functionId];
578
579
  functionLines = func.generateGlslLines();
579
- vertexLines.push.apply(vertexLines, functionLines);
580
+ addAllToArray(vertexLines, functionLines);
580
581
  }
581
582
 
582
583
  functionIds = shaderBuilder._fragmentShaderParts.functionIds;
@@ -584,7 +585,7 @@ function generateFunctionLines(shaderBuilder) {
584
585
  functionId = functionIds[i];
585
586
  func = shaderBuilder._functions[functionId];
586
587
  functionLines = func.generateGlslLines();
587
- fragmentLines.push.apply(fragmentLines, functionLines);
588
+ addAllToArray(fragmentLines, functionLines);
588
589
  }
589
590
 
590
591
  return {
@@ -0,0 +1,186 @@
1
+ import clone from "../Core/clone.js";
2
+ import destroyObject from "../Core/destroyObject.js";
3
+ import DeveloperError from "../Core/DeveloperError.js";
4
+ import Context from "./Context.js";
5
+
6
+ /**
7
+ * Enables a single WebGL context to be used by any number of {@link Scene}s.
8
+ * You can pass a SharedContext in place of a {@link ContextOptions} to the constructors of {@link Scene}, {@link CesiumWidget}, and {@link Viewer}.
9
+ * {@link Primitive}s associated with the shared WebGL context can be displayed in any Scene that uses the same context.
10
+ * The context renders each Scene to an off-screen canvas, then blits the result to that Scene's on-screen canvas.
11
+ *
12
+ * @private
13
+ * @alias SharedContext
14
+ * @constructor
15
+ *
16
+ * @param {object} [options] Object with the following properties:
17
+ * @param {ContextOptions} [options.contextOptions] Context and WebGL creation properties.
18
+ * @param {boolean} [options.autoDestroy=true] Destroys this context and all of its WebGL resources after all Scenes using the context are destroyed.
19
+
20
+ * @see {@link http://www.khronos.org/registry/webgl/specs/latest/#5.2|WebGLContextAttributes}
21
+ *
22
+ * @example
23
+ * // Create two Scenes sharing a single WebGL context
24
+ * const context = new Cesium.SharedContext();
25
+ * const scene1 = new Cesium.Scene({
26
+ * canvas: canvas1,
27
+ * contextOptions: context,
28
+ * });
29
+ * const scene2 = new Cesium.Scene({
30
+ * canvas: canvas2,
31
+ * contextOptions: context,
32
+ * });
33
+ */
34
+ function SharedContext(options) {
35
+ this._autoDestroy = options?.autoDestroy ?? true;
36
+ this._canvas = document.createElement("canvas");
37
+ this._context = new Context(this._canvas, clone(options?.contextOptions));
38
+ this._canvases = [];
39
+ }
40
+
41
+ /**
42
+ * Creates an instance of {@link Context} that manages the shared WebGL context for a specific canvas.
43
+ * @param {HTMLCanvasElement} canvas The canvas element to which the context will be associated
44
+ * @returns {Context} The created context instance
45
+ * @private
46
+ */
47
+ SharedContext.prototype.createSceneContext = function (canvas) {
48
+ const context2d = canvas.getContext("2d", { alpha: true });
49
+
50
+ //>>includeStart('debug', pragmas.debug);
51
+ if (!context2d) {
52
+ throw new DeveloperError(
53
+ "canvas used with SharedContext must provide a 2d context",
54
+ );
55
+ }
56
+
57
+ if (this._canvases.includes(canvas)) {
58
+ throw new DeveloperError("canvas is already associated with a scene");
59
+ }
60
+ //>>includeEnd('debug');
61
+
62
+ const sharedContext = this;
63
+ sharedContext._canvases.push(canvas);
64
+
65
+ let isDestroyed = false;
66
+ const destroy = function () {
67
+ isDestroyed = true;
68
+ const index = sharedContext._canvases.indexOf(canvas);
69
+ if (-1 !== index) {
70
+ sharedContext._canvases.splice(index, 1);
71
+ if (sharedContext._autoDestroy && sharedContext._canvases.length === 0) {
72
+ sharedContext.destroy();
73
+ }
74
+ }
75
+ };
76
+
77
+ const beginFrame = function () {
78
+ // Ensure the off-screen canvas is at least as large as the on-screen canvas.
79
+ const sharedCanvas = sharedContext._context.canvas;
80
+
81
+ const width = this.drawingBufferWidth;
82
+ if (sharedCanvas.width < width) {
83
+ sharedCanvas.width = width;
84
+ }
85
+
86
+ const height = this.drawingBufferHeight;
87
+ if (sharedCanvas.height < height) {
88
+ sharedCanvas.height = height;
89
+ }
90
+ };
91
+
92
+ const endFrame = function () {
93
+ // Blit the image from the off-screen canvas to the on-screen canvas.
94
+ const w = this.drawingBufferWidth;
95
+ const h = this.drawingBufferHeight;
96
+ const yOffset = sharedContext._context.canvas.height - h; // drawImage has top as Y=0, GL has bottom as Y=0
97
+ context2d.drawImage(
98
+ sharedContext._context.canvas,
99
+ 0,
100
+ yOffset,
101
+ w,
102
+ h,
103
+ 0,
104
+ 0,
105
+ w,
106
+ h,
107
+ );
108
+
109
+ // Do normal post-frame cleanup.
110
+ sharedContext._context.endFrame();
111
+ };
112
+
113
+ const proxy = new Proxy(this._context, {
114
+ get(target, prop, receiver) {
115
+ if (prop === "isDestroyed") {
116
+ return function () {
117
+ return isDestroyed;
118
+ };
119
+ } else if (isDestroyed) {
120
+ //>>includeStart('debug', pragmas.debug);
121
+ throw new DeveloperError(
122
+ "This object was destroyed, i.e., destroy() was called.",
123
+ );
124
+ //>>includeEnd('debug');
125
+ }
126
+
127
+ switch (prop) {
128
+ case "_canvas":
129
+ return canvas;
130
+ case "destroy":
131
+ return destroy;
132
+ case "drawingBufferWidth":
133
+ return canvas.width;
134
+ case "drawingBufferHeight":
135
+ return canvas.height;
136
+ case "beginFrame":
137
+ return beginFrame;
138
+ case "endFrame":
139
+ return endFrame;
140
+ default:
141
+ return Reflect.get(target, prop, receiver);
142
+ }
143
+ },
144
+ });
145
+
146
+ return proxy;
147
+ };
148
+
149
+ /**
150
+ * Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
151
+ * release of WebGL resources, instead of relying on the garbage collector to destroy this object.
152
+ * <br /><br />
153
+ * Once an object is destroyed, it should not be used; calling any function other than
154
+ * <code>isDestroyed</code> will result in a {@link DeveloperError} exception. Therefore,
155
+ * assign the return value (<code>undefined</code>) to the object as done in the example.
156
+ * <br /><br />
157
+ * By default, a SharedContext is destroyed automatically once the last Scene using it is destroyed, in which case it
158
+ * is not necessary to call this method directly.
159
+ *
160
+ * @exception {DeveloperError} This object was destroyed, i.e., destroy() was called.
161
+ *
162
+ * @example
163
+ * context = context && context.destroy();
164
+ *
165
+ * @see SharedContext#isDestroyed
166
+ */
167
+ SharedContext.prototype.destroy = function () {
168
+ this._context.destroy();
169
+ destroyObject(this);
170
+ };
171
+
172
+ /**
173
+ * Returns true if this object was destroyed; otherwise, false.
174
+ * <br /><br />
175
+ * If this object was destroyed, it should not be used; calling any function other than
176
+ * <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
177
+ *
178
+ * @returns {boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
179
+ *
180
+ * @see SharedContext#destroy
181
+ */
182
+ SharedContext.prototype.isDestroyed = function () {
183
+ return false;
184
+ };
185
+
186
+ export default SharedContext;
@@ -623,13 +623,12 @@ Texture.fromFramebuffer = function (options) {
623
623
  //>>includeEnd('debug');
624
624
 
625
625
  const context = options.context;
626
- const gl = context._gl;
627
626
  const {
628
627
  pixelFormat = PixelFormat.RGB,
629
628
  framebufferXOffset = 0,
630
629
  framebufferYOffset = 0,
631
- width = gl.drawingBufferWidth,
632
- height = gl.drawingBufferHeight,
630
+ width = context.drawingBufferWidth,
631
+ height = context.drawingBufferHeight,
633
632
  framebuffer,
634
633
  } = options;
635
634
 
@@ -656,12 +655,12 @@ Texture.fromFramebuffer = function (options) {
656
655
  framebufferYOffset,
657
656
  0,
658
657
  );
659
- if (framebufferXOffset + width > gl.drawingBufferWidth) {
658
+ if (framebufferXOffset + width > context.drawingBufferWidth) {
660
659
  throw new DeveloperError(
661
660
  "framebufferXOffset + width must be less than or equal to drawingBufferWidth",
662
661
  );
663
662
  }
664
- if (framebufferYOffset + height > gl.drawingBufferHeight) {
663
+ if (framebufferYOffset + height > context.drawingBufferHeight) {
665
664
  throw new DeveloperError(
666
665
  "framebufferYOffset + height must be less than or equal to drawingBufferHeight.",
667
666
  );
@@ -13,21 +13,30 @@ import Sampler from "./Sampler.js";
13
13
  import TextureMagnificationFilter from "./TextureMagnificationFilter.js";
14
14
  import TextureMinificationFilter from "./TextureMinificationFilter.js";
15
15
 
16
+ /**
17
+ * @typedef {object} Texture3D.Source
18
+ * @property {number} width The width (in pixels) of the 3D texture source data.
19
+ * @property {number} height The height (in pixels) of the 3D texture source data.
20
+ * @property {number} depth The depth (in pixels) of the 3D texture source data.
21
+ * @property {TypedArray|DataView} arrayBufferView The source data for a 3D texture. The type of each element needs to match the pixelDatatype.
22
+ * @property {TypedArray|DataView} [mipLevels] An array of mip level data. Each element in the array should be a TypedArray or DataView that matches the pixelDatatype.
23
+ */
24
+
16
25
  /**
17
26
  * @typedef {object} Texture3D.ConstructorOptions
18
27
  *
19
28
  * @property {Context} context
20
- * @property {object} [source] The source for texel values to be loaded into the texture3D.
29
+ * @property {Texture3D.Source} [source] The source for texel values to be loaded into the 3D texture.
21
30
  * @property {PixelFormat} [pixelFormat=PixelFormat.RGBA] The format of each pixel, i.e., the number of components it has and what they represent.
22
31
  * @property {PixelDatatype} [pixelDatatype=PixelDatatype.UNSIGNED_BYTE] The data type of each pixel.
23
32
  * @property {boolean} [flipY=true] If true, the source values will be read as if the y-axis is inverted (y=0 at the top).
24
33
  * @property {boolean} [skipColorSpaceConversion=false] If true, color space conversions will be skipped when reading the texel values.
25
- * @property {Sampler} [sampler] Information about how to sample the texture3D.
26
- * @property {number} [width] The pixel width of the texture3D. If not supplied, must be available from the source.
27
- * @property {number} [height] The pixel height of the texture3D. If not supplied, must be available from the source.
28
- * @property {number} [depth] The pixel depth of the texture3D. If not supplied, must be available from the source.
34
+ * @property {Sampler} [sampler] Information about how to sample the 3D texture.
35
+ * @property {number} [width] The width (in pixels) of the 3D texture. If not supplied, must be available from the source.
36
+ * @property {number} [height] The height (in pixels) of the 3D texture. If not supplied, must be available from the source.
37
+ * @property {number} [depth] The depth (in pixels) of the 3D texture. If not supplied, must be available from the source.
29
38
  * @property {boolean} [preMultiplyAlpha] If true, the alpha channel will be multiplied into the other channels.
30
- * @property {string} [id] A unique identifier for the texture3D. If this is not given, then a GUID will be created.
39
+ * @property {string} [id] A unique identifier for the 3D texture. If this is not given, then a GUID will be created.
31
40
  *
32
41
  * @private
33
42
  */
@@ -253,7 +262,7 @@ function Texture3D(options) {
253
262
  * Load texel data from a buffer into a texture3D.
254
263
  *
255
264
  * @param {Texture3D} texture3D The texture3D to which texel values will be loaded.
256
- * @param {object} source The source for texel values to be loaded into the texture3D.
265
+ * @param {Texture3D.Source} source The source for texel values to be loaded into the texture3D.
257
266
  *
258
267
  * @private
259
268
  */
@@ -503,6 +512,7 @@ function setupSampler(texture3D, sampler) {
503
512
  gl.bindTexture(target, texture3D._texture);
504
513
  gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, minificationFilter);
505
514
  gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, magnificationFilter);
515
+ gl.texParameteri(target, gl.TEXTURE_WRAP_R, sampler.wrapR);
506
516
  gl.texParameteri(target, gl.TEXTURE_WRAP_S, sampler.wrapS);
507
517
  gl.texParameteri(target, gl.TEXTURE_WRAP_T, sampler.wrapT);
508
518
  if (defined(texture3D._textureFilterAnisotropic)) {
@@ -4,7 +4,7 @@ import Resource from "../Core/Resource.js";
4
4
 
5
5
  let defaultTokenCredit;
6
6
  const defaultAccessToken =
7
- "AAPTxy8BH1VEsoebNVZXo8HurEOF051kAEKlhkOhBEc9BmTvj0sIevECBw-bvZAvk8zYQRQq68aswXB6_yVObhIYNHapUAk3eqDIvpDZAUjFHpy1wJdPnkcKqSGXXGM22C1fqVC0gbU2S_RjRHuIHK5WVIYP7fUJQPjRGD1weDGyD5vBqwZX1Ah4LLUPG9474k1fvB1_vIROH9r9R-Sd9f9pbBFr9FjKfISJZiiJdaXVas4.AT1_eWrg8X2i";
7
+ "AAPTxy8BH1VEsoebNVZXo8HurEOF051kAEKlhkOhBEc9BmRpOZfBt2Ic5blmnx9xwwyG_Mt0EmBxpEa6xCqXn5V_qFEgJ0edE9ixiefKjMiv986NGSn2HB8y6x0GtSOCBkg19K6rBgZ7Upl7ABEnaFh4dD73GW0gUAJ9hHWhqd1qgHkBuctWiFEJUmQjs_52tdx6l5bDGoeXVvmelklmEJOshCRV_s3kLPC19ENRNLc18eA.AT1_EXUMUBsi";
8
8
  /**
9
9
  * Default options for accessing the ArcGIS image tile service.
10
10
  *
@@ -1118,7 +1118,7 @@ function writeCompressedAttrib1(
1118
1118
  }
1119
1119
  }
1120
1120
 
1121
- const imageWidth = billboard.width ?? 0;
1121
+ const imageWidth = Math.round(billboard.width ?? 0);
1122
1122
  billboardCollection._maxSize = Math.max(
1123
1123
  billboardCollection._maxSize,
1124
1124
  imageWidth,
@@ -23,6 +23,7 @@ import getBinaryAccessor from "./getBinaryAccessor.js";
23
23
  import StencilConstants from "./StencilConstants.js";
24
24
  import StencilFunction from "./StencilFunction.js";
25
25
  import StencilOperation from "./StencilOperation.js";
26
+ import addAllToArray from "../Core/addAllToArray.js";
26
27
 
27
28
  const DEFAULT_COLOR_VALUE = BatchTexture.DEFAULT_COLOR_VALUE;
28
29
  const DEFAULT_SHOW_VALUE = BatchTexture.DEFAULT_SHOW_VALUE;
@@ -369,13 +370,14 @@ Cesium3DTileBatchTable.prototype.getPropertyIds = function (batchId, results) {
369
370
  results.length = 0;
370
371
 
371
372
  const scratchPropertyIds = Object.keys(this._properties);
372
- results.push.apply(results, scratchPropertyIds);
373
+ addAllToArray(results, scratchPropertyIds);
373
374
 
374
375
  if (defined(this._batchTableHierarchy)) {
375
- results.push.apply(
376
- results,
377
- this._batchTableHierarchy.getPropertyIds(batchId, scratchPropertyIds),
376
+ const propertyIds = this._batchTableHierarchy.getPropertyIds(
377
+ batchId,
378
+ scratchPropertyIds,
378
379
  );
380
+ addAllToArray(results, propertyIds);
379
381
  }
380
382
 
381
383
  return results;