@cesium/engine 13.1.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-APCS5YJI.js → chunk-25TOENEE.js} +7 -7
- package/Build/Workers/{chunk-FNCXBBCF.js → chunk-2AVIUB5H.js} +2 -2
- package/Build/Workers/{chunk-OZTFRHA2.js → chunk-3JZGPJMZ.js} +6 -6
- package/Build/Workers/{chunk-5JY4LYO3.js → chunk-3LHBH4TC.js} +7 -7
- package/Build/Workers/{chunk-MGABCOOH.js → chunk-3LZF23RY.js} +6 -6
- package/Build/Workers/{chunk-AXYZUG4N.js → chunk-5S2B46UQ.js} +1 -1
- package/Build/Workers/{chunk-2SRHVCFD.js → chunk-67ONR44K.js} +6 -6
- package/Build/Workers/{chunk-PBJQFLKS.js → chunk-6EDBC234.js} +11 -11
- package/Build/Workers/{chunk-GSLKQJM2.js → chunk-6EV4VOET.js} +10 -10
- package/Build/Workers/{chunk-OGRXNUR2.js → chunk-7ITUZTFH.js} +1 -1
- package/Build/Workers/{chunk-IP7F2MVW.js → chunk-ARVZCY6X.js} +7 -7
- package/Build/Workers/{chunk-EYZFEJX3.js → chunk-B2UQN3DH.js} +6 -6
- package/Build/Workers/{chunk-WE4KF4AM.js → chunk-B2Y4ZS6X.js} +9 -9
- package/Build/Workers/{chunk-DWIKWWEE.js → chunk-BD2TPFGC.js} +5 -5
- package/Build/Workers/{chunk-5ICYLS6B.js → chunk-CHX2K5AC.js} +10 -10
- package/Build/Workers/{chunk-NQDKNE7V.js → chunk-CJGVEABL.js} +13 -13
- package/Build/Workers/{chunk-B34JXFHF.js → chunk-DYJHEP3B.js} +5 -5
- package/Build/Workers/{chunk-J7BMSSY7.js → chunk-E3H7AVMK.js} +13 -13
- package/Build/Workers/{chunk-TOHDFUJM.js → chunk-EZNAJPP5.js} +4 -4
- package/Build/Workers/{chunk-K62EHZFT.js → chunk-F7ZI463G.js} +15 -15
- package/Build/Workers/{chunk-EJ5DT5BP.js → chunk-FMZ5CX6V.js} +1 -1
- package/Build/Workers/{chunk-OARMSJUU.js → chunk-FRAWHNSR.js} +2 -2
- package/Build/Workers/{chunk-S3UM4OKP.js → chunk-GGV2XJHE.js} +7 -7
- package/Build/Workers/{chunk-SAKQO5NX.js → chunk-GK4QU6QI.js} +2 -2
- package/Build/Workers/{chunk-LFUFGHL3.js → chunk-HYPB7FAV.js} +10 -10
- package/Build/Workers/{chunk-3SCCWLZS.js → chunk-I4HO2ED2.js} +9 -9
- package/Build/Workers/{chunk-K6SQV4IS.js → chunk-IGINOLDX.js} +6 -6
- package/Build/Workers/{chunk-IXNXKVOB.js → chunk-ISQSYLZY.js} +4 -4
- package/Build/Workers/{chunk-PM76TX2X.js → chunk-JZAMRL5I.js} +6 -6
- package/Build/Workers/{chunk-CBE4HRBH.js → chunk-K5G2WELR.js} +7 -7
- package/Build/Workers/{chunk-EHGQQA7C.js → chunk-L5SO4Y5V.js} +1 -1
- package/Build/Workers/{chunk-M2AA2ARJ.js → chunk-LCMJQVIF.js} +11 -11
- package/Build/Workers/{chunk-HI73PIPQ.js → chunk-MWJW37I7.js} +2 -2
- package/Build/Workers/{chunk-WAJNX74N.js → chunk-NAGMYRDW.js} +27 -20
- package/Build/Workers/{chunk-WUIDEXAN.js → chunk-OYO6TKMU.js} +7 -7
- package/Build/Workers/{chunk-YVGU235V.js → chunk-PUTA3AE2.js} +4 -4
- package/Build/Workers/{chunk-ZWSWJYJP.js → chunk-Q5BHMNKU.js} +13 -13
- package/Build/Workers/{chunk-LQT2ZK7D.js → chunk-QTEX3Y4V.js} +17 -17
- package/Build/Workers/{chunk-UBAHTE4Q.js → chunk-QZKN2RXM.js} +1 -1
- package/Build/Workers/{chunk-T34EOLFR.js → chunk-RO2Z3LCR.js} +14 -14
- package/Build/Workers/{chunk-PTFIVVLX.js → chunk-RRN6LRDX.js} +12 -12
- package/Build/Workers/{chunk-B6IJY6AN.js → chunk-SLIA3GQP.js} +7 -7
- package/Build/Workers/{chunk-GIOZHX7U.js → chunk-TFCOEX3W.js} +2 -2
- package/Build/Workers/{chunk-KRVALCCI.js → chunk-TU6ZXHVU.js} +5 -5
- package/Build/Workers/{chunk-54I6VSRP.js → chunk-VJ2PDF64.js} +6 -6
- package/Build/Workers/{chunk-BMFWWTD7.js → chunk-VMVPONIV.js} +5 -5
- package/Build/Workers/{chunk-CNPP6TQ2.js → chunk-WPXU45PH.js} +4 -4
- package/Build/Workers/{chunk-2ONAV62A.js → chunk-XDHM4G3P.js} +7 -7
- package/Build/Workers/{chunk-KO232FLP.js → chunk-XED3RXKO.js} +2 -2
- package/Build/Workers/{chunk-5I3LPAS7.js → chunk-YNYCGTQH.js} +5 -5
- package/Build/Workers/{chunk-THDHWSEJ.js → chunk-Z4SI54EB.js} +4 -4
- package/Build/Workers/{chunk-R2KGFZBA.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 +15 -14
- 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/Color.js +3 -3
- package/Source/Core/Credit.js +3 -3
- package/Source/Core/DistanceDisplayCondition.js +3 -3
- package/Source/Core/EllipsoidRhumbLine.js +1 -1
- package/Source/Core/Ion.js +1 -1
- package/Source/Core/OrientedBoundingBox.js +2 -2
- package/Source/Core/PolygonGeometryLibrary.js +26 -4
- package/Source/Core/Spherical.js +3 -3
- package/Source/Core/TexturePacker.js +166 -0
- package/Source/Core/writeTextToCanvas.js +0 -1
- package/Source/DataSources/BillboardVisualizer.js +3 -3
- package/Source/DataSources/BoundingSphereState.js +3 -3
- package/Source/DataSources/DataSourceClock.js +1 -1
- package/Source/DataSources/DataSourceDisplay.js +5 -2
- package/Source/DataSources/EntityCluster.js +44 -19
- package/Source/Renderer/AutomaticUniforms.js +2 -2
- 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 +87 -142
- 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/Cesium3DTile.js +56 -28
- package/Source/Scene/Cesium3DTilesVoxelProvider.js +403 -132
- package/Source/Scene/Cesium3DTilesetStatistics.js +0 -1
- package/Source/Scene/ClippingPolygon.js +2 -2
- package/Source/Scene/Expression.js +1 -0
- package/Source/Scene/GltfDracoLoader.js +45 -0
- package/Source/Scene/GltfIndexBufferLoader.js +5 -0
- package/Source/Scene/GltfLoader.js +22 -9
- package/Source/Scene/GltfVertexBufferLoader.js +13 -0
- package/Source/Scene/ITwinData.js +47 -1
- package/Source/Scene/ImageryLayer.js +1 -1
- package/Source/Scene/ImplicitSubtree.js +2 -0
- package/Source/Scene/KeyframeNode.js +16 -2
- package/Source/Scene/Label.js +1 -1
- package/Source/Scene/LabelCollection.js +212 -193
- 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/Multiple3DTileContent.js +21 -8
- package/Source/Scene/PointPrimitive.js +1 -1
- package/Source/Scene/ResourceCache.js +17 -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 +245 -53
- package/Source/Scene/VoxelProvider.js +44 -29
- package/Source/Scene/VoxelRenderResources.js +30 -7
- package/Source/Scene/VoxelShape.js +10 -3
- package/Source/Scene/VoxelTraversal.js +326 -166
- package/Source/Scene/WebMapTileServiceImageryProvider.js +2 -2
- package/Source/Scene/createGooglePhotorealistic3DTileset.js +5 -8
- package/Source/Scene/processVoxelProperties.js +3 -0
- package/Source/Shaders/GlobeFS.glsl +10 -1
- package/Source/Shaders/GlobeFS.js +10 -1
- package/Source/Shaders/PolylineCommon.glsl +1 -1
- package/Source/Shaders/PolylineCommon.js +1 -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/Source/Widget/CesiumWidget.js +16 -10
- package/Source/Workers/decodeDraco.js +4 -4
- package/index.d.ts +321 -110
- package/index.js +209 -205
- package/package.json +2 -2
- package/Source/Scene/TextureAtlas.js +0 -558
|
@@ -101,9 +101,8 @@ Object.defineProperties(Vector3DTilePoints.prototype, {
|
|
|
101
101
|
*/
|
|
102
102
|
texturesByteLength: {
|
|
103
103
|
get: function () {
|
|
104
|
-
const billboardSize =
|
|
105
|
-
|
|
106
|
-
const labelSize = this._labelCollection._textureAtlas.texture.sizeInBytes;
|
|
104
|
+
const billboardSize = this._billboardCollection.sizeInBytes;
|
|
105
|
+
const labelSize = this._labelCollection.sizeInBytes;
|
|
107
106
|
return billboardSize + labelSize;
|
|
108
107
|
},
|
|
109
108
|
},
|
|
@@ -496,8 +495,6 @@ Vector3DTilePoints.prototype.update = function (frameState) {
|
|
|
496
495
|
this._error = undefined;
|
|
497
496
|
throw error;
|
|
498
497
|
}
|
|
499
|
-
|
|
500
|
-
return;
|
|
501
498
|
}
|
|
502
499
|
|
|
503
500
|
this._polylineCollection.update(frameState);
|
|
@@ -24,6 +24,7 @@ function VoxelBoxShape() {
|
|
|
24
24
|
/**
|
|
25
25
|
* An oriented bounding box containing the bounded shape.
|
|
26
26
|
* The update function must be called before accessing this value.
|
|
27
|
+
* @private
|
|
27
28
|
* @type {OrientedBoundingBox}
|
|
28
29
|
* @readonly
|
|
29
30
|
*/
|
|
@@ -32,6 +33,7 @@ function VoxelBoxShape() {
|
|
|
32
33
|
/**
|
|
33
34
|
* A bounding sphere containing the bounded shape.
|
|
34
35
|
* The update function must be called before accessing this value.
|
|
36
|
+
* @private
|
|
35
37
|
* @type {BoundingSphere}
|
|
36
38
|
* @readonly
|
|
37
39
|
*/
|
|
@@ -40,6 +42,7 @@ function VoxelBoxShape() {
|
|
|
40
42
|
/**
|
|
41
43
|
* A transformation matrix containing the bounded shape.
|
|
42
44
|
* The update function must be called before accessing this value.
|
|
45
|
+
* @private
|
|
43
46
|
* @type {Matrix4}
|
|
44
47
|
* @readonly
|
|
45
48
|
*/
|
|
@@ -48,6 +51,7 @@ function VoxelBoxShape() {
|
|
|
48
51
|
/**
|
|
49
52
|
* A transformation matrix containing the shape, ignoring the bounds.
|
|
50
53
|
* The update function must be called before accessing this value.
|
|
54
|
+
* @private
|
|
51
55
|
* @type {Matrix4}
|
|
52
56
|
* @readonly
|
|
53
57
|
*/
|
|
@@ -72,6 +76,7 @@ function VoxelBoxShape() {
|
|
|
72
76
|
);
|
|
73
77
|
|
|
74
78
|
/**
|
|
79
|
+
* @private
|
|
75
80
|
* @type {Object<string, any>}
|
|
76
81
|
* @readonly
|
|
77
82
|
*/
|
|
@@ -83,6 +88,7 @@ function VoxelBoxShape() {
|
|
|
83
88
|
};
|
|
84
89
|
|
|
85
90
|
/**
|
|
91
|
+
* @private
|
|
86
92
|
* @type {Object<string, any>}
|
|
87
93
|
* @readonly
|
|
88
94
|
*/
|
|
@@ -93,6 +99,7 @@ function VoxelBoxShape() {
|
|
|
93
99
|
|
|
94
100
|
/**
|
|
95
101
|
* The maximum number of intersections against the shape for any ray direction.
|
|
102
|
+
* @private
|
|
96
103
|
* @type {number}
|
|
97
104
|
* @readonly
|
|
98
105
|
*/
|
|
@@ -115,7 +122,7 @@ const transformLocalToUv = Matrix4.fromRotationTranslation(
|
|
|
115
122
|
|
|
116
123
|
/**
|
|
117
124
|
* Update the shape's state.
|
|
118
|
-
*
|
|
125
|
+
* @private
|
|
119
126
|
* @param {Matrix4} modelMatrix The model matrix.
|
|
120
127
|
* @param {Cartesian3} minBounds The minimum bounds.
|
|
121
128
|
* @param {Cartesian3} maxBounds The maximum bounds.
|
|
@@ -302,7 +309,7 @@ const scratchTileMaxBounds = new Cartesian3();
|
|
|
302
309
|
/**
|
|
303
310
|
* Computes an oriented bounding box for a specified tile.
|
|
304
311
|
* The update function must be called before calling this function.
|
|
305
|
-
*
|
|
312
|
+
* @private
|
|
306
313
|
* @param {number} tileLevel The tile's level.
|
|
307
314
|
* @param {number} tileX The tile's x coordinate.
|
|
308
315
|
* @param {number} tileY The tile's y coordinate.
|
|
@@ -356,7 +363,7 @@ const sampleSizeScratch = new Cartesian3();
|
|
|
356
363
|
/**
|
|
357
364
|
* Computes an oriented bounding box for a specified sample within a specified tile.
|
|
358
365
|
* The update function must be called before calling this function.
|
|
359
|
-
*
|
|
366
|
+
* @private
|
|
360
367
|
* @param {SpatialNode} spatialNode The spatial node containing the sample
|
|
361
368
|
* @param {Cartesian3} tileDimensions The size of the tile in number of samples, before padding
|
|
362
369
|
* @param {Cartesian3} tileUv The sample coordinate within the tile
|
|
@@ -429,7 +436,7 @@ VoxelBoxShape.prototype.computeOrientedBoundingBoxForSample = function (
|
|
|
429
436
|
|
|
430
437
|
/**
|
|
431
438
|
* Defines the minimum bounds of the shape. Corresponds to minimum X, Y, Z.
|
|
432
|
-
*
|
|
439
|
+
* @private
|
|
433
440
|
* @type {Cartesian3}
|
|
434
441
|
* @constant
|
|
435
442
|
* @readonly
|
|
@@ -440,7 +447,7 @@ VoxelBoxShape.DefaultMinBounds = Object.freeze(
|
|
|
440
447
|
|
|
441
448
|
/**
|
|
442
449
|
* Defines the maximum bounds of the shape. Corresponds to maximum X, Y, Z.
|
|
443
|
-
*
|
|
450
|
+
* @private
|
|
444
451
|
* @type {Cartesian3}
|
|
445
452
|
* @constant
|
|
446
453
|
* @readonly
|
|
@@ -71,8 +71,8 @@ VoxelCell.fromKeyframeNode = function (
|
|
|
71
71
|
//>>includeEnd('debug');
|
|
72
72
|
|
|
73
73
|
const voxelCell = new VoxelCell(primitive, tileIndex, sampleIndex);
|
|
74
|
-
const { spatialNode,
|
|
75
|
-
voxelCell._metadata = getMetadataForSample(primitive,
|
|
74
|
+
const { spatialNode, content } = keyframeNode;
|
|
75
|
+
voxelCell._metadata = getMetadataForSample(primitive, content, sampleIndex);
|
|
76
76
|
voxelCell._orientedBoundingBox = getOrientedBoundingBox(
|
|
77
77
|
primitive,
|
|
78
78
|
spatialNode,
|
|
@@ -85,15 +85,16 @@ VoxelCell.fromKeyframeNode = function (
|
|
|
85
85
|
/**
|
|
86
86
|
* @private
|
|
87
87
|
* @param {VoxelPrimitive} primitive
|
|
88
|
-
* @param {
|
|
88
|
+
* @param {VoxelContent} content
|
|
89
89
|
* @param {number} sampleIndex
|
|
90
90
|
* @returns {object}
|
|
91
91
|
*/
|
|
92
|
-
function getMetadataForSample(primitive,
|
|
93
|
-
if (!defined(metadata)) {
|
|
92
|
+
function getMetadataForSample(primitive, content, sampleIndex) {
|
|
93
|
+
if (!defined(content) || !defined(content.metadata)) {
|
|
94
94
|
return undefined;
|
|
95
95
|
}
|
|
96
96
|
const { names, types } = primitive.provider;
|
|
97
|
+
const { metadata } = content;
|
|
97
98
|
const metadataMap = {};
|
|
98
99
|
for (let i = 0; i < names.length; i++) {
|
|
99
100
|
const name = names[i];
|
|
@@ -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;
|