@loaders.gl/3d-tiles 3.1.0-beta.7 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +5 -10008
- package/dist/dist.min.js +12179 -0
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/cesium-ion-loader.js +78 -23
- package/dist/es5/cesium-ion-loader.js.map +1 -1
- package/dist/es5/index.js +8 -8
- package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js +42 -30
- package/dist/es5/lib/classes/helpers/tile-3d-accessor-utils.js.map +1 -1
- package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js +59 -57
- package/dist/es5/lib/classes/tile-3d-batch-table-hierarchy.js.map +1 -1
- package/dist/es5/lib/classes/tile-3d-batch-table.js +238 -201
- package/dist/es5/lib/classes/tile-3d-batch-table.js.map +1 -1
- package/dist/es5/lib/classes/tile-3d-feature-table.js +78 -62
- package/dist/es5/lib/classes/tile-3d-feature-table.js.map +1 -1
- package/dist/es5/lib/constants.js +6 -5
- package/dist/es5/lib/constants.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js +22 -15
- package/dist/es5/lib/encoders/encode-3d-tile-batched-model.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-composite.js +13 -6
- package/dist/es5/lib/encoders/encode-3d-tile-composite.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js +23 -14
- package/dist/es5/lib/encoders/encode-3d-tile-instanced-model.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js +22 -15
- package/dist/es5/lib/encoders/encode-3d-tile-point-cloud.js.map +1 -1
- package/dist/es5/lib/encoders/encode-3d-tile.js +3 -3
- package/dist/es5/lib/encoders/encode-3d-tile.js.map +1 -1
- package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js +6 -6
- package/dist/es5/lib/encoders/helpers/encode-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/ion/ion.js +197 -69
- package/dist/es5/lib/ion/ion.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js +18 -17
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js +3 -3
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js +3 -3
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-positions.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js +270 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -0
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +66 -26
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js +4 -3
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js +141 -53
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +17 -19
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-utils.js +8 -7
- package/dist/es5/lib/parsers/helpers/parse-utils.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js +36 -10
- package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js +48 -12
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +45 -0
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
- package/dist/es5/lib/parsers/parse-3d-tile-header.js +161 -14
- package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js +63 -38
- package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js +198 -117
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile.js +74 -15
- 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 +1 -1
- package/dist/es5/tile-3d-subtree-loader.js.map +1 -1
- package/dist/es5/tile-3d-writer.js +5 -5
- package/dist/es5/tile-3d-writer.js.map +1 -1
- package/dist/es5/tiles-3d-loader.js +142 -37
- package/dist/es5/tiles-3d-loader.js.map +1 -1
- package/dist/esm/lib/constants.js +2 -1
- package/dist/esm/lib/constants.js.map +1 -1
- package/dist/esm/lib/ion/ion.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js +173 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -0
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-subtree.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +10 -0
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -0
- package/dist/esm/lib/parsers/parse-3d-tile-header.js +67 -0
- package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile.js +4 -0
- 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/tiles-3d-loader.js +9 -2
- package/dist/esm/tiles-3d-loader.js.map +1 -1
- package/dist/lib/constants.d.ts +1 -0
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +2 -1
- package/dist/lib/ion/ion.d.ts +3 -3
- package/dist/lib/ion/ion.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts +39 -0
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -0
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +189 -0
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts +2 -2
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +1 -0
- package/dist/lib/parsers/parse-3d-tile-batched-model.js +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +2 -0
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -0
- package/dist/lib/parsers/parse-3d-tile-gltf.js +18 -0
- package/dist/lib/parsers/parse-3d-tile-header.d.ts +16 -0
- package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-header.js +67 -1
- package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile.js +3 -0
- package/dist/tiles-3d-loader.d.ts.map +1 -1
- package/dist/tiles-3d-loader.js +8 -1
- package/dist/types.d.ts +6 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/lib/constants.ts +2 -1
- package/src/lib/ion/{ion.js → ion.ts} +0 -0
- package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +255 -0
- package/src/lib/parsers/helpers/parse-3d-tile-subtree.ts +4 -3
- package/src/lib/parsers/parse-3d-tile-gltf.js +16 -0
- package/src/lib/parsers/parse-3d-tile-header.ts +82 -1
- package/src/lib/parsers/parse-3d-tile.ts +4 -0
- package/src/tiles-3d-loader.ts +17 -2
- package/src/types.ts +7 -2
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
import { Tileset3D } from '@loaders.gl/tiles';
|
|
2
|
+
import { Subtree } from '../../types';
|
|
1
3
|
export declare function normalizeTileData(tile: any, options: any): any;
|
|
2
4
|
export declare function normalizeTileHeaders(tileset: any): any;
|
|
5
|
+
/**
|
|
6
|
+
* Do normalisation of implicit tile headers
|
|
7
|
+
* TODO Check if Tile3D class can be a return type here.
|
|
8
|
+
* @param tileset
|
|
9
|
+
*/
|
|
10
|
+
export declare function normalizeImplicitTileHeaders(tileset: Tileset3D): Promise<any>;
|
|
11
|
+
/**
|
|
12
|
+
* Do implicit data normalisation to create hierarchical tile structure
|
|
13
|
+
* @param tile
|
|
14
|
+
* @param rootSubtree
|
|
15
|
+
* @param options
|
|
16
|
+
* @returns
|
|
17
|
+
*/
|
|
18
|
+
export declare function normalizeImplicitTileData(tile: any, rootSubtree: Subtree, options: any): Promise<any>;
|
|
3
19
|
//# sourceMappingURL=parse-3d-tile-header.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile-header.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-header.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-header.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-header.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAA8C,MAAM,mBAAmB,CAAC;AACzF,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAC;AAoCpC,wBAAgB,iBAAiB,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA,OAgB9C;AAGD,wBAAgB,oBAAoB,CAAC,OAAO,KAAA,OAiB3C;AAED;;;;GAIG;AACH,wBAAsB,4BAA4B,CAAC,OAAO,EAAE,SAAS,gBAoCpE;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAAC,IAAI,KAAA,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,gBAsBvF"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.normalizeTileHeaders = exports.normalizeTileData = void 0;
|
|
3
|
+
exports.normalizeImplicitTileData = exports.normalizeImplicitTileHeaders = exports.normalizeTileHeaders = exports.normalizeTileData = void 0;
|
|
4
|
+
const tile_3d_subtree_loader_1 = require("../../tile-3d-subtree-loader");
|
|
5
|
+
const core_1 = require("@loaders.gl/core");
|
|
4
6
|
const tiles_1 = require("@loaders.gl/tiles");
|
|
7
|
+
const parse_3d_implicit_tiles_1 = require("./helpers/parse-3d-implicit-tiles");
|
|
5
8
|
function getTileType(tile) {
|
|
6
9
|
if (!tile.contentUrl) {
|
|
7
10
|
return tiles_1.TILE_TYPE.EMPTY;
|
|
@@ -13,6 +16,8 @@ function getTileType(tile) {
|
|
|
13
16
|
return tiles_1.TILE_TYPE.POINTCLOUD;
|
|
14
17
|
case 'i3dm':
|
|
15
18
|
case 'b3dm':
|
|
19
|
+
case 'glb':
|
|
20
|
+
case 'gltf':
|
|
16
21
|
return tiles_1.TILE_TYPE.SCENEGRAPH;
|
|
17
22
|
default:
|
|
18
23
|
return fileExtension;
|
|
@@ -64,3 +69,64 @@ function normalizeTileHeaders(tileset) {
|
|
|
64
69
|
return root;
|
|
65
70
|
}
|
|
66
71
|
exports.normalizeTileHeaders = normalizeTileHeaders;
|
|
72
|
+
/**
|
|
73
|
+
* Do normalisation of implicit tile headers
|
|
74
|
+
* TODO Check if Tile3D class can be a return type here.
|
|
75
|
+
* @param tileset
|
|
76
|
+
*/
|
|
77
|
+
async function normalizeImplicitTileHeaders(tileset) {
|
|
78
|
+
if (!tileset.root) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
const basePath = tileset.basePath;
|
|
82
|
+
const implicitTilingExtension = tileset.root.extensions['3DTILES_implicit_tiling'];
|
|
83
|
+
const { subdivisionScheme, maximumLevel, subtreeLevels, subtrees: { uri: subtreesUriTemplate } } = implicitTilingExtension;
|
|
84
|
+
const subtreeUrl = (0, parse_3d_implicit_tiles_1.replaceContentUrlTemplate)(subtreesUriTemplate, 0, 0, 0, 0);
|
|
85
|
+
const rootSubtreeUrl = `${basePath}/${subtreeUrl}`;
|
|
86
|
+
const rootSubtree = await (0, core_1.load)(rootSubtreeUrl, tile_3d_subtree_loader_1.Tile3DSubtreeLoader);
|
|
87
|
+
const contentUrlTemplate = `${basePath}/${tileset.root.content.uri}`;
|
|
88
|
+
const refine = tileset.root.refine;
|
|
89
|
+
// @ts-ignore
|
|
90
|
+
const rootLodMetricValue = tileset.root.geometricError;
|
|
91
|
+
const options = {
|
|
92
|
+
contentUrlTemplate,
|
|
93
|
+
subtreesUriTemplate,
|
|
94
|
+
subdivisionScheme,
|
|
95
|
+
subtreeLevels,
|
|
96
|
+
maximumLevel,
|
|
97
|
+
refine,
|
|
98
|
+
basePath,
|
|
99
|
+
lodMetricType: tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR,
|
|
100
|
+
rootLodMetricValue,
|
|
101
|
+
getTileType,
|
|
102
|
+
getRefine
|
|
103
|
+
};
|
|
104
|
+
return await normalizeImplicitTileData(tileset.root, rootSubtree, options);
|
|
105
|
+
}
|
|
106
|
+
exports.normalizeImplicitTileHeaders = normalizeImplicitTileHeaders;
|
|
107
|
+
/**
|
|
108
|
+
* Do implicit data normalisation to create hierarchical tile structure
|
|
109
|
+
* @param tile
|
|
110
|
+
* @param rootSubtree
|
|
111
|
+
* @param options
|
|
112
|
+
* @returns
|
|
113
|
+
*/
|
|
114
|
+
async function normalizeImplicitTileData(tile, rootSubtree, options) {
|
|
115
|
+
if (!tile) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
tile.lodMetricType = tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR;
|
|
119
|
+
tile.lodMetricValue = tile.geometricError;
|
|
120
|
+
tile.transformMatrix = tile.transform;
|
|
121
|
+
const { children, contentUrl } = await (0, parse_3d_implicit_tiles_1.parseImplicitTiles)(rootSubtree, options);
|
|
122
|
+
if (contentUrl) {
|
|
123
|
+
tile.contentUrl = contentUrl;
|
|
124
|
+
tile.content = { uri: contentUrl.replace(`${options.basePath}/`, '') };
|
|
125
|
+
}
|
|
126
|
+
tile.refine = getRefine(tile.refine);
|
|
127
|
+
tile.type = getTileType(tile);
|
|
128
|
+
tile.children = children;
|
|
129
|
+
tile.id = tile.contentUrl;
|
|
130
|
+
return tile;
|
|
131
|
+
}
|
|
132
|
+
exports.normalizeImplicitTileData = normalizeImplicitTileData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-3d-tile.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile.ts"],"names":[],"mappings":"AAaA,wBAAsB,WAAW,CAAC,WAAW,KAAA,EAAE,UAAU,oBAAI,EAAE,OAAO,KAAA,EAAE,OAAO,KAAA,EAAE,IAAI,KAAK,gBAmCzF"}
|
|
@@ -9,6 +9,7 @@ const parse_3d_tile_point_cloud_1 = require("./parse-3d-tile-point-cloud");
|
|
|
9
9
|
const parse_3d_tile_batched_model_1 = require("./parse-3d-tile-batched-model");
|
|
10
10
|
const parse_3d_tile_instanced_model_1 = require("./parse-3d-tile-instanced-model");
|
|
11
11
|
const parse_3d_tile_composite_1 = require("./parse-3d-tile-composite");
|
|
12
|
+
const parse_3d_tile_gltf_1 = require("./parse-3d-tile-gltf");
|
|
12
13
|
// Extracts
|
|
13
14
|
async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = {}) {
|
|
14
15
|
// @ts-expect-error
|
|
@@ -22,6 +23,8 @@ async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile =
|
|
|
22
23
|
return await (0, parse_3d_tile_composite_1.parseComposite3DTile)(tile, arrayBuffer, byteOffset, options, context, parse3DTile);
|
|
23
24
|
case constants_1.TILE3D_TYPE.BATCHED_3D_MODEL:
|
|
24
25
|
return await (0, parse_3d_tile_batched_model_1.parseBatchedModel3DTile)(tile, arrayBuffer, byteOffset, options, context);
|
|
26
|
+
case constants_1.TILE3D_TYPE.GLTF:
|
|
27
|
+
return await (0, parse_3d_tile_gltf_1.parseGltf3DTile)(tile, arrayBuffer, options, context);
|
|
25
28
|
case constants_1.TILE3D_TYPE.INSTANCED_3D_MODEL:
|
|
26
29
|
return await (0, parse_3d_tile_instanced_model_1.parseInstancedModel3DTile)(tile, arrayBuffer, byteOffset, options, context);
|
|
27
30
|
case constants_1.TILE3D_TYPE.POINT_CLOUD:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tiles-3d-loader.d.ts","sourceRoot":"","sources":["../src/tiles-3d-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"tiles-3d-loader.d.ts","sourceRoot":"","sources":["../src/tiles-3d-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAY/D;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,gBAiB3B,CAAC"}
|
package/dist/tiles-3d-loader.js
CHANGED
|
@@ -6,6 +6,7 @@ const tiles_1 = require("@loaders.gl/tiles");
|
|
|
6
6
|
const version_1 = require("./lib/utils/version");
|
|
7
7
|
const parse_3d_tile_1 = require("./lib/parsers/parse-3d-tile");
|
|
8
8
|
const parse_3d_tile_header_1 = require("./lib/parsers/parse-3d-tile-header");
|
|
9
|
+
const IMPLICIT_TILING_EXTENSION_NAME = '3DTILES_implicit_tiling';
|
|
9
10
|
/**
|
|
10
11
|
* Loader for 3D Tiles
|
|
11
12
|
*/
|
|
@@ -47,7 +48,9 @@ async function parseTileset(data, options, context) {
|
|
|
47
48
|
tilesetJson.url = context.url;
|
|
48
49
|
// base path that non-absolute paths in tileset are relative to.
|
|
49
50
|
tilesetJson.basePath = getBaseUri(tilesetJson);
|
|
50
|
-
tilesetJson.root = (
|
|
51
|
+
tilesetJson.root = hasImplicitTilingExtension(tilesetJson)
|
|
52
|
+
? await (0, parse_3d_tile_header_1.normalizeImplicitTileHeaders)(tilesetJson)
|
|
53
|
+
: (0, parse_3d_tile_header_1.normalizeTileHeaders)(tilesetJson);
|
|
51
54
|
tilesetJson.type = tiles_1.TILESET_TYPE.TILES3D;
|
|
52
55
|
tilesetJson.lodMetricType = tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR;
|
|
53
56
|
tilesetJson.lodMetricValue = tilesetJson.root?.lodMetricValue || 0;
|
|
@@ -71,3 +74,7 @@ async function parse(data, options, context) {
|
|
|
71
74
|
}
|
|
72
75
|
return data;
|
|
73
76
|
}
|
|
77
|
+
function hasImplicitTilingExtension(tilesetJson) {
|
|
78
|
+
return (tilesetJson?.extensionsRequired?.includes(IMPLICIT_TILING_EXTENSION_NAME) &&
|
|
79
|
+
tilesetJson?.extensionsUsed?.includes(IMPLICIT_TILING_EXTENSION_NAME));
|
|
80
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -48,19 +48,23 @@ declare type BoundingVolume = {
|
|
|
48
48
|
* 3DTILES_implicit_tiling types
|
|
49
49
|
* Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subtree-file-format
|
|
50
50
|
*/
|
|
51
|
-
export declare type
|
|
51
|
+
export declare type Subtree = {
|
|
52
52
|
buffers: Buffer[];
|
|
53
53
|
bufferViews: BufferView[];
|
|
54
54
|
tileAvailability: Availability;
|
|
55
55
|
contentAvailability: Availability;
|
|
56
56
|
childSubtreeAvailability: Availability;
|
|
57
57
|
};
|
|
58
|
-
declare type Availability = {
|
|
58
|
+
export declare type Availability = {
|
|
59
59
|
constant?: 0 | 1;
|
|
60
60
|
bufferView?: number;
|
|
61
61
|
explicitBitstream?: ExplicitBitstream;
|
|
62
62
|
};
|
|
63
63
|
export declare type ExplicitBitstream = Uint8Array;
|
|
64
|
+
/**
|
|
65
|
+
* Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling#subdivision-scheme
|
|
66
|
+
*/
|
|
67
|
+
export declare type SubdivisionScheme = 'QUADTREE' | 'OCTREE';
|
|
64
68
|
declare type Buffer = {
|
|
65
69
|
name: string;
|
|
66
70
|
uri?: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,oBAAY,cAAc,GAAG;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,CAAC;CACtB,CAAC;AAEF,oBAAY,WAAW,GAAG;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC7B,kBAAkB,CAAC,EAAE,UAAU,CAAC;IAChC,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAClC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B,EAAE,MAAM,CAAC;IACnC,wBAAwB,EAAE,MAAM,CAAC;IACjC,4BAA4B,EAAE,MAAM,CAAC;IACrC,0BAA0B,EAAE,MAAM,CAAC;CACpC,CAAC;AAEF,oBAAY,MAAM,GAAG;IACnB,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,GAAG,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,cAAc,EAAE,cAAc,CAAC;KAChC,CAAC;CACH,CAAC;AAEF,aAAK,cAAc,GAAG;IACpB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,oBAAY,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,eAAe,CAAC;AAE/C,oBAAY,cAAc,GAAG;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,CAAC;CACtB,CAAC;AAEF,oBAAY,WAAW,GAAG;IACxB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,uBAAuB,EAAE,OAAO,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC7B,kBAAkB,CAAC,EAAE,UAAU,CAAC;IAChC,gBAAgB,CAAC,EAAE,cAAc,CAAC;IAClC,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B,EAAE,MAAM,CAAC;IACnC,wBAAwB,EAAE,MAAM,CAAC;IACjC,4BAA4B,EAAE,MAAM,CAAC;IACrC,0BAA0B,EAAE,MAAM,CAAC;CACpC,CAAC;AAEF,oBAAY,MAAM,GAAG;IACnB,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,GAAG,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE;QACR,GAAG,EAAE,MAAM,CAAC;QACZ,cAAc,EAAE,cAAc,CAAC;KAChC,CAAC;CACH,CAAC;AAEF,aAAK,cAAc,GAAG;IACpB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,oBAAY,OAAO,GAAG;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,gBAAgB,EAAE,YAAY,CAAC;IAC/B,mBAAmB,EAAE,YAAY,CAAC;IAClC,wBAAwB,EAAE,YAAY,CAAC;CACxC,CAAC;AAEF,oBAAY,YAAY,GAAG;IACzB,QAAQ,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC,CAAC;AAEF,oBAAY,iBAAiB,GAAG,UAAU,CAAC;AAE3C;;GAEG;AACH,oBAAY,iBAAiB,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEtD,aAAK,MAAM,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,aAAK,UAAU,GAAG;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/3d-tiles",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "3D Tiles, an open standard for streaming massive heterogeneous 3D geospatial datasets.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,19 +31,19 @@
|
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
33
|
"pre-build": "npm run build-bundle",
|
|
34
|
-
"build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/
|
|
34
|
+
"build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@loaders.gl/draco": "3.1.
|
|
38
|
-
"@loaders.gl/gltf": "3.1.
|
|
39
|
-
"@loaders.gl/loader-utils": "3.1.
|
|
40
|
-
"@loaders.gl/math": "3.1.
|
|
41
|
-
"@loaders.gl/tiles": "3.1.
|
|
37
|
+
"@loaders.gl/draco": "3.1.3",
|
|
38
|
+
"@loaders.gl/gltf": "3.1.3",
|
|
39
|
+
"@loaders.gl/loader-utils": "3.1.3",
|
|
40
|
+
"@loaders.gl/math": "3.1.3",
|
|
41
|
+
"@loaders.gl/tiles": "3.1.3",
|
|
42
42
|
"@math.gl/core": "^3.5.1",
|
|
43
43
|
"@math.gl/geospatial": "^3.5.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
|
-
"@loaders.gl/core": "3.1.0
|
|
46
|
+
"@loaders.gl/core": "3.1.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "4a690c369779346d73c9a27395d1c08d77d279a4"
|
|
49
49
|
}
|
package/src/lib/constants.ts
CHANGED
|
File without changes
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import type {Availability, Subtree} from '../../../types';
|
|
2
|
+
import {Tile3DSubtreeLoader} from '../../../tile-3d-subtree-loader';
|
|
3
|
+
import {load} from '@loaders.gl/core';
|
|
4
|
+
|
|
5
|
+
const QUADTREE_DEVISION_COUNT = 4;
|
|
6
|
+
const OCTREE_DEVISION_COUNT = 8;
|
|
7
|
+
|
|
8
|
+
const SUBDIVISION_COUNT_MAP = {
|
|
9
|
+
QUADTREE: QUADTREE_DEVISION_COUNT,
|
|
10
|
+
OCTREE: OCTREE_DEVISION_COUNT
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Recursively parse implicit tiles tree
|
|
15
|
+
* Spec - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling
|
|
16
|
+
* TODO Check out do we able to use Tile3D class as return type here.
|
|
17
|
+
* @param subtree
|
|
18
|
+
* @param lodMetricValue
|
|
19
|
+
* @param options
|
|
20
|
+
* @param parentData
|
|
21
|
+
* @param childIndex
|
|
22
|
+
* @param level
|
|
23
|
+
* @param globalData
|
|
24
|
+
*/
|
|
25
|
+
// eslint-disable-next-line max-params
|
|
26
|
+
// eslint-disable-next-line max-statements
|
|
27
|
+
export async function parseImplicitTiles(
|
|
28
|
+
subtree: Subtree,
|
|
29
|
+
options: any,
|
|
30
|
+
parentData: {mortonIndex: number; x: number; y: number; z: number} = {
|
|
31
|
+
mortonIndex: 0,
|
|
32
|
+
x: 0,
|
|
33
|
+
y: 0,
|
|
34
|
+
z: 0
|
|
35
|
+
},
|
|
36
|
+
childIndex: number = 0,
|
|
37
|
+
level: number = 0,
|
|
38
|
+
globalData: {level: number; mortonIndex: number; x: number; y: number; z: number} = {
|
|
39
|
+
level: 0,
|
|
40
|
+
mortonIndex: 0,
|
|
41
|
+
x: 0,
|
|
42
|
+
y: 0,
|
|
43
|
+
z: 0
|
|
44
|
+
}
|
|
45
|
+
) {
|
|
46
|
+
const {
|
|
47
|
+
subdivisionScheme,
|
|
48
|
+
subtreeLevels,
|
|
49
|
+
maximumLevel,
|
|
50
|
+
contentUrlTemplate,
|
|
51
|
+
subtreesUriTemplate,
|
|
52
|
+
basePath
|
|
53
|
+
} = options;
|
|
54
|
+
|
|
55
|
+
const tile = {children: [], lodMetricValue: 0, contentUrl: ''};
|
|
56
|
+
|
|
57
|
+
const childrenPerTile = SUBDIVISION_COUNT_MAP[subdivisionScheme];
|
|
58
|
+
|
|
59
|
+
const childX = childIndex & 0b01;
|
|
60
|
+
const childY = (childIndex >> 1) & 0b01;
|
|
61
|
+
const childZ = (childIndex >> 2) & 0b01;
|
|
62
|
+
|
|
63
|
+
const levelOffset = (childrenPerTile ** level - 1) / (childrenPerTile - 1);
|
|
64
|
+
let childTileMortonIndex = concatBits(parentData.mortonIndex, childIndex);
|
|
65
|
+
let tileAvailabilityIndex = levelOffset + childTileMortonIndex;
|
|
66
|
+
|
|
67
|
+
// Local tile coordinates
|
|
68
|
+
let childTileX = concatBits(parentData.x, childX);
|
|
69
|
+
let childTileY = concatBits(parentData.y, childY);
|
|
70
|
+
let childTileZ = concatBits(parentData.z, childZ);
|
|
71
|
+
|
|
72
|
+
// TODO Remove after real implicit tileset will be tested.
|
|
73
|
+
// Degug data
|
|
74
|
+
// tile.level = level + globalData.level;
|
|
75
|
+
// tile.x = concatBits(globalData.x, childTileX);
|
|
76
|
+
// tile.y = concatBits(globalData.y, childTileY);
|
|
77
|
+
// tile.z = concatBits(globalData.z, childTileZ);
|
|
78
|
+
// tile.mortonIndex = childTileMortonIndex;
|
|
79
|
+
// End of debug data
|
|
80
|
+
|
|
81
|
+
let isChildSubtreeAvailable = false;
|
|
82
|
+
|
|
83
|
+
if (level + 1 > subtreeLevels) {
|
|
84
|
+
isChildSubtreeAvailable = getAvailabilityResult(
|
|
85
|
+
subtree.childSubtreeAvailability,
|
|
86
|
+
childTileMortonIndex
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const x = concatBits(globalData.x, childTileX);
|
|
91
|
+
const y = concatBits(globalData.y, childTileY);
|
|
92
|
+
const z = concatBits(globalData.z, childTileZ);
|
|
93
|
+
const lev = level + globalData.level;
|
|
94
|
+
|
|
95
|
+
if (isChildSubtreeAvailable) {
|
|
96
|
+
const subtreePath = `${basePath}/${subtreesUriTemplate}`;
|
|
97
|
+
const childSubtreeUrl = replaceContentUrlTemplate(subtreePath, lev, x, y, z);
|
|
98
|
+
const childSubtree = await load(childSubtreeUrl, Tile3DSubtreeLoader);
|
|
99
|
+
|
|
100
|
+
subtree = childSubtree;
|
|
101
|
+
|
|
102
|
+
globalData.mortonIndex = childTileMortonIndex;
|
|
103
|
+
globalData.x = childTileX;
|
|
104
|
+
globalData.y = childTileY;
|
|
105
|
+
globalData.z = childTileZ;
|
|
106
|
+
globalData.level = level;
|
|
107
|
+
|
|
108
|
+
childTileMortonIndex = 0;
|
|
109
|
+
tileAvailabilityIndex = 0;
|
|
110
|
+
childTileX = 0;
|
|
111
|
+
childTileY = 0;
|
|
112
|
+
childTileZ = 0;
|
|
113
|
+
level = 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const isTileAvailable = getAvailabilityResult(subtree.tileAvailability, tileAvailabilityIndex);
|
|
117
|
+
|
|
118
|
+
if (!isTileAvailable || level > maximumLevel) {
|
|
119
|
+
return tile;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const isContentAvailable = getAvailabilityResult(
|
|
123
|
+
subtree.contentAvailability,
|
|
124
|
+
tileAvailabilityIndex
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
if (isContentAvailable) {
|
|
128
|
+
tile.contentUrl = replaceContentUrlTemplate(contentUrlTemplate, lev, x, y, z);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const childTileLevel = level + 1;
|
|
132
|
+
const pData = {mortonIndex: childTileMortonIndex, x: childTileX, y: childTileY, z: childTileZ};
|
|
133
|
+
|
|
134
|
+
for (let index = 0; index < childrenPerTile; index++) {
|
|
135
|
+
const currentTile = await parseImplicitTiles(
|
|
136
|
+
subtree,
|
|
137
|
+
options,
|
|
138
|
+
pData,
|
|
139
|
+
index,
|
|
140
|
+
childTileLevel,
|
|
141
|
+
globalData
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
if (currentTile.contentUrl || currentTile.children.length) {
|
|
145
|
+
const globalLevel = lev + 1;
|
|
146
|
+
const formattedTile = formatTileData(currentTile, globalLevel, options);
|
|
147
|
+
// @ts-ignore
|
|
148
|
+
tile.children.push(formattedTile);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return tile;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function getAvailabilityResult(availabilityData: Availability, index: number): boolean {
|
|
156
|
+
if ('constant' in availabilityData) {
|
|
157
|
+
return Boolean(availabilityData.constant);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (availabilityData.explicitBitstream) {
|
|
161
|
+
return getBooleanValueFromBitstream(index, availabilityData.explicitBitstream);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Do formatting of implicit tile data.
|
|
169
|
+
* TODO Check out do we able to use Tile3D class as type here.
|
|
170
|
+
* @param tile
|
|
171
|
+
* @param lodMetricValue
|
|
172
|
+
* @param options
|
|
173
|
+
* @returns
|
|
174
|
+
*/
|
|
175
|
+
function formatTileData(tile, level: number, options: any) {
|
|
176
|
+
const {basePath, refine, getRefine, lodMetricType, getTileType, rootLodMetricValue} = options;
|
|
177
|
+
const uri = tile.contentUrl && tile.contentUrl.replace(`${basePath}/`, '');
|
|
178
|
+
const lodMetricValue = rootLodMetricValue / 2 ** level;
|
|
179
|
+
// TODO handle bounding volume
|
|
180
|
+
return {
|
|
181
|
+
children: tile.children,
|
|
182
|
+
contentUrl: tile.contentUrl,
|
|
183
|
+
content: {uri},
|
|
184
|
+
id: tile.contentUrl,
|
|
185
|
+
refine: getRefine(refine),
|
|
186
|
+
type: getTileType(tile),
|
|
187
|
+
lodMetricType,
|
|
188
|
+
lodMetricValue
|
|
189
|
+
// Temp debug values. Remove when real implicit tileset will be tested.
|
|
190
|
+
// x: tile.x,
|
|
191
|
+
// y: tile.y,
|
|
192
|
+
// z: tile.z,
|
|
193
|
+
// level: tile.level
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Do binary concatenation
|
|
199
|
+
* @param first
|
|
200
|
+
* @param second
|
|
201
|
+
*/
|
|
202
|
+
function concatBits(first: number, second: number): number {
|
|
203
|
+
return parseInt(first.toString(2) + second.toString(2), 2);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Replace implicit tile content url with real coordinates.
|
|
208
|
+
* @param templateUrl
|
|
209
|
+
* @param level
|
|
210
|
+
* @param x
|
|
211
|
+
* @param y
|
|
212
|
+
* @param z
|
|
213
|
+
*/
|
|
214
|
+
export function replaceContentUrlTemplate(
|
|
215
|
+
templateUrl: string,
|
|
216
|
+
level: number,
|
|
217
|
+
x: number,
|
|
218
|
+
y: number,
|
|
219
|
+
z: number
|
|
220
|
+
): string {
|
|
221
|
+
const mapUrl = generateMapUrl({level, x, y, z});
|
|
222
|
+
return templateUrl.replace(/{level}|{x}|{y}|{z}/gi, (matched) => mapUrl[matched]);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Get Map object for content url generation
|
|
227
|
+
* @param items
|
|
228
|
+
*/
|
|
229
|
+
function generateMapUrl(items: {[key: string]: number}): {[key: string]: string} {
|
|
230
|
+
const mapUrl = {};
|
|
231
|
+
|
|
232
|
+
for (const key in items) {
|
|
233
|
+
mapUrl[`{${key}}`] = items[key];
|
|
234
|
+
}
|
|
235
|
+
return mapUrl;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Get boolean value from bistream by index
|
|
240
|
+
* A boolean value is encoded as a single bit, either 0 (false) or 1 (true).
|
|
241
|
+
* Multiple boolean values are packed tightly in the same buffer.
|
|
242
|
+
* These buffers of tightly-packed bits are sometimes referred to as bitstreams.
|
|
243
|
+
* Spec - https://github.com/CesiumGS/3d-tiles/tree/implicit-revisions/specification/Metadata#booleans
|
|
244
|
+
* @param availabilitiIndex
|
|
245
|
+
*/
|
|
246
|
+
function getBooleanValueFromBitstream(
|
|
247
|
+
availabilityIndex: number,
|
|
248
|
+
availabilityBuffer: Uint8Array
|
|
249
|
+
): boolean {
|
|
250
|
+
const byteIndex = Math.floor(availabilityIndex / 8);
|
|
251
|
+
const bitIndex = availabilityIndex % 8;
|
|
252
|
+
const bitValue = (availabilityBuffer[byteIndex] >> bitIndex) & 1;
|
|
253
|
+
|
|
254
|
+
return bitValue === 1;
|
|
255
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {Subtree, ExplicitBitstream} from '../../../types';
|
|
2
2
|
import {fetchFile} from '@loaders.gl/core';
|
|
3
3
|
|
|
4
4
|
const SUBTREE_FILE_MAGIC = 0x74627573;
|
|
@@ -10,7 +10,8 @@ const SUBTREE_FILE_VERSION = 1;
|
|
|
10
10
|
* @param data
|
|
11
11
|
* @returns
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
// eslint-disable-next-line max-statements
|
|
14
|
+
export default async function parse3DTilesSubtree(data: ArrayBuffer): Promise<Subtree> {
|
|
14
15
|
const magic = new Uint32Array(data.slice(0, 4));
|
|
15
16
|
|
|
16
17
|
if (magic[0] !== SUBTREE_FILE_MAGIC) {
|
|
@@ -71,7 +72,7 @@ export default async function parse3DTilesSubtree(data: ArrayBuffer): Promise<Su
|
|
|
71
72
|
* @param internalBinaryBuffer
|
|
72
73
|
*/
|
|
73
74
|
async function getExplicitBitstream(
|
|
74
|
-
subtree:
|
|
75
|
+
subtree: Subtree,
|
|
75
76
|
name: string,
|
|
76
77
|
internalBinaryBuffer: ArrayBuffer
|
|
77
78
|
): Promise<ExplicitBitstream> {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {GLTFLoader} from '@loaders.gl/gltf';
|
|
2
|
+
|
|
3
|
+
export async function parseGltf3DTile(tile, arrayBuffer, options, context) {
|
|
4
|
+
// Set flags
|
|
5
|
+
// glTF models need to be rotated from Y to Z up
|
|
6
|
+
// https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up
|
|
7
|
+
tile.rotateYtoZ = true;
|
|
8
|
+
// Save gltf up axis
|
|
9
|
+
tile.gltfUpAxis =
|
|
10
|
+
options['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis
|
|
11
|
+
? options['3d-tiles'].assetGltfUpAxis
|
|
12
|
+
: 'Y';
|
|
13
|
+
|
|
14
|
+
const {parse} = context;
|
|
15
|
+
tile.gltf = await parse(arrayBuffer, GLTFLoader, options, context);
|
|
16
|
+
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {Tile3DSubtreeLoader} from '../../tile-3d-subtree-loader';
|
|
2
|
+
import {load} from '@loaders.gl/core';
|
|
3
|
+
import {Tileset3D, LOD_METRIC_TYPE, TILE_REFINEMENT, TILE_TYPE} from '@loaders.gl/tiles';
|
|
4
|
+
import {Subtree} from '../../types';
|
|
5
|
+
import {parseImplicitTiles, replaceContentUrlTemplate} from './helpers/parse-3d-implicit-tiles';
|
|
2
6
|
|
|
3
7
|
function getTileType(tile) {
|
|
4
8
|
if (!tile.contentUrl) {
|
|
@@ -12,6 +16,8 @@ function getTileType(tile) {
|
|
|
12
16
|
return TILE_TYPE.POINTCLOUD;
|
|
13
17
|
case 'i3dm':
|
|
14
18
|
case 'b3dm':
|
|
19
|
+
case 'glb':
|
|
20
|
+
case 'gltf':
|
|
15
21
|
return TILE_TYPE.SCENEGRAPH;
|
|
16
22
|
default:
|
|
17
23
|
return fileExtension;
|
|
@@ -45,6 +51,7 @@ export function normalizeTileData(tile, options) {
|
|
|
45
51
|
tile.transformMatrix = tile.transform;
|
|
46
52
|
tile.type = getTileType(tile);
|
|
47
53
|
tile.refine = getRefine(tile.refine);
|
|
54
|
+
|
|
48
55
|
return tile;
|
|
49
56
|
}
|
|
50
57
|
|
|
@@ -67,3 +74,77 @@ export function normalizeTileHeaders(tileset) {
|
|
|
67
74
|
|
|
68
75
|
return root;
|
|
69
76
|
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Do normalisation of implicit tile headers
|
|
80
|
+
* TODO Check if Tile3D class can be a return type here.
|
|
81
|
+
* @param tileset
|
|
82
|
+
*/
|
|
83
|
+
export async function normalizeImplicitTileHeaders(tileset: Tileset3D) {
|
|
84
|
+
if (!tileset.root) {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const basePath = tileset.basePath;
|
|
89
|
+
const implicitTilingExtension = tileset.root.extensions['3DTILES_implicit_tiling'];
|
|
90
|
+
const {
|
|
91
|
+
subdivisionScheme,
|
|
92
|
+
maximumLevel,
|
|
93
|
+
subtreeLevels,
|
|
94
|
+
subtrees: {uri: subtreesUriTemplate}
|
|
95
|
+
} = implicitTilingExtension;
|
|
96
|
+
const subtreeUrl = replaceContentUrlTemplate(subtreesUriTemplate, 0, 0, 0, 0);
|
|
97
|
+
const rootSubtreeUrl = `${basePath}/${subtreeUrl}`;
|
|
98
|
+
const rootSubtree = await load(rootSubtreeUrl, Tile3DSubtreeLoader);
|
|
99
|
+
const contentUrlTemplate = `${basePath}/${tileset.root.content.uri}`;
|
|
100
|
+
const refine = tileset.root.refine;
|
|
101
|
+
// @ts-ignore
|
|
102
|
+
const rootLodMetricValue = tileset.root.geometricError;
|
|
103
|
+
|
|
104
|
+
const options = {
|
|
105
|
+
contentUrlTemplate,
|
|
106
|
+
subtreesUriTemplate,
|
|
107
|
+
subdivisionScheme,
|
|
108
|
+
subtreeLevels,
|
|
109
|
+
maximumLevel,
|
|
110
|
+
refine,
|
|
111
|
+
basePath,
|
|
112
|
+
lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
|
|
113
|
+
rootLodMetricValue,
|
|
114
|
+
getTileType,
|
|
115
|
+
getRefine
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
return await normalizeImplicitTileData(tileset.root, rootSubtree, options);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Do implicit data normalisation to create hierarchical tile structure
|
|
123
|
+
* @param tile
|
|
124
|
+
* @param rootSubtree
|
|
125
|
+
* @param options
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
export async function normalizeImplicitTileData(tile, rootSubtree: Subtree, options: any) {
|
|
129
|
+
if (!tile) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
tile.lodMetricType = LOD_METRIC_TYPE.GEOMETRIC_ERROR;
|
|
134
|
+
tile.lodMetricValue = tile.geometricError;
|
|
135
|
+
tile.transformMatrix = tile.transform;
|
|
136
|
+
|
|
137
|
+
const {children, contentUrl} = await parseImplicitTiles(rootSubtree, options);
|
|
138
|
+
|
|
139
|
+
if (contentUrl) {
|
|
140
|
+
tile.contentUrl = contentUrl;
|
|
141
|
+
tile.content = {uri: contentUrl.replace(`${options.basePath}/`, '')};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
tile.refine = getRefine(tile.refine);
|
|
145
|
+
tile.type = getTileType(tile);
|
|
146
|
+
tile.children = children;
|
|
147
|
+
tile.id = tile.contentUrl;
|
|
148
|
+
|
|
149
|
+
return tile;
|
|
150
|
+
}
|
|
@@ -8,6 +8,7 @@ import {parsePointCloud3DTile} from './parse-3d-tile-point-cloud';
|
|
|
8
8
|
import {parseBatchedModel3DTile} from './parse-3d-tile-batched-model';
|
|
9
9
|
import {parseInstancedModel3DTile} from './parse-3d-tile-instanced-model';
|
|
10
10
|
import {parseComposite3DTile} from './parse-3d-tile-composite';
|
|
11
|
+
import {parseGltf3DTile} from './parse-3d-tile-gltf';
|
|
11
12
|
|
|
12
13
|
// Extracts
|
|
13
14
|
export async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = {}) {
|
|
@@ -32,6 +33,9 @@ export async function parse3DTile(arrayBuffer, byteOffset = 0, options, context,
|
|
|
32
33
|
case TILE3D_TYPE.BATCHED_3D_MODEL:
|
|
33
34
|
return await parseBatchedModel3DTile(tile, arrayBuffer, byteOffset, options, context);
|
|
34
35
|
|
|
36
|
+
case TILE3D_TYPE.GLTF:
|
|
37
|
+
return await parseGltf3DTile(tile, arrayBuffer, options, context);
|
|
38
|
+
|
|
35
39
|
case TILE3D_TYPE.INSTANCED_3D_MODEL:
|
|
36
40
|
return await parseInstancedModel3DTile(tile, arrayBuffer, byteOffset, options, context);
|
|
37
41
|
|