@loaders.gl/3d-tiles 4.0.0-alpha.7 → 4.0.0-alpha.9
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/dist.min.js +317 -146
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-colors.js +4 -3
- 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 +2 -2
- package/dist/es5/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-gltf-view.js +30 -18
- 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.map +1 -1
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js +12 -12
- package/dist/es5/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js +19 -4
- package/dist/es5/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-header.js +98 -80
- package/dist/es5/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile-instanced-model.js +12 -21
- 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 +29 -5
- package/dist/es5/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/es5/lib/parsers/parse-3d-tile.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/tiles-3d-loader.js +26 -31
- package/dist/es5/tiles-3d-loader.js.map +1 -1
- package/dist/es5/types.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js +3 -3
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-colors.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js +2 -2
- package/dist/esm/lib/parsers/helpers/normalize-3d-tile-normals.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-implicit-tiles.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js +15 -9
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-gltf-view.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js +7 -7
- package/dist/esm/lib/parsers/helpers/parse-3d-tile-tables.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-batched-model.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-composite.js +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-composite.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js +15 -7
- package/dist/esm/lib/parsers/parse-3d-tile-gltf.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-header.js +62 -45
- package/dist/esm/lib/parsers/parse-3d-tile-header.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js +12 -21
- package/dist/esm/lib/parsers/parse-3d-tile-instanced-model.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js +23 -2
- package/dist/esm/lib/parsers/parse-3d-tile-point-cloud.js.map +1 -1
- package/dist/esm/lib/parsers/parse-3d-tile.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/esm/tiles-3d-loader.js +18 -12
- package/dist/esm/tiles-3d-loader.js.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts +4 -2
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-colors.js +3 -3
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts +3 -2
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/normalize-3d-tile-normals.js +2 -2
- package/dist/lib/parsers/helpers/parse-3d-implicit-tiles.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-gltf-view.d.ts +5 -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 +15 -9
- package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts +2 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-header.d.ts.map +1 -1
- package/dist/lib/parsers/helpers/parse-3d-tile-tables.d.ts +4 -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 +7 -7
- package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts +4 -1
- package/dist/lib/parsers/parse-3d-tile-batched-model.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-batched-model.js +1 -1
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts +3 -2
- package/dist/lib/parsers/parse-3d-tile-composite.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-composite.js +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts +2 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-gltf.js +13 -5
- package/dist/lib/parsers/parse-3d-tile-header.d.ts +5 -6
- package/dist/lib/parsers/parse-3d-tile-header.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-header.js +57 -42
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts +2 -1
- package/dist/lib/parsers/parse-3d-tile-instanced-model.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile-instanced-model.js +11 -25
- package/dist/lib/parsers/parse-3d-tile-point-cloud.d.ts +3 -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 +23 -2
- package/dist/lib/parsers/parse-3d-tile.d.ts +4 -1
- package/dist/lib/parsers/parse-3d-tile.d.ts.map +1 -1
- package/dist/lib/parsers/parse-3d-tile.js +0 -4
- package/dist/tiles-3d-loader.d.ts.map +1 -1
- package/dist/tiles-3d-loader.js +18 -17
- package/dist/types.d.ts +257 -15
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/index.ts +12 -1
- package/src/lib/parsers/helpers/normalize-3d-tile-colors.ts +10 -4
- package/src/lib/parsers/helpers/normalize-3d-tile-normals.ts +7 -3
- package/src/lib/parsers/helpers/parse-3d-implicit-tiles.ts +4 -4
- package/src/lib/parsers/helpers/parse-3d-tile-gltf-view.ts +35 -13
- package/src/lib/parsers/helpers/parse-3d-tile-header.ts +7 -1
- package/src/lib/parsers/helpers/parse-3d-tile-tables.ts +32 -11
- package/src/lib/parsers/parse-3d-tile-batched-model.ts +18 -3
- package/src/lib/parsers/parse-3d-tile-composite.ts +7 -6
- package/src/lib/parsers/parse-3d-tile-gltf.ts +16 -8
- package/src/lib/parsers/parse-3d-tile-header.ts +84 -52
- package/src/lib/parsers/parse-3d-tile-instanced-model.ts +24 -33
- package/src/lib/parsers/parse-3d-tile-point-cloud.ts +51 -19
- package/src/lib/parsers/parse-3d-tile.ts +10 -5
- package/src/tiles-3d-loader.ts +21 -23
- package/src/types.ts +269 -15
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { LoaderContext } from '@loaders.gl/loader-utils';
|
|
2
2
|
import type { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
|
|
3
|
+
import { Tiles3DTileContent } from '../../types';
|
|
3
4
|
/** Resolve circulate dependency by passing in parsing function as argument */
|
|
4
|
-
type Parse3DTile = (arrayBuffer: ArrayBuffer, byteOffset: number, options: Tiles3DLoaderOptions, context: LoaderContext, subtile: any) => Promise<number>;
|
|
5
|
-
export declare function parseComposite3DTile(tile:
|
|
5
|
+
type Parse3DTile = (arrayBuffer: ArrayBuffer, byteOffset: number, options: Tiles3DLoaderOptions | undefined, context: LoaderContext | undefined, subtile: any) => Promise<number>;
|
|
6
|
+
export declare function parseComposite3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, byteOffset: number, options: Tiles3DLoaderOptions | undefined, context: LoaderContext | undefined, parse3DTile: Parse3DTile): Promise<number>;
|
|
6
7
|
export {};
|
|
7
8
|
//# sourceMappingURL=parse-3d-tile-composite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile-composite.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-composite.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-composite.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-composite.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;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"}
|
|
@@ -13,7 +13,7 @@ async function parseComposite3DTile(tile, arrayBuffer, byteOffset, options, cont
|
|
|
13
13
|
byteOffset += 4;
|
|
14
14
|
// extract each tile from the byte stream
|
|
15
15
|
tile.tiles = [];
|
|
16
|
-
while (tile.tiles.length < tile.tilesLength && tile.byteLength - byteOffset > 12) {
|
|
16
|
+
while (tile.tiles.length < tile.tilesLength && (tile.byteLength || 0) - byteOffset > 12) {
|
|
17
17
|
const subtile = {};
|
|
18
18
|
tile.tiles.push(subtile);
|
|
19
19
|
byteOffset = await parse3DTile(arrayBuffer, byteOffset, options, context, subtile);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { LoaderContext } from '@loaders.gl/loader-utils';
|
|
2
2
|
import type { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
|
|
3
|
-
|
|
3
|
+
import { Tiles3DTileContent } from '../../types';
|
|
4
|
+
export declare function parseGltf3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<void>;
|
|
4
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":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-gltf.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-gltf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAEhE,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;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,IAAI,CAAC,CAsBf"}
|
|
@@ -9,12 +9,20 @@ async function parseGltf3DTile(tile, arrayBuffer, options, context) {
|
|
|
9
9
|
tile.rotateYtoZ = true;
|
|
10
10
|
// Save gltf up axis
|
|
11
11
|
tile.gltfUpAxis =
|
|
12
|
-
options['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis
|
|
12
|
+
options?.['3d-tiles'] && options['3d-tiles'].assetGltfUpAxis
|
|
13
13
|
? options['3d-tiles'].assetGltfUpAxis
|
|
14
14
|
: 'Y';
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
if (options?.['3d-tiles']?.loadGLTF) {
|
|
16
|
+
if (!context) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const { parse } = context;
|
|
20
|
+
const gltfWithBuffers = await parse(arrayBuffer, gltf_1.GLTFLoader, options, context);
|
|
21
|
+
tile.gltf = (0, gltf_1.postProcessGLTF)(gltfWithBuffers);
|
|
22
|
+
tile.gpuMemoryUsageInBytes = (0, gltf_1._getMemoryUsageGLTF)(tile.gltf);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
tile.gltfArrayBuffer = arrayBuffer;
|
|
26
|
+
}
|
|
19
27
|
}
|
|
20
28
|
exports.parseGltf3DTile = parseGltf3DTile;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
|
|
2
2
|
import type { LoaderOptions } from '@loaders.gl/loader-utils';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export declare function
|
|
6
|
-
export declare function normalizeTileHeaders(tileset: Tileset3D, options: LoaderOptions): Promise<Tileset3D>;
|
|
3
|
+
import { ImplicitTilingExensionData, Subtree, Tiles3DTileJSON, Tiles3DTileJSONPostprocessed, Tiles3DTilesetJSON } from '../../types';
|
|
4
|
+
export declare function normalizeTileData(tile: Tiles3DTileJSON | null, basePath: string): Tiles3DTileJSONPostprocessed | null;
|
|
5
|
+
export declare function normalizeTileHeaders(tileset: Tiles3DTilesetJSON, basePath: string, options: LoaderOptions): Promise<Tiles3DTileJSONPostprocessed | null>;
|
|
7
6
|
/**
|
|
8
7
|
* Do normalisation of implicit tile headers
|
|
9
8
|
* TODO Check if Tile3D class can be a return type here.
|
|
10
9
|
* @param tileset
|
|
11
10
|
*/
|
|
12
|
-
export declare function normalizeImplicitTileHeaders(tile:
|
|
11
|
+
export declare function normalizeImplicitTileHeaders(tile: Tiles3DTileJSON, tileset: Tiles3DTilesetJSON, basePath: string, implicitTilingExtension: ImplicitTilingExensionData, options: Tiles3DLoaderOptions): Promise<Tiles3DTileJSONPostprocessed | null>;
|
|
13
12
|
/**
|
|
14
13
|
* Do implicit data normalisation to create hierarchical tile structure
|
|
15
14
|
* @param tile
|
|
@@ -17,5 +16,5 @@ export declare function normalizeImplicitTileHeaders(tile: Tile3D, tileset: Tile
|
|
|
17
16
|
* @param options
|
|
18
17
|
* @returns
|
|
19
18
|
*/
|
|
20
|
-
export declare function normalizeImplicitTileData(tile:
|
|
19
|
+
export declare function normalizeImplicitTileData(tile: Tiles3DTileJSON, basePath: string, rootSubtree: Subtree, options: any): Promise<Tiles3DTileJSONPostprocessed | null>;
|
|
21
20
|
//# 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":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-header.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-header.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAI5D,OAAO,EACL,0BAA0B,EAC1B,OAAO,EAEP,eAAe,EACf,4BAA4B,EAC5B,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAqDrB,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,eAAe,GAAG,IAAI,EAC5B,QAAQ,EAAE,MAAM,GACf,4BAA4B,GAAG,IAAI,CAqBrC;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,CAyC9C;AAED;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,eAAe,EACrB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,OAAO,EACpB,OAAO,EAAE,GAAG,GACX,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CA8B9C"}
|
|
@@ -6,11 +6,11 @@ const core_1 = require("@loaders.gl/core");
|
|
|
6
6
|
const tiles_1 = require("@loaders.gl/tiles");
|
|
7
7
|
const parse_3d_implicit_tiles_1 = require("./helpers/parse-3d-implicit-tiles");
|
|
8
8
|
const s2_corners_to_obb_1 = require("../utils/obb/s2-corners-to-obb");
|
|
9
|
-
function getTileType(tile) {
|
|
10
|
-
if (!
|
|
9
|
+
function getTileType(tile, tileContentUrl = '') {
|
|
10
|
+
if (!tileContentUrl) {
|
|
11
11
|
return tiles_1.TILE_TYPE.EMPTY;
|
|
12
12
|
}
|
|
13
|
-
const contentUrl =
|
|
13
|
+
const contentUrl = tileContentUrl.split('?')[0]; // Discard query string
|
|
14
14
|
const fileExtension = contentUrl.split('.').pop();
|
|
15
15
|
switch (fileExtension) {
|
|
16
16
|
case 'pnts':
|
|
@@ -21,7 +21,7 @@ function getTileType(tile) {
|
|
|
21
21
|
case 'gltf':
|
|
22
22
|
return tiles_1.TILE_TYPE.SCENEGRAPH;
|
|
23
23
|
default:
|
|
24
|
-
return fileExtension;
|
|
24
|
+
return fileExtension || tiles_1.TILE_TYPE.EMPTY;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function getRefine(refine) {
|
|
@@ -36,7 +36,7 @@ function getRefine(refine) {
|
|
|
36
36
|
return refine;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
function resolveUri(uri, basePath) {
|
|
39
|
+
function resolveUri(uri = '', basePath) {
|
|
40
40
|
// url scheme per RFC3986
|
|
41
41
|
const urlSchemeRegex = /^[a-z][0-9a-z+.-]*:/i;
|
|
42
42
|
if (urlSchemeRegex.test(basePath)) {
|
|
@@ -48,49 +48,59 @@ function resolveUri(uri, basePath) {
|
|
|
48
48
|
}
|
|
49
49
|
return `${basePath}/${uri}`;
|
|
50
50
|
}
|
|
51
|
-
function normalizeTileData(tile,
|
|
51
|
+
function normalizeTileData(tile, basePath) {
|
|
52
52
|
if (!tile) {
|
|
53
53
|
return null;
|
|
54
54
|
}
|
|
55
|
+
let tileContentUrl;
|
|
55
56
|
if (tile.content) {
|
|
56
|
-
const contentUri = tile.content.uri || tile.content
|
|
57
|
-
|
|
57
|
+
const contentUri = tile.content.uri || tile.content?.url;
|
|
58
|
+
tileContentUrl = resolveUri(contentUri, basePath);
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
const tilePostprocessed = {
|
|
61
|
+
...tile,
|
|
62
|
+
id: tileContentUrl,
|
|
63
|
+
contentUrl: tileContentUrl,
|
|
64
|
+
lodMetricType: tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR,
|
|
65
|
+
lodMetricValue: tile.geometricError,
|
|
66
|
+
transformMatrix: tile.transform,
|
|
67
|
+
type: getTileType(tile, tileContentUrl),
|
|
68
|
+
refine: getRefine(tile.refine)
|
|
69
|
+
};
|
|
70
|
+
return tilePostprocessed;
|
|
66
71
|
}
|
|
67
72
|
exports.normalizeTileData = normalizeTileData;
|
|
68
73
|
// normalize tile headers
|
|
69
|
-
async function normalizeTileHeaders(tileset, options) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const rootImplicitTilingExtension = getImplicitTilingExtensionData(tileset?.root);
|
|
74
|
+
async function normalizeTileHeaders(tileset, basePath, options) {
|
|
75
|
+
let root = null;
|
|
76
|
+
const rootImplicitTilingExtension = getImplicitTilingExtensionData(tileset.root);
|
|
73
77
|
if (rootImplicitTilingExtension && tileset.root) {
|
|
74
|
-
root = await normalizeImplicitTileHeaders(tileset.root, tileset, rootImplicitTilingExtension, options);
|
|
78
|
+
root = await normalizeImplicitTileHeaders(tileset.root, tileset, basePath, rootImplicitTilingExtension, options);
|
|
75
79
|
}
|
|
76
80
|
else {
|
|
77
|
-
root = normalizeTileData(tileset.root,
|
|
81
|
+
root = normalizeTileData(tileset.root, basePath);
|
|
78
82
|
}
|
|
79
83
|
const stack = [];
|
|
80
84
|
stack.push(root);
|
|
81
85
|
while (stack.length > 0) {
|
|
82
86
|
const tile = stack.pop() || {};
|
|
83
87
|
const children = tile.children || [];
|
|
84
|
-
|
|
88
|
+
const childrenPostprocessed = [];
|
|
89
|
+
for (const childHeader of children) {
|
|
85
90
|
const childImplicitTilingExtension = getImplicitTilingExtensionData(childHeader);
|
|
91
|
+
let childHeaderPostprocessed;
|
|
86
92
|
if (childImplicitTilingExtension) {
|
|
87
|
-
|
|
93
|
+
childHeaderPostprocessed = await normalizeImplicitTileHeaders(childHeader, tileset, basePath, childImplicitTilingExtension, options);
|
|
88
94
|
}
|
|
89
95
|
else {
|
|
90
|
-
normalizeTileData(childHeader,
|
|
96
|
+
childHeaderPostprocessed = normalizeTileData(childHeader, basePath);
|
|
97
|
+
}
|
|
98
|
+
if (childHeaderPostprocessed) {
|
|
99
|
+
childrenPostprocessed.push(childHeaderPostprocessed);
|
|
100
|
+
stack.push(childHeaderPostprocessed);
|
|
91
101
|
}
|
|
92
|
-
stack.push(childHeader);
|
|
93
102
|
}
|
|
103
|
+
tile.children = childrenPostprocessed;
|
|
94
104
|
}
|
|
95
105
|
return root;
|
|
96
106
|
}
|
|
@@ -100,13 +110,12 @@ exports.normalizeTileHeaders = normalizeTileHeaders;
|
|
|
100
110
|
* TODO Check if Tile3D class can be a return type here.
|
|
101
111
|
* @param tileset
|
|
102
112
|
*/
|
|
103
|
-
async function normalizeImplicitTileHeaders(tile, tileset, implicitTilingExtension, options) {
|
|
104
|
-
const basePath = tileset.basePath;
|
|
113
|
+
async function normalizeImplicitTileHeaders(tile, tileset, basePath, implicitTilingExtension, options) {
|
|
105
114
|
const { subdivisionScheme, maximumLevel, subtreeLevels, subtrees: { uri: subtreesUriTemplate } } = implicitTilingExtension;
|
|
106
115
|
const replacedUrlTemplate = (0, parse_3d_implicit_tiles_1.replaceContentUrlTemplate)(subtreesUriTemplate, 0, 0, 0, 0);
|
|
107
116
|
const subtreeUrl = resolveUri(replacedUrlTemplate, basePath);
|
|
108
117
|
const subtree = await (0, core_1.load)(subtreeUrl, tile_3d_subtree_loader_1.Tile3DSubtreeLoader, options);
|
|
109
|
-
const contentUrlTemplate = resolveUri(tile.content
|
|
118
|
+
const contentUrlTemplate = resolveUri(tile.content?.uri, basePath);
|
|
110
119
|
const refine = tileset?.root?.refine;
|
|
111
120
|
// @ts-ignore
|
|
112
121
|
const rootLodMetricValue = tile.geometricError;
|
|
@@ -132,7 +141,7 @@ async function normalizeImplicitTileHeaders(tile, tileset, implicitTilingExtensi
|
|
|
132
141
|
getTileType,
|
|
133
142
|
getRefine
|
|
134
143
|
};
|
|
135
|
-
return await normalizeImplicitTileData(tile, subtree, implicitOptions);
|
|
144
|
+
return await normalizeImplicitTileData(tile, basePath, subtree, implicitOptions);
|
|
136
145
|
}
|
|
137
146
|
exports.normalizeImplicitTileHeaders = normalizeImplicitTileHeaders;
|
|
138
147
|
/**
|
|
@@ -142,27 +151,33 @@ exports.normalizeImplicitTileHeaders = normalizeImplicitTileHeaders;
|
|
|
142
151
|
* @param options
|
|
143
152
|
* @returns
|
|
144
153
|
*/
|
|
145
|
-
async function normalizeImplicitTileData(tile, rootSubtree, options) {
|
|
154
|
+
async function normalizeImplicitTileData(tile, basePath, rootSubtree, options) {
|
|
146
155
|
if (!tile) {
|
|
147
156
|
return null;
|
|
148
157
|
}
|
|
149
|
-
tile.lodMetricType = tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR;
|
|
150
|
-
tile.lodMetricValue = tile.geometricError;
|
|
151
|
-
tile.transformMatrix = tile.transform;
|
|
152
158
|
const { children, contentUrl } = await (0, parse_3d_implicit_tiles_1.parseImplicitTiles)({
|
|
153
159
|
subtree: rootSubtree,
|
|
154
|
-
options
|
|
155
|
-
s2VolumeBox: tile
|
|
160
|
+
options
|
|
156
161
|
});
|
|
162
|
+
let tileContentUrl;
|
|
163
|
+
let tileContent = null;
|
|
157
164
|
if (contentUrl) {
|
|
158
|
-
|
|
159
|
-
|
|
165
|
+
tileContentUrl = contentUrl;
|
|
166
|
+
tileContent = { uri: contentUrl.replace(`${basePath}/`, '') };
|
|
160
167
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
168
|
+
const tilePostprocessed = {
|
|
169
|
+
...tile,
|
|
170
|
+
id: tileContentUrl,
|
|
171
|
+
contentUrl: tileContentUrl,
|
|
172
|
+
lodMetricType: tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR,
|
|
173
|
+
lodMetricValue: tile.geometricError,
|
|
174
|
+
transformMatrix: tile.transform,
|
|
175
|
+
type: getTileType(tile, tileContentUrl),
|
|
176
|
+
refine: getRefine(tile.refine),
|
|
177
|
+
content: tileContent || tile.content,
|
|
178
|
+
children
|
|
179
|
+
};
|
|
180
|
+
return tilePostprocessed;
|
|
166
181
|
}
|
|
167
182
|
exports.normalizeImplicitTileData = normalizeImplicitTileData;
|
|
168
183
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
|
|
2
2
|
import { LoaderContext } from '@loaders.gl/loader-utils';
|
|
3
|
-
|
|
3
|
+
import { Tiles3DTileContent } from '../../types';
|
|
4
|
+
export declare function parseInstancedModel3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, byteOffset: number, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<number>;
|
|
4
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":"AAYA,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-instanced-model.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-instanced-model.ts"],"names":[],"mappings":"AAYA,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;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"}
|
|
@@ -16,7 +16,7 @@ const parse_3d_tile_tables_1 = require("./helpers/parse-3d-tile-tables");
|
|
|
16
16
|
const parse_3d_tile_gltf_view_1 = require("./helpers/parse-3d-tile-gltf-view");
|
|
17
17
|
async function parseInstancedModel3DTile(tile, arrayBuffer, byteOffset, options, context) {
|
|
18
18
|
byteOffset = parseInstancedModel(tile, arrayBuffer, byteOffset, options, context);
|
|
19
|
-
await (0, parse_3d_tile_gltf_view_1.extractGLTF)(tile, tile.gltfFormat, options, context);
|
|
19
|
+
await (0, parse_3d_tile_gltf_view_1.extractGLTF)(tile, tile.gltfFormat || 0, options, context);
|
|
20
20
|
return byteOffset;
|
|
21
21
|
}
|
|
22
22
|
exports.parseInstancedModel3DTile = parseInstancedModel3DTile;
|
|
@@ -33,7 +33,7 @@ function parseInstancedModel(tile, arrayBuffer, byteOffset, options, context) {
|
|
|
33
33
|
byteOffset = (0, parse_3d_tile_tables_1.parse3DTileTablesSync)(tile, arrayBuffer, byteOffset, options);
|
|
34
34
|
byteOffset = (0, parse_3d_tile_gltf_view_1.parse3DTileGLTFViewSync)(tile, arrayBuffer, byteOffset, options);
|
|
35
35
|
// TODO - Is the feature table sometimes optional or can check be moved into table header parser?
|
|
36
|
-
if (tile.featureTableJsonByteLength === 0) {
|
|
36
|
+
if (!tile?.header?.featureTableJsonByteLength || tile.header.featureTableJsonByteLength === 0) {
|
|
37
37
|
throw new Error('i3dm parser: featureTableJsonByteLength is zero.');
|
|
38
38
|
}
|
|
39
39
|
const featureTable = new tile_3d_feature_table_1.default(tile.featureTableJson, tile.featureTableBinary);
|
|
@@ -50,21 +50,7 @@ function parseInstancedModel(tile, arrayBuffer, byteOffset, options, context) {
|
|
|
50
50
|
}
|
|
51
51
|
// eslint-disable-next-line max-statements, complexity
|
|
52
52
|
function extractInstancedAttributes(tile, featureTable, batchTable, instancesLength) {
|
|
53
|
-
|
|
54
|
-
const collectionOptions = {
|
|
55
|
-
instances: new Array(instancesLength),
|
|
56
|
-
batchTable: tile._batchTable,
|
|
57
|
-
cull: false,
|
|
58
|
-
url: undefined,
|
|
59
|
-
// requestType: RequestType.TILES3D,
|
|
60
|
-
gltf: undefined,
|
|
61
|
-
basePath: undefined,
|
|
62
|
-
incrementallyLoadTextures: false,
|
|
63
|
-
// TODO - tileset is not available at this stage, tile is parsed independently
|
|
64
|
-
// upAxis: (tileset && tileset._gltfUpAxis) || [0, 1, 0],
|
|
65
|
-
forwardAxis: [1, 0, 0]
|
|
66
|
-
};
|
|
67
|
-
const instances = collectionOptions.instances;
|
|
53
|
+
const instances = new Array(instancesLength);
|
|
68
54
|
const instancePosition = new core_1.Vector3();
|
|
69
55
|
const instanceNormalRight = new core_1.Vector3();
|
|
70
56
|
const instanceNormalUp = new core_1.Vector3();
|
|
@@ -76,8 +62,8 @@ function extractInstancedAttributes(tile, featureTable, batchTable, instancesLen
|
|
|
76
62
|
const instanceTransform = new core_1.Matrix4();
|
|
77
63
|
const scratch1 = [];
|
|
78
64
|
const scratch2 = [];
|
|
79
|
-
const
|
|
80
|
-
const
|
|
65
|
+
const scratch3 = [];
|
|
66
|
+
const scratch4 = [];
|
|
81
67
|
for (let i = 0; i < instancesLength; i++) {
|
|
82
68
|
let position;
|
|
83
69
|
// Get the instance position
|
|
@@ -86,11 +72,11 @@ function extractInstancedAttributes(tile, featureTable, batchTable, instancesLen
|
|
|
86
72
|
}
|
|
87
73
|
else if (featureTable.hasProperty('POSITION_QUANTIZED')) {
|
|
88
74
|
position = featureTable.getProperty('POSITION_QUANTIZED', math_1.GL.UNSIGNED_SHORT, 3, i, instancePosition);
|
|
89
|
-
const quantizedVolumeOffset = featureTable.getGlobalProperty('QUANTIZED_VOLUME_OFFSET', math_1.GL.FLOAT, 3
|
|
75
|
+
const quantizedVolumeOffset = featureTable.getGlobalProperty('QUANTIZED_VOLUME_OFFSET', math_1.GL.FLOAT, 3);
|
|
90
76
|
if (!quantizedVolumeOffset) {
|
|
91
77
|
throw new Error('i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.');
|
|
92
78
|
}
|
|
93
|
-
const quantizedVolumeScale = featureTable.getGlobalProperty('QUANTIZED_VOLUME_SCALE', math_1.GL.FLOAT, 3
|
|
79
|
+
const quantizedVolumeScale = featureTable.getGlobalProperty('QUANTIZED_VOLUME_SCALE', math_1.GL.FLOAT, 3);
|
|
94
80
|
if (!quantizedVolumeScale) {
|
|
95
81
|
throw new Error('i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.');
|
|
96
82
|
}
|
|
@@ -119,8 +105,8 @@ function extractInstancedAttributes(tile, featureTable, batchTable, instancesLen
|
|
|
119
105
|
tile.hasCustomOrientation = true;
|
|
120
106
|
}
|
|
121
107
|
else {
|
|
122
|
-
tile.octNormalUp = featureTable.getProperty('NORMAL_UP_OCT32P', math_1.GL.UNSIGNED_SHORT, 2, scratch1);
|
|
123
|
-
tile.octNormalRight = featureTable.getProperty('NORMAL_RIGHT_OCT32P', math_1.GL.UNSIGNED_SHORT, 2, scratch2);
|
|
108
|
+
tile.octNormalUp = featureTable.getProperty('NORMAL_UP_OCT32P', math_1.GL.UNSIGNED_SHORT, 2, i, scratch1);
|
|
109
|
+
tile.octNormalRight = featureTable.getProperty('NORMAL_RIGHT_OCT32P', math_1.GL.UNSIGNED_SHORT, 2, i, scratch2);
|
|
124
110
|
if (tile.octNormalUp) {
|
|
125
111
|
if (!tile.octNormalRight) {
|
|
126
112
|
throw new Error('i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P');
|
|
@@ -151,7 +137,7 @@ function extractInstancedAttributes(tile, featureTable, batchTable, instancesLen
|
|
|
151
137
|
instanceTranslationRotationScale.rotation = instanceQuaternion;
|
|
152
138
|
// Get the instance scale
|
|
153
139
|
instanceScale.set(1.0, 1.0, 1.0);
|
|
154
|
-
const scale = featureTable.getProperty('SCALE', math_1.GL.FLOAT, 1, i);
|
|
140
|
+
const scale = featureTable.getProperty('SCALE', math_1.GL.FLOAT, 1, i, scratch3);
|
|
155
141
|
if (Number.isFinite(scale)) {
|
|
156
142
|
instanceScale.multiplyByScalar(scale);
|
|
157
143
|
}
|
|
@@ -162,7 +148,7 @@ function extractInstancedAttributes(tile, featureTable, batchTable, instancesLen
|
|
|
162
148
|
// @ts-expect-error
|
|
163
149
|
instanceTranslationRotationScale.scale = instanceScale;
|
|
164
150
|
// Get the batchId
|
|
165
|
-
let batchId = featureTable.getProperty('BATCH_ID', math_1.GL.UNSIGNED_SHORT, 1, i);
|
|
151
|
+
let batchId = featureTable.getProperty('BATCH_ID', math_1.GL.UNSIGNED_SHORT, 1, i, scratch4);
|
|
166
152
|
if (batchId === undefined) {
|
|
167
153
|
// If BATCH_ID semantic is undefined, batchId is just the instance number
|
|
168
154
|
batchId = i;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
|
|
2
2
|
import { LoaderContext } from '@loaders.gl/loader-utils';
|
|
3
|
-
|
|
4
|
-
export declare function
|
|
3
|
+
import { Tiles3DTileContent } from '../../types';
|
|
4
|
+
export declare function parsePointCloud3DTile(tile: Tiles3DTileContent, arrayBuffer: ArrayBuffer, byteOffset: number, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<number>;
|
|
5
|
+
export declare function loadDraco(tile: Tiles3DTileContent, dracoData: any, options?: Tiles3DLoaderOptions, context?: LoaderContext): Promise<void>;
|
|
5
6
|
//# sourceMappingURL=parse-3d-tile-point-cloud.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-3d-tile-point-cloud.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-point-cloud.ts"],"names":[],"mappings":"AAcA,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"parse-3d-tile-point-cloud.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-3d-tile-point-cloud.ts"],"names":[],"mappings":"AAcA,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAE/C,wBAAsB,qBAAqB,CACzC,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,CAgBjB;AAuND,wBAAsB,SAAS,CAC7B,IAAI,EAAE,kBAAkB,EACxB,SAAS,KAAA,EACT,OAAO,CAAC,EAAE,oBAAoB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,OAAO,CAAC,IAAI,CAAC,CAwDf"}
|
|
@@ -58,6 +58,12 @@ function parsePointCloudTables(tile) {
|
|
|
58
58
|
return { featureTable, batchTable };
|
|
59
59
|
}
|
|
60
60
|
function parsePositions(tile, featureTable, options) {
|
|
61
|
+
tile.attributes = tile.attributes || {
|
|
62
|
+
positions: null,
|
|
63
|
+
colors: null,
|
|
64
|
+
normals: null,
|
|
65
|
+
batchIds: null
|
|
66
|
+
};
|
|
61
67
|
if (!tile.attributes.positions) {
|
|
62
68
|
if (featureTable.hasProperty('POSITION')) {
|
|
63
69
|
tile.attributes.positions = featureTable.getPropertyArray('POSITION', math_1.GL.FLOAT, 3);
|
|
@@ -82,6 +88,12 @@ function parsePositions(tile, featureTable, options) {
|
|
|
82
88
|
}
|
|
83
89
|
}
|
|
84
90
|
function parseColors(tile, featureTable, batchTable) {
|
|
91
|
+
tile.attributes = tile.attributes || {
|
|
92
|
+
positions: null,
|
|
93
|
+
colors: null,
|
|
94
|
+
normals: null,
|
|
95
|
+
batchIds: null
|
|
96
|
+
};
|
|
85
97
|
if (!tile.attributes.colors) {
|
|
86
98
|
let colors = null;
|
|
87
99
|
if (featureTable.hasProperty('RGBA')) {
|
|
@@ -102,6 +114,12 @@ function parseColors(tile, featureTable, batchTable) {
|
|
|
102
114
|
}
|
|
103
115
|
}
|
|
104
116
|
function parseNormals(tile, featureTable) {
|
|
117
|
+
tile.attributes = tile.attributes || {
|
|
118
|
+
positions: null,
|
|
119
|
+
colors: null,
|
|
120
|
+
normals: null,
|
|
121
|
+
batchIds: null
|
|
122
|
+
};
|
|
105
123
|
if (!tile.attributes.normals) {
|
|
106
124
|
let normals = null;
|
|
107
125
|
if (featureTable.hasProperty('NORMAL')) {
|
|
@@ -148,7 +166,7 @@ async function parseDraco(tile, featureTable, batchTable, options, context) {
|
|
|
148
166
|
if (!dracoFeatureTableProperties || !Number.isFinite(dracoByteOffset) || !dracoByteLength) {
|
|
149
167
|
throw new Error('Draco properties, byteOffset, and byteLength must be defined');
|
|
150
168
|
}
|
|
151
|
-
dracoBuffer = tile.featureTableBinary.slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
|
|
169
|
+
dracoBuffer = (tile.featureTableBinary || []).slice(dracoByteOffset, dracoByteOffset + dracoByteLength);
|
|
152
170
|
tile.hasPositions = Number.isFinite(dracoFeatureTableProperties.POSITION);
|
|
153
171
|
tile.hasColors =
|
|
154
172
|
Number.isFinite(dracoFeatureTableProperties.RGB) ||
|
|
@@ -171,11 +189,14 @@ async function parseDraco(tile, featureTable, batchTable, options, context) {
|
|
|
171
189
|
}
|
|
172
190
|
// eslint-disable-next-line complexity, max-statements
|
|
173
191
|
async function loadDraco(tile, dracoData, options, context) {
|
|
192
|
+
if (!context) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
174
195
|
const { parse } = context;
|
|
175
196
|
const dracoOptions = {
|
|
176
197
|
...options,
|
|
177
198
|
draco: {
|
|
178
|
-
...options
|
|
199
|
+
...options?.draco,
|
|
179
200
|
extraAttributes: dracoData.batchTableProperties || {}
|
|
180
201
|
}
|
|
181
202
|
};
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { LoaderContext } from '@loaders.gl/loader-utils';
|
|
2
|
+
import { Tiles3DLoaderOptions } from '../../tiles-3d-loader';
|
|
3
|
+
import { Tiles3DTileContent } from '../../types';
|
|
4
|
+
export declare function parse3DTile(arrayBuffer: ArrayBuffer, byteOffset: number | undefined, options: Tiles3DLoaderOptions | undefined, context: LoaderContext | undefined, tile?: Tiles3DTileContent): Promise<number | void>;
|
|
2
5
|
//# sourceMappingURL=parse-3d-tile.d.ts.map
|
|
@@ -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":"AAWA,OAAO,EAAC,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAC,oBAAoB,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,kBAAkB,EAAC,MAAM,aAAa,CAAC;AAG/C,wBAAsB,WAAW,CAC/B,WAAW,EAAE,WAAW,EACxB,UAAU,oBAAI,EACd,OAAO,EAAE,oBAAoB,GAAG,SAAS,EACzC,OAAO,EAAE,aAAa,GAAG,SAAS,EAClC,IAAI,GAAE,kBAAuB,0BAgC9B"}
|
|
@@ -12,11 +12,8 @@ const parse_3d_tile_composite_1 = require("./parse-3d-tile-composite");
|
|
|
12
12
|
const parse_3d_tile_gltf_1 = require("./parse-3d-tile-gltf");
|
|
13
13
|
// Extracts
|
|
14
14
|
async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile = {}) {
|
|
15
|
-
// @ts-expect-error
|
|
16
15
|
tile.byteOffset = byteOffset;
|
|
17
|
-
// @ts-expect-error
|
|
18
16
|
tile.type = (0, parse_utils_1.getMagicString)(arrayBuffer, byteOffset);
|
|
19
|
-
// @ts-expect-error
|
|
20
17
|
switch (tile.type) {
|
|
21
18
|
case constants_1.TILE3D_TYPE.COMPOSITE:
|
|
22
19
|
// Note: We pass this function as argument so that embedded tiles can be parsed recursively
|
|
@@ -30,7 +27,6 @@ async function parse3DTile(arrayBuffer, byteOffset = 0, options, context, tile =
|
|
|
30
27
|
case constants_1.TILE3D_TYPE.POINT_CLOUD:
|
|
31
28
|
return await (0, parse_3d_tile_point_cloud_1.parsePointCloud3DTile)(tile, arrayBuffer, byteOffset, options, context);
|
|
32
29
|
default:
|
|
33
|
-
// @ts-expect-error
|
|
34
30
|
throw new Error(`3DTileLoader: unknown type ${tile.type}`); // eslint-disable-line
|
|
35
31
|
}
|
|
36
32
|
}
|
|
@@ -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,EAAE,aAAa,EAAgB,MAAM,0BAA0B,CAAC;AAE7F,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"tiles-3d-loader.d.ts","sourceRoot":"","sources":["../src/tiles-3d-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAgB,MAAM,0BAA0B,CAAC;AAE7F,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AAS3D,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAE9C,kBAAkB,GAClB,kBAAkB,GAAG;IACnB,UAAU,CAAC,EAAE;QACX,mGAAmG;QACnG,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,qFAAqF;QACrF,wBAAwB,CAAC,EAAE,OAAO,CAAC;QACnC,0CAA0C;QAC1C,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;QAC7B,gDAAgD;QAChD,eAAe,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;KAC1C,CAAC;CACH,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,aAAa,EAAE,gBAiB3B,CAAC"}
|
package/dist/tiles-3d-loader.js
CHANGED
|
@@ -38,25 +38,26 @@ async function parse(data, options = {}, context) {
|
|
|
38
38
|
else {
|
|
39
39
|
isTileset = loaderOptions.isTileset;
|
|
40
40
|
}
|
|
41
|
-
return (
|
|
42
|
-
? parseTileset(data, options, context)
|
|
43
|
-
: parseTile(data, options, context);
|
|
41
|
+
return isTileset ? parseTileset(data, options, context) : parseTile(data, options, context);
|
|
44
42
|
}
|
|
45
43
|
/** Parse a tileset */
|
|
46
44
|
async function parseTileset(data, options, context) {
|
|
47
45
|
const tilesetJson = JSON.parse(new TextDecoder().decode(data));
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
const tilesetUrl = context?.url || '';
|
|
47
|
+
const basePath = getBaseUri(tilesetUrl);
|
|
48
|
+
const normalizedRoot = await (0, parse_3d_tile_header_1.normalizeTileHeaders)(tilesetJson, basePath, options || {});
|
|
49
|
+
const tilesetJsonPostprocessed = {
|
|
50
|
+
...tilesetJson,
|
|
51
|
+
loader: exports.Tiles3DLoader,
|
|
52
|
+
url: tilesetUrl,
|
|
53
|
+
queryString: context?.queryString || '',
|
|
54
|
+
basePath,
|
|
55
|
+
root: normalizedRoot || tilesetJson.root,
|
|
56
|
+
type: tiles_1.TILESET_TYPE.TILES3D,
|
|
57
|
+
lodMetricType: tiles_1.LOD_METRIC_TYPE.GEOMETRIC_ERROR,
|
|
58
|
+
lodMetricValue: tilesetJson.root?.geometricError || 0
|
|
59
|
+
};
|
|
60
|
+
return tilesetJsonPostprocessed;
|
|
60
61
|
}
|
|
61
62
|
/** Parse a tile */
|
|
62
63
|
async function parseTile(arrayBuffer, options, context) {
|
|
@@ -70,6 +71,6 @@ async function parseTile(arrayBuffer, options, context) {
|
|
|
70
71
|
return tile.content;
|
|
71
72
|
}
|
|
72
73
|
/** Get base name */
|
|
73
|
-
function getBaseUri(
|
|
74
|
-
return loader_utils_1.path.dirname(
|
|
74
|
+
function getBaseUri(tilesetUrl) {
|
|
75
|
+
return loader_utils_1.path.dirname(tilesetUrl);
|
|
75
76
|
}
|