@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,39 +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.encodePointCloud3DTile = void 0;
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
|
-
const encode_3d_tile_header_1 = require("./helpers/encode-3d-tile-header");
|
|
8
|
-
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
9
|
-
const DEFAULT_FEATURE_TABLE_JSON = {
|
|
10
|
-
POINTS_LENGTH: 1,
|
|
11
|
-
POSITIONS: {
|
|
12
|
-
byteOffset: 0
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
function encodePointCloud3DTile(tile, dataView, byteOffset, options) {
|
|
16
|
-
const { featureTableJson = DEFAULT_FEATURE_TABLE_JSON } = tile;
|
|
17
|
-
let featureTableJsonString = JSON.stringify(featureTableJson);
|
|
18
|
-
featureTableJsonString = (0, loader_utils_1.padStringToByteAlignment)(featureTableJsonString, 4);
|
|
19
|
-
const { featureTableJsonByteLength = featureTableJsonString.length } = tile;
|
|
20
|
-
const featureTableBinary = new ArrayBuffer(12); // Enough space to hold 3 floats
|
|
21
|
-
const featureTableBinaryByteLength = featureTableBinary.byteLength;
|
|
22
|
-
// Add default magic for this tile type
|
|
23
|
-
tile = { magic: constants_1.MAGIC_ARRAY.POINT_CLOUD, ...tile };
|
|
24
|
-
const byteOffsetStart = byteOffset;
|
|
25
|
-
byteOffset += (0, encode_3d_tile_header_1.encode3DTileHeader)(tile, dataView, 0);
|
|
26
|
-
if (dataView) {
|
|
27
|
-
dataView.setUint32(byteOffset + 0, featureTableJsonByteLength, true); // featureTableJsonByteLength
|
|
28
|
-
dataView.setUint32(byteOffset + 4, featureTableBinaryByteLength, true); // featureTableBinaryByteLength
|
|
29
|
-
dataView.setUint32(byteOffset + 8, 0, true); // batchTableJsonByteLength
|
|
30
|
-
dataView.setUint32(byteOffset + 12, 0, true); // batchTableBinaryByteLength
|
|
31
|
-
}
|
|
32
|
-
byteOffset += 16;
|
|
33
|
-
byteOffset += (0, loader_utils_1.copyStringToDataView)(dataView, byteOffset, featureTableJsonString, featureTableJsonByteLength);
|
|
34
|
-
byteOffset += (0, loader_utils_1.copyBinaryToDataView)(dataView, byteOffset, featureTableBinary, featureTableBinaryByteLength);
|
|
35
|
-
// Go "back" and rewrite the tile's `byteLength` now that we know the value
|
|
36
|
-
(0, encode_3d_tile_header_1.encode3DTileByteLength)(dataView, byteOffsetStart, byteOffset - byteOffsetStart);
|
|
37
|
-
return byteOffset;
|
|
38
|
-
}
|
|
39
|
-
exports.encodePointCloud3DTile = encodePointCloud3DTile;
|
|
@@ -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
|
-
const constants_1 = require("../constants");
|
|
6
|
-
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
7
|
-
const encode_3d_tile_composite_1 = require("./encode-3d-tile-composite");
|
|
8
|
-
const encode_3d_tile_batched_model_1 = require("./encode-3d-tile-batched-model");
|
|
9
|
-
const encode_3d_tile_instanced_model_1 = require("./encode-3d-tile-instanced-model");
|
|
10
|
-
const encode_3d_tile_point_cloud_1 = require("./encode-3d-tile-point-cloud");
|
|
11
|
-
function encode3DTile(tile, options) {
|
|
12
|
-
const byteLength = encode3DTileToDataView(tile, null, 0, options);
|
|
13
|
-
const arrayBuffer = new ArrayBuffer(byteLength);
|
|
14
|
-
const dataView = new DataView(arrayBuffer);
|
|
15
|
-
encode3DTileToDataView(tile, dataView, 0, options);
|
|
16
|
-
return arrayBuffer;
|
|
17
|
-
}
|
|
18
|
-
exports.default = encode3DTile;
|
|
19
|
-
function encode3DTileToDataView(tile, dataView, byteOffset, options) {
|
|
20
|
-
(0, loader_utils_1.assert)(typeof tile.type === 'string');
|
|
21
|
-
switch (tile.type) {
|
|
22
|
-
case constants_1.TILE3D_TYPE.COMPOSITE:
|
|
23
|
-
return (0, encode_3d_tile_composite_1.encodeComposite3DTile)(tile, dataView, byteOffset, options, encode3DTileToDataView);
|
|
24
|
-
case constants_1.TILE3D_TYPE.POINT_CLOUD:
|
|
25
|
-
return (0, encode_3d_tile_point_cloud_1.encodePointCloud3DTile)(tile, dataView, byteOffset, options);
|
|
26
|
-
case constants_1.TILE3D_TYPE.BATCHED_3D_MODEL:
|
|
27
|
-
return (0, encode_3d_tile_batched_model_1.encodeBatchedModel3DTile)(tile, dataView, byteOffset, options);
|
|
28
|
-
case constants_1.TILE3D_TYPE.INSTANCED_3D_MODEL:
|
|
29
|
-
return (0, encode_3d_tile_instanced_model_1.encodeInstancedModel3DTile)(tile, dataView, byteOffset, options);
|
|
30
|
-
default:
|
|
31
|
-
throw new Error('3D Tiles: unknown tile type');
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.encode3DTileByteLength = exports.encode3DTileHeader = void 0;
|
|
4
|
-
// HELPER ENCODERS
|
|
5
|
-
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
6
|
-
function encode3DTileHeader(tile, dataView, byteOffset) {
|
|
7
|
-
const HEADER_SIZE = 12;
|
|
8
|
-
if (!dataView) {
|
|
9
|
-
return byteOffset + HEADER_SIZE;
|
|
10
|
-
}
|
|
11
|
-
const { magic, version = 1, byteLength = 12 } = tile;
|
|
12
|
-
(0, loader_utils_1.assert)(Array.isArray(magic) && Number.isFinite(version) && Number.isFinite(byteLength));
|
|
13
|
-
dataView.setUint8(byteOffset + 0, magic[0]);
|
|
14
|
-
dataView.setUint8(byteOffset + 1, magic[1]);
|
|
15
|
-
dataView.setUint8(byteOffset + 2, magic[2]);
|
|
16
|
-
dataView.setUint8(byteOffset + 3, magic[3]);
|
|
17
|
-
dataView.setUint32(byteOffset + 4, version, true); // version
|
|
18
|
-
dataView.setUint32(byteOffset + 8, byteLength, true); // byteLength
|
|
19
|
-
byteOffset += HEADER_SIZE;
|
|
20
|
-
return byteOffset;
|
|
21
|
-
}
|
|
22
|
-
exports.encode3DTileHeader = encode3DTileHeader;
|
|
23
|
-
// Bytelength is sometimes only known at the end of writing a tile
|
|
24
|
-
function encode3DTileByteLength(dataView, byteOffsetTileStart, byteLength) {
|
|
25
|
-
if (!dataView) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
dataView.setUint32(byteOffsetTileStart + 8, byteLength, true); // byteLength
|
|
29
|
-
}
|
|
30
|
-
exports.encode3DTileByteLength = encode3DTileByteLength;
|
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, { fetch: { 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}`, { fetch: { 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`, { fetch: { 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,266 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.replaceContentUrlTemplate = exports.parseImplicitTiles = void 0;
|
|
4
|
-
const tile_3d_subtree_loader_1 = require("../../../tile-3d-subtree-loader");
|
|
5
|
-
const core_1 = require("@loaders.gl/core");
|
|
6
|
-
const index_1 = require("../../utils/s2/index");
|
|
7
|
-
const s2_corners_to_obb_1 = require("../../utils/obb/s2-corners-to-obb");
|
|
8
|
-
const QUADTREE_DEVISION_COUNT = 4;
|
|
9
|
-
const OCTREE_DEVISION_COUNT = 8;
|
|
10
|
-
const SUBDIVISION_COUNT_MAP = {
|
|
11
|
-
QUADTREE: QUADTREE_DEVISION_COUNT,
|
|
12
|
-
OCTREE: OCTREE_DEVISION_COUNT
|
|
13
|
-
};
|
|
14
|
-
function getChildS2VolumeBox(s2VolumeBox, index, subdivisionScheme) {
|
|
15
|
-
if (s2VolumeBox?.box) {
|
|
16
|
-
// Check if the BoundingVolume is of type "box"
|
|
17
|
-
const cellId = (0, index_1.getS2CellIdFromToken)(s2VolumeBox.s2VolumeInfo.token);
|
|
18
|
-
const childCellId = (0, index_1.getS2ChildCellId)(cellId, index);
|
|
19
|
-
const childToken = (0, index_1.getS2TokenFromCellId)(childCellId);
|
|
20
|
-
// Clone object. Note, s2VolumeInfo is a plain object that doesn't contain any nested object.
|
|
21
|
-
// So, we can use the Spread Operator to make a shallow copy of the object.
|
|
22
|
-
const s2ChildVolumeInfo = { ...s2VolumeBox.s2VolumeInfo };
|
|
23
|
-
s2ChildVolumeInfo.token = childToken; // replace the token with the child's one
|
|
24
|
-
// In case of QUADTREE the sizeZ should NOT be changed!
|
|
25
|
-
// https://portal.ogc.org/files/102132
|
|
26
|
-
// A quadtree divides space only on the x and y dimensions.
|
|
27
|
-
// It divides each tile into 4 smaller tiles where the x and y dimensions are halved.
|
|
28
|
-
// The quadtree z minimum and maximum remain unchanged.
|
|
29
|
-
switch (subdivisionScheme) {
|
|
30
|
-
case 'OCTREE':
|
|
31
|
-
const s2VolumeInfo = s2VolumeBox.s2VolumeInfo;
|
|
32
|
-
const delta = s2VolumeInfo.maximumHeight - s2VolumeInfo.minimumHeight;
|
|
33
|
-
const sizeZ = delta / 2.0; // It's a next level (a child)
|
|
34
|
-
const midZ = s2VolumeInfo.minimumHeight + delta / 2.0;
|
|
35
|
-
s2VolumeInfo.minimumHeight = midZ - sizeZ;
|
|
36
|
-
s2VolumeInfo.maximumHeight = midZ + sizeZ;
|
|
37
|
-
break;
|
|
38
|
-
default:
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
const box = (0, s2_corners_to_obb_1.convertS2BoundingVolumetoOBB)(s2ChildVolumeInfo);
|
|
42
|
-
const childS2VolumeBox = {
|
|
43
|
-
box,
|
|
44
|
-
s2VolumeInfo: s2ChildVolumeInfo
|
|
45
|
-
};
|
|
46
|
-
return childS2VolumeBox;
|
|
47
|
-
}
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Recursively parse implicit tiles tree
|
|
52
|
-
* Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling
|
|
53
|
-
* TODO Check out do we able to use Tile3D class as return type here.
|
|
54
|
-
* @param subtree
|
|
55
|
-
* @param lodMetricValue
|
|
56
|
-
* @param options
|
|
57
|
-
* @param parentData
|
|
58
|
-
* @param childIndex
|
|
59
|
-
* @param level
|
|
60
|
-
* @param globalData
|
|
61
|
-
*/
|
|
62
|
-
// eslint-disable-next-line max-statements
|
|
63
|
-
async function parseImplicitTiles(params) {
|
|
64
|
-
const { options, parentData = {
|
|
65
|
-
mortonIndex: 0,
|
|
66
|
-
x: 0,
|
|
67
|
-
y: 0,
|
|
68
|
-
z: 0
|
|
69
|
-
}, childIndex = 0, globalData = {
|
|
70
|
-
level: 0,
|
|
71
|
-
mortonIndex: 0,
|
|
72
|
-
x: 0,
|
|
73
|
-
y: 0,
|
|
74
|
-
z: 0
|
|
75
|
-
}, s2VolumeBox } = params;
|
|
76
|
-
let { subtree, level = 0 } = params;
|
|
77
|
-
const { subdivisionScheme, subtreeLevels, maximumLevel, contentUrlTemplate, subtreesUriTemplate, basePath } = options;
|
|
78
|
-
const tile = { children: [], lodMetricValue: 0, contentUrl: '' };
|
|
79
|
-
const childrenPerTile = SUBDIVISION_COUNT_MAP[subdivisionScheme];
|
|
80
|
-
const childX = childIndex & 0b01;
|
|
81
|
-
const childY = (childIndex >> 1) & 0b01;
|
|
82
|
-
const childZ = (childIndex >> 2) & 0b01;
|
|
83
|
-
const levelOffset = (childrenPerTile ** level - 1) / (childrenPerTile - 1);
|
|
84
|
-
let childTileMortonIndex = concatBits(parentData.mortonIndex, childIndex);
|
|
85
|
-
let tileAvailabilityIndex = levelOffset + childTileMortonIndex;
|
|
86
|
-
// Local tile coordinates
|
|
87
|
-
let childTileX = concatBits(parentData.x, childX);
|
|
88
|
-
let childTileY = concatBits(parentData.y, childY);
|
|
89
|
-
let childTileZ = concatBits(parentData.z, childZ);
|
|
90
|
-
let isChildSubtreeAvailable = false;
|
|
91
|
-
if (level + 1 > subtreeLevels) {
|
|
92
|
-
isChildSubtreeAvailable = getAvailabilityResult(subtree.childSubtreeAvailability, childTileMortonIndex);
|
|
93
|
-
}
|
|
94
|
-
const x = concatBits(globalData.x, childTileX);
|
|
95
|
-
const y = concatBits(globalData.y, childTileY);
|
|
96
|
-
const z = concatBits(globalData.z, childTileZ);
|
|
97
|
-
const lev = level + globalData.level;
|
|
98
|
-
if (isChildSubtreeAvailable) {
|
|
99
|
-
const subtreePath = `${basePath}/${subtreesUriTemplate}`;
|
|
100
|
-
const childSubtreeUrl = replaceContentUrlTemplate(subtreePath, lev, x, y, z);
|
|
101
|
-
const childSubtree = await (0, core_1.load)(childSubtreeUrl, tile_3d_subtree_loader_1.Tile3DSubtreeLoader);
|
|
102
|
-
subtree = childSubtree;
|
|
103
|
-
globalData.mortonIndex = childTileMortonIndex;
|
|
104
|
-
globalData.x = childTileX;
|
|
105
|
-
globalData.y = childTileY;
|
|
106
|
-
globalData.z = childTileZ;
|
|
107
|
-
globalData.level = level;
|
|
108
|
-
childTileMortonIndex = 0;
|
|
109
|
-
tileAvailabilityIndex = 0;
|
|
110
|
-
childTileX = 0;
|
|
111
|
-
childTileY = 0;
|
|
112
|
-
childTileZ = 0;
|
|
113
|
-
level = 0;
|
|
114
|
-
}
|
|
115
|
-
const isTileAvailable = getAvailabilityResult(subtree.tileAvailability, tileAvailabilityIndex);
|
|
116
|
-
if (!isTileAvailable || level > maximumLevel) {
|
|
117
|
-
return tile;
|
|
118
|
-
}
|
|
119
|
-
const isContentAvailable = getAvailabilityResult(subtree.contentAvailability, tileAvailabilityIndex);
|
|
120
|
-
if (isContentAvailable) {
|
|
121
|
-
tile.contentUrl = replaceContentUrlTemplate(contentUrlTemplate, lev, x, y, z);
|
|
122
|
-
}
|
|
123
|
-
const childTileLevel = level + 1;
|
|
124
|
-
const pData = { mortonIndex: childTileMortonIndex, x: childTileX, y: childTileY, z: childTileZ };
|
|
125
|
-
for (let index = 0; index < childrenPerTile; index++) {
|
|
126
|
-
const childS2VolumeBox = getChildS2VolumeBox(s2VolumeBox, index, subdivisionScheme);
|
|
127
|
-
// Recursive calling...
|
|
128
|
-
const childTileParsed = await parseImplicitTiles({
|
|
129
|
-
subtree,
|
|
130
|
-
options,
|
|
131
|
-
parentData: pData,
|
|
132
|
-
childIndex: index,
|
|
133
|
-
level: childTileLevel,
|
|
134
|
-
globalData,
|
|
135
|
-
s2VolumeBox: childS2VolumeBox
|
|
136
|
-
});
|
|
137
|
-
if (childTileParsed.contentUrl || childTileParsed.children.length) {
|
|
138
|
-
const globalLevel = lev + 1;
|
|
139
|
-
const childCoordinates = { childTileX, childTileY, childTileZ };
|
|
140
|
-
const formattedTile = formatTileData(childTileParsed, globalLevel, childCoordinates, options, s2VolumeBox);
|
|
141
|
-
// @ts-ignore
|
|
142
|
-
tile.children.push(formattedTile);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return tile;
|
|
146
|
-
}
|
|
147
|
-
exports.parseImplicitTiles = parseImplicitTiles;
|
|
148
|
-
function getAvailabilityResult(availabilityData, index) {
|
|
149
|
-
if ('constant' in availabilityData) {
|
|
150
|
-
return Boolean(availabilityData.constant);
|
|
151
|
-
}
|
|
152
|
-
if (availabilityData.explicitBitstream) {
|
|
153
|
-
return getBooleanValueFromBitstream(index, availabilityData.explicitBitstream);
|
|
154
|
-
}
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Do formatting of implicit tile data.
|
|
159
|
-
* TODO Check out do we able to use Tile3D class as type here.
|
|
160
|
-
* @param tile
|
|
161
|
-
* @param lodMetricValue
|
|
162
|
-
* @param options
|
|
163
|
-
* @returns
|
|
164
|
-
*/
|
|
165
|
-
function formatTileData(tile, level, childCoordinates, options, s2VolumeBox) {
|
|
166
|
-
const { basePath, refine, getRefine, lodMetricType, getTileType, rootLodMetricValue, rootBoundingVolume } = options;
|
|
167
|
-
const uri = tile.contentUrl && tile.contentUrl.replace(`${basePath}/`, '');
|
|
168
|
-
const lodMetricValue = rootLodMetricValue / 2 ** level;
|
|
169
|
-
const boundingVolume = s2VolumeBox?.box
|
|
170
|
-
? { box: s2VolumeBox.box }
|
|
171
|
-
: rootBoundingVolume;
|
|
172
|
-
const boundingVolumeForChildTile = calculateBoundingVolumeForChildTile(level, boundingVolume, childCoordinates);
|
|
173
|
-
return {
|
|
174
|
-
children: tile.children,
|
|
175
|
-
contentUrl: tile.contentUrl,
|
|
176
|
-
content: { uri },
|
|
177
|
-
id: tile.contentUrl,
|
|
178
|
-
refine: getRefine(refine),
|
|
179
|
-
type: getTileType(tile),
|
|
180
|
-
lodMetricType,
|
|
181
|
-
lodMetricValue,
|
|
182
|
-
geometricError: lodMetricValue,
|
|
183
|
-
transform: tile.transform,
|
|
184
|
-
boundingVolume: boundingVolumeForChildTile
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Calculate child bounding volume.
|
|
189
|
-
* Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subdivision-rules
|
|
190
|
-
* @param level
|
|
191
|
-
* @param rootBoundingVolume
|
|
192
|
-
* @param childCoordinates
|
|
193
|
-
*/
|
|
194
|
-
function calculateBoundingVolumeForChildTile(level, rootBoundingVolume, childCoordinates) {
|
|
195
|
-
if (rootBoundingVolume.region) {
|
|
196
|
-
const { childTileX, childTileY, childTileZ } = childCoordinates;
|
|
197
|
-
const [west, south, east, north, minimumHeight, maximumHeight] = rootBoundingVolume.region;
|
|
198
|
-
const boundingVolumesCount = 2 ** level;
|
|
199
|
-
const sizeX = (east - west) / boundingVolumesCount;
|
|
200
|
-
const sizeY = (north - south) / boundingVolumesCount;
|
|
201
|
-
// TODO : Why is the subdivisionScheme not being checked here?
|
|
202
|
-
// In case of QUADTREE the sizeZ should NOT be changed!
|
|
203
|
-
// https://portal.ogc.org/files/102132
|
|
204
|
-
// 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.
|
|
205
|
-
const sizeZ = (maximumHeight - minimumHeight) / boundingVolumesCount;
|
|
206
|
-
const [childWest, childEast] = [west + sizeX * childTileX, west + sizeX * (childTileX + 1)];
|
|
207
|
-
const [childSouth, childNorth] = [south + sizeY * childTileY, south + sizeY * (childTileY + 1)];
|
|
208
|
-
const [childMinimumHeight, childMaximumHeight] = [
|
|
209
|
-
minimumHeight + sizeZ * childTileZ,
|
|
210
|
-
minimumHeight + sizeZ * (childTileZ + 1)
|
|
211
|
-
];
|
|
212
|
-
return {
|
|
213
|
-
region: [childWest, childSouth, childEast, childNorth, childMinimumHeight, childMaximumHeight]
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
if (rootBoundingVolume.box) {
|
|
217
|
-
return rootBoundingVolume;
|
|
218
|
-
}
|
|
219
|
-
throw new Error(`Unsupported bounding volume type ${rootBoundingVolume}`);
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Do binary concatenation
|
|
223
|
-
* @param first
|
|
224
|
-
* @param second
|
|
225
|
-
*/
|
|
226
|
-
function concatBits(first, second) {
|
|
227
|
-
return parseInt(first.toString(2) + second.toString(2), 2);
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Replace implicit tile content url with real coordinates.
|
|
231
|
-
* @param templateUrl
|
|
232
|
-
* @param level
|
|
233
|
-
* @param x
|
|
234
|
-
* @param y
|
|
235
|
-
* @param z
|
|
236
|
-
*/
|
|
237
|
-
function replaceContentUrlTemplate(templateUrl, level, x, y, z) {
|
|
238
|
-
const mapUrl = generateMapUrl({ level, x, y, z });
|
|
239
|
-
return templateUrl.replace(/{level}|{x}|{y}|{z}/gi, (matched) => mapUrl[matched]);
|
|
240
|
-
}
|
|
241
|
-
exports.replaceContentUrlTemplate = replaceContentUrlTemplate;
|
|
242
|
-
/**
|
|
243
|
-
* Get Map object for content url generation
|
|
244
|
-
* @param items
|
|
245
|
-
*/
|
|
246
|
-
function generateMapUrl(items) {
|
|
247
|
-
const mapUrl = {};
|
|
248
|
-
for (const key in items) {
|
|
249
|
-
mapUrl[`{${key}}`] = items[key];
|
|
250
|
-
}
|
|
251
|
-
return mapUrl;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Get boolean value from bistream by index
|
|
255
|
-
* A boolean value is encoded as a single bit, either 0 (false) or 1 (true).
|
|
256
|
-
* Multiple boolean values are packed tightly in the same buffer.
|
|
257
|
-
* These buffers of tightly-packed bits are sometimes referred to as bitstreams.
|
|
258
|
-
* Spec - https://github.com/CesiumGS/3d-tiles/tree/implicit-revisions/specification/Metadata#booleans
|
|
259
|
-
* @param availabilitiIndex
|
|
260
|
-
*/
|
|
261
|
-
function getBooleanValueFromBitstream(availabilityIndex, availabilityBuffer) {
|
|
262
|
-
const byteIndex = Math.floor(availabilityIndex / 8);
|
|
263
|
-
const bitIndex = availabilityIndex % 8;
|
|
264
|
-
const bitValue = (availabilityBuffer[byteIndex] >> bitIndex) & 1;
|
|
265
|
-
return bitValue === 1;
|
|
266
|
-
}
|
|
@@ -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
|
-
const { parse, fetch } = context;
|
|
59
|
-
if (tile.gltfUrl) {
|
|
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 parse(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
|
-
}
|