@cesium/engine 7.0.0 → 9.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 (200) hide show
  1. package/Build/ThirdParty/Workers/z-worker-pako.js +1 -5
  2. package/Build/Workers/{chunk-7XEAYGZK.js → chunk-24YTYWNB.js} +10 -10
  3. package/Build/Workers/{chunk-IQBYFRVW.js → chunk-2632RVPI.js} +7 -7
  4. package/Build/Workers/chunk-2KACWKS4.js +501 -0
  5. package/Build/Workers/{chunk-QZAD5O7I.js → chunk-2XPLH3JY.js} +7 -7
  6. package/Build/Workers/{chunk-JY5YEZFA.js → chunk-2ZBL3MVO.js} +8 -8
  7. package/Build/Workers/{chunk-ZK5JOS3D.js → chunk-3NCVAGDA.js} +14 -14
  8. package/Build/Workers/{chunk-AR5DNBJ4.js → chunk-5R6VWLMH.js} +6 -6
  9. package/Build/Workers/{chunk-PTQQUQC3.js → chunk-5TIV3L26.js} +13 -13
  10. package/Build/Workers/{chunk-BZP4T2JJ.js → chunk-6WF3KIF5.js} +10 -10
  11. package/Build/Workers/{chunk-5WQ523AW.js → chunk-73FKKY52.js} +5 -5
  12. package/Build/Workers/{chunk-F6SE42BK.js → chunk-7COR472O.js} +15 -472
  13. package/Build/Workers/{chunk-72SANQJV.js → chunk-ADOVHYWO.js} +9 -5
  14. package/Build/Workers/{chunk-5YLJ77FF.js → chunk-BCU2LH5T.js} +12 -11
  15. package/Build/Workers/{chunk-4EBHOMFX.js → chunk-C3XBUYBO.js} +17 -17
  16. package/Build/Workers/{chunk-IX2JCCNM.js → chunk-C6OI26DR.js} +1 -1
  17. package/Build/Workers/{chunk-2HJWSU7B.js → chunk-CO35JNNE.js} +4 -4
  18. package/Build/Workers/{chunk-OVLG3FRS.js → chunk-DGDUKCJJ.js} +6 -6
  19. package/Build/Workers/{chunk-DTAIXKTO.js → chunk-DPUSFA7S.js} +6 -6
  20. package/Build/Workers/{chunk-R5X4OQT4.js → chunk-E6WXPSJS.js} +7 -7
  21. package/Build/Workers/{chunk-VK3EJHWI.js → chunk-EOXYZ34O.js} +2 -2
  22. package/Build/Workers/{chunk-RAEV7K66.js → chunk-EPKE7GE3.js} +5 -5
  23. package/Build/Workers/{chunk-GV56Q4LU.js → chunk-GFA4SMXV.js} +11 -11
  24. package/Build/Workers/{chunk-NKPBIX7F.js → chunk-GXUXEOE2.js} +1 -1
  25. package/Build/Workers/{chunk-NY3K4IM3.js → chunk-HBQPB6IH.js} +12 -12
  26. package/Build/Workers/{chunk-6HZQPRUS.js → chunk-I37B3MZ2.js} +1 -1
  27. package/Build/Workers/{chunk-VRGFV2UO.js → chunk-L4BW3RUA.js} +10 -10
  28. package/Build/Workers/{chunk-6VJVYK2V.js → chunk-LAQP3SCC.js} +2 -2
  29. package/Build/Workers/{chunk-PNBGBETF.js → chunk-LQJ5FFFR.js} +10 -10
  30. package/Build/Workers/{chunk-UAEW6HKG.js → chunk-M2AYBTNH.js} +13 -13
  31. package/Build/Workers/{chunk-YUCVWAY6.js → chunk-MWV7IZK4.js} +7 -7
  32. package/Build/Workers/{chunk-JXDC723O.js → chunk-N4KXMWQU.js} +2 -2
  33. package/Build/Workers/{chunk-XWXM2O2R.js → chunk-NP2GYYE5.js} +6 -6
  34. package/Build/Workers/{chunk-GEJTYLCO.js → chunk-NZWNZA6S.js} +5 -5
  35. package/Build/Workers/{chunk-LZGHD6NY.js → chunk-P2YAAMT2.js} +15 -15
  36. package/Build/Workers/{chunk-S6SKF6DT.js → chunk-P4XKB3QZ.js} +5 -5
  37. package/Build/Workers/{chunk-U2VCRRQW.js → chunk-PXB7T27O.js} +6 -6
  38. package/Build/Workers/{chunk-RV7ZYPFT.js → chunk-QCQUZGXI.js} +4 -4
  39. package/Build/Workers/{chunk-JJ4VBOQ3.js → chunk-QKBGRKKG.js} +4 -4
  40. package/Build/Workers/{chunk-ODW7WYM4.js → chunk-RMOEYCZW.js} +2 -2
  41. package/Build/Workers/{chunk-ZUA2UUNV.js → chunk-RSJXEO2A.js} +2 -2
  42. package/Build/Workers/{chunk-UDO6BFSF.js → chunk-RV7ZOSS6.js} +13 -13
  43. package/Build/Workers/{chunk-LZ7JIV3K.js → chunk-SE4PXOEA.js} +17 -17
  44. package/Build/Workers/{chunk-S4MAZ3SS.js → chunk-SS4ESNE3.js} +2 -2
  45. package/Build/Workers/{chunk-AIPU2VSX.js → chunk-TJBU6GML.js} +6 -6
  46. package/Build/Workers/{chunk-5M3U6ZMA.js → chunk-TZORKRNK.js} +1 -1
  47. package/Build/Workers/{chunk-MY3VNFGQ.js → chunk-VR5RBW52.js} +7 -7
  48. package/Build/Workers/{chunk-FP6GYBFX.js → chunk-WHUSTDIB.js} +10 -10
  49. package/Build/Workers/{chunk-5HDYHG3F.js → chunk-X2F6BEPY.js} +13 -13
  50. package/Build/Workers/{chunk-WZU2YLWG.js → chunk-X6XOMPWL.js} +3 -3
  51. package/Build/Workers/{chunk-UGK3FCDY.js → chunk-YDVSBWEO.js} +1 -1
  52. package/Build/Workers/{chunk-46UD5ABS.js → chunk-YV4H2Y7M.js} +4 -4
  53. package/Build/Workers/{chunk-WBQCVXR3.js → chunk-Z7FQLK6N.js} +4 -4
  54. package/Build/Workers/{chunk-L2ZN645J.js → chunk-ZNVSKMQ2.js} +6 -6
  55. package/Build/Workers/{chunk-JCNXK6EL.js → chunk-ZYPTP7GS.js} +11 -11
  56. package/Build/Workers/combineGeometry.js +24 -23
  57. package/Build/Workers/createBoxGeometry.js +18 -17
  58. package/Build/Workers/createBoxOutlineGeometry.js +16 -15
  59. package/Build/Workers/createCircleGeometry.js +26 -25
  60. package/Build/Workers/createCircleOutlineGeometry.js +19 -18
  61. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -32
  62. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -30
  63. package/Build/Workers/createCorridorGeometry.js +29 -28
  64. package/Build/Workers/createCorridorOutlineGeometry.js +28 -27
  65. package/Build/Workers/createCylinderGeometry.js +20 -19
  66. package/Build/Workers/createCylinderOutlineGeometry.js +18 -17
  67. package/Build/Workers/createEllipseGeometry.js +26 -25
  68. package/Build/Workers/createEllipseOutlineGeometry.js +19 -18
  69. package/Build/Workers/createEllipsoidGeometry.js +19 -18
  70. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -17
  71. package/Build/Workers/createFrustumGeometry.js +18 -17
  72. package/Build/Workers/createFrustumOutlineGeometry.js +18 -17
  73. package/Build/Workers/createGeometry.js +54 -33
  74. package/Build/Workers/createGroundPolylineGeometry.js +22 -21
  75. package/Build/Workers/createPlaneGeometry.js +16 -15
  76. package/Build/Workers/createPlaneOutlineGeometry.js +15 -14
  77. package/Build/Workers/createPolygonGeometry.js +33 -32
  78. package/Build/Workers/createPolygonOutlineGeometry.js +30 -29
  79. package/Build/Workers/createPolylineGeometry.js +25 -24
  80. package/Build/Workers/createPolylineVolumeGeometry.js +31 -30
  81. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -26
  82. package/Build/Workers/createRectangleGeometry.js +27 -26
  83. package/Build/Workers/createRectangleOutlineGeometry.js +20 -19
  84. package/Build/Workers/createSimplePolylineGeometry.js +23 -22
  85. package/Build/Workers/createSphereGeometry.js +19 -18
  86. package/Build/Workers/createSphereOutlineGeometry.js +18 -17
  87. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  88. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  89. package/Build/Workers/createVectorTileGeometries.js +24 -23
  90. package/Build/Workers/createVectorTilePoints.js +12 -12
  91. package/Build/Workers/createVectorTilePolygons.js +22 -21
  92. package/Build/Workers/createVectorTilePolylines.js +14 -14
  93. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -21
  94. package/Build/Workers/createVerticesFromHeightmap.js +22 -21
  95. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -18
  96. package/Build/Workers/createWallGeometry.js +24 -23
  97. package/Build/Workers/createWallOutlineGeometry.js +23 -22
  98. package/Build/Workers/decodeDraco.js +11 -11
  99. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  100. package/Build/Workers/decodeI3S.js +601 -92
  101. package/Build/Workers/transcodeKTX2.js +7 -7
  102. package/Build/Workers/transferTypedArrayTest.js +1 -1
  103. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -21
  104. package/Source/Core/Check.d.ts +127 -0
  105. package/Source/Core/Check.js +0 -1
  106. package/Source/Core/Ellipsoid.js +6 -0
  107. package/Source/Core/Geometry.js +1 -1
  108. package/Source/Core/IntersectionTests.js +6 -3
  109. package/Source/Core/Ion.js +1 -1
  110. package/Source/Core/PixelFormat.js +5 -0
  111. package/Source/Core/PolygonGeometry.js +1 -1
  112. package/Source/Core/Transforms.js +3 -0
  113. package/Source/Core/VerticalExaggeration.js +2 -1
  114. package/Source/Core/srgbToLinear.js +32 -0
  115. package/Source/DataSources/CzmlDataSource.js +51 -23
  116. package/Source/DataSources/DataSourceDisplay.js +27 -0
  117. package/Source/DataSources/Entity.js +20 -2
  118. package/Source/DataSources/GeometryUpdaterSet.js +114 -0
  119. package/Source/DataSources/GeometryVisualizer.js +19 -83
  120. package/Source/Renderer/Context.js +10 -0
  121. package/Source/Renderer/ContextLimits.js +2 -0
  122. package/Source/Renderer/demodernizeShader.js +4 -1
  123. package/Source/Scene/ArcGisMapService.js +1 -1
  124. package/Source/Scene/Axis.js +12 -7
  125. package/Source/Scene/Billboard.js +32 -0
  126. package/Source/Scene/BillboardCollection.js +1 -1
  127. package/Source/Scene/BingMapsImageryProvider.js +4 -0
  128. package/Source/Scene/Camera.js +46 -4
  129. package/Source/Scene/Cesium3DTilesVoxelProvider.js +2 -9
  130. package/Source/Scene/Cesium3DTileset.js +10 -7
  131. package/Source/Scene/Cesium3DTilesetBaseTraversal.js +2 -4
  132. package/Source/Scene/FrameState.js +5 -0
  133. package/Source/Scene/Globe.js +0 -67
  134. package/Source/Scene/GlobeTranslucencyState.js +1 -1
  135. package/Source/Scene/GltfPipeline/updateVersion.js +69 -68
  136. package/Source/Scene/I3SDataProvider.js +270 -53
  137. package/Source/Scene/I3SDecoder.js +8 -1
  138. package/Source/Scene/I3SFeature.js +2 -5
  139. package/Source/Scene/I3SField.js +136 -31
  140. package/Source/Scene/I3SGeometry.js +70 -2
  141. package/Source/Scene/I3SLayer.js +55 -10
  142. package/Source/Scene/I3SNode.js +175 -18
  143. package/Source/Scene/I3SStatistics.js +94 -0
  144. package/Source/Scene/I3SSublayer.js +176 -0
  145. package/Source/Scene/I3SSymbology.js +337 -0
  146. package/Source/Scene/KeyframeNode.js +1 -1
  147. package/Source/Scene/Label.js +33 -0
  148. package/Source/Scene/LabelCollection.js +2 -1
  149. package/Source/Scene/Model/pickModel.js +25 -7
  150. package/Source/Scene/PickFramebuffer.js +37 -2
  151. package/Source/Scene/Picking.js +113 -39
  152. package/Source/Scene/Primitive.js +6 -5
  153. package/Source/Scene/Scene.js +126 -42
  154. package/Source/Scene/ScreenSpaceCameraController.js +21 -7
  155. package/Source/Scene/SensorVolumePortionToDisplay.js +69 -0
  156. package/Source/Scene/SpatialNode.js +12 -19
  157. package/Source/Scene/StructuralMetadata.js +1 -1
  158. package/Source/Scene/VoxelBoxShape.js +67 -6
  159. package/Source/Scene/VoxelCell.js +273 -0
  160. package/Source/Scene/VoxelCylinderShape.js +117 -163
  161. package/Source/Scene/VoxelEllipsoidShape.js +255 -304
  162. package/Source/Scene/VoxelPrimitive.js +109 -15
  163. package/Source/Scene/VoxelRenderResources.js +12 -3
  164. package/Source/Scene/VoxelShape.js +7 -4
  165. package/Source/Scene/VoxelTraversal.js +76 -54
  166. package/Source/Scene/buildVoxelDrawCommands.js +23 -0
  167. package/Source/Scene/createGooglePhotorealistic3DTileset.js +1 -0
  168. package/Source/Scene/processVoxelProperties.js +3 -0
  169. package/Source/Shaders/Voxels/IntersectBox.glsl +21 -47
  170. package/Source/Shaders/Voxels/IntersectBox.js +21 -47
  171. package/Source/Shaders/Voxels/IntersectClippingPlanes.glsl +1 -1
  172. package/Source/Shaders/Voxels/IntersectClippingPlanes.js +1 -1
  173. package/Source/Shaders/Voxels/IntersectCylinder.glsl +76 -203
  174. package/Source/Shaders/Voxels/IntersectCylinder.js +76 -203
  175. package/Source/Shaders/Voxels/IntersectEllipsoid.glsl +220 -229
  176. package/Source/Shaders/Voxels/IntersectEllipsoid.js +220 -229
  177. package/Source/Shaders/Voxels/IntersectLongitude.glsl +102 -0
  178. package/Source/Shaders/Voxels/IntersectLongitude.js +104 -0
  179. package/Source/Shaders/Voxels/IntersectionUtils.glsl +33 -11
  180. package/Source/Shaders/Voxels/IntersectionUtils.js +33 -11
  181. package/Source/Shaders/Voxels/Megatexture.glsl +1 -2
  182. package/Source/Shaders/Voxels/Megatexture.js +1 -2
  183. package/Source/Shaders/Voxels/Octree.glsl +14 -9
  184. package/Source/Shaders/Voxels/Octree.js +14 -9
  185. package/Source/Shaders/Voxels/VoxelFS.glsl +128 -40
  186. package/Source/Shaders/Voxels/VoxelFS.js +128 -40
  187. package/Source/Shaders/Voxels/VoxelUtils.glsl +31 -0
  188. package/Source/Shaders/Voxels/VoxelUtils.js +33 -0
  189. package/Source/Shaders/Voxels/convertUvToBox.glsl +24 -3
  190. package/Source/Shaders/Voxels/convertUvToBox.js +24 -4
  191. package/Source/Shaders/Voxels/convertUvToCylinder.glsl +64 -40
  192. package/Source/Shaders/Voxels/convertUvToCylinder.js +64 -40
  193. package/Source/Shaders/Voxels/convertUvToEllipsoid.glsl +100 -91
  194. package/Source/Shaders/Voxels/convertUvToEllipsoid.js +100 -91
  195. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  196. package/Source/Workers/createGeometry.js +40 -11
  197. package/Source/Workers/decodeI3S.js +720 -94
  198. package/index.d.ts +542 -40
  199. package/index.js +75 -66
  200. package/package.json +2 -2
@@ -255,6 +255,8 @@ function ScreenSpaceCameraController(scene) {
255
255
  this._globe = undefined;
256
256
  this._ellipsoid = undefined;
257
257
 
258
+ this._lastGlobeHeight = 0.0;
259
+
258
260
  this._aggregator = new CameraEventAggregator(scene.canvas);
259
261
 
260
262
  this._lastInertiaSpinMovement = undefined;
@@ -1645,7 +1647,7 @@ function rotateCVOnTerrain(controller, startPosition, movement) {
1645
1647
  );
1646
1648
 
1647
1649
  if (controller.enableCollisionDetection) {
1648
- adjustHeightForTerrain(controller);
1650
+ adjustHeightForTerrain(controller, true);
1649
1651
  }
1650
1652
 
1651
1653
  if (!Cartesian3.equals(camera.positionWC, originalPosition)) {
@@ -2651,7 +2653,7 @@ function tilt3DOnTerrain(controller, startPosition, movement) {
2651
2653
  );
2652
2654
 
2653
2655
  if (controller.enableCollisionDetection) {
2654
- adjustHeightForTerrain(controller);
2656
+ adjustHeightForTerrain(controller, true);
2655
2657
  }
2656
2658
 
2657
2659
  if (!Cartesian3.equals(camera.positionWC, originalPosition)) {
@@ -2854,7 +2856,7 @@ function update3D(controller) {
2854
2856
  const scratchAdjustHeightTransform = new Matrix4();
2855
2857
  const scratchAdjustHeightCartographic = new Cartographic();
2856
2858
 
2857
- function adjustHeightForTerrain(controller) {
2859
+ function adjustHeightForTerrain(controller, cameraChanged) {
2858
2860
  controller._adjustedHeightForTerrain = true;
2859
2861
 
2860
2862
  const scene = controller._scene;
@@ -2889,7 +2891,15 @@ function adjustHeightForTerrain(controller) {
2889
2891
  const globeHeight = controller._scene.globeHeight;
2890
2892
  if (defined(globeHeight)) {
2891
2893
  const height = globeHeight + controller.minimumZoomDistance;
2892
- if (cartographic.height < height) {
2894
+ const difference = globeHeight - controller._lastGlobeHeight;
2895
+ const percentDifference = difference / controller._lastGlobeHeight;
2896
+
2897
+ // Unless the camera has been moved by user input, to avoid big jumps during tile loads
2898
+ // only make height updates when the globe height has been fairly stable across several frames
2899
+ if (
2900
+ cartographic.height < height &&
2901
+ (cameraChanged || Math.abs(percentDifference) <= 0.1)
2902
+ ) {
2893
2903
  cartographic.height = height;
2894
2904
  if (mode === SceneMode.SCENE3D) {
2895
2905
  ellipsoid.cartographicToCartesian(cartographic, camera.position);
@@ -2898,6 +2908,12 @@ function adjustHeightForTerrain(controller) {
2898
2908
  }
2899
2909
  heightUpdated = true;
2900
2910
  }
2911
+
2912
+ if (cameraChanged || Math.abs(percentDifference) <= 0.1) {
2913
+ controller._lastGlobeHeight = globeHeight;
2914
+ } else {
2915
+ controller._lastGlobeHeight += difference * 0.1;
2916
+ }
2901
2917
  }
2902
2918
  }
2903
2919
 
@@ -3004,9 +3020,7 @@ ScreenSpaceCameraController.prototype.update = function () {
3004
3020
  const cameraChanged =
3005
3021
  !Cartesian3.equals(previousPosition, camera.positionWC) ||
3006
3022
  !Cartesian3.equals(previousDirection, camera.directionWC);
3007
- if (cameraChanged) {
3008
- adjustHeightForTerrain(this);
3009
- }
3023
+ adjustHeightForTerrain(this, cameraChanged);
3010
3024
  }
3011
3025
 
3012
3026
  this._aggregator.reset();
@@ -0,0 +1,69 @@
1
+ import DeveloperError from "../Core/DeveloperError.js";
2
+
3
+ /**
4
+ * Constants used to indicated what part of the sensor volume to display.
5
+ *
6
+ * @enum {Number}
7
+ */
8
+ const SensorVolumePortionToDisplay = {
9
+ /**
10
+ * 0x0000. Display the complete sensor volume.
11
+ *
12
+ * @type {Number}
13
+ * @constant
14
+ */
15
+ COMPLETE: 0x0000,
16
+ /**
17
+ * 0x0001. Display the portion of the sensor volume that lies below the true horizon of the ellipsoid.
18
+ *
19
+ * @type {Number}
20
+ * @constant
21
+ */
22
+ BELOW_ELLIPSOID_HORIZON: 0x0001,
23
+ /**
24
+ * 0x0002. Display the portion of the sensor volume that lies above the true horizon of the ellipsoid.
25
+ *
26
+ * @type {Number}
27
+ * @constant
28
+ */
29
+ ABOVE_ELLIPSOID_HORIZON: 0x0002,
30
+ };
31
+
32
+ /**
33
+ * Validates that the provided value is a valid {@link SensorVolumePortionToDisplay} enumeration value.
34
+ *
35
+ * @param {SensorVolumePortionToDisplay} portionToDisplay The value to validate.
36
+ *
37
+ * @returns {Boolean} <code>true</code> if the provided value is a valid enumeration value; otherwise, <code>false</code>.
38
+ */
39
+ SensorVolumePortionToDisplay.validate = function (portionToDisplay) {
40
+ return (
41
+ portionToDisplay === SensorVolumePortionToDisplay.COMPLETE ||
42
+ portionToDisplay === SensorVolumePortionToDisplay.BELOW_ELLIPSOID_HORIZON ||
43
+ portionToDisplay === SensorVolumePortionToDisplay.ABOVE_ELLIPSOID_HORIZON
44
+ );
45
+ };
46
+
47
+ /**
48
+ * Converts the provided value to its corresponding enumeration string.
49
+ *
50
+ * @param {SensorVolumePortionToDisplay} portionToDisplay The value to be converted to its corresponding enumeration string.
51
+ *
52
+ * @returns {String} The enumeration string corresponding to the value.
53
+ */
54
+ SensorVolumePortionToDisplay.toString = function (portionToDisplay) {
55
+ switch (portionToDisplay) {
56
+ case SensorVolumePortionToDisplay.COMPLETE:
57
+ return "COMPLETE";
58
+ case SensorVolumePortionToDisplay.BELOW_ELLIPSOID_HORIZON:
59
+ return "BELOW_ELLIPSOID_HORIZON";
60
+ case SensorVolumePortionToDisplay.ABOVE_ELLIPSOID_HORIZON:
61
+ return "ABOVE_ELLIPSOID_HORIZON";
62
+ default:
63
+ throw new DeveloperError(
64
+ "SensorVolumePortionToDisplay value is not valid and cannot be converted to a String."
65
+ );
66
+ }
67
+ };
68
+
69
+ export default SensorVolumePortionToDisplay;
@@ -23,7 +23,6 @@ import OrientedBoundingBox from "../Core/OrientedBoundingBox.js";
23
23
  */
24
24
  function SpatialNode(level, x, y, z, parent, shape, voxelDimensions) {
25
25
  /**
26
- * @ignore
27
26
  * @type {SpatialNode[]}
28
27
  */
29
28
  this.children = undefined;
@@ -35,24 +34,24 @@ function SpatialNode(level, x, y, z, parent, shape, voxelDimensions) {
35
34
  this.z = z;
36
35
 
37
36
  /**
38
- * @ignore
37
+ * @type {Cartesian3}
38
+ */
39
+ this.dimensions = Cartesian3.clone(voxelDimensions);
40
+ /**
39
41
  * @type {KeyframeNode[]}
40
42
  */
41
43
  this.keyframeNodes = [];
42
44
  /**
43
- * @ignore
44
45
  * @type {KeyframeNode[]}
45
46
  */
46
47
  this.renderableKeyframeNodes = [];
47
48
 
48
49
  this.renderableKeyframeNodeLerp = 0.0;
49
50
  /**
50
- * @ignore
51
51
  * @type {KeyframeNode}
52
52
  */
53
53
  this.renderableKeyframeNodePrevious = undefined;
54
54
  /**
55
- * @ignore
56
55
  * @type {KeyframeNode}
57
56
  */
58
57
  this.renderableKeyframeNodeNext = undefined;
@@ -62,19 +61,15 @@ function SpatialNode(level, x, y, z, parent, shape, voxelDimensions) {
62
61
  this.screenSpaceError = 0.0;
63
62
  this.visitedFrameNumber = -1;
64
63
 
65
- this.computeBoundingVolumes(shape, voxelDimensions);
64
+ this.computeBoundingVolumes(shape);
66
65
  }
67
66
 
68
67
  const scratchObbHalfScale = new Cartesian3();
69
68
 
70
69
  /**
71
70
  * @param {VoxelShape} shape
72
- * @param {Cartesian3} voxelDimensions
73
71
  */
74
- SpatialNode.prototype.computeBoundingVolumes = function (
75
- shape,
76
- voxelDimensions
77
- ) {
72
+ SpatialNode.prototype.computeBoundingVolumes = function (shape) {
78
73
  this.orientedBoundingBox = shape.computeOrientedBoundingBoxForTile(
79
74
  this.level,
80
75
  this.x,
@@ -89,15 +84,14 @@ SpatialNode.prototype.computeBoundingVolumes = function (
89
84
  );
90
85
  const maximumScale = 2.0 * Cartesian3.maximumComponent(halfScale);
91
86
  this.approximateVoxelSize =
92
- maximumScale / Cartesian3.minimumComponent(voxelDimensions);
87
+ maximumScale / Cartesian3.minimumComponent(this.dimensions);
93
88
  };
94
89
 
95
90
  /**
96
91
  * @param {VoxelShape} shape The shape of the parent VoxelPrimitive
97
- * @param {Cartesian3} voxelDimensions
98
92
  * @private
99
93
  */
100
- SpatialNode.prototype.constructChildNodes = function (shape, voxelDimensions) {
94
+ SpatialNode.prototype.constructChildNodes = function (shape) {
101
95
  const { level, x, y, z } = this;
102
96
  const xMin = x * 2;
103
97
  const yMin = y * 2;
@@ -119,7 +113,7 @@ SpatialNode.prototype.constructChildNodes = function (shape, voxelDimensions) {
119
113
  ];
120
114
 
121
115
  this.children = childCoords.map(([level, x, y, z]) => {
122
- return new SpatialNode(level, x, y, z, this, shape, voxelDimensions);
116
+ return new SpatialNode(level, x, y, z, this, shape, this.dimensions);
123
117
  });
124
118
  };
125
119
 
@@ -328,7 +322,7 @@ SpatialNode.prototype.destroyKeyframeNode = function (
328
322
 
329
323
  keyframeNode.spatialNode = undefined;
330
324
  keyframeNode.state = KeyframeNode.LoadState.UNLOADED;
331
- keyframeNode.metadatas = {};
325
+ keyframeNode.metadata = {};
332
326
  keyframeNode.megatextureIndex = -1;
333
327
  keyframeNode.priority = -Number.MAX_VALUE;
334
328
  keyframeNode.highPriorityFrameNumber = -1;
@@ -345,15 +339,14 @@ SpatialNode.prototype.addKeyframeNodeToMegatextures = function (
345
339
  if (
346
340
  keyframeNode.state !== KeyframeNode.LoadState.RECEIVED ||
347
341
  keyframeNode.megatextureIndex !== -1 ||
348
- keyframeNode.metadatas.length !== megatextures.length
342
+ keyframeNode.metadata.length !== megatextures.length
349
343
  ) {
350
344
  throw new DeveloperError("Keyframe node cannot be added to megatexture");
351
345
  }
352
346
 
353
347
  for (let i = 0; i < megatextures.length; i++) {
354
348
  const megatexture = megatextures[i];
355
- keyframeNode.megatextureIndex = megatexture.add(keyframeNode.metadatas[i]);
356
- keyframeNode.metadatas[i] = undefined; // data is in megatexture so no need to hold onto it
349
+ keyframeNode.megatextureIndex = megatexture.add(keyframeNode.metadata[i]);
357
350
  }
358
351
 
359
352
  keyframeNode.state = KeyframeNode.LoadState.LOADED;
@@ -5,7 +5,7 @@ import defined from "../Core/defined.js";
5
5
  /**
6
6
  * An object containing structural metadata.
7
7
  * <p>
8
- * See the {@link https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadatas|EXT_structural_metadata Extension} as well as the
8
+ * See the {@link https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_structural_metadata|EXT_structural_metadata Extension} as well as the
9
9
  * previous {@link https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata|EXT_feature_metadata Extension} for glTF.
10
10
  * </p>
11
11
  *
@@ -351,19 +351,80 @@ VoxelBoxShape.prototype.computeOrientedBoundingBoxForTile = function (
351
351
  );
352
352
  };
353
353
 
354
+ const sampleSizeScratch = new Cartesian3();
355
+
354
356
  /**
355
- * Computes an approximate step size for raymarching the root tile of a voxel grid.
357
+ * Computes an oriented bounding box for a specified sample within a specified tile.
356
358
  * The update function must be called before calling this function.
357
359
  *
358
- * @param {Cartesian3} dimensions The voxel grid dimensions for a tile.
359
- * @returns {number} The step size.
360
+ * @param {SpatialNode} spatialNode The spatial node containing the sample
361
+ * @param {Cartesian3} tileDimensions The size of the tile in number of samples, before padding
362
+ * @param {Cartesian3} tileUv The sample coordinate within the tile
363
+ * @param {OrientedBoundingBox} result The oriented bounding box that will be set to enclose the specified sample
364
+ * @returns {OrientedBoundingBox} The oriented bounding box.
360
365
  */
361
- VoxelBoxShape.prototype.computeApproximateStepSize = function (dimensions) {
366
+ VoxelBoxShape.prototype.computeOrientedBoundingBoxForSample = function (
367
+ spatialNode,
368
+ tileDimensions,
369
+ tileUv,
370
+ result
371
+ ) {
362
372
  //>>includeStart('debug', pragmas.debug);
363
- Check.typeOf.object("dimensions", dimensions);
373
+ Check.typeOf.object("spatialNode", spatialNode);
374
+ Check.typeOf.object("tileDimensions", tileDimensions);
375
+ Check.typeOf.object("tileUv", tileUv);
376
+ Check.typeOf.object("result", result);
364
377
  //>>includeEnd('debug');
365
378
 
366
- return 1.0 / Cartesian3.maximumComponent(dimensions);
379
+ const tileSizeAtLevel = 1.0 / Math.pow(2, spatialNode.level);
380
+ const sampleSize = Cartesian3.divideComponents(
381
+ Cartesian3.ONE,
382
+ tileDimensions,
383
+ sampleSizeScratch
384
+ );
385
+ const sampleSizeAtLevel = Cartesian3.multiplyByScalar(
386
+ sampleSize,
387
+ tileSizeAtLevel,
388
+ sampleSizeScratch
389
+ );
390
+
391
+ const minLerp = Cartesian3.multiplyByScalar(
392
+ Cartesian3.fromElements(
393
+ spatialNode.x + tileUv.x,
394
+ spatialNode.y + tileUv.y,
395
+ spatialNode.z + tileUv.z,
396
+ scratchTileMinBounds
397
+ ),
398
+ tileSizeAtLevel,
399
+ scratchTileMinBounds
400
+ );
401
+ const maxLerp = Cartesian3.add(
402
+ minLerp,
403
+ sampleSizeAtLevel,
404
+ scratchTileMaxBounds
405
+ );
406
+
407
+ const minBounds = this._minBounds;
408
+ const maxBounds = this._maxBounds;
409
+ const sampleMinBounds = Cartesian3.fromElements(
410
+ CesiumMath.lerp(minBounds.x, maxBounds.x, minLerp.x),
411
+ CesiumMath.lerp(minBounds.y, maxBounds.y, minLerp.y),
412
+ CesiumMath.lerp(minBounds.z, maxBounds.z, minLerp.z),
413
+ scratchTileMinBounds
414
+ );
415
+ const sampleMaxBounds = Cartesian3.fromElements(
416
+ CesiumMath.lerp(minBounds.x, maxBounds.x, maxLerp.x),
417
+ CesiumMath.lerp(minBounds.y, maxBounds.y, maxLerp.y),
418
+ CesiumMath.lerp(minBounds.z, maxBounds.z, maxLerp.z),
419
+ scratchTileMaxBounds
420
+ );
421
+
422
+ return getBoxChunkObb(
423
+ sampleMinBounds,
424
+ sampleMaxBounds,
425
+ this.shapeTransform,
426
+ result
427
+ );
367
428
  };
368
429
 
369
430
  /**
@@ -0,0 +1,273 @@
1
+ import Cartesian3 from "../Core/Cartesian3.js";
2
+ import Check from "../Core/Check.js";
3
+ import defined from "../Core/defined.js";
4
+ import MetadataType from "./MetadataType.js";
5
+ import OrientedBoundingBox from "../Core/OrientedBoundingBox.js";
6
+
7
+ /**
8
+ * A cell from a {@link VoxelPrimitive}.
9
+ * <p>
10
+ * Provides access to properties associated with one cell of a voxel primitive.
11
+ * </p>
12
+ * <p>
13
+ * Do not construct this directly. Access it through picking using {@link Scene#pickVoxel}.
14
+ * </p>
15
+ *
16
+ * @alias VoxelCell
17
+ * @constructor
18
+ *
19
+ * @param {VoxelPrimitive} primitive The voxel primitive containing the cell
20
+ * @param {number} tileIndex The index of the tile
21
+ * @param {number} sampleIndex The index of the sample within the tile, containing metadata for this cell
22
+ *
23
+ * @example
24
+ * // On left click, display all the properties for a voxel cell in the console log.
25
+ * handler.setInputAction(function(movement) {
26
+ * const voxelCell = scene.pickVoxel(movement.position);
27
+ * if (voxelCell instanceof Cesium.VoxelCell) {
28
+ * const propertyIds = voxelCell.getPropertyIds();
29
+ * const length = propertyIds.length;
30
+ * for (let i = 0; i < length; ++i) {
31
+ * const propertyId = propertyIds[i];
32
+ * console.log(`{propertyId}: ${voxelCell.getProperty(propertyId)}`);
33
+ * }
34
+ * }
35
+ * }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
36
+ *
37
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
38
+ */
39
+ function VoxelCell(primitive, tileIndex, sampleIndex) {
40
+ this._primitive = primitive;
41
+ this._tileIndex = tileIndex;
42
+ this._sampleIndex = sampleIndex;
43
+ this._metadata = {};
44
+ this._orientedBoundingBox = new OrientedBoundingBox();
45
+ }
46
+
47
+ /**
48
+ * Construct a VoxelCell, and update the metadata and bounding box using the properties
49
+ * of a supplied keyframe node.
50
+ *
51
+ * @private
52
+ * @param {VoxelPrimitive} primitive The voxel primitive containing the cell.
53
+ * @param {number} tileIndex The index of the tile.
54
+ * @param {number} sampleIndex The index of the sample within the tile, containing metadata for this cell.
55
+ * @param {KeyframeNode} keyframeNode The keyframe node containing information about the tile.
56
+ * @returns {VoxelCell}
57
+ *
58
+ * @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
59
+ */
60
+ VoxelCell.fromKeyframeNode = function (
61
+ primitive,
62
+ tileIndex,
63
+ sampleIndex,
64
+ keyframeNode
65
+ ) {
66
+ //>>includeStart('debug', pragmas.debug);
67
+ Check.typeOf.object("primitive", primitive);
68
+ Check.typeOf.number("tileIndex", tileIndex);
69
+ Check.typeOf.number("sampleIndex", sampleIndex);
70
+ Check.typeOf.object("keyframeNode", keyframeNode);
71
+ //>>includeEnd('debug');
72
+
73
+ const voxelCell = new VoxelCell(primitive, tileIndex, sampleIndex);
74
+ const { spatialNode, metadata } = keyframeNode;
75
+ voxelCell._metadata = getMetadataForSample(primitive, metadata, sampleIndex);
76
+ voxelCell._orientedBoundingBox = getOrientedBoundingBox(
77
+ primitive,
78
+ spatialNode,
79
+ sampleIndex,
80
+ voxelCell._orientedBoundingBox
81
+ );
82
+ return voxelCell;
83
+ };
84
+
85
+ /**
86
+ * @private
87
+ * @param {VoxelPrimitive} primitive
88
+ * @param {object} metadata
89
+ * @param {number} sampleIndex
90
+ * @returns {object}
91
+ */
92
+ function getMetadataForSample(primitive, metadata, sampleIndex) {
93
+ if (!defined(metadata)) {
94
+ return undefined;
95
+ }
96
+ const { names, types } = primitive.provider;
97
+ const metadataMap = {};
98
+ for (let i = 0; i < names.length; i++) {
99
+ const name = names[i];
100
+ const componentCount = MetadataType.getComponentCount(types[i]);
101
+ const samples = metadata[i].slice(
102
+ sampleIndex * componentCount,
103
+ (sampleIndex + 1) * componentCount
104
+ );
105
+ metadataMap[name] = samples;
106
+ }
107
+ return metadataMap;
108
+ }
109
+
110
+ const tileCoordinateScratch = new Cartesian3();
111
+ const tileUvScratch = new Cartesian3();
112
+
113
+ /**
114
+ * @private
115
+ * @param {VoxelPrimitive} primitive
116
+ * @param {SpatialNode} spatialNode
117
+ * @param {OrientedBoundingBox} result
118
+ * @returns {OrientedBoundingBox}
119
+ */
120
+ function getOrientedBoundingBox(primitive, spatialNode, sampleIndex, result) {
121
+ // Convert the sample index into a 3D tile coordinate
122
+ // Note: dimensions from the spatialNode include padding
123
+ const paddedDimensions = spatialNode.dimensions;
124
+ const sliceSize = paddedDimensions.x * paddedDimensions.y;
125
+ const zIndex = Math.floor(sampleIndex / sliceSize);
126
+ const indexInSlice = sampleIndex - zIndex * sliceSize;
127
+ const yIndex = Math.floor(indexInSlice / paddedDimensions.x);
128
+ const xIndex = indexInSlice - yIndex * paddedDimensions.x;
129
+ const tileCoordinate = Cartesian3.fromElements(
130
+ xIndex,
131
+ yIndex,
132
+ zIndex,
133
+ tileCoordinateScratch
134
+ );
135
+
136
+ // Remove padding, and convert to a fraction in [0, 1], where the limits are
137
+ // the unpadded bounds of the tile
138
+ const tileUv = Cartesian3.divideComponents(
139
+ Cartesian3.subtract(
140
+ tileCoordinate,
141
+ primitive._paddingBefore,
142
+ tileCoordinateScratch
143
+ ),
144
+ primitive.dimensions,
145
+ tileUvScratch
146
+ );
147
+
148
+ const shape = primitive._shape;
149
+ return shape.computeOrientedBoundingBoxForSample(
150
+ spatialNode,
151
+ primitive.dimensions,
152
+ tileUv,
153
+ result
154
+ );
155
+ }
156
+
157
+ Object.defineProperties(VoxelCell.prototype, {
158
+ /**
159
+ * Gets an object of the metadata values for this cell. The object's keys are the metadata names.
160
+ *
161
+ * @memberof VoxelCell.prototype
162
+ *
163
+ * @type {object}
164
+ *
165
+ * @readonly
166
+ * @private
167
+ */
168
+ metadata: {
169
+ get: function () {
170
+ return this._metadata;
171
+ },
172
+ },
173
+
174
+ /**
175
+ * All objects returned by {@link Scene#pick} have a <code>primitive</code> property. This returns
176
+ * the VoxelPrimitive containing the cell.
177
+ *
178
+ * @memberof VoxelCell.prototype
179
+ *
180
+ * @type {VoxelPrimitive}
181
+ *
182
+ * @readonly
183
+ */
184
+ primitive: {
185
+ get: function () {
186
+ return this._primitive;
187
+ },
188
+ },
189
+
190
+ /**
191
+ * Get the sample index of the cell.
192
+ *
193
+ * @memberof VoxelCell.prototype
194
+ *
195
+ * @type {number}
196
+ *
197
+ * @readonly
198
+ */
199
+ sampleIndex: {
200
+ get: function () {
201
+ return this._sampleIndex;
202
+ },
203
+ },
204
+
205
+ /**
206
+ * Get the index of the tile containing the cell.
207
+ *
208
+ * @memberof VoxelCell.prototype
209
+ *
210
+ * @type {number}
211
+ *
212
+ * @readonly
213
+ */
214
+ tileIndex: {
215
+ get: function () {
216
+ return this._tileIndex;
217
+ },
218
+ },
219
+
220
+ /**
221
+ * Get a copy of the oriented bounding box containing the cell.
222
+ *
223
+ * @memberof VoxelCell.prototype
224
+ *
225
+ * @type {OrientedBoundingBox}
226
+ *
227
+ * @readonly
228
+ */
229
+ orientedBoundingBox: {
230
+ get: function () {
231
+ return this._orientedBoundingBox.clone();
232
+ },
233
+ },
234
+ });
235
+
236
+ /**
237
+ * Returns <code>true</code> if the feature contains this property.
238
+ *
239
+ * @param {string} name The case-sensitive name of the property.
240
+ * @returns {boolean} Whether the feature contains this property.
241
+ */
242
+ VoxelCell.prototype.hasProperty = function (name) {
243
+ return defined(this._metadata[name]);
244
+ };
245
+
246
+ /**
247
+ * Returns an array of metadata property names for the feature.
248
+ *
249
+ * @returns {string[]} The IDs of the feature's properties.
250
+ */
251
+ VoxelCell.prototype.getNames = function () {
252
+ return Object.keys(this._metadata);
253
+ };
254
+
255
+ /**
256
+ * Returns a copy of the value of the metadata in the cell with the given name.
257
+ *
258
+ * @param {string} name The case-sensitive name of the property.
259
+ * @returns {*} The value of the property or <code>undefined</code> if the feature does not have this property.
260
+ *
261
+ * @example
262
+ * // Display all the properties for a voxel cell in the console log.
263
+ * const names = voxelCell.getNames();
264
+ * for (let i = 0; i < names.length; ++i) {
265
+ * const name = names[i];
266
+ * console.log(`{name}: ${voxelCell.getProperty(name)}`);
267
+ * }
268
+ */
269
+ VoxelCell.prototype.getProperty = function (name) {
270
+ return this._metadata[name];
271
+ };
272
+
273
+ export default VoxelCell;