@cesium/engine 14.0.0 → 15.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-EWDGNOJE.js → chunk-25TOENEE.js} +7 -7
- package/Build/Workers/{chunk-OMXHEJTK.js → chunk-2AVIUB5H.js} +2 -2
- package/Build/Workers/{chunk-LJBJM6VI.js → chunk-3JZGPJMZ.js} +6 -6
- package/Build/Workers/{chunk-DT5NFR5C.js → chunk-3LHBH4TC.js} +7 -7
- package/Build/Workers/{chunk-3QLSKXKF.js → chunk-3LZF23RY.js} +6 -6
- package/Build/Workers/{chunk-ED6GLQTK.js → chunk-5S2B46UQ.js} +1 -1
- package/Build/Workers/{chunk-B4GSRXE3.js → chunk-67ONR44K.js} +6 -6
- package/Build/Workers/{chunk-LOZ4NKY3.js → chunk-6EDBC234.js} +11 -11
- package/Build/Workers/{chunk-7ZB2RVIQ.js → chunk-6EV4VOET.js} +10 -10
- package/Build/Workers/{chunk-KHWLAQVA.js → chunk-7ITUZTFH.js} +1 -1
- package/Build/Workers/{chunk-JHBPC4LK.js → chunk-ARVZCY6X.js} +7 -7
- package/Build/Workers/{chunk-FFBJDW4A.js → chunk-B2UQN3DH.js} +6 -6
- package/Build/Workers/{chunk-VCNOFQYH.js → chunk-B2Y4ZS6X.js} +9 -9
- package/Build/Workers/{chunk-Q4ZVWJXX.js → chunk-BD2TPFGC.js} +5 -5
- package/Build/Workers/{chunk-K4AH3TDT.js → chunk-CHX2K5AC.js} +10 -10
- package/Build/Workers/{chunk-3LYROPON.js → chunk-CJGVEABL.js} +13 -13
- package/Build/Workers/{chunk-KSYBJA4M.js → chunk-DYJHEP3B.js} +5 -5
- package/Build/Workers/{chunk-CI2HEJFC.js → chunk-E3H7AVMK.js} +13 -13
- package/Build/Workers/{chunk-F4CUH4MR.js → chunk-EZNAJPP5.js} +4 -4
- package/Build/Workers/{chunk-YJX7X577.js → chunk-F7ZI463G.js} +15 -15
- package/Build/Workers/{chunk-HEZHXDYB.js → chunk-FMZ5CX6V.js} +1 -1
- package/Build/Workers/{chunk-G3BVMPWG.js → chunk-FRAWHNSR.js} +2 -2
- package/Build/Workers/{chunk-J7IH4EYI.js → chunk-GGV2XJHE.js} +7 -7
- package/Build/Workers/{chunk-5KWRW7YL.js → chunk-GK4QU6QI.js} +2 -2
- package/Build/Workers/{chunk-77XPS7ZA.js → chunk-HYPB7FAV.js} +10 -10
- package/Build/Workers/{chunk-MVM4JV5U.js → chunk-I4HO2ED2.js} +9 -9
- package/Build/Workers/{chunk-FX4R4MTH.js → chunk-IGINOLDX.js} +6 -6
- package/Build/Workers/{chunk-PWF4EY5P.js → chunk-ISQSYLZY.js} +4 -4
- package/Build/Workers/{chunk-7UHKH6M3.js → chunk-JZAMRL5I.js} +6 -6
- package/Build/Workers/{chunk-HUFQVUMY.js → chunk-K5G2WELR.js} +7 -7
- package/Build/Workers/{chunk-5S5OOA6U.js → chunk-L5SO4Y5V.js} +1 -1
- package/Build/Workers/{chunk-LNSWJ43X.js → chunk-LCMJQVIF.js} +11 -11
- package/Build/Workers/{chunk-WVNLSTOF.js → chunk-MWJW37I7.js} +2 -2
- package/Build/Workers/{chunk-ZGFIT57T.js → chunk-NAGMYRDW.js} +27 -20
- package/Build/Workers/{chunk-SDIDRZDG.js → chunk-OYO6TKMU.js} +7 -7
- package/Build/Workers/{chunk-HKHQ3EDR.js → chunk-PUTA3AE2.js} +4 -4
- package/Build/Workers/{chunk-JPDKYBLF.js → chunk-Q5BHMNKU.js} +13 -13
- package/Build/Workers/{chunk-XK4OP6VA.js → chunk-QTEX3Y4V.js} +17 -17
- package/Build/Workers/{chunk-TVL3F7IU.js → chunk-QZKN2RXM.js} +1 -1
- package/Build/Workers/{chunk-Z3QWTHI7.js → chunk-RO2Z3LCR.js} +14 -14
- package/Build/Workers/{chunk-N2XAJBC6.js → chunk-RRN6LRDX.js} +12 -12
- package/Build/Workers/{chunk-FYGLNDKG.js → chunk-SLIA3GQP.js} +7 -7
- package/Build/Workers/{chunk-7EO56M5R.js → chunk-TFCOEX3W.js} +2 -2
- package/Build/Workers/{chunk-KM6MITPF.js → chunk-TU6ZXHVU.js} +5 -5
- package/Build/Workers/{chunk-LS3KVHYY.js → chunk-VJ2PDF64.js} +6 -6
- package/Build/Workers/{chunk-D7ZBZPHV.js → chunk-VMVPONIV.js} +5 -5
- package/Build/Workers/{chunk-3PIZQT3I.js → chunk-WPXU45PH.js} +4 -4
- package/Build/Workers/{chunk-WEHZP4SE.js → chunk-XDHM4G3P.js} +7 -7
- package/Build/Workers/{chunk-TY4DKOWR.js → chunk-XED3RXKO.js} +2 -2
- package/Build/Workers/{chunk-ZMNLEL6W.js → chunk-YNYCGTQH.js} +5 -5
- package/Build/Workers/{chunk-4CHMVQTQ.js → chunk-Z4SI54EB.js} +4 -4
- package/Build/Workers/{chunk-3JBEPBPL.js → chunk-ZVDLC3T4.js} +13 -13
- package/Build/Workers/combineGeometry.js +22 -22
- package/Build/Workers/createBoxGeometry.js +16 -16
- package/Build/Workers/createBoxOutlineGeometry.js +14 -14
- package/Build/Workers/createCircleGeometry.js +24 -24
- package/Build/Workers/createCircleOutlineGeometry.js +17 -17
- package/Build/Workers/createCoplanarPolygonGeometry.js +31 -31
- package/Build/Workers/createCoplanarPolygonOutlineGeometry.js +29 -29
- package/Build/Workers/createCorridorGeometry.js +27 -27
- package/Build/Workers/createCorridorOutlineGeometry.js +26 -26
- package/Build/Workers/createCylinderGeometry.js +18 -18
- package/Build/Workers/createCylinderOutlineGeometry.js +16 -16
- package/Build/Workers/createEllipseGeometry.js +24 -24
- package/Build/Workers/createEllipseOutlineGeometry.js +17 -17
- package/Build/Workers/createEllipsoidGeometry.js +17 -17
- package/Build/Workers/createEllipsoidOutlineGeometry.js +16 -16
- package/Build/Workers/createFrustumGeometry.js +16 -16
- package/Build/Workers/createFrustumOutlineGeometry.js +16 -16
- package/Build/Workers/createGeometry.js +22 -22
- package/Build/Workers/createGroundPolylineGeometry.js +20 -20
- package/Build/Workers/createPlaneGeometry.js +14 -14
- package/Build/Workers/createPlaneOutlineGeometry.js +13 -13
- package/Build/Workers/createPolygonGeometry.js +30 -30
- package/Build/Workers/createPolygonOutlineGeometry.js +28 -28
- package/Build/Workers/createPolylineGeometry.js +23 -23
- package/Build/Workers/createPolylineVolumeGeometry.js +29 -29
- package/Build/Workers/createPolylineVolumeOutlineGeometry.js +25 -25
- package/Build/Workers/createRectangleGeometry.js +25 -25
- package/Build/Workers/createRectangleOutlineGeometry.js +18 -18
- package/Build/Workers/createSimplePolylineGeometry.js +21 -21
- package/Build/Workers/createSphereGeometry.js +17 -17
- package/Build/Workers/createSphereOutlineGeometry.js +16 -16
- package/Build/Workers/createTaskProcessorWorker.js +3 -3
- package/Build/Workers/createVectorTileClampedPolylines.js +13 -13
- package/Build/Workers/createVectorTileGeometries.js +22 -22
- package/Build/Workers/createVectorTilePoints.js +12 -12
- package/Build/Workers/createVectorTilePolygons.js +20 -20
- package/Build/Workers/createVectorTilePolylines.js +13 -13
- package/Build/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +20 -20
- package/Build/Workers/createVerticesFromHeightmap.js +20 -20
- package/Build/Workers/createVerticesFromQuantizedTerrainMesh.js +17 -17
- package/Build/Workers/createWallGeometry.js +22 -22
- package/Build/Workers/createWallOutlineGeometry.js +21 -21
- package/Build/Workers/decodeDraco.js +11 -11
- package/Build/Workers/decodeGoogleEarthEnterprisePacket.js +5 -5
- package/Build/Workers/decodeI3S.js +10 -10
- package/Build/Workers/transcodeKTX2.js +50 -43
- package/Build/Workers/transferTypedArrayTest.js +1 -1
- package/Build/Workers/upsampleQuantizedTerrainMesh.js +20 -20
- package/Source/Core/EllipsoidRhumbLine.js +1 -1
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/PolygonGeometryLibrary.js +26 -4
- package/Source/Core/TexturePacker.js +166 -0
- package/Source/DataSources/BillboardVisualizer.js +3 -3
- package/Source/DataSources/EntityCluster.js +44 -19
- package/Source/Renderer/Context.js +0 -4
- package/Source/Renderer/Texture.js +6 -5
- package/Source/Renderer/TextureAtlas.js +802 -0
- package/Source/Scene/ArcGisMapService.js +1 -1
- package/Source/Scene/Billboard.js +86 -141
- package/Source/Scene/BillboardCollection.js +132 -202
- package/Source/Scene/BillboardLoadState.js +44 -0
- package/Source/Scene/BillboardTexture.js +348 -0
- package/Source/Scene/Camera.js +2 -2
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +380 -126
- package/Source/Scene/Cesium3DTilesetStatistics.js +0 -1
- package/Source/Scene/Expression.js +1 -0
- package/Source/Scene/GltfLoader.js +5 -7
- package/Source/Scene/ImplicitSubtree.js +2 -0
- package/Source/Scene/KeyframeNode.js +16 -2
- package/Source/Scene/LabelCollection.js +212 -182
- package/Source/Scene/Megatexture.js +145 -81
- package/Source/Scene/Model/CustomShader.js +0 -2
- package/Source/Scene/Model/Model.js +1 -1
- package/Source/Scene/Model/ModelUtility.js +5 -1
- package/Source/Scene/Scene.js +39 -15
- package/Source/Scene/ScreenSpaceCameraController.js +0 -8
- package/Source/Scene/SpatialNode.js +4 -11
- package/Source/Scene/Vector3DTilePoints.js +2 -5
- package/Source/Scene/VoxelBoxShape.js +12 -5
- package/Source/Scene/VoxelCell.js +6 -5
- package/Source/Scene/VoxelContent.js +171 -107
- package/Source/Scene/VoxelCylinderShape.js +65 -58
- package/Source/Scene/VoxelEllipsoidShape.js +15 -5
- package/Source/Scene/VoxelMetadataOrder.js +12 -0
- package/Source/Scene/VoxelPrimitive.js +122 -54
- package/Source/Scene/VoxelProvider.js +34 -29
- package/Source/Scene/VoxelRenderResources.js +30 -7
- package/Source/Scene/VoxelShape.js +10 -3
- package/Source/Scene/VoxelTraversal.js +264 -180
- package/Source/Scene/processVoxelProperties.js +3 -0
- package/Source/Shaders/GlobeFS.glsl +10 -1
- package/Source/Shaders/GlobeFS.js +10 -1
- package/Source/Shaders/Voxels/Megatexture.glsl +4 -16
- package/Source/Shaders/Voxels/Megatexture.js +4 -16
- package/Source/Shaders/Voxels/Octree.glsl +44 -7
- package/Source/Shaders/Voxels/Octree.js +44 -7
- package/Source/Shaders/Voxels/VoxelFS.glsl +9 -15
- package/Source/Shaders/Voxels/VoxelFS.js +9 -15
- package/Source/Shaders/Voxels/convertUvToCylinder.glsl +15 -15
- package/Source/Shaders/Voxels/convertUvToCylinder.js +15 -15
- package/index.d.ts +176 -79
- package/index.js +413 -409
- package/package.json +2 -2
- package/Source/Scene/TextureAtlas.js +0 -558
|
@@ -1,167 +1,231 @@
|
|
|
1
|
+
import { destroyObject } from "@cesium/engine";
|
|
1
2
|
import Check from "../Core/Check.js";
|
|
3
|
+
import ComponentDatatype from "../Core/ComponentDatatype.js";
|
|
2
4
|
import DeveloperError from "../Core/DeveloperError.js";
|
|
3
5
|
import defined from "../Core/defined.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
+
import GltfLoader from "./GltfLoader.js";
|
|
7
|
+
import MetadataComponentType from "./MetadataComponentType.js";
|
|
8
|
+
import MetadataType from "./MetadataType.js";
|
|
6
9
|
|
|
7
10
|
/**
|
|
11
|
+
* <div class="notice">
|
|
12
|
+
* To construct a VoxelContent, call {@link VoxelContent.fromMetadataArray} or {@link VoxelContent.fromGltf}. Do not call the constructor directly.
|
|
13
|
+
* </div>
|
|
8
14
|
* An object representing voxel content for a {@link Cesium3DTilesVoxelProvider}.
|
|
9
15
|
*
|
|
10
16
|
* @alias VoxelContent
|
|
11
|
-
* @
|
|
17
|
+
* @internalConstructor
|
|
12
18
|
*
|
|
13
|
-
* @
|
|
19
|
+
* @privateParam {object} options An object with the following properties:
|
|
20
|
+
* @privateParam {ResourceLoader} [options.loader] The loader used to load the voxel content.
|
|
21
|
+
* @privateParam {Int8Array[]|Uint8Array[]|Int16Array[]|Uint16Array[]|Int32Array[]|Uint32Array[]|Float32Array[]|Float64Array[]} [options.metadata] The metadata for this voxel content.
|
|
22
|
+
*
|
|
23
|
+
* @exception {DeveloperError} One of loader and metadata must be defined.
|
|
24
|
+
* @exception {DeveloperError} metadata must be an array of TypedArrays.
|
|
14
25
|
*
|
|
15
|
-
* @private
|
|
16
26
|
* @experimental This feature is not final and is subject to change without Cesium's standard deprecation policy.
|
|
17
27
|
*/
|
|
18
|
-
function VoxelContent(
|
|
28
|
+
function VoxelContent(options) {
|
|
19
29
|
//>>includeStart('debug', pragmas.debug);
|
|
20
|
-
Check.typeOf.object("
|
|
30
|
+
Check.typeOf.object("options", options);
|
|
31
|
+
if (!defined(options.loader)) {
|
|
32
|
+
if (!defined(options.metadata)) {
|
|
33
|
+
throw new DeveloperError("One of loader and metadata must be defined.");
|
|
34
|
+
}
|
|
35
|
+
if (!Array.isArray(options.metadata)) {
|
|
36
|
+
throw new DeveloperError("metadata must be an array of TypedArrays.");
|
|
37
|
+
}
|
|
38
|
+
}
|
|
21
39
|
//>>includeEnd('debug');
|
|
22
40
|
|
|
23
|
-
|
|
24
|
-
|
|
41
|
+
const { loader, metadata } = options;
|
|
42
|
+
|
|
43
|
+
this._loader = loader;
|
|
44
|
+
this._metadata = metadata;
|
|
45
|
+
this._resourcesLoaded = false;
|
|
46
|
+
this._ready = false;
|
|
25
47
|
}
|
|
26
48
|
|
|
27
49
|
Object.defineProperties(VoxelContent.prototype, {
|
|
28
50
|
/**
|
|
29
|
-
*
|
|
51
|
+
* Returns true when the content is ready to render; otherwise false
|
|
52
|
+
*
|
|
53
|
+
* @memberof VoxelContent.prototype
|
|
30
54
|
*
|
|
31
|
-
* @type {
|
|
55
|
+
* @type {boolean}
|
|
32
56
|
* @readonly
|
|
33
57
|
* @private
|
|
34
58
|
*/
|
|
35
|
-
|
|
59
|
+
ready: {
|
|
60
|
+
get: function () {
|
|
61
|
+
return this._ready;
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The metadata for this voxel content.
|
|
67
|
+
* The metadata is an array of typed arrays, one for each field.
|
|
68
|
+
* The data for one field is a flattened 3D array ordered by X, then Y, then Z.
|
|
69
|
+
* @type {Int8Array[]|Uint8Array[]|Int16Array[]|Uint16Array[]|Int32Array[]|Uint32Array[]|Float32Array[]|Float64Array[]}
|
|
70
|
+
* @readonly
|
|
71
|
+
*/
|
|
72
|
+
metadata: {
|
|
36
73
|
get: function () {
|
|
37
|
-
return this.
|
|
74
|
+
return this._metadata;
|
|
38
75
|
},
|
|
39
76
|
},
|
|
40
77
|
});
|
|
41
78
|
|
|
42
79
|
/**
|
|
43
|
-
*
|
|
80
|
+
* Constructs a VoxelContent from an array of metadata.
|
|
81
|
+
*
|
|
82
|
+
* @param {Int8Array[]|Uint8Array[]|Int16Array[]|Uint16Array[]|Int32Array[]|Uint32Array[]|Float32Array[]|Float64Array[]} metadata The metadata to use for this voxel content.
|
|
83
|
+
* @returns {VoxelContent} A VoxelContent containing the specified metadata.
|
|
84
|
+
*/
|
|
85
|
+
VoxelContent.fromMetadataArray = function (metadata) {
|
|
86
|
+
//>>includeStart('debug', pragmas.debug);
|
|
87
|
+
Check.typeOf.object("metadata", metadata);
|
|
88
|
+
if (!Array.isArray(metadata)) {
|
|
89
|
+
throw new DeveloperError("metadata must be an array of TypedArrays.");
|
|
90
|
+
}
|
|
91
|
+
//>>includeEnd('debug');
|
|
92
|
+
|
|
93
|
+
return new VoxelContent({ metadata });
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Constructs a VoxelContent from a glTF resource.
|
|
44
98
|
*
|
|
45
|
-
* @param {Resource} resource
|
|
46
|
-
* @
|
|
47
|
-
* @param {Uint8Array} [binary] Voxel binary contents. Mutually exclusive with json.
|
|
48
|
-
* @param {MetadataSchema} metadataSchema The metadata schema used by property tables in the voxel content
|
|
49
|
-
* @returns {Promise<VoxelContent>}
|
|
99
|
+
* @param {Resource} resource A Resource pointing to a glTF containing voxel content.
|
|
100
|
+
* @returns {Promise<VoxelContent>} A promise that resolves to the voxel content.
|
|
50
101
|
*
|
|
51
|
-
* @
|
|
102
|
+
* @private
|
|
52
103
|
*/
|
|
53
|
-
VoxelContent.
|
|
54
|
-
resource,
|
|
55
|
-
json,
|
|
56
|
-
binary,
|
|
57
|
-
metadataSchema,
|
|
58
|
-
) {
|
|
104
|
+
VoxelContent.fromGltf = async function (resource) {
|
|
59
105
|
//>>includeStart('debug', pragmas.debug);
|
|
60
106
|
Check.typeOf.object("resource", resource);
|
|
61
|
-
if (defined(json) === defined(binary)) {
|
|
62
|
-
throw new DeveloperError("One of json and binary must be defined.");
|
|
63
|
-
}
|
|
64
107
|
//>>includeEnd('debug');
|
|
65
108
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
109
|
+
// Construct the glTF loader
|
|
110
|
+
const loader = new GltfLoader({
|
|
111
|
+
gltfResource: resource,
|
|
112
|
+
releaseGltfJson: false,
|
|
113
|
+
loadAttributesAsTypedArray: true,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
// This loads the gltf JSON and ensures the gltf is valid
|
|
118
|
+
// Further resource loading is handled synchronously in loader.process()
|
|
119
|
+
// via voxelContent.update() as the frameState is needed
|
|
120
|
+
await loader.load();
|
|
121
|
+
} catch (error) {
|
|
122
|
+
loader.destroy();
|
|
123
|
+
throw error;
|
|
74
124
|
}
|
|
75
125
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
126
|
+
return new VoxelContent({ loader });
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Updates the content until all resources are ready for rendering.
|
|
131
|
+
* @param {FrameState} frameState The frame state
|
|
132
|
+
* @private
|
|
133
|
+
*/
|
|
134
|
+
VoxelContent.prototype.update = function (primitive, frameState) {
|
|
135
|
+
const loader = this._loader;
|
|
136
|
+
|
|
137
|
+
if (this._ready) {
|
|
138
|
+
// Nothing to do
|
|
139
|
+
return;
|
|
86
140
|
}
|
|
87
141
|
|
|
88
|
-
|
|
89
|
-
|
|
142
|
+
// Ensures frames continue to render in requestRender mode while resources are processing
|
|
143
|
+
frameState.afterRender.push(() => true);
|
|
90
144
|
|
|
91
|
-
|
|
145
|
+
if (!defined(loader)) {
|
|
146
|
+
this._ready = true;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
92
149
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
150
|
+
if (this._resourcesLoaded) {
|
|
151
|
+
const { structuralMetadata, scene } = loader.components;
|
|
152
|
+
const { attributes } = scene.nodes[0].primitives[0];
|
|
153
|
+
this._metadata = processAttributes(
|
|
154
|
+
attributes,
|
|
155
|
+
structuralMetadata,
|
|
156
|
+
primitive,
|
|
157
|
+
);
|
|
158
|
+
this._ready = true;
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
99
161
|
|
|
100
|
-
|
|
162
|
+
this._resourcesLoaded = loader.process(frameState);
|
|
101
163
|
};
|
|
102
164
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
165
|
+
/**
|
|
166
|
+
* Processes the attributes from the glTF loader, reordering them into the order expected by the primitive.
|
|
167
|
+
*
|
|
168
|
+
* @param {ModelComponents.Attribute[]} attributes The attributes to process
|
|
169
|
+
* @param {StructuralMetadata} structuralMetadata Information from the glTF EXT_structural_metadata extension
|
|
170
|
+
* @param {VoxelPrimitive} primitive The primitive for which this voxel content will be used.
|
|
171
|
+
* @returns {Int8Array[]|Uint8Array[]|Int16Array[]|Uint16Array[]|Int32Array[]|Uint32Array[]|Float32Array[]|Float64Array[]} An array of typed arrays containing the attribute values
|
|
172
|
+
* @private
|
|
173
|
+
*/
|
|
174
|
+
function processAttributes(attributes, structuralMetadata, primitive) {
|
|
175
|
+
const { className, names, types, componentTypes } = primitive.provider;
|
|
176
|
+
const propertyAttribute = structuralMetadata.propertyAttributes.find(
|
|
177
|
+
(p) => p.class.id === className,
|
|
178
|
+
);
|
|
179
|
+
const { properties } = propertyAttribute;
|
|
180
|
+
const data = new Array(names.length);
|
|
181
|
+
|
|
182
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
183
|
+
// Find the appropriate glTF attribute based on its name.
|
|
184
|
+
const name = properties[names[i]].attribute;
|
|
185
|
+
const attribute = attributes.find((a) => a.name === name);
|
|
186
|
+
if (!defined(attribute)) {
|
|
187
|
+
continue;
|
|
120
188
|
}
|
|
189
|
+
|
|
190
|
+
const componentDatatype = MetadataComponentType.toComponentDatatype(
|
|
191
|
+
componentTypes[i],
|
|
192
|
+
);
|
|
193
|
+
const componentCount = MetadataType.getComponentCount(types[i]);
|
|
194
|
+
const totalCount = attribute.count * componentCount;
|
|
195
|
+
data[i] = ComponentDatatype.createArrayBufferView(
|
|
196
|
+
componentDatatype,
|
|
197
|
+
attribute.typedArray.buffer,
|
|
198
|
+
attribute.typedArray.byteOffset + attribute.byteOffset,
|
|
199
|
+
totalCount,
|
|
200
|
+
);
|
|
121
201
|
}
|
|
122
202
|
|
|
123
|
-
return
|
|
203
|
+
return data;
|
|
124
204
|
}
|
|
125
205
|
|
|
126
206
|
/**
|
|
127
|
-
*
|
|
207
|
+
* Returns true if this object was destroyed; otherwise, false.
|
|
208
|
+
* <br /><br />
|
|
209
|
+
* If this object was destroyed, it should not be used; calling any function other than
|
|
210
|
+
* <code>isDestroyed</code> will result in a {@link DeveloperError} exception.
|
|
211
|
+
*
|
|
212
|
+
* @returns {boolean} <code>true</code> if this object was destroyed; otherwise, <code>false</code>.
|
|
213
|
+
*
|
|
214
|
+
* @see VoxelContent#destroy
|
|
128
215
|
*
|
|
129
|
-
* @typedef {object} VoxelChunks
|
|
130
|
-
* @property {object} json The json chunk of the binary voxel content
|
|
131
|
-
* @property {Uint8Array} binary The binary chunk of the binary voxel content. This represents the internal buffer.
|
|
132
216
|
* @private
|
|
133
217
|
*/
|
|
218
|
+
VoxelContent.prototype.isDestroyed = function () {
|
|
219
|
+
return false;
|
|
220
|
+
};
|
|
134
221
|
|
|
135
222
|
/**
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
* @param {Uint8Array} binaryView The binary voxel content
|
|
139
|
-
* @returns {VoxelChunks} An object containing the JSON and binary chunks
|
|
223
|
+
* Frees the resources used by this object.
|
|
140
224
|
* @private
|
|
141
225
|
*/
|
|
142
|
-
function
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
// Skip to the chunk lengths
|
|
147
|
-
let byteOffset = 8;
|
|
148
|
-
|
|
149
|
-
// Read the bottom 32 bits of the 64-bit byte length. This is ok for now because:
|
|
150
|
-
// 1) not all browsers have native 64-bit operations
|
|
151
|
-
// 2) the data is well under 4GB
|
|
152
|
-
const jsonByteLength = reader.getUint32(byteOffset, littleEndian);
|
|
153
|
-
byteOffset += 8;
|
|
154
|
-
const binaryByteLength = reader.getUint32(byteOffset, littleEndian);
|
|
155
|
-
byteOffset += 8;
|
|
156
|
-
|
|
157
|
-
const json = getJsonFromTypedArray(binaryView, byteOffset, jsonByteLength);
|
|
158
|
-
byteOffset += jsonByteLength;
|
|
159
|
-
const binary = binaryView.subarray(byteOffset, byteOffset + binaryByteLength);
|
|
160
|
-
|
|
161
|
-
return {
|
|
162
|
-
json: json,
|
|
163
|
-
binary: binary,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
226
|
+
VoxelContent.prototype.destroy = function () {
|
|
227
|
+
this._loader = this._loader && this._loader.destroy();
|
|
228
|
+
return destroyObject(this);
|
|
229
|
+
};
|
|
166
230
|
|
|
167
231
|
export default VoxelContent;
|