@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
|
@@ -17,127 +17,121 @@ import CesiumMath from "../Core/Math.js";
|
|
|
17
17
|
* Implements the {@link ResourceLoader} interface.
|
|
18
18
|
* </p>
|
|
19
19
|
*
|
|
20
|
-
* @alias GltfVertexBufferLoader
|
|
21
|
-
* @constructor
|
|
22
|
-
* @augments ResourceLoader
|
|
23
|
-
*
|
|
24
|
-
* @param {object} options Object with the following properties:
|
|
25
|
-
* @param {ResourceCache} options.resourceCache The {@link ResourceCache} (to avoid circular dependencies).
|
|
26
|
-
* @param {object} options.gltf The glTF JSON.
|
|
27
|
-
* @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
|
|
28
|
-
* @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
|
|
29
|
-
* @param {number} [options.bufferViewId] The bufferView ID corresponding to the vertex buffer.
|
|
30
|
-
* @param {object} [options.primitive] The primitive containing the Draco extension.
|
|
31
|
-
* @param {object} [options.draco] The Draco extension object.
|
|
32
|
-
* @param {string} [options.attributeSemantic] The attribute semantic, e.g. POSITION or NORMAL.
|
|
33
|
-
* @param {number} [options.accessorId] The accessor id.
|
|
34
|
-
* @param {string} [options.cacheKey] The cache key of the resource.
|
|
35
|
-
* @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.
|
|
36
|
-
* @param {boolean} [options.loadBuffer=false] Load vertex buffer as a GPU vertex buffer.
|
|
37
|
-
* @param {boolean} [options.loadTypedArray=false] Load vertex buffer as a typed array.
|
|
38
|
-
*
|
|
39
|
-
* @exception {DeveloperError} One of options.bufferViewId and options.draco must be defined.
|
|
40
|
-
* @exception {DeveloperError} When options.draco is defined options.attributeSemantic must also be defined.
|
|
41
|
-
* @exception {DeveloperError} When options.draco is defined options.accessorId must also be defined.
|
|
42
|
-
*
|
|
43
20
|
* @private
|
|
44
21
|
*/
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
22
|
+
class GltfVertexBufferLoader extends ResourceLoader {
|
|
23
|
+
/**
|
|
24
|
+
* @param {object} options Object with the following properties:
|
|
25
|
+
* @param {ResourceCache} options.resourceCache The {@link ResourceCache} (to avoid circular dependencies).
|
|
26
|
+
* @param {object} options.gltf The glTF JSON.
|
|
27
|
+
* @param {Resource} options.gltfResource The {@link Resource} containing the glTF.
|
|
28
|
+
* @param {Resource} options.baseResource The {@link Resource} that paths in the glTF JSON are relative to.
|
|
29
|
+
* @param {number} [options.bufferViewId] The bufferView ID corresponding to the vertex buffer.
|
|
30
|
+
* @param {object} [options.primitive] The primitive containing the Draco extension.
|
|
31
|
+
* @param {object} [options.draco] The Draco extension object.
|
|
32
|
+
* @param {string} [options.attributeSemantic] The attribute semantic, e.g. POSITION or NORMAL.
|
|
33
|
+
* @param {number} [options.accessorId] The accessor id.
|
|
34
|
+
* @param {string} [options.cacheKey] The cache key of the resource.
|
|
35
|
+
* @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.
|
|
36
|
+
* @param {boolean} [options.loadBuffer=false] Load vertex buffer as a GPU vertex buffer.
|
|
37
|
+
* @param {boolean} [options.loadTypedArray=false] Load vertex buffer as a typed array.
|
|
38
|
+
*
|
|
39
|
+
* @exception {DeveloperError} One of options.bufferViewId and options.draco must be defined.
|
|
40
|
+
* @exception {DeveloperError} When options.draco is defined options.attributeSemantic must also be defined.
|
|
41
|
+
* @exception {DeveloperError} When options.draco is defined options.accessorId must also be defined.
|
|
42
|
+
*/
|
|
43
|
+
constructor(options) {
|
|
44
|
+
super();
|
|
45
|
+
|
|
46
|
+
options = options ?? Frozen.EMPTY_OBJECT;
|
|
47
|
+
const resourceCache = options.resourceCache;
|
|
48
|
+
const gltf = options.gltf;
|
|
49
|
+
const gltfResource = options.gltfResource;
|
|
50
|
+
const baseResource = options.baseResource;
|
|
51
|
+
const bufferViewId = options.bufferViewId;
|
|
52
|
+
const primitive = options.primitive;
|
|
53
|
+
const draco = options.draco;
|
|
54
|
+
const attributeSemantic = options.attributeSemantic;
|
|
55
|
+
const accessorId = options.accessorId;
|
|
56
|
+
const cacheKey = options.cacheKey;
|
|
57
|
+
const spz = options.spz;
|
|
58
|
+
const asynchronous = options.asynchronous ?? true;
|
|
59
|
+
const loadBuffer = options.loadBuffer ?? false;
|
|
60
|
+
const loadTypedArray = options.loadTypedArray ?? false;
|
|
61
|
+
|
|
62
|
+
//>>includeStart('debug', pragmas.debug);
|
|
63
|
+
Check.typeOf.func("options.resourceCache", resourceCache);
|
|
64
|
+
Check.typeOf.object("options.gltf", gltf);
|
|
65
|
+
Check.typeOf.object("options.gltfResource", gltfResource);
|
|
66
|
+
Check.typeOf.object("options.baseResource", baseResource);
|
|
67
|
+
if (!loadBuffer && !loadTypedArray) {
|
|
68
|
+
throw new DeveloperError(
|
|
69
|
+
"At least one of loadBuffer and loadTypedArray must be true.",
|
|
70
|
+
);
|
|
71
|
+
}
|
|
84
72
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
89
|
-
|
|
73
|
+
const hasBufferViewId = defined(bufferViewId);
|
|
74
|
+
const hasPrimitive = defined(primitive);
|
|
75
|
+
const hasDraco = hasDracoCompression(draco, attributeSemantic);
|
|
76
|
+
const hasAttributeSemantic = defined(attributeSemantic);
|
|
77
|
+
const hasAccessorId = defined(accessorId);
|
|
78
|
+
const hasSpz = defined(spz);
|
|
79
|
+
if (hasBufferViewId === (hasDraco !== hasSpz)) {
|
|
80
|
+
throw new DeveloperError(
|
|
81
|
+
"One of options.bufferViewId, options.draco, or options.spz must be defined.",
|
|
82
|
+
);
|
|
83
|
+
}
|
|
90
84
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
85
|
+
if (hasDraco && !hasAttributeSemantic) {
|
|
86
|
+
throw new DeveloperError(
|
|
87
|
+
"When options.draco is defined options.attributeSemantic must also be defined.",
|
|
88
|
+
);
|
|
89
|
+
}
|
|
96
90
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
91
|
+
if (hasDraco && !hasAccessorId) {
|
|
92
|
+
throw new DeveloperError(
|
|
93
|
+
"When options.draco is defined options.accessorId must also be defined.",
|
|
94
|
+
);
|
|
95
|
+
}
|
|
102
96
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
97
|
+
if (hasDraco && !hasPrimitive) {
|
|
98
|
+
throw new DeveloperError(
|
|
99
|
+
"When options.draco is defined options.primitive must also be defined.",
|
|
100
|
+
);
|
|
101
|
+
}
|
|
109
102
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
this._bufferViewId = bufferViewId;
|
|
117
|
-
this._primitive = primitive;
|
|
118
|
-
this._draco = draco;
|
|
119
|
-
this._spz = spz;
|
|
120
|
-
this._attributeSemantic = attributeSemantic;
|
|
121
|
-
this._accessorId = accessorId;
|
|
122
|
-
this._cacheKey = cacheKey;
|
|
123
|
-
this._asynchronous = asynchronous;
|
|
124
|
-
this._loadBuffer = loadBuffer;
|
|
125
|
-
this._loadTypedArray = loadTypedArray;
|
|
126
|
-
this._bufferViewLoader = undefined;
|
|
127
|
-
this._dracoLoader = undefined;
|
|
128
|
-
this._quantization = undefined;
|
|
129
|
-
this._typedArray = undefined;
|
|
130
|
-
this._buffer = undefined;
|
|
131
|
-
this._state = ResourceLoaderState.UNLOADED;
|
|
132
|
-
this._promise = undefined;
|
|
133
|
-
}
|
|
103
|
+
if (hasDraco) {
|
|
104
|
+
Check.typeOf.object("options.primitive", primitive);
|
|
105
|
+
Check.typeOf.object("options.draco", draco);
|
|
106
|
+
Check.typeOf.string("options.attributeSemantic", attributeSemantic);
|
|
107
|
+
Check.typeOf.number("options.accessorId", accessorId);
|
|
108
|
+
}
|
|
134
109
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
110
|
+
//>>includeEnd('debug');
|
|
111
|
+
|
|
112
|
+
this._resourceCache = resourceCache;
|
|
113
|
+
this._gltfResource = gltfResource;
|
|
114
|
+
this._baseResource = baseResource;
|
|
115
|
+
this._gltf = gltf;
|
|
116
|
+
this._bufferViewId = bufferViewId;
|
|
117
|
+
this._primitive = primitive;
|
|
118
|
+
this._draco = draco;
|
|
119
|
+
this._spz = spz;
|
|
120
|
+
this._attributeSemantic = attributeSemantic;
|
|
121
|
+
this._accessorId = accessorId;
|
|
122
|
+
this._cacheKey = cacheKey;
|
|
123
|
+
this._asynchronous = asynchronous;
|
|
124
|
+
this._loadBuffer = loadBuffer;
|
|
125
|
+
this._loadTypedArray = loadTypedArray;
|
|
126
|
+
this._bufferViewLoader = undefined;
|
|
127
|
+
this._dracoLoader = undefined;
|
|
128
|
+
this._quantization = undefined;
|
|
129
|
+
this._typedArray = undefined;
|
|
130
|
+
this._buffer = undefined;
|
|
131
|
+
this._state = ResourceLoaderState.UNLOADED;
|
|
132
|
+
this._promise = undefined;
|
|
133
|
+
}
|
|
139
134
|
|
|
140
|
-
Object.defineProperties(GltfVertexBufferLoader.prototype, {
|
|
141
135
|
/**
|
|
142
136
|
* The cache key of the resource.
|
|
143
137
|
*
|
|
@@ -147,11 +141,10 @@ Object.defineProperties(GltfVertexBufferLoader.prototype, {
|
|
|
147
141
|
* @readonly
|
|
148
142
|
* @private
|
|
149
143
|
*/
|
|
150
|
-
cacheKey
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
},
|
|
144
|
+
get cacheKey() {
|
|
145
|
+
return this._cacheKey;
|
|
146
|
+
}
|
|
147
|
+
|
|
155
148
|
/**
|
|
156
149
|
* The vertex buffer. This is only defined when <code>loadAsTypedArray</code> is false.
|
|
157
150
|
*
|
|
@@ -161,11 +154,10 @@ Object.defineProperties(GltfVertexBufferLoader.prototype, {
|
|
|
161
154
|
* @readonly
|
|
162
155
|
* @private
|
|
163
156
|
*/
|
|
164
|
-
buffer
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
},
|
|
157
|
+
get buffer() {
|
|
158
|
+
return this._buffer;
|
|
159
|
+
}
|
|
160
|
+
|
|
169
161
|
/**
|
|
170
162
|
* The typed array containing vertex buffer data. This is only defined when <code>loadAsTypedArray</code> is true.
|
|
171
163
|
*
|
|
@@ -175,11 +167,10 @@ Object.defineProperties(GltfVertexBufferLoader.prototype, {
|
|
|
175
167
|
* @readonly
|
|
176
168
|
* @private
|
|
177
169
|
*/
|
|
178
|
-
typedArray
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
},
|
|
170
|
+
get typedArray() {
|
|
171
|
+
return this._typedArray;
|
|
172
|
+
}
|
|
173
|
+
|
|
183
174
|
/**
|
|
184
175
|
* Information about the quantized vertex attribute after Draco decode.
|
|
185
176
|
*
|
|
@@ -189,44 +180,150 @@ Object.defineProperties(GltfVertexBufferLoader.prototype, {
|
|
|
189
180
|
* @readonly
|
|
190
181
|
* @private
|
|
191
182
|
*/
|
|
192
|
-
quantization
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
},
|
|
196
|
-
},
|
|
197
|
-
});
|
|
183
|
+
get quantization() {
|
|
184
|
+
return this._quantization;
|
|
185
|
+
}
|
|
198
186
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
)
|
|
205
|
-
|
|
187
|
+
/**
|
|
188
|
+
* Loads the resource.
|
|
189
|
+
* @returns {Promise<GltfVertexBufferLoader>} A promise which resolves to the loader when the resource loading is completed.
|
|
190
|
+
* @private
|
|
191
|
+
*/
|
|
192
|
+
async load() {
|
|
193
|
+
if (defined(this._promise)) {
|
|
194
|
+
return this._promise;
|
|
195
|
+
}
|
|
206
196
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
197
|
+
if (defined(this._spz)) {
|
|
198
|
+
this._promise = loadFromSpz(this);
|
|
199
|
+
return this._promise;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (hasDracoCompression(this._draco, this._attributeSemantic)) {
|
|
203
|
+
this._promise = loadFromDraco(this);
|
|
204
|
+
return this._promise;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
this._promise = loadFromBufferView(this);
|
|
214
208
|
return this._promise;
|
|
215
209
|
}
|
|
216
210
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
211
|
+
/**
|
|
212
|
+
* Processes the resource until it becomes ready.
|
|
213
|
+
*
|
|
214
|
+
* @param {FrameState} frameState The frame state.
|
|
215
|
+
* @private
|
|
216
|
+
*/
|
|
217
|
+
process(frameState) {
|
|
218
|
+
//>>includeStart('debug', pragmas.debug);
|
|
219
|
+
Check.typeOf.object("frameState", frameState);
|
|
220
|
+
//>>includeEnd('debug');
|
|
221
|
+
|
|
222
|
+
if (this._state === ResourceLoaderState.READY) {
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (
|
|
227
|
+
this._state !== ResourceLoaderState.LOADED &&
|
|
228
|
+
this._state !== ResourceLoaderState.PROCESSING
|
|
229
|
+
) {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (defined(this._dracoLoader)) {
|
|
234
|
+
try {
|
|
235
|
+
const ready = this._dracoLoader.process(frameState);
|
|
236
|
+
if (!ready) {
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
} catch (error) {
|
|
240
|
+
handleError(this, error);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
processDraco(this);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (defined(this._spzLoader)) {
|
|
247
|
+
try {
|
|
248
|
+
const ready = this._spzLoader.process(frameState);
|
|
249
|
+
if (!ready) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
} catch (error) {
|
|
253
|
+
handleError(this, error);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
processSpz(this);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
let buffer;
|
|
260
|
+
const typedArray = this._typedArray;
|
|
261
|
+
if (this._loadBuffer && this._asynchronous) {
|
|
262
|
+
const vertexBufferJob = scratchVertexBufferJob;
|
|
263
|
+
vertexBufferJob.set(typedArray, frameState.context);
|
|
264
|
+
const jobScheduler = frameState.jobScheduler;
|
|
265
|
+
if (!jobScheduler.execute(vertexBufferJob, JobType.BUFFER)) {
|
|
266
|
+
// Job scheduler is full. Try again next frame.
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
buffer = vertexBufferJob.buffer;
|
|
270
|
+
} else if (this._loadBuffer) {
|
|
271
|
+
buffer = createVertexBuffer(typedArray, frameState.context);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Unload everything except the vertex buffer
|
|
275
|
+
this.unload();
|
|
276
|
+
|
|
277
|
+
this._buffer = buffer;
|
|
278
|
+
this._typedArray = this._loadTypedArray ? typedArray : undefined;
|
|
279
|
+
this._state = ResourceLoaderState.READY;
|
|
280
|
+
this._resourceCache.statistics.addGeometryLoader(this);
|
|
281
|
+
return true;
|
|
220
282
|
}
|
|
221
283
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
284
|
+
/**
|
|
285
|
+
* Unloads the resource.
|
|
286
|
+
* @private
|
|
287
|
+
*/
|
|
288
|
+
unload() {
|
|
289
|
+
if (defined(this._buffer)) {
|
|
290
|
+
this._buffer.destroy();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const resourceCache = this._resourceCache;
|
|
294
|
+
|
|
295
|
+
if (
|
|
296
|
+
defined(this._bufferViewLoader) &&
|
|
297
|
+
!this._bufferViewLoader.isDestroyed()
|
|
298
|
+
) {
|
|
299
|
+
resourceCache.unload(this._bufferViewLoader);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (defined(this._dracoLoader)) {
|
|
303
|
+
resourceCache.unload(this._dracoLoader);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (defined(this._spzLoader)) {
|
|
307
|
+
resourceCache.unload(this._spzLoader);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
this._bufferViewLoader = undefined;
|
|
311
|
+
this._dracoLoader = undefined;
|
|
312
|
+
this._spzLoader = undefined;
|
|
313
|
+
this._typedArray = undefined;
|
|
314
|
+
this._buffer = undefined;
|
|
315
|
+
this._gltf = undefined;
|
|
316
|
+
this._primitive = undefined;
|
|
225
317
|
}
|
|
318
|
+
}
|
|
226
319
|
|
|
227
|
-
|
|
228
|
-
return
|
|
229
|
-
|
|
320
|
+
function hasDracoCompression(draco, semantic) {
|
|
321
|
+
return (
|
|
322
|
+
defined(draco) &&
|
|
323
|
+
defined(draco.attributes) &&
|
|
324
|
+
defined(draco.attributes[semantic])
|
|
325
|
+
);
|
|
326
|
+
}
|
|
230
327
|
|
|
231
328
|
function getQuantizationInformation(
|
|
232
329
|
dracoQuantization,
|
|
@@ -496,20 +593,22 @@ function handleError(vertexBufferLoader, error) {
|
|
|
496
593
|
throw vertexBufferLoader.getError(errorMessage, error);
|
|
497
594
|
}
|
|
498
595
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
596
|
+
class CreateVertexBufferJob {
|
|
597
|
+
constructor() {
|
|
598
|
+
this.typedArray = undefined;
|
|
599
|
+
this.context = undefined;
|
|
600
|
+
this.buffer = undefined;
|
|
601
|
+
}
|
|
504
602
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
}
|
|
603
|
+
set(typedArray, context) {
|
|
604
|
+
this.typedArray = typedArray;
|
|
605
|
+
this.context = context;
|
|
606
|
+
}
|
|
509
607
|
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
608
|
+
execute() {
|
|
609
|
+
this.buffer = createVertexBuffer(this.typedArray, this.context);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
513
612
|
|
|
514
613
|
function createVertexBuffer(typedArray, context) {
|
|
515
614
|
const buffer = Buffer.createVertexBuffer({
|
|
@@ -523,112 +622,4 @@ function createVertexBuffer(typedArray, context) {
|
|
|
523
622
|
|
|
524
623
|
const scratchVertexBufferJob = new CreateVertexBufferJob();
|
|
525
624
|
|
|
526
|
-
/**
|
|
527
|
-
* Processes the resource until it becomes ready.
|
|
528
|
-
*
|
|
529
|
-
* @param {FrameState} frameState The frame state.
|
|
530
|
-
* @private
|
|
531
|
-
*/
|
|
532
|
-
GltfVertexBufferLoader.prototype.process = function (frameState) {
|
|
533
|
-
//>>includeStart('debug', pragmas.debug);
|
|
534
|
-
Check.typeOf.object("frameState", frameState);
|
|
535
|
-
//>>includeEnd('debug');
|
|
536
|
-
|
|
537
|
-
if (this._state === ResourceLoaderState.READY) {
|
|
538
|
-
return true;
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
if (
|
|
542
|
-
this._state !== ResourceLoaderState.LOADED &&
|
|
543
|
-
this._state !== ResourceLoaderState.PROCESSING
|
|
544
|
-
) {
|
|
545
|
-
return false;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
if (defined(this._dracoLoader)) {
|
|
549
|
-
try {
|
|
550
|
-
const ready = this._dracoLoader.process(frameState);
|
|
551
|
-
if (!ready) {
|
|
552
|
-
return false;
|
|
553
|
-
}
|
|
554
|
-
} catch (error) {
|
|
555
|
-
handleError(this, error);
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
processDraco(this);
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
if (defined(this._spzLoader)) {
|
|
562
|
-
try {
|
|
563
|
-
const ready = this._spzLoader.process(frameState);
|
|
564
|
-
if (!ready) {
|
|
565
|
-
return false;
|
|
566
|
-
}
|
|
567
|
-
} catch (error) {
|
|
568
|
-
handleError(this, error);
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
processSpz(this);
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
let buffer;
|
|
575
|
-
const typedArray = this._typedArray;
|
|
576
|
-
if (this._loadBuffer && this._asynchronous) {
|
|
577
|
-
const vertexBufferJob = scratchVertexBufferJob;
|
|
578
|
-
vertexBufferJob.set(typedArray, frameState.context);
|
|
579
|
-
const jobScheduler = frameState.jobScheduler;
|
|
580
|
-
if (!jobScheduler.execute(vertexBufferJob, JobType.BUFFER)) {
|
|
581
|
-
// Job scheduler is full. Try again next frame.
|
|
582
|
-
return false;
|
|
583
|
-
}
|
|
584
|
-
buffer = vertexBufferJob.buffer;
|
|
585
|
-
} else if (this._loadBuffer) {
|
|
586
|
-
buffer = createVertexBuffer(typedArray, frameState.context);
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
// Unload everything except the vertex buffer
|
|
590
|
-
this.unload();
|
|
591
|
-
|
|
592
|
-
this._buffer = buffer;
|
|
593
|
-
this._typedArray = this._loadTypedArray ? typedArray : undefined;
|
|
594
|
-
this._state = ResourceLoaderState.READY;
|
|
595
|
-
this._resourceCache.statistics.addGeometryLoader(this);
|
|
596
|
-
return true;
|
|
597
|
-
};
|
|
598
|
-
|
|
599
|
-
/**
|
|
600
|
-
* Unloads the resource.
|
|
601
|
-
* @private
|
|
602
|
-
*/
|
|
603
|
-
GltfVertexBufferLoader.prototype.unload = function () {
|
|
604
|
-
if (defined(this._buffer)) {
|
|
605
|
-
this._buffer.destroy();
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
const resourceCache = this._resourceCache;
|
|
609
|
-
|
|
610
|
-
if (
|
|
611
|
-
defined(this._bufferViewLoader) &&
|
|
612
|
-
!this._bufferViewLoader.isDestroyed()
|
|
613
|
-
) {
|
|
614
|
-
resourceCache.unload(this._bufferViewLoader);
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
if (defined(this._dracoLoader)) {
|
|
618
|
-
resourceCache.unload(this._dracoLoader);
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
if (defined(this._spzLoader)) {
|
|
622
|
-
resourceCache.unload(this._spzLoader);
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
this._bufferViewLoader = undefined;
|
|
626
|
-
this._dracoLoader = undefined;
|
|
627
|
-
this._spzLoader = undefined;
|
|
628
|
-
this._typedArray = undefined;
|
|
629
|
-
this._buffer = undefined;
|
|
630
|
-
this._gltf = undefined;
|
|
631
|
-
this._primitive = undefined;
|
|
632
|
-
};
|
|
633
|
-
|
|
634
625
|
export default GltfVertexBufferLoader;
|