@cesium/engine 13.0.0 → 13.1.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 (117) hide show
  1. package/Build/Workers/{chunk-BFNZUP2C.js → chunk-2ONAV62A.js} +14 -13
  2. package/Build/Workers/{chunk-OUIF26MQ.js → chunk-2SRHVCFD.js} +6 -6
  3. package/Build/Workers/{chunk-GBXJIWAZ.js → chunk-3SCCWLZS.js} +9 -9
  4. package/Build/Workers/{chunk-4IM6WQEI.js → chunk-54I6VSRP.js} +6 -6
  5. package/Build/Workers/{chunk-JISDBAYP.js → chunk-5I3LPAS7.js} +5 -5
  6. package/Build/Workers/{chunk-W2DVQETH.js → chunk-5ICYLS6B.js} +35 -21
  7. package/Build/Workers/{chunk-GJZQSAES.js → chunk-5JY4LYO3.js} +7 -7
  8. package/Build/Workers/{chunk-CQDSGG3R.js → chunk-APCS5YJI.js} +7 -7
  9. package/Build/Workers/{chunk-ZIWULRRD.js → chunk-AXYZUG4N.js} +1 -1
  10. package/Build/Workers/{chunk-H4Y7ADFL.js → chunk-B34JXFHF.js} +5 -5
  11. package/Build/Workers/{chunk-2OD54CUD.js → chunk-B6IJY6AN.js} +7 -7
  12. package/Build/Workers/{chunk-Z7OYBX6P.js → chunk-BMFWWTD7.js} +5 -5
  13. package/Build/Workers/{chunk-PMNQULFU.js → chunk-CBE4HRBH.js} +7 -7
  14. package/Build/Workers/{chunk-3ZMTG4X5.js → chunk-CNPP6TQ2.js} +4 -4
  15. package/Build/Workers/{chunk-KKVKSTWC.js → chunk-DWIKWWEE.js} +5 -5
  16. package/Build/Workers/{chunk-KRCUHV7P.js → chunk-EHGQQA7C.js} +1 -1
  17. package/Build/Workers/{chunk-YBDL7YPF.js → chunk-EJ5DT5BP.js} +1 -1
  18. package/Build/Workers/{chunk-6HWW6KNV.js → chunk-EYZFEJX3.js} +6 -6
  19. package/Build/Workers/{chunk-FANORJU6.js → chunk-FNCXBBCF.js} +2 -2
  20. package/Build/Workers/{chunk-2IIE2UZ3.js → chunk-GIOZHX7U.js} +2 -2
  21. package/Build/Workers/{chunk-KCCTLUKK.js → chunk-GSLKQJM2.js} +10 -10
  22. package/Build/Workers/{chunk-PD2MCNV7.js → chunk-HI73PIPQ.js} +2 -2
  23. package/Build/Workers/{chunk-RR4M3ZGF.js → chunk-IP7F2MVW.js} +7 -7
  24. package/Build/Workers/{chunk-GNG3V432.js → chunk-IXNXKVOB.js} +4 -4
  25. package/Build/Workers/{chunk-D3VPMNUR.js → chunk-J7BMSSY7.js} +13 -13
  26. package/Build/Workers/{chunk-NVFEDMX4.js → chunk-K62EHZFT.js} +15 -15
  27. package/Build/Workers/{chunk-FLPIQK2R.js → chunk-K6SQV4IS.js} +6 -6
  28. package/Build/Workers/{chunk-22NU5WU5.js → chunk-KO232FLP.js} +2 -2
  29. package/Build/Workers/{chunk-XQP37R5E.js → chunk-KRVALCCI.js} +5 -5
  30. package/Build/Workers/{chunk-MSKD73KW.js → chunk-LFUFGHL3.js} +10 -10
  31. package/Build/Workers/{chunk-T5H7YWC7.js → chunk-LQT2ZK7D.js} +17 -17
  32. package/Build/Workers/{chunk-MMILY4S7.js → chunk-M2AA2ARJ.js} +11 -11
  33. package/Build/Workers/{chunk-Q4MTXEB7.js → chunk-MGABCOOH.js} +6 -6
  34. package/Build/Workers/{chunk-W2E67GLE.js → chunk-NQDKNE7V.js} +13 -13
  35. package/Build/Workers/{chunk-YDEZMDB7.js → chunk-OARMSJUU.js} +2 -2
  36. package/Build/Workers/{chunk-S4SCKDK4.js → chunk-OGRXNUR2.js} +1 -1
  37. package/Build/Workers/{chunk-3VHIUS7I.js → chunk-OZTFRHA2.js} +6 -6
  38. package/Build/Workers/{chunk-CUMDCSMT.js → chunk-PBJQFLKS.js} +11 -11
  39. package/Build/Workers/{chunk-H7BML7HH.js → chunk-PM76TX2X.js} +6 -6
  40. package/Build/Workers/{chunk-HMMPNR4Z.js → chunk-PTFIVVLX.js} +12 -12
  41. package/Build/Workers/{chunk-BZMHXDKV.js → chunk-R2KGFZBA.js} +13 -13
  42. package/Build/Workers/{chunk-6ZOS2ACR.js → chunk-S3UM4OKP.js} +7 -7
  43. package/Build/Workers/{chunk-2TSF7N76.js → chunk-SAKQO5NX.js} +2 -2
  44. package/Build/Workers/{chunk-4HS475MU.js → chunk-T34EOLFR.js} +14 -14
  45. package/Build/Workers/{chunk-EXDSJZ7J.js → chunk-THDHWSEJ.js} +4 -4
  46. package/Build/Workers/{chunk-RGZWZ4PP.js → chunk-TOHDFUJM.js} +4 -4
  47. package/Build/Workers/{chunk-BLTSMJIP.js → chunk-UBAHTE4Q.js} +1 -1
  48. package/Build/Workers/{chunk-OZZD3VY4.js → chunk-WAJNX74N.js} +17 -17
  49. package/Build/Workers/{chunk-DIAH2ZTB.js → chunk-WE4KF4AM.js} +9 -9
  50. package/Build/Workers/{chunk-RC5N5SJL.js → chunk-WUIDEXAN.js} +7 -7
  51. package/Build/Workers/{chunk-RIQGQMS4.js → chunk-YVGU235V.js} +4 -4
  52. package/Build/Workers/{chunk-WXJY6NDI.js → chunk-ZWSWJYJP.js} +13 -13
  53. package/Build/Workers/combineGeometry.js +22 -22
  54. package/Build/Workers/createBoxGeometry.js +16 -16
  55. package/Build/Workers/createBoxOutlineGeometry.js +14 -14
  56. package/Build/Workers/createCircleGeometry.js +24 -24
  57. package/Build/Workers/createCircleOutlineGeometry.js +17 -17
  58. package/Build/Workers/createCoplanarPolygonGeometry.js +31 -31
  59. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
  60. package/Build/Workers/createCorridorGeometry.js +27 -27
  61. package/Build/Workers/createCorridorOutlineGeometry.js +26 -26
  62. package/Build/Workers/createCylinderGeometry.js +18 -18
  63. package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
  64. package/Build/Workers/createEllipseGeometry.js +24 -24
  65. package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
  66. package/Build/Workers/createEllipsoidGeometry.js +17 -17
  67. package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
  68. package/Build/Workers/createFrustumGeometry.js +16 -16
  69. package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
  70. package/Build/Workers/createGeometry.js +22 -22
  71. package/Build/Workers/createGroundPolylineGeometry.js +20 -20
  72. package/Build/Workers/createPlaneGeometry.js +14 -14
  73. package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
  74. package/Build/Workers/createPolygonGeometry.js +30 -30
  75. package/Build/Workers/createPolygonOutlineGeometry.js +28 -28
  76. package/Build/Workers/createPolylineGeometry.js +23 -23
  77. package/Build/Workers/createPolylineVolumeGeometry.js +29 -29
  78. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -25
  79. package/Build/Workers/createRectangleGeometry.js +25 -25
  80. package/Build/Workers/createRectangleOutlineGeometry.js +18 -18
  81. package/Build/Workers/createSimplePolylineGeometry.js +21 -21
  82. package/Build/Workers/createSphereGeometry.js +17 -17
  83. package/Build/Workers/createSphereOutlineGeometry.js +16 -16
  84. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  85. package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
  86. package/Build/Workers/createVectorTileGeometries.js +22 -22
  87. package/Build/Workers/createVectorTilePoints.js +12 -12
  88. package/Build/Workers/createVectorTilePolygons.js +20 -20
  89. package/Build/Workers/createVectorTilePolylines.js +13 -13
  90. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
  91. package/Build/Workers/createVerticesFromHeightmap.js +20 -20
  92. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
  93. package/Build/Workers/createWallGeometry.js +22 -22
  94. package/Build/Workers/createWallOutlineGeometry.js +21 -21
  95. package/Build/Workers/decodeDraco.js +11 -11
  96. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  97. package/Build/Workers/decodeI3S.js +10 -10
  98. package/Build/Workers/transcodeKTX2.js +7 -7
  99. package/Build/Workers/transferTypedArrayTest.js +1 -1
  100. package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
  101. package/Source/Core/Check.d.ts +2 -1
  102. package/Source/Core/ITwinPlatform.js +3 -38
  103. package/Source/Core/Ion.js +1 -1
  104. package/Source/Core/JulianDate.js +14 -7
  105. package/Source/Core/defined.d.ts +11 -0
  106. package/Source/DataSources/ModelGraphics.js +23 -1
  107. package/Source/DataSources/ModelVisualizer.js +22 -1
  108. package/Source/Scene/ArcGisMapService.js +1 -1
  109. package/Source/Scene/Cesium3DTileset.js +1 -1
  110. package/Source/Scene/DynamicEnvironmentMapManager.js +123 -66
  111. package/Source/Scene/ITwinData.js +70 -0
  112. package/Source/Scene/Model/Model.js +1 -1
  113. package/Source/Shaders/DepthPlaneVS.glsl +1 -1
  114. package/Source/Shaders/DepthPlaneVS.js +1 -1
  115. package/index.d.ts +26 -4
  116. package/index.js +61 -61
  117. package/package.json +1 -1
@@ -35,6 +35,9 @@ const defaultColor = Color.WHITE;
35
35
  const defaultColorBlendMode = ColorBlendMode.HIGHLIGHT;
36
36
  const defaultColorBlendAmount = 0.5;
37
37
  const defaultImageBasedLightingFactor = new Cartesian2(1.0, 1.0);
38
+ const defaultEnvironmentMapOptions = {
39
+ maximumPositionEpsilon: Number.POSITIVE_INFINITY,
40
+ };
38
41
 
39
42
  const modelMatrixScratch = new Matrix4();
40
43
  const nodeMatrixScratch = new Matrix4();
@@ -76,6 +79,7 @@ async function createModelPrimitive(
76
79
  entity,
77
80
  resource,
78
81
  incrementallyLoadTextures,
82
+ environmentMapOptions,
79
83
  ) {
80
84
  const primitives = visualizer._primitives;
81
85
  const modelHash = visualizer._modelHash;
@@ -85,6 +89,7 @@ async function createModelPrimitive(
85
89
  url: resource,
86
90
  incrementallyLoadTextures: incrementallyLoadTextures,
87
91
  scene: visualizer._scene,
92
+ environmentMapOptions: environmentMapOptions,
88
93
  });
89
94
 
90
95
  if (visualizer.isDestroyed() || !defined(modelHash[entity.id])) {
@@ -176,6 +181,9 @@ ModelVisualizer.prototype.update = function (time) {
176
181
  articulationsScratch: {},
177
182
  loadFailed: false,
178
183
  modelUpdated: false,
184
+ environmentMapOptionsScratch: {
185
+ ...defaultEnvironmentMapOptions,
186
+ },
179
187
  };
180
188
  modelHash[entity.id] = modelData;
181
189
 
@@ -185,7 +193,20 @@ ModelVisualizer.prototype.update = function (time) {
185
193
  defaultIncrementallyLoadTextures,
186
194
  );
187
195
 
188
- createModelPrimitive(this, entity, resource, incrementallyLoadTextures);
196
+ const environmentMapOptions = Property.getValueOrDefault(
197
+ modelGraphics._environmentMapOptions,
198
+ time,
199
+ defaultEnvironmentMapOptions,
200
+ modelData.environmentMapOptionsScratch,
201
+ );
202
+
203
+ createModelPrimitive(
204
+ this,
205
+ entity,
206
+ resource,
207
+ incrementallyLoadTextures,
208
+ environmentMapOptions,
209
+ );
189
210
  }
190
211
 
191
212
  const model = modelData.modelPrimitive;
@@ -4,7 +4,7 @@ import Resource from "../Core/Resource.js";
4
4
 
5
5
  let defaultTokenCredit;
6
6
  const defaultAccessToken =
7
- "AAPTxy8BH1VEsoebNVZXo8HurEOF051kAEKlhkOhBEc9BmSrZYLHFXe7j_lQcsSJKc8-7rwh0IFSNWLGZErkzXRnYjMjURTz-hGiKMEeAJIZBG7uiYEn0Mt1rrwlJGIpirZQC4iO428519DlO3QC9DnRBqLXGTBhirgoU7-Z2209sy87s49kw6NOC8_Eew6nCLf-pZ883DRPRyAYH7LC8cvRLInud0EdndtUFa4y83TamrA.AT1_ahjrWDrq";
7
+ "AAPTxy8BH1VEsoebNVZXo8HurEOF051kAEKlhkOhBEc9BmSFctdVnwhKUPPSRxMpNygUNlP8JmGGUdPJSkOUNGzOjDGJ6_IBw0ZIYb2CxiR6SbKR4hMj3np1HXa_Idxv_txLhu62WcUsFQSTBvq7ktym5DNKxqVmIzBnPljNsM8ff9hCKEXq0LTd8VzkHqjVA7-ig_wg7BqJGg7vUMgG1QseyUAjpmY2OaEv9rA8aeBjRrc.AT1_8nZ92i8c";
8
8
  /**
9
9
  * Default options for accessing the ArcGIS image tile service.
10
10
  *
@@ -105,7 +105,7 @@ import DynamicEnvironmentMapManager from "./DynamicEnvironmentMapManager.js";
105
105
  * @property {object} [pointCloudShading] Options for constructing a {@link PointCloudShading} object to control point attenuation based on geometric error and lighting.
106
106
  * @property {Cartesian3} [lightColor] The light color when shading models. When <code>undefined</code> the scene's light color is used instead.
107
107
  * @property {ImageBasedLighting} [imageBasedLighting] The properties for managing image-based lighting for this tileset.
108
- * @param {DynamicEnvironmentMapManager.ConstructorOptions} [options.environmentMapOptions] The properties for managing dynamic environment maps on this model.
108
+ * @property {DynamicEnvironmentMapManager.ConstructorOptions} [environmentMapOptions] The properties for managing dynamic environment maps on this tileset.
109
109
  * @property {boolean} [backFaceCulling=true] Whether to cull back-facing geometry. When true, back face culling is determined by the glTF material's doubleSided property; when false, back face culling is disabled.
110
110
  * @property {boolean} [enableShowOutline=true] Whether to enable outlines for models using the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. This can be set to false to avoid the additional processing of geometry at load time. When false, the showOutlines and outlineColor options are ignored.
111
111
  * @property {boolean} [showOutline=true] Whether to display the outline for models using the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. When true, outlines are displayed. When false, outlines are not displayed.
@@ -33,7 +33,7 @@ import ConvolveSpecularMapVS from "../Shaders/ConvolveSpecularMapVS.js";
33
33
  * @typedef {object} DynamicEnvironmentMapManager.ConstructorOptions
34
34
  * Options for the DynamicEnvironmentMapManager constructor
35
35
  * @property {boolean} [enabled=true] If true, the environment map and related properties will continue to update.
36
- * @property {number} [mipmapLevels=10] The number of mipmap levels to generate for specular maps. More mipmap levels will produce a higher resolution specular reflection.
36
+ * @property {number} [mipmapLevels=7] The number of mipmap levels to generate for specular maps. More mipmap levels will produce a higher resolution specular reflection.
37
37
  * @property {number} [maximumSecondsDifference=3600] The maximum amount of elapsed seconds before a new environment map is created.
38
38
  * @property {number} [maximumPositionEpsilon=1000] The maximum difference in position before a new environment map is created, in meters. Small differences in position will not visibly affect results.
39
39
  * @property {number} [atmosphereScatteringIntensity=2.0] The intensity of the scattered light emitted from the atmosphere. This should be adjusted relative to the value of {@link Scene.light} intensity.
@@ -77,11 +77,12 @@ function DynamicEnvironmentMapManager(options) {
77
77
  this._sphericalHarmonicCoefficientsDirty = false;
78
78
 
79
79
  this._shouldRegenerateShaders = false;
80
+ this._shouldReset = false;
80
81
 
81
82
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
82
83
 
83
84
  const mipmapLevels = Math.min(
84
- defaultValue(options.mipmapLevels, 10),
85
+ defaultValue(options.mipmapLevels, 7),
85
86
  Math.log2(ContextLimits.maximumCubeMapSize),
86
87
  );
87
88
 
@@ -251,7 +252,7 @@ Object.defineProperties(DynamicEnvironmentMapManager.prototype, {
251
252
  }
252
253
 
253
254
  this._position = Cartesian3.clone(value, this._position);
254
- this.reset();
255
+ this._shouldReset = true;
255
256
  },
256
257
  },
257
258
 
@@ -345,7 +346,7 @@ DynamicEnvironmentMapManager._updateCommandQueue = (frameState) => {
345
346
  DynamicEnvironmentMapManager._activeComputeCommandCount <
346
347
  DynamicEnvironmentMapManager._maximumComputeCommandCount
347
348
  ) {
348
- if (command.canceled) {
349
+ if (command.owner.isDestroyed() || command.canceled) {
349
350
  command = DynamicEnvironmentMapManager._nextFrameCommandQueue.shift();
350
351
  continue;
351
352
  }
@@ -354,6 +355,10 @@ DynamicEnvironmentMapManager._updateCommandQueue = (frameState) => {
354
355
  DynamicEnvironmentMapManager._activeComputeCommandCount++;
355
356
  command = DynamicEnvironmentMapManager._nextFrameCommandQueue.shift();
356
357
  }
358
+
359
+ if (defined(command)) {
360
+ DynamicEnvironmentMapManager._nextFrameCommandQueue.push(command);
361
+ }
357
362
  }
358
363
  };
359
364
 
@@ -398,7 +403,6 @@ DynamicEnvironmentMapManager.prototype.reset = function () {
398
403
  for (let i = 0; i < length; ++i) {
399
404
  if (defined(this._radianceMapComputeCommands[i])) {
400
405
  this._radianceMapComputeCommands[i].canceled = true;
401
- DynamicEnvironmentMapManager._activeComputeCommandCount--;
402
406
  }
403
407
  this._radianceMapComputeCommands[i] = undefined;
404
408
  }
@@ -407,19 +411,19 @@ DynamicEnvironmentMapManager.prototype.reset = function () {
407
411
  for (let i = 0; i < length; ++i) {
408
412
  if (defined(this._convolutionComputeCommands[i])) {
409
413
  this._convolutionComputeCommands[i].canceled = true;
410
- DynamicEnvironmentMapManager._activeComputeCommandCount--;
411
414
  }
412
415
  this._convolutionComputeCommands[i] = undefined;
413
416
  }
414
417
 
415
418
  if (defined(this._irradianceComputeCommand)) {
416
419
  this._irradianceComputeCommand.canceled = true;
417
- DynamicEnvironmentMapManager._activeComputeCommandCount--;
418
420
  this._irradianceComputeCommand = undefined;
419
421
  }
420
422
 
421
423
  this._radianceMapDirty = true;
422
424
  this._radianceCommandsDirty = true;
425
+ this._convolutionsCommandsDirty = false;
426
+ this._irradianceCommandDirty = false;
423
427
  };
424
428
 
425
429
  const scratchPackedAtmosphere = new Cartesian3();
@@ -539,7 +543,8 @@ function updateRadianceMap(manager, frameState) {
539
543
  let i = 0;
540
544
  for (const face of CubeMap.faceNames()) {
541
545
  let texture = manager._radianceMapTextures[i];
542
- if (defined(texture)) {
546
+ // Destroy any existing textures that have no yet been cleaned up
547
+ if (defined(texture) && !texture.isDestroyed()) {
543
548
  texture.destroy();
544
549
  }
545
550
 
@@ -570,36 +575,35 @@ function updateRadianceMap(manager, frameState) {
570
575
  );
571
576
  },
572
577
  },
573
- persists: true,
574
578
  owner: manager,
575
- postExecute: () => {
576
- const commands = manager._radianceMapComputeCommands;
577
- if (!defined(commands[index])) {
578
- // This command was cancelled
579
- return;
580
- }
581
- commands[index] = undefined;
582
-
583
- const framebuffer = new Framebuffer({
584
- context: context,
585
- colorTextures: [manager._radianceMapTextures[index]],
586
- destroyAttachments: false,
587
- });
588
-
589
- // Copy the output texture into the corresponding cubemap face
590
- framebuffer._bind();
591
- manager._radianceCubeMap[face].copyFromFramebuffer();
592
- framebuffer._unBind();
593
- framebuffer.destroy();
594
-
579
+ });
580
+ command.postExecute = () => {
581
+ if (manager.isDestroyed() || command.canceled) {
595
582
  DynamicEnvironmentMapManager._activeComputeCommandCount--;
583
+ return;
584
+ }
596
585
 
597
- if (!commands.some(defined)) {
598
- manager._convolutionsCommandsDirty = true;
599
- manager._shouldRegenerateShaders = true;
600
- }
601
- },
602
- });
586
+ const commands = manager._radianceMapComputeCommands;
587
+ commands[index] = undefined;
588
+
589
+ const framebuffer = new Framebuffer({
590
+ context: context,
591
+ colorTextures: [manager._radianceMapTextures[index]],
592
+ });
593
+
594
+ // Copy the output texture into the corresponding cubemap face
595
+ framebuffer._bind();
596
+ manager._radianceCubeMap[face].copyFromFramebuffer();
597
+ framebuffer._unBind();
598
+ framebuffer.destroy();
599
+
600
+ DynamicEnvironmentMapManager._activeComputeCommandCount--;
601
+
602
+ if (!commands.some(defined)) {
603
+ manager._convolutionsCommandsDirty = true;
604
+ manager._shouldRegenerateShaders = true;
605
+ }
606
+ };
603
607
 
604
608
  manager._radianceMapComputeCommands[i] = command;
605
609
  DynamicEnvironmentMapManager._queueCommand(command, frameState);
@@ -626,32 +630,48 @@ function updateSpecularMaps(manager, frameState) {
626
630
  const context = frameState.context;
627
631
 
628
632
  let facesCopied = 0;
629
- const getPostExecute = (index, texture, face, level) => () => {
630
- // Copy output texture to corresponding face and mipmap level
631
- const commands = manager._convolutionComputeCommands;
632
- if (!defined(commands[index]) || commands[index].canceled) {
633
- // This command was cancelled
633
+ const getPostExecute = (command, index, texture, face, level) => () => {
634
+ if (manager.isDestroyed() || command.canceled) {
635
+ DynamicEnvironmentMapManager._activeComputeCommandCount--;
634
636
  return;
635
637
  }
638
+
639
+ // Copy output texture to corresponding face and mipmap level
640
+ const commands = manager._convolutionComputeCommands;
636
641
  commands[index] = undefined;
637
642
 
638
643
  radianceCubeMap.copyFace(frameState, texture, face, level);
639
644
  facesCopied++;
640
645
  DynamicEnvironmentMapManager._activeComputeCommandCount--;
641
646
 
642
- // All faces and levels have been copied
643
- if (facesCopied === manager._specularMapTextures.length) {
647
+ texture.destroy();
648
+ manager._specularMapTextures[index] = undefined;
649
+
650
+ // All faces for each mipmap level have been copied
651
+ const length = manager._specularMapTextures.length;
652
+ if (facesCopied >= length) {
644
653
  manager._irradianceCommandDirty = true;
645
654
  radianceCubeMap.sampler = new Sampler({
646
655
  minificationFilter: TextureMinificationFilter.LINEAR_MIPMAP_LINEAR,
647
656
  });
657
+
648
658
  manager._shouldRegenerateShaders = true;
659
+
660
+ // Cleanup shared resources
661
+ manager._va.destroy();
662
+ manager._va = undefined;
663
+ manager._convolveSP.destroy();
664
+ manager._convolveSP = undefined;
649
665
  }
650
666
  };
651
667
 
652
668
  let index = 0;
653
669
  for (let level = 1; level < mipmapLevels; ++level) {
654
670
  for (const face of CubeMap.faceNames()) {
671
+ if (defined(manager._specularMapTextures[index])) {
672
+ manager._specularMapTextures[index].destroy();
673
+ }
674
+
655
675
  const texture = (manager._specularMapTextures[index] = new Texture({
656
676
  context: context,
657
677
  width: width,
@@ -683,6 +703,8 @@ function updateSpecularMaps(manager, frameState) {
683
703
  shaderProgram: shaderProgram,
684
704
  vertexArray: vertexArray,
685
705
  outputTexture: texture,
706
+ // Persist so we can use a shared shader progam and vertex array across all commands
707
+ // Shared resources are instead destroyed in postExecute
686
708
  persists: true,
687
709
  owner: manager,
688
710
  uniformMap: {
@@ -692,8 +714,14 @@ function updateSpecularMaps(manager, frameState) {
692
714
  return CubeMap.getDirection(face, scratchCartesian);
693
715
  },
694
716
  },
695
- postExecute: getPostExecute(index, texture, face, level),
696
717
  });
718
+ command.postExecute = getPostExecute(
719
+ command,
720
+ index,
721
+ texture,
722
+ face,
723
+ level,
724
+ );
697
725
  manager._convolutionComputeCommands[index] = command;
698
726
  DynamicEnvironmentMapManager._queueCommand(command, frameState);
699
727
  ++index;
@@ -717,17 +745,19 @@ function updateIrradianceResources(manager, frameState) {
717
745
  const dimensions = irradianceTextureDimensions;
718
746
 
719
747
  let texture = manager._irradianceMapTexture;
720
- if (!defined(texture)) {
721
- texture = new Texture({
722
- context: context,
723
- width: dimensions.x,
724
- height: dimensions.y,
725
- pixelDatatype: PixelDatatype.FLOAT,
726
- pixelFormat: PixelFormat.RGBA,
727
- });
728
- manager._irradianceMapTexture = texture;
748
+ if (defined(texture) && !texture.isDestroyed()) {
749
+ texture.destroy();
729
750
  }
730
751
 
752
+ texture = new Texture({
753
+ context: context,
754
+ width: dimensions.x,
755
+ height: dimensions.y,
756
+ pixelDatatype: PixelDatatype.FLOAT,
757
+ pixelFormat: PixelFormat.RGBA,
758
+ });
759
+ manager._irradianceMapTexture = texture;
760
+
731
761
  let fs = manager._irradianceMapFS;
732
762
  if (!defined(fs)) {
733
763
  fs = new ShaderSource({
@@ -739,21 +769,25 @@ function updateIrradianceResources(manager, frameState) {
739
769
  const command = new ComputeCommand({
740
770
  fragmentShaderSource: fs,
741
771
  outputTexture: texture,
772
+ owner: manager,
742
773
  uniformMap: {
743
774
  u_radianceMap: () => manager._radianceCubeMap ?? context.defaultTexture,
744
775
  },
745
- postExecute: () => {
746
- if (!defined(manager._irradianceComputeCommand)) {
747
- // This command was cancelled
748
- return;
749
- }
750
- manager._irradianceTextureDirty = false;
751
- manager._irradianceComputeCommand = undefined;
752
- manager._sphericalHarmonicCoefficientsDirty = true;
776
+ });
753
777
 
778
+ command.postExecute = () => {
779
+ if (manager.isDestroyed() || command.canceled) {
754
780
  DynamicEnvironmentMapManager._activeComputeCommandCount--;
755
- },
756
- });
781
+ return;
782
+ }
783
+ manager._irradianceTextureDirty = false;
784
+ manager._irradianceComputeCommand = undefined;
785
+ manager._sphericalHarmonicCoefficientsDirty = true;
786
+ manager._irradianceMapFS = undefined;
787
+
788
+ DynamicEnvironmentMapManager._activeComputeCommandCount--;
789
+ };
790
+
757
791
  manager._irradianceComputeCommand = command;
758
792
  DynamicEnvironmentMapManager._queueCommand(command, frameState);
759
793
  manager._irradianceTextureDirty = true;
@@ -768,6 +802,11 @@ function updateIrradianceResources(manager, frameState) {
768
802
  function updateSphericalHarmonicCoefficients(manager, frameState) {
769
803
  const context = frameState.context;
770
804
 
805
+ if (!defined(manager._irradianceMapTexture)) {
806
+ // Operation was canceled
807
+ return;
808
+ }
809
+
771
810
  const framebuffer = new Framebuffer({
772
811
  context: context,
773
812
  colorTextures: [manager._irradianceMapTexture],
@@ -793,6 +832,8 @@ function updateSphericalHarmonicCoefficients(manager, frameState) {
793
832
  }
794
833
 
795
834
  framebuffer.destroy();
835
+ manager._irradianceMapTexture.destroy();
836
+ manager._irradianceMapTexture = undefined;
796
837
  manager._shouldRegenerateShaders = true;
797
838
  }
798
839
 
@@ -834,9 +875,11 @@ DynamicEnvironmentMapManager.prototype.update = function (frameState) {
834
875
  this.maximumSecondsDifference,
835
876
  ));
836
877
 
837
- if (regenerateEnvironmentMap) {
878
+ if (this._shouldReset || regenerateEnvironmentMap) {
838
879
  this.reset();
880
+ this._shouldReset = false;
839
881
  this._lastTime = JulianDate.clone(frameState.time, this._lastTime);
882
+ return;
840
883
  }
841
884
 
842
885
  if (this._radianceMapDirty) {
@@ -910,19 +953,33 @@ DynamicEnvironmentMapManager.prototype.destroy = function () {
910
953
  length = this._radianceMapTextures.length;
911
954
  for (let i = 0; i < length; ++i) {
912
955
  this._radianceMapTextures[i] =
913
- this._radianceMapTextures[i] && this._radianceMapTextures[i].destroy();
956
+ this._radianceMapTextures[i] &&
957
+ !this._radianceMapTextures[i].isDestroyed() &&
958
+ this._radianceMapTextures[i].destroy();
914
959
  }
915
960
 
916
961
  length = this._specularMapTextures.length;
917
962
  for (let i = 0; i < length; ++i) {
918
963
  this._specularMapTextures[i] =
919
- this._specularMapTextures[i] && this._specularMapTextures[i].destroy();
964
+ this._specularMapTextures[i] &&
965
+ !this._specularMapTextures[i].isDestroyed() &&
966
+ this._specularMapTextures[i].destroy();
920
967
  }
921
968
 
922
969
  this._radianceCubeMap =
923
970
  this._radianceCubeMap && this._radianceCubeMap.destroy();
924
971
  this._irradianceMapTexture =
925
- this._irradianceMapTexture && this._irradianceMapTexture.destroy();
972
+ this._irradianceMapTexture &&
973
+ !this._irradianceMapTexture.isDestroyed() &&
974
+ this._irradianceMapTexture.destroy();
975
+
976
+ if (defined(this._va)) {
977
+ this._va.destroy();
978
+ }
979
+
980
+ if (defined(this._convolveSP)) {
981
+ this._convolveSP.destroy();
982
+ }
926
983
 
927
984
  return destroyObject(this);
928
985
  };
@@ -4,6 +4,8 @@ import Resource from "../Core/Resource.js";
4
4
  import ITwinPlatform from "../Core/ITwinPlatform.js";
5
5
  import RuntimeError from "../Core/RuntimeError.js";
6
6
  import Check from "../Core/Check.js";
7
+ import KmlDataSource from "../DataSources/KmlDataSource.js";
8
+ import GeoJsonDataSource from "../DataSources/GeoJsonDataSource.js";
7
9
 
8
10
  /**
9
11
  * Methods for loading iTwin platform data into CesiumJS
@@ -86,6 +88,8 @@ ITwinData.createTilesetFromIModelId = async function (iModelId, options) {
86
88
  * @param {ITwinPlatform.RealityDataType} [type] The type of this reality data
87
89
  * @param {string} [rootDocument] The path of the root document for this reality data
88
90
  * @returns {Promise<Cesium3DTileset>}
91
+ *
92
+ * @throws {RuntimeError} if the type of reality data is not supported by this function
89
93
  */
90
94
  ITwinData.createTilesetForRealityDataId = async function (
91
95
  iTwinId,
@@ -135,4 +139,70 @@ ITwinData.createTilesetForRealityDataId = async function (
135
139
  });
136
140
  };
137
141
 
142
+ /**
143
+ * Create a data source of the correct type for the specified reality data id.
144
+ * This function only works for KML and GeoJSON type data.
145
+ *
146
+ * If the <code>type</code> or <code>rootDocument</code> are not provided this function
147
+ * will first request the full metadata for the specified reality data to fill these values.
148
+ *
149
+ * @param {string} iTwinId The id of the iTwin to load data from
150
+ * @param {string} realityDataId The id of the reality data to load
151
+ * @param {ITwinPlatform.RealityDataType} [type] The type of this reality data
152
+ * @param {string} [rootDocument] The path of the root document for this reality data
153
+ * @returns {Promise<GeoJsonDataSource | KmlDataSource>}
154
+ *
155
+ * @throws {RuntimeError} if the type of reality data is not supported by this function
156
+ */
157
+ ITwinData.createDataSourceForRealityDataId = async function loadRealityData(
158
+ iTwinId,
159
+ realityDataId,
160
+ type,
161
+ rootDocument,
162
+ ) {
163
+ //>>includeStart('debug', pragmas.debug);
164
+ Check.typeOf.string("iTwinId", iTwinId);
165
+ Check.typeOf.string("realityDataId", realityDataId);
166
+ if (defined(type)) {
167
+ Check.typeOf.string("type", type);
168
+ }
169
+ if (defined(rootDocument)) {
170
+ Check.typeOf.string("rootDocument", rootDocument);
171
+ }
172
+ //>>includeEnd('debug')
173
+
174
+ if (!defined(type) || !defined(rootDocument)) {
175
+ const metadata = await ITwinPlatform.getRealityDataMetadata(
176
+ iTwinId,
177
+ realityDataId,
178
+ );
179
+ rootDocument = metadata.rootDocument;
180
+ type = metadata.type;
181
+ }
182
+
183
+ const supportedRealityDataTypes = [
184
+ ITwinPlatform.RealityDataType.KML,
185
+ ITwinPlatform.RealityDataType.GeoJSON,
186
+ ];
187
+
188
+ if (!supportedRealityDataTypes.includes(type)) {
189
+ throw new RuntimeError(
190
+ `Reality data type is not a data source type: ${type}`,
191
+ );
192
+ }
193
+
194
+ const tilesetAccessUrl = await ITwinPlatform.getRealityDataURL(
195
+ iTwinId,
196
+ realityDataId,
197
+ rootDocument,
198
+ );
199
+
200
+ if (type === ITwinPlatform.RealityDataType.GeoJSON) {
201
+ return GeoJsonDataSource.load(tilesetAccessUrl);
202
+ }
203
+
204
+ // If we get here it's guaranteed to be a KML type
205
+ return KmlDataSource.load(tilesetAccessUrl);
206
+ };
207
+
138
208
  export default ITwinData;
@@ -1823,7 +1823,7 @@ Model.prototype.applyArticulations = function () {
1823
1823
  *
1824
1824
  * The given name may be the name of a glTF extension, like `"EXT_example_extension"`.
1825
1825
  * If the specified extension was present in the root of the underlying glTF asset,
1826
- * and a loder for the specified extension has processed the extension data, then
1826
+ * and a loader for the specified extension has processed the extension data, then
1827
1827
  * this will return the model representation of the extension.
1828
1828
  *
1829
1829
  * @param {string} extensionName The name of the extension
@@ -5,7 +5,7 @@ out vec4 positionEC;
5
5
  void main()
6
6
  {
7
7
  positionEC = czm_modelView * position;
8
- gl_Position = czm_modelViewProjection * position;
8
+ gl_Position = czm_projection * positionEC;
9
9
 
10
10
  czm_vertexLogDepth();
11
11
  }
@@ -6,7 +6,7 @@ out vec4 positionEC;\n\
6
6
  void main()\n\
7
7
  {\n\
8
8
  positionEC = czm_modelView * position;\n\
9
- gl_Position = czm_modelViewProjection * position;\n\
9
+ gl_Position = czm_projection * positionEC;\n\
10
10
  \n\
11
11
  czm_vertexLogDepth();\n\
12
12
  }\n\
package/index.d.ts CHANGED
@@ -8401,7 +8401,7 @@ export namespace ITwinPlatform {
8401
8401
  enum ExportType {
8402
8402
  }
8403
8403
  /**
8404
- * Types of Reality data
8404
+ * Types of Reality data. This is a partial list of types we know we can support
8405
8405
  */
8406
8406
  enum RealityDataType {
8407
8407
  }
@@ -18491,6 +18491,7 @@ export function defaultValue(a: any, b: any): any;
18491
18491
  */
18492
18492
  export function defined<Type>(value: Type): value is NonNullable<Type>;
18493
18493
 
18494
+
18494
18495
  /**
18495
18496
  * Destroys an object. Each of the object's functions, including functions in its prototype,
18496
18497
  * is replaced with a function that throws a {@link DeveloperError}, except for the object's
@@ -22746,6 +22747,7 @@ export namespace ModelGraphics {
22746
22747
  * @property [colorBlendMode = ColorBlendMode.HIGHLIGHT] - An enum Property specifying how the color blends with the model.
22747
22748
  * @property [colorBlendAmount = 0.5] - A numeric Property specifying the color strength when the <code>colorBlendMode</code> is <code>MIX</code>. A value of 0.0 results in the model's rendered color while a value of 1.0 results in a solid color, with any value in-between resulting in a mix of the two.
22748
22749
  * @property [imageBasedLightingFactor = new Cartesian2(1.0, 1.0)] - A property specifying the contribution from diffuse and specular image-based lighting.
22750
+ * @property [environmentMapOptions] - The properties for managing dynamic environment maps on this entity.
22749
22751
  * @property [lightColor] - A property specifying the light color when shading the model. When <code>undefined</code> the scene's light color is used instead.
22750
22752
  * @property [distanceDisplayCondition] - A Property specifying at what distance from the camera that this model will be displayed.
22751
22753
  * @property [nodeTransformations] - An object, where keys are names of nodes, and values are {@link TranslationRotationScale} Properties describing the transformation to apply to that node. The transformation is applied after the node's existing transformation as specified in the glTF, and does not replace the node's existing transformation.
@@ -22771,6 +22773,9 @@ export namespace ModelGraphics {
22771
22773
  colorBlendMode?: Property | ColorBlendMode;
22772
22774
  colorBlendAmount?: Property | number;
22773
22775
  imageBasedLightingFactor?: Property | Cartesian2;
22776
+ environmentMapOptions?: PropertyBag | {
22777
+ [key: string]: any;
22778
+ };
22774
22779
  lightColor?: Property | Color;
22775
22780
  distanceDisplayCondition?: Property | DistanceDisplayCondition;
22776
22781
  nodeTransformations?: PropertyBag | {
@@ -22878,6 +22883,10 @@ export class ModelGraphics {
22878
22883
  * A property specifying the {@link Cartesian2} used to scale the diffuse and specular image-based lighting contribution to the final color.
22879
22884
  */
22880
22885
  imageBasedLightingFactor: Property | undefined;
22886
+ /**
22887
+ * Gets or sets the {@link DynamicEnvironmentMapManager.ConstructorOptions} to apply to this model. This is represented as an {@link PropertyBag}.
22888
+ */
22889
+ environmentMapOptions: PropertyBag;
22881
22890
  /**
22882
22891
  * A property specifying the {@link Cartesian3} light color when shading the model. When <code>undefined</code> the scene's light color is used instead.
22883
22892
  */
@@ -29237,6 +29246,7 @@ export namespace Cesium3DTileset {
29237
29246
  * @property [pointCloudShading] - Options for constructing a {@link PointCloudShading} object to control point attenuation based on geometric error and lighting.
29238
29247
  * @property [lightColor] - The light color when shading models. When <code>undefined</code> the scene's light color is used instead.
29239
29248
  * @property [imageBasedLighting] - The properties for managing image-based lighting for this tileset.
29249
+ * @property [environmentMapOptions] - The properties for managing dynamic environment maps on this tileset.
29240
29250
  * @property [backFaceCulling = true] - Whether to cull back-facing geometry. When true, back face culling is determined by the glTF material's doubleSided property; when false, back face culling is disabled.
29241
29251
  * @property [enableShowOutline = true] - Whether to enable outlines for models using the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. This can be set to false to avoid the additional processing of geometry at load time. When false, the showOutlines and outlineColor options are ignored.
29242
29252
  * @property [showOutline = true] - Whether to display the outline for models using the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. When true, outlines are displayed. When false, outlines are not displayed.
@@ -29262,7 +29272,6 @@ export namespace Cesium3DTileset {
29262
29272
  * @property [debugShowRenderingStatistics = false] - For debugging only. When true, draws labels to indicate the number of commands, points, triangles and features for each tile.
29263
29273
  * @property [debugShowMemoryUsage = false] - For debugging only. When true, draws labels to indicate the texture and geometry memory in megabytes used by each tile.
29264
29274
  * @property [debugShowUrl = false] - For debugging only. When true, draws labels to indicate the url of each tile.
29265
- * @param [options.environmentMapOptions] - The properties for managing dynamic environment maps on this model.
29266
29275
  */
29267
29276
  type ConstructorOptions = {
29268
29277
  show?: boolean;
@@ -29302,6 +29311,7 @@ export namespace Cesium3DTileset {
29302
29311
  pointCloudShading?: any;
29303
29312
  lightColor?: Cartesian3;
29304
29313
  imageBasedLighting?: ImageBasedLighting;
29314
+ environmentMapOptions?: DynamicEnvironmentMapManager.ConstructorOptions;
29305
29315
  backFaceCulling?: boolean;
29306
29316
  enableShowOutline?: boolean;
29307
29317
  showOutline?: boolean;
@@ -31696,7 +31706,7 @@ export namespace DynamicEnvironmentMapManager {
31696
31706
  /**
31697
31707
  * Options for the DynamicEnvironmentMapManager constructor
31698
31708
  * @property [enabled = true] - If true, the environment map and related properties will continue to update.
31699
- * @property [mipmapLevels = 10] - The number of mipmap levels to generate for specular maps. More mipmap levels will produce a higher resolution specular reflection.
31709
+ * @property [mipmapLevels = 7] - The number of mipmap levels to generate for specular maps. More mipmap levels will produce a higher resolution specular reflection.
31700
31710
  * @property [maximumSecondsDifference = 3600] - The maximum amount of elapsed seconds before a new environment map is created.
31701
31711
  * @property [maximumPositionEpsilon = 1000] - The maximum difference in position before a new environment map is created, in meters. Small differences in position will not visibly affect results.
31702
31712
  * @property [atmosphereScatteringIntensity = 2.0] - The intensity of the scattered light emitted from the atmosphere. This should be adjusted relative to the value of {@link Scene.light} intensity.
@@ -34011,6 +34021,18 @@ export namespace ITwinData {
34011
34021
  * @param [rootDocument] - The path of the root document for this reality data
34012
34022
  */
34013
34023
  function createTilesetForRealityDataId(iTwinId: string, realityDataId: string, type?: ITwinPlatform.RealityDataType, rootDocument?: string): Promise<Cesium3DTileset>;
34024
+ /**
34025
+ * Create a data source of the correct type for the specified reality data id.
34026
+ * This function only works for KML and GeoJSON type data.
34027
+ *
34028
+ * If the <code>type</code> or <code>rootDocument</code> are not provided this function
34029
+ * will first request the full metadata for the specified reality data to fill these values.
34030
+ * @param iTwinId - The id of the iTwin to load data from
34031
+ * @param realityDataId - The id of the reality data to load
34032
+ * @param [type] - The type of this reality data
34033
+ * @param [rootDocument] - The path of the root document for this reality data
34034
+ */
34035
+ function createDataSourceForRealityDataId(iTwinId: string, realityDataId: string, type?: ITwinPlatform.RealityDataType, rootDocument?: string): Promise<GeoJsonDataSource | KmlDataSource>;
34014
34036
  }
34015
34037
 
34016
34038
  /**
@@ -37596,7 +37618,7 @@ export class Model {
37596
37618
  *
37597
37619
  * The given name may be the name of a glTF extension, like `"EXT_example_extension"`.
37598
37620
  * If the specified extension was present in the root of the underlying glTF asset,
37599
- * and a loder for the specified extension has processed the extension data, then
37621
+ * and a loader for the specified extension has processed the extension data, then
37600
37622
  * this will return the model representation of the extension.
37601
37623
  * @param extensionName - The name of the extension
37602
37624
  * @returns The object, or `undefined`