@cesium/engine 22.3.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.
- package/Build/Workers/{chunk-EAAH543Q.js → chunk-2GL2EUEE.js} +11 -11
- package/Build/Workers/{chunk-EUDHHS7K.js → chunk-2WI4HGJU.js} +6 -6
- package/Build/Workers/{chunk-LWZHJWYK.js → chunk-36LBFITA.js} +665 -366
- package/Build/Workers/{chunk-7U5YNLF3.js → chunk-3B65YFXC.js} +1 -1
- package/Build/Workers/{chunk-D63Z7KKL.js → chunk-4LGFX2P5.js} +11 -11
- package/Build/Workers/{chunk-D6OKR3BQ.js → chunk-4UNQX2MP.js} +2 -2
- package/Build/Workers/{chunk-BO22JHBX.js → chunk-52K3GJKG.js} +3 -3
- package/Build/Workers/{chunk-XLIJV3YZ.js → chunk-56OHFSLH.js} +10 -10
- package/Build/Workers/{chunk-AWELU5C6.js → chunk-5A7YSAXT.js} +14 -14
- package/Build/Workers/{chunk-T5MJDW43.js → chunk-5JP5FG7U.js} +7 -7
- package/Build/Workers/{chunk-NVL7JXAQ.js → chunk-5R7SBUTW.js} +10 -10
- package/Build/Workers/chunk-5VKZVPO5.js +1829 -0
- package/Build/Workers/{chunk-YHPBT4I5.js → chunk-6FVFM2KB.js} +5 -5
- package/Build/Workers/{chunk-WHLGBMBC.js → chunk-6SLGTBB2.js} +5 -5
- package/Build/Workers/{chunk-VIQIKMTZ.js → chunk-7KRN6JPQ.js} +14 -14
- package/Build/Workers/{chunk-TCOUGKXF.js → chunk-AA33B6PU.js} +4 -4
- package/Build/Workers/{chunk-S2KVL7OJ.js → chunk-AP6XWET5.js} +8 -8
- package/Build/Workers/{chunk-5PJB7ASO.js → chunk-APDKMX7W.js} +6 -6
- package/Build/Workers/{chunk-IXL46IYV.js → chunk-ARCFIOKA.js} +12 -12
- package/Build/Workers/{chunk-KIJR26N3.js → chunk-BNBD2YZK.js} +16 -16
- package/Build/Workers/{chunk-4R6FGUFP.js → chunk-DT5SJBKA.js} +29 -15
- package/Build/Workers/{chunk-FUDC3KOT.js → chunk-ESD4IEOU.js} +5 -5
- package/Build/Workers/{chunk-K2PLKJJG.js → chunk-FSDVXW7M.js} +5 -5
- package/Build/Workers/{chunk-4BBANFU6.js → chunk-G3YT7M7A.js} +1 -1
- package/Build/Workers/{chunk-K4PGSAR5.js → chunk-GN5NEUDT.js} +8 -8
- package/Build/Workers/{chunk-OOYICVOK.js → chunk-HYLEKKO5.js} +1 -1
- package/Build/Workers/{chunk-FDOLXORR.js → chunk-HYTFXWMY.js} +7 -7
- package/Build/Workers/{chunk-7SLNBIZS.js → chunk-IFA7VHHP.js} +560 -277
- package/Build/Workers/{chunk-N66PIK46.js → chunk-IYVDOB5V.js} +4 -4
- package/Build/Workers/{chunk-ZWWN2CQH.js → chunk-JUGY5AZN.js} +4 -4
- package/Build/Workers/{chunk-4O2ARYS7.js → chunk-KPYU6YZG.js} +1 -1
- package/Build/Workers/{chunk-TY5JXMVO.js → chunk-L7RDJ4V7.js} +1 -1
- package/Build/Workers/{chunk-L4OFWHNI.js → chunk-LDQWNMEC.js} +1 -1
- package/Build/Workers/{chunk-N6XBJBI7.js → chunk-MQJG522T.js} +6 -6
- package/Build/Workers/{chunk-FS42VX2H.js → chunk-MT5M7RLZ.js} +2 -2
- package/Build/Workers/{chunk-7ATKQRBM.js → chunk-N4AWE7TZ.js} +10 -10
- package/Build/Workers/{chunk-EOSX23OS.js → chunk-NAYRNPEP.js} +4 -4
- package/Build/Workers/{chunk-NO3LMU7T.js → chunk-NNHU33JK.js} +7 -7
- package/Build/Workers/{chunk-HWGP4GVC.js → chunk-NQCAZU7S.js} +13 -13
- package/Build/Workers/{chunk-6GBGEUWR.js → chunk-NUYLNQKV.js} +2 -2
- package/Build/Workers/{chunk-E4YDCSQK.js → chunk-OC6X22PG.js} +9 -9
- package/Build/Workers/{chunk-ZGGVEGTA.js → chunk-OHBM4YG4.js} +12 -12
- package/Build/Workers/{chunk-6WDMPXQ7.js → chunk-OMXN7YF4.js} +12 -12
- package/Build/Workers/{chunk-LK7GEFGB.js → chunk-OQ3EAJNW.js} +2 -2
- package/Build/Workers/{chunk-M5DVYXJJ.js → chunk-OQBPOKPZ.js} +6 -6
- package/Build/Workers/{chunk-WUWPKBOZ.js → chunk-PQVNT5CJ.js} +6 -6
- package/Build/Workers/{chunk-W5NV72VR.js → chunk-QA24Q62E.js} +17 -17
- package/Build/Workers/{chunk-PJLRXIMS.js → chunk-QQX7S5QT.js} +17 -17
- package/Build/Workers/{chunk-D2PEV362.js → chunk-QTOHIXGF.js} +10 -10
- package/Build/Workers/{chunk-MASEF4OV.js → chunk-R7M4XNPP.js} +8 -8
- package/Build/Workers/{chunk-2MLJ46ZZ.js → chunk-SGKTBHFQ.js} +13 -13
- package/Build/Workers/{chunk-EY5HOJFQ.js → chunk-SQTRWKO2.js} +5 -5
- package/Build/Workers/{chunk-AFGP5BXS.js → chunk-T43FXHNC.js} +7 -7
- package/Build/Workers/{chunk-IHFAFGR2.js → chunk-UEEGWJJP.js} +2 -2
- package/Build/Workers/{chunk-TMGLPEZW.js → chunk-WKXDCVBO.js} +4 -4
- package/Build/Workers/{chunk-VRAAQ3FS.js → chunk-Y5AJSEEN.js} +2 -2
- package/Build/Workers/{chunk-Y5MRBKQN.js → chunk-ZIW5FCIW.js} +18 -18
- package/Build/Workers/combineGeometry.js +24 -24
- package/Build/Workers/createBoxGeometry.js +18 -18
- package/Build/Workers/createBoxOutlineGeometry.js +16 -16
- package/Build/Workers/createCircleGeometry.js +26 -26
- package/Build/Workers/createCircleOutlineGeometry.js +19 -19
- package/Build/Workers/createCoplanarPolygonGeometry.js +33 -33
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +31 -31
- package/Build/Workers/createCorridorGeometry.js +29 -29
- package/Build/Workers/createCorridorOutlineGeometry.js +28 -28
- package/Build/Workers/createCylinderGeometry.js +20 -20
- package/Build/Workers/createCylinderOutlineGeometry.js +18 -18
- package/Build/Workers/createEllipseGeometry.js +26 -26
- package/Build/Workers/createEllipseOutlineGeometry.js +19 -19
- package/Build/Workers/createEllipsoidGeometry.js +19 -19
- package/Build/Workers/createEllipsoidOutlineGeometry.js +18 -18
- package/Build/Workers/createFrustumGeometry.js +18 -18
- package/Build/Workers/createFrustumOutlineGeometry.js +18 -18
- package/Build/Workers/createGeometry.js +24 -24
- package/Build/Workers/createGroundPolylineGeometry.js +22 -22
- package/Build/Workers/createPlaneGeometry.js +16 -16
- package/Build/Workers/createPlaneOutlineGeometry.js +15 -15
- package/Build/Workers/createPolygonGeometry.js +32 -32
- package/Build/Workers/createPolygonOutlineGeometry.js +30 -30
- package/Build/Workers/createPolylineGeometry.js +25 -25
- package/Build/Workers/createPolylineVolumeGeometry.js +31 -31
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +27 -27
- package/Build/Workers/createRectangleGeometry.js +27 -27
- package/Build/Workers/createRectangleOutlineGeometry.js +20 -20
- package/Build/Workers/createSimplePolylineGeometry.js +23 -23
- package/Build/Workers/createSphereGeometry.js +19 -19
- package/Build/Workers/createSphereOutlineGeometry.js +18 -18
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +14 -14
- package/Build/Workers/createVectorTileGeometries.js +24 -24
- package/Build/Workers/createVectorTilePoints.js +13 -13
- package/Build/Workers/createVectorTilePolygons.js +22 -22
- package/Build/Workers/createVectorTilePolylines.js +14 -14
- package/Build/Workers/createVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +22 -22
- package/Build/Workers/createVerticesFromHeightmap.js +22 -22
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +20 -20
- package/Build/Workers/createWallGeometry.js +24 -24
- package/Build/Workers/createWallOutlineGeometry.js +23 -23
- package/Build/Workers/decodeDraco.js +10 -10
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/gaussianSplatSorter.js +4 -4
- package/Build/Workers/gaussianSplatTextureGenerator.js +4 -4
- package/Build/Workers/incrementallyBuildTerrainPicker.js +10 -10
- package/Build/Workers/transcodeKTX2.js +6 -6
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +22 -22
- package/Build/Workers/upsampleVerticesFromCesium3DTilesTerrain.js +25 -25
- package/Source/Core/AttributeCompression.js +53 -6
- package/Source/Core/Cartesian2.js +689 -684
- package/Source/Core/Cartesian3.js +1044 -1043
- package/Source/Core/Cartesian4.js +816 -813
- package/Source/Core/GoogleMaps.js +23 -2
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/OpenCageGeocoderService.js +2 -3
- package/Source/Core/globalTypes.js +16 -0
- package/Source/Renderer/ShaderDestination.js +54 -13
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +7 -4
- package/Source/Scene/BillboardCollection.js +64 -25
- package/Source/Scene/BufferLoader.js +65 -74
- package/Source/Scene/CubeMapPanorama.js +351 -0
- package/Source/Scene/DerivedCommand.js +8 -31
- package/Source/Scene/DracoLoader.js +79 -78
- package/Source/Scene/EquirectangularPanorama.js +264 -0
- package/Source/Scene/FrameState.js +7 -0
- package/Source/Scene/GaussianSplatPrimitive.js +906 -167
- package/Source/Scene/GlobeSurfaceShaderSet.js +36 -32
- package/Source/Scene/GltfBufferViewLoader.js +109 -118
- package/Source/Scene/GltfDracoLoader.js +167 -176
- package/Source/Scene/GltfImageLoader.js +91 -101
- package/Source/Scene/GltfIndexBufferLoader.js +228 -241
- package/Source/Scene/GltfJsonLoader.js +90 -99
- package/Source/Scene/GltfLoader.js +313 -324
- package/Source/Scene/GltfSpzLoader.js +127 -134
- package/Source/Scene/GltfStructuralMetadataLoader.js +181 -186
- package/Source/Scene/GltfTextureLoader.js +217 -231
- package/Source/Scene/GltfVertexBufferLoader.js +267 -276
- package/Source/Scene/GoogleStreetViewCubeMapPanoramaProvider.js +341 -0
- package/Source/Scene/Label.js +6 -4
- package/Source/Scene/LabelCollection.js +59 -1
- package/Source/Scene/MetadataClassProperty.js +212 -7
- package/Source/Scene/MetadataComponentType.js +162 -127
- package/Source/Scene/MetadataSchemaLoader.js +60 -67
- package/Source/Scene/MetadataTable.js +14 -0
- package/Source/Scene/MetadataTableProperty.js +14 -0
- package/Source/Scene/Model/B3dmLoader.js +216 -224
- package/Source/Scene/Model/CustomShader.js +6 -1
- package/Source/Scene/Model/CustomShaderPipelineStage.js +122 -7
- package/Source/Scene/Model/GeoJsonLoader.js +53 -61
- package/Source/Scene/Model/GeometryPipelineStage.js +17 -3
- package/Source/Scene/Model/I3dmLoader.js +232 -240
- package/Source/Scene/Model/MaterialPipelineStage.js +1 -1
- package/Source/Scene/Model/MetadataPipelineStage.js +438 -22
- package/Source/Scene/Model/PntsLoader.js +78 -89
- package/Source/Scene/Panorama.js +53 -0
- package/Source/Scene/PanoramaProvider.js +43 -0
- package/Source/Scene/PointPrimitiveCollection.js +14 -22
- package/Source/Scene/PropertyTable.js +43 -0
- package/Source/Scene/PropertyTexture.js +1 -1
- package/Source/Scene/PropertyTextureProperty.js +0 -97
- package/Source/Scene/ResourceLoader.js +84 -92
- package/Source/Scene/Scene.js +12 -0
- package/Source/Scene/SkyBox.js +29 -164
- package/Source/Scene/StructuralMetadata.js +18 -3
- package/Source/Scene/parseStructuralMetadata.js +244 -0
- package/Source/Shaders/BillboardCollectionFS.glsl +66 -40
- package/Source/Shaders/BillboardCollectionFS.js +67 -40
- package/Source/Shaders/BillboardCollectionVS.glsl +22 -31
- package/Source/Shaders/BillboardCollectionVS.js +22 -31
- package/Source/Shaders/Builtin/CzmBuiltins.js +4 -0
- package/Source/Shaders/Builtin/Functions/decodeRGB8.glsl +22 -0
- package/Source/Shaders/Builtin/Functions/decodeRGB8.js +24 -0
- package/Source/Shaders/Builtin/Functions/unpackTexture.glsl +35 -0
- package/Source/Shaders/Builtin/Functions/unpackTexture.js +37 -0
- package/Source/Shaders/CubeMapPanoramaVS.glsl +11 -0
- package/Source/Shaders/CubeMapPanoramaVS.js +13 -0
- package/Source/Shaders/Model/MetadataStageFS.glsl +2 -1
- package/Source/Shaders/Model/MetadataStageFS.js +2 -1
- package/Source/Shaders/Model/MetadataStageVS.glsl +2 -1
- package/Source/Shaders/Model/MetadataStageVS.js +2 -1
- package/Source/Shaders/Model/ModelFS.glsl +2 -2
- package/Source/Shaders/Model/ModelFS.js +2 -2
- package/Source/Shaders/Model/ModelVS.glsl +2 -2
- package/Source/Shaders/Model/ModelVS.js +2 -2
- package/Source/Shaders/PointPrimitiveCollectionVS.glsl +8 -39
- package/Source/Shaders/PointPrimitiveCollectionVS.js +8 -39
- package/index.d.ts +564 -189
- package/index.js +127 -119
- package/package.json +1 -1
- package/Build/Workers/chunk-LYBNPUEI.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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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
|
-
|
|
83
|
-
|
|
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
|
-
|
|
97
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
82
|
-
|
|
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
|
-
|
|
96
|
-
|
|
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
|
-
|
|
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
|
-
|
|
126
|
-
|
|
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
|
-
|
|
131
|
-
|
|
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
|
|