@loaders.gl/3d-tiles 3.1.0-alpha.5 → 3.1.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/bundle.d.ts +1 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +9973 -0
- package/dist/cesium-ion-loader.d.ts +1 -0
- package/dist/cesium-ion-loader.d.ts.map +1 -0
- package/dist/cesium-ion-loader.js +40 -0
- package/dist/es5/index.js +8 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -1
- package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
- package/dist/es5/lib/classes/tile-3d-batch-table.js +12 -1
- package/dist/es5/lib/classes/tile-3d-batch-table.js.map +1 -1
- package/dist/es5/lib/classes/tile-3d-feature-table.js +8 -2
- package/dist/es5/lib/classes/tile-3d-feature-table.js.map +1 -1
- package/dist/es5/lib/constants.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-composite.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile.js.map +1 -1
- package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js +73 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-utils.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -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 +26 -0
- package/dist/es5/tile-3d-subtree-loader.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -1
- package/dist/esm/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
- package/dist/esm/lib/classes/tile-3d-batch-table.js +16 -1
- package/dist/esm/lib/classes/tile-3d-batch-table.js.map +1 -1
- package/dist/esm/lib/classes/tile-3d-feature-table.js +9 -2
- package/dist/esm/lib/classes/tile-3d-feature-table.js.map +1 -1
- package/dist/esm/lib/constants.js.map +1 -1
- package/dist/esm/lib/encoders/encode-3d-tile-batched-model.js.map +1 -1
- package/dist/esm/lib/encoders/encode-3d-tile-composite.js.map +1 -1
- package/dist/esm/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -1
- package/dist/esm/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -1
- package/dist/esm/lib/encoders/encode-3d-tile.js.map +1 -1
- package/dist/esm/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js +64 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-utils.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -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 +14 -0
- package/dist/esm/tile-3d-subtree-loader.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/lib/classes/helpers/tile-3d-accessor-utils.d.ts +3 -2
- package/dist/lib/classes/helpers/tile-3d-accessor-utils.d.ts.map +1 -0
- package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +113 -0
- package/dist/lib/classes/tile-3d-batch-table-hierarchy.d.ts +4 -3
- package/dist/lib/classes/tile-3d-batch-table-hierarchy.d.ts.map +1 -0
- package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +197 -0
- package/dist/lib/classes/tile-3d-batch-table.d.ts +8 -14
- package/dist/lib/classes/tile-3d-batch-table.d.ts.map +1 -0
- package/dist/lib/classes/tile-3d-batch-table.js +245 -0
- package/dist/lib/classes/tile-3d-feature-table.d.ts +2 -1
- package/dist/lib/classes/tile-3d-feature-table.d.ts.map +1 -0
- package/dist/lib/classes/tile-3d-feature-table.js +72 -0
- package/dist/lib/constants.d.ts +21 -22
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +25 -0
- package/dist/lib/encoders/encode-3d-tile-batched-model.d.ts +2 -1
- package/dist/lib/encoders/encode-3d-tile-batched-model.d.ts.map +1 -0
- package/dist/lib/encoders/encode-3d-tile-batched-model.js +46 -0
- package/dist/lib/encoders/encode-3d-tile-composite.d.ts +2 -1
- package/dist/lib/encoders/encode-3d-tile-composite.d.ts.map +1 -0
- package/dist/lib/encoders/encode-3d-tile-composite.js +24 -0
- package/dist/lib/encoders/encode-3d-tile-instanced-model.d.ts +2 -1
- package/dist/lib/encoders/encode-3d-tile-instanced-model.d.ts.map +1 -0
- package/dist/lib/encoders/encode-3d-tile-instanced-model.js +38 -0
- package/dist/lib/encoders/encode-3d-tile-point-cloud.d.ts +2 -1
- package/dist/lib/encoders/encode-3d-tile-point-cloud.d.ts.map +1 -0
- package/dist/lib/encoders/encode-3d-tile-point-cloud.js +39 -0
- package/dist/lib/encoders/encode-3d-tile.d.ts +1 -0
- package/dist/lib/encoders/encode-3d-tile.d.ts.map +1 -0
- package/dist/lib/encoders/encode-3d-tile.js +33 -0
- package/dist/lib/encoders/helpers/encode-3d-tile-header.d.ts +3 -2
- package/dist/lib/encoders/helpers/encode-3d-tile-header.d.ts.map +1 -0
- package/dist/lib/encoders/helpers/encode-3d-tile-header.js +30 -0
- package/dist/lib/ion/ion.d.ts +1 -0
- package/dist/lib/ion/ion.d.ts.map +1 -0
- package/dist/lib/ion/ion.js +68 -0
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts +2 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +65 -0
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts +2 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +30 -0
- package/dist/lib/parsers/helpers/normalize-3d-tile-positions.d.ts +2 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-positions.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +42 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts +7 -6
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +88 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts +2 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-header.js +28 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts +9 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +74 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts +3 -2
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +93 -0
- package/dist/lib/parsers/helpers/parse-utils.d.ts +4 -3
- package/dist/lib/parsers/helpers/parse-utils.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/parse-utils.js +32 -0
- package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts +2 -1
- package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile-batched-model.js +33 -0
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts +2 -1
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile-composite.js +26 -0
- package/dist/lib/parsers/parse-3d-tile-header.d.ts +3 -2
- package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile-header.js +66 -0
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts +2 -1
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile-instanced-model.js +186 -0
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +3 -2
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile-point-cloud.js +411 -0
- package/dist/lib/parsers/parse-3d-tile.d.ts +2 -1
- package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile.js +34 -0
- package/dist/lib/utils/version.d.ts +2 -1
- package/dist/lib/utils/version.d.ts.map +1 -0
- package/dist/lib/utils/version.js +7 -0
- package/dist/tile-3d-subtree-loader.d.ts +7 -0
- package/dist/tile-3d-subtree-loader.d.ts.map +1 -0
- package/dist/tile-3d-subtree-loader.js +23 -0
- package/dist/tile-3d-writer.d.ts +1 -0
- package/dist/tile-3d-writer.d.ts.map +1 -0
- package/dist/tile-3d-writer.js +27 -0
- package/dist/tiles-3d-loader.d.ts +1 -0
- package/dist/tiles-3d-loader.d.ts.map +1 -0
- package/dist/tiles-3d-loader.js +73 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/package.json +9 -10
- package/src/index.ts +1 -0
- package/src/lib/classes/helpers/{tile-3d-accessor-utils.js → tile-3d-accessor-utils.ts} +0 -0
- package/src/lib/classes/{tile-3d-batch-table-hierarchy.js → tile-3d-batch-table-hierarchy.ts} +0 -0
- package/src/lib/classes/{tile-3d-batch-table.js → tile-3d-batch-table.ts} +14 -4
- package/src/lib/classes/{tile-3d-feature-table.js → tile-3d-feature-table.ts} +5 -2
- package/src/lib/{constants.js → constants.ts} +0 -0
- package/src/lib/encoders/{encode-3d-tile-batched-model.js → encode-3d-tile-batched-model.ts} +0 -0
- package/src/lib/encoders/{encode-3d-tile-composite.js → encode-3d-tile-composite.ts} +0 -0
- package/src/lib/encoders/{encode-3d-tile-instanced-model.js → encode-3d-tile-instanced-model.ts} +0 -0
- package/src/lib/encoders/{encode-3d-tile-point-cloud.js → encode-3d-tile-point-cloud.ts} +0 -0
- package/src/lib/encoders/{encode-3d-tile.js → encode-3d-tile.ts} +0 -0
- package/src/lib/encoders/helpers/{encode-3d-tile-header.js → encode-3d-tile-header.ts} +0 -0
- package/src/lib/parsers/helpers/{normalize-3d-tile-colors.js → normalize-3d-tile-colors.ts} +1 -1
- package/src/lib/parsers/helpers/{normalize-3d-tile-normals.js → normalize-3d-tile-normals.ts} +0 -0
- package/src/lib/parsers/helpers/{normalize-3d-tile-positions.js → normalize-3d-tile-positions.ts} +0 -0
- package/src/lib/parsers/helpers/{parse-3d-tile-gltf-view.js → parse-3d-tile-gltf-view.ts} +1 -1
- package/src/lib/parsers/helpers/{parse-3d-tile-header.js → parse-3d-tile-header.ts} +0 -0
- package/src/lib/parsers/helpers/parse-3d-tile-subtree.ts +104 -0
- package/src/lib/parsers/helpers/{parse-3d-tile-tables.js → parse-3d-tile-tables.ts} +1 -1
- package/src/lib/parsers/helpers/{parse-utils.js → parse-utils.ts} +0 -0
- package/src/lib/parsers/{parse-3d-tile-batched-model.js → parse-3d-tile-batched-model.ts} +0 -0
- package/src/lib/parsers/{parse-3d-tile-composite.js → parse-3d-tile-composite.ts} +0 -0
- package/src/lib/parsers/{parse-3d-tile-header.js → parse-3d-tile-header.ts} +1 -1
- package/src/lib/parsers/{parse-3d-tile-instanced-model.js → parse-3d-tile-instanced-model.ts} +6 -0
- package/src/lib/parsers/{parse-3d-tile-point-cloud.js → parse-3d-tile-point-cloud.ts} +2 -2
- package/src/lib/parsers/{parse-3d-tile.js → parse-3d-tile.ts} +4 -0
- package/src/lib/utils/{version.js → version.ts} +0 -0
- package/src/tile-3d-subtree-loader.ts +19 -0
- package/src/types.ts +33 -0
- package/dist/dist.min.js +0 -2
- package/dist/dist.min.js.map +0 -1
|
@@ -0,0 +1,411 @@
|
|
|
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
|
+
parseColors(tile, featureTable, batchTable);
|
|
28
|
+
parseNormals(tile, featureTable);
|
|
29
|
+
return byteOffset;
|
|
30
|
+
}
|
|
31
|
+
exports.parsePointCloud3DTile = parsePointCloud3DTile;
|
|
32
|
+
function initializeTile(tile) {
|
|
33
|
+
// Initialize point cloud tile defaults
|
|
34
|
+
tile.attributes = {
|
|
35
|
+
positions: null,
|
|
36
|
+
colors: null,
|
|
37
|
+
normals: null,
|
|
38
|
+
batchIds: null
|
|
39
|
+
};
|
|
40
|
+
tile.isQuantized = false;
|
|
41
|
+
tile.isTranslucent = false;
|
|
42
|
+
tile.isRGB565 = false;
|
|
43
|
+
tile.isOctEncoded16P = false;
|
|
44
|
+
}
|
|
45
|
+
function parsePointCloudTables(tile) {
|
|
46
|
+
const featureTable = new tile_3d_feature_table_1.default(tile.featureTableJson, tile.featureTableBinary);
|
|
47
|
+
const pointsLength = featureTable.getGlobalProperty('POINTS_LENGTH');
|
|
48
|
+
if (!Number.isFinite(pointsLength)) {
|
|
49
|
+
throw new Error('POINTS_LENGTH must be defined');
|
|
50
|
+
}
|
|
51
|
+
featureTable.featuresLength = pointsLength;
|
|
52
|
+
tile.featuresLength = pointsLength;
|
|
53
|
+
tile.pointsLength = pointsLength;
|
|
54
|
+
tile.pointCount = pointsLength;
|
|
55
|
+
tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', math_1.GL.FLOAT, 3);
|
|
56
|
+
const batchTable = parseBatchIds(tile, featureTable);
|
|
57
|
+
return { featureTable, batchTable };
|
|
58
|
+
}
|
|
59
|
+
function parsePositions(tile, featureTable, options) {
|
|
60
|
+
if (!tile.attributes.positions) {
|
|
61
|
+
if (featureTable.hasProperty('POSITION')) {
|
|
62
|
+
tile.attributes.positions = featureTable.getPropertyArray('POSITION', math_1.GL.FLOAT, 3);
|
|
63
|
+
}
|
|
64
|
+
else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
|
|
65
|
+
const positions = featureTable.getPropertyArray('POSITION_QUANTIZED', math_1.GL.UNSIGNED_SHORT, 3);
|
|
66
|
+
tile.isQuantized = true;
|
|
67
|
+
tile.quantizedRange = (1 << 16) - 1;
|
|
68
|
+
tile.quantizedVolumeScale = featureTable.getGlobalProperty('QUANTIZED_VOLUME_SCALE', math_1.GL.FLOAT, 3);
|
|
69
|
+
if (!tile.quantizedVolumeScale) {
|
|
70
|
+
throw new Error('QUANTIZED_VOLUME_SCALE must be defined for quantized positions.');
|
|
71
|
+
}
|
|
72
|
+
tile.quantizedVolumeOffset = featureTable.getGlobalProperty('QUANTIZED_VOLUME_OFFSET', math_1.GL.FLOAT, 3);
|
|
73
|
+
if (!tile.quantizedVolumeOffset) {
|
|
74
|
+
throw new Error('QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.');
|
|
75
|
+
}
|
|
76
|
+
tile.attributes.positions = (0, normalize_3d_tile_positions_1.normalize3DTilePositionAttribute)(tile, positions, options);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (!tile.attributes.positions) {
|
|
80
|
+
throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
function parseColors(tile, featureTable, batchTable) {
|
|
84
|
+
if (!tile.attributes.colors) {
|
|
85
|
+
let colors = null;
|
|
86
|
+
if (featureTable.hasProperty('RGBA')) {
|
|
87
|
+
colors = featureTable.getPropertyArray('RGBA', math_1.GL.UNSIGNED_BYTE, 4);
|
|
88
|
+
tile.isTranslucent = true;
|
|
89
|
+
}
|
|
90
|
+
else if (featureTable.hasProperty('RGB')) {
|
|
91
|
+
colors = featureTable.getPropertyArray('RGB', math_1.GL.UNSIGNED_BYTE, 3);
|
|
92
|
+
}
|
|
93
|
+
else if (featureTable.hasProperty('RGB565')) {
|
|
94
|
+
colors = featureTable.getPropertyArray('RGB565', math_1.GL.UNSIGNED_SHORT, 1);
|
|
95
|
+
tile.isRGB565 = true;
|
|
96
|
+
}
|
|
97
|
+
tile.attributes.colors = (0, normalize_3d_tile_colors_1.normalize3DTileColorAttribute)(tile, colors, batchTable);
|
|
98
|
+
}
|
|
99
|
+
if (featureTable.hasProperty('CONSTANT_RGBA')) {
|
|
100
|
+
tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', math_1.GL.UNSIGNED_BYTE, 4);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function parseNormals(tile, featureTable) {
|
|
104
|
+
if (!tile.attributes.normals) {
|
|
105
|
+
let normals = null;
|
|
106
|
+
if (featureTable.hasProperty('NORMAL')) {
|
|
107
|
+
normals = featureTable.getPropertyArray('NORMAL', math_1.GL.FLOAT, 3);
|
|
108
|
+
}
|
|
109
|
+
else if (featureTable.hasProperty('NORMAL_OCT16P')) {
|
|
110
|
+
normals = featureTable.getPropertyArray('NORMAL_OCT16P', math_1.GL.UNSIGNED_BYTE, 2);
|
|
111
|
+
tile.isOctEncoded16P = true;
|
|
112
|
+
}
|
|
113
|
+
tile.attributes.normals = (0, normalize_3d_tile_normals_1.normalize3DTileNormalAttribute)(tile, normals);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function parseBatchIds(tile, featureTable) {
|
|
117
|
+
let batchTable = null;
|
|
118
|
+
if (!tile.batchIds && featureTable.hasProperty('BATCH_ID')) {
|
|
119
|
+
tile.batchIds = featureTable.getPropertyArray('BATCH_ID', math_1.GL.UNSIGNED_SHORT, 1);
|
|
120
|
+
if (tile.batchIds) {
|
|
121
|
+
const batchFeatureLength = featureTable.getGlobalProperty('BATCH_LENGTH');
|
|
122
|
+
if (!batchFeatureLength) {
|
|
123
|
+
throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');
|
|
124
|
+
}
|
|
125
|
+
const { batchTableJson, batchTableBinary } = tile;
|
|
126
|
+
batchTable = new tile_3d_batch_table_1.default(batchTableJson, batchTableBinary, batchFeatureLength);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return batchTable;
|
|
130
|
+
}
|
|
131
|
+
// eslint-disable-next-line complexity
|
|
132
|
+
async function parseDraco(tile, featureTable, batchTable, options, context) {
|
|
133
|
+
let dracoBuffer;
|
|
134
|
+
let dracoFeatureTableProperties;
|
|
135
|
+
let dracoBatchTableProperties;
|
|
136
|
+
const batchTableDraco = tile.batchTableJson &&
|
|
137
|
+
tile.batchTableJson.extensions &&
|
|
138
|
+
tile.batchTableJson.extensions['3DTILES_draco_point_compression'];
|
|
139
|
+
if (batchTableDraco) {
|
|
140
|
+
dracoBatchTableProperties = batchTableDraco.properties;
|
|
141
|
+
}
|
|
142
|
+
const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');
|
|
143
|
+
if (featureTableDraco) {
|
|
144
|
+
dracoFeatureTableProperties = featureTableDraco.properties;
|
|
145
|
+
const dracoByteOffset = featureTableDraco.byteOffset;
|
|
146
|
+
const dracoByteLength = featureTableDraco.byteLength;
|
|
147
|
+
if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {
|
|
148
|
+
throw new Error('Draco properties, byteOffset, and byteLength must be defined');
|
|
149
|
+
}
|
|
150
|
+
dracoBuffer = tile.featureTableBinary.slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
|
|
151
|
+
tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);
|
|
152
|
+
tile.hasColors =
|
|
153
|
+
Number.isFinite(dracoFeatureTableProperties.RGB) ||
|
|
154
|
+
Number.isFinite(dracoFeatureTableProperties.RGBA);
|
|
155
|
+
tile.hasNormals = Number.isFinite(dracoFeatureTableProperties.NORMAL);
|
|
156
|
+
tile.hasBatchIds = Number.isFinite(dracoFeatureTableProperties.BATCH_ID);
|
|
157
|
+
tile.isTranslucent = Number.isFinite(dracoFeatureTableProperties.RGBA);
|
|
158
|
+
}
|
|
159
|
+
if (!dracoBuffer) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
const dracoData = {
|
|
163
|
+
buffer: dracoBuffer,
|
|
164
|
+
properties: { ...dracoFeatureTableProperties, ...dracoBatchTableProperties },
|
|
165
|
+
featureTableProperties: dracoFeatureTableProperties,
|
|
166
|
+
batchTableProperties: dracoBatchTableProperties,
|
|
167
|
+
dequantizeInShader: false
|
|
168
|
+
};
|
|
169
|
+
return await loadDraco(tile, dracoData, options, context);
|
|
170
|
+
}
|
|
171
|
+
// eslint-disable-next-line complexity, max-statements
|
|
172
|
+
async function loadDraco(tile, dracoData, options, context) {
|
|
173
|
+
const { parse } = context;
|
|
174
|
+
const dracoOptions = {
|
|
175
|
+
...options,
|
|
176
|
+
draco: {
|
|
177
|
+
...options.draco,
|
|
178
|
+
extraAttributes: dracoData.batchTableProperties || {}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
// The entire tileset might be included, too expensive to serialize
|
|
182
|
+
delete dracoOptions['3d-tiles'];
|
|
183
|
+
const data = await parse(dracoData.buffer, draco_1.DracoLoader, dracoOptions);
|
|
184
|
+
const decodedPositions = data.attributes.POSITION && data.attributes.POSITION.value;
|
|
185
|
+
const decodedColors = data.attributes.COLOR_0 && data.attributes.COLOR_0.value;
|
|
186
|
+
const decodedNormals = data.attributes.NORMAL && data.attributes.NORMAL.value;
|
|
187
|
+
const decodedBatchIds = data.attributes.BATCH_ID && data.attributes.BATCH_ID.value;
|
|
188
|
+
const isQuantizedDraco = decodedPositions && data.attributes.POSITION.value.quantization;
|
|
189
|
+
const isOctEncodedDraco = decodedNormals && data.attributes.NORMAL.value.quantization;
|
|
190
|
+
if (isQuantizedDraco) {
|
|
191
|
+
// Draco quantization range == quantized volume scale - size in meters of the quantized volume
|
|
192
|
+
// Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc
|
|
193
|
+
const quantization = data.POSITION.data.quantization;
|
|
194
|
+
const range = quantization.range;
|
|
195
|
+
tile.quantizedVolumeScale = new core_1.Vector3(range, range, range);
|
|
196
|
+
tile.quantizedVolumeOffset = new core_1.Vector3(quantization.minValues);
|
|
197
|
+
tile.quantizedRange = (1 << quantization.quantizationBits) - 1.0;
|
|
198
|
+
tile.isQuantizedDraco = true;
|
|
199
|
+
}
|
|
200
|
+
if (isOctEncodedDraco) {
|
|
201
|
+
tile.octEncodedRange = (1 << data.NORMAL.data.quantization.quantizationBits) - 1.0;
|
|
202
|
+
tile.isOctEncodedDraco = true;
|
|
203
|
+
}
|
|
204
|
+
// Extra batch table attributes
|
|
205
|
+
const batchTableAttributes = {};
|
|
206
|
+
if (dracoData.batchTableProperties) {
|
|
207
|
+
for (const attributeName of Object.keys(dracoData.batchTableProperties)) {
|
|
208
|
+
if (data.attributes[attributeName] && data.attributes[attributeName].value) {
|
|
209
|
+
batchTableAttributes[attributeName.toLowerCase()] = data.attributes[attributeName].value;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
tile.attributes = {
|
|
214
|
+
positions: decodedPositions,
|
|
215
|
+
colors: (0, normalize_3d_tile_colors_1.normalize3DTileColorAttribute)(tile, decodedColors, undefined),
|
|
216
|
+
normals: decodedNormals,
|
|
217
|
+
batchIds: decodedBatchIds,
|
|
218
|
+
...batchTableAttributes
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
exports.loadDraco = loadDraco;
|
|
222
|
+
// TODO - this is the remaining code from Cesium's parser
|
|
223
|
+
/*
|
|
224
|
+
const batchTable = new Tile3DBatchTable(tile);
|
|
225
|
+
|
|
226
|
+
// parseDracoBuffer(tile, featureTable, batchTable);
|
|
227
|
+
|
|
228
|
+
if (!tile.attributes.positions) {
|
|
229
|
+
throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/*
|
|
233
|
+
|
|
234
|
+
if (!tile.attributes.positions) {
|
|
235
|
+
if (featureTable.hasProperty('POSITION')) {
|
|
236
|
+
tile.attributes.positions = featureTable.getPropertyArray('POSITION', GL.FLOAT, 3);
|
|
237
|
+
} else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
|
|
238
|
+
tile.attributes.positions = featureTable.getPropertyArray('POSITION_QUANTIZED', GL.UNSIGNED_SHORT, 3);
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
if (!tile.colors) {
|
|
242
|
+
if (featureTable.hasProperty('RGBA')) {
|
|
243
|
+
tile.colors = featureTable.getPropertyArray('RGBA', GL.UNSIGNED_BYTE, 4);
|
|
244
|
+
tile.isTranslucent = true;
|
|
245
|
+
} else if (featureTable.hasProperty('RGB')) {
|
|
246
|
+
tile.colors = featureTable.getPropertyArray('RGB', GL.UNSIGNED_BYTE, 3);
|
|
247
|
+
} else if (featureTable.hasPropertry('RGB565')) {
|
|
248
|
+
tile.colors = featureTable.getPropertyArray('RGB565', GL.UNSIGNED_SHORT, 1);
|
|
249
|
+
tile.isRGB565 = true;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
if (!tile.attributes.normals) {
|
|
254
|
+
if (featureTable.getPropertry('NORMAL')) {
|
|
255
|
+
tile.attributes.normals = featureTable.getPropertyArray('NORMAL', GL.FLOAT, 3);
|
|
256
|
+
} else if (featureTable.getProperty('NORMAL_OCT16P')) {
|
|
257
|
+
tile.attributes.normals = featureTable.getPropertyArray('NORMAL_OCT16P', GL.UNSIGNED_BYTE, 2);
|
|
258
|
+
tile.isOctEncoded16P = true;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (!tile.batchIds) {
|
|
263
|
+
if (featureTable.hasProperty('BATCH_ID')) {
|
|
264
|
+
tile.batchIds = featureTable.getPropertyArray('BATCH_ID', GL.UNSIGNED_SHORT, 1);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
if (!tile.attributes.positions) {
|
|
269
|
+
throw new Error('Either POSITION or POSITION_QUANTIZED must be defined.');
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (featureTable.getPropertry('CONSTANT_RGBA')) {
|
|
273
|
+
tile.constantRGBA = featureTable.getGlobalProperty('CONSTANT_RGBA', GL.UNSIGNED_BYTE, 4);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
if (tile.batchIds) {
|
|
277
|
+
const batchLength = featureTable.getGlobalProperty('BATCH_LENGTH');
|
|
278
|
+
if (!defined(batchLength)) {
|
|
279
|
+
throw new Error('Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.');
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (defined(batchTableBinary)) {
|
|
283
|
+
// Copy the batchTableBinary section and let the underlying ArrayBuffer be freed
|
|
284
|
+
batchTableBinary = new Uint8Array(batchTableBinary);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (defined(pointCloud._batchTableLoaded)) {
|
|
288
|
+
pointCloud._batchTableLoaded(batchLength, batchTableJson, batchTableBinary);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// If points are not batched and there are per-point properties, use these properties for styling purposes
|
|
293
|
+
var styleableProperties;
|
|
294
|
+
if (!hasBatchIds && defined(batchTableBinary)) {
|
|
295
|
+
tile.styleableProperties = Cesium3DTileBatchTable.getBinaryProperties(
|
|
296
|
+
pointsLength,
|
|
297
|
+
batchTableJson,
|
|
298
|
+
batchTableBinary
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
tile.draco = draco;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Separate parsing and decoding of Draco
|
|
306
|
+
export function parseDracoBuffer(tile, featureTable, batchTable) {
|
|
307
|
+
let dracoBuffer;
|
|
308
|
+
let dracoFeatureTableProperties;
|
|
309
|
+
let dracoBatchTableProperties;
|
|
310
|
+
|
|
311
|
+
const batchTableDraco = batchTable.getExtension('3DTILES_draco_point_compression');
|
|
312
|
+
if (batchTableDraco) {
|
|
313
|
+
dracoBatchTableProperties = batchTableDraco.properties;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const featureTableDraco = featureTable.getExtension('3DTILES_draco_point_compression');
|
|
317
|
+
if (featureTableDraco) {
|
|
318
|
+
dracoFeatureTableProperties = featureTableDraco.properties;
|
|
319
|
+
const dracoByteOffset = featureTableDraco.byteOffset;
|
|
320
|
+
const dracoByteLength = featureTableDraco.byteLength;
|
|
321
|
+
if (!dracoFeatureTableProperties || !dracoByteOffset || !dracoByteLength) {
|
|
322
|
+
throw new Error('Draco properties, byteOffset, and byteLength must be defined');
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
dracoBuffer = arraySlice(
|
|
326
|
+
featureTableBinary,
|
|
327
|
+
dracoByteOffset,
|
|
328
|
+
dracoByteOffset + dracoByteLength
|
|
329
|
+
);
|
|
330
|
+
tile.hasPositions = dracoFeatureTableProperties.POSITION;
|
|
331
|
+
tile.hasColors = dracoFeatureTableProperties.RGB || dracoFeatureTableProperties.RGBA;
|
|
332
|
+
tile.hasNormals = dracoFeatureTableProperties.NORMAL;
|
|
333
|
+
tile.hasBatchIds = dracoFeatureTableProperties.BATCH_ID;
|
|
334
|
+
tile.isTranslucent = dracoFeatureTableProperties.RGBA;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
if (dracoBuffer) {
|
|
338
|
+
tile.draco = {
|
|
339
|
+
buffer: dracoBuffer,
|
|
340
|
+
properties: {...dracoFeatureTableProperties, ...dracoBatchTableProperties},
|
|
341
|
+
featureTableProperties: dracoFeatureTableProperties,
|
|
342
|
+
batchTableProperties: dracoBatchTableProperties,
|
|
343
|
+
dequantizeInShader: false
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
tile.decodingState = DECODING_STATE.NEEDS_DECODE;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/*
|
|
351
|
+
function decodeDraco(tile, context) {
|
|
352
|
+
if (tile.decodingState === DECODING_STATE.READY) {
|
|
353
|
+
return false;
|
|
354
|
+
}
|
|
355
|
+
if (tile.decodingState === DECODING_STATE.NEEDS_DECODE) {
|
|
356
|
+
var parsedContent = tile._parsedContent;
|
|
357
|
+
var draco = parsedContent.draco;
|
|
358
|
+
var decodePromise = DracoLoader.decodePointCloud(draco, context);
|
|
359
|
+
if (defined(decodePromise)) {
|
|
360
|
+
tile.decodingState = DECODING_STATE.DECODING;
|
|
361
|
+
decodePromise.then(function(result) {
|
|
362
|
+
tile.decodingState = DECODING_STATE.READY;
|
|
363
|
+
var decodedPositions = defined(result.POSITION) ? result.POSITION.array : undefined;
|
|
364
|
+
var decodedRgb = defined(result.RGB) ? result.RGB.array : undefined;
|
|
365
|
+
var decodedRgba = defined(result.RGBA) ? result.RGBA.array : undefined;
|
|
366
|
+
var decodedNormals = defined(result.NORMAL) ? result.NORMAL.array : undefined;
|
|
367
|
+
var decodedBatchIds = defined(result.BATCH_ID) ? result.BATCH_ID.array : undefined;
|
|
368
|
+
var isQuantizedDraco = defined(decodedPositions) && defined(result.POSITION.data.quantization);
|
|
369
|
+
var isOctEncodedDraco = defined(decodedNormals) && defined(result.NORMAL.data.quantization);
|
|
370
|
+
if (isQuantizedDraco) {
|
|
371
|
+
// Draco quantization range == quantized volume scale - size in meters of the quantized volume
|
|
372
|
+
// Internal quantized range is the range of values of the quantized data, e.g. 255 for 8-bit, 1023 for 10-bit, etc
|
|
373
|
+
var quantization = result.POSITION.data.quantization;
|
|
374
|
+
var range = quantization.range;
|
|
375
|
+
tile._quantizedVolumeScale = Cartesian3.fromElements(range, range, range);
|
|
376
|
+
tile._quantizedVolumeOffset = Cartesian3.unpack(quantization.minValues);
|
|
377
|
+
tile._quantizedRange = (1 << quantization.quantizationBits) - 1.0;
|
|
378
|
+
tile._isQuantizedDraco = true;
|
|
379
|
+
}
|
|
380
|
+
if (isOctEncodedDraco) {
|
|
381
|
+
tile._octEncodedRange = (1 << result.NORMAL.data.quantization.quantizationBits) - 1.0;
|
|
382
|
+
tile._isOctEncodedDraco = true;
|
|
383
|
+
}
|
|
384
|
+
var styleableProperties = parsedContent.styleableProperties;
|
|
385
|
+
var batchTableProperties = draco.batchTableProperties;
|
|
386
|
+
for (var name in batchTableProperties) {
|
|
387
|
+
if (batchTableProperties.hasOwnProperty(name)) {
|
|
388
|
+
var property = result[name];
|
|
389
|
+
if (!defined(styleableProperties)) {
|
|
390
|
+
styleableProperties = {};
|
|
391
|
+
}
|
|
392
|
+
styleableProperties[name] = {
|
|
393
|
+
typedArray : property.array,
|
|
394
|
+
componentCount : property.data.componentsPerAttribute
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
parsedContent.positions = defaultValue(decodedPositions, parsedContent.positions);
|
|
399
|
+
parsedContent.colors = defaultValue(defaultValue(decodedRgba, decodedRgb), parsedContent.colors);
|
|
400
|
+
parsedContent.normals = defaultValue(decodedNormals, parsedContent.normals);
|
|
401
|
+
parsedContent.batchIds = defaultValue(decodedBatchIds, parsedContent.batchIds);
|
|
402
|
+
parsedContent.styleableProperties = styleableProperties;
|
|
403
|
+
}).otherwise(function(error) {
|
|
404
|
+
tile.decodingState = DECODING_STATE.FAILED;
|
|
405
|
+
tile._readyPromise.reject(error);
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
return true;
|
|
410
|
+
}
|
|
411
|
+
*/
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export function parse3DTile(arrayBuffer: any, byteOffset: number | undefined, options: any, context: any, tile?: {}): Promise<any>;
|
|
1
|
+
export declare function parse3DTile(arrayBuffer: any, byteOffset: number | undefined, options: any, context: any, tile?: {}): Promise<any>;
|
|
2
|
+
//# sourceMappingURL=parse-3d-tile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-3d-tile.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile.ts"],"names":[],"mappings":"AAYA,wBAAsB,WAAW,CAAC,WAAW,KAAA,EAAE,UAAU,oBAAI,EAAE,OAAO,KAAA,EAAE,OAAO,KAAA,EAAE,IAAI,KAAK,gBAgCzF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
// Extracts
|
|
13
|
+
async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = {}) {
|
|
14
|
+
// @ts-expect-error
|
|
15
|
+
tile.byteOffset = byteOffset;
|
|
16
|
+
// @ts-expect-error
|
|
17
|
+
tile.type = (0, parse_utils_1.getMagicString)(arrayBuffer, byteOffset);
|
|
18
|
+
// @ts-expect-error
|
|
19
|
+
switch (tile.type) {
|
|
20
|
+
case constants_1.TILE3D_TYPE.COMPOSITE:
|
|
21
|
+
// Note: We pass this function as argument so that embedded tiles can be parsed recursively
|
|
22
|
+
return await (0, parse_3d_tile_composite_1.parseComposite3DTile)(tile, arrayBuffer, byteOffset, options, context, parse3DTile);
|
|
23
|
+
case constants_1.TILE3D_TYPE.BATCHED_3D_MODEL:
|
|
24
|
+
return await (0, parse_3d_tile_batched_model_1.parseBatchedModel3DTile)(tile, arrayBuffer, byteOffset, 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
|
+
// @ts-expect-error
|
|
31
|
+
throw new Error(`3DTileLoader: unknown type ${tile.type}`); // eslint-disable-line
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.parse3DTile = parse3DTile;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export const VERSION: any;
|
|
1
|
+
export declare const VERSION: any;
|
|
2
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/version.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,KAA8D,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VERSION = void 0;
|
|
4
|
+
// Version constant cannot be imported, it needs to correspond to the build version of **this** module.
|
|
5
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
6
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
7
|
+
exports.VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tile-3d-subtree-loader.d.ts","sourceRoot":"","sources":["../src/tile-3d-subtree-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAI/D;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,gBAUjC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Tile3DSubtreeLoader = void 0;
|
|
7
|
+
const parse_3d_tile_subtree_1 = __importDefault(require("./lib/parsers/helpers/parse-3d-tile-subtree"));
|
|
8
|
+
const version_1 = require("./lib/utils/version");
|
|
9
|
+
/**
|
|
10
|
+
* Loader for 3D Tiles Subtree
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
exports.Tile3DSubtreeLoader = {
|
|
14
|
+
id: '3d-tiles-subtree',
|
|
15
|
+
name: '3D Tiles Subtree',
|
|
16
|
+
module: '3d-tiles',
|
|
17
|
+
version: version_1.VERSION,
|
|
18
|
+
extensions: ['subtree'],
|
|
19
|
+
mimeTypes: ['application/octet-stream'],
|
|
20
|
+
tests: ['subtree'],
|
|
21
|
+
parse: parse_3d_tile_subtree_1.default,
|
|
22
|
+
options: {}
|
|
23
|
+
};
|
package/dist/tile-3d-writer.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tile-3d-writer.d.ts","sourceRoot":"","sources":["../src/tile-3d-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,0BAA0B,CAAC;AAIrD;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,MAY1B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Tile3DWriter = void 0;
|
|
7
|
+
const version_1 = require("./lib/utils/version");
|
|
8
|
+
const encode_3d_tile_1 = __importDefault(require("./lib/encoders/encode-3d-tile"));
|
|
9
|
+
/**
|
|
10
|
+
* Exporter for 3D Tiles
|
|
11
|
+
*/
|
|
12
|
+
exports.Tile3DWriter = {
|
|
13
|
+
name: '3D Tile',
|
|
14
|
+
id: '3d-tiles',
|
|
15
|
+
module: '3d-tiles',
|
|
16
|
+
version: version_1.VERSION,
|
|
17
|
+
extensions: ['cmpt', 'pnts', 'b3dm', 'i3dm'],
|
|
18
|
+
mimeTypes: ['application/octet-stream'],
|
|
19
|
+
encodeSync,
|
|
20
|
+
binary: true,
|
|
21
|
+
options: {
|
|
22
|
+
['3d-tiles']: {}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
function encodeSync(tile, options) {
|
|
26
|
+
return (0, encode_3d_tile_1.default)(tile, options);
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tiles-3d-loader.d.ts","sourceRoot":"","sources":["../src/tiles-3d-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAO/D;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,gBAiB3B,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Tiles3DLoader = void 0;
|
|
4
|
+
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
5
|
+
const tiles_1 = require("@loaders.gl/tiles");
|
|
6
|
+
const version_1 = require("./lib/utils/version");
|
|
7
|
+
const parse_3d_tile_1 = require("./lib/parsers/parse-3d-tile");
|
|
8
|
+
const parse_3d_tile_header_1 = require("./lib/parsers/parse-3d-tile-header");
|
|
9
|
+
/**
|
|
10
|
+
* Loader for 3D Tiles
|
|
11
|
+
*/
|
|
12
|
+
exports.Tiles3DLoader = {
|
|
13
|
+
id: '3d-tiles',
|
|
14
|
+
name: '3D Tiles',
|
|
15
|
+
module: '3d-tiles',
|
|
16
|
+
version: version_1.VERSION,
|
|
17
|
+
extensions: ['cmpt', 'pnts', 'b3dm', 'i3dm'],
|
|
18
|
+
mimeTypes: ['application/octet-stream'],
|
|
19
|
+
tests: ['cmpt', 'pnts', 'b3dm', 'i3dm'],
|
|
20
|
+
parse,
|
|
21
|
+
options: {
|
|
22
|
+
'3d-tiles': {
|
|
23
|
+
loadGLTF: true,
|
|
24
|
+
decodeQuantizedPositions: false,
|
|
25
|
+
isTileset: 'auto',
|
|
26
|
+
assetGltfUpAxis: null
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
function getBaseUri(tileset) {
|
|
31
|
+
return loader_utils_1.path.dirname(tileset.url);
|
|
32
|
+
}
|
|
33
|
+
async function parseTile(arrayBuffer, options, context) {
|
|
34
|
+
const tile = {
|
|
35
|
+
content: {
|
|
36
|
+
featureIds: null
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const byteOffset = 0;
|
|
40
|
+
await (0, parse_3d_tile_1.parse3DTile)(arrayBuffer, byteOffset, options, context, tile.content);
|
|
41
|
+
return tile.content;
|
|
42
|
+
}
|
|
43
|
+
async function parseTileset(data, options, context) {
|
|
44
|
+
const tilesetJson = JSON.parse(new TextDecoder().decode(data));
|
|
45
|
+
// eslint-disable-next-line no-use-before-define
|
|
46
|
+
tilesetJson.loader = options.loader || exports.Tiles3DLoader;
|
|
47
|
+
tilesetJson.url = context.url;
|
|
48
|
+
// base path that non-absolute paths in tileset are relative to.
|
|
49
|
+
tilesetJson.basePath = getBaseUri(tilesetJson);
|
|
50
|
+
tilesetJson.root = (0, parse_3d_tile_header_1.normalizeTileHeaders)(tilesetJson);
|
|
51
|
+
tilesetJson.type = tiles_1.TILESET_TYPE.TILES3D;
|
|
52
|
+
tilesetJson.lodMetricType = tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR;
|
|
53
|
+
tilesetJson.lodMetricValue = tilesetJson.root?.lodMetricValue || 0;
|
|
54
|
+
return tilesetJson;
|
|
55
|
+
}
|
|
56
|
+
async function parse(data, options, context) {
|
|
57
|
+
// auto detect file type
|
|
58
|
+
const loaderOptions = options['3d-tiles'] || {};
|
|
59
|
+
let isTileset;
|
|
60
|
+
if (loaderOptions.isTileset === 'auto') {
|
|
61
|
+
isTileset = context.url && context.url.indexOf('.json') !== -1;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
isTileset = loaderOptions.isTileset;
|
|
65
|
+
}
|
|
66
|
+
if (isTileset) {
|
|
67
|
+
data = await parseTileset(data, options, context);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
data = await parseTile(data, options, context);
|
|
71
|
+
}
|
|
72
|
+
return data;
|
|
73
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -44,4 +44,32 @@ declare type BoundingVolume = {
|
|
|
44
44
|
box?: number[];
|
|
45
45
|
sphere?: number[];
|
|
46
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* 3DTILES_implicit_tiling types
|
|
49
|
+
* Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subtree-file-format
|
|
50
|
+
*/
|
|
51
|
+
export declare type SubtreeAvailability = {
|
|
52
|
+
buffers: Buffer[];
|
|
53
|
+
bufferViews: BufferView[];
|
|
54
|
+
tileAvailability: Availability;
|
|
55
|
+
contentAvailability: Availability;
|
|
56
|
+
childSubtreeAvailability: Availability;
|
|
57
|
+
};
|
|
58
|
+
declare type Availability = {
|
|
59
|
+
constant?: 0 | 1;
|
|
60
|
+
bufferView?: number;
|
|
61
|
+
explicitBitstream?: ExplicitBitstream;
|
|
62
|
+
};
|
|
63
|
+
export declare type ExplicitBitstream = Uint8Array;
|
|
64
|
+
declare type Buffer = {
|
|
65
|
+
name: string;
|
|
66
|
+
uri?: string;
|
|
67
|
+
byteLength: number;
|
|
68
|
+
};
|
|
69
|
+
declare type BufferView = {
|
|
70
|
+
buffer: number;
|
|
71
|
+
byteOffset: number;
|
|
72
|
+
byteLength: number;
|
|
73
|
+
};
|
|
47
74
|
export {};
|
|
75
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,oBAAY,cAAc,GAAG;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,CAAC;CACtB,CAAC;AAEF,oBAAY,WAAW,GAAG;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC7B,kBAAkB,CAAC,EAAE,UAAU,CAAC;IAChC,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAClC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B,EAAE,MAAM,CAAC;IACnC,wBAAwB,EAAE,MAAM,CAAC;IACjC,4BAA4B,EAAE,MAAM,CAAC;IACrC,0BAA0B,EAAE,MAAM,CAAC;CACpC,CAAC;AAEF,oBAAY,MAAM,GAAG;IACnB,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,GAAG,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,cAAc,EAAE,cAAc,CAAC;KAChC,CAAC;CACH,CAAC;AAEF,aAAK,cAAc,GAAG;IACpB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,oBAAY,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,gBAAgB,EAAE,YAAY,CAAC;IAC/B,mBAAmB,EAAE,YAAY,CAAC;IAClC,wBAAwB,EAAE,YAAY,CAAC;CACxC,CAAC;AAEF,aAAK,YAAY,GAAG;IAClB,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAEF,oBAAY,iBAAiB,GAAG,UAAU,CAAC;AAE3C,aAAK,MAAM,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,aAAK,UAAU,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|