@cesium/engine 22.2.0 → 23.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/Build/Workers/{chunk-YFEZPDAY.js → chunk-2GL2EUEE.js} +11 -11
  2. package/Build/Workers/{chunk-A3NUMZBG.js → chunk-2WI4HGJU.js} +6 -6
  3. package/Build/Workers/{chunk-3JB2X2PR.js → chunk-36LBFITA.js} +665 -366
  4. package/Build/Workers/{chunk-VSZ5DB2W.js → chunk-3B65YFXC.js} +1 -1
  5. package/Build/Workers/{chunk-PSHZAHFE.js → chunk-4LGFX2P5.js} +11 -11
  6. package/Build/Workers/{chunk-AMWXJ5A7.js → chunk-4UNQX2MP.js} +2 -2
  7. package/Build/Workers/{chunk-LDSQMLRC.js → chunk-52K3GJKG.js} +3 -3
  8. package/Build/Workers/{chunk-MSTAVM2N.js → chunk-56OHFSLH.js} +10 -10
  9. package/Build/Workers/{chunk-IWOSJVFQ.js → chunk-5A7YSAXT.js} +14 -14
  10. package/Build/Workers/{chunk-PMDPP22G.js → chunk-5JP5FG7U.js} +7 -7
  11. package/Build/Workers/{chunk-DIJ7IG5D.js → chunk-5R7SBUTW.js} +10 -10
  12. package/Build/Workers/chunk-5VKZVPO5.js +1829 -0
  13. package/Build/Workers/{chunk-L2FSBEW2.js → chunk-6FVFM2KB.js} +5 -5
  14. package/Build/Workers/{chunk-G6WQA27G.js → chunk-6SLGTBB2.js} +5 -5
  15. package/Build/Workers/{chunk-3HUEBDFC.js → chunk-7KRN6JPQ.js} +14 -14
  16. package/Build/Workers/{chunk-GMHDOQPH.js → chunk-AA33B6PU.js} +4 -4
  17. package/Build/Workers/{chunk-7CDQUIP5.js → chunk-AP6XWET5.js} +8 -8
  18. package/Build/Workers/{chunk-IVN5HSOI.js → chunk-APDKMX7W.js} +6 -6
  19. package/Build/Workers/{chunk-72LZ3FN6.js → chunk-ARCFIOKA.js} +12 -12
  20. package/Build/Workers/{chunk-UBJYWGMV.js → chunk-BNBD2YZK.js} +16 -16
  21. package/Build/Workers/{chunk-VGH2CSC7.js → chunk-DT5SJBKA.js} +29 -15
  22. package/Build/Workers/{chunk-ED4UXMYY.js → chunk-ESD4IEOU.js} +5 -5
  23. package/Build/Workers/{chunk-JFN2DQHY.js → chunk-FSDVXW7M.js} +5 -5
  24. package/Build/Workers/{chunk-JERDRSEI.js → chunk-G3YT7M7A.js} +1 -1
  25. package/Build/Workers/{chunk-NY3CWLIZ.js → chunk-GN5NEUDT.js} +8 -8
  26. package/Build/Workers/{chunk-O3GWUTWM.js → chunk-HYLEKKO5.js} +1 -1
  27. package/Build/Workers/{chunk-64PJ4MTB.js → chunk-HYTFXWMY.js} +7 -7
  28. package/Build/Workers/{chunk-FPRM6PCE.js → chunk-IFA7VHHP.js} +560 -306
  29. package/Build/Workers/{chunk-FM5XPC2E.js → chunk-IYVDOB5V.js} +4 -4
  30. package/Build/Workers/{chunk-P7ISUYLW.js → chunk-JUGY5AZN.js} +4 -4
  31. package/Build/Workers/{chunk-JONWM4IO.js → chunk-KPYU6YZG.js} +1 -1
  32. package/Build/Workers/{chunk-JUOSYFXT.js → chunk-L7RDJ4V7.js} +1 -1
  33. package/Build/Workers/{chunk-MWGB6DLR.js → chunk-LDQWNMEC.js} +1 -1
  34. package/Build/Workers/{chunk-C6FTHSJA.js → chunk-MQJG522T.js} +6 -6
  35. package/Build/Workers/{chunk-WH4HDRGN.js → chunk-MT5M7RLZ.js} +2 -2
  36. package/Build/Workers/{chunk-4ZQN7M7E.js → chunk-N4AWE7TZ.js} +10 -10
  37. package/Build/Workers/{chunk-SDUH3N6G.js → chunk-NAYRNPEP.js} +4 -4
  38. package/Build/Workers/{chunk-7OPRTZBT.js → chunk-NNHU33JK.js} +7 -7
  39. package/Build/Workers/{chunk-CQCEPC6N.js → chunk-NQCAZU7S.js} +13 -13
  40. package/Build/Workers/{chunk-35J4D6PX.js → chunk-NUYLNQKV.js} +2 -2
  41. package/Build/Workers/{chunk-I45CATZK.js → chunk-OC6X22PG.js} +9 -9
  42. package/Build/Workers/{chunk-7MGTX4WP.js → chunk-OHBM4YG4.js} +12 -12
  43. package/Build/Workers/{chunk-DCR62BCO.js → chunk-OMXN7YF4.js} +12 -12
  44. package/Build/Workers/{chunk-XPNY2VY3.js → chunk-OQ3EAJNW.js} +2 -2
  45. package/Build/Workers/{chunk-4I7BCCNU.js → chunk-OQBPOKPZ.js} +6 -6
  46. package/Build/Workers/{chunk-2JNPWPLE.js → chunk-PQVNT5CJ.js} +6 -6
  47. package/Build/Workers/{chunk-K64RQCRK.js → chunk-QA24Q62E.js} +17 -17
  48. package/Build/Workers/{chunk-K6BXEBAF.js → chunk-QQX7S5QT.js} +17 -17
  49. package/Build/Workers/{chunk-2YVTOY5Z.js → chunk-QTOHIXGF.js} +10 -10
  50. package/Build/Workers/{chunk-4MCPC4TE.js → chunk-R7M4XNPP.js} +8 -8
  51. package/Build/Workers/{chunk-C35SJ4QP.js → chunk-SGKTBHFQ.js} +13 -13
  52. package/Build/Workers/{chunk-BKYJBTHW.js → chunk-SQTRWKO2.js} +5 -5
  53. package/Build/Workers/{chunk-I4D5IP46.js → chunk-T43FXHNC.js} +7 -7
  54. package/Build/Workers/{chunk-QO6Z5UJE.js → chunk-UEEGWJJP.js} +2 -2
  55. package/Build/Workers/{chunk-ZUWF63QU.js → chunk-WKXDCVBO.js} +4 -4
  56. package/Build/Workers/{chunk-N5MNKWED.js → chunk-Y5AJSEEN.js} +2 -2
  57. package/Build/Workers/{chunk-V26Y7ZQL.js → chunk-ZIW5FCIW.js} +37 -27
  58. package/Build/Workers/combineGeometry.js +24 -24
  59. package/Build/Workers/createBoxGeometry.js +18 -18
  60. package/Build/Workers/createBoxOutlineGeometry.js +16 -16
  61. package/Build/Workers/createCircleGeometry.js +26 -26
  62. package/Build/Workers/createCircleOutlineGeometry.js +19 -19
  63. package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
  64. package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
  65. package/Build/Workers/createCorridorGeometry.js +29 -29
  66. package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
  67. package/Build/Workers/createCylinderGeometry.js +20 -20
  68. package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
  69. package/Build/Workers/createEllipseGeometry.js +26 -26
  70. package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
  71. package/Build/Workers/createEllipsoidGeometry.js +19 -19
  72. package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
  73. package/Build/Workers/createFrustumGeometry.js +18 -18
  74. package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
  75. package/Build/Workers/createGeometry.js +24 -24
  76. package/Build/Workers/createGroundPolylineGeometry.js +22 -22
  77. package/Build/Workers/createPlaneGeometry.js +16 -16
  78. package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
  79. package/Build/Workers/createPolygonGeometry.js +32 -32
  80. package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
  81. package/Build/Workers/createPolylineGeometry.js +25 -25
  82. package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
  83. package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
  84. package/Build/Workers/createRectangleGeometry.js +27 -27
  85. package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
  86. package/Build/Workers/createSimplePolylineGeometry.js +23 -23
  87. package/Build/Workers/createSphereGeometry.js +19 -19
  88. package/Build/Workers/createSphereOutlineGeometry.js +18 -18
  89. package/Build/Workers/createTaskProcessorWorker.js +3 -3
  90. package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
  91. package/Build/Workers/createVectorTileGeometries.js +24 -24
  92. package/Build/Workers/createVectorTilePoints.js +13 -13
  93. package/Build/Workers/createVectorTilePolygons.js +22 -22
  94. package/Build/Workers/createVectorTilePolylines.js +14 -14
  95. package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
  96. package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
  97. package/Build/Workers/createVerticesFromHeightmap.js +22 -22
  98. package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
  99. package/Build/Workers/createWallGeometry.js +24 -24
  100. package/Build/Workers/createWallOutlineGeometry.js +23 -23
  101. package/Build/Workers/decodeDraco.js +10 -10
  102. package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
  103. package/Build/Workers/decodeI3S.js +10 -10
  104. package/Build/Workers/gaussianSplatSorter.js +4 -4
  105. package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
  106. package/Build/Workers/incrementallyBuildTerrainPicker.js +20 -12
  107. package/Build/Workers/transcodeKTX2.js +6 -6
  108. package/Build/Workers/transferTypedArrayTest.js +1 -1
  109. package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
  110. package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
  111. package/Source/Core/AttributeCompression.js +53 -6
  112. package/Source/Core/BoxGeometry.js +1 -1
  113. package/Source/Core/Cartesian2.js +689 -684
  114. package/Source/Core/Cartesian3.js +1044 -1043
  115. package/Source/Core/Cartesian4.js +816 -813
  116. package/Source/Core/CornerType.js +1 -1
  117. package/Source/Core/CorridorGeometry.js +1 -1
  118. package/Source/Core/FeatureDetection.js +1 -32
  119. package/Source/Core/Geometry.js +1 -1
  120. package/Source/Core/GoogleMaps.js +23 -2
  121. package/Source/Core/IntersectionTests.js +2 -2
  122. package/Source/Core/Ion.js +1 -1
  123. package/Source/Core/OpenCageGeocoderService.js +2 -3
  124. package/Source/Core/PinBuilder.js +1 -1
  125. package/Source/Core/PolygonGeometry.js +1 -1
  126. package/Source/Core/PolylineGeometry.js +1 -1
  127. package/Source/Core/PolylineVolumeGeometry.js +1 -1
  128. package/Source/Core/RectangleGeometry.js +1 -1
  129. package/Source/Core/ScreenSpaceEventHandler.js +4 -8
  130. package/Source/Core/TerrainMesh.js +11 -8
  131. package/Source/Core/TerrainPicker.js +24 -7
  132. package/Source/Core/VideoSynchronizer.js +1 -1
  133. package/Source/Core/WallGeometry.js +1 -1
  134. package/Source/Core/globalTypes.js +16 -0
  135. package/Source/Core/writeTextToCanvas.js +40 -86
  136. package/Source/DataSources/BillboardGraphics.js +1 -1
  137. package/Source/DataSources/BoxGraphics.js +1 -1
  138. package/Source/DataSources/CallbackPositionProperty.js +1 -1
  139. package/Source/DataSources/CorridorGraphics.js +1 -1
  140. package/Source/DataSources/CzmlDataSource.js +1 -1
  141. package/Source/DataSources/EllipseGraphics.js +1 -1
  142. package/Source/DataSources/EllipsoidGraphics.js +1 -1
  143. package/Source/DataSources/Entity.js +1 -1
  144. package/Source/DataSources/EntityCluster.js +2 -2
  145. package/Source/DataSources/GeoJsonDataSource.js +2 -2
  146. package/Source/DataSources/GpxDataSource.js +1 -1
  147. package/Source/DataSources/KmlDataSource.js +1 -1
  148. package/Source/DataSources/KmlTour.js +1 -1
  149. package/Source/DataSources/LabelGraphics.js +1 -1
  150. package/Source/DataSources/ModelGraphics.js +1 -1
  151. package/Source/DataSources/PlaneGraphics.js +1 -1
  152. package/Source/DataSources/PolygonGraphics.js +1 -1
  153. package/Source/DataSources/PolylineGraphics.js +1 -1
  154. package/Source/DataSources/PolylineVolumeGraphics.js +1 -1
  155. package/Source/DataSources/RectangleGraphics.js +1 -1
  156. package/Source/DataSources/WallGraphics.js +1 -1
  157. package/Source/DataSources/exportKml.js +1 -1
  158. package/Source/Renderer/Context.js +11 -10
  159. package/Source/Renderer/ContextLimits.js +66 -33
  160. package/Source/Renderer/ShaderDestination.js +54 -13
  161. package/Source/Renderer/ShaderSource.js +19 -18
  162. package/Source/Renderer/Texture.js +1 -1
  163. package/Source/Renderer/Texture3D.js +166 -7
  164. package/Source/Renderer/TextureAtlas.js +2 -2
  165. package/Source/Scene/Appearance.js +1 -1
  166. package/Source/Scene/ArcGisMapService.js +1 -1
  167. package/Source/Scene/Billboard.js +8 -5
  168. package/Source/Scene/BillboardCollection.js +65 -26
  169. package/Source/Scene/BillboardTexture.js +4 -1
  170. package/Source/Scene/BufferLoader.js +65 -74
  171. package/Source/Scene/Camera.js +13 -2
  172. package/Source/Scene/ClippingPlaneCollection.js +2 -2
  173. package/Source/Scene/CloudCollection.js +2 -2
  174. package/Source/Scene/CubeMapPanorama.js +351 -0
  175. package/Source/Scene/CumulusCloud.js +1 -1
  176. package/Source/Scene/DerivedCommand.js +8 -31
  177. package/Source/Scene/DracoLoader.js +79 -78
  178. package/Source/Scene/DynamicEnvironmentMapManager.js +41 -26
  179. package/Source/Scene/EquirectangularPanorama.js +264 -0
  180. package/Source/Scene/Fog.js +1 -1
  181. package/Source/Scene/FrameState.js +7 -0
  182. package/Source/Scene/GaussianSplatPrimitive.js +907 -168
  183. package/Source/Scene/Globe.js +3 -10
  184. package/Source/Scene/GlobeSurfaceShaderSet.js +36 -32
  185. package/Source/Scene/GltfBufferViewLoader.js +109 -118
  186. package/Source/Scene/GltfDracoLoader.js +167 -176
  187. package/Source/Scene/GltfImageLoader.js +91 -101
  188. package/Source/Scene/GltfIndexBufferLoader.js +228 -241
  189. package/Source/Scene/GltfJsonLoader.js +90 -99
  190. package/Source/Scene/GltfLoader.js +323 -324
  191. package/Source/Scene/GltfSpzLoader.js +127 -134
  192. package/Source/Scene/GltfStructuralMetadataLoader.js +181 -186
  193. package/Source/Scene/GltfTextureLoader.js +217 -231
  194. package/Source/Scene/GltfVertexBufferLoader.js +267 -276
  195. package/Source/Scene/GoogleStreetViewCubeMapPanoramaProvider.js +341 -0
  196. package/Source/Scene/ImageBasedLighting.js +2 -2
  197. package/Source/Scene/ImageryLayerCollection.js +2 -2
  198. package/Source/Scene/ImageryProvider.js +2 -2
  199. package/Source/Scene/Label.js +7 -5
  200. package/Source/Scene/LabelCollection.js +60 -2
  201. package/Source/Scene/Material.js +1 -1
  202. package/Source/Scene/MaterialAppearance.js +1 -1
  203. package/Source/Scene/Megatexture.js +174 -242
  204. package/Source/Scene/MetadataClassProperty.js +212 -7
  205. package/Source/Scene/MetadataComponentType.js +162 -127
  206. package/Source/Scene/MetadataSchemaLoader.js +60 -67
  207. package/Source/Scene/MetadataTable.js +14 -0
  208. package/Source/Scene/MetadataTableProperty.js +14 -0
  209. package/Source/Scene/Model/B3dmLoader.js +216 -224
  210. package/Source/Scene/Model/CustomShader.js +6 -1
  211. package/Source/Scene/Model/CustomShaderPipelineStage.js +122 -7
  212. package/Source/Scene/Model/GeoJsonLoader.js +53 -61
  213. package/Source/Scene/Model/GeometryPipelineStage.js +17 -3
  214. package/Source/Scene/Model/I3dmLoader.js +232 -240
  215. package/Source/Scene/Model/MaterialPipelineStage.js +17 -0
  216. package/Source/Scene/Model/MetadataPipelineStage.js +438 -22
  217. package/Source/Scene/Model/Model.js +1 -1
  218. package/Source/Scene/Model/PntsLoader.js +78 -89
  219. package/Source/Scene/ModelComponents.js +10 -0
  220. package/Source/Scene/Panorama.js +53 -0
  221. package/Source/Scene/PanoramaProvider.js +43 -0
  222. package/Source/Scene/ParticleSystem.js +2 -2
  223. package/Source/Scene/PointPrimitive.js +1 -1
  224. package/Source/Scene/PointPrimitiveCollection.js +14 -22
  225. package/Source/Scene/Polyline.js +0 -1
  226. package/Source/Scene/PolylineCollection.js +1 -4
  227. package/Source/Scene/PolylineColorAppearance.js +1 -6
  228. package/Source/Scene/PolylineMaterialAppearance.js +1 -6
  229. package/Source/Scene/PostProcessStageCollection.js +1 -1
  230. package/Source/Scene/PropertyTable.js +43 -0
  231. package/Source/Scene/PropertyTexture.js +1 -1
  232. package/Source/Scene/PropertyTextureProperty.js +0 -97
  233. package/Source/Scene/QuadtreePrimitive.js +6 -3
  234. package/Source/Scene/ResourceLoader.js +84 -92
  235. package/Source/Scene/Scene.js +12 -0
  236. package/Source/Scene/ShadowMap.js +1 -2
  237. package/Source/Scene/SkyBox.js +29 -164
  238. package/Source/Scene/StructuralMetadata.js +18 -3
  239. package/Source/Scene/Vector3DTileClampedPolylines.js +1 -5
  240. package/Source/Scene/Vector3DTilePolylines.js +1 -5
  241. package/Source/Scene/VoxelPrimitive.js +16 -33
  242. package/Source/Scene/VoxelRenderResources.js +1 -8
  243. package/Source/Scene/VoxelTraversal.js +16 -61
  244. package/Source/Scene/WebMapTileServiceImageryProvider.js +1 -1
  245. package/Source/Scene/createElevationBandMaterial.js +1 -1
  246. package/Source/Scene/parseStructuralMetadata.js +244 -0
  247. package/Source/Scene/processVoxelProperties.js +1 -1
  248. package/Source/Shaders/BillboardCollectionFS.glsl +66 -40
  249. package/Source/Shaders/BillboardCollectionFS.js +67 -40
  250. package/Source/Shaders/BillboardCollectionVS.glsl +22 -31
  251. package/Source/Shaders/BillboardCollectionVS.js +22 -31
  252. package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
  253. package/Source/Shaders/Builtin/Functions/columbusViewMorph.glsl +8 -1
  254. package/Source/Shaders/Builtin/Functions/columbusViewMorph.js +8 -1
  255. package/Source/Shaders/Builtin/Functions/decodeRGB8.glsl +22 -0
  256. package/Source/Shaders/Builtin/Functions/decodeRGB8.js +24 -0
  257. package/Source/Shaders/Builtin/Functions/unpackTexture.glsl +35 -0
  258. package/Source/Shaders/Builtin/Functions/unpackTexture.js +37 -0
  259. package/Source/Shaders/CubeMapPanoramaVS.glsl +11 -0
  260. package/Source/Shaders/CubeMapPanoramaVS.js +13 -0
  261. package/Source/Shaders/Model/MetadataStageFS.glsl +2 -1
  262. package/Source/Shaders/Model/MetadataStageFS.js +2 -1
  263. package/Source/Shaders/Model/MetadataStageVS.glsl +2 -1
  264. package/Source/Shaders/Model/MetadataStageVS.js +2 -1
  265. package/Source/Shaders/Model/ModelFS.glsl +9 -1
  266. package/Source/Shaders/Model/ModelFS.js +9 -1
  267. package/Source/Shaders/Model/ModelVS.glsl +4 -2
  268. package/Source/Shaders/Model/ModelVS.js +4 -2
  269. package/Source/Shaders/PointPrimitiveCollectionVS.glsl +8 -39
  270. package/Source/Shaders/PointPrimitiveCollectionVS.js +8 -39
  271. package/Source/Shaders/Voxels/IntersectionUtils.glsl +1 -1
  272. package/Source/Shaders/Voxels/IntersectionUtils.js +1 -1
  273. package/Source/Shaders/Voxels/Megatexture.glsl +15 -83
  274. package/Source/Shaders/Voxels/Megatexture.js +15 -83
  275. package/Source/Shaders/Voxels/Octree.glsl +6 -9
  276. package/Source/Shaders/Voxels/Octree.js +6 -9
  277. package/Source/Widget/CesiumWidget.js +1 -1
  278. package/Source/Workers/incrementallyBuildTerrainPicker.js +16 -2
  279. package/index.d.ts +582 -193
  280. package/index.js +91 -83
  281. package/package.json +2 -1
  282. package/Build/Workers/chunk-ZGWX2R5I.js +0 -1443
@@ -13,62 +13,56 @@ import VertexAttributeSemantic from "./VertexAttributeSemantic.js";
13
13
  * Implements the {@link ResourceLoader} interface.
14
14
  * </p>
15
15
  *
16
- * @alias GltfDracoLoader
17
- * @constructor
18
- * @augments ResourceLoader
19
- *
20
- * @param {object} options Object with the following properties:
21
- * @param {ResourceCache} options.resourceCache The {@link ResourceCache} (to avoid circular dependencies).
22
- * @param {object} options.gltf The glTF JSON.
23
- * @param {object} options.primitive The primitive containing the Draco extension.
24
- * @param {object} options.draco The Draco extension object.
25
- * @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
26
- * @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
27
- * @param {string} [options.cacheKey] The cache key of the resource.
28
- *
29
16
  * @private
30
17
  */
31
- function GltfDracoLoader(options) {
32
- options = options ?? Frozen.EMPTY_OBJECT;
33
- const resourceCache = options.resourceCache;
34
- const gltf = options.gltf;
35
- const primitive = options.primitive;
36
- const draco = options.draco;
37
- const gltfResource = options.gltfResource;
38
- const baseResource = options.baseResource;
39
- const cacheKey = options.cacheKey;
40
-
41
- //>>includeStart('debug', pragmas.debug);
42
- Check.typeOf.func("options.resourceCache", resourceCache);
43
- Check.typeOf.object("options.gltf", gltf);
44
- Check.typeOf.object("options.primitive", primitive);
45
- Check.typeOf.object("options.draco", draco);
46
- Check.typeOf.object("options.gltfResource", gltfResource);
47
- Check.typeOf.object("options.baseResource", baseResource);
48
- //>>includeEnd('debug');
49
-
50
- this._resourceCache = resourceCache;
51
- this._gltfResource = gltfResource;
52
- this._baseResource = baseResource;
53
- this._gltf = gltf;
54
- this._primitive = primitive;
55
- this._draco = draco;
56
- this._cacheKey = cacheKey;
57
- this._bufferViewLoader = undefined;
58
- this._bufferViewTypedArray = undefined;
59
- this._decodePromise = undefined;
60
- this._decodedData = undefined;
61
- this._state = ResourceLoaderState.UNLOADED;
62
- this._promise = undefined;
63
- this._dracoError = undefined;
64
- }
65
-
66
- if (defined(Object.create)) {
67
- GltfDracoLoader.prototype = Object.create(ResourceLoader.prototype);
68
- GltfDracoLoader.prototype.constructor = GltfDracoLoader;
69
- }
18
+ class GltfDracoLoader extends ResourceLoader {
19
+ /**
20
+ * @param {object} options Object with the following properties:
21
+ * @param {ResourceCache} options.resourceCache The {@link ResourceCache} (to avoid circular dependencies).
22
+ * @param {object} options.gltf The glTF JSON.
23
+ * @param {object} options.primitive The primitive containing the Draco extension.
24
+ * @param {object} options.draco The Draco extension object.
25
+ * @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
26
+ * @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
27
+ * @param {string} [options.cacheKey] The cache key of the resource.
28
+ */
29
+ constructor(options) {
30
+ super();
31
+
32
+ options = options ?? Frozen.EMPTY_OBJECT;
33
+ const resourceCache = options.resourceCache;
34
+ const gltf = options.gltf;
35
+ const primitive = options.primitive;
36
+ const draco = options.draco;
37
+ const gltfResource = options.gltfResource;
38
+ const baseResource = options.baseResource;
39
+ const cacheKey = options.cacheKey;
40
+
41
+ //>>includeStart('debug', pragmas.debug);
42
+ Check.typeOf.func("options.resourceCache", resourceCache);
43
+ Check.typeOf.object("options.gltf", gltf);
44
+ Check.typeOf.object("options.primitive", primitive);
45
+ Check.typeOf.object("options.draco", draco);
46
+ Check.typeOf.object("options.gltfResource", gltfResource);
47
+ Check.typeOf.object("options.baseResource", baseResource);
48
+ //>>includeEnd('debug');
49
+
50
+ this._resourceCache = resourceCache;
51
+ this._gltfResource = gltfResource;
52
+ this._baseResource = baseResource;
53
+ this._gltf = gltf;
54
+ this._primitive = primitive;
55
+ this._draco = draco;
56
+ this._cacheKey = cacheKey;
57
+ this._bufferViewLoader = undefined;
58
+ this._bufferViewTypedArray = undefined;
59
+ this._decodePromise = undefined;
60
+ this._decodedData = undefined;
61
+ this._state = ResourceLoaderState.UNLOADED;
62
+ this._promise = undefined;
63
+ this._dracoError = undefined;
64
+ }
70
65
 
71
- Object.defineProperties(GltfDracoLoader.prototype, {
72
66
  /**
73
67
  * The cache key of the resource.
74
68
  *
@@ -78,11 +72,10 @@ Object.defineProperties(GltfDracoLoader.prototype, {
78
72
  * @readonly
79
73
  * @private
80
74
  */
81
- cacheKey: {
82
- get: function () {
83
- return this._cacheKey;
84
- },
85
- },
75
+ get cacheKey() {
76
+ return this._cacheKey;
77
+ }
78
+
86
79
  /**
87
80
  * The decoded data.
88
81
  *
@@ -92,12 +85,122 @@ Object.defineProperties(GltfDracoLoader.prototype, {
92
85
  * @readonly
93
86
  * @private
94
87
  */
95
- decodedData: {
96
- get: function () {
97
- return this._decodedData;
98
- },
99
- },
100
- });
88
+ get decodedData() {
89
+ return this._decodedData;
90
+ }
91
+
92
+ /**
93
+ * Loads the resource.
94
+ * @returns {Promise<GltfDracoLoader>} A promise which resolves to the loader when the resource loading is completed.
95
+ * @private
96
+ */
97
+ async load() {
98
+ if (defined(this._promise)) {
99
+ return this._promise;
100
+ }
101
+
102
+ this._state = ResourceLoaderState.LOADING;
103
+ this._promise = loadResources(this);
104
+ return this._promise;
105
+ }
106
+
107
+ /**
108
+ * Processes the resource until it becomes ready.
109
+ *
110
+ * @param {FrameState} frameState The frame state.
111
+ * @private
112
+ */
113
+ process(frameState) {
114
+ //>>includeStart('debug', pragmas.debug);
115
+ Check.typeOf.object("frameState", frameState);
116
+ //>>includeEnd('debug');
117
+
118
+ if (this._state === ResourceLoaderState.READY) {
119
+ return true;
120
+ }
121
+
122
+ if (this._state !== ResourceLoaderState.PROCESSING) {
123
+ return false;
124
+ }
125
+
126
+ if (defined(this._dracoError)) {
127
+ handleError(this, this._dracoError);
128
+ }
129
+
130
+ if (!defined(this._bufferViewTypedArray)) {
131
+ // Not ready to decode the Draco buffer
132
+ return false;
133
+ }
134
+
135
+ if (defined(this._decodePromise)) {
136
+ // Currently decoding
137
+ return false;
138
+ }
139
+
140
+ const draco = this._draco;
141
+ const primitive = this._primitive;
142
+ const gltf = this._gltf;
143
+ const bufferViews = gltf.bufferViews;
144
+ const bufferViewId = draco.bufferView;
145
+ const bufferView = bufferViews[bufferViewId];
146
+ const compressedAttributes = draco.attributes;
147
+
148
+ // Skip de-quantization transform if present for floating point attributes.
149
+ // They will stay quantized in memory and be dequantized in the shader.
150
+ const attributesToSkipTransform = [];
151
+
152
+ for (const attribute in primitive.attributes) {
153
+ if (primitive.attributes.hasOwnProperty(attribute)) {
154
+ const dracoAttributeType = getDracoAttributeType(attribute);
155
+ if (defined(dracoAttributeType)) {
156
+ const accessor = gltf.accessors[primitive.attributes[attribute]];
157
+ if (accessor.componentType === ComponentDatatype.FLOAT) {
158
+ if (!attributesToSkipTransform.includes(dracoAttributeType)) {
159
+ attributesToSkipTransform.push(dracoAttributeType);
160
+ }
161
+ }
162
+ }
163
+ }
164
+ }
165
+
166
+ const decodeOptions = {
167
+ // Need to make a copy of the typed array otherwise the underlying
168
+ // ArrayBuffer may be accessed on both the worker and the main thread. This
169
+ // leads to errors such as "ArrayBuffer at index 0 is already detached".
170
+ // PERFORMANCE_IDEA: Look into SharedArrayBuffer to get around this.
171
+ array: new Uint8Array(this._bufferViewTypedArray),
172
+ bufferView: bufferView,
173
+ compressedAttributes: compressedAttributes,
174
+ dequantizeInShader: true,
175
+ attributesToSkipTransform: attributesToSkipTransform,
176
+ };
177
+
178
+ const decodePromise = DracoLoader.decodeBufferView(decodeOptions);
179
+
180
+ if (!defined(decodePromise)) {
181
+ // Cannot schedule task this frame
182
+ return false;
183
+ }
184
+
185
+ this._decodePromise = processDecode(this, decodePromise);
186
+ }
187
+
188
+ /**
189
+ * Unloads the resource.
190
+ * @private
191
+ */
192
+ unload() {
193
+ if (defined(this._bufferViewLoader)) {
194
+ this._resourceCache.unload(this._bufferViewLoader);
195
+ }
196
+
197
+ this._bufferViewLoader = undefined;
198
+ this._bufferViewTypedArray = undefined;
199
+ this._decodedData = undefined;
200
+ this._gltf = undefined;
201
+ this._primitive = undefined;
202
+ }
203
+ }
101
204
 
102
205
  async function loadResources(loader) {
103
206
  const resourceCache = loader._resourceCache;
@@ -127,21 +230,6 @@ async function loadResources(loader) {
127
230
  }
128
231
  }
129
232
 
130
- /**
131
- * Loads the resource.
132
- * @returns {Promise<GltfDracoLoader>} A promise which resolves to the loader when the resource loading is completed.
133
- * @private
134
- */
135
- GltfDracoLoader.prototype.load = async function () {
136
- if (defined(this._promise)) {
137
- return this._promise;
138
- }
139
-
140
- this._state = ResourceLoaderState.LOADING;
141
- this._promise = loadResources(this);
142
- return this._promise;
143
- };
144
-
145
233
  function handleError(dracoLoader, error) {
146
234
  dracoLoader.unload();
147
235
  dracoLoader._state = ResourceLoaderState.FAILED;
@@ -193,101 +281,4 @@ function getDracoAttributeType(attribute) {
193
281
  return undefined;
194
282
  }
195
283
 
196
- /**
197
- * Processes the resource until it becomes ready.
198
- *
199
- * @param {FrameState} frameState The frame state.
200
- * @private
201
- */
202
- GltfDracoLoader.prototype.process = function (frameState) {
203
- //>>includeStart('debug', pragmas.debug);
204
- Check.typeOf.object("frameState", frameState);
205
- //>>includeEnd('debug');
206
-
207
- if (this._state === ResourceLoaderState.READY) {
208
- return true;
209
- }
210
-
211
- if (this._state !== ResourceLoaderState.PROCESSING) {
212
- return false;
213
- }
214
-
215
- if (defined(this._dracoError)) {
216
- handleError(this, this._dracoError);
217
- }
218
-
219
- if (!defined(this._bufferViewTypedArray)) {
220
- // Not ready to decode the Draco buffer
221
- return false;
222
- }
223
-
224
- if (defined(this._decodePromise)) {
225
- // Currently decoding
226
- return false;
227
- }
228
-
229
- const draco = this._draco;
230
- const primitive = this._primitive;
231
- const gltf = this._gltf;
232
- const bufferViews = gltf.bufferViews;
233
- const bufferViewId = draco.bufferView;
234
- const bufferView = bufferViews[bufferViewId];
235
- const compressedAttributes = draco.attributes;
236
-
237
- // Skip de-quantization transform if present for floating point attributes.
238
- // They will stay quantized in memory and be dequantized in the shader.
239
- const attributesToSkipTransform = [];
240
-
241
- for (const attribute in primitive.attributes) {
242
- if (primitive.attributes.hasOwnProperty(attribute)) {
243
- const dracoAttributeType = getDracoAttributeType(attribute);
244
- if (defined(dracoAttributeType)) {
245
- const accessor = gltf.accessors[primitive.attributes[attribute]];
246
- if (accessor.componentType === ComponentDatatype.FLOAT) {
247
- if (!attributesToSkipTransform.includes(dracoAttributeType)) {
248
- attributesToSkipTransform.push(dracoAttributeType);
249
- }
250
- }
251
- }
252
- }
253
- }
254
-
255
- const decodeOptions = {
256
- // Need to make a copy of the typed array otherwise the underlying
257
- // ArrayBuffer may be accessed on both the worker and the main thread. This
258
- // leads to errors such as "ArrayBuffer at index 0 is already detached".
259
- // PERFORMANCE_IDEA: Look into SharedArrayBuffer to get around this.
260
- array: new Uint8Array(this._bufferViewTypedArray),
261
- bufferView: bufferView,
262
- compressedAttributes: compressedAttributes,
263
- dequantizeInShader: true,
264
- attributesToSkipTransform: attributesToSkipTransform,
265
- };
266
-
267
- const decodePromise = DracoLoader.decodeBufferView(decodeOptions);
268
-
269
- if (!defined(decodePromise)) {
270
- // Cannot schedule task this frame
271
- return false;
272
- }
273
-
274
- this._decodePromise = processDecode(this, decodePromise);
275
- };
276
-
277
- /**
278
- * Unloads the resource.
279
- * @private
280
- */
281
- GltfDracoLoader.prototype.unload = function () {
282
- if (defined(this._bufferViewLoader)) {
283
- this._resourceCache.unload(this._bufferViewLoader);
284
- }
285
-
286
- this._bufferViewLoader = undefined;
287
- this._bufferViewTypedArray = undefined;
288
- this._decodedData = undefined;
289
- this._gltf = undefined;
290
- this._primitive = undefined;
291
- };
292
-
293
284
  export default GltfDracoLoader;
@@ -13,61 +13,55 @@ import ResourceLoaderState from "./ResourceLoaderState.js";
13
13
  * Implements the {@link ResourceLoader} interface.
14
14
  * </p>
15
15
  *
16
- * @alias GltfImageLoader
17
- * @constructor
18
- * @augments ResourceLoader
19
- *
20
- * @param {object} options Object with the following properties:
21
- * @param {ResourceCache} options.resourceCache The {@link ResourceCache} (to avoid circular dependencies).
22
- * @param {object} options.gltf The glTF JSON.
23
- * @param {number} options.imageId The image ID.
24
- * @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
25
- * @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
26
- * @param {string} [options.cacheKey] The cache key of the resource.
27
- *
28
16
  * @private
29
17
  */
30
- function GltfImageLoader(options) {
31
- options = options ?? Frozen.EMPTY_OBJECT;
32
- const resourceCache = options.resourceCache;
33
- const gltf = options.gltf;
34
- const imageId = options.imageId;
35
- const gltfResource = options.gltfResource;
36
- const baseResource = options.baseResource;
37
- const cacheKey = options.cacheKey;
38
-
39
- //>>includeStart('debug', pragmas.debug);
40
- Check.typeOf.func("options.resourceCache", resourceCache);
41
- Check.typeOf.object("options.gltf", gltf);
42
- Check.typeOf.number("options.imageId", imageId);
43
- Check.typeOf.object("options.gltfResource", gltfResource);
44
- Check.typeOf.object("options.baseResource", baseResource);
45
- //>>includeEnd('debug');
46
-
47
- const image = gltf.images[imageId];
48
- const bufferViewId = image.bufferView;
49
- const uri = image.uri;
50
-
51
- this._resourceCache = resourceCache;
52
- this._gltfResource = gltfResource;
53
- this._baseResource = baseResource;
54
- this._gltf = gltf;
55
- this._bufferViewId = bufferViewId;
56
- this._uri = uri;
57
- this._cacheKey = cacheKey;
58
- this._bufferViewLoader = undefined;
59
- this._image = undefined;
60
- this._mipLevels = undefined;
61
- this._state = ResourceLoaderState.UNLOADED;
62
- this._promise = undefined;
63
- }
64
-
65
- if (defined(Object.create)) {
66
- GltfImageLoader.prototype = Object.create(ResourceLoader.prototype);
67
- GltfImageLoader.prototype.constructor = GltfImageLoader;
68
- }
18
+ class GltfImageLoader extends ResourceLoader {
19
+ /**
20
+ * @param {object} options Object with the following properties:
21
+ * @param {ResourceCache} options.resourceCache The {@link ResourceCache} (to avoid circular dependencies).
22
+ * @param {object} options.gltf The glTF JSON.
23
+ * @param {number} options.imageId The image ID.
24
+ * @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
25
+ * @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
26
+ * @param {string} [options.cacheKey] The cache key of the resource.
27
+ */
28
+ constructor(options) {
29
+ super();
30
+
31
+ options = options ?? Frozen.EMPTY_OBJECT;
32
+ const resourceCache = options.resourceCache;
33
+ const gltf = options.gltf;
34
+ const imageId = options.imageId;
35
+ const gltfResource = options.gltfResource;
36
+ const baseResource = options.baseResource;
37
+ const cacheKey = options.cacheKey;
38
+
39
+ //>>includeStart('debug', pragmas.debug);
40
+ Check.typeOf.func("options.resourceCache", resourceCache);
41
+ Check.typeOf.object("options.gltf", gltf);
42
+ Check.typeOf.number("options.imageId", imageId);
43
+ Check.typeOf.object("options.gltfResource", gltfResource);
44
+ Check.typeOf.object("options.baseResource", baseResource);
45
+ //>>includeEnd('debug');
46
+
47
+ const image = gltf.images[imageId];
48
+ const bufferViewId = image.bufferView;
49
+ const uri = image.uri;
50
+
51
+ this._resourceCache = resourceCache;
52
+ this._gltfResource = gltfResource;
53
+ this._baseResource = baseResource;
54
+ this._gltf = gltf;
55
+ this._bufferViewId = bufferViewId;
56
+ this._uri = uri;
57
+ this._cacheKey = cacheKey;
58
+ this._bufferViewLoader = undefined;
59
+ this._image = undefined;
60
+ this._mipLevels = undefined;
61
+ this._state = ResourceLoaderState.UNLOADED;
62
+ this._promise = undefined;
63
+ }
69
64
 
70
- Object.defineProperties(GltfImageLoader.prototype, {
71
65
  /**
72
66
  * The cache key of the resource.
73
67
  *
@@ -77,11 +71,10 @@ Object.defineProperties(GltfImageLoader.prototype, {
77
71
  * @readonly
78
72
  * @private
79
73
  */
80
- cacheKey: {
81
- get: function () {
82
- return this._cacheKey;
83
- },
84
- },
74
+ get cacheKey() {
75
+ return this._cacheKey;
76
+ }
77
+
85
78
  /**
86
79
  * The image.
87
80
  *
@@ -91,11 +84,10 @@ Object.defineProperties(GltfImageLoader.prototype, {
91
84
  * @readonly
92
85
  * @private
93
86
  */
94
- image: {
95
- get: function () {
96
- return this._image;
97
- },
98
- },
87
+ get image() {
88
+ return this._image;
89
+ }
90
+
99
91
  /**
100
92
  * The mip levels. Only defined for KTX2 files containing mip levels.
101
93
  *
@@ -105,31 +97,48 @@ Object.defineProperties(GltfImageLoader.prototype, {
105
97
  * @readonly
106
98
  * @private
107
99
  */
108
- mipLevels: {
109
- get: function () {
110
- return this._mipLevels;
111
- },
112
- },
113
- });
114
-
115
- /**
116
- * Loads the resource.
117
- * @returns {Promise<GltfImageLoader>} A promise which resolves to the loader when the resource loading is completed.
118
- * @private
119
- */
120
- GltfImageLoader.prototype.load = function () {
121
- if (defined(this._promise)) {
122
- return this._promise;
100
+ get mipLevels() {
101
+ return this._mipLevels;
123
102
  }
124
103
 
125
- if (defined(this._bufferViewId)) {
126
- this._promise = loadFromBufferView(this);
104
+ /**
105
+ * Loads the resource.
106
+ * @returns {Promise<GltfImageLoader>} A promise which resolves to the loader when the resource loading is completed.
107
+ * @private
108
+ */
109
+ load() {
110
+ if (defined(this._promise)) {
111
+ return this._promise;
112
+ }
113
+
114
+ if (defined(this._bufferViewId)) {
115
+ this._promise = loadFromBufferView(this);
116
+ return this._promise;
117
+ }
118
+
119
+ this._promise = loadFromUri(this);
127
120
  return this._promise;
128
121
  }
129
122
 
130
- this._promise = loadFromUri(this);
131
- return this._promise;
132
- };
123
+ /**
124
+ * Unloads the resource.
125
+ * @private
126
+ */
127
+ unload() {
128
+ if (
129
+ defined(this._bufferViewLoader) &&
130
+ !this._bufferViewLoader.isDestroyed()
131
+ ) {
132
+ this._resourceCache.unload(this._bufferViewLoader);
133
+ }
134
+
135
+ this._bufferViewLoader = undefined;
136
+ this._uri = undefined; // Free in case the uri is a data uri
137
+ this._image = undefined;
138
+ this._mipLevels = undefined;
139
+ this._gltf = undefined;
140
+ }
141
+ }
133
142
 
134
143
  function getImageAndMipLevels(image) {
135
144
  // Images transcoded from KTX2 can contain multiple mip levels:
@@ -295,25 +304,6 @@ function loadImageFromUri(resource) {
295
304
  });
296
305
  }
297
306
 
298
- /**
299
- * Unloads the resource.
300
- * @private
301
- */
302
- GltfImageLoader.prototype.unload = function () {
303
- if (
304
- defined(this._bufferViewLoader) &&
305
- !this._bufferViewLoader.isDestroyed()
306
- ) {
307
- this._resourceCache.unload(this._bufferViewLoader);
308
- }
309
-
310
- this._bufferViewLoader = undefined;
311
- this._uri = undefined; // Free in case the uri is a data uri
312
- this._image = undefined;
313
- this._mipLevels = undefined;
314
- this._gltf = undefined;
315
- };
316
-
317
307
  // Exposed for testing
318
308
  GltfImageLoader._loadImageFromTypedArray = loadImageFromTypedArray;
319
309