@cesium/engine 2.1.0 → 2.3.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 (240) hide show
  1. package/Build/Workers/{AttributeCompression-8a5a065e.js → AttributeCompression-f9f6c717.js} +1 -1
  2. package/Build/Workers/{AxisAlignedBoundingBox-a6f9f0e5.js → AxisAlignedBoundingBox-31fadcf0.js} +1 -1
  3. package/Build/Workers/{BoundingRectangle-b0a68595.js → BoundingRectangle-995f0079.js} +1 -1
  4. package/Build/Workers/{BoxGeometry-baedd794.js → BoxGeometry-7eb1af60.js} +1 -1
  5. package/Build/Workers/{Color-f85df1be.js → Color-2dc49658.js} +1 -1
  6. package/Build/Workers/{CoplanarPolygonGeometryLibrary-30516950.js → CoplanarPolygonGeometryLibrary-d7d972d6.js} +1 -1
  7. package/Build/Workers/{CorridorGeometryLibrary-5d5d3b3a.js → CorridorGeometryLibrary-1f5ef7b3.js} +1 -1
  8. package/Build/Workers/{CylinderGeometry-d899ae26.js → CylinderGeometry-23c67a6c.js} +1 -1
  9. package/Build/Workers/{CylinderGeometryLibrary-135b0858.js → CylinderGeometryLibrary-7bf291b4.js} +1 -1
  10. package/Build/Workers/{EllipseGeometry-a49f8449.js → EllipseGeometry-37014da4.js} +1 -1
  11. package/Build/Workers/{EllipseGeometryLibrary-cba7edde.js → EllipseGeometryLibrary-92ab6b1e.js} +1 -1
  12. package/Build/Workers/{EllipseOutlineGeometry-8095c8cb.js → EllipseOutlineGeometry-12b6fef5.js} +1 -1
  13. package/Build/Workers/{EllipsoidGeodesic-dcff5cbd.js → EllipsoidGeodesic-5b3623dc.js} +1 -1
  14. package/Build/Workers/{EllipsoidGeometry-ed93f571.js → EllipsoidGeometry-508da15c.js} +1 -1
  15. package/Build/Workers/{EllipsoidOutlineGeometry-e4854854.js → EllipsoidOutlineGeometry-40d97455.js} +1 -1
  16. package/Build/Workers/{EllipsoidRhumbLine-b672d507.js → EllipsoidRhumbLine-ef872433.js} +1 -1
  17. package/Build/Workers/{EllipsoidTangentPlane-7ae1aa9a.js → EllipsoidTangentPlane-46d4d9c2.js} +1 -1
  18. package/Build/Workers/{EncodedCartesian3-e8bbca36.js → EncodedCartesian3-57415c8a.js} +1 -1
  19. package/Build/Workers/{FrustumGeometry-b62db3e3.js → FrustumGeometry-38605e69.js} +32 -4
  20. package/Build/Workers/{GeometryAttribute-780af4fa.js → GeometryAttribute-a466e9c7.js} +1 -1
  21. package/Build/Workers/{GeometryInstance-3fb607b7.js → GeometryInstance-34d9e21e.js} +1 -1
  22. package/Build/Workers/{GeometryPipeline-36b61c99.js → GeometryPipeline-dcf79306.js} +1 -1
  23. package/Build/Workers/{IndexDatatype-b8f3e09d.js → IndexDatatype-2643aa47.js} +1 -1
  24. package/Build/Workers/{IntersectionTests-e889fcf0.js → IntersectionTests-88c49b2e.js} +1 -1
  25. package/Build/Workers/{Math-dad82b4d.js → Math-0a2ac845.js} +12 -2
  26. package/Build/Workers/{Matrix2-1e403d0e.js → Matrix2-e1298525.js} +1 -1
  27. package/Build/Workers/{Matrix3-fa806b97.js → Matrix3-41c58dde.js} +1 -1
  28. package/Build/Workers/{OrientedBoundingBox-43478ac8.js → OrientedBoundingBox-2dd47921.js} +5 -3
  29. package/Build/Workers/{Plane-c27e1ac6.js → Plane-4c3d403b.js} +1 -1
  30. package/Build/Workers/{PolygonGeometryLibrary-38a98276.js → PolygonGeometryLibrary-59126025.js} +1 -1
  31. package/Build/Workers/PolygonPipeline-1fe328c0.js +1344 -0
  32. package/Build/Workers/{PolylinePipeline-30e4cec9.js → PolylinePipeline-896735cc.js} +1 -1
  33. package/Build/Workers/{PolylineVolumeGeometryLibrary-90551d26.js → PolylineVolumeGeometryLibrary-9c0639f7.js} +1 -1
  34. package/Build/Workers/{PrimitivePipeline-558d9cb0.js → PrimitivePipeline-fc1a47ff.js} +1 -1
  35. package/Build/Workers/{RectangleGeometryLibrary-815c68df.js → RectangleGeometryLibrary-a23c9ebe.js} +1 -1
  36. package/Build/Workers/{TerrainEncoding-341ead52.js → TerrainEncoding-51b8b33b.js} +1 -1
  37. package/Build/Workers/Transforms-bc45e707.js +14699 -0
  38. package/Build/Workers/{WallGeometryLibrary-ccf90976.js → WallGeometryLibrary-007e9883.js} +1 -1
  39. package/Build/Workers/{WebMercatorProjection-76a3fcc0.js → WebMercatorProjection-13ed1a6e.js} +1 -1
  40. package/Build/Workers/{arrayRemoveDuplicates-fac118a8.js → arrayRemoveDuplicates-d2061e85.js} +1 -1
  41. package/Build/Workers/cesiumWorkerBootstrapper.js +1 -1
  42. package/Build/Workers/combineGeometry.js +1 -1
  43. package/Build/Workers/createBoxGeometry.js +1 -1
  44. package/Build/Workers/createBoxOutlineGeometry.js +1 -1
  45. package/Build/Workers/createCircleGeometry.js +1 -1
  46. package/Build/Workers/createCircleOutlineGeometry.js +1 -1
  47. package/Build/Workers/createCoplanarPolygonGeometry.js +1 -1
  48. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +1 -1
  49. package/Build/Workers/createCorridorGeometry.js +1 -1
  50. package/Build/Workers/createCorridorOutlineGeometry.js +1 -1
  51. package/Build/Workers/createCylinderGeometry.js +1 -1
  52. package/Build/Workers/createCylinderOutlineGeometry.js +1 -1
  53. package/Build/Workers/createEllipseGeometry.js +1 -1
  54. package/Build/Workers/createEllipseOutlineGeometry.js +1 -1
  55. package/Build/Workers/createEllipsoidGeometry.js +1 -1
  56. package/Build/Workers/createEllipsoidOutlineGeometry.js +1 -1
  57. package/Build/Workers/createFrustumGeometry.js +1 -1
  58. package/Build/Workers/createFrustumOutlineGeometry.js +1 -1
  59. package/Build/Workers/createGeometry.js +1 -1
  60. package/Build/Workers/createGroundPolylineGeometry.js +1 -1
  61. package/Build/Workers/createPlaneGeometry.js +1 -1
  62. package/Build/Workers/createPlaneOutlineGeometry.js +1 -1
  63. package/Build/Workers/createPolygonGeometry.js +1 -1
  64. package/Build/Workers/createPolygonOutlineGeometry.js +1 -1
  65. package/Build/Workers/createPolylineGeometry.js +1 -1
  66. package/Build/Workers/createPolylineVolumeGeometry.js +1 -1
  67. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +1 -1
  68. package/Build/Workers/createRectangleGeometry.js +1 -1
  69. package/Build/Workers/createRectangleOutlineGeometry.js +1 -1
  70. package/Build/Workers/createSimplePolylineGeometry.js +1 -1
  71. package/Build/Workers/createSphereGeometry.js +1 -1
  72. package/Build/Workers/createSphereOutlineGeometry.js +1 -1
  73. package/Build/Workers/createVectorTileClampedPolylines.js +1 -1
  74. package/Build/Workers/createVectorTileGeometries.js +1 -1
  75. package/Build/Workers/createVectorTilePoints.js +1 -1
  76. package/Build/Workers/createVectorTilePolygons.js +1 -1
  77. package/Build/Workers/createVectorTilePolylines.js +1 -1
  78. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +1 -1
  79. package/Build/Workers/createVerticesFromHeightmap.js +5 -8
  80. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +10 -15
  81. package/Build/Workers/createWallGeometry.js +1 -1
  82. package/Build/Workers/createWallOutlineGeometry.js +1 -1
  83. package/Build/Workers/decodeDraco.js +1 -1
  84. package/Build/Workers/decodeI3S.js +1 -1
  85. package/Build/Workers/package.js +1 -1
  86. package/Build/Workers/transferTypedArrayTest.js +1 -1
  87. package/Build/Workers/upsampleQuantizedTerrainMesh.js +1 -1
  88. package/Source/Core/ArcGISTiledElevationTerrainProvider.js +291 -191
  89. package/Source/Core/BingMapsGeocoderService.js +19 -1
  90. package/Source/Core/CartographicGeocoderService.js +15 -0
  91. package/Source/Core/CesiumTerrainProvider.js +571 -434
  92. package/Source/Core/Credit.js +1 -1
  93. package/Source/Core/CustomHeightmapTerrainProvider.js +12 -0
  94. package/Source/Core/EllipsoidTerrainProvider.js +17 -10
  95. package/Source/Core/FrustumGeometry.js +4 -3
  96. package/Source/Core/GeocoderService.js +32 -1
  97. package/Source/Core/GoogleEarthEnterpriseMetadata.js +86 -34
  98. package/Source/Core/GoogleEarthEnterpriseTerrainProvider.js +119 -82
  99. package/Source/Core/Ion.js +1 -1
  100. package/Source/Core/IonGeocoderService.js +17 -2
  101. package/Source/Core/IonResource.js +14 -3
  102. package/Source/Core/OpenCageGeocoderService.js +18 -1
  103. package/Source/Core/OrientedBoundingBox.js +4 -2
  104. package/Source/Core/OrthographicFrustum.js +13 -0
  105. package/Source/Core/PeliasGeocoderService.js +14 -1
  106. package/Source/Core/PerspectiveFrustum.js +14 -0
  107. package/Source/Core/Request.js +3 -2
  108. package/Source/Core/RequestScheduler.js +10 -5
  109. package/Source/Core/Resource.js +230 -236
  110. package/Source/Core/TerrainProvider.js +9 -14
  111. package/Source/Core/TileProviderError.js +8 -8
  112. package/Source/Core/VRTheWorldTerrainProvider.js +193 -124
  113. package/Source/Core/buildModuleUrl.js +4 -3
  114. package/Source/Core/createWorldTerrain.js +20 -2
  115. package/Source/Core/createWorldTerrainAsync.js +48 -0
  116. package/Source/Core/sampleTerrain.js +9 -10
  117. package/Source/Core/sampleTerrainMostDetailed.js +66 -72
  118. package/Source/DataSources/Cesium3DTilesetVisualizer.js +37 -26
  119. package/Source/DataSources/DataSourceDisplay.js +2 -2
  120. package/Source/DataSources/Entity.js +6 -1
  121. package/Source/DataSources/EntityCluster.js +126 -128
  122. package/Source/DataSources/ModelVisualizer.js +104 -34
  123. package/Source/DataSources/PolygonGraphics.js +1 -1
  124. package/Source/Renderer/UniformState.js +3 -2
  125. package/Source/Renderer/demodernizeShader.js +5 -5
  126. package/Source/Scene/ArcGisBaseMapType.js +12 -0
  127. package/Source/Scene/ArcGisMapServerImageryProvider.js +694 -376
  128. package/Source/Scene/ArcGisMapService.js +83 -0
  129. package/Source/Scene/BingMapsImageryProvider.js +511 -305
  130. package/Source/Scene/BufferLoader.js +29 -34
  131. package/Source/Scene/Camera.js +8 -7
  132. package/Source/Scene/Cesium3DTile.js +392 -254
  133. package/Source/Scene/Cesium3DTileBatchTable.js +2 -2
  134. package/Source/Scene/Cesium3DTileContent.js +16 -0
  135. package/Source/Scene/Cesium3DTileContentFactory.js +4 -4
  136. package/Source/Scene/Cesium3DTilePass.js +8 -11
  137. package/Source/Scene/Cesium3DTileStyleEngine.js +1 -1
  138. package/Source/Scene/Cesium3DTilesVoxelProvider.js +225 -117
  139. package/Source/Scene/Cesium3DTileset.js +756 -482
  140. package/Source/Scene/Cesium3DTilesetBaseTraversal.js +301 -0
  141. package/Source/Scene/Cesium3DTilesetMostDetailedTraversal.js +33 -46
  142. package/Source/Scene/Cesium3DTilesetSkipTraversal.js +421 -0
  143. package/Source/Scene/Cesium3DTilesetTraversal.js +219 -671
  144. package/Source/Scene/ClassificationPrimitive.js +7 -0
  145. package/Source/Scene/Composite3DTileContent.js +69 -26
  146. package/Source/Scene/CreditDisplay.js +132 -20
  147. package/Source/Scene/DepthPlane.js +1 -1
  148. package/Source/Scene/Empty3DTileContent.js +31 -1
  149. package/Source/Scene/Geometry3DTileContent.js +47 -7
  150. package/Source/Scene/Globe.js +5 -1
  151. package/Source/Scene/GlobeSurfaceTile.js +2 -1
  152. package/Source/Scene/GlobeSurfaceTileProvider.js +53 -30
  153. package/Source/Scene/GltfBufferViewLoader.js +47 -91
  154. package/Source/Scene/GltfDracoLoader.js +110 -112
  155. package/Source/Scene/GltfImageLoader.js +71 -78
  156. package/Source/Scene/GltfIndexBufferLoader.js +108 -121
  157. package/Source/Scene/GltfJsonLoader.js +87 -74
  158. package/Source/Scene/GltfLoader.js +381 -300
  159. package/Source/Scene/GltfStructuralMetadataLoader.js +109 -110
  160. package/Source/Scene/GltfTextureLoader.js +97 -96
  161. package/Source/Scene/GltfVertexBufferLoader.js +128 -133
  162. package/Source/Scene/GoogleEarthEnterpriseImageryProvider.js +353 -225
  163. package/Source/Scene/GoogleEarthEnterpriseMapsProvider.js +491 -331
  164. package/Source/Scene/GridImageryProvider.js +267 -104
  165. package/Source/Scene/GroundPolylinePrimitive.js +12 -1
  166. package/Source/Scene/GroundPrimitive.js +8 -1
  167. package/Source/Scene/I3SDataProvider.js +214 -113
  168. package/Source/Scene/I3SFeature.js +7 -6
  169. package/Source/Scene/I3SLayer.js +26 -37
  170. package/Source/Scene/I3SNode.js +59 -66
  171. package/Source/Scene/Imagery.js +6 -1
  172. package/Source/Scene/ImageryLayer.js +299 -48
  173. package/Source/Scene/ImageryLayerCollection.js +26 -0
  174. package/Source/Scene/ImageryProvider.js +129 -111
  175. package/Source/Scene/Implicit3DTileContent.js +72 -23
  176. package/Source/Scene/ImplicitSubtree.js +66 -45
  177. package/Source/Scene/IonImageryProvider.js +482 -275
  178. package/Source/Scene/MapboxImageryProvider.js +272 -112
  179. package/Source/Scene/MapboxStyleImageryProvider.js +270 -111
  180. package/Source/Scene/MetadataSchemaLoader.js +26 -36
  181. package/Source/Scene/Model/B3dmLoader.js +42 -46
  182. package/Source/Scene/Model/GeoJsonLoader.js +8 -32
  183. package/Source/Scene/Model/I3dmLoader.js +48 -74
  184. package/Source/Scene/Model/MaterialPipelineStage.js +12 -12
  185. package/Source/Scene/Model/Model.js +514 -135
  186. package/Source/Scene/Model/Model3DTileContent.js +83 -31
  187. package/Source/Scene/Model/ModelAnimationCollection.js +3 -3
  188. package/Source/Scene/Model/ModelDrawCommand.js +15 -26
  189. package/Source/Scene/Model/ModelUtility.js +16 -16
  190. package/Source/Scene/Model/PntsLoader.js +27 -32
  191. package/Source/Scene/Model/UniformType.js +1 -1
  192. package/Source/Scene/Multiple3DTileContent.js +134 -115
  193. package/Source/Scene/Picking.js +3 -2
  194. package/Source/Scene/PointCloud.js +11 -19
  195. package/Source/Scene/Primitive.js +20 -0
  196. package/Source/Scene/QuadtreePrimitive.js +5 -2
  197. package/Source/Scene/QuadtreeTileProvider.js +4 -8
  198. package/Source/Scene/ResourceCache.js +47 -105
  199. package/Source/Scene/ResourceCacheStatistics.js +24 -58
  200. package/Source/Scene/ResourceLoader.js +5 -17
  201. package/Source/Scene/ResourceLoaderState.js +12 -4
  202. package/Source/Scene/Scene.js +65 -0
  203. package/Source/Scene/SceneTransforms.js +3 -2
  204. package/Source/Scene/ScreenSpaceCameraController.js +2 -2
  205. package/Source/Scene/SingleTileImageryProvider.js +382 -209
  206. package/Source/Scene/Terrain.js +196 -0
  207. package/Source/Scene/TileCoordinatesImageryProvider.js +267 -104
  208. package/Source/Scene/TileMapServiceImageryProvider.js +177 -85
  209. package/Source/Scene/Tileset3DTileContent.js +47 -5
  210. package/Source/Scene/TimeDynamicPointCloud.js +15 -2
  211. package/Source/Scene/UrlTemplateImageryProvider.js +343 -215
  212. package/Source/Scene/Vector3DTileClampedPolylines.js +96 -84
  213. package/Source/Scene/Vector3DTileContent.js +47 -22
  214. package/Source/Scene/Vector3DTileGeometry.js +57 -52
  215. package/Source/Scene/Vector3DTilePoints.js +97 -81
  216. package/Source/Scene/Vector3DTilePolygons.js +118 -117
  217. package/Source/Scene/Vector3DTilePolylines.js +86 -82
  218. package/Source/Scene/Vector3DTilePrimitive.js +0 -1
  219. package/Source/Scene/VoxelContent.js +61 -63
  220. package/Source/Scene/VoxelPrimitive.js +39 -91
  221. package/Source/Scene/VoxelProvider.js +2 -2
  222. package/Source/Scene/WebMapServiceImageryProvider.js +272 -111
  223. package/Source/Scene/WebMapTileServiceImageryProvider.js +270 -107
  224. package/Source/Scene/computeFlyToLocationForRectangle.js +33 -37
  225. package/Source/Scene/createOsmBuildings.js +6 -0
  226. package/Source/Scene/createOsmBuildingsAsync.js +82 -0
  227. package/Source/Scene/createWorldImagery.js +14 -5
  228. package/Source/Scene/createWorldImageryAsync.js +39 -0
  229. package/Source/Shaders/AtmosphereCommon.glsl +51 -8
  230. package/Source/Shaders/AtmosphereCommon.js +51 -8
  231. package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.glsl +1 -1
  232. package/Source/Shaders/PostProcessStages/AmbientOcclusionGenerate.js +1 -1
  233. package/Source/Shaders/PostProcessStages/AmbientOcclusionModulate.glsl +3 -3
  234. package/Source/Shaders/PostProcessStages/AmbientOcclusionModulate.js +3 -3
  235. package/Source/Widget/CesiumWidget.js +67 -27
  236. package/index.d.ts +2429 -1475
  237. package/index.js +324 -315
  238. package/package.json +4 -4
  239. package/Build/Workers/PolygonPipeline-d31ff61c.js +0 -1345
  240. package/Build/Workers/Transforms-9e9df299.js +0 -14714
@@ -10,10 +10,10 @@ import defaultValue from "../Core/defaultValue.js";
10
10
  import defined from "../Core/defined.js";
11
11
  import deprecationWarning from "../Core/deprecationWarning.js";
12
12
  import destroyObject from "../Core/destroyObject.js";
13
- import DeveloperError from "../Core/DeveloperError.js";
14
13
  import Ellipsoid from "../Core/Ellipsoid.js";
15
14
  import Event from "../Core/Event.js";
16
15
  import ImageBasedLighting from "./ImageBasedLighting.js";
16
+ import IonResource from "../Core/IonResource.js";
17
17
  import JulianDate from "../Core/JulianDate.js";
18
18
  import ManagedArray from "../Core/ManagedArray.js";
19
19
  import CesiumMath from "../Core/Math.js";
@@ -52,114 +52,131 @@ import StencilConstants from "./StencilConstants.js";
52
52
  import TileBoundingRegion from "./TileBoundingRegion.js";
53
53
  import TileBoundingSphere from "./TileBoundingSphere.js";
54
54
  import TileOrientedBoundingBox from "./TileOrientedBoundingBox.js";
55
+ import Cesium3DTilesetMostDetailedTraversal from "./Cesium3DTilesetMostDetailedTraversal.js";
56
+ import Cesium3DTilesetBaseTraversal from "./Cesium3DTilesetBaseTraversal.js";
57
+ import Cesium3DTilesetSkipTraversal from "./Cesium3DTilesetSkipTraversal.js";
58
+
59
+ /**
60
+ * @typedef {Object} Cesium3DTileset.ConstructorOptions
61
+ *
62
+ * Initialization options for the Cesium3DTileset constructor
63
+ *
64
+ * @property {Resource|string|Promise<Resource>|Promise<string>} [.url] The url to a tileset JSON file. Deprecated.
65
+ * @property {boolean} [show=true] Determines if the tileset will be shown.
66
+ * @property {Matrix4} [modelMatrix=Matrix4.IDENTITY] A 4x4 transformation matrix that transforms the tileset's root tile.
67
+ * @property {Axis} [modelUpAxis=Axis.Y] Which axis is considered up when loading models for tile contents.
68
+ * @property {Axis} [modelForwardAxis=Axis.X] Which axis is considered forward when loading models for tile contents.
69
+ * @property {ShadowMode} [shadows=ShadowMode.ENABLED] Determines whether the tileset casts or receives shadows from light sources.
70
+ * @property {number} [maximumScreenSpaceError=16] The maximum screen space error used to drive level of detail refinement.
71
+ * @property {number} [maximumMemoryUsage=512] The maximum amount of memory in MB that can be used by the tileset.
72
+ * @property {boolean} [cullWithChildrenBounds=true] Optimization option. Whether to cull tiles using the union of their children bounding volumes.
73
+ * @property {boolean} [cullRequestsWhileMoving=true] Optimization option. Don't request tiles that will likely be unused when they come back because of the camera's movement. This optimization only applies to stationary tilesets.
74
+ * @property {number} [cullRequestsWhileMovingMultiplier=60.0] Optimization option. Multiplier used in culling requests while moving. Larger is more aggressive culling, smaller less aggressive culling.
75
+ * @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
+ * @property {boolean} [preloadFlightDestinations=true] Optimization option. Preload tiles at the camera's flight destination while the camera is in flight.
77
+ * @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.
82
+ * @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
+ * @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
+ * @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.
85
+ * @property {number} [foveatedMinimumScreenSpaceErrorRelaxation=0.0] Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control the starting screen space error relaxation for tiles outside the foveated cone. The screen space error will be raised starting with tileset value up to {@link Cesium3DTileset#maximumScreenSpaceError} based on the provided {@link Cesium3DTileset#foveatedInterpolationCallback}.
86
+ * @property {Cesium3DTileset.foveatedInterpolationCallback} [foveatedInterpolationCallback=Math.lerp] Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control how much to raise the screen space error for tiles outside the foveated cone, interpolating between {@link Cesium3DTileset#foveatedMinimumScreenSpaceErrorRelaxation} and {@link Cesium3DTileset#maximumScreenSpaceError}
87
+ * @property {number} [foveatedTimeDelay=0.2] Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control how long in seconds to wait after the camera stops moving before deferred tiles start loading in. This time delay prevents requesting tiles around the edges of the screen when the camera is moving. Setting this to 0.0 will immediately request all tiles in any given view.
88
+ * @property {boolean} [skipLevelOfDetail=false] Optimization option. Determines if level of detail skipping should be applied during the traversal.
89
+ * @property {number} [baseScreenSpaceError=1024] When <code>skipLevelOfDetail</code> is <code>true</code>, the screen space error that must be reached before skipping levels of detail.
90
+ * @property {number} [skipScreenSpaceErrorFactor=16] When <code>skipLevelOfDetail</code> is <code>true</code>, a multiplier defining the minimum screen space error to skip. Used in conjunction with <code>skipLevels</code> to determine which tiles to load.
91
+ * @property {number} [skipLevels=1] When <code>skipLevelOfDetail</code> is <code>true</code>, a constant defining the minimum number of levels to skip when loading tiles. When it is 0, no levels are skipped. Used in conjunction with <code>skipScreenSpaceErrorFactor</code> to determine which tiles to load.
92
+ * @property {boolean} [immediatelyLoadDesiredLevelOfDetail=false] When <code>skipLevelOfDetail</code> is <code>true</code>, only tiles that meet the maximum screen space error will ever be downloaded. Skipping factors are ignored and just the desired tiles are loaded.
93
+ * @property {boolean} [loadSiblings=false] When <code>skipLevelOfDetail</code> is <code>true</code>, determines whether siblings of visible tiles are always downloaded during traversal.
94
+ * @property {ClippingPlaneCollection} [clippingPlanes] The {@link ClippingPlaneCollection} used to selectively disable rendering the tileset.
95
+ * @property {ClassificationType} [classificationType] Determines whether terrain, 3D Tiles or both will be classified by this tileset. See {@link Cesium3DTileset#classificationType} for details about restrictions and limitations.
96
+ * @property {Ellipsoid} [ellipsoid=Ellipsoid.WGS84] The ellipsoid determining the size and shape of the globe.
97
+ * @property {object} [pointCloudShading] Options for constructing a {@link PointCloudShading} object to control point attenuation based on geometric error and lighting.
98
+ * @property {Cartesian3} [lightColor] The light color when shading models. When <code>undefined</code> the scene's light color is used instead.
99
+ * @property {ImageBasedLighting} [imageBasedLighting] The properties for managing image-based lighting for this tileset.
100
+ * @property {boolean} [backFaceCulling=true] Whether to cull back-facing geometry. When true, back face culling is determined by the glTF material's doubleSided property; when false, back face culling is disabled.
101
+ * @property {boolean} [enableShowOutline=true] Whether to enable outlines for models using the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. This can be set to false to avoid the additional processing of geometry at load time. When false, the showOutlines and outlineColor options are ignored.
102
+ * @property {boolean} [showOutline=true] Whether to display the outline for models using the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. When true, outlines are displayed. When false, outlines are not displayed.
103
+ * @property {Color} [outlineColor=Color.BLACK] The color to use when rendering outlines.
104
+ * @property {boolean} [vectorClassificationOnly=false] Indicates that only the tileset's vector tiles should be used for classification.
105
+ * @property {boolean} [vectorKeepDecodedPositions=false] Whether vector tiles should keep decoded positions in memory. This is used with {@link Cesium3DTileFeature.getPolylinePositions}.
106
+ * @property {string|number} [featureIdLabel="featureId_0"] Label of the feature ID set to use for picking and styling. For EXT_mesh_features, this is the feature ID's label property, or "featureId_N" (where N is the index in the featureIds array) when not specified. EXT_feature_metadata did not have a label field, so such feature ID sets are always labeled "featureId_N" where N is the index in the list of all feature Ids, where feature ID attributes are listed before feature ID textures. If featureIdLabel is an integer N, it is converted to the string "featureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.
107
+ * @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
+ * @property {boolean} [showCreditsOnScreen=false] Whether to display the credits of this tileset on screen.
109
+ * @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.
111
+ * @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
+ * @property {boolean} [debugFreezeFrame=false] For debugging only. Determines if only the tiles from last frame should be used for rendering.
113
+ * @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.
115
+ * @property {boolean} [debugWireframe=false] For debugging only. When true, render's each tile's content as a wireframe.
116
+ * @property {boolean} [debugShowBoundingVolume=false] For debugging only. When true, renders the bounding volume for each tile.
117
+ * @property {boolean} [debugShowContentBoundingVolume=false] For debugging only. When true, renders the bounding volume for each tile's content.
118
+ * @property {boolean} [debugShowViewerRequestVolume=false] For debugging only. When true, renders the viewer request volume for each tile.
119
+ * @property {boolean} [debugShowGeometricError=false] For debugging only. When true, draws labels to indicate the geometric error of each tile.
120
+ * @property {boolean} [debugShowRenderingStatistics=false] For debugging only. When true, draws labels to indicate the number of commands, points, triangles and features for each tile.
121
+ * @property {boolean} [debugShowMemoryUsage=false] For debugging only. When true, draws labels to indicate the texture and geometry memory in megabytes used by each tile.
122
+ * @property {boolean} [debugShowUrl=false] For debugging only. When true, draws labels to indicate the url of each tile.
123
+ */
55
124
 
56
125
  /**
57
126
  * A {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification|3D Tiles tileset},
58
127
  * used for streaming massive heterogeneous 3D geospatial datasets.
59
128
  *
129
+ * <div class="notice">
130
+ * This object is normally not instantiated directly, use {@link Cesium3DTileset.fromUrl}.
131
+ * </div>
132
+ *
60
133
  * @alias Cesium3DTileset
61
134
  * @constructor
62
135
  *
63
- * @param {object} options Object with the following properties:
64
- * @param {Resource|string|Promise<Resource>|Promise<string>} options.url The url to a tileset JSON file.
65
- * @param {boolean} [options.show=true] Determines if the tileset will be shown.
66
- * @param {Matrix4} [options.modelMatrix=Matrix4.IDENTITY] A 4x4 transformation matrix that transforms the tileset's root tile.
67
- * @param {Axis} [options.modelUpAxis=Axis.Y] Which axis is considered up when loading models for tile contents.
68
- * @param {Axis} [options.modelForwardAxis=Axis.X] Which axis is considered forward when loading models for tile contents.
69
- * @param {ShadowMode} [options.shadows=ShadowMode.ENABLED] Determines whether the tileset casts or receives shadows from light sources.
70
- * @param {number} [options.maximumScreenSpaceError=16] The maximum screen space error used to drive level of detail refinement.
71
- * @param {number} [options.maximumMemoryUsage=512] The maximum amount of memory in MB that can be used by the tileset.
72
- * @param {boolean} [options.cullWithChildrenBounds=true] Optimization option. Whether to cull tiles using the union of their children bounding volumes.
73
- * @param {boolean} [options.cullRequestsWhileMoving=true] Optimization option. Don't request tiles that will likely be unused when they come back because of the camera's movement. This optimization only applies to stationary tilesets.
74
- * @param {number} [options.cullRequestsWhileMovingMultiplier=60.0] Optimization option. Multiplier used in culling requests while moving. Larger is more aggressive culling, smaller less aggressive culling.
75
- * @param {boolean} [options.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
- * @param {boolean} [options.preloadFlightDestinations=true] Optimization option. Preload tiles at the camera's flight destination while the camera is in flight.
77
- * @param {boolean} [options.preferLeaves=false] Optimization option. Prefer loading of leaves first.
78
- * @param {boolean} [options.dynamicScreenSpaceError=false] Optimization option. Reduce the screen space error for tiles that are further away from the camera.
79
- * @param {number} [options.dynamicScreenSpaceErrorDensity=0.00278] Density used to adjust the dynamic screen space error, similar to fog density.
80
- * @param {number} [options.dynamicScreenSpaceErrorFactor=4.0] A factor used to increase the computed dynamic screen space error.
81
- * @param {number} [options.dynamicScreenSpaceErrorHeightFalloff=0.25] A ratio of the tileset's height at which the density starts to falloff.
82
- * @param {number} [options.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
- * @param {boolean} [options.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
- * @param {number} [options.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.
85
- * @param {number} [options.foveatedMinimumScreenSpaceErrorRelaxation=0.0] Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control the starting screen space error relaxation for tiles outside the foveated cone. The screen space error will be raised starting with tileset value up to {@link Cesium3DTileset#maximumScreenSpaceError} based on the provided {@link Cesium3DTileset#foveatedInterpolationCallback}.
86
- * @param {Cesium3DTileset.foveatedInterpolationCallback} [options.foveatedInterpolationCallback=Math.lerp] Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control how much to raise the screen space error for tiles outside the foveated cone, interpolating between {@link Cesium3DTileset#foveatedMinimumScreenSpaceErrorRelaxation} and {@link Cesium3DTileset#maximumScreenSpaceError}
87
- * @param {number} [options.foveatedTimeDelay=0.2] Optimization option. Used when {@link Cesium3DTileset#foveatedScreenSpaceError} is true to control how long in seconds to wait after the camera stops moving before deferred tiles start loading in. This time delay prevents requesting tiles around the edges of the screen when the camera is moving. Setting this to 0.0 will immediately request all tiles in any given view.
88
- * @param {boolean} [options.skipLevelOfDetail=false] Optimization option. Determines if level of detail skipping should be applied during the traversal.
89
- * @param {number} [options.baseScreenSpaceError=1024] When <code>skipLevelOfDetail</code> is <code>true</code>, the screen space error that must be reached before skipping levels of detail.
90
- * @param {number} [options.skipScreenSpaceErrorFactor=16] When <code>skipLevelOfDetail</code> is <code>true</code>, a multiplier defining the minimum screen space error to skip. Used in conjunction with <code>skipLevels</code> to determine which tiles to load.
91
- * @param {number} [options.skipLevels=1] When <code>skipLevelOfDetail</code> is <code>true</code>, a constant defining the minimum number of levels to skip when loading tiles. When it is 0, no levels are skipped. Used in conjunction with <code>skipScreenSpaceErrorFactor</code> to determine which tiles to load.
92
- * @param {boolean} [options.immediatelyLoadDesiredLevelOfDetail=false] When <code>skipLevelOfDetail</code> is <code>true</code>, only tiles that meet the maximum screen space error will ever be downloaded. Skipping factors are ignored and just the desired tiles are loaded.
93
- * @param {boolean} [options.loadSiblings=false] When <code>skipLevelOfDetail</code> is <code>true</code>, determines whether siblings of visible tiles are always downloaded during traversal.
94
- * @param {ClippingPlaneCollection} [options.clippingPlanes] The {@link ClippingPlaneCollection} used to selectively disable rendering the tileset.
95
- * @param {ClassificationType} [options.classificationType] Determines whether terrain, 3D Tiles or both will be classified by this tileset. See {@link Cesium3DTileset#classificationType} for details about restrictions and limitations.
96
- * @param {Ellipsoid} [options.ellipsoid=Ellipsoid.WGS84] The ellipsoid determining the size and shape of the globe.
97
- * @param {object} [options.pointCloudShading] Options for constructing a {@link PointCloudShading} object to control point attenuation based on geometric error and lighting.
98
- * @param {Cartesian3} [options.lightColor] The light color when shading models. When <code>undefined</code> the scene's light color is used instead.
99
- * @param {ImageBasedLighting} [options.imageBasedLighting] The properties for managing image-based lighting for this tileset.
100
- * @param {boolean} [options.backFaceCulling=true] Whether to cull back-facing geometry. When true, back face culling is determined by the glTF material's doubleSided property; when false, back face culling is disabled.
101
- * @param {boolean} [options.enableShowOutline=true] Whether to enable outlines for models using the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. This can be set to false to avoid the additional processing of geometry at load time. When false, the showOutlines and outlineColor options are ignored.
102
- * @param {boolean} [options.showOutline=true] Whether to display the outline for models using the {@link https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/CESIUM_primitive_outline|CESIUM_primitive_outline} extension. When true, outlines are displayed. When false, outlines are not displayed.
103
- * @param {Color} [options.outlineColor=Color.BLACK] The color to use when rendering outlines.
104
- * @param {boolean} [options.vectorClassificationOnly=false] Indicates that only the tileset's vector tiles should be used for classification.
105
- * @param {boolean} [options.vectorKeepDecodedPositions=false] Whether vector tiles should keep decoded positions in memory. This is used with {@link Cesium3DTileFeature.getPolylinePositions}.
106
- * @param {string|number} [options.featureIdLabel="featureId_0"] Label of the feature ID set to use for picking and styling. For EXT_mesh_features, this is the feature ID's label property, or "featureId_N" (where N is the index in the featureIds array) when not specified. EXT_feature_metadata did not have a label field, so such feature ID sets are always labeled "featureId_N" where N is the index in the list of all feature Ids, where feature ID attributes are listed before feature ID textures. If featureIdLabel is an integer N, it is converted to the string "featureId_N" automatically. If both per-primitive and per-instance feature IDs are present, the instance feature IDs take priority.
107
- * @param {string|number} [options.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
- * @param {boolean} [options.showCreditsOnScreen=false] Whether to display the credits of this tileset on screen.
109
- * @param {SplitDirection} [options.splitDirection=SplitDirection.NONE] The {@link SplitDirection} split to apply to this tileset.
110
- * @param {boolean} [options.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.
111
- * @param {string} [options.debugHeatmapTilePropertyName] The tile variable to colorize as a heatmap. All rendered tiles will be colorized relative to each other's specified variable value.
112
- * @param {boolean} [options.debugFreezeFrame=false] For debugging only. Determines if only the tiles from last frame should be used for rendering.
113
- * @param {boolean} [options.debugColorizeTiles=false] For debugging only. When true, assigns a random color to each tile.
114
- * @param {boolean} [options.enableDebugWireframe] For debugging only. This must be true for debugWireframe to work in WebGL1. This cannot be set after the tileset has loaded.
115
- * @param {boolean} [options.debugWireframe=false] For debugging only. When true, render's each tile's content as a wireframe.
116
- * @param {boolean} [options.debugShowBoundingVolume=false] For debugging only. When true, renders the bounding volume for each tile.
117
- * @param {boolean} [options.debugShowContentBoundingVolume=false] For debugging only. When true, renders the bounding volume for each tile's content.
118
- * @param {boolean} [options.debugShowViewerRequestVolume=false] For debugging only. When true, renders the viewer request volume for each tile.
119
- * @param {boolean} [options.debugShowGeometricError=false] For debugging only. When true, draws labels to indicate the geometric error of each tile.
120
- * @param {boolean} [options.debugShowRenderingStatistics=false] For debugging only. When true, draws labels to indicate the number of commands, points, triangles and features for each tile.
121
- * @param {boolean} [options.debugShowMemoryUsage=false] For debugging only. When true, draws labels to indicate the texture and geometry memory in megabytes used by each tile.
122
- * @param {boolean} [options.debugShowUrl=false] For debugging only. When true, draws labels to indicate the url of each tile.
136
+ * @param {Cesium3DTileset.ConstructorOptions} options An object describing initialization options
123
137
  *
124
138
  * @exception {DeveloperError} The tileset must be 3D Tiles version 0.0 or 1.0.
125
139
  *
126
140
  * @example
127
- * const tileset = scene.primitives.add(new Cesium.Cesium3DTileset({
128
- * url : 'http://localhost:8002/tilesets/Seattle/tileset.json'
129
- * }));
141
+ * try {
142
+ * const tileset = await Cesium.Cesium3DTileset.fromUrl(
143
+ * "http://localhost:8002/tilesets/Seattle/tileset.json"
144
+ * );
145
+ * scene.primitives.add(tileset);
146
+ * } catch (error) {
147
+ * console.error(`Error creating tileset: ${error}`);
148
+ * }
130
149
  *
131
150
  * @example
132
151
  * // Common setting for the skipLevelOfDetail optimization
133
- * const tileset = scene.primitives.add(new Cesium.Cesium3DTileset({
134
- * url : 'http://localhost:8002/tilesets/Seattle/tileset.json',
135
- * skipLevelOfDetail : true,
136
- * baseScreenSpaceError : 1024,
137
- * skipScreenSpaceErrorFactor : 16,
138
- * skipLevels : 1,
139
- * immediatelyLoadDesiredLevelOfDetail : false,
140
- * loadSiblings : false,
141
- * cullWithChildrenBounds : true
142
- * }));
152
+ * const tileset = await Cesium.Cesium3DTileset.fromUrl(
153
+ * "http://localhost:8002/tilesets/Seattle/tileset.json", {
154
+ * skipLevelOfDetail: true,
155
+ * baseScreenSpaceError: 1024,
156
+ * skipScreenSpaceErrorFactor: 16,
157
+ * skipLevels: 1,
158
+ * immediatelyLoadDesiredLevelOfDetail: false,
159
+ * loadSiblings: false,
160
+ * cullWithChildrenBounds: true
161
+ * });
162
+ * scene.primitives.add(tileset);
143
163
  *
144
164
  * @example
145
165
  * // Common settings for the dynamicScreenSpaceError optimization
146
- * const tileset = scene.primitives.add(new Cesium.Cesium3DTileset({
147
- * url : 'http://localhost:8002/tilesets/Seattle/tileset.json',
148
- * dynamicScreenSpaceError : true,
149
- * dynamicScreenSpaceErrorDensity : 0.00278,
150
- * dynamicScreenSpaceErrorFactor : 4.0,
151
- * dynamicScreenSpaceErrorHeightFalloff : 0.25
152
- * }));
166
+ * const tileset = await Cesium.Cesium3DTileset.fromUrl(
167
+ * "http://localhost:8002/tilesets/Seattle/tileset.json", {
168
+ * dynamicScreenSpaceError: true,
169
+ * dynamicScreenSpaceErrorDensity: 0.00278,
170
+ * dynamicScreenSpaceErrorFactor: 4.0,
171
+ * dynamicScreenSpaceErrorHeightFalloff: 0.25
172
+ * });
173
+ * scene.primitives.add(tileset);
153
174
  *
154
175
  * @see {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification|3D Tiles specification}
155
176
  */
156
177
  function Cesium3DTileset(options) {
157
178
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
158
179
 
159
- //>>includeStart('debug', pragmas.debug);
160
- Check.defined("options.url", options.url);
161
- //>>includeEnd('debug');
162
-
163
180
  this._url = undefined;
164
181
  this._basePath = undefined;
165
182
  this._root = undefined;
@@ -654,7 +671,7 @@ function Cesium3DTileset(options) {
654
671
  * @default false
655
672
  */
656
673
  this.skipLevelOfDetail = defaultValue(options.skipLevelOfDetail, false);
657
- this._skipLevelOfDetail = this.skipLevelOfDetail;
674
+
658
675
  this._disableSkipLevelOfDetail = false;
659
676
 
660
677
  /**
@@ -884,6 +901,10 @@ function Cesium3DTileset(options) {
884
901
  false
885
902
  );
886
903
 
904
+ /**
905
+ * @private
906
+ * @type {LabelCollection|undefined}
907
+ */
887
908
  this._tileDebugLabels = undefined;
888
909
  this.debugPickedTileLabelOnly = false;
889
910
  this.debugPickedTile = undefined;
@@ -970,114 +991,123 @@ function Cesium3DTileset(options) {
970
991
  }
971
992
  this._instanceFeatureIdLabel = instanceFeatureIdLabel;
972
993
 
973
- this._schemaLoader = undefined;
974
-
975
- const that = this;
976
- let resource;
977
- this._readyPromise = Promise.resolve(options.url)
978
- .then(function (url) {
979
- let basePath;
980
- resource = Resource.createIfNeeded(url);
981
- that._resource = resource;
982
-
983
- // ion resources have a credits property we can use for additional attribution.
984
- that._credits = resource.credits;
985
-
986
- if (resource.extension === "json") {
987
- basePath = resource.getBaseUri(true);
988
- } else if (resource.isDataUri) {
989
- basePath = "";
990
- }
994
+ if (defined(options.url)) {
995
+ deprecationWarning(
996
+ "Cesium3DTileset options.url",
997
+ "Cesium3DTileset constructor parameter options.url was deprecated in CesiumJS 1.104. It will be removed in 1.107. Use Cesium3DTileset.fromUrl instead."
998
+ );
999
+ const that = this;
1000
+ let resource;
1001
+ this._readyPromise = Promise.resolve(options.url)
1002
+ .then(function (url) {
1003
+ let basePath;
1004
+ resource = Resource.createIfNeeded(url);
1005
+ that._resource = resource;
1006
+
1007
+ // ion resources have a credits property we can use for additional attribution.
1008
+ that._credits = resource.credits;
1009
+
1010
+ if (resource.extension === "json") {
1011
+ basePath = resource.getBaseUri(true);
1012
+ } else if (resource.isDataUri) {
1013
+ basePath = "";
1014
+ }
991
1015
 
992
- that._url = resource.url;
993
- that._basePath = basePath;
1016
+ that._url = resource.url;
1017
+ that._basePath = basePath;
994
1018
 
995
- return Cesium3DTileset.loadJson(resource);
996
- })
997
- .then(function (tilesetJson) {
998
- if (that.isDestroyed()) {
999
- return;
1000
- }
1001
-
1002
- // This needs to be called before loadTileset() so tile metadata
1003
- // can be initialized synchronously in the Cesium3DTile constructor
1004
- return processMetadataExtension(that, tilesetJson);
1005
- })
1006
- .then(function (tilesetJson) {
1007
- if (that.isDestroyed()) {
1008
- return;
1009
- }
1019
+ return Cesium3DTileset.loadJson(resource);
1020
+ })
1021
+ .then(function (tilesetJson) {
1022
+ if (that.isDestroyed()) {
1023
+ return;
1024
+ }
1010
1025
 
1011
- // Set these before loading the tileset since _geometricError
1012
- // and _scaledGeometricError get accessed during tile creation
1013
- that._geometricError = tilesetJson.geometricError;
1014
- that._scaledGeometricError = tilesetJson.geometricError;
1015
-
1016
- that._root = that.loadTileset(resource, tilesetJson);
1017
-
1018
- // Handle legacy gltfUpAxis option
1019
- const gltfUpAxis = defined(tilesetJson.asset.gltfUpAxis)
1020
- ? Axis.fromName(tilesetJson.asset.gltfUpAxis)
1021
- : Axis.Y;
1022
- const modelUpAxis = defaultValue(options.modelUpAxis, gltfUpAxis);
1023
- const modelForwardAxis = defaultValue(options.modelForwardAxis, Axis.X);
1024
-
1025
- const asset = tilesetJson.asset;
1026
- that._asset = asset;
1027
- that._properties = tilesetJson.properties;
1028
- that._extensionsUsed = tilesetJson.extensionsUsed;
1029
- that._extensions = tilesetJson.extensions;
1030
- that._modelUpAxis = modelUpAxis;
1031
- that._modelForwardAxis = modelForwardAxis;
1032
- that._extras = tilesetJson.extras;
1033
-
1034
- const extras = asset.extras;
1035
- if (
1036
- defined(extras) &&
1037
- defined(extras.cesium) &&
1038
- defined(extras.cesium.credits)
1039
- ) {
1040
- const extraCredits = extras.cesium.credits;
1041
- let credits = that._credits;
1042
- if (!defined(credits)) {
1043
- credits = [];
1044
- that._credits = credits;
1026
+ // This needs to be called before loadTileset() so tile metadata
1027
+ // can be initialized synchronously in the Cesium3DTile constructor
1028
+ return processMetadataExtension(resource, tilesetJson).then(
1029
+ (metadata) => {
1030
+ that._metadataExtension = metadata;
1031
+ return tilesetJson;
1032
+ }
1033
+ );
1034
+ })
1035
+ .then(function (tilesetJson) {
1036
+ if (that.isDestroyed()) {
1037
+ return;
1045
1038
  }
1046
- for (let i = 0; i < extraCredits.length; ++i) {
1047
- const credit = extraCredits[i];
1048
- credits.push(new Credit(credit.html, that._showCreditsOnScreen));
1039
+
1040
+ // Set these before loading the tileset since _geometricError
1041
+ // and _scaledGeometricError get accessed during tile creation
1042
+ that._geometricError = tilesetJson.geometricError;
1043
+ that._scaledGeometricError = tilesetJson.geometricError;
1044
+
1045
+ that._root = that.loadTileset(resource, tilesetJson);
1046
+
1047
+ // Handle legacy gltfUpAxis option
1048
+ const gltfUpAxis = defined(tilesetJson.asset.gltfUpAxis)
1049
+ ? Axis.fromName(tilesetJson.asset.gltfUpAxis)
1050
+ : Axis.Y;
1051
+ const modelUpAxis = defaultValue(options.modelUpAxis, gltfUpAxis);
1052
+ const modelForwardAxis = defaultValue(options.modelForwardAxis, Axis.X);
1053
+
1054
+ const asset = tilesetJson.asset;
1055
+ that._asset = asset;
1056
+ that._properties = tilesetJson.properties;
1057
+ that._extensionsUsed = tilesetJson.extensionsUsed;
1058
+ that._extensions = tilesetJson.extensions;
1059
+ that._modelUpAxis = modelUpAxis;
1060
+ that._modelForwardAxis = modelForwardAxis;
1061
+ that._extras = tilesetJson.extras;
1062
+
1063
+ const extras = asset.extras;
1064
+ if (
1065
+ defined(extras) &&
1066
+ defined(extras.cesium) &&
1067
+ defined(extras.cesium.credits)
1068
+ ) {
1069
+ const extraCredits = extras.cesium.credits;
1070
+ let credits = that._credits;
1071
+ if (!defined(credits)) {
1072
+ credits = [];
1073
+ that._credits = credits;
1074
+ }
1075
+ for (let i = 0; i < extraCredits.length; ++i) {
1076
+ const credit = extraCredits[i];
1077
+ credits.push(new Credit(credit.html, that._showCreditsOnScreen));
1078
+ }
1049
1079
  }
1050
- }
1051
1080
 
1052
- // Save the original, untransformed bounding volume position so we can apply
1053
- // the tile transform and model matrix at run time
1054
- const boundingVolume = that._root.createBoundingVolume(
1055
- tilesetJson.root.boundingVolume,
1056
- Matrix4.IDENTITY
1057
- );
1058
- const clippingPlanesOrigin = boundingVolume.boundingSphere.center;
1059
- // If this origin is above the surface of the earth
1060
- // we want to apply an ENU orientation as our best guess of orientation.
1061
- // Otherwise, we assume it gets its position/orientation completely from the
1062
- // root tile transform and the tileset's model matrix
1063
- const originCartographic = that._ellipsoid.cartesianToCartographic(
1064
- clippingPlanesOrigin
1065
- );
1066
- if (
1067
- defined(originCartographic) &&
1068
- originCartographic.height >
1069
- ApproximateTerrainHeights._defaultMinTerrainHeight
1070
- ) {
1071
- that._initialClippingPlanesOriginMatrix = Transforms.eastNorthUpToFixedFrame(
1081
+ // Save the original, untransformed bounding volume position so we can apply
1082
+ // the tile transform and model matrix at run time
1083
+ const boundingVolume = that._root.createBoundingVolume(
1084
+ tilesetJson.root.boundingVolume,
1085
+ Matrix4.IDENTITY
1086
+ );
1087
+ const clippingPlanesOrigin = boundingVolume.boundingSphere.center;
1088
+ // If this origin is above the surface of the earth
1089
+ // we want to apply an ENU orientation as our best guess of orientation.
1090
+ // Otherwise, we assume it gets its position/orientation completely from the
1091
+ // root tile transform and the tileset's model matrix
1092
+ const originCartographic = that._ellipsoid.cartesianToCartographic(
1072
1093
  clippingPlanesOrigin
1073
1094
  );
1074
- }
1075
- that._clippingPlanesOriginMatrix = Matrix4.clone(
1076
- that._initialClippingPlanesOriginMatrix
1077
- );
1095
+ if (
1096
+ defined(originCartographic) &&
1097
+ originCartographic.height >
1098
+ ApproximateTerrainHeights._defaultMinTerrainHeight
1099
+ ) {
1100
+ that._initialClippingPlanesOriginMatrix = Transforms.eastNorthUpToFixedFrame(
1101
+ clippingPlanesOrigin
1102
+ );
1103
+ }
1104
+ that._clippingPlanesOriginMatrix = Matrix4.clone(
1105
+ that._initialClippingPlanesOriginMatrix
1106
+ );
1078
1107
 
1079
- return that;
1080
- });
1108
+ return that;
1109
+ });
1110
+ }
1081
1111
  }
1082
1112
 
1083
1113
  Object.defineProperties(Cesium3DTileset.prototype, {
@@ -1104,19 +1134,9 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1104
1134
  *
1105
1135
  * @type {object}
1106
1136
  * @readonly
1107
- *
1108
- * @exception {DeveloperError} The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true.
1109
1137
  */
1110
1138
  asset: {
1111
1139
  get: function () {
1112
- //>>includeStart('debug', pragmas.debug);
1113
- if (!this.ready) {
1114
- throw new DeveloperError(
1115
- "The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true."
1116
- );
1117
- }
1118
- //>>includeEnd('debug');
1119
-
1120
1140
  return this._asset;
1121
1141
  },
1122
1142
  },
@@ -1128,19 +1148,9 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1128
1148
  *
1129
1149
  * @type {object}
1130
1150
  * @readonly
1131
- *
1132
- * @exception {DeveloperError} The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true.
1133
1151
  */
1134
1152
  extensions: {
1135
1153
  get: function () {
1136
- //>>includeStart('debug', pragmas.debug);
1137
- if (!this.ready) {
1138
- throw new DeveloperError(
1139
- "The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true."
1140
- );
1141
- }
1142
- //>>includeEnd('debug');
1143
-
1144
1154
  return this._extensions;
1145
1155
  },
1146
1156
  },
@@ -1173,8 +1183,6 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1173
1183
  * @type {object}
1174
1184
  * @readonly
1175
1185
  *
1176
- * @exception {DeveloperError} The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true.
1177
- *
1178
1186
  * @example
1179
1187
  * console.log(`Maximum building height: ${tileset.properties.height.maximum}`);
1180
1188
  * console.log(`Minimum building height: ${tileset.properties.height.minimum}`);
@@ -1184,21 +1192,12 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1184
1192
  */
1185
1193
  properties: {
1186
1194
  get: function () {
1187
- //>>includeStart('debug', pragmas.debug);
1188
- if (!this.ready) {
1189
- throw new DeveloperError(
1190
- "The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true."
1191
- );
1192
- }
1193
- //>>includeEnd('debug');
1194
-
1195
1195
  return this._properties;
1196
1196
  },
1197
1197
  },
1198
1198
 
1199
1199
  /**
1200
1200
  * When <code>true</code>, the tileset's root tile is loaded and the tileset is ready to render.
1201
- * This is set to <code>true</code> right before {@link Cesium3DTileset#readyPromise} is resolved.
1202
1201
  *
1203
1202
  * @memberof Cesium3DTileset.prototype
1204
1203
  *
@@ -1209,6 +1208,10 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1209
1208
  */
1210
1209
  ready: {
1211
1210
  get: function () {
1211
+ deprecationWarning(
1212
+ "Cesium3DTileset.ready",
1213
+ "Cesium3DTileset.ready was deprecated in CesiumJS 1.104. It will be removed in 1.107. Use Cesium3DTileset.fromUrl instead."
1214
+ );
1212
1215
  return defined(this._root);
1213
1216
  },
1214
1217
  },
@@ -1223,6 +1226,7 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1223
1226
  *
1224
1227
  * @type {Promise<Cesium3DTileset>}
1225
1228
  * @readonly
1229
+ * @deprecated
1226
1230
  *
1227
1231
  * @example
1228
1232
  * tileset.readyPromise.then(function(tileset) {
@@ -1237,6 +1241,10 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1237
1241
  */
1238
1242
  readyPromise: {
1239
1243
  get: function () {
1244
+ deprecationWarning(
1245
+ "Cesium3DTileset.readyPromise",
1246
+ "Cesium3DTileset.readyPromise was deprecated in CesiumJS 1.104. It will be removed in 1.107. Use Cesium3DTileset.fromUrl instead."
1247
+ );
1240
1248
  return this._readyPromise;
1241
1249
  },
1242
1250
  },
@@ -1369,6 +1377,50 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1369
1377
  },
1370
1378
  },
1371
1379
 
1380
+ /**
1381
+ * Whether the tileset is rendering different levels of detail in the same view.
1382
+ * Only relevant if {@link Cesium3DTileset.isSkippingLevelOfDetail} is true.
1383
+ *
1384
+ * @memberof Cesium3DTileset.prototype
1385
+ *
1386
+ * @type {boolean}
1387
+ * @private
1388
+ */
1389
+ hasMixedContent: {
1390
+ get: function () {
1391
+ return this._hasMixedContent;
1392
+ },
1393
+ set: function (value) {
1394
+ //>>includeStart('debug', pragmas.debug);
1395
+ Check.typeOf.bool("value", value);
1396
+ //>>includeEnd('debug');
1397
+
1398
+ this._hasMixedContent = value;
1399
+ },
1400
+ },
1401
+
1402
+ /**
1403
+ * Whether this tileset is actually skipping levels of detail.
1404
+ * The user option may have been disabled if all tiles are using additive refinement,
1405
+ * or if some tiles have a content type for which rendering does not support skipping
1406
+ *
1407
+ * @memberof Cesium3DTileset.prototype
1408
+ *
1409
+ * @type {boolean}
1410
+ * @private
1411
+ * @readonly
1412
+ */
1413
+ isSkippingLevelOfDetail: {
1414
+ get: function () {
1415
+ return (
1416
+ this.skipLevelOfDetail &&
1417
+ !defined(this._classificationType) &&
1418
+ !this._disableSkipLevelOfDetail &&
1419
+ !this._allTilesAdditive
1420
+ );
1421
+ },
1422
+ },
1423
+
1372
1424
  /**
1373
1425
  * The tileset's schema, groups, tileset metadata and other details from the
1374
1426
  * 3DTILES_metadata extension or a 3D Tiles 1.1 tileset JSON. This getter is
@@ -1533,19 +1585,9 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1533
1585
  *
1534
1586
  * @type {Cesium3DTile}
1535
1587
  * @readonly
1536
- *
1537
- * @exception {DeveloperError} The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true.
1538
1588
  */
1539
1589
  root: {
1540
1590
  get: function () {
1541
- //>>includeStart('debug', pragmas.debug);
1542
- if (!this.ready) {
1543
- throw new DeveloperError(
1544
- "The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true."
1545
- );
1546
- }
1547
- //>>includeEnd('debug');
1548
-
1549
1591
  return this._root;
1550
1592
  },
1551
1593
  },
@@ -1558,28 +1600,16 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1558
1600
  * @type {BoundingSphere}
1559
1601
  * @readonly
1560
1602
  *
1561
- * @exception {DeveloperError} The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true.
1562
- *
1563
1603
  * @example
1564
- * const tileset = viewer.scene.primitives.add(new Cesium.Cesium3DTileset({
1565
- * url : 'http://localhost:8002/tilesets/Seattle/tileset.json'
1566
- * }));
1604
+ * const tileset = await Cesium.Cesium3DTileset.fromUrl("http://localhost:8002/tilesets/Seattle/tileset.json");
1567
1605
  *
1568
- * tileset.readyPromise.then(function(tileset) {
1569
- * // Set the camera to view the newly added tileset
1570
- * viewer.camera.viewBoundingSphere(tileset.boundingSphere, new Cesium.HeadingPitchRange(0, -0.5, 0));
1571
- * });
1606
+ * viewer.scene.primitives.add(tileset);
1607
+ *
1608
+ * // Set the camera to view the newly added tileset
1609
+ * viewer.camera.viewBoundingSphere(tileset.boundingSphere, new Cesium.HeadingPitchRange(0, -0.5, 0));
1572
1610
  */
1573
1611
  boundingSphere: {
1574
1612
  get: function () {
1575
- //>>includeStart('debug', pragmas.debug);
1576
- if (!this.ready) {
1577
- throw new DeveloperError(
1578
- "The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true."
1579
- );
1580
- }
1581
- //>>includeEnd('debug');
1582
-
1583
1613
  this._root.updateTransform(this._modelMatrix);
1584
1614
  return this._root.boundingSphere;
1585
1615
  },
@@ -1802,8 +1832,6 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1802
1832
  *
1803
1833
  * @memberof Cesium3DTileset.prototype
1804
1834
  *
1805
- * @exception {DeveloperError} The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true.
1806
- *
1807
1835
  * @type {*}
1808
1836
  * @readonly
1809
1837
  *
@@ -1811,14 +1839,6 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1811
1839
  */
1812
1840
  extras: {
1813
1841
  get: function () {
1814
- //>>includeStart('debug', pragmas.debug);
1815
- if (!this.ready) {
1816
- throw new DeveloperError(
1817
- "The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true."
1818
- );
1819
- }
1820
- //>>includeEnd('debug');
1821
-
1822
1842
  return this._extras;
1823
1843
  },
1824
1844
  },
@@ -1974,6 +1994,184 @@ Object.defineProperties(Cesium3DTileset.prototype, {
1974
1994
  },
1975
1995
  });
1976
1996
 
1997
+ /**
1998
+ * Creates a {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification|3D Tiles tileset},
1999
+ * used for streaming massive heterogeneous 3D geospatial datasets, from a Cesium ion asset ID.
2000
+ *
2001
+ * @param {number} assetId The Cesium ion asset id.
2002
+ * @param {Cesium3DTileset.ConstructorOptions} options An object describing initialization options
2003
+ * @returns {Promise<Cesium3DTileset>}
2004
+ *
2005
+ * @exception {DeveloperError} The tileset must be 3D Tiles version 0.0 or 1.0.
2006
+ *
2007
+ * @see Cesium3DTileset#fromUrl
2008
+ *
2009
+ * @example
2010
+ * // Load a Cesium3DTileset with a Cesium ion asset ID of 124624234
2011
+ * try {
2012
+ * const tileset = await Cesium.Cesium3DTileset.fromIonAssetId(124624234);
2013
+ * scene.primitives.add(tileset);
2014
+ * } catch (error) {
2015
+ * console.error(`Error creating tileset: ${error}`);
2016
+ * }
2017
+ */
2018
+ Cesium3DTileset.fromIonAssetId = async function (assetId, options) {
2019
+ //>>includeStart('debug', pragmas.debug);
2020
+ Check.defined("assetId", assetId);
2021
+ //>>includeEnd('debug');
2022
+
2023
+ const resource = await IonResource.fromAssetId(assetId);
2024
+ return Cesium3DTileset.fromUrl(resource, options);
2025
+ };
2026
+
2027
+ /**
2028
+ * Creates a {@link https://github.com/CesiumGS/3d-tiles/tree/main/specification|3D Tiles tileset},
2029
+ * used for streaming massive heterogeneous 3D geospatial datasets.
2030
+ *
2031
+ * @param {Resource|string} url The url to a tileset JSON file.
2032
+ * @param {Cesium3DTileset.ConstructorOptions} [options] An object describing initialization options
2033
+ * @returns {Promise<Cesium3DTileset>}
2034
+ *
2035
+ * @exception {DeveloperError} The tileset must be 3D Tiles version 0.0 or 1.0.
2036
+ *
2037
+ * @see Cesium3DTileset#fromIonAssetId
2038
+ *
2039
+ * @example
2040
+ * try {
2041
+ * const tileset = await Cesium.Cesium3DTileset.fromUrl(
2042
+ * "http://localhost:8002/tilesets/Seattle/tileset.json"
2043
+ * );
2044
+ * scene.primitives.add(tileset);
2045
+ * } catch (error) {
2046
+ * console.error(`Error creating tileset: ${error}`);
2047
+ * }
2048
+ *
2049
+ * @example
2050
+ * // Common setting for the skipLevelOfDetail optimization
2051
+ * const tileset = await Cesium.Cesium3DTileset.fromUrl(
2052
+ * "http://localhost:8002/tilesets/Seattle/tileset.json", {
2053
+ * skipLevelOfDetail: true,
2054
+ * baseScreenSpaceError: 1024,
2055
+ * skipScreenSpaceErrorFactor: 16,
2056
+ * skipLevels: 1,
2057
+ * immediatelyLoadDesiredLevelOfDetail: false,
2058
+ * loadSiblings: false,
2059
+ * cullWithChildrenBounds: true
2060
+ * });
2061
+ * scene.primitives.add(tileset);
2062
+ *
2063
+ * @example
2064
+ * // Common settings for the dynamicScreenSpaceError optimization
2065
+ * const tileset = await Cesium.Cesium3DTileset.fromUrl(
2066
+ * "http://localhost:8002/tilesets/Seattle/tileset.json", {
2067
+ * dynamicScreenSpaceError: true,
2068
+ * dynamicScreenSpaceErrorDensity: 0.00278,
2069
+ * dynamicScreenSpaceErrorFactor: 4.0,
2070
+ * dynamicScreenSpaceErrorHeightFalloff: 0.25
2071
+ * });
2072
+ * scene.primitives.add(tileset);
2073
+ */
2074
+ Cesium3DTileset.fromUrl = async function (url, options) {
2075
+ //>>includeStart('debug', pragmas.debug);
2076
+ Check.defined("url", url);
2077
+ //>>includeEnd('debug');
2078
+
2079
+ options = defaultValue(options, defaultValue.EMPTY_OBJECT);
2080
+
2081
+ const resource = Resource.createIfNeeded(url);
2082
+ let basePath;
2083
+ if (resource.extension === "json") {
2084
+ basePath = resource.getBaseUri(true);
2085
+ } else if (resource.isDataUri) {
2086
+ basePath = "";
2087
+ }
2088
+
2089
+ const tilesetJson = await Cesium3DTileset.loadJson(resource);
2090
+ const metadataExtension = await processMetadataExtension(
2091
+ resource,
2092
+ tilesetJson
2093
+ );
2094
+
2095
+ const tileset = new Cesium3DTileset(options);
2096
+ tileset._resource = resource;
2097
+ tileset._url = resource.url;
2098
+ tileset._basePath = basePath;
2099
+ tileset._metadataExtension = metadataExtension;
2100
+ // Set these before loading the tileset since _geometricError
2101
+ // and _scaledGeometricError get accessed during tile creation
2102
+ tileset._geometricError = tilesetJson.geometricError;
2103
+ tileset._scaledGeometricError = tilesetJson.geometricError;
2104
+
2105
+ const asset = tilesetJson.asset;
2106
+ tileset._asset = asset;
2107
+ tileset._extras = tilesetJson.extras;
2108
+
2109
+ let credits = resource.credits;
2110
+ if (!defined(credits)) {
2111
+ credits = [];
2112
+ }
2113
+
2114
+ const assetExtras = asset.extras;
2115
+ if (
2116
+ defined(assetExtras) &&
2117
+ defined(assetExtras.cesium) &&
2118
+ defined(assetExtras.cesium.credits)
2119
+ ) {
2120
+ const extraCredits = assetExtras.cesium.credits;
2121
+ for (let i = 0; i < extraCredits.length; ++i) {
2122
+ const credit = extraCredits[i];
2123
+ credits.push(new Credit(credit.html, tileset._showCreditsOnScreen));
2124
+ }
2125
+ }
2126
+ tileset._credits = credits;
2127
+
2128
+ // Handle legacy gltfUpAxis option
2129
+ const gltfUpAxis = defined(tilesetJson.asset.gltfUpAxis)
2130
+ ? Axis.fromName(tilesetJson.asset.gltfUpAxis)
2131
+ : Axis.Y;
2132
+ const modelUpAxis = defaultValue(options.modelUpAxis, gltfUpAxis);
2133
+ const modelForwardAxis = defaultValue(options.modelForwardAxis, Axis.X);
2134
+
2135
+ tileset._properties = tilesetJson.properties;
2136
+ tileset._extensionsUsed = tilesetJson.extensionsUsed;
2137
+ tileset._extensions = tilesetJson.extensions;
2138
+ tileset._modelUpAxis = modelUpAxis;
2139
+ tileset._modelForwardAxis = modelForwardAxis;
2140
+
2141
+ tileset._root = tileset.loadTileset(resource, tilesetJson);
2142
+
2143
+ // Save the original, untransformed bounding volume position so we can apply
2144
+ // the tile transform and model matrix at run time
2145
+ const boundingVolume = tileset._root.createBoundingVolume(
2146
+ tilesetJson.root.boundingVolume,
2147
+ Matrix4.IDENTITY
2148
+ );
2149
+ const clippingPlanesOrigin = boundingVolume.boundingSphere.center;
2150
+ // If this origin is above the surface of the earth
2151
+ // we want to apply an ENU orientation as our best guess of orientation.
2152
+ // Otherwise, we assume it gets its position/orientation completely from the
2153
+ // root tile transform and the tileset's model matrix
2154
+ const originCartographic = tileset._ellipsoid.cartesianToCartographic(
2155
+ clippingPlanesOrigin
2156
+ );
2157
+ if (
2158
+ defined(originCartographic) &&
2159
+ originCartographic.height >
2160
+ ApproximateTerrainHeights._defaultMinTerrainHeight
2161
+ ) {
2162
+ tileset._initialClippingPlanesOriginMatrix = Transforms.eastNorthUpToFixedFrame(
2163
+ clippingPlanesOrigin
2164
+ );
2165
+ }
2166
+ tileset._clippingPlanesOriginMatrix = Matrix4.clone(
2167
+ tileset._initialClippingPlanesOriginMatrix
2168
+ );
2169
+
2170
+ tileset._readyPromise = Promise.resolve(tileset);
2171
+ tileset._ready = true;
2172
+ return tileset;
2173
+ };
2174
+
1977
2175
  /**
1978
2176
  * Provides a hook to override the method used to request the tileset json
1979
2177
  * useful when fetching tilesets from remote servers
@@ -2052,8 +2250,7 @@ Cesium3DTileset.prototype.loadTileset = function (
2052
2250
  this._allTilesAdditive && tile.refine === Cesium3DTileRefine.ADD;
2053
2251
  const children = tile._header.children;
2054
2252
  if (defined(children)) {
2055
- const length = children.length;
2056
- for (let i = 0; i < length; ++i) {
2253
+ for (let i = 0; i < children.length; ++i) {
2057
2254
  const childHeader = children[i];
2058
2255
  const childTile = makeTile(this, resource, childHeader, tile);
2059
2256
  tile.children.push(childTile);
@@ -2088,53 +2285,53 @@ function makeTile(tileset, baseResource, tileHeader, parentTile) {
2088
2285
  defined(tileHeader.implicitTiling) ||
2089
2286
  hasExtension(tileHeader, "3DTILES_implicit_tiling");
2090
2287
 
2091
- if (hasImplicitTiling) {
2092
- const metadataSchema = tileset.schema;
2093
-
2094
- const implicitTileset = new ImplicitTileset(
2095
- baseResource,
2096
- tileHeader,
2097
- metadataSchema
2098
- );
2099
- const rootCoordinates = new ImplicitTileCoordinates({
2100
- subdivisionScheme: implicitTileset.subdivisionScheme,
2101
- subtreeLevels: implicitTileset.subtreeLevels,
2102
- level: 0,
2103
- x: 0,
2104
- y: 0,
2105
- // The constructor will only use this for octrees.
2106
- z: 0,
2107
- });
2288
+ if (!hasImplicitTiling) {
2289
+ return new Cesium3DTile(tileset, baseResource, tileHeader, parentTile);
2290
+ }
2108
2291
 
2109
- // Create a placeholder Cesium3DTile that has an ImplicitTileset
2110
- // object and whose content will resolve to an Implicit3DTileContent
2111
- const contentUri = implicitTileset.subtreeUriTemplate.getDerivedResource({
2112
- templateValues: rootCoordinates.getTemplateValues(),
2113
- }).url;
2292
+ const metadataSchema = tileset.schema;
2114
2293
 
2115
- const deepCopy = true;
2116
- const tileJson = clone(tileHeader, deepCopy);
2117
- // Replace contents with the subtree
2118
- tileJson.contents = [
2119
- {
2120
- uri: contentUri,
2121
- },
2122
- ];
2294
+ const implicitTileset = new ImplicitTileset(
2295
+ baseResource,
2296
+ tileHeader,
2297
+ metadataSchema
2298
+ );
2299
+ const rootCoordinates = new ImplicitTileCoordinates({
2300
+ subdivisionScheme: implicitTileset.subdivisionScheme,
2301
+ subtreeLevels: implicitTileset.subtreeLevels,
2302
+ level: 0,
2303
+ x: 0,
2304
+ y: 0,
2305
+ // The constructor will only use this for octrees.
2306
+ z: 0,
2307
+ });
2123
2308
 
2124
- delete tileJson.content;
2309
+ // Create a placeholder Cesium3DTile that has an ImplicitTileset
2310
+ // object and whose content will resolve to an Implicit3DTileContent
2311
+ const contentUri = implicitTileset.subtreeUriTemplate.getDerivedResource({
2312
+ templateValues: rootCoordinates.getTemplateValues(),
2313
+ }).url;
2314
+
2315
+ const deepCopy = true;
2316
+ const tileJson = clone(tileHeader, deepCopy);
2317
+ // Replace contents with the subtree
2318
+ tileJson.contents = [
2319
+ {
2320
+ uri: contentUri,
2321
+ },
2322
+ ];
2125
2323
 
2126
- // The placeholder tile does not have any extensions. If there are any
2127
- // extensions beyond 3DTILES_implicit_tiling, Implicit3DTileContent will
2128
- // copy them to the transcoded tiles.
2129
- delete tileJson.extensions;
2324
+ delete tileJson.content;
2130
2325
 
2131
- const tile = new Cesium3DTile(tileset, baseResource, tileJson, parentTile);
2132
- tile.implicitTileset = implicitTileset;
2133
- tile.implicitCoordinates = rootCoordinates;
2134
- return tile;
2135
- }
2326
+ // The placeholder tile does not have any extensions. If there are any
2327
+ // extensions beyond 3DTILES_implicit_tiling, Implicit3DTileContent will
2328
+ // copy them to the transcoded tiles.
2329
+ delete tileJson.extensions;
2136
2330
 
2137
- return new Cesium3DTile(tileset, baseResource, tileHeader, parentTile);
2331
+ const tile = new Cesium3DTile(tileset, baseResource, tileJson, parentTile);
2332
+ tile.implicitTileset = implicitTileset;
2333
+ tile.implicitCoordinates = rootCoordinates;
2334
+ return tile;
2138
2335
  }
2139
2336
 
2140
2337
  /**
@@ -2143,40 +2340,40 @@ function makeTile(tileset, baseResource, tileHeader, parentTile) {
2143
2340
  *
2144
2341
  * @param {Cesium3DTileset} tileset The tileset
2145
2342
  * @param {object} tilesetJson The tileset JSON
2146
- * @return {Promise<object>} A promise that resolves to tilesetJson for chaining.
2343
+ * @return {Promise<Cesium3DTilesetMetadata>} The loaded Cesium3DTilesetMetadata
2147
2344
  * @private
2148
2345
  */
2149
- function processMetadataExtension(tileset, tilesetJson) {
2346
+ async function processMetadataExtension(resource, tilesetJson) {
2150
2347
  const metadataJson = hasExtension(tilesetJson, "3DTILES_metadata")
2151
2348
  ? tilesetJson.extensions["3DTILES_metadata"]
2152
2349
  : tilesetJson;
2153
2350
 
2154
2351
  let schemaLoader;
2155
2352
  if (defined(metadataJson.schemaUri)) {
2156
- const resource = tileset._resource.getDerivedResource({
2353
+ resource = resource.getDerivedResource({
2157
2354
  url: metadataJson.schemaUri,
2158
2355
  });
2159
- schemaLoader = ResourceCache.loadSchema({
2356
+ schemaLoader = ResourceCache.getSchemaLoader({
2160
2357
  resource: resource,
2161
2358
  });
2162
2359
  } else if (defined(metadataJson.schema)) {
2163
- schemaLoader = ResourceCache.loadSchema({
2360
+ schemaLoader = ResourceCache.getSchemaLoader({
2164
2361
  schema: metadataJson.schema,
2165
2362
  });
2166
2363
  } else {
2167
- return Promise.resolve(tilesetJson);
2364
+ return;
2168
2365
  }
2169
2366
 
2170
- tileset._schemaLoader = schemaLoader;
2367
+ await schemaLoader.load();
2171
2368
 
2172
- return schemaLoader.promise.then(function (schemaLoader) {
2173
- tileset._metadataExtension = new Cesium3DTilesetMetadata({
2174
- schema: schemaLoader.schema,
2175
- metadataJson: metadataJson,
2176
- });
2177
-
2178
- return tilesetJson;
2369
+ const metadataExtension = new Cesium3DTilesetMetadata({
2370
+ schema: schemaLoader.schema,
2371
+ metadataJson: metadataJson,
2179
2372
  });
2373
+
2374
+ ResourceCache.unload(schemaLoader);
2375
+
2376
+ return metadataExtension;
2180
2377
  }
2181
2378
 
2182
2379
  const scratchPositionNormal = new Cartesian3();
@@ -2186,6 +2383,11 @@ const scratchCenter = new Cartesian3();
2186
2383
  const scratchPosition = new Cartesian3();
2187
2384
  const scratchDirection = new Cartesian3();
2188
2385
 
2386
+ /**
2387
+ * @private
2388
+ * @param {Cesium3DTileset} tileset
2389
+ * @param {FrameState} frameState
2390
+ */
2189
2391
  function updateDynamicScreenSpaceError(tileset, frameState) {
2190
2392
  let up;
2191
2393
  let direction;
@@ -2269,36 +2471,48 @@ function updateDynamicScreenSpaceError(tileset, frameState) {
2269
2471
  );
2270
2472
 
2271
2473
  // Increase density as the camera tilts towards the horizon
2272
- const dot = Math.abs(Cartesian3.dot(direction, up));
2273
- let horizonFactor = 1.0 - dot;
2474
+ let horizonFactor = 1.0 - Math.abs(Cartesian3.dot(direction, up));
2274
2475
 
2275
2476
  // Weaken the horizon factor as the camera height increases, implying the camera is further away from the tileset.
2276
2477
  // The goal is to increase density for the "street view", not when viewing the tileset from a distance.
2277
2478
  horizonFactor = horizonFactor * (1.0 - t);
2278
2479
 
2279
- let density = tileset.dynamicScreenSpaceErrorDensity;
2280
- density *= horizonFactor;
2281
-
2282
- tileset._dynamicScreenSpaceErrorComputedDensity = density;
2480
+ tileset._dynamicScreenSpaceErrorComputedDensity =
2481
+ tileset.dynamicScreenSpaceErrorDensity * horizonFactor;
2283
2482
  }
2284
2483
 
2285
- ///////////////////////////////////////////////////////////////////////////
2286
-
2484
+ /**
2485
+ * @private
2486
+ * @param {Cesium3DTileset} tileset
2487
+ * @param {Cesium3DTile} tile
2488
+ */
2287
2489
  function requestContent(tileset, tile) {
2288
2490
  if (tile.hasEmptyContent) {
2289
2491
  return;
2290
2492
  }
2291
2493
 
2292
- const statistics = tileset._statistics;
2293
- const expired = tile.contentExpired;
2294
- const attemptedRequests = tile.requestContent();
2494
+ const { statistics } = tileset;
2495
+ const contentExpired = tile.contentExpired;
2295
2496
 
2296
- if (attemptedRequests > 0) {
2297
- statistics.numberOfAttemptedRequests += attemptedRequests;
2497
+ const promise = tile.requestContent();
2498
+ if (!defined(promise)) {
2298
2499
  return;
2299
2500
  }
2300
2501
 
2301
- if (expired) {
2502
+ promise
2503
+ .then((content) => {
2504
+ if (!defined(content) || tile.isDestroyed() || tileset.isDestroyed()) {
2505
+ return;
2506
+ }
2507
+
2508
+ tileset._processingQueue.push(tile);
2509
+ ++statistics.numberOfTilesProcessing;
2510
+ })
2511
+ .catch((error) => {
2512
+ handleTileFailure(error, tileset, tile);
2513
+ });
2514
+
2515
+ if (contentExpired) {
2302
2516
  if (tile.hasTilesetContent || tile.hasImplicitContent) {
2303
2517
  destroySubtree(tileset, tile);
2304
2518
  } else {
@@ -2308,15 +2522,6 @@ function requestContent(tileset, tile) {
2308
2522
  }
2309
2523
 
2310
2524
  tileset._requestedTilesInFlight.push(tile);
2311
-
2312
- tile.contentReadyToProcessPromise
2313
- .then(addToProcessingQueue(tileset, tile))
2314
- .catch(function (e) {
2315
- // Any error will propagate through contentReadyPromise and will be handled below
2316
- });
2317
- tile.contentReadyPromise
2318
- .then(handleTileSuccess(tileset, tile))
2319
- .catch(handleTileFailure(tileset, tile));
2320
2525
  }
2321
2526
 
2322
2527
  function sortRequestByPriority(a, b) {
@@ -2326,9 +2531,10 @@ function sortRequestByPriority(a, b) {
2326
2531
  /**
2327
2532
  * Perform any pass invariant tasks here. Called after the render pass.
2328
2533
  * @private
2534
+ * @param {FrameState} frameState
2329
2535
  */
2330
2536
  Cesium3DTileset.prototype.postPassesUpdate = function (frameState) {
2331
- if (!this.ready) {
2537
+ if (!defined(this._root)) {
2332
2538
  return;
2333
2539
  }
2334
2540
 
@@ -2348,9 +2554,10 @@ Cesium3DTileset.prototype.postPassesUpdate = function (frameState) {
2348
2554
  /**
2349
2555
  * Perform any pass invariant tasks here. Called before any passes are executed.
2350
2556
  * @private
2557
+ * @param {FrameState} frameState
2351
2558
  */
2352
2559
  Cesium3DTileset.prototype.prePassesUpdate = function (frameState) {
2353
- if (!this.ready) {
2560
+ if (!defined(this._root)) {
2354
2561
  return;
2355
2562
  }
2356
2563
 
@@ -2371,12 +2578,6 @@ Cesium3DTileset.prototype.prePassesUpdate = function (frameState) {
2371
2578
  0.0
2372
2579
  );
2373
2580
 
2374
- this._skipLevelOfDetail =
2375
- this.skipLevelOfDetail &&
2376
- !defined(this._classificationType) &&
2377
- !this._disableSkipLevelOfDetail &&
2378
- !this._allTilesAdditive;
2379
-
2380
2581
  if (this.dynamicScreenSpaceError) {
2381
2582
  updateDynamicScreenSpaceError(this, frameState);
2382
2583
  }
@@ -2386,11 +2587,15 @@ Cesium3DTileset.prototype.prePassesUpdate = function (frameState) {
2386
2587
  }
2387
2588
  };
2388
2589
 
2590
+ /**
2591
+ * @private
2592
+ * @param {Cesium3DTileset} tileset
2593
+ * @param {FrameState} frameState
2594
+ */
2389
2595
  function cancelOutOfViewRequests(tileset, frameState) {
2390
2596
  const requestedTilesInFlight = tileset._requestedTilesInFlight;
2391
2597
  let removeCount = 0;
2392
- const length = requestedTilesInFlight.length;
2393
- for (let i = 0; i < length; ++i) {
2598
+ for (let i = 0; i < requestedTilesInFlight.length; ++i) {
2394
2599
  const tile = requestedTilesInFlight[i];
2395
2600
 
2396
2601
  // NOTE: This is framerate dependant so make sure the threshold check is small
@@ -2414,78 +2619,62 @@ function cancelOutOfViewRequests(tileset, frameState) {
2414
2619
  requestedTilesInFlight.length -= removeCount;
2415
2620
  }
2416
2621
 
2417
- function requestTiles(tileset, isAsync) {
2418
- // Sort requests by priority before making any requests.
2419
- // This makes it less likely that requests will be cancelled after being issued.
2622
+ /**
2623
+ * Sort requests by priority before making any requests.
2624
+ * This makes it less likely that requests will be cancelled after being issued.
2625
+ * @private
2626
+ * @param {Cesium3DTileset} tileset
2627
+ */
2628
+ function requestTiles(tileset) {
2420
2629
  const requestedTiles = tileset._requestedTiles;
2421
- const length = requestedTiles.length;
2422
2630
  requestedTiles.sort(sortRequestByPriority);
2423
- for (let i = 0; i < length; ++i) {
2631
+ for (let i = 0; i < requestedTiles.length; ++i) {
2424
2632
  requestContent(tileset, requestedTiles[i]);
2425
2633
  }
2426
2634
  }
2427
2635
 
2428
- function addToProcessingQueue(tileset, tile) {
2429
- return function () {
2430
- tileset._processingQueue.push(tile);
2431
-
2432
- ++tileset._statistics.numberOfTilesProcessing;
2433
- };
2434
- }
2435
-
2436
- function handleTileFailure(tileset, tile) {
2437
- return function (error) {
2438
- if (tile._contentState !== Cesium3DTileContentState.FAILED) {
2439
- // If the tile has not failed, the request has been rejected this frame, but will be retried. Do not bubble up the error.
2440
- return;
2441
- }
2442
-
2443
- const url = tile._contentResource.url;
2444
- const message = defined(error.message) ? error.message : error.toString();
2445
- if (tileset.tileFailed.numberOfListeners > 0) {
2446
- tileset.tileFailed.raiseEvent({
2447
- url: url,
2448
- message: message,
2449
- });
2450
- } else {
2451
- console.log(`A 3D tile failed to load: ${url}`);
2452
- console.log(`Error: ${message}`);
2453
- }
2454
- };
2455
- }
2456
-
2457
- function handleTileSuccess(tileset, tile) {
2458
- return function (content) {
2459
- --tileset._statistics.numberOfTilesProcessing;
2460
-
2461
- if (!defined(content)) {
2462
- // A request was cancelled. Do not update successful statistics. The request will be retried.
2463
- return;
2464
- }
2465
-
2466
- if (!tile.hasTilesetContent && !tile.hasImplicitContent) {
2467
- // RESEARCH_IDEA: ability to unload tiles (without content) for an
2468
- // external tileset when all the tiles are unloaded.
2469
- tileset._statistics.incrementLoadCounts(tile.content);
2470
- ++tileset._statistics.numberOfTilesWithContentReady;
2471
- ++tileset._statistics.numberOfLoadedTilesTotal;
2636
+ /**
2637
+ * @private
2638
+ * @param {Error} error
2639
+ * @param {Cesium3DTileset} tileset
2640
+ * @param {Cesium3DTile} tile
2641
+ */
2642
+ function handleTileFailure(error, tileset, tile) {
2643
+ if (tileset.isDestroyed()) {
2644
+ return;
2645
+ }
2472
2646
 
2473
- // Add to the tile cache. Previously expired tiles are already in the cache and won't get re-added.
2474
- tileset._cache.add(tile);
2475
- }
2647
+ let url;
2648
+ if (!tile.isDestroyed()) {
2649
+ url = tile._contentResource.url;
2650
+ }
2476
2651
 
2477
- tileset.tileLoad.raiseEvent(tile);
2478
- };
2652
+ const message = defined(error.message) ? error.message : error.toString();
2653
+ if (tileset.tileFailed.numberOfListeners > 0) {
2654
+ tileset.tileFailed.raiseEvent({
2655
+ url: url,
2656
+ message: message,
2657
+ });
2658
+ } else {
2659
+ console.log(`A 3D tile failed to load: ${url}`);
2660
+ console.log(`Error: ${message}`);
2661
+ }
2479
2662
  }
2480
2663
 
2664
+ /**
2665
+ * @private
2666
+ * @param {Cesium3DTileset} tileset
2667
+ */
2481
2668
  function filterProcessingQueue(tileset) {
2482
2669
  const tiles = tileset._processingQueue;
2483
- const length = tiles.length;
2484
2670
 
2485
2671
  let removeCount = 0;
2486
- for (let i = 0; i < length; ++i) {
2672
+ for (let i = 0; i < tiles.length; ++i) {
2487
2673
  const tile = tiles[i];
2488
- if (tile._contentState !== Cesium3DTileContentState.PROCESSING) {
2674
+ if (
2675
+ tile.isDestroyed() ||
2676
+ tile._contentState !== Cesium3DTileContentState.PROCESSING
2677
+ ) {
2489
2678
  ++removeCount;
2490
2679
  continue;
2491
2680
  }
@@ -2496,24 +2685,44 @@ function filterProcessingQueue(tileset) {
2496
2685
  tiles.length -= removeCount;
2497
2686
  }
2498
2687
 
2688
+ /**
2689
+ * Process tiles in the PROCESSING state so they will eventually move to the READY state.
2690
+ * @private
2691
+ * @param {Cesium3DTileset} tileset
2692
+ * @param {Cesium3DTile} tile
2693
+ */
2499
2694
  function processTiles(tileset, frameState) {
2500
2695
  filterProcessingQueue(tileset);
2501
2696
  const tiles = tileset._processingQueue;
2502
- const length = tiles.length;
2503
- // Process tiles in the PROCESSING state so they will eventually move to the READY state.
2504
- for (let i = 0; i < length; ++i) {
2505
- tiles[i].process(tileset, frameState);
2697
+ const statistics = tileset._statistics;
2698
+ let tile;
2699
+ for (let i = 0; i < tiles.length; ++i) {
2700
+ tile = tiles[i];
2701
+ try {
2702
+ tile.process(tileset, frameState);
2703
+
2704
+ if (tile.contentReady) {
2705
+ --statistics.numberOfTilesProcessing;
2706
+ tileset.tileLoad.raiseEvent(tile);
2707
+ }
2708
+ } catch (error) {
2709
+ --statistics.numberOfTilesProcessing;
2710
+ handleTileFailure(error, tileset, tile);
2711
+ }
2506
2712
  }
2507
2713
  }
2508
2714
 
2509
- ///////////////////////////////////////////////////////////////////////////
2510
-
2511
2715
  const scratchCartesian = new Cartesian3();
2512
2716
 
2513
2717
  const stringOptions = {
2514
2718
  maximumFractionDigits: 3,
2515
2719
  };
2516
2720
 
2721
+ /**
2722
+ * @private
2723
+ * @param {number} memorySizeInBytes
2724
+ * @returns {string}
2725
+ */
2517
2726
  function formatMemoryString(memorySizeInBytes) {
2518
2727
  const memoryInMegabytes = memorySizeInBytes / 1048576;
2519
2728
  if (memoryInMegabytes < 1.0) {
@@ -2522,28 +2731,38 @@ function formatMemoryString(memorySizeInBytes) {
2522
2731
  return Math.round(memoryInMegabytes).toLocaleString();
2523
2732
  }
2524
2733
 
2734
+ /**
2735
+ * @private
2736
+ * @param {Cesium3DTile} tile
2737
+ * @returns {Cartesian3}
2738
+ */
2525
2739
  function computeTileLabelPosition(tile) {
2526
- const boundingVolume = tile.boundingVolume.boundingVolume;
2527
- const halfAxes = boundingVolume.halfAxes;
2528
- const radius = boundingVolume.radius;
2740
+ const { halfAxes, radius, center } = tile.boundingVolume.boundingVolume;
2529
2741
 
2530
- let position = Cartesian3.clone(boundingVolume.center, scratchCartesian);
2742
+ let position = Cartesian3.clone(center, scratchCartesian);
2531
2743
  if (defined(halfAxes)) {
2532
2744
  position.x += 0.75 * (halfAxes[0] + halfAxes[3] + halfAxes[6]);
2533
2745
  position.y += 0.75 * (halfAxes[1] + halfAxes[4] + halfAxes[7]);
2534
2746
  position.z += 0.75 * (halfAxes[2] + halfAxes[5] + halfAxes[8]);
2535
2747
  } else if (defined(radius)) {
2536
- let normal = Cartesian3.normalize(boundingVolume.center, scratchCartesian);
2748
+ let normal = Cartesian3.normalize(center, scratchCartesian);
2537
2749
  normal = Cartesian3.multiplyByScalar(
2538
2750
  normal,
2539
2751
  0.75 * radius,
2540
2752
  scratchCartesian
2541
2753
  );
2542
- position = Cartesian3.add(normal, boundingVolume.center, scratchCartesian);
2754
+ position = Cartesian3.add(normal, center, scratchCartesian);
2543
2755
  }
2544
2756
  return position;
2545
2757
  }
2546
2758
 
2759
+ /**
2760
+ * @private
2761
+ * @param {Cesium3DTile} tile
2762
+ * @param {Cesium3DTileset} tileset
2763
+ * @param {Cartesian3} position
2764
+ * @returns {Label}
2765
+ */
2547
2766
  function addTileDebugLabel(tile, tileset, position) {
2548
2767
  let labelString = "";
2549
2768
  let attributes = 0;
@@ -2609,9 +2828,12 @@ function addTileDebugLabel(tile, tileset, position) {
2609
2828
  return tileset._tileDebugLabels.add(newLabel);
2610
2829
  }
2611
2830
 
2831
+ /**
2832
+ * @private
2833
+ * @param {Cesium3DTileset} tileset
2834
+ * @param {FrameState} frameState
2835
+ */
2612
2836
  function updateTileDebugLabels(tileset, frameState) {
2613
- let i;
2614
- let tile;
2615
2837
  const selectedTiles = tileset._selectedTiles;
2616
2838
  const selectedLength = selectedTiles.length;
2617
2839
  const emptyTiles = tileset._emptyTiles;
@@ -2631,12 +2853,12 @@ function updateTileDebugLabels(tileset, frameState) {
2631
2853
  label.pixelOffset = new Cartesian2(15, -15); // Offset to avoid picking the label.
2632
2854
  }
2633
2855
  } else {
2634
- for (i = 0; i < selectedLength; ++i) {
2635
- tile = selectedTiles[i];
2856
+ for (let i = 0; i < selectedLength; ++i) {
2857
+ const tile = selectedTiles[i];
2636
2858
  addTileDebugLabel(tile, tileset, computeTileLabelPosition(tile));
2637
2859
  }
2638
- for (i = 0; i < emptyLength; ++i) {
2639
- tile = emptyTiles[i];
2860
+ for (let i = 0; i < emptyLength; ++i) {
2861
+ const tile = emptyTiles[i];
2640
2862
  if (tile.hasTilesetContent || tile.hasImplicitContent) {
2641
2863
  addTileDebugLabel(tile, tileset, computeTileLabelPosition(tile));
2642
2864
  }
@@ -2645,27 +2867,25 @@ function updateTileDebugLabels(tileset, frameState) {
2645
2867
  tileset._tileDebugLabels.update(frameState);
2646
2868
  }
2647
2869
 
2870
+ /**
2871
+ * @private
2872
+ * @param {Cesium3DTileset} tileset
2873
+ * @param {FrameState} frameState
2874
+ * @param {object} passOptions
2875
+ */
2648
2876
  function updateTiles(tileset, frameState, passOptions) {
2649
2877
  tileset._styleEngine.applyStyle(tileset);
2650
2878
  tileset._styleApplied = true;
2651
2879
 
2652
- const isRender = passOptions.isRender;
2653
- const statistics = tileset._statistics;
2654
- const commandList = frameState.commandList;
2880
+ const { commandList, context } = frameState;
2655
2881
  const numberOfInitialCommands = commandList.length;
2656
2882
  const selectedTiles = tileset._selectedTiles;
2657
- const selectedLength = selectedTiles.length;
2658
- const emptyTiles = tileset._emptyTiles;
2659
- const emptyLength = emptyTiles.length;
2660
- const tileVisible = tileset.tileVisible;
2661
- let i;
2662
- let tile;
2663
2883
 
2664
2884
  const bivariateVisibilityTest =
2665
- tileset._skipLevelOfDetail &&
2885
+ tileset.isSkippingLevelOfDetail &&
2666
2886
  tileset._hasMixedContent &&
2667
- frameState.context.stencilBuffer &&
2668
- selectedLength > 0;
2887
+ context.stencilBuffer &&
2888
+ selectedTiles.length > 0;
2669
2889
 
2670
2890
  tileset._backfaceCommands.length = 0;
2671
2891
 
@@ -2682,9 +2902,12 @@ function updateTiles(tileset, frameState, passOptions) {
2682
2902
  commandList.push(tileset._stencilClearCommand);
2683
2903
  }
2684
2904
 
2905
+ const { statistics, tileVisible } = tileset;
2906
+ const isRender = passOptions.isRender;
2685
2907
  const lengthBeforeUpdate = commandList.length;
2686
- for (i = 0; i < selectedLength; ++i) {
2687
- tile = selectedTiles[i];
2908
+
2909
+ for (let i = 0; i < selectedTiles.length; ++i) {
2910
+ const tile = selectedTiles[i];
2688
2911
  // Raise the tileVisible event before update in case the tileVisible event
2689
2912
  // handler makes changes that update needs to apply to WebGL resources
2690
2913
  if (isRender) {
@@ -2694,8 +2917,9 @@ function updateTiles(tileset, frameState, passOptions) {
2694
2917
  statistics.incrementSelectionCounts(tile.content);
2695
2918
  ++statistics.selected;
2696
2919
  }
2697
- for (i = 0; i < emptyLength; ++i) {
2698
- tile = emptyTiles[i];
2920
+ const emptyTiles = tileset._emptyTiles;
2921
+ for (let i = 0; i < emptyTiles.length; ++i) {
2922
+ const tile = emptyTiles[i];
2699
2923
  tile.update(tileset, frameState, passOptions);
2700
2924
  }
2701
2925
 
@@ -2734,13 +2958,13 @@ function updateTiles(tileset, frameState, passOptions) {
2734
2958
  commandList.length += backfaceCommandsLength;
2735
2959
 
2736
2960
  // copy commands to the back of the commandList
2737
- for (i = addedCommandsLength - 1; i >= 0; --i) {
2961
+ for (let i = addedCommandsLength - 1; i >= 0; --i) {
2738
2962
  commandList[lengthBeforeUpdate + backfaceCommandsLength + i] =
2739
2963
  commandList[lengthBeforeUpdate + i];
2740
2964
  }
2741
2965
 
2742
2966
  // move backface commands to the front of the commandList
2743
- for (i = 0; i < backfaceCommandsLength; ++i) {
2967
+ for (let i = 0; i < backfaceCommandsLength; ++i) {
2744
2968
  commandList[lengthBeforeUpdate + i] = backfaceCommands[i];
2745
2969
  }
2746
2970
  }
@@ -2749,9 +2973,12 @@ function updateTiles(tileset, frameState, passOptions) {
2749
2973
  addedCommandsLength = commandList.length - numberOfInitialCommands;
2750
2974
  statistics.numberOfCommands = addedCommandsLength;
2751
2975
 
2976
+ if (!isRender) {
2977
+ return;
2978
+ }
2979
+
2752
2980
  // Only run EDL if simple attenuation is on
2753
2981
  if (
2754
- isRender &&
2755
2982
  tileset.pointCloudShading.attenuation &&
2756
2983
  tileset.pointCloudShading.eyeDomeLighting &&
2757
2984
  addedCommandsLength > 0
@@ -2764,26 +2991,29 @@ function updateTiles(tileset, frameState, passOptions) {
2764
2991
  );
2765
2992
  }
2766
2993
 
2767
- if (isRender) {
2768
- if (
2769
- tileset.debugShowGeometricError ||
2770
- tileset.debugShowRenderingStatistics ||
2771
- tileset.debugShowMemoryUsage ||
2772
- tileset.debugShowUrl
2773
- ) {
2774
- if (!defined(tileset._tileDebugLabels)) {
2775
- tileset._tileDebugLabels = new LabelCollection();
2776
- }
2777
- updateTileDebugLabels(tileset, frameState);
2778
- } else {
2779
- tileset._tileDebugLabels =
2780
- tileset._tileDebugLabels && tileset._tileDebugLabels.destroy();
2994
+ if (
2995
+ tileset.debugShowGeometricError ||
2996
+ tileset.debugShowRenderingStatistics ||
2997
+ tileset.debugShowMemoryUsage ||
2998
+ tileset.debugShowUrl
2999
+ ) {
3000
+ if (!defined(tileset._tileDebugLabels)) {
3001
+ tileset._tileDebugLabels = new LabelCollection();
2781
3002
  }
3003
+ updateTileDebugLabels(tileset, frameState);
3004
+ } else {
3005
+ tileset._tileDebugLabels =
3006
+ tileset._tileDebugLabels && tileset._tileDebugLabels.destroy();
2782
3007
  }
2783
3008
  }
2784
3009
 
2785
3010
  const scratchStack = [];
2786
3011
 
3012
+ /**
3013
+ * @private
3014
+ * @param {Cesium3DTileset} tileset
3015
+ * @param {Cesium3DTile} tile
3016
+ */
2787
3017
  function destroySubtree(tileset, tile) {
2788
3018
  const root = tile;
2789
3019
  const stack = scratchStack;
@@ -2791,8 +3021,7 @@ function destroySubtree(tileset, tile) {
2791
3021
  while (stack.length > 0) {
2792
3022
  tile = stack.pop();
2793
3023
  const children = tile.children;
2794
- const length = children.length;
2795
- for (let i = 0; i < length; ++i) {
3024
+ for (let i = 0; i < children.length; ++i) {
2796
3025
  stack.push(children[i]);
2797
3026
  }
2798
3027
  if (tile !== root) {
@@ -2803,6 +3032,11 @@ function destroySubtree(tileset, tile) {
2803
3032
  root.children = [];
2804
3033
  }
2805
3034
 
3035
+ /**
3036
+ * @private
3037
+ * @param {Cesium3DTileset} tileset
3038
+ * @param {Cesium3DTile} tile
3039
+ */
2806
3040
  function unloadTile(tileset, tile) {
2807
3041
  tileset.tileUnload.raiseEvent(tile);
2808
3042
  tileset._statistics.decrementLoadCounts(tile.content);
@@ -2810,6 +3044,11 @@ function unloadTile(tileset, tile) {
2810
3044
  tile.unloadContent();
2811
3045
  }
2812
3046
 
3047
+ /**
3048
+ * @private
3049
+ * @param {Cesium3DTileset} tileset
3050
+ * @param {Cesium3DTile} tile
3051
+ */
2813
3052
  function destroyTile(tileset, tile) {
2814
3053
  tileset._cache.unloadTile(tileset, tile, unloadTile);
2815
3054
  tile.destroy();
@@ -2828,8 +3067,11 @@ Cesium3DTileset.prototype.trimLoadedTiles = function () {
2828
3067
  this._cache.trim();
2829
3068
  };
2830
3069
 
2831
- ///////////////////////////////////////////////////////////////////////////
2832
-
3070
+ /**
3071
+ * @private
3072
+ * @param {Cesium3DTileset} tileset
3073
+ * @param {FrameState} frameState
3074
+ */
2833
3075
  function raiseLoadProgressEvent(tileset, frameState) {
2834
3076
  const statistics = tileset._statistics;
2835
3077
  const statisticsLast = tileset._statisticsLast;
@@ -2863,7 +3105,7 @@ function raiseLoadProgressEvent(tileset, frameState) {
2863
3105
 
2864
3106
  // Events are raised (added to the afterRender queue) here since promises
2865
3107
  // may resolve outside of the update loop that then raise events, e.g.,
2866
- // model's readyPromise.
3108
+ // model's readyEvent
2867
3109
  if (progressChanged && tileset._tilesLoaded) {
2868
3110
  frameState.afterRender.push(function () {
2869
3111
  tileset.allTilesLoaded.raiseEvent();
@@ -2879,6 +3121,10 @@ function raiseLoadProgressEvent(tileset, frameState) {
2879
3121
  }
2880
3122
  }
2881
3123
 
3124
+ /**
3125
+ * @private
3126
+ * @param {Cesium3DTileset} tileset
3127
+ */
2882
3128
  function resetMinimumMaximum(tileset) {
2883
3129
  tileset._heatmap.resetMinimumMaximum();
2884
3130
  tileset._minimumPriority.depth = Number.MAX_VALUE;
@@ -2891,41 +3137,52 @@ function resetMinimumMaximum(tileset) {
2891
3137
  tileset._maximumPriority.reverseScreenSpaceError = -Number.MAX_VALUE;
2892
3138
  }
2893
3139
 
3140
+ /**
3141
+ * @private
3142
+ * @param {Cesium3DTileset} tileset
3143
+ * @param {FrameState} frameState
3144
+ */
2894
3145
  function detectModelMatrixChanged(tileset, frameState) {
2895
3146
  if (
2896
- frameState.frameNumber !== tileset._updatedModelMatrixFrame ||
2897
- !defined(tileset._previousModelMatrix)
3147
+ frameState.frameNumber === tileset._updatedModelMatrixFrame &&
3148
+ defined(tileset._previousModelMatrix)
2898
3149
  ) {
2899
- tileset._updatedModelMatrixFrame = frameState.frameNumber;
2900
- tileset._modelMatrixChanged = !Matrix4.equals(
3150
+ return;
3151
+ }
3152
+
3153
+ tileset._updatedModelMatrixFrame = frameState.frameNumber;
3154
+ tileset._modelMatrixChanged = !Matrix4.equals(
3155
+ tileset.modelMatrix,
3156
+ tileset._previousModelMatrix
3157
+ );
3158
+ if (tileset._modelMatrixChanged) {
3159
+ tileset._previousModelMatrix = Matrix4.clone(
2901
3160
  tileset.modelMatrix,
2902
3161
  tileset._previousModelMatrix
2903
3162
  );
2904
- if (tileset._modelMatrixChanged) {
2905
- tileset._previousModelMatrix = Matrix4.clone(
2906
- tileset.modelMatrix,
2907
- tileset._previousModelMatrix
2908
- );
2909
- }
2910
3163
  }
2911
3164
  }
2912
3165
 
2913
- ///////////////////////////////////////////////////////////////////////////
2914
-
3166
+ /**
3167
+ * @private
3168
+ * @param {Cesium3DTileset} tileset
3169
+ * @param {FrameState} frameState
3170
+ * @param {Cesium3DTilesetStatistics} passStatistics
3171
+ * @param {object} passOptions
3172
+ * @returns {boolean}
3173
+ */
2915
3174
  function update(tileset, frameState, passStatistics, passOptions) {
2916
3175
  if (frameState.mode === SceneMode.MORPHING) {
2917
3176
  return false;
2918
3177
  }
2919
3178
 
2920
- if (!tileset.ready) {
3179
+ if (!defined(tileset._root)) {
2921
3180
  return false;
2922
3181
  }
2923
3182
 
2924
3183
  const statistics = tileset._statistics;
2925
3184
  statistics.clear();
2926
3185
 
2927
- const isRender = passOptions.isRender;
2928
-
2929
3186
  // Resets the visibility check for each pass
2930
3187
  ++tileset._updatedVisibilityFrame;
2931
3188
 
@@ -2936,7 +3193,9 @@ function update(tileset, frameState, passStatistics, passOptions) {
2936
3193
  tileset._cullRequestsWhileMoving =
2937
3194
  tileset.cullRequestsWhileMoving && !tileset._modelMatrixChanged;
2938
3195
 
2939
- const ready = passOptions.traversal.selectTiles(tileset, frameState);
3196
+ const ready = tileset
3197
+ .getTraversal(passOptions)
3198
+ .selectTiles(tileset, frameState);
2940
3199
 
2941
3200
  if (passOptions.requestTiles) {
2942
3201
  requestTiles(tileset);
@@ -2947,14 +3206,13 @@ function update(tileset, frameState, passStatistics, passOptions) {
2947
3206
  // Update pass statistics
2948
3207
  Cesium3DTilesetStatistics.clone(statistics, passStatistics);
2949
3208
 
2950
- if (isRender) {
3209
+ if (passOptions.isRender) {
2951
3210
  const credits = tileset._credits;
2952
3211
  if (defined(credits) && statistics.selected !== 0) {
2953
- const length = credits.length;
2954
- for (let i = 0; i < length; ++i) {
3212
+ for (let i = 0; i < credits.length; ++i) {
2955
3213
  const credit = credits[i];
2956
3214
  credit.showOnScreen = tileset._showCreditsOnScreen;
2957
- frameState.creditDisplay.addCredit(credit);
3215
+ frameState.creditDisplay.addCreditToNextFrame(credit);
2958
3216
  }
2959
3217
  }
2960
3218
  }
@@ -2964,6 +3222,25 @@ function update(tileset, frameState, passStatistics, passOptions) {
2964
3222
 
2965
3223
  /**
2966
3224
  * @private
3225
+ * @param {object} passOptions
3226
+ * @returns {Cesium3DTilesetTraversal}
3227
+ */
3228
+ Cesium3DTileset.prototype.getTraversal = function (passOptions) {
3229
+ const { pass } = passOptions;
3230
+ if (
3231
+ pass === Cesium3DTilePass.MOST_DETAILED_PRELOAD ||
3232
+ pass === Cesium3DTilePass.MOST_DETAILED_PICK
3233
+ ) {
3234
+ return Cesium3DTilesetMostDetailedTraversal;
3235
+ }
3236
+ return this.isSkippingLevelOfDetail
3237
+ ? Cesium3DTilesetSkipTraversal
3238
+ : Cesium3DTilesetBaseTraversal;
3239
+ };
3240
+
3241
+ /**
3242
+ * @private
3243
+ * @param {FrameState} frameState
2967
3244
  */
2968
3245
  Cesium3DTileset.prototype.update = function (frameState) {
2969
3246
  this.updateForPass(frameState, frameState.tilesetPassState);
@@ -2971,6 +3248,8 @@ Cesium3DTileset.prototype.update = function (frameState) {
2971
3248
 
2972
3249
  /**
2973
3250
  * @private
3251
+ * @param {FrameState} frameState
3252
+ * @param {object} tilesetPassState
2974
3253
  */
2975
3254
  Cesium3DTileset.prototype.updateForPass = function (
2976
3255
  frameState,
@@ -3086,10 +3365,6 @@ Cesium3DTileset.prototype.destroy = function () {
3086
3365
  this._tileDebugLabels && this._tileDebugLabels.destroy();
3087
3366
  this._clippingPlanes = this._clippingPlanes && this._clippingPlanes.destroy();
3088
3367
 
3089
- if (defined(this._schemaLoader)) {
3090
- ResourceCache.unload(this._schemaLoader);
3091
- }
3092
-
3093
3368
  // Traverse the tree and destroy all tiles
3094
3369
  if (defined(this._root)) {
3095
3370
  const stack = scratchStack;
@@ -3100,8 +3375,7 @@ Cesium3DTileset.prototype.destroy = function () {
3100
3375
  tile.destroy();
3101
3376
 
3102
3377
  const children = tile.children;
3103
- const length = children.length;
3104
- for (let i = 0; i < length; ++i) {
3378
+ for (let i = 0; i < children.length; ++i) {
3105
3379
  stack.push(children[i]);
3106
3380
  }
3107
3381
  }