@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
|
@@ -18,74 +18,68 @@ import resizeImageToNextPowerOfTwo from "../Core/resizeImageToNextPowerOfTwo.js"
|
|
|
18
18
|
* Implements the {@link ResourceLoader} interface.
|
|
19
19
|
* </p>
|
|
20
20
|
*
|
|
21
|
-
* @alias GltfTextureLoader
|
|
22
|
-
* @constructor
|
|
23
|
-
* @augments ResourceLoader
|
|
24
|
-
*
|
|
25
|
-
* @param {object} options Object with the following properties:
|
|
26
|
-
* @param {ResourceCache} options.resourceCache The {@link ResourceCache} (to avoid circular dependencies).
|
|
27
|
-
* @param {object} options.gltf The glTF JSON.
|
|
28
|
-
* @param {object} options.textureInfo The texture info object.
|
|
29
|
-
* @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
|
|
30
|
-
* @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
|
|
31
|
-
* @param {SupportedImageFormats} options.supportedImageFormats The supported image formats.
|
|
32
|
-
* @param {string} [options.cacheKey] The cache key of the resource.
|
|
33
|
-
* @param {boolean} [options.asynchronous=true] Determines if WebGL resource creation will be spread out over several frames or block until all WebGL resources are created.
|
|
34
|
-
*
|
|
35
21
|
* @private
|
|
36
22
|
*/
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this._promise = undefined;
|
|
81
|
-
}
|
|
23
|
+
class GltfTextureLoader extends ResourceLoader {
|
|
24
|
+
/**
|
|
25
|
+
* @param {object} options Object with the following properties:
|
|
26
|
+
* @param {ResourceCache} options.resourceCache The {@link ResourceCache} (to avoid circular dependencies).
|
|
27
|
+
* @param {object} options.gltf The glTF JSON.
|
|
28
|
+
* @param {object} options.textureInfo The texture info object.
|
|
29
|
+
* @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
|
|
30
|
+
* @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
|
|
31
|
+
* @param {SupportedImageFormats} options.supportedImageFormats The supported image formats.
|
|
32
|
+
* @param {string} [options.cacheKey] The cache key of the resource.
|
|
33
|
+
* @param {boolean} [options.asynchronous=true] Determines if WebGL resource creation will be spread out over several frames or block until all WebGL resources are created.
|
|
34
|
+
*/
|
|
35
|
+
constructor(options) {
|
|
36
|
+
super();
|
|
37
|
+
|
|
38
|
+
options = options ?? Frozen.EMPTY_OBJECT;
|
|
39
|
+
const resourceCache = options.resourceCache;
|
|
40
|
+
const gltf = options.gltf;
|
|
41
|
+
const textureInfo = options.textureInfo;
|
|
42
|
+
const gltfResource = options.gltfResource;
|
|
43
|
+
const baseResource = options.baseResource;
|
|
44
|
+
const supportedImageFormats = options.supportedImageFormats;
|
|
45
|
+
const cacheKey = options.cacheKey;
|
|
46
|
+
const asynchronous = options.asynchronous ?? true;
|
|
47
|
+
|
|
48
|
+
//>>includeStart('debug', pragmas.debug);
|
|
49
|
+
Check.typeOf.func("options.resourceCache", resourceCache);
|
|
50
|
+
Check.typeOf.object("options.gltf", gltf);
|
|
51
|
+
Check.typeOf.object("options.textureInfo", textureInfo);
|
|
52
|
+
Check.typeOf.object("options.gltfResource", gltfResource);
|
|
53
|
+
Check.typeOf.object("options.baseResource", baseResource);
|
|
54
|
+
Check.typeOf.object("options.supportedImageFormats", supportedImageFormats);
|
|
55
|
+
//>>includeEnd('debug');
|
|
56
|
+
|
|
57
|
+
const textureId = textureInfo.index;
|
|
58
|
+
|
|
59
|
+
// imageId is guaranteed to be defined otherwise the GltfTextureLoader
|
|
60
|
+
// wouldn't have been created
|
|
61
|
+
const imageId = GltfLoaderUtil.getImageIdFromTexture({
|
|
62
|
+
gltf: gltf,
|
|
63
|
+
textureId: textureId,
|
|
64
|
+
supportedImageFormats: supportedImageFormats,
|
|
65
|
+
});
|
|
82
66
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
67
|
+
this._resourceCache = resourceCache;
|
|
68
|
+
this._gltf = gltf;
|
|
69
|
+
this._textureInfo = textureInfo;
|
|
70
|
+
this._imageId = imageId;
|
|
71
|
+
this._gltfResource = gltfResource;
|
|
72
|
+
this._baseResource = baseResource;
|
|
73
|
+
this._cacheKey = cacheKey;
|
|
74
|
+
this._asynchronous = asynchronous;
|
|
75
|
+
this._imageLoader = undefined;
|
|
76
|
+
this._image = undefined;
|
|
77
|
+
this._mipLevels = undefined;
|
|
78
|
+
this._texture = undefined;
|
|
79
|
+
this._state = ResourceLoaderState.UNLOADED;
|
|
80
|
+
this._promise = undefined;
|
|
81
|
+
}
|
|
87
82
|
|
|
88
|
-
Object.defineProperties(GltfTextureLoader.prototype, {
|
|
89
83
|
/**
|
|
90
84
|
* The cache key of the resource.
|
|
91
85
|
*
|
|
@@ -95,11 +89,10 @@ Object.defineProperties(GltfTextureLoader.prototype, {
|
|
|
95
89
|
* @readonly
|
|
96
90
|
* @private
|
|
97
91
|
*/
|
|
98
|
-
cacheKey
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
},
|
|
92
|
+
get cacheKey() {
|
|
93
|
+
return this._cacheKey;
|
|
94
|
+
}
|
|
95
|
+
|
|
103
96
|
/**
|
|
104
97
|
* The texture.
|
|
105
98
|
*
|
|
@@ -109,99 +102,148 @@ Object.defineProperties(GltfTextureLoader.prototype, {
|
|
|
109
102
|
* @readonly
|
|
110
103
|
* @private
|
|
111
104
|
*/
|
|
112
|
-
texture
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
});
|
|
105
|
+
get texture() {
|
|
106
|
+
return this._texture;
|
|
107
|
+
}
|
|
118
108
|
|
|
119
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Loads the resource.
|
|
111
|
+
* @returns {Promise<GltfDracoLoader>} A promise which resolves to the loader when the resource loading is completed.
|
|
112
|
+
* @private
|
|
113
|
+
*/
|
|
114
|
+
async load() {
|
|
115
|
+
if (defined(this._promise)) {
|
|
116
|
+
return this._promise;
|
|
117
|
+
}
|
|
120
118
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
gltf: loader._gltf,
|
|
126
|
-
imageId: loader._imageId,
|
|
127
|
-
gltfResource: loader._gltfResource,
|
|
128
|
-
baseResource: loader._baseResource,
|
|
129
|
-
});
|
|
130
|
-
loader._imageLoader = imageLoader;
|
|
131
|
-
await imageLoader.load();
|
|
119
|
+
this._state = ResourceLoaderState.LOADING;
|
|
120
|
+
this._promise = loadResources(this);
|
|
121
|
+
return this._promise;
|
|
122
|
+
}
|
|
132
123
|
|
|
133
|
-
|
|
134
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Processes the resource until it becomes ready.
|
|
126
|
+
*
|
|
127
|
+
* @param {FrameState} frameState The frame state.
|
|
128
|
+
* @returns {boolean} true once all resourced are ready.
|
|
129
|
+
* @private
|
|
130
|
+
*/
|
|
131
|
+
process(frameState) {
|
|
132
|
+
//>>includeStart('debug', pragmas.debug);
|
|
133
|
+
Check.typeOf.object("frameState", frameState);
|
|
134
|
+
//>>includeEnd('debug');
|
|
135
|
+
|
|
136
|
+
if (this._state === ResourceLoaderState.READY) {
|
|
137
|
+
return true;
|
|
135
138
|
}
|
|
136
139
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
if (
|
|
141
|
+
this._state !== ResourceLoaderState.LOADED &&
|
|
142
|
+
this._state !== ResourceLoaderState.PROCESSING
|
|
143
|
+
) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
141
146
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
return;
|
|
147
|
+
if (defined(this._texture)) {
|
|
148
|
+
// Already created texture
|
|
149
|
+
return false;
|
|
146
150
|
}
|
|
147
151
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
if (!defined(this._image)) {
|
|
153
|
+
// Not ready to create texture
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
this._state = ResourceLoaderState.PROCESSING;
|
|
158
|
+
|
|
159
|
+
let texture;
|
|
160
|
+
if (this._asynchronous) {
|
|
161
|
+
const textureJob = scratchTextureJob;
|
|
162
|
+
textureJob.set(
|
|
163
|
+
this._gltf,
|
|
164
|
+
this._textureInfo,
|
|
165
|
+
this._cacheKey,
|
|
166
|
+
this._image,
|
|
167
|
+
this._mipLevels,
|
|
168
|
+
frameState.context,
|
|
169
|
+
);
|
|
170
|
+
const jobScheduler = frameState.jobScheduler;
|
|
171
|
+
if (!jobScheduler.execute(textureJob, JobType.TEXTURE)) {
|
|
172
|
+
// Job scheduler is full. Try again next frame.
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
texture = textureJob.texture;
|
|
176
|
+
} else {
|
|
177
|
+
texture = createTexture(
|
|
178
|
+
this._gltf,
|
|
179
|
+
this._textureInfo,
|
|
180
|
+
this._cacheKey,
|
|
181
|
+
this._image,
|
|
182
|
+
this._mipLevels,
|
|
183
|
+
frameState.context,
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Unload everything except the texture
|
|
188
|
+
this.unload();
|
|
189
|
+
|
|
190
|
+
this._texture = texture;
|
|
191
|
+
this._state = ResourceLoaderState.READY;
|
|
192
|
+
this._resourceCache.statistics.addTextureLoader(this);
|
|
193
|
+
return true;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Unloads the resource.
|
|
198
|
+
* @private
|
|
199
|
+
*/
|
|
200
|
+
unload() {
|
|
201
|
+
if (defined(this._texture)) {
|
|
202
|
+
this._texture.destroy();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (defined(this._imageLoader) && !this._imageLoader.isDestroyed()) {
|
|
206
|
+
this._resourceCache.unload(this._imageLoader);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
this._imageLoader = undefined;
|
|
210
|
+
this._image = undefined;
|
|
211
|
+
this._mipLevels = undefined;
|
|
212
|
+
this._texture = undefined;
|
|
213
|
+
this._gltf = undefined;
|
|
152
214
|
}
|
|
153
215
|
}
|
|
154
216
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
217
|
+
class CreateTextureJob {
|
|
218
|
+
constructor() {
|
|
219
|
+
this.gltf = undefined;
|
|
220
|
+
this.textureInfo = undefined;
|
|
221
|
+
this.textureId = undefined;
|
|
222
|
+
this.image = undefined;
|
|
223
|
+
this.context = undefined;
|
|
224
|
+
this.texture = undefined;
|
|
163
225
|
}
|
|
164
226
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this.textureId = undefined;
|
|
174
|
-
this.image = undefined;
|
|
175
|
-
this.context = undefined;
|
|
176
|
-
this.texture = undefined;
|
|
177
|
-
}
|
|
227
|
+
set(gltf, textureInfo, textureId, image, mipLevels, context) {
|
|
228
|
+
this.gltf = gltf;
|
|
229
|
+
this.textureInfo = textureInfo;
|
|
230
|
+
this.textureId = textureId;
|
|
231
|
+
this.image = image;
|
|
232
|
+
this.mipLevels = mipLevels;
|
|
233
|
+
this.context = context;
|
|
234
|
+
}
|
|
178
235
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
this.image = image;
|
|
191
|
-
this.mipLevels = mipLevels;
|
|
192
|
-
this.context = context;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
CreateTextureJob.prototype.execute = function () {
|
|
196
|
-
this.texture = createTexture(
|
|
197
|
-
this.gltf,
|
|
198
|
-
this.textureInfo,
|
|
199
|
-
this.textureId,
|
|
200
|
-
this.image,
|
|
201
|
-
this.mipLevels,
|
|
202
|
-
this.context,
|
|
203
|
-
);
|
|
204
|
-
};
|
|
236
|
+
execute() {
|
|
237
|
+
this.texture = createTexture(
|
|
238
|
+
this.gltf,
|
|
239
|
+
this.textureInfo,
|
|
240
|
+
this.textureId,
|
|
241
|
+
this.image,
|
|
242
|
+
this.mipLevels,
|
|
243
|
+
this.context,
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
205
247
|
|
|
206
248
|
function createTexture(
|
|
207
249
|
gltf,
|
|
@@ -304,96 +346,40 @@ function createTexture(
|
|
|
304
346
|
return texture;
|
|
305
347
|
}
|
|
306
348
|
|
|
307
|
-
|
|
308
|
-
* Processes the resource until it becomes ready.
|
|
309
|
-
*
|
|
310
|
-
* @param {FrameState} frameState The frame state.
|
|
311
|
-
* @returns {boolean} true once all resourced are ready.
|
|
312
|
-
* @private
|
|
313
|
-
*/
|
|
314
|
-
GltfTextureLoader.prototype.process = function (frameState) {
|
|
315
|
-
//>>includeStart('debug', pragmas.debug);
|
|
316
|
-
Check.typeOf.object("frameState", frameState);
|
|
317
|
-
//>>includeEnd('debug');
|
|
318
|
-
|
|
319
|
-
if (this._state === ResourceLoaderState.READY) {
|
|
320
|
-
return true;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
if (
|
|
324
|
-
this._state !== ResourceLoaderState.LOADED &&
|
|
325
|
-
this._state !== ResourceLoaderState.PROCESSING
|
|
326
|
-
) {
|
|
327
|
-
return false;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
if (defined(this._texture)) {
|
|
331
|
-
// Already created texture
|
|
332
|
-
return false;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
if (!defined(this._image)) {
|
|
336
|
-
// Not ready to create texture
|
|
337
|
-
return false;
|
|
338
|
-
}
|
|
349
|
+
const scratchTextureJob = new CreateTextureJob();
|
|
339
350
|
|
|
340
|
-
|
|
351
|
+
async function loadResources(loader) {
|
|
352
|
+
const resourceCache = loader._resourceCache;
|
|
353
|
+
try {
|
|
354
|
+
const imageLoader = resourceCache.getImageLoader({
|
|
355
|
+
gltf: loader._gltf,
|
|
356
|
+
imageId: loader._imageId,
|
|
357
|
+
gltfResource: loader._gltfResource,
|
|
358
|
+
baseResource: loader._baseResource,
|
|
359
|
+
});
|
|
360
|
+
loader._imageLoader = imageLoader;
|
|
361
|
+
await imageLoader.load();
|
|
341
362
|
|
|
342
|
-
|
|
343
|
-
if (this._asynchronous) {
|
|
344
|
-
const textureJob = scratchTextureJob;
|
|
345
|
-
textureJob.set(
|
|
346
|
-
this._gltf,
|
|
347
|
-
this._textureInfo,
|
|
348
|
-
this._cacheKey,
|
|
349
|
-
this._image,
|
|
350
|
-
this._mipLevels,
|
|
351
|
-
frameState.context,
|
|
352
|
-
);
|
|
353
|
-
const jobScheduler = frameState.jobScheduler;
|
|
354
|
-
if (!jobScheduler.execute(textureJob, JobType.TEXTURE)) {
|
|
355
|
-
// Job scheduler is full. Try again next frame.
|
|
363
|
+
if (loader.isDestroyed()) {
|
|
356
364
|
return;
|
|
357
365
|
}
|
|
358
|
-
texture = textureJob.texture;
|
|
359
|
-
} else {
|
|
360
|
-
texture = createTexture(
|
|
361
|
-
this._gltf,
|
|
362
|
-
this._textureInfo,
|
|
363
|
-
this._cacheKey,
|
|
364
|
-
this._image,
|
|
365
|
-
this._mipLevels,
|
|
366
|
-
frameState.context,
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// Unload everything except the texture
|
|
371
|
-
this.unload();
|
|
372
366
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
};
|
|
367
|
+
// Now wait for process() to run to finish loading
|
|
368
|
+
loader._image = imageLoader.image;
|
|
369
|
+
loader._mipLevels = imageLoader.mipLevels;
|
|
370
|
+
loader._state = ResourceLoaderState.LOADED;
|
|
378
371
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
if (defined(this._texture)) {
|
|
385
|
-
this._texture.destroy();
|
|
386
|
-
}
|
|
372
|
+
return loader;
|
|
373
|
+
} catch (error) {
|
|
374
|
+
if (loader.isDestroyed()) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
387
377
|
|
|
388
|
-
|
|
389
|
-
|
|
378
|
+
loader.unload();
|
|
379
|
+
loader._state = ResourceLoaderState.FAILED;
|
|
380
|
+
const errorMessage = "Failed to load texture";
|
|
381
|
+
throw loader.getError(errorMessage, error);
|
|
390
382
|
}
|
|
391
|
-
|
|
392
|
-
this._imageLoader = undefined;
|
|
393
|
-
this._image = undefined;
|
|
394
|
-
this._mipLevels = undefined;
|
|
395
|
-
this._texture = undefined;
|
|
396
|
-
this._gltf = undefined;
|
|
397
|
-
};
|
|
383
|
+
}
|
|
398
384
|
|
|
399
385
|
export default GltfTextureLoader;
|