@loaders.gl/3d-tiles 4.0.0-alpha.23 → 4.0.0-alpha.25
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/cesium-ion-loader.d.ts +2 -2
- package/dist/cesium-ion-loader.d.ts.map +1 -1
- package/dist/dist.min.js +421 -270
- package/dist/es5/3d-tiles-archive-loader.js +1 -1
- package/dist/es5/cesium-ion-loader.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/types.js.map +1 -1
- package/dist/esm/3d-tiles-archive-loader.js +1 -1
- package/dist/esm/cesium-ion-loader.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/types.js.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/types.d.ts +2 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/cesium-ion-loader.ts +2 -2
- package/src/tile-3d-subtree-loader.ts +3 -3
- package/src/tile-3d-writer.ts +2 -2
- package/src/types.ts +3 -5
- 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 -40
- 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 -29
- 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 -80
- package/dist/types.js +0 -2
|
@@ -1,72 +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 math_1 = require("@loaders.gl/math");
|
|
6
|
-
// Reference:
|
|
7
|
-
// https://github.com/AnalyticalGraphicsInc/cesium/blob/1de96d087f0b17575eb1a3f736407b348c765d59/Source/Scene/Cesium3DTileFeatureTable.js
|
|
8
|
-
class Tile3DFeatureTable {
|
|
9
|
-
constructor(featureTableJson, featureTableBinary) {
|
|
10
|
-
this.featuresLength = 0;
|
|
11
|
-
this._cachedTypedArrays = {};
|
|
12
|
-
this.json = featureTableJson;
|
|
13
|
-
this.buffer = featureTableBinary;
|
|
14
|
-
}
|
|
15
|
-
getExtension(extensionName) {
|
|
16
|
-
return this.json.extensions && this.json.extensions[extensionName];
|
|
17
|
-
}
|
|
18
|
-
hasProperty(propertyName) {
|
|
19
|
-
return Boolean(this.json[propertyName]);
|
|
20
|
-
}
|
|
21
|
-
getGlobalProperty(propertyName, componentType = math_1.GL.UNSIGNED_INT, componentLength = 1) {
|
|
22
|
-
const jsonValue = this.json[propertyName];
|
|
23
|
-
if (jsonValue && Number.isFinite(jsonValue.byteOffset)) {
|
|
24
|
-
return this._getTypedArrayFromBinary(propertyName, componentType, componentLength, 1, jsonValue.byteOffset);
|
|
25
|
-
}
|
|
26
|
-
return jsonValue;
|
|
27
|
-
}
|
|
28
|
-
getPropertyArray(propertyName, componentType, componentLength) {
|
|
29
|
-
const jsonValue = this.json[propertyName];
|
|
30
|
-
if (jsonValue && Number.isFinite(jsonValue.byteOffset)) {
|
|
31
|
-
if ('componentType' in jsonValue) {
|
|
32
|
-
componentType = math_1.GLType.fromName(jsonValue.componentType);
|
|
33
|
-
}
|
|
34
|
-
return this._getTypedArrayFromBinary(propertyName, componentType, componentLength, this.featuresLength, jsonValue.byteOffset);
|
|
35
|
-
}
|
|
36
|
-
return this._getTypedArrayFromArray(propertyName, componentType, jsonValue);
|
|
37
|
-
}
|
|
38
|
-
getProperty(propertyName, componentType, componentLength, featureId, result) {
|
|
39
|
-
const jsonValue = this.json[propertyName];
|
|
40
|
-
if (!jsonValue) {
|
|
41
|
-
return jsonValue;
|
|
42
|
-
}
|
|
43
|
-
const typedArray = this.getPropertyArray(propertyName, componentType, componentLength);
|
|
44
|
-
if (componentLength === 1) {
|
|
45
|
-
return typedArray[featureId];
|
|
46
|
-
}
|
|
47
|
-
for (let i = 0; i < componentLength; ++i) {
|
|
48
|
-
result[i] = typedArray[componentLength * featureId + i];
|
|
49
|
-
}
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
// HELPERS
|
|
53
|
-
_getTypedArrayFromBinary(propertyName, componentType, componentLength, count, byteOffset) {
|
|
54
|
-
const cachedTypedArrays = this._cachedTypedArrays;
|
|
55
|
-
let typedArray = cachedTypedArrays[propertyName];
|
|
56
|
-
if (!typedArray) {
|
|
57
|
-
typedArray = math_1.GLType.createTypedArray(componentType, this.buffer.buffer, this.buffer.byteOffset + byteOffset, count * componentLength);
|
|
58
|
-
cachedTypedArrays[propertyName] = typedArray;
|
|
59
|
-
}
|
|
60
|
-
return typedArray;
|
|
61
|
-
}
|
|
62
|
-
_getTypedArrayFromArray(propertyName, componentType, array) {
|
|
63
|
-
const cachedTypedArrays = this._cachedTypedArrays;
|
|
64
|
-
let typedArray = cachedTypedArrays[propertyName];
|
|
65
|
-
if (!typedArray) {
|
|
66
|
-
typedArray = math_1.GLType.createTypedArray(componentType, array);
|
|
67
|
-
cachedTypedArrays[propertyName] = typedArray;
|
|
68
|
-
}
|
|
69
|
-
return typedArray;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.default = Tile3DFeatureTable;
|
package/dist/lib/constants.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// TILE TYPES
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.TILE3D_OPTIMIZATION_HINT = exports.MAGIC_ARRAY = exports.TILE3D_TYPES = exports.TILE3D_TYPE = void 0;
|
|
5
|
-
exports.TILE3D_TYPE = {
|
|
6
|
-
COMPOSITE: 'cmpt',
|
|
7
|
-
POINT_CLOUD: 'pnts',
|
|
8
|
-
BATCHED_3D_MODEL: 'b3dm',
|
|
9
|
-
INSTANCED_3D_MODEL: 'i3dm',
|
|
10
|
-
GEOMETRY: 'geom',
|
|
11
|
-
VECTOR: 'vect',
|
|
12
|
-
GLTF: 'glTF'
|
|
13
|
-
};
|
|
14
|
-
exports.TILE3D_TYPES = Object.keys(exports.TILE3D_TYPE);
|
|
15
|
-
exports.MAGIC_ARRAY = {
|
|
16
|
-
BATCHED_MODEL: [98, 51, 100, 109],
|
|
17
|
-
INSTANCED_MODEL: [105, 51, 100, 109],
|
|
18
|
-
POINT_CLOUD: [112, 110, 116, 115],
|
|
19
|
-
COMPOSITE: [99, 109, 112, 116]
|
|
20
|
-
};
|
|
21
|
-
// TILE CONSTANTS
|
|
22
|
-
exports.TILE3D_OPTIMIZATION_HINT = {
|
|
23
|
-
NOT_COMPUTED: -1,
|
|
24
|
-
USE_OPTIMIZATION: 1,
|
|
25
|
-
SKIP_OPTIMIZATION: 0
|
|
26
|
-
};
|
|
@@ -1,46 +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.encodeBatchedModel3DTile = void 0;
|
|
6
|
-
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
7
|
-
const constants_1 = require("../constants");
|
|
8
|
-
const encode_3d_tile_header_1 = require("./helpers/encode-3d-tile-header");
|
|
9
|
-
// Procedurally encode the tile array dataView for testing purposes
|
|
10
|
-
function encodeBatchedModel3DTile(tile, dataView, byteOffset, options) {
|
|
11
|
-
const { featuresLength = 0, batchTable } = tile;
|
|
12
|
-
const featureTableJson = {
|
|
13
|
-
BATCH_LENGTH: featuresLength
|
|
14
|
-
};
|
|
15
|
-
const featureTableJsonString = JSON.stringify(featureTableJson);
|
|
16
|
-
const batchTableJsonString = batchTable ? JSON.stringify(batchTable) : '';
|
|
17
|
-
const featureTableJsonByteLength = (0, loader_utils_1.padToNBytes)(featureTableJsonString.length, 8);
|
|
18
|
-
const batchTableJsonByteLength = batchTableJsonString
|
|
19
|
-
? (0, loader_utils_1.padToNBytes)(batchTableJsonString.length, 8)
|
|
20
|
-
: 0;
|
|
21
|
-
// Add default magic for this tile type
|
|
22
|
-
tile = { magic: constants_1.MAGIC_ARRAY.BATCHED_MODEL, ...tile };
|
|
23
|
-
const byteOffsetStart = byteOffset;
|
|
24
|
-
byteOffset = (0, encode_3d_tile_header_1.encode3DTileHeader)(tile, dataView, byteOffset);
|
|
25
|
-
if (dataView) {
|
|
26
|
-
dataView.setUint32(12, featureTableJsonByteLength, true); // featureTableJsonByteLength
|
|
27
|
-
dataView.setUint32(16, 0, true); // featureTableBinaryByteLength
|
|
28
|
-
dataView.setUint32(20, batchTableJsonByteLength, true); // batchTableJsonByteLength
|
|
29
|
-
dataView.setUint32(24, 0, true); // batchTableBinaryByteLength
|
|
30
|
-
}
|
|
31
|
-
byteOffset += 16;
|
|
32
|
-
// TODO feature table binary
|
|
33
|
-
byteOffset = (0, loader_utils_1.copyPaddedStringToDataView)(dataView, byteOffset, featureTableJsonString, 8);
|
|
34
|
-
if (batchTable) {
|
|
35
|
-
byteOffset = (0, loader_utils_1.copyPaddedStringToDataView)(dataView, byteOffset, batchTableJsonString, 8);
|
|
36
|
-
}
|
|
37
|
-
// Add encoded GLTF to the end of data
|
|
38
|
-
const gltfEncoded = tile.gltfEncoded;
|
|
39
|
-
if (gltfEncoded) {
|
|
40
|
-
byteOffset = (0, loader_utils_1.copyBinaryToDataView)(dataView, byteOffset, gltfEncoded, gltfEncoded.byteLength);
|
|
41
|
-
}
|
|
42
|
-
// Go "back" and rewrite the tile's `byteLength` now that we know the value
|
|
43
|
-
(0, encode_3d_tile_header_1.encode3DTileByteLength)(dataView, byteOffsetStart, byteOffset - byteOffsetStart);
|
|
44
|
-
return byteOffset;
|
|
45
|
-
}
|
|
46
|
-
exports.encodeBatchedModel3DTile = encodeBatchedModel3DTile;
|
|
@@ -1,24 +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.encodeComposite3DTile = void 0;
|
|
6
|
-
const constants_1 = require("../constants");
|
|
7
|
-
const encode_3d_tile_header_1 = require("./helpers/encode-3d-tile-header");
|
|
8
|
-
function encodeComposite3DTile(tile, dataView, byteOffset, options, encode3DTile) {
|
|
9
|
-
// Add default magic for this tile type
|
|
10
|
-
tile = { magic: constants_1.MAGIC_ARRAY.COMPOSITE, tiles: [], ...tile };
|
|
11
|
-
const byteOffsetStart = byteOffset;
|
|
12
|
-
byteOffset += (0, encode_3d_tile_header_1.encode3DTileHeader)(tile, dataView, byteOffset);
|
|
13
|
-
if (dataView) {
|
|
14
|
-
dataView.setUint32(byteOffset, tile.tiles.length, true); // tilesLength
|
|
15
|
-
}
|
|
16
|
-
byteOffset += 4;
|
|
17
|
-
for (let i = 0; i < tile.tiles.length; ++i) {
|
|
18
|
-
byteOffset += encode3DTile(tile.tiles[i], dataView, byteOffset, options);
|
|
19
|
-
}
|
|
20
|
-
// Go "back" and rewrite the tile's `byteLength` now that we know the value
|
|
21
|
-
(0, encode_3d_tile_header_1.encode3DTileByteLength)(dataView, byteOffsetStart, byteOffset - byteOffsetStart);
|
|
22
|
-
return byteOffset;
|
|
23
|
-
}
|
|
24
|
-
exports.encodeComposite3DTile = encodeComposite3DTile;
|
|
@@ -1,38 +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.encodeInstancedModel3DTile = void 0;
|
|
6
|
-
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
7
|
-
const constants_1 = require("../constants");
|
|
8
|
-
const encode_3d_tile_header_1 = require("./helpers/encode-3d-tile-header");
|
|
9
|
-
// Procedurally encode the tile array buffer for testing purposes
|
|
10
|
-
// eslint-disable-next-line max-statements
|
|
11
|
-
function encodeInstancedModel3DTile(tile, dataView, byteOffset, options) {
|
|
12
|
-
const { featuresLength = 1, gltfFormat = 1, gltfUri = '' } = tile;
|
|
13
|
-
const gltfUriByteLength = gltfUri.length;
|
|
14
|
-
const featureTableJson = {
|
|
15
|
-
INSTANCES_LENGTH: featuresLength,
|
|
16
|
-
POSITION: new Array(featuresLength * 3).fill(0)
|
|
17
|
-
};
|
|
18
|
-
const featureTableJsonString = JSON.stringify(featureTableJson);
|
|
19
|
-
const featureTableJsonByteLength = featureTableJsonString.length;
|
|
20
|
-
// Add default magic for this tile type
|
|
21
|
-
tile = { magic: constants_1.MAGIC_ARRAY.INSTANCED_MODEL, ...tile };
|
|
22
|
-
const byteOffsetStart = byteOffset;
|
|
23
|
-
byteOffset = (0, encode_3d_tile_header_1.encode3DTileHeader)(tile, dataView, 0);
|
|
24
|
-
if (dataView) {
|
|
25
|
-
dataView.setUint32(12, featureTableJsonByteLength, true); // featureTableJsonByteLength
|
|
26
|
-
dataView.setUint32(16, 0, true); // featureTableBinaryByteLength
|
|
27
|
-
dataView.setUint32(20, 0, true); // batchTableJsonByteLength
|
|
28
|
-
dataView.setUint32(24, 0, true); // batchTableBinaryByteLength
|
|
29
|
-
dataView.setUint32(28, gltfFormat, true); // gltfFormat
|
|
30
|
-
}
|
|
31
|
-
byteOffset += 20;
|
|
32
|
-
byteOffset += (0, loader_utils_1.copyStringToDataView)(dataView, byteOffset, featureTableJsonString, featureTableJsonByteLength);
|
|
33
|
-
byteOffset += (0, loader_utils_1.copyStringToDataView)(dataView, byteOffset, gltfUri, gltfUriByteLength);
|
|
34
|
-
// Go "back" and rewrite the tile's `byteLength` now that we know the value
|
|
35
|
-
(0, encode_3d_tile_header_1.encode3DTileByteLength)(dataView, byteOffsetStart, byteOffset - byteOffsetStart);
|
|
36
|
-
return byteOffset;
|
|
37
|
-
}
|
|
38
|
-
exports.encodeInstancedModel3DTile = encodeInstancedModel3DTile;
|
|
@@ -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;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Tiles3DArchiveFileSystem = void 0;
|
|
4
|
-
const zip_1 = require("@loaders.gl/zip");
|
|
5
|
-
const _3d_tiles_archive_archive_1 = require("../../3d-tiles-archive/3d-tiles-archive-archive");
|
|
6
|
-
/**
|
|
7
|
-
* FileSystem adapter for a 3tz (3D tiles archive format) file
|
|
8
|
-
* Holds FileProvider object that provides random access to archived files.
|
|
9
|
-
* The difference from ZipFileSystem is usage of `@3dtilesIndex1@` index file that increases
|
|
10
|
-
* access speed to archived files
|
|
11
|
-
* @see https://github.com/erikdahlstrom/3tz-specification/blob/master/Specification.md
|
|
12
|
-
*/
|
|
13
|
-
class Tiles3DArchiveFileSystem extends zip_1.ZipFileSystem {
|
|
14
|
-
/**
|
|
15
|
-
* Constructor
|
|
16
|
-
* @param file - instance of FileProvider or file path string
|
|
17
|
-
*/
|
|
18
|
-
constructor(file) {
|
|
19
|
-
super(file);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Implementation of fetch against this file system.
|
|
23
|
-
* It tries to take `@3dtilesIndex1@` file from the archive and use it
|
|
24
|
-
* for faster access to archived files
|
|
25
|
-
* @param filename - name of a file
|
|
26
|
-
* @returns - Response with file data
|
|
27
|
-
*/
|
|
28
|
-
async fetch(filename) {
|
|
29
|
-
const fileProvider = await this.fileProvider;
|
|
30
|
-
if (!fileProvider) {
|
|
31
|
-
throw new Error('No data detected in the zip archive');
|
|
32
|
-
}
|
|
33
|
-
await this.parseHashFile();
|
|
34
|
-
if (this.hashData) {
|
|
35
|
-
const archive = new _3d_tiles_archive_archive_1.Tiles3DArchive(fileProvider, this.hashData);
|
|
36
|
-
const fileData = await archive.getFile(filename);
|
|
37
|
-
const response = new Response(fileData);
|
|
38
|
-
Object.defineProperty(response, 'url', { value: `${this.fileName || ''}/${filename}` });
|
|
39
|
-
return response;
|
|
40
|
-
}
|
|
41
|
-
return super.fetch(filename);
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Try to get and parse '@3dtilesIndex1@' file, that allows to get direct access
|
|
45
|
-
* to files inside the archive
|
|
46
|
-
* @returns void
|
|
47
|
-
*/
|
|
48
|
-
async parseHashFile() {
|
|
49
|
-
if (this.hashData !== undefined) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
const fileProvider = await this.fileProvider;
|
|
53
|
-
if (!fileProvider) {
|
|
54
|
-
throw new Error('No data detected in the zip archive');
|
|
55
|
-
}
|
|
56
|
-
const hashCDOffset = await (0, zip_1.searchFromTheEnd)(fileProvider, zip_1.cdSignature);
|
|
57
|
-
const cdFileHeader = await (0, zip_1.parseZipCDFileHeader)(hashCDOffset, fileProvider);
|
|
58
|
-
// '@3dtilesIndex1@' is index file that must be the last in the archive. It allows
|
|
59
|
-
// to improve load and read performance when the archive contains a very large number
|
|
60
|
-
// of files.
|
|
61
|
-
if (cdFileHeader?.fileName === '@3dtilesIndex1@') {
|
|
62
|
-
const localFileHeader = await (0, zip_1.parseZipLocalFileHeader)(cdFileHeader.localHeaderOffset, fileProvider);
|
|
63
|
-
if (!localFileHeader) {
|
|
64
|
-
throw new Error('corrupted 3tz');
|
|
65
|
-
}
|
|
66
|
-
const fileDataOffset = localFileHeader.fileDataOffset;
|
|
67
|
-
const hashFile = await fileProvider.slice(fileDataOffset, fileDataOffset + localFileHeader.compressedSize);
|
|
68
|
-
this.hashData = (0, zip_1.parseHashFile)(hashFile);
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
this.hashData = null;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
exports.Tiles3DArchiveFileSystem = Tiles3DArchiveFileSystem;
|
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
|
-
}
|