@cesium/engine 13.0.0 → 14.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 (150) hide show
  1. package/Build/Workers/{chunk-BZMHXDKV.js → chunk-3JBEPBPL.js} +13 -13
  2. package/Build/Workers/{chunk-W2E67GLE.js → chunk-3LYROPON.js} +13 -13
  3. package/Build/Workers/{chunk-3ZMTG4X5.js → chunk-3PIZQT3I.js} +4 -4
  4. package/Build/Workers/{chunk-Q4MTXEB7.js → chunk-3QLSKXKF.js} +6 -6
  5. package/Build/Workers/{chunk-EXDSJZ7J.js → chunk-4CHMVQTQ.js} +4 -4
  6. package/Build/Workers/{chunk-2TSF7N76.js → chunk-5KWRW7YL.js} +2 -2
  7. package/Build/Workers/{chunk-KRCUHV7P.js → chunk-5S5OOA6U.js} +1 -1
  8. package/Build/Workers/{chunk-MSKD73KW.js → chunk-77XPS7ZA.js} +10 -10
  9. package/Build/Workers/{chunk-2IIE2UZ3.js → chunk-7EO56M5R.js} +2 -2
  10. package/Build/Workers/{chunk-H7BML7HH.js → chunk-7UHKH6M3.js} +6 -6
  11. package/Build/Workers/{chunk-KCCTLUKK.js → chunk-7ZB2RVIQ.js} +10 -10
  12. package/Build/Workers/{chunk-OUIF26MQ.js → chunk-B4GSRXE3.js} +6 -6
  13. package/Build/Workers/{chunk-D3VPMNUR.js → chunk-CI2HEJFC.js} +13 -13
  14. package/Build/Workers/{chunk-Z7OYBX6P.js → chunk-D7ZBZPHV.js} +5 -5
  15. package/Build/Workers/{chunk-GJZQSAES.js → chunk-DT5NFR5C.js} +7 -7
  16. package/Build/Workers/{chunk-ZIWULRRD.js → chunk-ED6GLQTK.js} +1 -1
  17. package/Build/Workers/{chunk-CQDSGG3R.js → chunk-EWDGNOJE.js} +7 -7
  18. package/Build/Workers/{chunk-RGZWZ4PP.js → chunk-F4CUH4MR.js} +4 -4
  19. package/Build/Workers/{chunk-6HWW6KNV.js → chunk-FFBJDW4A.js} +6 -6
  20. package/Build/Workers/{chunk-FLPIQK2R.js → chunk-FX4R4MTH.js} +6 -6
  21. package/Build/Workers/{chunk-2OD54CUD.js → chunk-FYGLNDKG.js} +7 -7
  22. package/Build/Workers/{chunk-YDEZMDB7.js → chunk-G3BVMPWG.js} +2 -2
  23. package/Build/Workers/{chunk-YBDL7YPF.js → chunk-HEZHXDYB.js} +1 -1
  24. package/Build/Workers/{chunk-RIQGQMS4.js → chunk-HKHQ3EDR.js} +4 -4
  25. package/Build/Workers/{chunk-PMNQULFU.js → chunk-HUFQVUMY.js} +7 -7
  26. package/Build/Workers/{chunk-6ZOS2ACR.js → chunk-J7IH4EYI.js} +7 -7
  27. package/Build/Workers/{chunk-RR4M3ZGF.js → chunk-JHBPC4LK.js} +7 -7
  28. package/Build/Workers/{chunk-WXJY6NDI.js → chunk-JPDKYBLF.js} +13 -13
  29. package/Build/Workers/{chunk-W2DVQETH.js → chunk-K4AH3TDT.js} +35 -21
  30. package/Build/Workers/{chunk-S4SCKDK4.js → chunk-KHWLAQVA.js} +1 -1
  31. package/Build/Workers/{chunk-XQP37R5E.js → chunk-KM6MITPF.js} +5 -5
  32. package/Build/Workers/{chunk-H4Y7ADFL.js → chunk-KSYBJA4M.js} +5 -5
  33. package/Build/Workers/{chunk-3VHIUS7I.js → chunk-LJBJM6VI.js} +6 -6
  34. package/Build/Workers/{chunk-MMILY4S7.js → chunk-LNSWJ43X.js} +11 -11
  35. package/Build/Workers/{chunk-CUMDCSMT.js → chunk-LOZ4NKY3.js} +11 -11
  36. package/Build/Workers/{chunk-4IM6WQEI.js → chunk-LS3KVHYY.js} +6 -6
  37. package/Build/Workers/{chunk-GBXJIWAZ.js → chunk-MVM4JV5U.js} +9 -9
  38. package/Build/Workers/{chunk-HMMPNR4Z.js → chunk-N2XAJBC6.js} +12 -12
  39. package/Build/Workers/{chunk-FANORJU6.js → chunk-OMXHEJTK.js} +2 -2
  40. package/Build/Workers/{chunk-GNG3V432.js → chunk-PWF4EY5P.js} +4 -4
  41. package/Build/Workers/{chunk-KKVKSTWC.js → chunk-Q4ZVWJXX.js} +5 -5
  42. package/Build/Workers/{chunk-RC5N5SJL.js → chunk-SDIDRZDG.js} +7 -7
  43. package/Build/Workers/{chunk-BLTSMJIP.js → chunk-TVL3F7IU.js} +1 -1
  44. package/Build/Workers/{chunk-22NU5WU5.js → chunk-TY4DKOWR.js} +2 -2
  45. package/Build/Workers/{chunk-DIAH2ZTB.js → chunk-VCNOFQYH.js} +9 -9
  46. package/Build/Workers/{chunk-BFNZUP2C.js → chunk-WEHZP4SE.js} +14 -13
  47. package/Build/Workers/{chunk-PD2MCNV7.js → chunk-WVNLSTOF.js} +2 -2
  48. package/Build/Workers/{chunk-T5H7YWC7.js → chunk-XK4OP6VA.js} +17 -17
  49. package/Build/Workers/{chunk-NVFEDMX4.js → chunk-YJX7X577.js} +15 -15
  50. package/Build/Workers/{chunk-4HS475MU.js → chunk-Z3QWTHI7.js} +14 -14
  51. package/Build/Workers/{chunk-OZZD3VY4.js → chunk-ZGFIT57T.js} +17 -17
  52. package/Build/Workers/{chunk-JISDBAYP.js → chunk-ZMNLEL6W.js} +5 -5
  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 +15 -14
  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/Color.js +3 -3
  103. package/Source/Core/Credit.js +3 -3
  104. package/Source/Core/DistanceDisplayCondition.js +3 -3
  105. package/Source/Core/ITwinPlatform.js +3 -38
  106. package/Source/Core/Ion.js +1 -1
  107. package/Source/Core/JulianDate.js +14 -7
  108. package/Source/Core/OrientedBoundingBox.js +2 -2
  109. package/Source/Core/Spherical.js +3 -3
  110. package/Source/Core/defined.d.ts +11 -0
  111. package/Source/Core/writeTextToCanvas.js +0 -1
  112. package/Source/DataSources/BoundingSphereState.js +3 -3
  113. package/Source/DataSources/DataSourceClock.js +1 -1
  114. package/Source/DataSources/DataSourceDisplay.js +5 -2
  115. package/Source/DataSources/ModelGraphics.js +23 -1
  116. package/Source/DataSources/ModelVisualizer.js +22 -1
  117. package/Source/Renderer/AutomaticUniforms.js +2 -2
  118. package/Source/Scene/ArcGisMapService.js +1 -1
  119. package/Source/Scene/Billboard.js +1 -1
  120. package/Source/Scene/Cesium3DTile.js +56 -28
  121. package/Source/Scene/Cesium3DTilesVoxelProvider.js +17 -0
  122. package/Source/Scene/Cesium3DTileset.js +1 -1
  123. package/Source/Scene/ClippingPolygon.js +2 -2
  124. package/Source/Scene/DynamicEnvironmentMapManager.js +123 -66
  125. package/Source/Scene/GltfDracoLoader.js +45 -0
  126. package/Source/Scene/GltfIndexBufferLoader.js +5 -0
  127. package/Source/Scene/GltfLoader.js +17 -2
  128. package/Source/Scene/GltfVertexBufferLoader.js +13 -0
  129. package/Source/Scene/ITwinData.js +116 -0
  130. package/Source/Scene/ImageryLayer.js +1 -1
  131. package/Source/Scene/Label.js +1 -1
  132. package/Source/Scene/LabelCollection.js +0 -11
  133. package/Source/Scene/Model/Model.js +1 -1
  134. package/Source/Scene/Multiple3DTileContent.js +21 -8
  135. package/Source/Scene/PointPrimitive.js +1 -1
  136. package/Source/Scene/ResourceCache.js +17 -1
  137. package/Source/Scene/VoxelPrimitive.js +124 -0
  138. package/Source/Scene/VoxelProvider.js +10 -0
  139. package/Source/Scene/VoxelTraversal.js +88 -12
  140. package/Source/Scene/WebMapTileServiceImageryProvider.js +2 -2
  141. package/Source/Scene/createGooglePhotorealistic3DTileset.js +5 -8
  142. package/Source/Shaders/DepthPlaneVS.glsl +1 -1
  143. package/Source/Shaders/DepthPlaneVS.js +1 -1
  144. package/Source/Shaders/PolylineCommon.glsl +1 -1
  145. package/Source/Shaders/PolylineCommon.js +1 -1
  146. package/Source/Widget/CesiumWidget.js +16 -10
  147. package/Source/Workers/decodeDraco.js +4 -4
  148. package/index.d.ts +178 -42
  149. package/index.js +247 -247
  150. package/package.json +1 -1
@@ -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
  };
@@ -1,9 +1,11 @@
1
1
  import Check from "../Core/Check.js";
2
+ import ComponentDatatype from "../Core/ComponentDatatype.js";
2
3
  import defaultValue from "../Core/defaultValue.js";
3
4
  import defined from "../Core/defined.js";
4
5
  import DracoLoader from "./DracoLoader.js";
5
6
  import ResourceLoader from "./ResourceLoader.js";
6
7
  import ResourceLoaderState from "./ResourceLoaderState.js";
8
+ import VertexAttributeSemantic from "./VertexAttributeSemantic.js";
7
9
 
8
10
  /**
9
11
  * Load a draco buffer from a glTF.
@@ -18,6 +20,7 @@ import ResourceLoaderState from "./ResourceLoaderState.js";
18
20
  * @param {object} options Object with the following properties:
19
21
  * @param {ResourceCache} options.resourceCache The {@link ResourceCache} (to avoid circular dependencies).
20
22
  * @param {object} options.gltf The glTF JSON.
23
+ * @param {object} options.primitive The primitive containing the Draco extension.
21
24
  * @param {object} options.draco The Draco extension object.
22
25
  * @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
23
26
  * @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
@@ -29,6 +32,7 @@ function GltfDracoLoader(options) {
29
32
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
30
33
  const resourceCache = options.resourceCache;
31
34
  const gltf = options.gltf;
35
+ const primitive = options.primitive;
32
36
  const draco = options.draco;
33
37
  const gltfResource = options.gltfResource;
34
38
  const baseResource = options.baseResource;
@@ -37,6 +41,7 @@ function GltfDracoLoader(options) {
37
41
  //>>includeStart('debug', pragmas.debug);
38
42
  Check.typeOf.func("options.resourceCache", resourceCache);
39
43
  Check.typeOf.object("options.gltf", gltf);
44
+ Check.typeOf.object("options.primitive", primitive);
40
45
  Check.typeOf.object("options.draco", draco);
41
46
  Check.typeOf.object("options.gltfResource", gltfResource);
42
47
  Check.typeOf.object("options.baseResource", baseResource);
@@ -46,6 +51,7 @@ function GltfDracoLoader(options) {
46
51
  this._gltfResource = gltfResource;
47
52
  this._baseResource = baseResource;
48
53
  this._gltf = gltf;
54
+ this._primitive = primitive;
49
55
  this._draco = draco;
50
56
  this._cacheKey = cacheKey;
51
57
  this._bufferViewLoader = undefined;
@@ -169,6 +175,24 @@ async function processDecode(loader, decodePromise) {
169
175
  }
170
176
  }
171
177
 
178
+ const SemanticToDracoAttributeType = {};
179
+ SemanticToDracoAttributeType[VertexAttributeSemantic.POSITION] = "POSITION";
180
+ SemanticToDracoAttributeType[VertexAttributeSemantic.NORMAL] = "NORMAL";
181
+ SemanticToDracoAttributeType[VertexAttributeSemantic.COLOR] = "COLOR";
182
+ SemanticToDracoAttributeType[VertexAttributeSemantic.TEXCOORD] = "TEX_COORD";
183
+
184
+ function getDracoAttributeType(attribute) {
185
+ for (const semantic in SemanticToDracoAttributeType) {
186
+ if (SemanticToDracoAttributeType.hasOwnProperty(semantic)) {
187
+ if (attribute.startsWith(semantic)) {
188
+ return SemanticToDracoAttributeType[semantic];
189
+ }
190
+ }
191
+ }
192
+
193
+ return undefined;
194
+ }
195
+
172
196
  /**
173
197
  * Processes the resource until it becomes ready.
174
198
  *
@@ -203,12 +227,31 @@ GltfDracoLoader.prototype.process = function (frameState) {
203
227
  }
204
228
 
205
229
  const draco = this._draco;
230
+ const primitive = this._primitive;
206
231
  const gltf = this._gltf;
207
232
  const bufferViews = gltf.bufferViews;
208
233
  const bufferViewId = draco.bufferView;
209
234
  const bufferView = bufferViews[bufferViewId];
210
235
  const compressedAttributes = draco.attributes;
211
236
 
237
+ // Skip de-quantization transform if present for floating point attributes.
238
+ // They will stay quantized in memory and be dequantized in the shader.
239
+ const attributesToSkipTransform = [];
240
+
241
+ for (const attribute in primitive.attributes) {
242
+ if (primitive.attributes.hasOwnProperty(attribute)) {
243
+ const dracoAttributeType = getDracoAttributeType(attribute);
244
+ if (defined(dracoAttributeType)) {
245
+ const accessor = gltf.accessors[primitive.attributes[attribute]];
246
+ if (accessor.componentType === ComponentDatatype.FLOAT) {
247
+ if (!attributesToSkipTransform.includes(dracoAttributeType)) {
248
+ attributesToSkipTransform.push(dracoAttributeType);
249
+ }
250
+ }
251
+ }
252
+ }
253
+ }
254
+
212
255
  const decodeOptions = {
213
256
  // Need to make a copy of the typed array otherwise the underlying
214
257
  // ArrayBuffer may be accessed on both the worker and the main thread. This
@@ -218,6 +261,7 @@ GltfDracoLoader.prototype.process = function (frameState) {
218
261
  bufferView: bufferView,
219
262
  compressedAttributes: compressedAttributes,
220
263
  dequantizeInShader: true,
264
+ attributesToSkipTransform: attributesToSkipTransform,
221
265
  };
222
266
 
223
267
  const decodePromise = DracoLoader.decodeBufferView(decodeOptions);
@@ -243,6 +287,7 @@ GltfDracoLoader.prototype.unload = function () {
243
287
  this._bufferViewTypedArray = undefined;
244
288
  this._decodedData = undefined;
245
289
  this._gltf = undefined;
290
+ this._primitive = undefined;
246
291
  };
247
292
 
248
293
  export default GltfDracoLoader;
@@ -27,6 +27,7 @@ import ResourceLoaderState from "./ResourceLoaderState.js";
27
27
  * @param {number} options.accessorId The accessor ID corresponding to the index buffer.
28
28
  * @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
29
29
  * @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
30
+ * @param {object} [options.primitive] The primitive containing the Draco extension.
30
31
  * @param {object} [options.draco] The Draco extension object.
31
32
  * @param {string} [options.cacheKey] The cache key of the resource.
32
33
  * @param {boolean} [options.asynchronous=true] Determines if WebGL resource creation will be spread out over several frames or block until all WebGL resources are created.
@@ -41,6 +42,7 @@ function GltfIndexBufferLoader(options) {
41
42
  const accessorId = options.accessorId;
42
43
  const gltfResource = options.gltfResource;
43
44
  const baseResource = options.baseResource;
45
+ const primitive = options.primitive;
44
46
  const draco = options.draco;
45
47
  const cacheKey = options.cacheKey;
46
48
  const asynchronous = defaultValue(options.asynchronous, true);
@@ -68,6 +70,7 @@ function GltfIndexBufferLoader(options) {
68
70
  this._gltf = gltf;
69
71
  this._accessorId = accessorId;
70
72
  this._indexDatatype = indexDatatype;
73
+ this._primitive = primitive;
71
74
  this._draco = draco;
72
75
  this._cacheKey = cacheKey;
73
76
  this._asynchronous = asynchronous;
@@ -174,6 +177,7 @@ async function loadFromDraco(indexBufferLoader) {
174
177
  try {
175
178
  const dracoLoader = resourceCache.getDracoLoader({
176
179
  gltf: indexBufferLoader._gltf,
180
+ primitive: indexBufferLoader._primitive,
177
181
  draco: indexBufferLoader._draco,
178
182
  gltfResource: indexBufferLoader._gltfResource,
179
183
  baseResource: indexBufferLoader._baseResource,
@@ -411,6 +415,7 @@ GltfIndexBufferLoader.prototype.unload = function () {
411
415
  this._typedArray = undefined;
412
416
  this._buffer = undefined;
413
417
  this._gltf = undefined;
418
+ this._primitive = undefined;
414
419
  };
415
420
 
416
421
  export default GltfIndexBufferLoader;
@@ -685,6 +685,7 @@ function getVertexBufferLoader(
685
685
  loader,
686
686
  accessorId,
687
687
  semantic,
688
+ primitive,
688
689
  draco,
689
690
  loadBuffer,
690
691
  loadTypedArray,
@@ -700,6 +701,7 @@ function getVertexBufferLoader(
700
701
  baseResource: loader._baseResource,
701
702
  frameState: frameState,
702
703
  bufferViewId: bufferViewId,
704
+ primitive: primitive,
703
705
  draco: draco,
704
706
  attributeSemantic: semantic,
705
707
  accessorId: accessorId,
@@ -714,6 +716,7 @@ function getVertexBufferLoader(
714
716
  function getIndexBufferLoader(
715
717
  loader,
716
718
  accessorId,
719
+ primitive,
717
720
  draco,
718
721
  loadBuffer,
719
722
  loadTypedArray,
@@ -725,6 +728,7 @@ function getIndexBufferLoader(
725
728
  gltfResource: loader._gltfResource,
726
729
  baseResource: loader._baseResource,
727
730
  frameState: frameState,
731
+ primitive: primitive,
728
732
  draco: draco,
729
733
  asynchronous: loader._asynchronous,
730
734
  loadBuffer: loadBuffer,
@@ -1154,6 +1158,7 @@ function loadAttribute(
1154
1158
  loader,
1155
1159
  accessorId,
1156
1160
  semanticInfo,
1161
+ primitive,
1157
1162
  draco,
1158
1163
  loadBuffer,
1159
1164
  loadTypedArray,
@@ -1188,6 +1193,7 @@ function loadAttribute(
1188
1193
  loader,
1189
1194
  accessorId,
1190
1195
  gltfSemantic,
1196
+ primitive,
1191
1197
  draco,
1192
1198
  loadBuffer,
1193
1199
  loadTypedArray,
@@ -1232,6 +1238,7 @@ function loadVertexAttribute(
1232
1238
  loader,
1233
1239
  accessorId,
1234
1240
  semanticInfo,
1241
+ primitive,
1235
1242
  draco,
1236
1243
  hasInstances,
1237
1244
  needsPostProcessing,
@@ -1278,6 +1285,7 @@ function loadVertexAttribute(
1278
1285
  loader,
1279
1286
  accessorId,
1280
1287
  semanticInfo,
1288
+ primitive,
1281
1289
  draco,
1282
1290
  loadBuffer,
1283
1291
  loadTypedArray,
@@ -1345,12 +1353,13 @@ function loadInstancedAttribute(
1345
1353
 
1346
1354
  const loadTypedArray = loadAsTypedArrayOnly || loadTranslationAsTypedArray;
1347
1355
 
1348
- // Don't pass in draco object since instanced attributes can't be draco compressed
1356
+ // Don't pass in primitive or draco object since instanced attributes can't be draco compressed
1349
1357
  return loadAttribute(
1350
1358
  loader,
1351
1359
  accessorId,
1352
1360
  semanticInfo,
1353
1361
  undefined,
1362
+ undefined,
1354
1363
  loadBuffer,
1355
1364
  loadTypedArray,
1356
1365
  frameState,
@@ -1360,6 +1369,7 @@ function loadInstancedAttribute(
1360
1369
  function loadIndices(
1361
1370
  loader,
1362
1371
  accessorId,
1372
+ primitive,
1363
1373
  draco,
1364
1374
  hasFeatureIds,
1365
1375
  needsPostProcessing,
@@ -1403,6 +1413,7 @@ function loadIndices(
1403
1413
  const indexBufferLoader = getIndexBufferLoader(
1404
1414
  loader,
1405
1415
  accessorId,
1416
+ primitive,
1406
1417
  draco,
1407
1418
  loadBuffer,
1408
1419
  loadTypedArray,
@@ -1865,7 +1876,8 @@ function loadMorphTarget(
1865
1876
  ) {
1866
1877
  const morphTarget = new MorphTarget();
1867
1878
 
1868
- // Don't pass in draco object since morph targets can't be draco compressed
1879
+ // Don't pass in primitive or draco object since morph targets can't be draco compressed
1880
+ const primitive = undefined;
1869
1881
  const draco = undefined;
1870
1882
  const hasInstances = false;
1871
1883
 
@@ -1885,6 +1897,7 @@ function loadMorphTarget(
1885
1897
  loader,
1886
1898
  accessorId,
1887
1899
  semanticInfo,
1900
+ primitive,
1888
1901
  draco,
1889
1902
  hasInstances,
1890
1903
  needsPostProcessing,
@@ -1970,6 +1983,7 @@ function loadPrimitive(loader, gltfPrimitive, hasInstances, frameState) {
1970
1983
  loader,
1971
1984
  accessorId,
1972
1985
  semanticInfo,
1986
+ gltfPrimitive,
1973
1987
  draco,
1974
1988
  hasInstances,
1975
1989
  needsPostProcessing,
@@ -2002,6 +2016,7 @@ function loadPrimitive(loader, gltfPrimitive, hasInstances, frameState) {
2002
2016
  const indicesPlan = loadIndices(
2003
2017
  loader,
2004
2018
  indices,
2019
+ gltfPrimitive,
2005
2020
  draco,
2006
2021
  hasFeatureIds,
2007
2022
  needsPostProcessing,