@loaders.gl/3d-tiles 4.0.0-alpha.22 → 4.0.0-alpha.24
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 +2 -1
- package/dist/3d-tiles-archive/3d-tiles-archive-archive.d.ts.map +1 -1
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts +1 -1
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts.map +1 -1
- package/dist/3d-tiles-archive-loader.d.ts +1 -1
- package/dist/3d-tiles-archive-loader.d.ts.map +1 -1
- package/dist/cesium-ion-loader.d.ts +2 -2
- package/dist/cesium-ion-loader.d.ts.map +1 -1
- package/dist/dist.min.js +2074 -1483
- package/dist/es5/3d-tiles-archive/3d-tiles-archive-archive.js.map +1 -1
- package/dist/es5/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -1
- package/dist/es5/3d-tiles-archive-loader.js +3 -3
- package/dist/es5/3d-tiles-archive-loader.js.map +1 -1
- package/dist/es5/cesium-ion-loader.js.map +1 -1
- package/dist/es5/lib/filesystems/tiles-3d-archive-file-system.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 +3 -1
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.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/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.map +1 -1
- package/dist/esm/3d-tiles-archive/3d-tiles-archive-parser.js.map +1 -1
- package/dist/esm/3d-tiles-archive-loader.js +2 -2
- package/dist/esm/3d-tiles-archive-loader.js.map +1 -1
- package/dist/esm/cesium-ion-loader.js.map +1 -1
- package/dist/esm/lib/filesystems/tiles-3d-archive-file-system.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 +2 -1
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.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/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/lib/filesystems/tiles-3d-archive-file-system.d.ts +2 -1
- package/dist/lib/filesystems/tiles-3d-archive-file-system.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.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 +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/3d-tiles-archive/3d-tiles-archive-archive.ts +2 -1
- package/src/3d-tiles-archive/3d-tiles-archive-parser.ts +1 -1
- package/src/3d-tiles-archive-loader.ts +2 -2
- package/src/cesium-ion-loader.ts +2 -3
- package/src/lib/filesystems/tiles-3d-archive-file-system.ts +1 -1
- package/src/lib/parsers/parse-3d-tile-composite.ts +1 -1
- package/src/lib/parsers/parse-3d-tile-gltf.ts +3 -2
- 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 +3 -0
- package/dist/3d-tiles-archive/3d-tiles-archive-archive.js +0 -72
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.js +0 -33
- package/dist/3d-tiles-archive-loader.js +0 -31
- package/dist/bundle.js +0 -5
- package/dist/cesium-ion-loader.js +0 -41
- package/dist/index.js +0 -30
- 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/filesystems/tiles-3d-archive-file-system.js +0 -75
- 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 -303
- 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 -87
- 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 -194
- package/dist/lib/parsers/parse-3d-tile-instanced-model.js +0 -172
- package/dist/lib/parsers/parse-3d-tile-point-cloud.js +0 -441
- 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
package/dist/lib/ion/ion.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Minimal support to load tilsets from the Cesium ION services
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.getIonAssetMetadata = exports.getIonAssets = exports.getIonTilesetMetadata = void 0;
|
|
5
|
-
const core_1 = require("@loaders.gl/core");
|
|
6
|
-
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
7
|
-
const CESIUM_ION_URL = 'https://api.cesium.com/v1/assets';
|
|
8
|
-
// Returns `{url, headers, type, attributions}` for an ion tileset
|
|
9
|
-
async function getIonTilesetMetadata(accessToken, assetId) {
|
|
10
|
-
// Step 1, if no asset id, look for first 3DTILES asset associated with this token.
|
|
11
|
-
if (!assetId) {
|
|
12
|
-
const assets = await getIonAssets(accessToken);
|
|
13
|
-
for (const item of assets.items) {
|
|
14
|
-
if (item.type === '3DTILES') {
|
|
15
|
-
assetId = item.id;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
// Step 2: Query metdatadata for this asset.
|
|
20
|
-
const ionAssetMetadata = await getIonAssetMetadata(accessToken, assetId);
|
|
21
|
-
const { type, url } = ionAssetMetadata;
|
|
22
|
-
(0, loader_utils_1.assert)(type === '3DTILES' && url);
|
|
23
|
-
// Prepare a headers object for fetch
|
|
24
|
-
ionAssetMetadata.headers = {
|
|
25
|
-
Authorization: `Bearer ${ionAssetMetadata.accessToken}`
|
|
26
|
-
};
|
|
27
|
-
return ionAssetMetadata;
|
|
28
|
-
}
|
|
29
|
-
exports.getIonTilesetMetadata = getIonTilesetMetadata;
|
|
30
|
-
// Return a list of all assets associated with accessToken
|
|
31
|
-
async function getIonAssets(accessToken) {
|
|
32
|
-
(0, loader_utils_1.assert)(accessToken);
|
|
33
|
-
const url = CESIUM_ION_URL;
|
|
34
|
-
const headers = { Authorization: `Bearer ${accessToken}` };
|
|
35
|
-
const response = await (0, core_1.fetchFile)(url, { headers });
|
|
36
|
-
if (!response.ok) {
|
|
37
|
-
throw new Error(response.statusText);
|
|
38
|
-
}
|
|
39
|
-
return await response.json();
|
|
40
|
-
}
|
|
41
|
-
exports.getIonAssets = getIonAssets;
|
|
42
|
-
// Return metadata for a specific asset associated with token
|
|
43
|
-
async function getIonAssetMetadata(accessToken, assetId) {
|
|
44
|
-
(0, loader_utils_1.assert)(accessToken, assetId);
|
|
45
|
-
const headers = { Authorization: `Bearer ${accessToken}` };
|
|
46
|
-
const url = `${CESIUM_ION_URL}/${assetId}`;
|
|
47
|
-
// https://cesium.com/docs/rest-api/#operation/getAsset
|
|
48
|
-
// Retrieves metadata information about a specific asset.
|
|
49
|
-
let response = await (0, core_1.fetchFile)(`${url}`, { headers });
|
|
50
|
-
if (!response.ok) {
|
|
51
|
-
throw new Error(response.statusText);
|
|
52
|
-
}
|
|
53
|
-
let metadata = await response.json();
|
|
54
|
-
// https://cesium.com/docs/rest-api/#operation/getAssetEndpoint
|
|
55
|
-
// Retrieves information and credentials that allow you to access the tiled asset data for visualization and analysis.
|
|
56
|
-
response = await (0, core_1.fetchFile)(`${url}/endpoint`, { headers });
|
|
57
|
-
if (!response.ok) {
|
|
58
|
-
throw new Error(response.statusText);
|
|
59
|
-
}
|
|
60
|
-
const tilesetInfo = await response.json();
|
|
61
|
-
// extract dataset description
|
|
62
|
-
metadata = {
|
|
63
|
-
...metadata,
|
|
64
|
-
...tilesetInfo
|
|
65
|
-
};
|
|
66
|
-
return metadata;
|
|
67
|
-
}
|
|
68
|
-
exports.getIonAssetMetadata = getIonAssetMetadata;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalize3DTileColorAttribute = void 0;
|
|
4
|
-
const math_1 = require("@loaders.gl/math");
|
|
5
|
-
/* eslint-disable complexity*/
|
|
6
|
-
function normalize3DTileColorAttribute(tile, colors, batchTable) {
|
|
7
|
-
// no colors defined
|
|
8
|
-
if (!colors && (!tile || !tile.batchIds || !batchTable)) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
const { batchIds, isRGB565, pointCount = 0 } = tile;
|
|
12
|
-
// Batch table, look up colors in table
|
|
13
|
-
if (batchIds && batchTable) {
|
|
14
|
-
const colorArray = new Uint8ClampedArray(pointCount * 3);
|
|
15
|
-
for (let i = 0; i < pointCount; i++) {
|
|
16
|
-
const batchId = batchIds[i];
|
|
17
|
-
// TODO figure out what is `dimensions` used for
|
|
18
|
-
const dimensions = batchTable.getProperty(batchId, 'dimensions');
|
|
19
|
-
const color = dimensions.map((d) => d * 255);
|
|
20
|
-
colorArray[i * 3] = color[0];
|
|
21
|
-
colorArray[i * 3 + 1] = color[1];
|
|
22
|
-
colorArray[i * 3 + 2] = color[2];
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
type: math_1.GL.UNSIGNED_BYTE,
|
|
26
|
-
value: colorArray,
|
|
27
|
-
size: 3,
|
|
28
|
-
normalized: true
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
// RGB565 case, convert to RGB
|
|
32
|
-
if (colors && isRGB565) {
|
|
33
|
-
const colorArray = new Uint8ClampedArray(pointCount * 3);
|
|
34
|
-
for (let i = 0; i < pointCount; i++) {
|
|
35
|
-
const color = (0, math_1.decodeRGB565)(colors[i]);
|
|
36
|
-
colorArray[i * 3] = color[0];
|
|
37
|
-
colorArray[i * 3 + 1] = color[1];
|
|
38
|
-
colorArray[i * 3 + 2] = color[2];
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
type: math_1.GL.UNSIGNED_BYTE,
|
|
42
|
-
value: colorArray,
|
|
43
|
-
size: 3,
|
|
44
|
-
normalized: true
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
// RGB case (tile.isTranslucent)
|
|
48
|
-
if (colors && colors.length === pointCount * 3) {
|
|
49
|
-
return {
|
|
50
|
-
type: math_1.GL.UNSIGNED_BYTE,
|
|
51
|
-
value: colors,
|
|
52
|
-
size: 3,
|
|
53
|
-
normalized: true
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
// DEFAULT: RGBA case
|
|
57
|
-
return {
|
|
58
|
-
type: math_1.GL.UNSIGNED_BYTE,
|
|
59
|
-
value: colors || new Uint8ClampedArray(),
|
|
60
|
-
size: 4,
|
|
61
|
-
normalized: true
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
exports.normalize3DTileColorAttribute = normalize3DTileColorAttribute;
|
|
65
|
-
/* eslint-enable complexity*/
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalize3DTileNormalAttribute = void 0;
|
|
4
|
-
const core_1 = require("@math.gl/core");
|
|
5
|
-
const math_1 = require("@loaders.gl/math");
|
|
6
|
-
const scratchNormal = new core_1.Vector3();
|
|
7
|
-
function normalize3DTileNormalAttribute(tile, normals) {
|
|
8
|
-
if (!normals) {
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
if (tile.isOctEncoded16P) {
|
|
12
|
-
const decodedArray = new Float32Array((tile.pointsLength || 0) * 3);
|
|
13
|
-
for (let i = 0; i < (tile.pointsLength || 0); i++) {
|
|
14
|
-
(0, math_1.octDecode)(normals[i * 2], normals[i * 2 + 1], scratchNormal);
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
scratchNormal.toArray(decodedArray, i * 3);
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
type: math_1.GL.FLOAT,
|
|
20
|
-
size: 2,
|
|
21
|
-
value: decodedArray
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
type: math_1.GL.FLOAT,
|
|
26
|
-
size: 2,
|
|
27
|
-
value: normals
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
exports.normalize3DTileNormalAttribute = normalize3DTileNormalAttribute;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalize3DTilePositionAttribute = void 0;
|
|
4
|
-
const core_1 = require("@math.gl/core");
|
|
5
|
-
const math_1 = require("@loaders.gl/math");
|
|
6
|
-
// Prepare attribute for positions
|
|
7
|
-
function normalize3DTilePositionAttribute(tile, positions, options) {
|
|
8
|
-
if (!tile.isQuantized) {
|
|
9
|
-
return positions;
|
|
10
|
-
}
|
|
11
|
-
// For quantized posititions, either expand to Float32Array or return custom accessor
|
|
12
|
-
// https://github.com/AnalyticalGraphicsInc/3d-tiles/blob/master/specification/TileFormats/Instanced3DModel/README.md#quantized-positions
|
|
13
|
-
// Optionally decodes quantized positions on GPU, for simpler renderers that don't accept normalized attributes
|
|
14
|
-
if (options['3d-tiles'] && options['3d-tiles'].decodeQuantizedPositions) {
|
|
15
|
-
tile.isQuantized = false;
|
|
16
|
-
return decodeQuantizedPositions(tile, positions);
|
|
17
|
-
}
|
|
18
|
-
// Default: Use normalized shorts directly, no copying/processing.
|
|
19
|
-
// NOTE: The "missing" offset/scaling operations are automatically added to modelMatrix if `tile.isQuantized === true`
|
|
20
|
-
return {
|
|
21
|
-
type: math_1.GL.UNSIGNED_SHORT,
|
|
22
|
-
value: positions,
|
|
23
|
-
size: 3,
|
|
24
|
-
normalized: true
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
exports.normalize3DTilePositionAttribute = normalize3DTilePositionAttribute;
|
|
28
|
-
// Pre-scale quantized positions on CPU
|
|
29
|
-
function decodeQuantizedPositions(tile, positions) {
|
|
30
|
-
const scratchPosition = new core_1.Vector3();
|
|
31
|
-
const decodedArray = new Float32Array(tile.pointCount * 3);
|
|
32
|
-
for (let i = 0; i < tile.pointCount; i++) {
|
|
33
|
-
// POSITION = POSITION_QUANTIZED / 65535.0 * QUANTIZED_VOLUME_SCALE + QUANTIZED_VOLUME_OFFSET
|
|
34
|
-
scratchPosition
|
|
35
|
-
.set(positions[i * 3], positions[i * 3 + 1], positions[i * 3 + 2])
|
|
36
|
-
.scale(1 / tile.quantizedRange)
|
|
37
|
-
.multiply(tile.quantizedVolumeScale)
|
|
38
|
-
.add(tile.quantizedVolumeOffset)
|
|
39
|
-
.toArray(decodedArray, i * 3);
|
|
40
|
-
}
|
|
41
|
-
return decodedArray;
|
|
42
|
-
}
|
|
@@ -1,303 +0,0 @@
|
|
|
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.replaceContentUrlTemplate = exports.parseImplicitTiles = void 0;
|
|
7
|
-
const tile_3d_subtree_loader_1 = require("../../../tile-3d-subtree-loader");
|
|
8
|
-
const core_1 = require("@loaders.gl/core");
|
|
9
|
-
const log_1 = __importDefault(require("@probe.gl/log"));
|
|
10
|
-
const index_1 = require("../../utils/s2/index");
|
|
11
|
-
const s2_corners_to_obb_1 = require("../../utils/obb/s2-corners-to-obb");
|
|
12
|
-
const QUADTREE_DEVISION_COUNT = 4;
|
|
13
|
-
const OCTREE_DEVISION_COUNT = 8;
|
|
14
|
-
const SUBDIVISION_COUNT_MAP = {
|
|
15
|
-
QUADTREE: QUADTREE_DEVISION_COUNT,
|
|
16
|
-
OCTREE: OCTREE_DEVISION_COUNT
|
|
17
|
-
};
|
|
18
|
-
function getChildS2VolumeBox(s2VolumeBox, index, subdivisionScheme) {
|
|
19
|
-
if (s2VolumeBox?.box) {
|
|
20
|
-
// Check if the BoundingVolume is of type "box"
|
|
21
|
-
const cellId = (0, index_1.getS2CellIdFromToken)(s2VolumeBox.s2VolumeInfo.token);
|
|
22
|
-
const childCellId = (0, index_1.getS2ChildCellId)(cellId, index);
|
|
23
|
-
const childToken = (0, index_1.getS2TokenFromCellId)(childCellId);
|
|
24
|
-
// Clone object. Note, s2VolumeInfo is a plain object that doesn't contain any nested object.
|
|
25
|
-
// So, we can use the Spread Operator to make a shallow copy of the object.
|
|
26
|
-
const s2ChildVolumeInfo = { ...s2VolumeBox.s2VolumeInfo };
|
|
27
|
-
s2ChildVolumeInfo.token = childToken; // replace the token with the child's one
|
|
28
|
-
// In case of QUADTREE the sizeZ should NOT be changed!
|
|
29
|
-
// https://portal.ogc.org/files/102132
|
|
30
|
-
// A quadtree divides space only on the x and y dimensions.
|
|
31
|
-
// It divides each tile into 4 smaller tiles where the x and y dimensions are halved.
|
|
32
|
-
// The quadtree z minimum and maximum remain unchanged.
|
|
33
|
-
switch (subdivisionScheme) {
|
|
34
|
-
case 'OCTREE':
|
|
35
|
-
const s2VolumeInfo = s2VolumeBox.s2VolumeInfo;
|
|
36
|
-
const delta = s2VolumeInfo.maximumHeight - s2VolumeInfo.minimumHeight;
|
|
37
|
-
const sizeZ = delta / 2.0; // It's a next level (a child)
|
|
38
|
-
const midZ = s2VolumeInfo.minimumHeight + delta / 2.0;
|
|
39
|
-
s2VolumeInfo.minimumHeight = midZ - sizeZ;
|
|
40
|
-
s2VolumeInfo.maximumHeight = midZ + sizeZ;
|
|
41
|
-
break;
|
|
42
|
-
default:
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
const box = (0, s2_corners_to_obb_1.convertS2BoundingVolumetoOBB)(s2ChildVolumeInfo);
|
|
46
|
-
const childS2VolumeBox = {
|
|
47
|
-
box,
|
|
48
|
-
s2VolumeInfo: s2ChildVolumeInfo
|
|
49
|
-
};
|
|
50
|
-
return childS2VolumeBox;
|
|
51
|
-
}
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Recursively parse implicit tiles tree
|
|
56
|
-
* Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling
|
|
57
|
-
* TODO Check out do we able to use Tile3D class as return type here.
|
|
58
|
-
* @param subtree
|
|
59
|
-
* @param lodMetricValue
|
|
60
|
-
* @param options
|
|
61
|
-
* @param parentData
|
|
62
|
-
* @param childIndex
|
|
63
|
-
* @param level
|
|
64
|
-
* @param globalData
|
|
65
|
-
*/
|
|
66
|
-
// eslint-disable-next-line max-statements
|
|
67
|
-
async function parseImplicitTiles(params) {
|
|
68
|
-
const { implicitOptions, parentData = {
|
|
69
|
-
mortonIndex: 0,
|
|
70
|
-
x: 0,
|
|
71
|
-
y: 0,
|
|
72
|
-
z: 0
|
|
73
|
-
}, childIndex = 0, globalData = {
|
|
74
|
-
level: 0,
|
|
75
|
-
mortonIndex: 0,
|
|
76
|
-
x: 0,
|
|
77
|
-
y: 0,
|
|
78
|
-
z: 0
|
|
79
|
-
}, s2VolumeBox, loaderOptions } = params;
|
|
80
|
-
let { subtree, level = 0 } = params;
|
|
81
|
-
const { subdivisionScheme, subtreeLevels, maximumLevel, contentUrlTemplate, subtreesUriTemplate, basePath } = implicitOptions;
|
|
82
|
-
const tile = { children: [], lodMetricValue: 0, contentUrl: '' };
|
|
83
|
-
if (!maximumLevel) {
|
|
84
|
-
// eslint-disable-next-line no-console
|
|
85
|
-
log_1.default.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${contentUrlTemplate} won't be loaded...`);
|
|
86
|
-
return tile;
|
|
87
|
-
}
|
|
88
|
-
const lev = level + globalData.level;
|
|
89
|
-
if (lev > maximumLevel) {
|
|
90
|
-
return tile;
|
|
91
|
-
}
|
|
92
|
-
const childrenPerTile = SUBDIVISION_COUNT_MAP[subdivisionScheme];
|
|
93
|
-
const bitsPerTile = Math.log2(childrenPerTile);
|
|
94
|
-
// childIndex is in range [0,4] for quadtrees and [0, 7] for octrees
|
|
95
|
-
const childX = childIndex & 0b01; // Get first bit for X
|
|
96
|
-
const childY = (childIndex >> 1) & 0b01; // Get second bit for Y
|
|
97
|
-
const childZ = (childIndex >> 2) & 0b01; // Get third bit for Z
|
|
98
|
-
const levelOffset = (childrenPerTile ** level - 1) / (childrenPerTile - 1);
|
|
99
|
-
let childTileMortonIndex = concatBits(parentData.mortonIndex, childIndex, bitsPerTile);
|
|
100
|
-
let tileAvailabilityIndex = levelOffset + childTileMortonIndex;
|
|
101
|
-
// Local tile coordinates
|
|
102
|
-
let childTileX = concatBits(parentData.x, childX, 1);
|
|
103
|
-
let childTileY = concatBits(parentData.y, childY, 1);
|
|
104
|
-
let childTileZ = concatBits(parentData.z, childZ, 1);
|
|
105
|
-
let isChildSubtreeAvailable = false;
|
|
106
|
-
if (level >= subtreeLevels) {
|
|
107
|
-
isChildSubtreeAvailable = getAvailabilityResult(subtree.childSubtreeAvailability, childTileMortonIndex);
|
|
108
|
-
}
|
|
109
|
-
const x = concatBits(globalData.x, childTileX, level * bitsPerTile);
|
|
110
|
-
const y = concatBits(globalData.y, childTileY, level * bitsPerTile);
|
|
111
|
-
const z = concatBits(globalData.z, childTileZ, level * bitsPerTile);
|
|
112
|
-
if (isChildSubtreeAvailable) {
|
|
113
|
-
const subtreePath = `${basePath}/${subtreesUriTemplate}`;
|
|
114
|
-
const childSubtreeUrl = replaceContentUrlTemplate(subtreePath, lev, x, y, z);
|
|
115
|
-
const childSubtree = await (0, core_1.load)(childSubtreeUrl, tile_3d_subtree_loader_1.Tile3DSubtreeLoader, loaderOptions);
|
|
116
|
-
subtree = childSubtree;
|
|
117
|
-
globalData.mortonIndex = childTileMortonIndex;
|
|
118
|
-
globalData.x = childTileX;
|
|
119
|
-
globalData.y = childTileY;
|
|
120
|
-
globalData.z = childTileZ;
|
|
121
|
-
globalData.level = level;
|
|
122
|
-
childTileMortonIndex = 0;
|
|
123
|
-
tileAvailabilityIndex = 0;
|
|
124
|
-
childTileX = 0;
|
|
125
|
-
childTileY = 0;
|
|
126
|
-
childTileZ = 0;
|
|
127
|
-
level = 0;
|
|
128
|
-
}
|
|
129
|
-
const isTileAvailable = getAvailabilityResult(subtree.tileAvailability, tileAvailabilityIndex);
|
|
130
|
-
if (!isTileAvailable) {
|
|
131
|
-
return tile;
|
|
132
|
-
}
|
|
133
|
-
const isContentAvailable = getAvailabilityResult(subtree.contentAvailability, tileAvailabilityIndex);
|
|
134
|
-
if (isContentAvailable) {
|
|
135
|
-
tile.contentUrl = replaceContentUrlTemplate(contentUrlTemplate, lev, x, y, z);
|
|
136
|
-
}
|
|
137
|
-
const childTileLevel = level + 1;
|
|
138
|
-
const pData = { mortonIndex: childTileMortonIndex, x: childTileX, y: childTileY, z: childTileZ };
|
|
139
|
-
for (let index = 0; index < childrenPerTile; index++) {
|
|
140
|
-
const childS2VolumeBox = getChildS2VolumeBox(s2VolumeBox, index, subdivisionScheme);
|
|
141
|
-
// Recursive calling...
|
|
142
|
-
const childTileParsed = await parseImplicitTiles({
|
|
143
|
-
subtree,
|
|
144
|
-
implicitOptions,
|
|
145
|
-
loaderOptions,
|
|
146
|
-
parentData: pData,
|
|
147
|
-
childIndex: index,
|
|
148
|
-
level: childTileLevel,
|
|
149
|
-
globalData: { ...globalData },
|
|
150
|
-
s2VolumeBox: childS2VolumeBox
|
|
151
|
-
});
|
|
152
|
-
if (childTileParsed.contentUrl || childTileParsed.children.length) {
|
|
153
|
-
const globalLevel = lev + 1;
|
|
154
|
-
const childCoordinates = { childTileX, childTileY, childTileZ };
|
|
155
|
-
const formattedTile = formatTileData(childTileParsed, globalLevel, childCoordinates, implicitOptions, s2VolumeBox);
|
|
156
|
-
// @ts-ignore
|
|
157
|
-
tile.children.push(formattedTile);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return tile;
|
|
161
|
-
}
|
|
162
|
-
exports.parseImplicitTiles = parseImplicitTiles;
|
|
163
|
-
/**
|
|
164
|
-
* Check tile availability in the bitstream array
|
|
165
|
-
* @param availabilityData - tileAvailability / contentAvailability / childSubtreeAvailability object
|
|
166
|
-
* @param index - index in the bitstream array
|
|
167
|
-
* @returns
|
|
168
|
-
*/
|
|
169
|
-
function getAvailabilityResult(availabilityData, index) {
|
|
170
|
-
let availabilityObject;
|
|
171
|
-
if (Array.isArray(availabilityData)) {
|
|
172
|
-
/** TODO: we don't support `3DTILES_multiple_contents` extension at the moment.
|
|
173
|
-
* https://github.com/CesiumGS/3d-tiles/blob/main/extensions/3DTILES_implicit_tiling/README.md#multiple-contents
|
|
174
|
-
* Take first item in the array
|
|
175
|
-
*/
|
|
176
|
-
availabilityObject = availabilityData[0];
|
|
177
|
-
if (availabilityData.length > 1) {
|
|
178
|
-
// eslint-disable-next-line no-console
|
|
179
|
-
log_1.default.once('Not supported extension "3DTILES_multiple_contents" has been detected');
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
availabilityObject = availabilityData;
|
|
184
|
-
}
|
|
185
|
-
if ('constant' in availabilityObject) {
|
|
186
|
-
return Boolean(availabilityObject.constant);
|
|
187
|
-
}
|
|
188
|
-
if (availabilityObject.explicitBitstream) {
|
|
189
|
-
return getBooleanValueFromBitstream(index, availabilityObject.explicitBitstream);
|
|
190
|
-
}
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Do formatting of implicit tile data.
|
|
195
|
-
* TODO Check out do we able to use Tile3D class as type here.
|
|
196
|
-
* @param tile
|
|
197
|
-
* @param lodMetricValue
|
|
198
|
-
* @param options
|
|
199
|
-
* @returns
|
|
200
|
-
*/
|
|
201
|
-
function formatTileData(tile, level, childCoordinates, options, s2VolumeBox) {
|
|
202
|
-
const { basePath, refine, getRefine, lodMetricType, getTileType, rootLodMetricValue, rootBoundingVolume } = options;
|
|
203
|
-
const uri = tile.contentUrl && tile.contentUrl.replace(`${basePath}/`, '');
|
|
204
|
-
const lodMetricValue = rootLodMetricValue / 2 ** level;
|
|
205
|
-
const boundingVolume = s2VolumeBox?.box
|
|
206
|
-
? { box: s2VolumeBox.box }
|
|
207
|
-
: rootBoundingVolume;
|
|
208
|
-
const boundingVolumeForChildTile = calculateBoundingVolumeForChildTile(level, boundingVolume, childCoordinates);
|
|
209
|
-
return {
|
|
210
|
-
children: tile.children,
|
|
211
|
-
contentUrl: tile.contentUrl,
|
|
212
|
-
content: { uri },
|
|
213
|
-
id: tile.contentUrl,
|
|
214
|
-
refine: getRefine(refine),
|
|
215
|
-
type: getTileType(tile),
|
|
216
|
-
lodMetricType,
|
|
217
|
-
lodMetricValue,
|
|
218
|
-
geometricError: lodMetricValue,
|
|
219
|
-
transform: tile.transform,
|
|
220
|
-
boundingVolume: boundingVolumeForChildTile
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Calculate child bounding volume.
|
|
225
|
-
* Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subdivision-rules
|
|
226
|
-
* @param level
|
|
227
|
-
* @param rootBoundingVolume
|
|
228
|
-
* @param childCoordinates
|
|
229
|
-
*/
|
|
230
|
-
function calculateBoundingVolumeForChildTile(level, rootBoundingVolume, childCoordinates) {
|
|
231
|
-
if (rootBoundingVolume.region) {
|
|
232
|
-
const { childTileX, childTileY, childTileZ } = childCoordinates;
|
|
233
|
-
const [west, south, east, north, minimumHeight, maximumHeight] = rootBoundingVolume.region;
|
|
234
|
-
const boundingVolumesCount = 2 ** level;
|
|
235
|
-
const sizeX = (east - west) / boundingVolumesCount;
|
|
236
|
-
const sizeY = (north - south) / boundingVolumesCount;
|
|
237
|
-
// TODO : Why is the subdivisionScheme not being checked here?
|
|
238
|
-
// In case of QUADTREE the sizeZ should NOT be changed!
|
|
239
|
-
// https://portal.ogc.org/files/102132
|
|
240
|
-
// A quadtree divides space only on the x and y dimensions. It divides each tile into 4 smaller tiles where the x and y dimensions are halved. The quadtree z minimum and maximum remain unchanged.
|
|
241
|
-
const sizeZ = (maximumHeight - minimumHeight) / boundingVolumesCount;
|
|
242
|
-
const [childWest, childEast] = [west + sizeX * childTileX, west + sizeX * (childTileX + 1)];
|
|
243
|
-
const [childSouth, childNorth] = [south + sizeY * childTileY, south + sizeY * (childTileY + 1)];
|
|
244
|
-
const [childMinimumHeight, childMaximumHeight] = [
|
|
245
|
-
minimumHeight + sizeZ * childTileZ,
|
|
246
|
-
minimumHeight + sizeZ * (childTileZ + 1)
|
|
247
|
-
];
|
|
248
|
-
return {
|
|
249
|
-
region: [childWest, childSouth, childEast, childNorth, childMinimumHeight, childMaximumHeight]
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
if (rootBoundingVolume.box) {
|
|
253
|
-
return rootBoundingVolume;
|
|
254
|
-
}
|
|
255
|
-
throw new Error(`Unsupported bounding volume type ${rootBoundingVolume}`);
|
|
256
|
-
}
|
|
257
|
-
/**
|
|
258
|
-
* Do binary concatenation
|
|
259
|
-
* @param higher - number to put to higher part of result
|
|
260
|
-
* @param lower - number to put to lower part of result
|
|
261
|
-
* @param shift - number of bits to shift lower number
|
|
262
|
-
*/
|
|
263
|
-
function concatBits(higher, lower, shift) {
|
|
264
|
-
return (higher << shift) + lower;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Replace implicit tile content url with real coordinates.
|
|
268
|
-
* @param templateUrl
|
|
269
|
-
* @param level
|
|
270
|
-
* @param x
|
|
271
|
-
* @param y
|
|
272
|
-
* @param z
|
|
273
|
-
*/
|
|
274
|
-
function replaceContentUrlTemplate(templateUrl, level, x, y, z) {
|
|
275
|
-
const mapUrl = generateMapUrl({ level, x, y, z });
|
|
276
|
-
return templateUrl.replace(/{level}|{x}|{y}|{z}/gi, (matched) => mapUrl[matched]);
|
|
277
|
-
}
|
|
278
|
-
exports.replaceContentUrlTemplate = replaceContentUrlTemplate;
|
|
279
|
-
/**
|
|
280
|
-
* Get Map object for content url generation
|
|
281
|
-
* @param items
|
|
282
|
-
*/
|
|
283
|
-
function generateMapUrl(items) {
|
|
284
|
-
const mapUrl = {};
|
|
285
|
-
for (const key in items) {
|
|
286
|
-
mapUrl[`{${key}}`] = items[key];
|
|
287
|
-
}
|
|
288
|
-
return mapUrl;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* Get boolean value from bistream by index
|
|
292
|
-
* A boolean value is encoded as a single bit, either 0 (false) or 1 (true).
|
|
293
|
-
* Multiple boolean values are packed tightly in the same buffer.
|
|
294
|
-
* These buffers of tightly-packed bits are sometimes referred to as bitstreams.
|
|
295
|
-
* Spec - https://github.com/CesiumGS/3d-tiles/tree/implicit-revisions/specification/Metadata#booleans
|
|
296
|
-
* @param availabilitiIndex
|
|
297
|
-
*/
|
|
298
|
-
function getBooleanValueFromBitstream(availabilityIndex, availabilityBuffer) {
|
|
299
|
-
const byteIndex = Math.floor(availabilityIndex / 8);
|
|
300
|
-
const bitIndex = availabilityIndex % 8;
|
|
301
|
-
const bitValue = (availabilityBuffer[byteIndex] >> bitIndex) & 1;
|
|
302
|
-
return bitValue === 1;
|
|
303
|
-
}
|
|
@@ -1,96 +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.extractGLTF = exports.parse3DTileGLTFViewSync = exports.GLTF_FORMAT = void 0;
|
|
6
|
-
// TODO - should we automatically parse the embedded glTF or leave it to the app?
|
|
7
|
-
// - I.e. some apps might work directly on a GLB, in that case no need for us to decode...
|
|
8
|
-
// - And if we decode, do we still keep the GLB in case it is needed?
|
|
9
|
-
// - Do we add an option to control this?
|
|
10
|
-
// - Also, should we have hard dependency on gltf module or use injection or auto-discovery for gltf parser?
|
|
11
|
-
const gltf_1 = require("@loaders.gl/gltf");
|
|
12
|
-
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
13
|
-
exports.GLTF_FORMAT = {
|
|
14
|
-
URI: 0,
|
|
15
|
-
EMBEDDED: 1
|
|
16
|
-
};
|
|
17
|
-
function parse3DTileGLTFViewSync(tile, arrayBuffer, byteOffset, options) {
|
|
18
|
-
// Set flags
|
|
19
|
-
// glTF models need to be rotated from Y to Z up
|
|
20
|
-
// https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up
|
|
21
|
-
tile.rotateYtoZ = true;
|
|
22
|
-
// Assume glTF consumes rest of tile
|
|
23
|
-
const gltfByteLength = (tile.byteOffset || 0) + (tile.byteLength || 0) - byteOffset;
|
|
24
|
-
if (gltfByteLength === 0) {
|
|
25
|
-
throw new Error('glTF byte length must be greater than 0.');
|
|
26
|
-
}
|
|
27
|
-
// Save gltf up axis
|
|
28
|
-
tile.gltfUpAxis =
|
|
29
|
-
options?.['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis
|
|
30
|
-
? options['3d-tiles'].assetGltfUpAxis
|
|
31
|
-
: 'Y';
|
|
32
|
-
// TODO - We can avoid copy if already 4-byte aligned...
|
|
33
|
-
// However the rest of the code may not be able to accept byteOffsets, so copy anyway
|
|
34
|
-
tile.gltfArrayBuffer = (0, loader_utils_1.sliceArrayBuffer)(arrayBuffer, byteOffset, gltfByteLength);
|
|
35
|
-
tile.gltfByteOffset = 0;
|
|
36
|
-
tile.gltfByteLength = gltfByteLength;
|
|
37
|
-
if (byteOffset % 4 === 0) {
|
|
38
|
-
// tile.gltfArrayBuffer = arrayBuffer;
|
|
39
|
-
// tile.gltfByteOffset = byteOffset;
|
|
40
|
-
// tile.gltfByteLength = gltfByteLength;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
// Create a copy of the glb so that it is 4-byte aligned
|
|
44
|
-
// eslint-disable-next-line
|
|
45
|
-
console.warn(`${tile.type}: embedded glb is not aligned to a 4-byte boundary.`);
|
|
46
|
-
}
|
|
47
|
-
// Entire tile is consumed
|
|
48
|
-
return (tile.byteOffset || 0) + (tile.byteLength || 0);
|
|
49
|
-
}
|
|
50
|
-
exports.parse3DTileGLTFViewSync = parse3DTileGLTFViewSync;
|
|
51
|
-
async function extractGLTF(tile, gltfFormat, options, context) {
|
|
52
|
-
const tile3DOptions = options?.['3d-tiles'] || {};
|
|
53
|
-
extractGLTFBufferOrURL(tile, gltfFormat, options);
|
|
54
|
-
if (tile3DOptions.loadGLTF) {
|
|
55
|
-
if (!context) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (tile.gltfUrl) {
|
|
59
|
-
const { fetch } = context;
|
|
60
|
-
const response = await fetch(tile.gltfUrl, options);
|
|
61
|
-
tile.gltfArrayBuffer = await response.arrayBuffer();
|
|
62
|
-
tile.gltfByteOffset = 0;
|
|
63
|
-
}
|
|
64
|
-
if (tile.gltfArrayBuffer) {
|
|
65
|
-
// TODO - Should handle byteOffset... However, not used now...
|
|
66
|
-
const gltfWithBuffers = await (0, loader_utils_1.parseFromContext)(tile.gltfArrayBuffer, gltf_1.GLTFLoader, options, context);
|
|
67
|
-
tile.gltf = (0, gltf_1.postProcessGLTF)(gltfWithBuffers);
|
|
68
|
-
tile.gpuMemoryUsageInBytes = (0, gltf_1._getMemoryUsageGLTF)(tile.gltf);
|
|
69
|
-
delete tile.gltfArrayBuffer;
|
|
70
|
-
delete tile.gltfByteOffset;
|
|
71
|
-
delete tile.gltfByteLength;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.extractGLTF = extractGLTF;
|
|
76
|
-
function extractGLTFBufferOrURL(tile, gltfFormat, options) {
|
|
77
|
-
switch (gltfFormat) {
|
|
78
|
-
case exports.GLTF_FORMAT.URI:
|
|
79
|
-
// We need to remove padding from the end of the model URL in case this tile was part of a composite tile.
|
|
80
|
-
// This removes all white space and null characters from the end of the string.
|
|
81
|
-
if (tile.gltfArrayBuffer) {
|
|
82
|
-
const gltfUrlBytes = new Uint8Array(tile.gltfArrayBuffer, tile.gltfByteOffset);
|
|
83
|
-
const textDecoder = new TextDecoder();
|
|
84
|
-
const gltfUrl = textDecoder.decode(gltfUrlBytes);
|
|
85
|
-
tile.gltfUrl = gltfUrl.replace(/[\s\0]+$/, '');
|
|
86
|
-
}
|
|
87
|
-
delete tile.gltfArrayBuffer;
|
|
88
|
-
delete tile.gltfByteOffset;
|
|
89
|
-
delete tile.gltfByteLength;
|
|
90
|
-
break;
|
|
91
|
-
case exports.GLTF_FORMAT.EMBEDDED:
|
|
92
|
-
break;
|
|
93
|
-
default:
|
|
94
|
-
throw new Error('b3dm: Illegal glTF format field');
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,28 +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.parse3DTileHeaderSync = void 0;
|
|
6
|
-
const SIZEOF_UINT32 = 4;
|
|
7
|
-
/* PARSE FIXED HEADER:
|
|
8
|
-
Populates
|
|
9
|
-
magic, // identifies type of tile
|
|
10
|
-
type, // String version of magic
|
|
11
|
-
version,
|
|
12
|
-
byteLength
|
|
13
|
-
*/
|
|
14
|
-
function parse3DTileHeaderSync(tile, arrayBuffer, byteOffset = 0) {
|
|
15
|
-
const view = new DataView(arrayBuffer);
|
|
16
|
-
tile.magic = view.getUint32(byteOffset, true);
|
|
17
|
-
byteOffset += SIZEOF_UINT32;
|
|
18
|
-
tile.version = view.getUint32(byteOffset, true);
|
|
19
|
-
byteOffset += SIZEOF_UINT32;
|
|
20
|
-
tile.byteLength = view.getUint32(byteOffset, true);
|
|
21
|
-
byteOffset += SIZEOF_UINT32;
|
|
22
|
-
// TODO - move version check into each tile parser?
|
|
23
|
-
if (tile.version !== 1) {
|
|
24
|
-
throw new Error(`3D Tile Version ${tile.version} not supported`);
|
|
25
|
-
}
|
|
26
|
-
return byteOffset; // Indicates where the parsing ended
|
|
27
|
-
}
|
|
28
|
-
exports.parse3DTileHeaderSync = parse3DTileHeaderSync;
|