@cesium/engine 6.1.1 → 7.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 (229) hide show
  1. package/Build/ThirdParty/Workers/z-worker-pako.js +568 -407
  2. package/Build/Workers/{chunk-FRG2Z7DE.js → chunk-2HJWSU7B.js} +4 -4
  3. package/Build/Workers/{chunk-ZTYE74E2.js → chunk-46UD5ABS.js} +4 -4
  4. package/Build/Workers/{chunk-VODWDCX6.js → chunk-4EBHOMFX.js} +18 -20
  5. package/Build/Workers/{chunk-N7TYCDTR.js → chunk-5HDYHG3F.js} +13 -13
  6. package/Build/Workers/{chunk-C53JYYKX.js → chunk-5M3U6ZMA.js} +1 -1
  7. package/Build/Workers/{chunk-GTEXWEAP.js → chunk-5WQ523AW.js} +5 -5
  8. package/Build/Workers/{chunk-SEFDWMCW.js → chunk-5YLJ77FF.js} +31 -21
  9. package/Build/Workers/{chunk-VNRUVNIK.js → chunk-6HZQPRUS.js} +1 -1
  10. package/Build/Workers/{chunk-PB7BIXHI.js → chunk-6VJVYK2V.js} +2 -2
  11. package/Build/Workers/{chunk-PHQVHDVI.js → chunk-72SANQJV.js} +325 -5
  12. package/Build/Workers/{chunk-D325WRAY.js → chunk-7XEAYGZK.js} +35 -11
  13. package/Build/Workers/{chunk-FGUP2QEP.js → chunk-AIPU2VSX.js} +6 -6
  14. package/Build/Workers/{chunk-QUXSQQEF.js → chunk-AR5DNBJ4.js} +6 -6
  15. package/Build/Workers/{chunk-ZVUAJKAL.js → chunk-BZP4T2JJ.js} +11 -13
  16. package/Build/Workers/{chunk-K6Q5IRBK.js → chunk-DTAIXKTO.js} +6 -6
  17. package/Build/Workers/{chunk-D4YHO4NZ.js → chunk-F6SE42BK.js} +133 -101
  18. package/Build/Workers/{chunk-QY2WY5XJ.js → chunk-FP6GYBFX.js} +11 -11
  19. package/Build/Workers/{chunk-Z6LPXA7S.js → chunk-GEJTYLCO.js} +5 -5
  20. package/Build/Workers/{chunk-VKTKOIYG.js → chunk-GV56Q4LU.js} +11 -11
  21. package/Build/Workers/{chunk-KUB2HQXR.js → chunk-IQBYFRVW.js} +8 -8
  22. package/Build/Workers/{chunk-235MRXLH.js → chunk-IX2JCCNM.js} +1 -1
  23. package/Build/Workers/{chunk-3FCUUN6M.js → chunk-JCNXK6EL.js} +11 -11
  24. package/Build/Workers/{chunk-364TQORK.js → chunk-JJ4VBOQ3.js} +5 -7
  25. package/Build/Workers/{chunk-66CXKODF.js → chunk-JXDC723O.js} +2 -2
  26. package/Build/Workers/{chunk-OTBRPBCC.js → chunk-JY5YEZFA.js} +9 -9
  27. package/Build/Workers/{chunk-LSGUCCKJ.js → chunk-L2ZN645J.js} +6 -6
  28. package/Build/Workers/{chunk-VLDDXYKI.js → chunk-LZ7JIV3K.js} +18 -18
  29. package/Build/Workers/{chunk-36ESDRIZ.js → chunk-LZGHD6NY.js} +16 -16
  30. package/Build/Workers/{chunk-PXLFBN2Q.js → chunk-MY3VNFGQ.js} +7 -7
  31. package/Build/Workers/{chunk-W7F5VTH6.js → chunk-NKPBIX7F.js} +1 -1
  32. package/Build/Workers/{chunk-XBZSOW3F.js → chunk-NY3K4IM3.js} +12 -12
  33. package/Build/Workers/{chunk-AI3KSNM6.js → chunk-ODW7WYM4.js} +2 -2
  34. package/Build/Workers/{chunk-6PWSSCRA.js → chunk-OVLG3FRS.js} +6 -6
  35. package/Build/Workers/{chunk-MOLGJDJV.js → chunk-PNBGBETF.js} +11 -11
  36. package/Build/Workers/{chunk-T73B27DG.js → chunk-PTQQUQC3.js} +13 -13
  37. package/Build/Workers/{chunk-RSWBNJPT.js → chunk-QZAD5O7I.js} +8 -304
  38. package/Build/Workers/{chunk-I6TVJ6T7.js → chunk-R5X4OQT4.js} +8 -8
  39. package/Build/Workers/{chunk-DTNN3ODA.js → chunk-RAEV7K66.js} +5 -5
  40. package/Build/Workers/{chunk-IZED7ODV.js → chunk-RV7ZYPFT.js} +4 -4
  41. package/Build/Workers/{chunk-7FEGZO3D.js → chunk-S4MAZ3SS.js} +2 -2
  42. package/Build/Workers/{chunk-J3U6Z5YQ.js → chunk-S6SKF6DT.js} +5 -5
  43. package/Build/Workers/{chunk-CHDJ66UM.js → chunk-U2VCRRQW.js} +6 -6
  44. package/Build/Workers/{chunk-R22RQAAM.js → chunk-UAEW6HKG.js} +13 -13
  45. package/Build/Workers/{chunk-S7IBK36I.js → chunk-UDO6BFSF.js} +14 -16
  46. package/Build/Workers/{chunk-YS4KPNLC.js → chunk-UGK3FCDY.js} +1 -1
  47. package/Build/Workers/{chunk-SJDXMQSP.js → chunk-VK3EJHWI.js} +2 -2
  48. package/Build/Workers/{chunk-HEROVJML.js → chunk-VRGFV2UO.js} +7 -7
  49. package/Build/Workers/{chunk-VOAZN4IP.js → chunk-WBQCVXR3.js} +4 -4
  50. package/Build/Workers/{chunk-HSW63JN4.js → chunk-WZU2YLWG.js} +3 -3
  51. package/Build/Workers/{chunk-4EYB62WJ.js → chunk-XWXM2O2R.js} +6 -6
  52. package/Build/Workers/{chunk-ZGMOBRTG.js → chunk-YUCVWAY6.js} +7 -7
  53. package/Build/Workers/{chunk-CLVEIRXT.js → chunk-ZK5JOS3D.js} +15 -17
  54. package/Build/Workers/{chunk-5NZTU5YL.js → chunk-ZUA2UUNV.js} +2 -2
  55. package/Build/Workers/combineGeometry.js +23 -23
  56. package/Build/Workers/createBoxGeometry.js +17 -17
  57. package/Build/Workers/createBoxOutlineGeometry.js +15 -15
  58. package/Build/Workers/createCircleGeometry.js +25 -25
  59. package/Build/Workers/createCircleOutlineGeometry.js +18 -18
  60. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -34
  61. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +30 -30
  62. package/Build/Workers/createCorridorGeometry.js +28 -29
  63. package/Build/Workers/createCorridorOutlineGeometry.js +27 -28
  64. package/Build/Workers/createCylinderGeometry.js +19 -19
  65. package/Build/Workers/createCylinderOutlineGeometry.js +18 -19
  66. package/Build/Workers/createEllipseGeometry.js +25 -25
  67. package/Build/Workers/createEllipseOutlineGeometry.js +18 -18
  68. package/Build/Workers/createEllipsoidGeometry.js +18 -18
  69. package/Build/Workers/createEllipsoidOutlineGeometry.js +17 -17
  70. package/Build/Workers/createFrustumGeometry.js +17 -17
  71. package/Build/Workers/createFrustumOutlineGeometry.js +17 -17
  72. package/Build/Workers/createGeometry.js +23 -23
  73. package/Build/Workers/createGroundPolylineGeometry.js +22 -22
  74. package/Build/Workers/createPlaneGeometry.js +15 -15
  75. package/Build/Workers/createPlaneOutlineGeometry.js +14 -14
  76. package/Build/Workers/createPolygonGeometry.js +32 -167
  77. package/Build/Workers/createPolygonOutlineGeometry.js +29 -29
  78. package/Build/Workers/createPolylineGeometry.js +24 -24
  79. package/Build/Workers/createPolylineVolumeGeometry.js +32 -35
  80. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -29
  81. package/Build/Workers/createRectangleGeometry.js +27 -27
  82. package/Build/Workers/createRectangleOutlineGeometry.js +21 -23
  83. package/Build/Workers/createSimplePolylineGeometry.js +22 -22
  84. package/Build/Workers/createSphereGeometry.js +18 -18
  85. package/Build/Workers/createSphereOutlineGeometry.js +17 -17
  86. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  87. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  88. package/Build/Workers/createVectorTileGeometries.js +23 -23
  89. package/Build/Workers/createVectorTilePoints.js +12 -12
  90. package/Build/Workers/createVectorTilePolygons.js +21 -21
  91. package/Build/Workers/createVectorTilePolylines.js +14 -14
  92. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  93. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  94. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +19 -19
  95. package/Build/Workers/createWallGeometry.js +23 -23
  96. package/Build/Workers/createWallOutlineGeometry.js +22 -22
  97. package/Build/Workers/decodeDraco.js +11 -11
  98. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  99. package/Build/Workers/decodeI3S.js +9 -9
  100. package/Build/Workers/transcodeKTX2.js +7 -7
  101. package/Build/Workers/transferTypedArrayTest.js +1 -1
  102. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  103. package/LICENSE.md +1 -1
  104. package/Source/Assets/approximateTerrainHeights.json +1 -1
  105. package/Source/Core/Ellipsoid.js +45 -0
  106. package/Source/Core/GregorianDate.js +85 -0
  107. package/Source/Core/HeadingPitchRange.js +2 -2
  108. package/Source/Core/Ion.js +1 -1
  109. package/Source/Core/PolygonGeometry.js +0 -169
  110. package/Source/Core/Quaternion.js +6 -2
  111. package/Source/Core/RectangleOutlineGeometry.js +2 -4
  112. package/Source/Core/RequestScheduler.js +3 -9
  113. package/Source/Core/Resource.js +30 -69
  114. package/Source/Core/TerrainEncoding.js +2 -2
  115. package/Source/Core/Transforms.js +27 -18
  116. package/Source/Core/VerticalExaggeration.js +69 -0
  117. package/Source/Core/createWorldBathymetryAsync.js +45 -0
  118. package/Source/DataSources/EllipsoidGeometryUpdater.js +3 -4
  119. package/Source/DataSources/Entity.js +8 -5
  120. package/Source/DataSources/EntityCollection.js +1 -2
  121. package/Source/DataSources/GeometryUpdater.js +1 -2
  122. package/Source/DataSources/GroundGeometryUpdater.js +6 -3
  123. package/Source/DataSources/ModelVisualizer.js +19 -98
  124. package/Source/DataSources/PolygonGeometryUpdater.js +14 -2
  125. package/Source/DataSources/PolylineGeometryUpdater.js +9 -8
  126. package/Source/DataSources/TerrainOffsetProperty.js +15 -23
  127. package/Source/Renderer/AutomaticUniforms.js +173 -0
  128. package/Source/Renderer/UniformState.js +246 -1
  129. package/Source/Scene/ArcGisMapService.js +1 -1
  130. package/Source/Scene/Atmosphere.js +127 -0
  131. package/Source/Scene/Billboard.js +29 -26
  132. package/Source/Scene/BillboardCollection.js +3 -3
  133. package/Source/Scene/Camera.js +1 -1
  134. package/Source/Scene/Cesium3DTile.js +123 -10
  135. package/Source/Scene/Cesium3DTileContent.js +14 -0
  136. package/Source/Scene/Cesium3DTileset.js +326 -45
  137. package/Source/Scene/Cesium3DTilesetTraversal.js +4 -0
  138. package/Source/Scene/Composite3DTileContent.js +42 -0
  139. package/Source/Scene/DynamicAtmosphereLightingType.js +56 -0
  140. package/Source/Scene/Empty3DTileContent.js +4 -0
  141. package/Source/Scene/Fog.js +1 -0
  142. package/Source/Scene/FrameState.js +13 -5
  143. package/Source/Scene/Geometry3DTileContent.js +4 -0
  144. package/Source/Scene/Globe.js +69 -21
  145. package/Source/Scene/GlobeSurfaceTile.js +4 -4
  146. package/Source/Scene/GlobeSurfaceTileProvider.js +24 -22
  147. package/Source/Scene/GltfLoader.js +15 -5
  148. package/Source/Scene/GroundPrimitive.js +5 -5
  149. package/Source/Scene/HeightReference.js +59 -2
  150. package/Source/Scene/ImageryLayer.js +3 -3
  151. package/Source/Scene/Implicit3DTileContent.js +4 -0
  152. package/Source/Scene/LabelCollection.js +2 -2
  153. package/Source/Scene/MapboxImageryProvider.js +2 -2
  154. package/Source/Scene/Megatexture.js +1 -1
  155. package/Source/Scene/Model/AtmospherePipelineStage.js +59 -0
  156. package/Source/Scene/Model/B3dmLoader.js +4 -0
  157. package/Source/Scene/Model/FeatureIdPipelineStage.js +25 -2
  158. package/Source/Scene/Model/I3dmLoader.js +4 -0
  159. package/Source/Scene/Model/InstancingPipelineStage.js +24 -6
  160. package/Source/Scene/Model/MetadataPipelineStage.js +31 -3
  161. package/Source/Scene/Model/Model.js +93 -32
  162. package/Source/Scene/Model/Model3DTileContent.js +31 -0
  163. package/Source/Scene/Model/ModelAnimationChannel.js +16 -15
  164. package/Source/Scene/Model/ModelRuntimePrimitive.js +6 -0
  165. package/Source/Scene/Model/ModelSceneGraph.js +6 -0
  166. package/Source/Scene/Model/VerticalExaggerationPipelineStage.js +60 -0
  167. package/Source/Scene/Model/pickModel.js +408 -0
  168. package/Source/Scene/Multiple3DTileContent.js +42 -0
  169. package/Source/Scene/QuadtreePrimitive.js +1 -1
  170. package/Source/Scene/Scene.js +226 -19
  171. package/Source/Scene/ScreenSpaceCameraController.js +14 -25
  172. package/Source/Scene/SkyAtmosphere.js +5 -6
  173. package/Source/Scene/Terrain.js +49 -0
  174. package/Source/Scene/TerrainFillMesh.js +2 -2
  175. package/Source/Scene/TileBoundingS2Cell.js +2 -2
  176. package/Source/Scene/TileOrientedBoundingBox.js +1 -1
  177. package/Source/Scene/Tileset3DTileContent.js +4 -0
  178. package/Source/Scene/Vector3DTileContent.js +4 -0
  179. package/Source/Scene/VoxelPrimitive.js +73 -2
  180. package/Source/Shaders/AtmosphereCommon.glsl +3 -11
  181. package/Source/Shaders/AtmosphereCommon.js +3 -11
  182. package/Source/Shaders/Builtin/CzmBuiltins.js +12 -0
  183. package/Source/Shaders/Builtin/Functions/applyHSBShift.glsl +32 -0
  184. package/Source/Shaders/Builtin/Functions/applyHSBShift.js +34 -0
  185. package/Source/Shaders/Builtin/Functions/approximateTanh.glsl +10 -0
  186. package/Source/Shaders/Builtin/Functions/approximateTanh.js +12 -0
  187. package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.glsl +44 -0
  188. package/Source/Shaders/Builtin/Functions/computeAtmosphereColor.js +46 -0
  189. package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.glsl +30 -0
  190. package/Source/Shaders/Builtin/Functions/computeGroundAtmosphereScattering.js +32 -0
  191. package/Source/Shaders/Builtin/Functions/computeScattering.glsl +150 -0
  192. package/Source/Shaders/Builtin/Functions/computeScattering.js +152 -0
  193. package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.glsl +22 -0
  194. package/Source/Shaders/Builtin/Functions/getDynamicAtmosphereLightDirection.js +24 -0
  195. package/Source/Shaders/Builtin/Functions/translateRelativeToEye.glsl +5 -0
  196. package/Source/Shaders/Builtin/Functions/translateRelativeToEye.js +5 -0
  197. package/Source/Shaders/GlobeFS.glsl +16 -25
  198. package/Source/Shaders/GlobeFS.js +16 -25
  199. package/Source/Shaders/GlobeVS.glsl +4 -4
  200. package/Source/Shaders/GlobeVS.js +4 -4
  201. package/Source/Shaders/Model/AtmosphereStageFS.glsl +111 -0
  202. package/Source/Shaders/Model/AtmosphereStageFS.js +113 -0
  203. package/Source/Shaders/Model/AtmosphereStageVS.glsl +12 -0
  204. package/Source/Shaders/Model/AtmosphereStageVS.js +14 -0
  205. package/Source/Shaders/Model/GeometryStageFS.glsl +1 -1
  206. package/Source/Shaders/Model/GeometryStageFS.js +1 -1
  207. package/Source/Shaders/Model/GeometryStageVS.glsl +4 -4
  208. package/Source/Shaders/Model/GeometryStageVS.js +4 -4
  209. package/Source/Shaders/Model/ModelColorStageFS.glsl +1 -1
  210. package/Source/Shaders/Model/ModelColorStageFS.js +2 -1
  211. package/Source/Shaders/Model/ModelFS.glsl +4 -0
  212. package/Source/Shaders/Model/ModelFS.js +4 -0
  213. package/Source/Shaders/Model/ModelVS.glsl +13 -4
  214. package/Source/Shaders/Model/ModelVS.js +13 -4
  215. package/Source/Shaders/Model/VerticalExaggerationStageVS.glsl +39 -0
  216. package/Source/Shaders/Model/VerticalExaggerationStageVS.js +41 -0
  217. package/Source/Shaders/SkyAtmosphereCommon.glsl +3 -13
  218. package/Source/Shaders/SkyAtmosphereCommon.js +3 -13
  219. package/Source/Shaders/SkyAtmosphereFS.glsl +5 -10
  220. package/Source/Shaders/SkyAtmosphereFS.js +5 -10
  221. package/Source/Shaders/SkyAtmosphereVS.glsl +3 -2
  222. package/Source/Shaders/SkyAtmosphereVS.js +3 -2
  223. package/Source/ThirdParty/Workers/z-worker-pako.js +1 -1
  224. package/Source/ThirdParty/draco_decoder.wasm +0 -0
  225. package/index.d.ts +318 -83
  226. package/index.js +77 -62
  227. package/package.json +3 -3
  228. package/Build/Workers/chunk-7ONRI7T4.js +0 -55
  229. package/Source/Core/TerrainExaggeration.js +0 -49
@@ -1,4 +1,5 @@
1
1
  import ApproximateTerrainHeights from "../Core/ApproximateTerrainHeights.js";
2
+ import BoundingSphere from "../Core/BoundingSphere.js";
2
3
  import Cartesian2 from "../Core/Cartesian2.js";
3
4
  import Cartesian3 from "../Core/Cartesian3.js";
4
5
  import Cartographic from "../Core/Cartographic.js";
@@ -13,10 +14,13 @@ import destroyObject from "../Core/destroyObject.js";
13
14
  import Ellipsoid from "../Core/Ellipsoid.js";
14
15
  import Event from "../Core/Event.js";
15
16
  import ImageBasedLighting from "./ImageBasedLighting.js";
17
+ import Interval from "../Core/Interval.js";
18
+ import IntersectionTests from "../Core/IntersectionTests.js";
16
19
  import IonResource from "../Core/IonResource.js";
17
20
  import JulianDate from "../Core/JulianDate.js";
18
21
  import ManagedArray from "../Core/ManagedArray.js";
19
22
  import CesiumMath from "../Core/Math.js";
23
+ import Matrix3 from "../Core/Matrix3.js";
20
24
  import Matrix4 from "../Core/Matrix4.js";
21
25
  import Resource from "../Core/Resource.js";
22
26
  import RuntimeError from "../Core/RuntimeError.js";
@@ -55,6 +59,7 @@ import TileOrientedBoundingBox from "./TileOrientedBoundingBox.js";
55
59
  import Cesium3DTilesetMostDetailedTraversal from "./Cesium3DTilesetMostDetailedTraversal.js";
56
60
  import Cesium3DTilesetBaseTraversal from "./Cesium3DTilesetBaseTraversal.js";
57
61
  import Cesium3DTilesetSkipTraversal from "./Cesium3DTilesetSkipTraversal.js";
62
+ import Ray from "../Core/Ray.js";
58
63
 
59
64
  /**
60
65
  * @typedef {Object} Cesium3DTileset.ConstructorOptions
@@ -75,10 +80,10 @@ import Cesium3DTilesetSkipTraversal from "./Cesium3DTilesetSkipTraversal.js";
75
80
  * @property {boolean} [preloadWhenHidden=false] Preload tiles when <code>tileset.show</code> is <code>false</code>. Loads tiles as if the tileset is visible but does not render them.
76
81
  * @property {boolean} [preloadFlightDestinations=true] Optimization option. Preload tiles at the camera's flight destination while the camera is in flight.
77
82
  * @property {boolean} [preferLeaves=false] Optimization option. Prefer loading of leaves first.
78
- * @property {boolean} [dynamicScreenSpaceError=false] Optimization option. Reduce the screen space error for tiles that are further away from the camera.
79
- * @property {number} [dynamicScreenSpaceErrorDensity=0.00278] Density used to adjust the dynamic screen space error, similar to fog density.
80
- * @property {number} [dynamicScreenSpaceErrorFactor=4.0] A factor used to increase the computed dynamic screen space error.
81
- * @property {number} [dynamicScreenSpaceErrorHeightFalloff=0.25] A ratio of the tileset's height at which the density starts to falloff.
83
+ * @property {boolean} [dynamicScreenSpaceError=true] Optimization option. For street-level horizon views, use lower resolution tiles far from the camera. This reduces the amount of data loaded and improves tileset loading time with a slight drop in visual quality in the distance.
84
+ * @property {number} [dynamicScreenSpaceErrorDensity=2.0e-4] Similar to {@link Fog#density}, this option controls the camera distance at which the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization applies. Larger values will cause tiles closer to the camera to be affected.
85
+ * @property {number} [dynamicScreenSpaceErrorFactor=24.0] A parameter that controls the intensity of the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization for tiles on the horizon. Larger values cause lower resolution tiles to load, improving runtime performance at a slight reduction of visual quality.
86
+ * @property {number} [dynamicScreenSpaceErrorHeightFalloff=0.25] A ratio of the tileset's height that determines where "street level" camera views occur. When the camera is below this height, the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization will have the maximum effect, and it will roll off above this value.
82
87
  * @property {number} [progressiveResolutionHeightFraction=0.3] Optimization option. If between (0.0, 0.5], tiles at or above the screen space error for the reduced screen resolution of <code>progressiveResolutionHeightFraction*screenHeight</code> will be prioritized first. This can help get a quick layer of tiles down while full resolution tiles continue to load.
83
88
  * @property {boolean} [foveatedScreenSpaceError=true] Optimization option. Prioritize loading tiles in the center of the screen by temporarily raising the screen space error for tiles around the edge of the screen. Screen space error returns to normal once all the tiles in the center of the screen as determined by the {@link Cesium3DTileset#foveatedConeSize} are loaded.
84
89
  * @property {number} [foveatedConeSize=0.1] Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control the cone size that determines which tiles are deferred. Tiles that are inside this cone are loaded immediately. Tiles outside the cone are potentially deferred based on how far outside the cone they are and their screen space error. This is controlled by {@link Cesium3DTileset#foveatedInterpolationCallback} and {@link Cesium3DTileset#foveatedMinimumScreenSpaceErrorRelaxation}. Setting this to 0.0 means the cone will be the line formed by the camera position and its view direction. Setting this to 1.0 means the cone encompasses the entire field of view of the camera, disabling the effect.
@@ -107,11 +112,13 @@ import Cesium3DTilesetSkipTraversal from "./Cesium3DTilesetSkipTraversal.js";
107
112
  * @property {string|number} [instanceFeatureIdLabel="instanceFeatureId_0"] Label of the instance feature ID set used for picking and styling. If instanceFeatureIdLabel is set to an integer N, it is converted to the string "instanceFeatureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.
108
113
  * @property {boolean} [showCreditsOnScreen=false] Whether to display the credits of this tileset on screen.
109
114
  * @property {SplitDirection} [splitDirection=SplitDirection.NONE] The {@link SplitDirection} split to apply to this tileset.
110
- * @property {boolean} [projectTo2D=false] Whether to accurately project the tileset to 2D. If this is true, the tileset will be projected accurately to 2D, but it will use more memory to do so. If this is false, the tileset will use less memory and will still render in 2D / CV mode, but its projected positions may be inaccurate. This cannot be set after the tileset has loaded.
115
+ * @property {boolean} [disableCollision=false] Whether to turn off collisions for camera collisions or picking. While this is <code>true</code> the camera will be allowed to go in or below the tileset surface if {@link ScreenSpaceCameraController#enableCollisionDetection} is true.
116
+ * @property {boolean} [projectTo2D=false] Whether to accurately project the tileset to 2D. If this is true, the tileset will be projected accurately to 2D, but it will use more memory to do so. If this is false, the tileset will use less memory and will still render in 2D / CV mode, but its projected positions may be inaccurate. This cannot be set after the tileset has been created.
117
+ * @property {boolean} [enablePick=false] Whether to allow collision and CPU picking with <code>pick</code> when using WebGL 1. If using WebGL 2 or above, this option will be ignored. If using WebGL 1 and this is true, the <code>pick</code> operation will work correctly, but it will use more memory to do so. If running with WebGL 1 and this is false, the model will use less memory, but <code>pick</code> will always return <code>undefined</code>. This cannot be set after the tileset has loaded.
111
118
  * @property {string} [debugHeatmapTilePropertyName] The tile variable to colorize as a heatmap. All rendered tiles will be colorized relative to each other's specified variable value.
112
119
  * @property {boolean} [debugFreezeFrame=false] For debugging only. Determines if only the tiles from last frame should be used for rendering.
113
120
  * @property {boolean} [debugColorizeTiles=false] For debugging only. When true, assigns a random color to each tile.
114
- * @property {boolean} [enableDebugWireframe] For debugging only. This must be true for debugWireframe to work in WebGL1. This cannot be set after the tileset has loaded.
121
+ * @property {boolean} [enableDebugWireframe=false] For debugging only. This must be true for debugWireframe to work in WebGL1. This cannot be set after the tileset has been created.
115
122
  * @property {boolean} [debugWireframe=false] For debugging only. When true, render's each tile's content as a wireframe.
116
123
  * @property {boolean} [debugShowBoundingVolume=false] For debugging only. When true, renders the bounding volume for each tile.
117
124
  * @property {boolean} [debugShowContentBoundingVolume=false] For debugging only. When true, renders the bounding volume for each tile's content.
@@ -148,6 +155,18 @@ import Cesium3DTilesetSkipTraversal from "./Cesium3DTilesetSkipTraversal.js";
148
155
  * }
149
156
  *
150
157
  * @example
158
+ * // Allow camera to go inside and under 3D tileset
159
+ * try {
160
+ * const tileset = await Cesium.Cesium3DTileset.fromUrl(
161
+ * "http://localhost:8002/tilesets/Seattle/tileset.json",
162
+ * { disableCollision: true }
163
+ * );
164
+ * scene.primitives.add(tileset);
165
+ * } catch (error) {
166
+ * console.error(`Error creating tileset: ${error}`);
167
+ * }
168
+ *
169
+ * @example
151
170
  * // Common setting for the skipLevelOfDetail optimization
152
171
  * const tileset = await Cesium.Cesium3DTileset.fromUrl(
153
172
  * "http://localhost:8002/tilesets/Seattle/tileset.json", {
@@ -166,8 +185,8 @@ import Cesium3DTilesetSkipTraversal from "./Cesium3DTilesetSkipTraversal.js";
166
185
  * const tileset = await Cesium.Cesium3DTileset.fromUrl(
167
186
  * "http://localhost:8002/tilesets/Seattle/tileset.json", {
168
187
  * dynamicScreenSpaceError: true,
169
- * dynamicScreenSpaceErrorDensity: 0.00278,
170
- * dynamicScreenSpaceErrorFactor: 4.0,
188
+ * dynamicScreenSpaceErrorDensity: 2.0e-4,
189
+ * dynamicScreenSpaceErrorFactor: 24.0,
171
190
  * dynamicScreenSpaceErrorHeightFalloff: 0.25
172
191
  * });
173
192
  * scene.primitives.add(tileset);
@@ -248,6 +267,8 @@ function Cesium3DTileset(options) {
248
267
  ? Matrix4.clone(options.modelMatrix)
249
268
  : Matrix4.clone(Matrix4.IDENTITY);
250
269
 
270
+ this._addHeightCallbacks = [];
271
+
251
272
  this._statistics = new Cesium3DTilesetStatistics();
252
273
  this._statisticsLast = new Cesium3DTilesetStatistics();
253
274
  this._statisticsPerPass = new Array(Cesium3DTilePass.NUMBER_OF_PASSES);
@@ -361,18 +382,18 @@ function Cesium3DTileset(options) {
361
382
  this._pass = undefined; // Cesium3DTilePass
362
383
 
363
384
  /**
364
- * Optimization option. Whether the tileset should refine based on a dynamic screen space error. Tiles that are further
365
- * away will be rendered with lower detail than closer tiles. This improves performance by rendering fewer
366
- * tiles and making less requests, but may result in a slight drop in visual quality for tiles in the distance.
367
- * The algorithm is biased towards "street views" where the camera is close to the ground plane of the tileset and looking
368
- * at the horizon. In addition results are more accurate for tightly fitting bounding volumes like box and region.
385
+ * Optimization option. For street-level horizon views, use lower resolution tiles far from the camera. This reduces
386
+ * the amount of data loaded and improves tileset loading time with a slight drop in visual quality in the distance.
387
+ * <p>
388
+ * This optimization is strongest when the camera is close to the ground plane of the tileset and looking at the
389
+ * horizon. Furthermore, the results are more accurate for tightly fitting bounding volumes like box and region.
369
390
  *
370
391
  * @type {boolean}
371
- * @default false
392
+ * @default true
372
393
  */
373
394
  this.dynamicScreenSpaceError = defaultValue(
374
395
  options.dynamicScreenSpaceError,
375
- false
396
+ true
376
397
  );
377
398
 
378
399
  /**
@@ -416,48 +437,68 @@ function Cesium3DTileset(options) {
416
437
  this.foveatedTimeDelay = defaultValue(options.foveatedTimeDelay, 0.2);
417
438
 
418
439
  /**
419
- * A scalar that determines the density used to adjust the dynamic screen space error, similar to {@link Fog}. Increasing this
420
- * value has the effect of increasing the maximum screen space error for all tiles, but in a non-linear fashion.
421
- * The error starts at 0.0 and increases exponentially until a midpoint is reached, and then approaches 1.0 asymptotically.
422
- * This has the effect of keeping high detail in the closer tiles and lower detail in the further tiles, with all tiles
423
- * beyond a certain distance all roughly having an error of 1.0.
440
+ * Similar to {@link Fog#density}, this option controls the camera distance at which the {@link Cesium3DTileset#dynamicScreenSpaceError}
441
+ * optimization applies. Larger values will cause tiles closer to the camera to be affected. This value must be
442
+ * non-negative.
424
443
  * <p>
425
- * The dynamic error is in the range [0.0, 1.0) and is multiplied by <code>dynamicScreenSpaceErrorFactor</code> to produce the
426
- * final dynamic error. This dynamic error is then subtracted from the tile's actual screen space error.
444
+ * This optimization works by rolling off the tile screen space error (SSE) with camera distance like a bell curve.
445
+ * This has the effect of selecting lower resolution tiles far from the camera. Near the camera, no adjustment is
446
+ * made. For tiles further away, the SSE is reduced by up to {@link Cesium3DTileset#dynamicScreenSpaceErrorFactor}
447
+ * (measured in pixels of error).
427
448
  * </p>
428
449
  * <p>
429
- * Increasing <code>dynamicScreenSpaceErrorDensity</code> has the effect of moving the error midpoint closer to the camera.
430
- * It is analogous to moving fog closer to the camera.
450
+ * Increasing the density makes the bell curve narrower so tiles closer to the camera are affected. This is analagous
451
+ * to moving fog closer to the camera.
452
+ * </p>
453
+ * <p>
454
+ * When the density is 0, the optimization will have no effect on the tileset.
431
455
  * </p>
432
456
  *
433
457
  * @type {number}
434
- * @default 0.00278
458
+ * @default 2.0e-4
435
459
  */
436
- this.dynamicScreenSpaceErrorDensity = 0.00278;
460
+ this.dynamicScreenSpaceErrorDensity = defaultValue(
461
+ options.dynamicScreenSpaceErrorDensity,
462
+ 2.0e-4
463
+ );
437
464
 
438
465
  /**
439
- * A factor used to increase the screen space error of tiles for dynamic screen space error. As this value increases less tiles
440
- * are requested for rendering and tiles in the distance will have lower detail. If set to zero, the feature will be disabled.
466
+ * A parameter that controls the intensity of the {@link Cesium3DTileset#dynamicScreenSpaceError} optimization for
467
+ * tiles on the horizon. Larger values cause lower resolution tiles to load, improving runtime performance at a slight
468
+ * reduction of visual quality. The value must be non-negative.
469
+ * <p>
470
+ * More specifically, this parameter represents the maximum adjustment to screen space error (SSE) in pixels for tiles
471
+ * far away from the camera. See {@link Cesium3DTileset#dynamicScreenSpaceErrorDensity} for more details about how
472
+ * this optimization works.
473
+ * </p>
474
+ * <p>
475
+ * When the SSE factor is set to 0, the optimization will have no effect on the tileset.
476
+ * </p>
441
477
  *
442
478
  * @type {number}
443
- * @default 4.0
479
+ * @default 24.0
444
480
  */
445
- this.dynamicScreenSpaceErrorFactor = 4.0;
481
+ this.dynamicScreenSpaceErrorFactor = defaultValue(
482
+ options.dynamicScreenSpaceErrorFactor,
483
+ 24.0
484
+ );
446
485
 
447
486
  /**
448
- * A ratio of the tileset's height at which the density starts to falloff. If the camera is below this height the
449
- * full computed density is applied, otherwise the density falls off. This has the effect of higher density at
450
- * street level views.
487
+ * A ratio of the tileset's height that determines "street level" for the {@link Cesium3DTileset#dynamicScreenSpaceError}
488
+ * optimization. When the camera is below this height, the dynamic screen space error optimization will have the maximum
489
+ * effect, and it will roll off above this value. Valid values are between 0.0 and 1.0.
451
490
  * <p>
452
- * Valid values are between 0.0 and 1.0.
453
- * </p>
454
491
  *
455
492
  * @type {number}
456
493
  * @default 0.25
457
494
  */
458
- this.dynamicScreenSpaceErrorHeightFalloff = 0.25;
495
+ this.dynamicScreenSpaceErrorHeightFalloff = defaultValue(
496
+ options.dynamicScreenSpaceErrorHeightFalloff,
497
+ 0.25
498
+ );
459
499
 
460
- this._dynamicScreenSpaceErrorComputedDensity = 0.0; // Updated based on the camera position and direction
500
+ // Updated based on the camera position and direction
501
+ this._dynamicScreenSpaceErrorComputedDensity = 0.0;
461
502
 
462
503
  /**
463
504
  * Determines whether the tileset casts or receives shadows from light sources.
@@ -822,7 +863,16 @@ function Cesium3DTileset(options) {
822
863
  SplitDirection.NONE
823
864
  );
824
865
 
866
+ /**
867
+ * Whether to turn off collisions for camera collisions or picking. While this is <code>true</code> the camera will be allowed to go in or below the tileset surface if {@link ScreenSpaceCameraController#enableCollisionDetection} is true.
868
+ *
869
+ * @type {boolean}
870
+ * @default false
871
+ */
872
+ this.disableCollision = defaultValue(options.disableCollision, false);
873
+
825
874
  this._projectTo2D = defaultValue(options.projectTo2D, false);
875
+ this._enablePick = defaultValue(options.enablePick, false);
826
876
 
827
877
  /**
828
878
  * This property is for debugging only; it is not optimized for production use.
@@ -1635,6 +1685,7 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1635
1685
  * <li>The glTF cannot contain morph targets, skins, or animations.</li>
1636
1686
  * <li>The glTF cannot contain the <code>EXT_mesh_gpu_instancing</code> extension.</li>
1637
1687
  * <li>Only meshes with TRIANGLES can be used to classify other assets.</li>
1688
+ * <li>The meshes must be watertight.</li>
1638
1689
  * <li>The <code>POSITION</code> semantic is required.</li>
1639
1690
  * <li>If <code>_BATCHID</code>s and an index buffer are both present, all indices with the same batch id must occupy contiguous sections of the index buffer.</li>
1640
1691
  * <li>If <code>_BATCHID</code>s are present with no index buffer, all positions with the same batch id must occupy contiguous sections of the position buffer.</li>
@@ -1644,6 +1695,9 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1644
1695
  * Additionally, classification is not supported for points or instanced 3D
1645
1696
  * models.
1646
1697
  * </p>
1698
+ * <p>
1699
+ * The 3D Tiles or terrain receiving the classification must be opaque.
1700
+ * </p>
1647
1701
  *
1648
1702
  * @memberof Cesium3DTileset.prototype
1649
1703
  *
@@ -1905,7 +1959,8 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1905
1959
  * @param {Cesium3DTileset.ConstructorOptions} [options] An object describing initialization options
1906
1960
  * @returns {Promise<Cesium3DTileset>}
1907
1961
  *
1908
- * @exception {DeveloperError} The tileset must be 3D Tiles version 0.0 or 1.0.
1962
+ * @exception {RuntimeError} When the tileset asset version is not 0.0, 1.0, or 1.1,
1963
+ * or when the tileset contains a required extension that is not supported.
1909
1964
  *
1910
1965
  * @see Cesium3DTileset#fromUrl
1911
1966
  *
@@ -1935,7 +1990,8 @@ Cesium3DTileset.fromIonAssetId = async function (assetId, options) {
1935
1990
  * @param {Cesium3DTileset.ConstructorOptions} [options] An object describing initialization options
1936
1991
  * @returns {Promise<Cesium3DTileset>}
1937
1992
  *
1938
- * @exception {DeveloperError} The tileset must be 3D Tiles version 0.0 or 1.0.
1993
+ * @exception {RuntimeError} When the tileset asset version is not 0.0, 1.0, or 1.1,
1994
+ * or when the tileset contains a required extension that is not supported.
1939
1995
  *
1940
1996
  * @see Cesium3DTileset#fromIonAssetId
1941
1997
  *
@@ -1968,8 +2024,8 @@ Cesium3DTileset.fromIonAssetId = async function (assetId, options) {
1968
2024
  * const tileset = await Cesium.Cesium3DTileset.fromUrl(
1969
2025
  * "http://localhost:8002/tilesets/Seattle/tileset.json", {
1970
2026
  * dynamicScreenSpaceError: true,
1971
- * dynamicScreenSpaceErrorDensity: 0.00278,
1972
- * dynamicScreenSpaceErrorFactor: 4.0,
2027
+ * dynamicScreenSpaceErrorDensity: 2.0e-4,
2028
+ * dynamicScreenSpaceErrorFactor: 24.0,
1973
2029
  * dynamicScreenSpaceErrorHeightFalloff: 0.25
1974
2030
  * });
1975
2031
  * scene.primitives.add(tileset);
@@ -2078,6 +2134,9 @@ Cesium3DTileset.prototype.makeStyleDirty = function () {
2078
2134
  /**
2079
2135
  * Loads the main tileset JSON file or a tileset JSON file referenced from a tile.
2080
2136
  *
2137
+ * @exception {RuntimeError} When the tileset asset version is not 0.0, 1.0, or 1.1,
2138
+ * or when the tileset contains a required extension that is not supported.
2139
+ *
2081
2140
  * @private
2082
2141
  */
2083
2142
  Cesium3DTileset.prototype.loadTileset = function (
@@ -2266,6 +2325,7 @@ const scratchMatrix = new Matrix4();
2266
2325
  const scratchCenter = new Cartesian3();
2267
2326
  const scratchPosition = new Cartesian3();
2268
2327
  const scratchDirection = new Cartesian3();
2328
+ const scratchHalfHeight = new Cartesian3();
2269
2329
 
2270
2330
  /**
2271
2331
  * @private
@@ -2330,10 +2390,16 @@ function updateDynamicScreenSpaceError(tileset, frameState) {
2330
2390
  direction = Cartesian3.normalize(direction, direction);
2331
2391
  height = positionLocal.z;
2332
2392
  if (tileBoundingVolume instanceof TileOrientedBoundingBox) {
2333
- // Assuming z-up, the last component stores the half-height of the box
2334
- const boxHeight = root._header.boundingVolume.box[11];
2335
- minimumHeight = centerLocal.z - boxHeight;
2336
- maximumHeight = centerLocal.z + boxHeight;
2393
+ // Assuming z-up, the last column is the local z direction and
2394
+ // represents the height of the bounding box.
2395
+ const halfHeightVector = Matrix3.getColumn(
2396
+ boundingVolume.halfAxes,
2397
+ 2,
2398
+ scratchHalfHeight
2399
+ );
2400
+ const halfHeight = Cartesian3.magnitude(halfHeightVector);
2401
+ minimumHeight = centerLocal.z - halfHeight;
2402
+ maximumHeight = centerLocal.z + halfHeight;
2337
2403
  } else if (tileBoundingVolume instanceof TileBoundingSphere) {
2338
2404
  const radius = boundingVolume.radius;
2339
2405
  minimumHeight = centerLocal.z - radius;
@@ -2569,6 +2635,55 @@ function filterProcessingQueue(tileset) {
2569
2635
  tiles.length -= removeCount;
2570
2636
  }
2571
2637
 
2638
+ const scratchUpdateHeightCartographic = new Cartographic();
2639
+ const scratchUpdateHeightCartographic2 = new Cartographic();
2640
+ const scratchUpdateHeightCartesian = new Cartesian3();
2641
+ function processUpdateHeight(tileset, tile, frameState) {
2642
+ const heightCallbackData = tileset._addHeightCallbacks;
2643
+ const boundingSphere = tile.boundingSphere;
2644
+
2645
+ for (const callbackData of heightCallbackData) {
2646
+ // No need to upadate if the tile was already visible last frame
2647
+ if (callbackData.invoked || tile._wasSelectedLastFrame) {
2648
+ continue;
2649
+ }
2650
+
2651
+ const ellipsoid = callbackData.ellipsoid;
2652
+ const positionCartographic = Cartographic.clone(
2653
+ callbackData.positionCartographic,
2654
+ scratchUpdateHeightCartographic
2655
+ );
2656
+ const centerCartographic = Cartographic.fromCartesian(
2657
+ boundingSphere.center,
2658
+ ellipsoid,
2659
+ scratchUpdateHeightCartographic2
2660
+ );
2661
+
2662
+ // This can be undefined when the bounding sphere is at the origin
2663
+ if (defined(centerCartographic)) {
2664
+ positionCartographic.height = centerCartographic.height;
2665
+ }
2666
+
2667
+ const position = Cartographic.toCartesian(
2668
+ positionCartographic,
2669
+ ellipsoid,
2670
+ scratchUpdateHeightCartesian
2671
+ );
2672
+ if (
2673
+ Cartesian3.distance(position, boundingSphere.center) <=
2674
+ boundingSphere.radius
2675
+ ) {
2676
+ frameState.afterRender.push(() => {
2677
+ // Callback can be removed before it actually invoked at the end of the frame
2678
+ if (defined(callbackData.callback)) {
2679
+ callbackData.callback(positionCartographic);
2680
+ }
2681
+ callbackData.invoked = false;
2682
+ });
2683
+ }
2684
+ }
2685
+ }
2686
+
2572
2687
  /**
2573
2688
  * Process tiles in the PROCESSING state so they will eventually move to the READY state.
2574
2689
  * @private
@@ -2836,6 +2951,7 @@ function updateTiles(tileset, frameState, passOptions) {
2836
2951
  if (isRender) {
2837
2952
  tileVisible.raiseEvent(tile);
2838
2953
  }
2954
+ processUpdateHeight(tileset, tile, frameState);
2839
2955
  tile.update(tileset, frameState, passOptions);
2840
2956
  statistics.incrementSelectionCounts(tile.content);
2841
2957
  ++statistics.selected;
@@ -3379,6 +3495,171 @@ Cesium3DTileset.checkSupportedExtensions = function (extensionsRequired) {
3379
3495
  }
3380
3496
  };
3381
3497
 
3498
+ const scratchGetHeightRay = new Ray();
3499
+ const scratchIntersection = new Cartesian3();
3500
+ const scratchGetHeightCartographic = new Cartographic();
3501
+
3502
+ /**
3503
+ * Get the height of the loaded surface at a given cartographic. This function will only take into account meshes for loaded tiles, not neccisarily the most detailed tiles available for a tileset. This function will always return undefined when sampling a point cloud.
3504
+ *
3505
+ * @param {Cartographic} cartographic The cartographic for which to find the height.
3506
+ * @param {Scene} scene The scene where visualization is taking place.
3507
+ * @returns {number|undefined} The height of the cartographic or undefined if it could not be found.
3508
+ *
3509
+ * @example
3510
+ * const tileset = await Cesium.Cesium3DTileset.fromIonAssetId(124624234);
3511
+ * scene.primitives.add(tileset);
3512
+ *
3513
+ * const height = tileset.getHeight(scene.camera.positionCartographic, scene);
3514
+ */
3515
+ Cesium3DTileset.prototype.getHeight = function (cartographic, scene) {
3516
+ //>>includeStart('debug', pragmas.debug);
3517
+ Check.typeOf.object("cartographic", cartographic);
3518
+ Check.typeOf.object("scene", scene);
3519
+ //>>includeEnd('debug');
3520
+
3521
+ let ellipsoid = scene.globe?.ellipsoid;
3522
+ if (!defined(ellipsoid)) {
3523
+ ellipsoid = Ellipsoid.WGS84;
3524
+ }
3525
+
3526
+ const ray = scratchGetHeightRay;
3527
+ const position = ellipsoid.cartographicToCartesian(
3528
+ cartographic,
3529
+ ray.direction
3530
+ );
3531
+ Cartesian3.normalize(ray.direction, ray.direction);
3532
+
3533
+ ray.direction = Cartesian3.normalize(position, ray.direction);
3534
+ ray.direction = Cartesian3.negate(position, ray.direction);
3535
+ ray.origin = Cartesian3.multiplyByScalar(
3536
+ ray.direction,
3537
+ -2 * ellipsoid.maximumRadius,
3538
+ ray.origin
3539
+ );
3540
+
3541
+ const intersection = this.pick(ray, scene.frameState, scratchIntersection);
3542
+ if (!defined(intersection)) {
3543
+ return;
3544
+ }
3545
+
3546
+ return ellipsoid.cartesianToCartographic(
3547
+ intersection,
3548
+ scratchGetHeightCartographic
3549
+ )?.height;
3550
+ };
3551
+
3552
+ /**
3553
+ * Calls the callback when a new tile is rendered that contains the given cartographic. The only parameter
3554
+ * is the cartographic position on the tile.
3555
+ *
3556
+ * @private
3557
+ *
3558
+ * @param {Scene} scene The scene where visualization is taking place.
3559
+ * @param {Cartographic} cartographic The cartographic position.
3560
+ * @param {Function} callback The function to be called when a new tile is loaded.
3561
+ * @param {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid to use.
3562
+ * @returns {Function} The function to remove this callback from the quadtree.
3563
+ */
3564
+ Cesium3DTileset.prototype.updateHeight = function (
3565
+ cartographic,
3566
+ callback,
3567
+ ellipsoid
3568
+ ) {
3569
+ ellipsoid = defaultValue(ellipsoid, Ellipsoid.WGS84);
3570
+
3571
+ const object = {
3572
+ positionCartographic: cartographic,
3573
+ ellipsoid: ellipsoid,
3574
+ callback: callback,
3575
+ invoked: false,
3576
+ };
3577
+
3578
+ const removeCallback = () => {
3579
+ const addedCallbacks = this._addHeightCallbacks;
3580
+ const length = addedCallbacks.length;
3581
+ for (let i = 0; i < length; ++i) {
3582
+ if (addedCallbacks[i] === object) {
3583
+ addedCallbacks.splice(i, 1);
3584
+ break;
3585
+ }
3586
+ }
3587
+
3588
+ if (object.callback) {
3589
+ object.callback = undefined;
3590
+ }
3591
+ };
3592
+
3593
+ this._addHeightCallbacks.push(object);
3594
+ return removeCallback;
3595
+ };
3596
+
3597
+ const scratchSphereIntersection = new Interval();
3598
+ const scratchPickIntersection = new Cartesian3();
3599
+
3600
+ /**
3601
+ * Find an intersection between a ray and the tileset surface that was rendered. The ray must be given in world coordinates.
3602
+ *
3603
+ * @param {Ray} ray The ray to test for intersection.
3604
+ * @param {FrameState} frameState The frame state.
3605
+ * @param {Cartesian3|undefined} [result] The intersection or <code>undefined</code> if none was found.
3606
+ * @returns {Cartesian3|undefined} The intersection or <code>undefined</code> if none was found.
3607
+ *
3608
+ * @private
3609
+ */
3610
+ Cesium3DTileset.prototype.pick = function (ray, frameState, result) {
3611
+ if (!frameState.context.webgl2 && !this._enablePick) {
3612
+ return;
3613
+ }
3614
+
3615
+ const selectedTiles = this._selectedTiles;
3616
+ const selectedLength = selectedTiles.length;
3617
+ const candidates = [];
3618
+
3619
+ for (let i = 0; i < selectedLength; ++i) {
3620
+ const tile = selectedTiles[i];
3621
+ const boundsIntersection = IntersectionTests.raySphere(
3622
+ ray,
3623
+ tile.contentBoundingVolume.boundingSphere,
3624
+ scratchSphereIntersection
3625
+ );
3626
+ if (!defined(boundsIntersection) || !defined(tile.content)) {
3627
+ continue;
3628
+ }
3629
+
3630
+ candidates.push(tile);
3631
+ }
3632
+
3633
+ const length = candidates.length;
3634
+ candidates.sort((a, b) => {
3635
+ const aDist = BoundingSphere.distanceSquaredTo(
3636
+ a.contentBoundingVolume.boundingSphere,
3637
+ ray.origin
3638
+ );
3639
+ const bDist = BoundingSphere.distanceSquaredTo(
3640
+ b.contentBoundingVolume.boundingSphere,
3641
+ ray.origin
3642
+ );
3643
+
3644
+ return aDist - bDist;
3645
+ });
3646
+
3647
+ let intersection;
3648
+ for (let i = 0; i < length; ++i) {
3649
+ const tile = candidates[i];
3650
+ const candidate = tile.content.pick(
3651
+ ray,
3652
+ frameState,
3653
+ scratchPickIntersection
3654
+ );
3655
+
3656
+ if (defined(candidate)) {
3657
+ intersection = Cartesian3.clone(candidate, result);
3658
+ return intersection;
3659
+ }
3660
+ }
3661
+ };
3662
+
3382
3663
  /**
3383
3664
  * Optimization option. Used as a callback when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control how much to raise the screen space error for tiles outside the foveated cone,
3384
3665
  * interpolating between {@link Cesium3DTileset#foveatedMinimumScreenSpaceErrorRelaxation} and {@link Cesium3DTileset#maximumScreenSpaceError}.
@@ -79,6 +79,8 @@ Cesium3DTilesetTraversal.selectTile = function (tile, frameState) {
79
79
  return;
80
80
  }
81
81
 
82
+ tile._wasSelectedLastFrame = true;
83
+
82
84
  const { content, tileset } = tile;
83
85
  if (content.featurePropertiesDirty) {
84
86
  // A feature's property in this tile changed, the tile needs to be re-styled.
@@ -88,7 +90,9 @@ Cesium3DTilesetTraversal.selectTile = function (tile, frameState) {
88
90
  } else if (tile._selectedFrame < frameState.frameNumber - 1) {
89
91
  // Tile is newly selected; it is selected this frame, but was not selected last frame.
90
92
  tileset._selectedTilesToStyle.push(tile);
93
+ tile._wasSelectedLastFrame = false;
91
94
  }
95
+
92
96
  tile._selectedFrame = frameState.frameNumber;
93
97
  tileset._selectedTiles.push(tile);
94
98
  };
@@ -1,3 +1,4 @@
1
+ import Cartesian3 from "../Core/Cartesian3.js";
1
2
  import defaultValue from "../Core/defaultValue.js";
2
3
  import defined from "../Core/defined.js";
3
4
  import destroyObject from "../Core/destroyObject.js";
@@ -347,6 +348,47 @@ Composite3DTileContent.prototype.update = function (tileset, frameState) {
347
348
  }
348
349
  };
349
350
 
351
+ /**
352
+ * Find an intersection between a ray and the tile content surface that was rendered. The ray must be given in world coordinates.
353
+ *
354
+ * @param {Ray} ray The ray to test for intersection.
355
+ * @param {FrameState} frameState The frame state.
356
+ * @param {Cartesian3|undefined} [result] The intersection or <code>undefined</code> if none was found.
357
+ * @returns {Cartesian3|undefined} The intersection or <code>undefined</code> if none was found.
358
+ *
359
+ * @private
360
+ */
361
+ Composite3DTileContent.prototype.pick = function (ray, frameState, result) {
362
+ if (!this._ready) {
363
+ return undefined;
364
+ }
365
+
366
+ let intersection;
367
+ let minDistance = Number.POSITIVE_INFINITY;
368
+ const contents = this._contents;
369
+ const length = contents.length;
370
+
371
+ for (let i = 0; i < length; ++i) {
372
+ const candidate = contents[i].pick(ray, frameState, result);
373
+
374
+ if (!defined(candidate)) {
375
+ continue;
376
+ }
377
+
378
+ const distance = Cartesian3.distance(ray.origin, candidate);
379
+ if (distance < minDistance) {
380
+ intersection = candidate;
381
+ minDistance = distance;
382
+ }
383
+ }
384
+
385
+ if (!defined(intersection)) {
386
+ return undefined;
387
+ }
388
+
389
+ return result;
390
+ };
391
+
350
392
  Composite3DTileContent.prototype.isDestroyed = function () {
351
393
  return false;
352
394
  };