@loaders.gl/3d-tiles 4.2.0-alpha.3 → 4.2.0-alpha.5
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.js +66 -41
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts +1 -1
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.d.ts.map +1 -1
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.js +26 -16
- package/dist/3d-tiles-archive-loader.js +26 -15
- package/dist/cesium-ion-loader.js +34 -30
- package/dist/dist.dev.js +1963 -1037
- package/dist/dist.min.js +32 -0
- package/dist/index.cjs +122 -337
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +13 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/lib/classes/helpers/tile-3d-accessor-utils.js +103 -87
- package/dist/lib/classes/tile-3d-batch-table-hierarchy.js +179 -155
- package/dist/lib/classes/tile-3d-batch-table.js +232 -217
- package/dist/lib/classes/tile-3d-feature-table.js +62 -59
- package/dist/lib/constants.js +19 -15
- package/dist/lib/encoders/encode-3d-tile-batched-model.js +40 -35
- package/dist/lib/encoders/encode-3d-tile-composite.js +19 -17
- package/dist/lib/encoders/encode-3d-tile-instanced-model.js +32 -31
- package/dist/lib/encoders/encode-3d-tile-point-cloud.js +31 -32
- package/dist/lib/encoders/encode-3d-tile.js +23 -19
- package/dist/lib/encoders/helpers/encode-3d-tile-header.js +23 -23
- package/dist/lib/ion/ion.js +55 -54
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts +1 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +57 -51
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts +1 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +21 -18
- package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js +35 -20
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts +4 -4
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js +269 -234
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts +2 -2
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js +83 -55
- package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-header.js +23 -14
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js +82 -54
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts +2 -2
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.js +79 -68
- package/dist/lib/parsers/helpers/parse-utils.js +19 -14
- package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts +2 -2
- package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-batched-model.js +21 -17
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts +2 -2
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-composite.js +18 -14
- 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-gltf.js +22 -14
- package/dist/lib/parsers/parse-3d-tile-header.d.ts +2 -2
- package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-header.js +168 -159
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts +2 -2
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-instanced-model.js +153 -123
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +2 -2
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-point-cloud.js +380 -174
- package/dist/lib/parsers/parse-3d-tile.d.ts +2 -2
- package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile.js +24 -24
- package/dist/lib/utils/obb/s2-corners-to-obb.js +29 -16
- package/dist/lib/utils/s2/converters/s2-to-boundary.d.ts +1 -1
- package/dist/lib/utils/s2/converters/s2-to-boundary.d.ts.map +1 -1
- package/dist/lib/utils/s2/converters/s2-to-boundary.js +55 -35
- package/dist/lib/utils/s2/converters/s2-to-obb-points.js +31 -20
- package/dist/lib/utils/s2/converters/s2-to-region.d.ts +1 -1
- package/dist/lib/utils/s2/converters/s2-to-region.d.ts.map +1 -1
- package/dist/lib/utils/s2/converters/s2-to-region.js +51 -35
- package/dist/lib/utils/s2/index.d.ts +7 -7
- package/dist/lib/utils/s2/index.d.ts.map +1 -1
- package/dist/lib/utils/s2/index.js +3 -1
- package/dist/lib/utils/s2/s2-geometry-functions.js +19 -5
- package/dist/lib/utils/s2/s2-token-functions.js +51 -22
- package/dist/lib/utils/s2/s2geometry/s2-cell-utils.d.ts +1 -1
- package/dist/lib/utils/s2/s2geometry/s2-cell-utils.d.ts.map +1 -1
- package/dist/lib/utils/s2/s2geometry/s2-cell-utils.js +23 -9
- package/dist/lib/utils/s2/s2geometry/s2-geometry.js +218 -157
- package/dist/lib/utils/version.js +4 -2
- package/dist/tile-3d-subtree-loader.d.ts +1 -1
- package/dist/tile-3d-subtree-loader.d.ts.map +1 -1
- package/dist/tile-3d-subtree-loader.js +15 -10
- package/dist/tile-3d-writer.js +19 -14
- package/dist/tiles-3d-loader.js +65 -55
- package/dist/types.js +3 -1
- package/package.json +11 -10
- package/dist/3d-tiles-archive/3d-tiles-archive-archive.js.map +0 -1
- package/dist/3d-tiles-archive/3d-tiles-archive-parser.js.map +0 -1
- package/dist/3d-tiles-archive-loader.js.map +0 -1
- package/dist/cesium-ion-loader.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/classes/helpers/tile-3d-accessor-utils.js.map +0 -1
- package/dist/lib/classes/tile-3d-batch-table-hierarchy.js.map +0 -1
- package/dist/lib/classes/tile-3d-batch-table.js.map +0 -1
- package/dist/lib/classes/tile-3d-feature-table.js.map +0 -1
- package/dist/lib/constants.js.map +0 -1
- package/dist/lib/encoders/encode-3d-tile-batched-model.js.map +0 -1
- package/dist/lib/encoders/encode-3d-tile-composite.js.map +0 -1
- package/dist/lib/encoders/encode-3d-tile-instanced-model.js.map +0 -1
- package/dist/lib/encoders/encode-3d-tile-point-cloud.js.map +0 -1
- package/dist/lib/encoders/encode-3d-tile.js.map +0 -1
- package/dist/lib/encoders/helpers/encode-3d-tile-header.js.map +0 -1
- package/dist/lib/ion/ion.js.map +0 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js.map +0 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js.map +0 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-positions.js.map +0 -1
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +0 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +0 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-header.js.map +0 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-subtree.js.map +0 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.js.map +0 -1
- package/dist/lib/parsers/helpers/parse-utils.js.map +0 -1
- package/dist/lib/parsers/parse-3d-tile-batched-model.js.map +0 -1
- package/dist/lib/parsers/parse-3d-tile-composite.js.map +0 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.js.map +0 -1
- package/dist/lib/parsers/parse-3d-tile-header.js.map +0 -1
- package/dist/lib/parsers/parse-3d-tile-instanced-model.js.map +0 -1
- package/dist/lib/parsers/parse-3d-tile-point-cloud.js.map +0 -1
- package/dist/lib/parsers/parse-3d-tile.js.map +0 -1
- package/dist/lib/utils/obb/s2-corners-to-obb.js.map +0 -1
- package/dist/lib/utils/s2/converters/s2-to-boundary.js.map +0 -1
- package/dist/lib/utils/s2/converters/s2-to-obb-points.js.map +0 -1
- package/dist/lib/utils/s2/converters/s2-to-region.js.map +0 -1
- package/dist/lib/utils/s2/index.js.map +0 -1
- package/dist/lib/utils/s2/s2-geometry-functions.js.map +0 -1
- package/dist/lib/utils/s2/s2-token-functions.js.map +0 -1
- package/dist/lib/utils/s2/s2geometry/s2-cell-utils.js.map +0 -1
- package/dist/lib/utils/s2/s2geometry/s2-geometry.js.map +0 -1
- package/dist/lib/utils/version.js.map +0 -1
- package/dist/tile-3d-subtree-loader.js.map +0 -1
- package/dist/tile-3d-writer.js.map +0 -1
- package/dist/tiles-3d-loader.js.map +0 -1
- package/dist/types.js.map +0 -1
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT AND Apache-2.0
|
|
3
|
+
// Copyright vis.gl contributors
|
|
4
|
+
// This file is derived from the Cesium code base under Apache 2 license
|
|
5
|
+
// See LICENSE.md and https://github.com/AnalyticalGraphicsInc/cesium/blob/master/LICENSE.md
|
|
6
|
+
import { GL } from '@loaders.gl/math'; // math.gl/geometry;
|
|
2
7
|
import Tile3DFeatureTable from "../classes/tile-3d-feature-table.js";
|
|
8
|
+
// import Tile3DBatchTable from '../classes/tile-3d-batch-table';
|
|
3
9
|
import { parse3DTileHeaderSync } from "./helpers/parse-3d-tile-header.js";
|
|
4
10
|
import { parse3DTileTablesHeaderSync, parse3DTileTablesSync } from "./helpers/parse-3d-tile-tables.js";
|
|
5
11
|
import { parse3DTileGLTFViewSync, extractGLTF, GLTF_FORMAT } from "./helpers/parse-3d-tile-gltf-view.js";
|
|
6
12
|
export async function parseBatchedModel3DTile(tile, arrayBuffer, byteOffset, options, context) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return byteOffset;
|
|
13
|
+
byteOffset = parseBatchedModel(tile, arrayBuffer, byteOffset, options, context);
|
|
14
|
+
await extractGLTF(tile, GLTF_FORMAT.EMBEDDED, options, context);
|
|
15
|
+
const extensions = tile?.gltf?.extensions;
|
|
16
|
+
if (extensions && extensions.CESIUM_RTC) {
|
|
17
|
+
tile.rtcCenter = extensions.CESIUM_RTC.center;
|
|
18
|
+
}
|
|
19
|
+
return byteOffset;
|
|
15
20
|
}
|
|
16
21
|
function parseBatchedModel(tile, arrayBuffer, byteOffset, options, context) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);
|
|
23
|
+
byteOffset = parse3DTileTablesHeaderSync(tile, arrayBuffer, byteOffset);
|
|
24
|
+
byteOffset = parse3DTileTablesSync(tile, arrayBuffer, byteOffset, options);
|
|
25
|
+
byteOffset = parse3DTileGLTFViewSync(tile, arrayBuffer, byteOffset, options);
|
|
26
|
+
const featureTable = new Tile3DFeatureTable(tile.featureTableJson, tile.featureTableBinary);
|
|
27
|
+
tile.rtcCenter = featureTable.getGlobalProperty('RTC_CENTER', GL.FLOAT, 3);
|
|
28
|
+
return byteOffset;
|
|
24
29
|
}
|
|
25
|
-
//# sourceMappingURL=parse-3d-tile-batched-model.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LoaderContext } from '@loaders.gl/loader-utils';
|
|
2
|
-
import type { Tiles3DLoaderOptions } from
|
|
3
|
-
import { Tiles3DTileContent } from
|
|
2
|
+
import type { Tiles3DLoaderOptions } from "../../tiles-3d-loader.js";
|
|
3
|
+
import { Tiles3DTileContent } from "../../types.js";
|
|
4
4
|
/** Resolve circulate dependency by passing in parsing function as argument */
|
|
5
5
|
type Parse3DTile = (arrayBuffer: ArrayBuffer, byteOffset: number, options: Tiles3DLoaderOptions | undefined, context: LoaderContext | undefined, subtile: any) => Promise<number>;
|
|
6
6
|
export declare function parseComposite3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, byteOffset: number, options: Tiles3DLoaderOptions | undefined, context: LoaderContext | undefined, parse3DTile: Parse3DTile): Promise<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile-composite.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-composite.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAC,oBAAoB,EAAC,
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-composite.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-composite.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAC,oBAAoB,EAAC,iCAA8B;AAEhE,OAAO,EAAC,kBAAkB,EAAC,uBAAoB;AAE/C,8EAA8E;AAC9E,KAAK,WAAW,GAAG,CACjB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAAG,SAAS,EACzC,OAAO,EAAE,aAAa,GAAG,SAAS,EAClC,OAAO,KAAA,KACJ,OAAO,CAAC,MAAM,CAAC,CAAC;AAGrB,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAAG,SAAS,EACzC,OAAO,EAAE,aAAa,GAAG,SAAS,EAClC,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,MAAM,CAAC,CAmBjB"}
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT AND Apache-2.0
|
|
3
|
+
// Copyright vis.gl contributors
|
|
1
4
|
import { parse3DTileHeaderSync } from "./helpers/parse-3d-tile-header.js";
|
|
5
|
+
// eslint-disable-next-line max-params
|
|
2
6
|
export async function parseComposite3DTile(tile, arrayBuffer, byteOffset, options, context, parse3DTile) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
byteOffset = parse3DTileHeaderSync(tile, arrayBuffer, byteOffset);
|
|
8
|
+
const view = new DataView(arrayBuffer);
|
|
9
|
+
// Extract number of tiles
|
|
10
|
+
tile.tilesLength = view.getUint32(byteOffset, true);
|
|
11
|
+
byteOffset += 4;
|
|
12
|
+
// extract each tile from the byte stream
|
|
13
|
+
tile.tiles = [];
|
|
14
|
+
while (tile.tiles.length < tile.tilesLength && (tile.byteLength || 0) - byteOffset > 12) {
|
|
15
|
+
const subtile = { shape: 'tile3d' };
|
|
16
|
+
tile.tiles.push(subtile);
|
|
17
|
+
byteOffset = await parse3DTile(arrayBuffer, byteOffset, options, context, subtile);
|
|
18
|
+
// TODO - do we need to add any padding in between tiles?
|
|
19
|
+
}
|
|
20
|
+
return byteOffset;
|
|
16
21
|
}
|
|
17
|
-
//# sourceMappingURL=parse-3d-tile-composite.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LoaderContext } from '@loaders.gl/loader-utils';
|
|
2
|
-
import type { Tiles3DLoaderOptions } from
|
|
3
|
-
import { Tiles3DTileContent } from
|
|
2
|
+
import type { Tiles3DLoaderOptions } from "../../tiles-3d-loader.js";
|
|
3
|
+
import { Tiles3DTileContent } from "../../types.js";
|
|
4
4
|
export declare function parseGltf3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<number>;
|
|
5
5
|
//# sourceMappingURL=parse-3d-tile-gltf.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile-gltf.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-gltf.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAEzE,OAAO,KAAK,EAAC,oBAAoB,EAAC,
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-gltf.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-gltf.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAEzE,OAAO,KAAK,EAAC,oBAAoB,EAAC,iCAA8B;AAChE,OAAO,EAAC,kBAAkB,EAAC,uBAAoB;AAE/C,wBAAsB,eAAe,CACnC,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,MAAM,CAAC,CAqBjB"}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT license
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { parseFromContext } from '@loaders.gl/loader-utils';
|
|
2
5
|
import { _getMemoryUsageGLTF, GLTFLoader, postProcessGLTF } from '@loaders.gl/gltf';
|
|
3
6
|
export async function parseGltf3DTile(tile, arrayBuffer, options, context) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
// Set flags
|
|
8
|
+
// glTF models need to be rotated from Y to Z up
|
|
9
|
+
// https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up
|
|
10
|
+
tile.rotateYtoZ = true;
|
|
11
|
+
// Save gltf up axis
|
|
12
|
+
tile.gltfUpAxis = options?.['3d-tiles']?.assetGltfUpAxis
|
|
13
|
+
? options['3d-tiles'].assetGltfUpAxis
|
|
14
|
+
: 'Y';
|
|
15
|
+
if (options?.['3d-tiles']?.loadGLTF) {
|
|
16
|
+
if (!context) {
|
|
17
|
+
return arrayBuffer.byteLength;
|
|
18
|
+
}
|
|
19
|
+
const gltfWithBuffers = await parseFromContext(arrayBuffer, GLTFLoader, options, context);
|
|
20
|
+
tile.gltf = postProcessGLTF(gltfWithBuffers);
|
|
21
|
+
tile.gpuMemoryUsageInBytes = _getMemoryUsageGLTF(tile.gltf);
|
|
10
22
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
tile.gltfArrayBuffer = arrayBuffer;
|
|
16
|
-
}
|
|
17
|
-
return arrayBuffer.byteLength;
|
|
23
|
+
else {
|
|
24
|
+
tile.gltfArrayBuffer = arrayBuffer;
|
|
25
|
+
}
|
|
26
|
+
return arrayBuffer.byteLength;
|
|
18
27
|
}
|
|
19
|
-
//# sourceMappingURL=parse-3d-tile-gltf.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Tiles3DLoaderOptions } from
|
|
1
|
+
import type { Tiles3DLoaderOptions } from "../../tiles-3d-loader.js";
|
|
2
2
|
import type { LoaderOptions } from '@loaders.gl/loader-utils';
|
|
3
3
|
import { LOD_METRIC_TYPE, TILE_REFINEMENT, TILE_TYPE } from '@loaders.gl/tiles';
|
|
4
|
-
import { ImplicitTilingExensionData, Subtree, Tile3DBoundingVolume, Tiles3DTileJSON, Tiles3DTileJSONPostprocessed, Tiles3DTilesetJSON } from
|
|
4
|
+
import { ImplicitTilingExensionData, Subtree, Tile3DBoundingVolume, Tiles3DTileJSON, Tiles3DTileJSONPostprocessed, Tiles3DTilesetJSON } from "../../types.js";
|
|
5
5
|
/** Options for recursive loading implicit subtrees */
|
|
6
6
|
export type ImplicitOptions = {
|
|
7
7
|
/** Template of the full url of the content template */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile-header.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-header.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,oBAAoB,EAAC,
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-header.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-header.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,oBAAoB,EAAC,iCAA8B;AAChE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAI5D,OAAO,EAAC,eAAe,EAAE,eAAe,EAAE,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EACL,0BAA0B,EAC1B,OAAO,EACP,oBAAoB,EAEpB,eAAe,EACf,4BAA4B,EAC5B,kBAAkB,EACnB,uBAAoB;AAMrB,sDAAsD;AACtD,MAAM,MAAM,eAAe,GAAG;IAC5B,uDAAuD;IACvD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,+CAA+C;IAC/C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kCAAkC;IAClC,iBAAiB,EAAE,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;IAClD,yBAAyB;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,aAAa,EAAE,eAAe,CAAC,eAAe,CAAC;IAC/C,kEAAkE;IAClE,kBAAkB,EAAE,MAAM,CAAC;IAC3B,gEAAgE;IAChE,kBAAkB,EAAE,oBAAoB,CAAC;IACzC,uEAAuE;IACvE,WAAW,EAAE,CAAC,IAAI,EAAE,eAAe,EAAE,cAAc,CAAC,EAAE,MAAM,KAAK,SAAS,GAAG,MAAM,CAAC;IACpF,gEAAgE;IAChE,SAAS,EAAE,CAAC,MAAM,CAAC,EAAE,MAAM,KAAK,eAAe,GAAG,MAAM,GAAG,SAAS,CAAC;CACtE,CAAC;AAiDF,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,eAAe,GAAG,IAAI,EAC5B,QAAQ,EAAE,MAAM,GACf,4BAA4B,GAAG,IAAI,CAwBrC;AAGD,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CA+C9C;AAED;;;;GAIG;AACH,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,kBAAkB,EAC3B,QAAQ,EAAE,MAAM,EAChB,uBAAuB,EAAE,0BAA0B,EACnD,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CA2C9C;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,eAAe,EACrB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,OAAO,EACpB,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,oBAAoB,GAClC,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CA+B9C"}
|
|
@@ -1,185 +1,194 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright vis.gl contributors
|
|
1
4
|
import { path } from '@loaders.gl/loader-utils';
|
|
2
5
|
import { Tile3DSubtreeLoader } from "../../tile-3d-subtree-loader.js";
|
|
3
6
|
import { load } from '@loaders.gl/core';
|
|
4
7
|
import { LOD_METRIC_TYPE, TILE_REFINEMENT, TILE_TYPE } from '@loaders.gl/tiles';
|
|
5
8
|
import { parseImplicitTiles, replaceContentUrlTemplate } from "./helpers/parse-3d-implicit-tiles.js";
|
|
6
9
|
import { convertS2BoundingVolumetoOBB } from "../utils/obb/s2-corners-to-obb.js";
|
|
7
|
-
function getTileType(tile) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
10
|
+
function getTileType(tile, tileContentUrl = '') {
|
|
11
|
+
if (!tileContentUrl) {
|
|
12
|
+
return TILE_TYPE.EMPTY;
|
|
13
|
+
}
|
|
14
|
+
const contentUrl = tileContentUrl.split('?')[0]; // Discard query string
|
|
15
|
+
const fileExtension = contentUrl.split('.').pop();
|
|
16
|
+
switch (fileExtension) {
|
|
17
|
+
case 'pnts':
|
|
18
|
+
return TILE_TYPE.POINTCLOUD;
|
|
19
|
+
case 'i3dm':
|
|
20
|
+
case 'b3dm':
|
|
21
|
+
case 'glb':
|
|
22
|
+
case 'gltf':
|
|
23
|
+
return TILE_TYPE.SCENEGRAPH;
|
|
24
|
+
default:
|
|
25
|
+
return fileExtension || TILE_TYPE.EMPTY;
|
|
26
|
+
}
|
|
25
27
|
}
|
|
26
28
|
function getRefine(refine) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
switch (refine) {
|
|
30
|
+
case 'REPLACE':
|
|
31
|
+
case 'replace':
|
|
32
|
+
return TILE_REFINEMENT.REPLACE;
|
|
33
|
+
case 'ADD':
|
|
34
|
+
case 'add':
|
|
35
|
+
return TILE_REFINEMENT.ADD;
|
|
36
|
+
default:
|
|
37
|
+
return refine;
|
|
38
|
+
}
|
|
37
39
|
}
|
|
38
40
|
function resolveUri(uri, basePath) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
// url scheme per RFC3986
|
|
42
|
+
const urlSchemeRegex = /^[a-z][0-9a-z+.-]*:/i;
|
|
43
|
+
if (urlSchemeRegex.test(basePath)) {
|
|
44
|
+
const url = new URL(uri, `${basePath}/`);
|
|
45
|
+
return decodeURI(url.toString());
|
|
46
|
+
}
|
|
47
|
+
else if (uri.startsWith('/')) {
|
|
48
|
+
return uri;
|
|
49
|
+
}
|
|
50
|
+
return path.resolve(basePath, uri);
|
|
47
51
|
}
|
|
48
52
|
export function normalizeTileData(tile, basePath) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
if (!tile) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
let tileContentUrl;
|
|
57
|
+
if (tile.content) {
|
|
58
|
+
const contentUri = tile.content.uri || tile.content?.url;
|
|
59
|
+
if (typeof contentUri !== 'undefined') {
|
|
60
|
+
// sparse implicit tilesets may not define content for all nodes
|
|
61
|
+
tileContentUrl = resolveUri(contentUri, basePath);
|
|
62
|
+
}
|
|
58
63
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return tilePostprocessed;
|
|
64
|
+
const tilePostprocessed = {
|
|
65
|
+
...tile,
|
|
66
|
+
id: tileContentUrl,
|
|
67
|
+
contentUrl: tileContentUrl,
|
|
68
|
+
lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
|
|
69
|
+
lodMetricValue: tile.geometricError,
|
|
70
|
+
transformMatrix: tile.transform,
|
|
71
|
+
type: getTileType(tile, tileContentUrl),
|
|
72
|
+
refine: getRefine(tile.refine)
|
|
73
|
+
};
|
|
74
|
+
return tilePostprocessed;
|
|
71
75
|
}
|
|
76
|
+
// normalize tile headers
|
|
72
77
|
export async function normalizeTileHeaders(tileset, basePath, options) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
78
|
+
let root = null;
|
|
79
|
+
const rootImplicitTilingExtension = getImplicitTilingExtensionData(tileset.root);
|
|
80
|
+
if (rootImplicitTilingExtension && tileset.root) {
|
|
81
|
+
root = await normalizeImplicitTileHeaders(tileset.root, tileset, basePath, rootImplicitTilingExtension, options);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
root = normalizeTileData(tileset.root, basePath);
|
|
85
|
+
}
|
|
86
|
+
const stack = [];
|
|
87
|
+
stack.push(root);
|
|
88
|
+
while (stack.length > 0) {
|
|
89
|
+
const tile = stack.pop() || {};
|
|
90
|
+
const children = tile.children || [];
|
|
91
|
+
const childrenPostprocessed = [];
|
|
92
|
+
for (const childHeader of children) {
|
|
93
|
+
const childImplicitTilingExtension = getImplicitTilingExtensionData(childHeader);
|
|
94
|
+
let childHeaderPostprocessed;
|
|
95
|
+
if (childImplicitTilingExtension) {
|
|
96
|
+
childHeaderPostprocessed = await normalizeImplicitTileHeaders(childHeader, tileset, basePath, childImplicitTilingExtension, options);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
childHeaderPostprocessed = normalizeTileData(childHeader, basePath);
|
|
100
|
+
}
|
|
101
|
+
if (childHeaderPostprocessed) {
|
|
102
|
+
childrenPostprocessed.push(childHeaderPostprocessed);
|
|
103
|
+
stack.push(childHeaderPostprocessed);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
tile.children = childrenPostprocessed;
|
|
98
107
|
}
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
return root;
|
|
108
|
+
return root;
|
|
102
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Do normalisation of implicit tile headers
|
|
112
|
+
* TODO Check if Tile3D class can be a return type here.
|
|
113
|
+
* @param tileset
|
|
114
|
+
*/
|
|
103
115
|
export async function normalizeImplicitTileHeaders(tile, tileset, basePath, implicitTilingExtension, options) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
116
|
+
const { subdivisionScheme, maximumLevel, availableLevels, subtreeLevels, subtrees: { uri: subtreesUriTemplate } } = implicitTilingExtension;
|
|
117
|
+
const replacedUrlTemplate = replaceContentUrlTemplate(subtreesUriTemplate, 0, 0, 0, 0);
|
|
118
|
+
const subtreeUrl = resolveUri(replacedUrlTemplate, basePath);
|
|
119
|
+
const subtree = await load(subtreeUrl, Tile3DSubtreeLoader, options);
|
|
120
|
+
const tileContentUri = tile.content?.uri;
|
|
121
|
+
const contentUrlTemplate = tileContentUri ? resolveUri(tileContentUri, basePath) : '';
|
|
122
|
+
const refine = tileset?.root?.refine;
|
|
123
|
+
// @ts-ignore
|
|
124
|
+
const rootLodMetricValue = tile.geometricError;
|
|
125
|
+
// Replace tile.boundingVolume with the the bounding volume specified by the extensions['3DTILES_bounding_volume_S2']
|
|
126
|
+
const s2VolumeInfo = tile.boundingVolume.extensions?.['3DTILES_bounding_volume_S2'];
|
|
127
|
+
if (s2VolumeInfo) {
|
|
128
|
+
const box = convertS2BoundingVolumetoOBB(s2VolumeInfo);
|
|
129
|
+
const s2VolumeBox = { box, s2VolumeInfo };
|
|
130
|
+
tile.boundingVolume = s2VolumeBox;
|
|
112
131
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
132
|
+
const rootBoundingVolume = tile.boundingVolume;
|
|
133
|
+
const implicitOptions = {
|
|
134
|
+
contentUrlTemplate,
|
|
135
|
+
subtreesUriTemplate,
|
|
136
|
+
subdivisionScheme,
|
|
137
|
+
subtreeLevels,
|
|
138
|
+
maximumLevel: Number.isFinite(availableLevels) ? availableLevels - 1 : maximumLevel,
|
|
139
|
+
refine,
|
|
140
|
+
basePath,
|
|
141
|
+
lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
|
|
142
|
+
rootLodMetricValue,
|
|
143
|
+
rootBoundingVolume,
|
|
144
|
+
getTileType,
|
|
145
|
+
getRefine
|
|
127
146
|
};
|
|
128
|
-
tile
|
|
129
|
-
}
|
|
130
|
-
const rootBoundingVolume = tile.boundingVolume;
|
|
131
|
-
const implicitOptions = {
|
|
132
|
-
contentUrlTemplate,
|
|
133
|
-
subtreesUriTemplate,
|
|
134
|
-
subdivisionScheme,
|
|
135
|
-
subtreeLevels,
|
|
136
|
-
maximumLevel: Number.isFinite(availableLevels) ? availableLevels - 1 : maximumLevel,
|
|
137
|
-
refine,
|
|
138
|
-
basePath,
|
|
139
|
-
lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
|
|
140
|
-
rootLodMetricValue,
|
|
141
|
-
rootBoundingVolume,
|
|
142
|
-
getTileType,
|
|
143
|
-
getRefine
|
|
144
|
-
};
|
|
145
|
-
return await normalizeImplicitTileData(tile, basePath, subtree, implicitOptions, options);
|
|
147
|
+
return await normalizeImplicitTileData(tile, basePath, subtree, implicitOptions, options);
|
|
146
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Do implicit data normalisation to create hierarchical tile structure
|
|
151
|
+
* @param tile
|
|
152
|
+
* @param rootSubtree
|
|
153
|
+
* @param options
|
|
154
|
+
* @returns
|
|
155
|
+
*/
|
|
147
156
|
export async function normalizeImplicitTileData(tile, basePath, rootSubtree, implicitOptions, loaderOptions) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
157
|
+
if (!tile) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
const { children, contentUrl } = await parseImplicitTiles({
|
|
161
|
+
subtree: rootSubtree,
|
|
162
|
+
implicitOptions,
|
|
163
|
+
loaderOptions
|
|
164
|
+
});
|
|
165
|
+
let tileContentUrl;
|
|
166
|
+
let tileContent = null;
|
|
167
|
+
if (contentUrl) {
|
|
168
|
+
tileContentUrl = contentUrl;
|
|
169
|
+
tileContent = { uri: contentUrl.replace(`${basePath}/`, '') };
|
|
170
|
+
}
|
|
171
|
+
const tilePostprocessed = {
|
|
172
|
+
...tile,
|
|
173
|
+
id: tileContentUrl,
|
|
174
|
+
contentUrl: tileContentUrl,
|
|
175
|
+
lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
|
|
176
|
+
lodMetricValue: tile.geometricError,
|
|
177
|
+
transformMatrix: tile.transform,
|
|
178
|
+
type: getTileType(tile, tileContentUrl),
|
|
179
|
+
refine: getRefine(tile.refine),
|
|
180
|
+
content: tileContent || tile.content,
|
|
181
|
+
children
|
|
165
182
|
};
|
|
166
|
-
|
|
167
|
-
const tilePostprocessed = {
|
|
168
|
-
...tile,
|
|
169
|
-
id: tileContentUrl,
|
|
170
|
-
contentUrl: tileContentUrl,
|
|
171
|
-
lodMetricType: LOD_METRIC_TYPE.GEOMETRIC_ERROR,
|
|
172
|
-
lodMetricValue: tile.geometricError,
|
|
173
|
-
transformMatrix: tile.transform,
|
|
174
|
-
type: getTileType(tile, tileContentUrl),
|
|
175
|
-
refine: getRefine(tile.refine),
|
|
176
|
-
content: tileContent || tile.content,
|
|
177
|
-
children
|
|
178
|
-
};
|
|
179
|
-
return tilePostprocessed;
|
|
183
|
+
return tilePostprocessed;
|
|
180
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Implicit Tiling data can be in 3DTILES_implicit_tiling for 3DTiles v.Next or directly in implicitTiling object for 3DTiles v1.1.
|
|
187
|
+
* Spec 3DTiles v.Next - https://github.com/CesiumGS/3d-tiles/tree/main/extensions/3DTILES_implicit_tiling
|
|
188
|
+
* Spec 3DTiles v.1.1 - https://github.com/CesiumGS/3d-tiles/tree/draft-1.1/specification/ImplicitTiling
|
|
189
|
+
* @param tile
|
|
190
|
+
* @returns
|
|
191
|
+
*/
|
|
181
192
|
function getImplicitTilingExtensionData(tile) {
|
|
182
|
-
|
|
183
|
-
return (tile === null || tile === void 0 ? void 0 : (_tile$extensions = tile.extensions) === null || _tile$extensions === void 0 ? void 0 : _tile$extensions['3DTILES_implicit_tiling']) || (tile === null || tile === void 0 ? void 0 : tile.implicitTiling);
|
|
193
|
+
return tile?.extensions?.['3DTILES_implicit_tiling'] || tile?.implicitTiling;
|
|
184
194
|
}
|
|
185
|
-
//# sourceMappingURL=parse-3d-tile-header.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Tiles3DLoaderOptions } from
|
|
1
|
+
import { Tiles3DLoaderOptions } from "../../tiles-3d-loader.js";
|
|
2
2
|
import { LoaderContext } from '@loaders.gl/loader-utils';
|
|
3
|
-
import { Tiles3DTileContent } from
|
|
3
|
+
import { Tiles3DTileContent } from "../../types.js";
|
|
4
4
|
export declare function parseInstancedModel3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, byteOffset: number, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<number>;
|
|
5
5
|
//# sourceMappingURL=parse-3d-tile-instanced-model.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile-instanced-model.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-instanced-model.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,oBAAoB,EAAC,
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-instanced-model.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-instanced-model.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,oBAAoB,EAAC,iCAA8B;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,kBAAkB,EAAC,uBAAoB;AAE/C,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,kBAAkB,EACxB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,MAAM,CAAC,CAIjB"}
|