@loaders.gl/3d-tiles 4.0.0-alpha.9 → 4.0.0-beta.1
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/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts +30 -0
- package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts.map +1 -0
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts +10 -0
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts.map +1 -0
- package/dist/3d-tiles-archive-loader.d.ts +13 -0
- package/dist/3d-tiles-archive-loader.d.ts.map +1 -0
- package/dist/cesium-ion-loader.d.ts +2 -2
- package/dist/cesium-ion-loader.d.ts.map +1 -1
- package/dist/dist.min.js +10981 -4462
- package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js +126 -0
- package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
- package/dist/es5/3d-tiles-archive/3d-tiles-archive-parser.js +69 -0
- package/dist/es5/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
- package/dist/es5/3d-tiles-archive-loader.js +50 -0
- package/dist/es5/3d-tiles-archive-loader.js.map +1 -0
- package/dist/es5/cesium-ion-loader.js.map +1 -1
- package/dist/es5/index.js +14 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js +151 -0
- package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -0
- package/dist/es5/lib/ion/ion.js +3 -9
- package/dist/es5/lib/ion/ion.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js +63 -38
- package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +3 -3
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js +70 -55
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js +3 -1
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +14 -12
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-header.js +14 -12
- package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +6 -6
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile.js +3 -1
- package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/lib/utils/version.js.map +1 -1
- package/dist/es5/tile-3d-subtree-loader.js.map +1 -1
- package/dist/es5/tile-3d-writer.js.map +1 -1
- package/dist/es5/tiles-3d-loader.js +2 -0
- package/dist/es5/tiles-3d-loader.js.map +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/3d-tiles-archive/3d-tiles-archive-archive.js +46 -0
- package/dist/esm/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -0
- package/dist/esm/3d-tiles-archive/3d-tiles-archive-parser.js +23 -0
- package/dist/esm/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -0
- package/dist/esm/3d-tiles-archive-loader.js +20 -0
- package/dist/esm/3d-tiles-archive-loader.js.map +1 -0
- package/dist/esm/cesium-ion-loader.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js +49 -0
- package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.js.map +1 -0
- package/dist/esm/lib/ion/ion.js +3 -9
- package/dist/esm/lib/ion/ion.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js +45 -23
- package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +5 -6
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js +18 -24
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-composite.js +3 -1
- package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +7 -8
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-header.js +8 -5
- package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +2 -4
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile.js +3 -1
- package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/esm/lib/utils/version.js.map +1 -1
- package/dist/esm/tile-3d-subtree-loader.js.map +1 -1
- package/dist/esm/tile-3d-writer.js.map +1 -1
- package/dist/esm/tiles-3d-loader.js +2 -0
- package/dist/esm/tiles-3d-loader.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts +32 -0
- package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts +4 -1
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +2 -2
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-header.d.ts +30 -2
- package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +1 -1
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile.d.ts +1 -1
- package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -1
- package/dist/tile-3d-subtree-loader.d.ts +3 -3
- package/dist/tile-3d-subtree-loader.d.ts.map +1 -1
- package/dist/tile-3d-writer.d.ts +2 -2
- package/dist/tile-3d-writer.d.ts.map +1 -1
- package/dist/tiles-3d-loader.d.ts +2 -1
- package/dist/tiles-3d-loader.d.ts.map +1 -1
- package/dist/types.d.ts +49 -8
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -7
- package/src/3d-tiles-archive/3d-tiles-archive-archive.ts +85 -0
- package/src/3d-tiles-archive/3d-tiles-archive-parser.ts +52 -0
- package/src/3d-tiles-archive-loader.ts +47 -0
- package/src/cesium-ion-loader.ts +2 -3
- package/src/index.ts +3 -0
- package/src/lib/filesystems/tiles-3d-archive-file-system.ts +97 -0
- package/src/lib/ion/ion.ts +3 -3
- package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +76 -32
- package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +8 -3
- package/src/lib/parsers/helpers/parse-3d-tile-subtree.ts +44 -62
- package/src/lib/parsers/parse-3d-tile-composite.ts +1 -1
- package/src/lib/parsers/parse-3d-tile-gltf.ts +11 -10
- package/src/lib/parsers/parse-3d-tile-header.ts +39 -6
- package/src/lib/parsers/parse-3d-tile-point-cloud.ts +10 -3
- package/src/lib/parsers/parse-3d-tile.ts +2 -2
- package/src/tile-3d-subtree-loader.ts +3 -3
- package/src/tile-3d-writer.ts +2 -2
- package/src/tiles-3d-loader.ts +16 -4
- package/src/types.ts +52 -9
- package/dist/bundle.js +0 -5
- package/dist/cesium-ion-loader.js +0 -41
- package/dist/index.js +0 -26
- package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +0 -113
- package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +0 -197
- package/dist/lib/classes/tile-3d-batch-table.js +0 -245
- package/dist/lib/classes/tile-3d-feature-table.js +0 -72
- package/dist/lib/constants.js +0 -26
- package/dist/lib/encoders/encode-3d-tile-batched-model.js +0 -46
- package/dist/lib/encoders/encode-3d-tile-composite.js +0 -24
- package/dist/lib/encoders/encode-3d-tile-instanced-model.js +0 -38
- package/dist/lib/encoders/encode-3d-tile-point-cloud.js +0 -39
- package/dist/lib/encoders/encode-3d-tile.js +0 -33
- package/dist/lib/encoders/helpers/encode-3d-tile-header.js +0 -30
- package/dist/lib/ion/ion.js +0 -68
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +0 -65
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +0 -30
- package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +0 -42
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +0 -266
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +0 -96
- package/dist/lib/parsers/helpers/parse-3d-tile-header.js +0 -28
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +0 -104
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +0 -93
- package/dist/lib/parsers/helpers/parse-utils.js +0 -32
- package/dist/lib/parsers/parse-3d-tile-batched-model.js +0 -33
- package/dist/lib/parsers/parse-3d-tile-composite.js +0 -24
- package/dist/lib/parsers/parse-3d-tile-gltf.js +0 -28
- package/dist/lib/parsers/parse-3d-tile-header.js +0 -192
- package/dist/lib/parsers/parse-3d-tile-instanced-model.js +0 -172
- package/dist/lib/parsers/parse-3d-tile-point-cloud.js +0 -433
- package/dist/lib/parsers/parse-3d-tile.js +0 -33
- package/dist/lib/utils/obb/s2-corners-to-obb.js +0 -37
- package/dist/lib/utils/s2/converters/s2-to-boundary.js +0 -61
- package/dist/lib/utils/s2/converters/s2-to-obb-points.js +0 -36
- package/dist/lib/utils/s2/converters/s2-to-region.js +0 -59
- package/dist/lib/utils/s2/index.js +0 -23
- package/dist/lib/utils/s2/s2-geometry-functions.js +0 -29
- package/dist/lib/utils/s2/s2-token-functions.js +0 -68
- package/dist/lib/utils/s2/s2geometry/s2-cell-utils.js +0 -32
- package/dist/lib/utils/s2/s2geometry/s2-geometry.js +0 -260
- package/dist/lib/utils/version.js +0 -7
- package/dist/tile-3d-subtree-loader.js +0 -23
- package/dist/tile-3d-writer.js +0 -27
- package/dist/tiles-3d-loader.js +0 -76
- package/dist/types.js +0 -2
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This file is derived from the Cesium code base under Apache 2 license
|
|
3
|
-
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
4
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.parseInstancedModel3DTile = void 0;
|
|
9
|
-
const core_1 = require("@math.gl/core");
|
|
10
|
-
const geospatial_1 = require("@math.gl/geospatial");
|
|
11
|
-
const math_1 = require("@loaders.gl/math"); // 'math.gl/geometry';
|
|
12
|
-
const tile_3d_feature_table_1 = __importDefault(require("../classes/tile-3d-feature-table"));
|
|
13
|
-
const tile_3d_batch_table_1 = __importDefault(require("../classes/tile-3d-batch-table"));
|
|
14
|
-
const parse_3d_tile_header_1 = require("./helpers/parse-3d-tile-header");
|
|
15
|
-
const parse_3d_tile_tables_1 = require("./helpers/parse-3d-tile-tables");
|
|
16
|
-
const parse_3d_tile_gltf_view_1 = require("./helpers/parse-3d-tile-gltf-view");
|
|
17
|
-
async function parseInstancedModel3DTile(tile, arrayBuffer, byteOffset, options, context) {
|
|
18
|
-
byteOffset = parseInstancedModel(tile, arrayBuffer, byteOffset, options, context);
|
|
19
|
-
await (0, parse_3d_tile_gltf_view_1.extractGLTF)(tile, tile.gltfFormat || 0, options, context);
|
|
20
|
-
return byteOffset;
|
|
21
|
-
}
|
|
22
|
-
exports.parseInstancedModel3DTile = parseInstancedModel3DTile;
|
|
23
|
-
function parseInstancedModel(tile, arrayBuffer, byteOffset, options, context) {
|
|
24
|
-
byteOffset = (0, parse_3d_tile_header_1.parse3DTileHeaderSync)(tile, arrayBuffer, byteOffset);
|
|
25
|
-
if (tile.version !== 1) {
|
|
26
|
-
throw new Error(`Instanced 3D Model version ${tile.version} is not supported`);
|
|
27
|
-
}
|
|
28
|
-
byteOffset = (0, parse_3d_tile_tables_1.parse3DTileTablesHeaderSync)(tile, arrayBuffer, byteOffset);
|
|
29
|
-
const view = new DataView(arrayBuffer);
|
|
30
|
-
tile.gltfFormat = view.getUint32(byteOffset, true);
|
|
31
|
-
byteOffset += 4;
|
|
32
|
-
// PARSE FEATURE TABLE
|
|
33
|
-
byteOffset = (0, parse_3d_tile_tables_1.parse3DTileTablesSync)(tile, arrayBuffer, byteOffset, options);
|
|
34
|
-
byteOffset = (0, parse_3d_tile_gltf_view_1.parse3DTileGLTFViewSync)(tile, arrayBuffer, byteOffset, options);
|
|
35
|
-
// TODO - Is the feature table sometimes optional or can check be moved into table header parser?
|
|
36
|
-
if (!tile?.header?.featureTableJsonByteLength || tile.header.featureTableJsonByteLength === 0) {
|
|
37
|
-
throw new Error('i3dm parser: featureTableJsonByteLength is zero.');
|
|
38
|
-
}
|
|
39
|
-
const featureTable = new tile_3d_feature_table_1.default(tile.featureTableJson, tile.featureTableBinary);
|
|
40
|
-
const instancesLength = featureTable.getGlobalProperty('INSTANCES_LENGTH');
|
|
41
|
-
featureTable.featuresLength = instancesLength;
|
|
42
|
-
if (!Number.isFinite(instancesLength)) {
|
|
43
|
-
throw new Error('i3dm parser: INSTANCES_LENGTH must be defined');
|
|
44
|
-
}
|
|
45
|
-
tile.eastNorthUp = featureTable.getGlobalProperty('EAST_NORTH_UP');
|
|
46
|
-
tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', math_1.GL.FLOAT, 3);
|
|
47
|
-
const batchTable = new tile_3d_batch_table_1.default(tile.batchTableJson, tile.batchTableBinary, instancesLength);
|
|
48
|
-
extractInstancedAttributes(tile, featureTable, batchTable, instancesLength);
|
|
49
|
-
return byteOffset;
|
|
50
|
-
}
|
|
51
|
-
// eslint-disable-next-line max-statements, complexity
|
|
52
|
-
function extractInstancedAttributes(tile, featureTable, batchTable, instancesLength) {
|
|
53
|
-
const instances = new Array(instancesLength);
|
|
54
|
-
const instancePosition = new core_1.Vector3();
|
|
55
|
-
const instanceNormalRight = new core_1.Vector3();
|
|
56
|
-
const instanceNormalUp = new core_1.Vector3();
|
|
57
|
-
const instanceNormalForward = new core_1.Vector3();
|
|
58
|
-
const instanceRotation = new core_1.Matrix3();
|
|
59
|
-
const instanceQuaternion = new core_1.Quaternion();
|
|
60
|
-
const instanceScale = new core_1.Vector3();
|
|
61
|
-
const instanceTranslationRotationScale = {};
|
|
62
|
-
const instanceTransform = new core_1.Matrix4();
|
|
63
|
-
const scratch1 = [];
|
|
64
|
-
const scratch2 = [];
|
|
65
|
-
const scratch3 = [];
|
|
66
|
-
const scratch4 = [];
|
|
67
|
-
for (let i = 0; i < instancesLength; i++) {
|
|
68
|
-
let position;
|
|
69
|
-
// Get the instance position
|
|
70
|
-
if (featureTable.hasProperty('POSITION')) {
|
|
71
|
-
position = featureTable.getProperty('POSITION', math_1.GL.FLOAT, 3, i, instancePosition);
|
|
72
|
-
}
|
|
73
|
-
else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
|
|
74
|
-
position = featureTable.getProperty('POSITION_QUANTIZED', math_1.GL.UNSIGNED_SHORT, 3, i, instancePosition);
|
|
75
|
-
const quantizedVolumeOffset = featureTable.getGlobalProperty('QUANTIZED_VOLUME_OFFSET', math_1.GL.FLOAT, 3);
|
|
76
|
-
if (!quantizedVolumeOffset) {
|
|
77
|
-
throw new Error('i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.');
|
|
78
|
-
}
|
|
79
|
-
const quantizedVolumeScale = featureTable.getGlobalProperty('QUANTIZED_VOLUME_SCALE', math_1.GL.FLOAT, 3);
|
|
80
|
-
if (!quantizedVolumeScale) {
|
|
81
|
-
throw new Error('i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.');
|
|
82
|
-
}
|
|
83
|
-
const MAX_UNSIGNED_SHORT = 65535.0;
|
|
84
|
-
for (let j = 0; j < 3; j++) {
|
|
85
|
-
position[j] =
|
|
86
|
-
(position[j] / MAX_UNSIGNED_SHORT) * quantizedVolumeScale[j] + quantizedVolumeOffset[j];
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (!position) {
|
|
90
|
-
throw new Error('i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.');
|
|
91
|
-
}
|
|
92
|
-
instancePosition.copy(position);
|
|
93
|
-
// @ts-expect-error
|
|
94
|
-
instanceTranslationRotationScale.translation = instancePosition;
|
|
95
|
-
// Get the instance rotation
|
|
96
|
-
tile.normalUp = featureTable.getProperty('NORMAL_UP', math_1.GL.FLOAT, 3, i, scratch1);
|
|
97
|
-
tile.normalRight = featureTable.getProperty('NORMAL_RIGHT', math_1.GL.FLOAT, 3, i, scratch2);
|
|
98
|
-
const hasCustomOrientation = false;
|
|
99
|
-
if (tile.normalUp) {
|
|
100
|
-
if (!tile.normalRight) {
|
|
101
|
-
throw new Error('i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.');
|
|
102
|
-
}
|
|
103
|
-
// Vector3.unpack(normalUp, 0, instanceNormalUp);
|
|
104
|
-
// Vector3.unpack(normalRight, 0, instanceNormalRight);
|
|
105
|
-
tile.hasCustomOrientation = true;
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
tile.octNormalUp = featureTable.getProperty('NORMAL_UP_OCT32P', math_1.GL.UNSIGNED_SHORT, 2, i, scratch1);
|
|
109
|
-
tile.octNormalRight = featureTable.getProperty('NORMAL_RIGHT_OCT32P', math_1.GL.UNSIGNED_SHORT, 2, i, scratch2);
|
|
110
|
-
if (tile.octNormalUp) {
|
|
111
|
-
if (!tile.octNormalRight) {
|
|
112
|
-
throw new Error('i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P');
|
|
113
|
-
}
|
|
114
|
-
throw new Error('i3dm: oct-encoded orientation not implemented');
|
|
115
|
-
/*
|
|
116
|
-
AttributeCompression.octDecodeInRange(octNormalUp[0], octNormalUp[1], 65535, instanceNormalUp);
|
|
117
|
-
AttributeCompression.octDecodeInRange(octNormalRight[0], octNormalRight[1], 65535, instanceNormalRight);
|
|
118
|
-
hasCustomOrientation = true;
|
|
119
|
-
*/
|
|
120
|
-
}
|
|
121
|
-
else if (tile.eastNorthUp) {
|
|
122
|
-
geospatial_1.Ellipsoid.WGS84.eastNorthUpToFixedFrame(instancePosition, instanceTransform);
|
|
123
|
-
instanceTransform.getRotationMatrix3(instanceRotation);
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
instanceRotation.identity();
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
if (hasCustomOrientation) {
|
|
130
|
-
instanceNormalForward.copy(instanceNormalRight).cross(instanceNormalUp).normalize();
|
|
131
|
-
instanceRotation.setColumn(0, instanceNormalRight);
|
|
132
|
-
instanceRotation.setColumn(1, instanceNormalUp);
|
|
133
|
-
instanceRotation.setColumn(2, instanceNormalForward);
|
|
134
|
-
}
|
|
135
|
-
instanceQuaternion.fromMatrix3(instanceRotation);
|
|
136
|
-
// @ts-expect-error
|
|
137
|
-
instanceTranslationRotationScale.rotation = instanceQuaternion;
|
|
138
|
-
// Get the instance scale
|
|
139
|
-
instanceScale.set(1.0, 1.0, 1.0);
|
|
140
|
-
const scale = featureTable.getProperty('SCALE', math_1.GL.FLOAT, 1, i, scratch3);
|
|
141
|
-
if (Number.isFinite(scale)) {
|
|
142
|
-
instanceScale.multiplyByScalar(scale);
|
|
143
|
-
}
|
|
144
|
-
const nonUniformScale = featureTable.getProperty('SCALE_NON_UNIFORM', math_1.GL.FLOAT, 3, i, scratch1);
|
|
145
|
-
if (nonUniformScale) {
|
|
146
|
-
instanceScale.scale(nonUniformScale);
|
|
147
|
-
}
|
|
148
|
-
// @ts-expect-error
|
|
149
|
-
instanceTranslationRotationScale.scale = instanceScale;
|
|
150
|
-
// Get the batchId
|
|
151
|
-
let batchId = featureTable.getProperty('BATCH_ID', math_1.GL.UNSIGNED_SHORT, 1, i, scratch4);
|
|
152
|
-
if (batchId === undefined) {
|
|
153
|
-
// If BATCH_ID semantic is undefined, batchId is just the instance number
|
|
154
|
-
batchId = i;
|
|
155
|
-
}
|
|
156
|
-
// @ts-expect-error
|
|
157
|
-
const rotationMatrix = new core_1.Matrix4().fromQuaternion(instanceTranslationRotationScale.rotation);
|
|
158
|
-
// Create the model matrix and the instance
|
|
159
|
-
instanceTransform.identity();
|
|
160
|
-
// @ts-expect-error
|
|
161
|
-
instanceTransform.translate(instanceTranslationRotationScale.translation);
|
|
162
|
-
instanceTransform.multiplyRight(rotationMatrix);
|
|
163
|
-
// @ts-expect-error
|
|
164
|
-
instanceTransform.scale(instanceTranslationRotationScale.scale);
|
|
165
|
-
const modelMatrix = instanceTransform.clone();
|
|
166
|
-
instances[i] = {
|
|
167
|
-
modelMatrix,
|
|
168
|
-
batchId
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
tile.instances = instances;
|
|
172
|
-
}
|
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This file is derived from the Cesium code base under Apache 2 license
|
|
3
|
-
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
4
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.loadDraco = exports.parsePointCloud3DTile = void 0;
|
|
9
|
-
const draco_1 = require("@loaders.gl/draco");
|
|
10
|
-
const math_1 = require("@loaders.gl/math");
|
|
11
|
-
const core_1 = require("@math.gl/core");
|
|
12
|
-
const tile_3d_feature_table_1 = __importDefault(require("../classes/tile-3d-feature-table"));
|
|
13
|
-
const tile_3d_batch_table_1 = __importDefault(require("../classes/tile-3d-batch-table"));
|
|
14
|
-
const parse_3d_tile_header_1 = require("./helpers/parse-3d-tile-header");
|
|
15
|
-
const parse_3d_tile_tables_1 = require("./helpers/parse-3d-tile-tables");
|
|
16
|
-
const normalize_3d_tile_colors_1 = require("./helpers/normalize-3d-tile-colors");
|
|
17
|
-
const normalize_3d_tile_normals_1 = require("./helpers/normalize-3d-tile-normals");
|
|
18
|
-
const normalize_3d_tile_positions_1 = require("./helpers/normalize-3d-tile-positions");
|
|
19
|
-
async function parsePointCloud3DTile(tile, arrayBuffer, byteOffset, options, context) {
|
|
20
|
-
byteOffset = (0, parse_3d_tile_header_1.parse3DTileHeaderSync)(tile, arrayBuffer, byteOffset);
|
|
21
|
-
byteOffset = (0, parse_3d_tile_tables_1.parse3DTileTablesHeaderSync)(tile, arrayBuffer, byteOffset);
|
|
22
|
-
byteOffset = (0, parse_3d_tile_tables_1.parse3DTileTablesSync)(tile, arrayBuffer, byteOffset, options);
|
|
23
|
-
initializeTile(tile);
|
|
24
|
-
const { featureTable, batchTable } = parsePointCloudTables(tile);
|
|
25
|
-
await parseDraco(tile, featureTable, batchTable, options, context);
|
|
26
|
-
parsePositions(tile, featureTable, options);
|
|
27
|
-
// @ts-expect-error TODO - do we need to assert on the batch table?
|
|
28
|
-
parseColors(tile, featureTable, batchTable);
|
|
29
|
-
parseNormals(tile, featureTable);
|
|
30
|
-
return byteOffset;
|
|
31
|
-
}
|
|
32
|
-
exports.parsePointCloud3DTile = parsePointCloud3DTile;
|
|
33
|
-
function initializeTile(tile) {
|
|
34
|
-
// Initialize point cloud tile defaults
|
|
35
|
-
tile.attributes = {
|
|
36
|
-
positions: null,
|
|
37
|
-
colors: null,
|
|
38
|
-
normals: null,
|
|
39
|
-
batchIds: null
|
|
40
|
-
};
|
|
41
|
-
tile.isQuantized = false;
|
|
42
|
-
tile.isTranslucent = false;
|
|
43
|
-
tile.isRGB565 = false;
|
|
44
|
-
tile.isOctEncoded16P = false;
|
|
45
|
-
}
|
|
46
|
-
function parsePointCloudTables(tile) {
|
|
47
|
-
const featureTable = new tile_3d_feature_table_1.default(tile.featureTableJson, tile.featureTableBinary);
|
|
48
|
-
const pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');
|
|
49
|
-
if (!Number.isFinite(pointsLength)) {
|
|
50
|
-
throw new Error('POINTS_LENGTH must be defined');
|
|
51
|
-
}
|
|
52
|
-
featureTable.featuresLength = pointsLength;
|
|
53
|
-
tile.featuresLength = pointsLength;
|
|
54
|
-
tile.pointsLength = pointsLength;
|
|
55
|
-
tile.pointCount = pointsLength;
|
|
56
|
-
tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', math_1.GL.FLOAT, 3);
|
|
57
|
-
const batchTable = parseBatchIds(tile, featureTable);
|
|
58
|
-
return { featureTable, batchTable };
|
|
59
|
-
}
|
|
60
|
-
function parsePositions(tile, featureTable, options) {
|
|
61
|
-
tile.attributes = tile.attributes || {
|
|
62
|
-
positions: null,
|
|
63
|
-
colors: null,
|
|
64
|
-
normals: null,
|
|
65
|
-
batchIds: null
|
|
66
|
-
};
|
|
67
|
-
if (!tile.attributes.positions) {
|
|
68
|
-
if (featureTable.hasProperty('POSITION')) {
|
|
69
|
-
tile.attributes.positions = featureTable.getPropertyArray('POSITION', math_1.GL.FLOAT, 3);
|
|
70
|
-
}
|
|
71
|
-
else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
|
|
72
|
-
const positions = featureTable.getPropertyArray('POSITION_QUANTIZED', math_1.GL.UNSIGNED_SHORT, 3);
|
|
73
|
-
tile.isQuantized = true;
|
|
74
|
-
tile.quantizedRange = (1 << 16) - 1;
|
|
75
|
-
tile.quantizedVolumeScale = featureTable.getGlobalProperty('QUANTIZED_VOLUME_SCALE', math_1.GL.FLOAT, 3);
|
|
76
|
-
if (!tile.quantizedVolumeScale) {
|
|
77
|
-
throw new Error('QUANTIZED_VOLUME_SCALE must be defined for quantized positions.');
|
|
78
|
-
}
|
|
79
|
-
tile.quantizedVolumeOffset = featureTable.getGlobalProperty('QUANTIZED_VOLUME_OFFSET', math_1.GL.FLOAT, 3);
|
|
80
|
-
if (!tile.quantizedVolumeOffset) {
|
|
81
|
-
throw new Error('QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.');
|
|
82
|
-
}
|
|
83
|
-
tile.attributes.positions = (0, normalize_3d_tile_positions_1.normalize3DTilePositionAttribute)(tile, positions, options);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (!tile.attributes.positions) {
|
|
87
|
-
throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function parseColors(tile, featureTable, batchTable) {
|
|
91
|
-
tile.attributes = tile.attributes || {
|
|
92
|
-
positions: null,
|
|
93
|
-
colors: null,
|
|
94
|
-
normals: null,
|
|
95
|
-
batchIds: null
|
|
96
|
-
};
|
|
97
|
-
if (!tile.attributes.colors) {
|
|
98
|
-
let colors = null;
|
|
99
|
-
if (featureTable.hasProperty('RGBA')) {
|
|
100
|
-
colors = featureTable.getPropertyArray('RGBA', math_1.GL.UNSIGNED_BYTE, 4);
|
|
101
|
-
tile.isTranslucent = true;
|
|
102
|
-
}
|
|
103
|
-
else if (featureTable.hasProperty('RGB')) {
|
|
104
|
-
colors = featureTable.getPropertyArray('RGB', math_1.GL.UNSIGNED_BYTE, 3);
|
|
105
|
-
}
|
|
106
|
-
else if (featureTable.hasProperty('RGB565')) {
|
|
107
|
-
colors = featureTable.getPropertyArray('RGB565', math_1.GL.UNSIGNED_SHORT, 1);
|
|
108
|
-
tile.isRGB565 = true;
|
|
109
|
-
}
|
|
110
|
-
tile.attributes.colors = (0, normalize_3d_tile_colors_1.normalize3DTileColorAttribute)(tile, colors, batchTable);
|
|
111
|
-
}
|
|
112
|
-
if (featureTable.hasProperty('CONSTANT_RGBA')) {
|
|
113
|
-
tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', math_1.GL.UNSIGNED_BYTE, 4);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function parseNormals(tile, featureTable) {
|
|
117
|
-
tile.attributes = tile.attributes || {
|
|
118
|
-
positions: null,
|
|
119
|
-
colors: null,
|
|
120
|
-
normals: null,
|
|
121
|
-
batchIds: null
|
|
122
|
-
};
|
|
123
|
-
if (!tile.attributes.normals) {
|
|
124
|
-
let normals = null;
|
|
125
|
-
if (featureTable.hasProperty('NORMAL')) {
|
|
126
|
-
normals = featureTable.getPropertyArray('NORMAL', math_1.GL.FLOAT, 3);
|
|
127
|
-
}
|
|
128
|
-
else if (featureTable.hasProperty('NORMAL_OCT16P')) {
|
|
129
|
-
normals = featureTable.getPropertyArray('NORMAL_OCT16P', math_1.GL.UNSIGNED_BYTE, 2);
|
|
130
|
-
tile.isOctEncoded16P = true;
|
|
131
|
-
}
|
|
132
|
-
tile.attributes.normals = (0, normalize_3d_tile_normals_1.normalize3DTileNormalAttribute)(tile, normals);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
function parseBatchIds(tile, featureTable) {
|
|
136
|
-
let batchTable = null;
|
|
137
|
-
if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {
|
|
138
|
-
tile.batchIds = featureTable.getPropertyArray('BATCH_ID', math_1.GL.UNSIGNED_SHORT, 1);
|
|
139
|
-
if (tile.batchIds) {
|
|
140
|
-
const batchFeatureLength = featureTable.getGlobalProperty('BATCH_LENGTH');
|
|
141
|
-
if (!batchFeatureLength) {
|
|
142
|
-
throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');
|
|
143
|
-
}
|
|
144
|
-
const { batchTableJson, batchTableBinary } = tile;
|
|
145
|
-
batchTable = new tile_3d_batch_table_1.default(batchTableJson, batchTableBinary, batchFeatureLength);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return batchTable;
|
|
149
|
-
}
|
|
150
|
-
// eslint-disable-next-line complexity
|
|
151
|
-
async function parseDraco(tile, featureTable, batchTable, options, context) {
|
|
152
|
-
let dracoBuffer;
|
|
153
|
-
let dracoFeatureTableProperties;
|
|
154
|
-
let dracoBatchTableProperties;
|
|
155
|
-
const batchTableDraco = tile.batchTableJson &&
|
|
156
|
-
tile.batchTableJson.extensions &&
|
|
157
|
-
tile.batchTableJson.extensions['3DTILES_draco_point_compression'];
|
|
158
|
-
if (batchTableDraco) {
|
|
159
|
-
dracoBatchTableProperties = batchTableDraco.properties;
|
|
160
|
-
}
|
|
161
|
-
const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');
|
|
162
|
-
if (featureTableDraco) {
|
|
163
|
-
dracoFeatureTableProperties = featureTableDraco.properties;
|
|
164
|
-
const dracoByteOffset = featureTableDraco.byteOffset;
|
|
165
|
-
const dracoByteLength = featureTableDraco.byteLength;
|
|
166
|
-
if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {
|
|
167
|
-
throw new Error('Draco properties, byteOffset, and byteLength must be defined');
|
|
168
|
-
}
|
|
169
|
-
dracoBuffer = (tile.featureTableBinary || []).slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
|
|
170
|
-
tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);
|
|
171
|
-
tile.hasColors =
|
|
172
|
-
Number.isFinite(dracoFeatureTableProperties.RGB) ||
|
|
173
|
-
Number.isFinite(dracoFeatureTableProperties.RGBA);
|
|
174
|
-
tile.hasNormals = Number.isFinite(dracoFeatureTableProperties.NORMAL);
|
|
175
|
-
tile.hasBatchIds = Number.isFinite(dracoFeatureTableProperties.BATCH_ID);
|
|
176
|
-
tile.isTranslucent = Number.isFinite(dracoFeatureTableProperties.RGBA);
|
|
177
|
-
}
|
|
178
|
-
if (!dracoBuffer) {
|
|
179
|
-
return true;
|
|
180
|
-
}
|
|
181
|
-
const dracoData = {
|
|
182
|
-
buffer: dracoBuffer,
|
|
183
|
-
properties: { ...dracoFeatureTableProperties, ...dracoBatchTableProperties },
|
|
184
|
-
featureTableProperties: dracoFeatureTableProperties,
|
|
185
|
-
batchTableProperties: dracoBatchTableProperties,
|
|
186
|
-
dequantizeInShader: false
|
|
187
|
-
};
|
|
188
|
-
return await loadDraco(tile, dracoData, options, context);
|
|
189
|
-
}
|
|
190
|
-
// eslint-disable-next-line complexity, max-statements
|
|
191
|
-
async function loadDraco(tile, dracoData, options, context) {
|
|
192
|
-
if (!context) {
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
const { parse } = context;
|
|
196
|
-
const dracoOptions = {
|
|
197
|
-
...options,
|
|
198
|
-
draco: {
|
|
199
|
-
...options?.draco,
|
|
200
|
-
extraAttributes: dracoData.batchTableProperties || {}
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
// The entire tileset might be included, too expensive to serialize
|
|
204
|
-
delete dracoOptions['3d-tiles'];
|
|
205
|
-
const data = await parse(dracoData.buffer, draco_1.DracoLoader, dracoOptions);
|
|
206
|
-
const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
|
|
207
|
-
const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
|
|
208
|
-
const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
|
|
209
|
-
const decodedBatchIds = data.attributes.BATCH_ID && data.attributes.BATCH_ID.value;
|
|
210
|
-
const isQuantizedDraco = decodedPositions && data.attributes.POSITION.value.quantization;
|
|
211
|
-
const isOctEncodedDraco = decodedNormals && data.attributes.NORMAL.value.quantization;
|
|
212
|
-
if (isQuantizedDraco) {
|
|
213
|
-
// Draco quantization range == quantized volume scale - size in meters of the quantized volume
|
|
214
|
-
// Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc
|
|
215
|
-
const quantization = data.POSITION.data.quantization;
|
|
216
|
-
const range = quantization.range;
|
|
217
|
-
tile.quantizedVolumeScale = new core_1.Vector3(range, range, range);
|
|
218
|
-
tile.quantizedVolumeOffset = new core_1.Vector3(quantization.minValues);
|
|
219
|
-
tile.quantizedRange = (1 << quantization.quantizationBits) - 1.0;
|
|
220
|
-
tile.isQuantizedDraco = true;
|
|
221
|
-
}
|
|
222
|
-
if (isOctEncodedDraco) {
|
|
223
|
-
tile.octEncodedRange = (1 << data.NORMAL.data.quantization.quantizationBits) - 1.0;
|
|
224
|
-
tile.isOctEncodedDraco = true;
|
|
225
|
-
}
|
|
226
|
-
// Extra batch table attributes
|
|
227
|
-
const batchTableAttributes = {};
|
|
228
|
-
if (dracoData.batchTableProperties) {
|
|
229
|
-
for (const attributeName of Object.keys(dracoData.batchTableProperties)) {
|
|
230
|
-
if (data.attributes[attributeName] && data.attributes[attributeName].value) {
|
|
231
|
-
batchTableAttributes[attributeName.toLowerCase()] = data.attributes[attributeName].value;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
tile.attributes = {
|
|
236
|
-
positions: decodedPositions,
|
|
237
|
-
colors: (0, normalize_3d_tile_colors_1.normalize3DTileColorAttribute)(tile, decodedColors, undefined),
|
|
238
|
-
normals: decodedNormals,
|
|
239
|
-
batchIds: decodedBatchIds,
|
|
240
|
-
...batchTableAttributes
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
exports.loadDraco = loadDraco;
|
|
244
|
-
// TODO - this is the remaining code from Cesium's parser
|
|
245
|
-
/*
|
|
246
|
-
const batchTable = new Tile3DBatchTable(tile);
|
|
247
|
-
|
|
248
|
-
// parseDracoBuffer(tile, featureTable, batchTable);
|
|
249
|
-
|
|
250
|
-
if (!tile.attributes.positions) {
|
|
251
|
-
throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
/*
|
|
255
|
-
|
|
256
|
-
if (!tile.attributes.positions) {
|
|
257
|
-
if (featureTable.hasProperty('POSITION')) {
|
|
258
|
-
tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);
|
|
259
|
-
} else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
|
|
260
|
-
tile.attributes.positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
if (!tile.colors) {
|
|
264
|
-
if (featureTable.hasProperty('RGBA')) {
|
|
265
|
-
tile.colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);
|
|
266
|
-
tile.isTranslucent = true;
|
|
267
|
-
} else if (featureTable.hasProperty('RGB')) {
|
|
268
|
-
tile.colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);
|
|
269
|
-
} else if (featureTable.hasPropertry('RGB565')) {
|
|
270
|
-
tile.colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);
|
|
271
|
-
tile.isRGB565 = true;
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (!tile.attributes.normals) {
|
|
276
|
-
if (featureTable.getPropertry('NORMAL')) {
|
|
277
|
-
tile.attributes.normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);
|
|
278
|
-
} else if (featureTable.getProperty('NORMAL_OCT16P')) {
|
|
279
|
-
tile.attributes.normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);
|
|
280
|
-
tile.isOctEncoded16P = true;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
if (!tile.batchIds) {
|
|
285
|
-
if (featureTable.hasProperty('BATCH_ID')) {
|
|
286
|
-
tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (!tile.attributes.positions) {
|
|
291
|
-
throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if (featureTable.getPropertry('CONSTANT_RGBA')) {
|
|
295
|
-
tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
if (tile.batchIds) {
|
|
299
|
-
const batchLength = featureTable.getGlobalProperty('BATCH_LENGTH');
|
|
300
|
-
if (!defined(batchLength)) {
|
|
301
|
-
throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
if (defined(batchTableBinary)) {
|
|
305
|
-
// Copy the batchTableBinary section and let the underlying ArrayBuffer be freed
|
|
306
|
-
batchTableBinary = new Uint8Array(batchTableBinary);
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
if (defined(pointCloud._batchTableLoaded)) {
|
|
310
|
-
pointCloud._batchTableLoaded(batchLength, batchTableJson, batchTableBinary);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// If points are not batched and there are per-point properties, use these properties for styling purposes
|
|
315
|
-
var styleableProperties;
|
|
316
|
-
if (!hasBatchIds && defined(batchTableBinary)) {
|
|
317
|
-
tile.styleableProperties = Cesium3DTileBatchTable.getBinaryProperties(
|
|
318
|
-
pointsLength,
|
|
319
|
-
batchTableJson,
|
|
320
|
-
batchTableBinary
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
tile.draco = draco;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
// Separate parsing and decoding of Draco
|
|
328
|
-
export function parseDracoBuffer(tile, featureTable, batchTable) {
|
|
329
|
-
let dracoBuffer;
|
|
330
|
-
let dracoFeatureTableProperties;
|
|
331
|
-
let dracoBatchTableProperties;
|
|
332
|
-
|
|
333
|
-
const batchTableDraco = batchTable.getExtension('3DTILES_draco_point_compression');
|
|
334
|
-
if (batchTableDraco) {
|
|
335
|
-
dracoBatchTableProperties = batchTableDraco.properties;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');
|
|
339
|
-
if (featureTableDraco) {
|
|
340
|
-
dracoFeatureTableProperties = featureTableDraco.properties;
|
|
341
|
-
const dracoByteOffset = featureTableDraco.byteOffset;
|
|
342
|
-
const dracoByteLength = featureTableDraco.byteLength;
|
|
343
|
-
if (!dracoFeatureTableProperties || !dracoByteOffset || !dracoByteLength) {
|
|
344
|
-
throw new Error('Draco properties, byteOffset, and byteLength must be defined');
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
dracoBuffer = arraySlice(
|
|
348
|
-
featureTableBinary,
|
|
349
|
-
dracoByteOffset,
|
|
350
|
-
dracoByteOffset + dracoByteLength
|
|
351
|
-
);
|
|
352
|
-
tile.hasPositions = dracoFeatureTableProperties.POSITION;
|
|
353
|
-
tile.hasColors = dracoFeatureTableProperties.RGB || dracoFeatureTableProperties.RGBA;
|
|
354
|
-
tile.hasNormals = dracoFeatureTableProperties.NORMAL;
|
|
355
|
-
tile.hasBatchIds = dracoFeatureTableProperties.BATCH_ID;
|
|
356
|
-
tile.isTranslucent = dracoFeatureTableProperties.RGBA;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
if (dracoBuffer) {
|
|
360
|
-
tile.draco = {
|
|
361
|
-
buffer: dracoBuffer,
|
|
362
|
-
properties: {...dracoFeatureTableProperties, ...dracoBatchTableProperties},
|
|
363
|
-
featureTableProperties: dracoFeatureTableProperties,
|
|
364
|
-
batchTableProperties: dracoBatchTableProperties,
|
|
365
|
-
dequantizeInShader: false
|
|
366
|
-
};
|
|
367
|
-
|
|
368
|
-
tile.decodingState = DECODING_STATE.NEEDS_DECODE;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/*
|
|
373
|
-
function decodeDraco(tile, context) {
|
|
374
|
-
if (tile.decodingState === DECODING_STATE.READY) {
|
|
375
|
-
return false;
|
|
376
|
-
}
|
|
377
|
-
if (tile.decodingState === DECODING_STATE.NEEDS_DECODE) {
|
|
378
|
-
var parsedContent = tile._parsedContent;
|
|
379
|
-
var draco = parsedContent.draco;
|
|
380
|
-
var decodePromise = DracoLoader.decodePointCloud(draco, context);
|
|
381
|
-
if (defined(decodePromise)) {
|
|
382
|
-
tile.decodingState = DECODING_STATE.DECODING;
|
|
383
|
-
decodePromise.then(function(result) {
|
|
384
|
-
tile.decodingState = DECODING_STATE.READY;
|
|
385
|
-
var decodedPositions = defined(result.POSITION) ? result.POSITION.array : undefined;
|
|
386
|
-
var decodedRgb = defined(result.RGB) ? result.RGB.array : undefined;
|
|
387
|
-
var decodedRgba = defined(result.RGBA) ? result.RGBA.array : undefined;
|
|
388
|
-
var decodedNormals = defined(result.NORMAL) ? result.NORMAL.array : undefined;
|
|
389
|
-
var decodedBatchIds = defined(result.BATCH_ID) ? result.BATCH_ID.array : undefined;
|
|
390
|
-
var isQuantizedDraco = defined(decodedPositions) && defined(result.POSITION.data.quantization);
|
|
391
|
-
var isOctEncodedDraco = defined(decodedNormals) && defined(result.NORMAL.data.quantization);
|
|
392
|
-
if (isQuantizedDraco) {
|
|
393
|
-
// Draco quantization range == quantized volume scale - size in meters of the quantized volume
|
|
394
|
-
// Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc
|
|
395
|
-
var quantization = result.POSITION.data.quantization;
|
|
396
|
-
var range = quantization.range;
|
|
397
|
-
tile._quantizedVolumeScale = Cartesian3.fromElements(range, range, range);
|
|
398
|
-
tile._quantizedVolumeOffset = Cartesian3.unpack(quantization.minValues);
|
|
399
|
-
tile._quantizedRange = (1 << quantization.quantizationBits) - 1.0;
|
|
400
|
-
tile._isQuantizedDraco = true;
|
|
401
|
-
}
|
|
402
|
-
if (isOctEncodedDraco) {
|
|
403
|
-
tile._octEncodedRange = (1 << result.NORMAL.data.quantization.quantizationBits) - 1.0;
|
|
404
|
-
tile._isOctEncodedDraco = true;
|
|
405
|
-
}
|
|
406
|
-
var styleableProperties = parsedContent.styleableProperties;
|
|
407
|
-
var batchTableProperties = draco.batchTableProperties;
|
|
408
|
-
for (var name in batchTableProperties) {
|
|
409
|
-
if (batchTableProperties.hasOwnProperty(name)) {
|
|
410
|
-
var property = result[name];
|
|
411
|
-
if (!defined(styleableProperties)) {
|
|
412
|
-
styleableProperties = {};
|
|
413
|
-
}
|
|
414
|
-
styleableProperties[name] = {
|
|
415
|
-
typedArray : property.array,
|
|
416
|
-
componentCount : property.data.componentsPerAttribute
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
parsedContent.positions = defaultValue(decodedPositions, parsedContent.positions);
|
|
421
|
-
parsedContent.colors = defaultValue(defaultValue(decodedRgba, decodedRgb), parsedContent.colors);
|
|
422
|
-
parsedContent.normals = defaultValue(decodedNormals, parsedContent.normals);
|
|
423
|
-
parsedContent.batchIds = defaultValue(decodedBatchIds, parsedContent.batchIds);
|
|
424
|
-
parsedContent.styleableProperties = styleableProperties;
|
|
425
|
-
}).otherwise(function(error) {
|
|
426
|
-
tile.decodingState = DECODING_STATE.FAILED;
|
|
427
|
-
tile._readyPromise.reject(error);
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
return true;
|
|
432
|
-
}
|
|
433
|
-
*/
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This file is derived from the Cesium code base under Apache 2 license
|
|
3
|
-
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.parse3DTile = void 0;
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
|
-
const parse_utils_1 = require("./helpers/parse-utils");
|
|
8
|
-
const parse_3d_tile_point_cloud_1 = require("./parse-3d-tile-point-cloud");
|
|
9
|
-
const parse_3d_tile_batched_model_1 = require("./parse-3d-tile-batched-model");
|
|
10
|
-
const parse_3d_tile_instanced_model_1 = require("./parse-3d-tile-instanced-model");
|
|
11
|
-
const parse_3d_tile_composite_1 = require("./parse-3d-tile-composite");
|
|
12
|
-
const parse_3d_tile_gltf_1 = require("./parse-3d-tile-gltf");
|
|
13
|
-
// Extracts
|
|
14
|
-
async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = {}) {
|
|
15
|
-
tile.byteOffset = byteOffset;
|
|
16
|
-
tile.type = (0, parse_utils_1.getMagicString)(arrayBuffer, byteOffset);
|
|
17
|
-
switch (tile.type) {
|
|
18
|
-
case constants_1.TILE3D_TYPE.COMPOSITE:
|
|
19
|
-
// Note: We pass this function as argument so that embedded tiles can be parsed recursively
|
|
20
|
-
return await (0, parse_3d_tile_composite_1.parseComposite3DTile)(tile, arrayBuffer, byteOffset, options, context, parse3DTile);
|
|
21
|
-
case constants_1.TILE3D_TYPE.BATCHED_3D_MODEL:
|
|
22
|
-
return await (0, parse_3d_tile_batched_model_1.parseBatchedModel3DTile)(tile, arrayBuffer, byteOffset, options, context);
|
|
23
|
-
case constants_1.TILE3D_TYPE.GLTF:
|
|
24
|
-
return await (0, parse_3d_tile_gltf_1.parseGltf3DTile)(tile, arrayBuffer, options, context);
|
|
25
|
-
case constants_1.TILE3D_TYPE.INSTANCED_3D_MODEL:
|
|
26
|
-
return await (0, parse_3d_tile_instanced_model_1.parseInstancedModel3DTile)(tile, arrayBuffer, byteOffset, options, context);
|
|
27
|
-
case constants_1.TILE3D_TYPE.POINT_CLOUD:
|
|
28
|
-
return await (0, parse_3d_tile_point_cloud_1.parsePointCloud3DTile)(tile, arrayBuffer, byteOffset, options, context);
|
|
29
|
-
default:
|
|
30
|
-
throw new Error(`3DTileLoader: unknown type ${tile.type}`); // eslint-disable-line
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.parse3DTile = parse3DTile;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertS2BoundingVolumetoOBB = void 0;
|
|
4
|
-
const core_1 = require("@math.gl/core");
|
|
5
|
-
const culling_1 = require("@math.gl/culling");
|
|
6
|
-
const index_1 = require("../../utils/s2/index");
|
|
7
|
-
const index_2 = require("../../utils/s2/index");
|
|
8
|
-
const geospatial_1 = require("@math.gl/geospatial");
|
|
9
|
-
/**
|
|
10
|
-
* Converts S2VolumeInfo to OrientedBoundingBox
|
|
11
|
-
* @param {S2VolumeInfo} s2VolumeInfo - s2 volume to convert
|
|
12
|
-
* @returns Oriented Bounding Box of type Box
|
|
13
|
-
*/
|
|
14
|
-
function convertS2BoundingVolumetoOBB(s2VolumeInfo) {
|
|
15
|
-
const token = s2VolumeInfo.token;
|
|
16
|
-
const heightInfo = {
|
|
17
|
-
minimumHeight: s2VolumeInfo.minimumHeight,
|
|
18
|
-
maximumHeight: s2VolumeInfo.maximumHeight
|
|
19
|
-
};
|
|
20
|
-
const corners = (0, index_1.getS2OrientedBoundingBoxCornerPoints)(token, heightInfo);
|
|
21
|
-
// Add a point that doesn't allow the box dive under the Earth
|
|
22
|
-
const center = (0, index_2.getS2LngLat)(token);
|
|
23
|
-
const centerLng = center[0];
|
|
24
|
-
const centerLat = center[1];
|
|
25
|
-
const point = geospatial_1.Ellipsoid.WGS84.cartographicToCartesian([
|
|
26
|
-
centerLng,
|
|
27
|
-
centerLat,
|
|
28
|
-
heightInfo.maximumHeight
|
|
29
|
-
]);
|
|
30
|
-
const centerPointAdditional = new core_1.Vector3(point[0], point[1], point[2]);
|
|
31
|
-
corners.push(centerPointAdditional);
|
|
32
|
-
// corners should be an array of Vector3 (XYZ)
|
|
33
|
-
const obb = (0, culling_1.makeOrientedBoundingBoxFromPoints)(corners);
|
|
34
|
-
const box = [...obb.center, ...obb.halfAxes];
|
|
35
|
-
return box;
|
|
36
|
-
}
|
|
37
|
-
exports.convertS2BoundingVolumetoOBB = convertS2BoundingVolumetoOBB;
|