@loaders.gl/tile-converter 5.0.0-alpha.11 → 5.0.0-alpha.14
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/LICENSE +1 -1
- package/README.md +180 -4
- package/bin/converter-v5.js +2 -0
- package/dist/converter.min.cjs +172 -182
- package/dist/i3s-server/bin/i3s-server.min.cjs +113 -158
- package/dist/index.cjs +18832 -19228
- package/dist/index.js +19566 -19968
- package/dist/v5/adapters.cjs +2002 -230
- package/dist/v5/adapters.d.ts +20 -0
- package/dist/v5/adapters.js +2005 -214
- package/dist/v5/archive-source.d.ts +36 -0
- package/dist/v5/browser-tileset-source.d.ts +55 -11
- package/dist/v5/browser.cjs +18 -0
- package/dist/v5/browser.d.ts +15 -1
- package/dist/v5/browser.js +26 -0
- package/dist/v5/conversion-api.d.ts +34 -0
- package/dist/v5/converter-cli.d.ts +1 -0
- package/dist/v5/converter-cli.js +1230 -0
- package/dist/v5/core.cjs +547 -77
- package/dist/v5/core.d.ts +3 -1
- package/dist/v5/core.js +540 -70
- package/dist/v5/feature-arrow.d.ts +1 -1
- package/dist/v5/i3s-mesh-conversion.d.ts +5 -1
- package/dist/v5/i3s-mesh-source-features.d.ts +2 -2
- package/dist/v5/i3s-mesh-source-material.d.ts +1 -1
- package/dist/v5/i3s-mesh-source.d.ts +2 -2
- package/dist/v5/i3s-selection-source.d.ts +70 -0
- package/dist/v5/index.cjs +15 -0
- package/dist/v5/index.d.ts +13 -1
- package/dist/v5/index.js +22 -0
- package/dist/v5/mesh-conversion.d.ts +21 -3
- package/dist/v5/mesh-draco.d.ts +2 -2
- package/dist/v5/mesh-features.d.ts +2 -2
- package/dist/v5/mesh-hierarchy.d.ts +47 -0
- package/dist/v5/mesh-source-features.d.ts +6 -5
- package/dist/v5/mesh-source-schema.d.ts +12 -0
- package/dist/v5/mesh-source-texture.d.ts +3 -3
- package/dist/v5/mesh-source.d.ts +10 -7
- package/dist/v5/mesh-tileset-sink.d.ts +5 -0
- package/dist/v5/mesh.d.ts +1 -1
- package/dist/v5/node-cli.d.ts +9 -0
- package/dist/v5/node-conversion.d.ts +34 -0
- package/dist/v5/node-feature-schema.d.ts +3 -0
- package/dist/v5/node-i3s-source.d.ts +41 -0
- package/dist/v5/node-source.d.ts +47 -0
- package/dist/v5/node.cjs +913 -0
- package/dist/v5/node.d.ts +6 -0
- package/dist/v5/node.js +890 -0
- package/dist/v5/point-cloud-attributes.d.ts +19 -0
- package/dist/v5/point-cloud-conversion.d.ts +1 -1
- package/dist/v5/point-cloud-copc.d.ts +44 -0
- package/dist/v5/point-cloud-file.d.ts +83 -0
- package/dist/v5/point-cloud-potree.d.ts +47 -0
- package/dist/v5/point-cloud-source-encoder.d.ts +1 -1
- package/dist/v5/point-cloud-source.d.ts +1 -1
- package/dist/v5/point-cloud-tileset.d.ts +44 -0
- package/dist/v5/point-cloud.d.ts +1 -1
- package/dist/v5/resource-manifest.d.ts +10 -1
- package/dist/v5/selected-mesh-source.d.ts +53 -0
- package/dist/v5/spatial-conversion.d.ts +1 -1
- package/dist/v5/tileset-source.d.ts +1 -1
- package/package.json +25 -32
- package/src/index.ts +4 -1
- package/src/v4/3d-tiles-converter/3d-tiles-converter.ts +11 -12
- package/src/v4/3d-tiles-converter/helpers/3d-tiles-content-converter.ts +7 -3
- package/src/v4/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.ts +2 -2
- package/src/v4/3d-tiles-converter/helpers/load-i3s.ts +4 -6
- package/src/v4/3d-tiles-converter/helpers/texture-atlas.ts +1 -1
- package/src/v4/3d-tiles-converter/helpers/validate-i3s-spatial-reference.ts +2 -2
- package/src/v4/3d-tiles-converter/json-templates/tileset.ts +58 -39
- package/src/v4/converter-cli.ts +10 -4
- package/src/v4/deps-installer/deps-installer.ts +3 -3
- package/src/v4/i3s-converter/helpers/attribute-metadata-info.ts +1 -1
- package/src/v4/i3s-converter/helpers/batch-ids-extensions.ts +9 -10
- package/src/v4/i3s-converter/helpers/conversion-gltf.ts +108 -0
- package/src/v4/i3s-converter/helpers/coordinate-converter.ts +6 -5
- package/src/v4/i3s-converter/helpers/create-scene-server-path.ts +5 -6
- package/src/v4/i3s-converter/helpers/feature-attributes.ts +4 -4
- package/src/v4/i3s-converter/helpers/geometry-attributes.ts +1 -1
- package/src/v4/i3s-converter/helpers/geometry-converter.ts +69 -77
- package/src/v4/i3s-converter/helpers/gltf-attributes.ts +58 -74
- package/src/v4/i3s-converter/helpers/load-3d-tiles.ts +6 -54
- package/src/v4/i3s-converter/helpers/node-debug.ts +7 -3
- package/src/v4/i3s-converter/helpers/node-index-document.ts +11 -9
- package/src/v4/i3s-converter/helpers/node-pages.ts +3 -4
- package/src/v4/i3s-converter/helpers/preprocess-3d-tiles.ts +2 -2
- package/src/v4/i3s-converter/helpers/tileset-traversal.ts +1 -1
- package/src/v4/i3s-converter/i3s-converter.ts +29 -31
- package/src/v4/i3s-converter/json-templates/geometry-definitions.ts +71 -66
- package/src/v4/i3s-converter/json-templates/layers.ts +97 -132
- package/src/v4/i3s-converter/json-templates/metadata.ts +31 -21
- package/src/v4/i3s-converter/json-templates/node.ts +60 -74
- package/src/v4/i3s-converter/json-templates/scene-server.ts +36 -27
- package/src/v4/i3s-converter/json-templates/shared-resources.ts +62 -123
- package/src/v4/i3s-converter/json-templates/store.ts +39 -57
- package/src/v4/i3s-converter/types.ts +4 -4
- package/src/v4/i3s-server/controllers/slpk-controller.ts +3 -3
- package/src/v4/i3s-server/utils/create-scene-server.ts +3 -3
- package/src/v4/lib/utils/builder-input.ts +8 -0
- package/src/v4/lib/utils/conversion-dump.ts +5 -1
- package/src/v4/lib/utils/file-utils.ts +1 -1
- package/src/v4/lib/utils/hash-string.ts +21 -0
- package/src/v4/lib/utils/lod-conversion-utils.ts +3 -3
- package/src/v4/pgm-loader.ts +2 -2
- package/src/v5/adapters.ts +53 -0
- package/src/v5/archive-source.ts +235 -0
- package/src/v5/browser-tileset-source.ts +418 -48
- package/src/v5/browser.ts +46 -0
- package/src/v5/conversion-api.ts +184 -17
- package/src/v5/conversion-archive.ts +2 -2
- package/src/v5/converter-cli.ts +28 -0
- package/src/v5/core.ts +7 -0
- package/src/v5/feature-arrow.ts +2 -2
- package/src/v5/i3s-mesh-conversion.ts +41 -3
- package/src/v5/i3s-mesh-sink.ts +1 -1
- package/src/v5/i3s-mesh-source-features.ts +3 -3
- package/src/v5/i3s-mesh-source-material.ts +18 -11
- package/src/v5/i3s-mesh-source.ts +3 -2
- package/src/v5/i3s-selection-source.ts +298 -0
- package/src/v5/index.ts +41 -0
- package/src/v5/mesh-conversion.ts +24 -4
- package/src/v5/mesh-draco.ts +2 -2
- package/src/v5/mesh-features.ts +3 -3
- package/src/v5/mesh-hierarchy.ts +648 -0
- package/src/v5/mesh-source-features.ts +165 -51
- package/src/v5/mesh-source-schema.ts +140 -0
- package/src/v5/mesh-source-texture.ts +49 -19
- package/src/v5/mesh-source.ts +80 -49
- package/src/v5/mesh-tileset-archive.ts +1 -1
- package/src/v5/mesh-tileset-sink.ts +2 -2
- package/src/v5/mesh.ts +1 -1
- package/src/v5/node-cli.ts +201 -0
- package/src/v5/node-conversion.ts +362 -0
- package/src/v5/node-feature-schema.ts +155 -0
- package/src/v5/node-i3s-source.ts +181 -0
- package/src/v5/node-source.ts +328 -0
- package/src/v5/node.ts +16 -0
- package/src/v5/point-cloud-attributes.ts +113 -0
- package/src/v5/point-cloud-conversion.ts +1 -1
- package/src/v5/point-cloud-copc.ts +289 -0
- package/src/v5/point-cloud-file.ts +306 -0
- package/src/v5/point-cloud-potree.ts +134 -0
- package/src/v5/point-cloud-source-encoder.ts +1 -1
- package/src/v5/point-cloud-source.ts +1 -1
- package/src/v5/point-cloud-spatial.ts +2 -2
- package/src/v5/point-cloud-tileset.ts +137 -0
- package/src/v5/point-cloud.ts +3 -3
- package/src/v5/resource-fetcher.ts +4 -1
- package/src/v5/resource-manifest.ts +40 -5
- package/src/v5/selected-mesh-source.ts +384 -0
- package/src/v5/spatial-conversion.ts +90 -19
- package/src/v5/tileset-source.ts +2 -2
|
@@ -1,42 +1,61 @@
|
|
|
1
|
-
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
version: {
|
|
5
|
-
path: 'version',
|
|
6
|
-
default: '1.0'
|
|
7
|
-
}
|
|
8
|
-
});
|
|
5
|
+
import type {BuilderInput} from '../../lib/utils/builder-input';
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
7
|
+
/** Tile asset metadata used by the legacy writer. */
|
|
8
|
+
export type TilesetAsset = {
|
|
9
|
+
/** Target version. */
|
|
10
|
+
version?: string;
|
|
11
|
+
};
|
|
12
|
+
/** Selected legacy tileset fields. */
|
|
13
|
+
export type TilesetTile = {
|
|
14
|
+
/** Bounding volume. */
|
|
15
|
+
boundingVolume?: unknown;
|
|
16
|
+
/** Geometric error. */
|
|
17
|
+
geometricError?: number;
|
|
18
|
+
/** Refinement policy. */
|
|
19
|
+
refine?: string;
|
|
20
|
+
/** Content link. */
|
|
21
|
+
content?: unknown;
|
|
22
|
+
/** Child tiles. */
|
|
23
|
+
children: TilesetTile[];
|
|
24
|
+
};
|
|
25
|
+
/** Input to the legacy tileset writer. */
|
|
26
|
+
export type TilesetInput = {
|
|
27
|
+
/** Asset metadata. */
|
|
28
|
+
asset: TilesetAsset;
|
|
29
|
+
/** Root tile. */
|
|
30
|
+
root: TilesetTile;
|
|
31
|
+
};
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
/** Builds asset with the legacy field selection and defaults. */
|
|
34
|
+
function createAsset(input: BuilderInput<TilesetAsset> | null | undefined) {
|
|
35
|
+
const source = input ?? {};
|
|
36
|
+
return {
|
|
37
|
+
version: source.version ?? '1.0'
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Builds tile with the legacy field selection and defaults. */
|
|
42
|
+
function createTile(input: BuilderInput<TilesetTile> | null | undefined): TilesetTile {
|
|
43
|
+
const source = input ?? {};
|
|
44
|
+
return {
|
|
45
|
+
boundingVolume: source.boundingVolume ?? undefined,
|
|
46
|
+
geometricError: source.geometricError ?? undefined,
|
|
47
|
+
refine: source.refine ?? undefined,
|
|
48
|
+
content: source.content ?? undefined,
|
|
49
|
+
children: source.children!.map(tile => createTile(tile))
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Builds tileset with the legacy field selection and defaults. */
|
|
54
|
+
export function createTileset(input: BuilderInput<TilesetInput> | null | undefined) {
|
|
55
|
+
const source = input ?? {};
|
|
56
|
+
return {
|
|
57
|
+
asset: createAsset(source.asset),
|
|
58
|
+
geometricError: source.root!.geometricError,
|
|
59
|
+
root: createTile(source.root)
|
|
60
|
+
};
|
|
61
|
+
}
|
package/src/v4/converter-cli.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
-
import '@loaders.gl/polyfills';
|
|
2
|
+
import '@loaders.gl/core/polyfills';
|
|
3
3
|
import {join} from 'path';
|
|
4
4
|
import inquirer from 'inquirer';
|
|
5
5
|
import {I3SConverter, Tiles3DConverter} from '@loaders.gl/tile-converter';
|
|
@@ -11,8 +11,8 @@ import {
|
|
|
11
11
|
getURLValue,
|
|
12
12
|
validateOptionsWithEqual
|
|
13
13
|
} from './lib/utils/cli-utils';
|
|
14
|
-
import {addOneFile, composeHashFile,
|
|
15
|
-
import {NodeFile} from '@loaders.gl/loader-utils';
|
|
14
|
+
import {addOneFile, composeHashFile, openZipArchive} from '@loaders.gl/archives/zip';
|
|
15
|
+
import {NodeFile} from '@loaders.gl/core/loader-utils';
|
|
16
16
|
// @ts-ignore
|
|
17
17
|
import {copyFile} from 'node:fs/promises';
|
|
18
18
|
|
|
@@ -141,7 +141,13 @@ async function main() {
|
|
|
141
141
|
if (finalPath !== validatedOptions.tileset) {
|
|
142
142
|
await copyFile(validatedOptions.tileset, finalPath);
|
|
143
143
|
}
|
|
144
|
-
const
|
|
144
|
+
const archive = await openZipArchive(new NodeFile(finalPath));
|
|
145
|
+
let hashTable: ArrayBuffer;
|
|
146
|
+
try {
|
|
147
|
+
hashTable = await composeHashFile(archive.entries());
|
|
148
|
+
} finally {
|
|
149
|
+
await archive.close();
|
|
150
|
+
}
|
|
145
151
|
await addOneFile(finalPath, hashTable, '@specialIndexFileHASH128@');
|
|
146
152
|
|
|
147
153
|
return;
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
// Copyright vis.gl contributors
|
|
4
4
|
|
|
5
5
|
import {load, fetchFile} from '@loaders.gl/core';
|
|
6
|
-
import {ZipLoader} from '@loaders.gl/zip';
|
|
6
|
+
import {ZipLoader} from '@loaders.gl/archives/zip';
|
|
7
7
|
import {writeFile} from '../lib/utils/file-utils';
|
|
8
8
|
import {join, dirname} from 'path';
|
|
9
|
-
import {ChildProcessProxy} from '@loaders.gl/worker-utils';
|
|
9
|
+
import {ChildProcessProxy} from '@loaders.gl/core/worker-utils';
|
|
10
10
|
import {DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS} from '@loaders.gl/draco';
|
|
11
11
|
import {BASIS_EXTERNAL_LIBRARIES} from '@loaders.gl/textures';
|
|
12
12
|
|
|
@@ -42,7 +42,7 @@ export class DepsInstaller {
|
|
|
42
42
|
await writeFile(depsPath, new Uint8Array(fileMap['geoids/egm2008-5.pgm']), 'egm2008-5.pgm');
|
|
43
43
|
|
|
44
44
|
console.log('Installing "I3S Content Loader" worker'); // eslint-disable-line no-console
|
|
45
|
-
await this.installFromNpm('
|
|
45
|
+
await this.installFromNpm('tiles-3d', 'i3s-content-worker-node.js');
|
|
46
46
|
|
|
47
47
|
console.log('Installing "Draco Loader" worker'); // eslint-disable-line no-console
|
|
48
48
|
await this.installFromNpm('draco', 'draco-worker-node.js');
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
+
import type {ConversionAccessor, ConversionPrimitive} from './conversion-gltf';
|
|
1
2
|
/* eslint-disable camelcase */
|
|
2
|
-
import type {NumericArray} from '@loaders.gl/loader-utils';
|
|
3
|
+
import type {NumericArray} from '@loaders.gl/core/loader-utils';
|
|
3
4
|
import type {
|
|
4
|
-
GLTFAccessorPostprocessed,
|
|
5
|
-
GLTFMeshPrimitivePostprocessed,
|
|
6
5
|
GLTF_EXT_feature_metadata_FeatureIdTexture,
|
|
7
6
|
GLTF_EXT_feature_metadata_GLTF,
|
|
8
7
|
GLTF_EXT_feature_metadata_Primitive,
|
|
9
8
|
GLTF_EXT_mesh_features
|
|
10
9
|
} from '@loaders.gl/gltf';
|
|
11
10
|
import {EXT_MESH_FEATURES, EXT_FEATURE_METADATA} from '@loaders.gl/gltf';
|
|
12
|
-
import {Tiles3DTileContent} from '@loaders.gl/3d-tiles';
|
|
13
|
-
import {emod} from '@math.gl/geometry
|
|
11
|
+
import {Tiles3DTileContent} from '@loaders.gl/tiles-3d/3d-tiles';
|
|
12
|
+
import {emod} from '@math.gl/geometry/utils';
|
|
14
13
|
import {TypedArray} from '@math.gl/core';
|
|
15
14
|
import {TextureImageProperties} from '../types';
|
|
16
15
|
|
|
@@ -27,7 +26,7 @@ export function getTextureByMetadataClass(
|
|
|
27
26
|
tileContent: Tiles3DTileContent,
|
|
28
27
|
metadataClass?: string
|
|
29
28
|
): string | null {
|
|
30
|
-
const extFeatureMetadata = tileContent.gltf?.extensions?.[
|
|
29
|
+
const extFeatureMetadata = tileContent.gltf?.json.extensions?.[
|
|
31
30
|
EXT_FEATURE_METADATA
|
|
32
31
|
] as GLTF_EXT_feature_metadata_GLTF;
|
|
33
32
|
if (!extFeatureMetadata?.featureTextures) {
|
|
@@ -52,9 +51,9 @@ export function getTextureByMetadataClass(
|
|
|
52
51
|
*/
|
|
53
52
|
export function handleBatchIdsExtensions(
|
|
54
53
|
attributes: {
|
|
55
|
-
[key: string]:
|
|
54
|
+
[key: string]: ConversionAccessor;
|
|
56
55
|
},
|
|
57
|
-
primitive:
|
|
56
|
+
primitive: ConversionPrimitive,
|
|
58
57
|
images: (TextureImageProperties | null)[],
|
|
59
58
|
featureTexture: string | null
|
|
60
59
|
): NumericArray {
|
|
@@ -90,7 +89,7 @@ export function handleBatchIdsExtensions(
|
|
|
90
89
|
*/
|
|
91
90
|
function handleExtMeshFeaturesExtension(
|
|
92
91
|
attributes: {
|
|
93
|
-
[key: string]:
|
|
92
|
+
[key: string]: ConversionAccessor;
|
|
94
93
|
},
|
|
95
94
|
extMeshFeatures: GLTF_EXT_mesh_features
|
|
96
95
|
): NumericArray {
|
|
@@ -114,7 +113,7 @@ function handleExtMeshFeaturesExtension(
|
|
|
114
113
|
*/
|
|
115
114
|
function handleExtFeatureMetadataExtension(
|
|
116
115
|
attributes: {
|
|
117
|
-
[key: string]:
|
|
116
|
+
[key: string]: ConversionAccessor;
|
|
118
117
|
},
|
|
119
118
|
extFeatureMetadata: GLTF_EXT_feature_metadata_Primitive,
|
|
120
119
|
images: (TextureImageProperties | null)[],
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
import {GLTFScenegraph, getGLTFAccessor, getGLTFAccessorValue} from '@loaders.gl/gltf';
|
|
6
|
+
import type {
|
|
7
|
+
GLTFWithBuffers,
|
|
8
|
+
GLTFAccessor,
|
|
9
|
+
GLTFNode,
|
|
10
|
+
GLTFMeshPrimitive,
|
|
11
|
+
GLTFMaterial,
|
|
12
|
+
GLTFTexture,
|
|
13
|
+
GLTFImage
|
|
14
|
+
} from '@loaders.gl/gltf';
|
|
15
|
+
import type {TypedArray} from '@math.gl/core';
|
|
16
|
+
|
|
17
|
+
/** Packed geometry passed to the legacy conversion worker, independent of scene JSON. */
|
|
18
|
+
export type ConversionAccessor = Omit<GLTFAccessor, 'bufferView' | 'sparse'> & {
|
|
19
|
+
value: TypedArray;
|
|
20
|
+
components: number;
|
|
21
|
+
};
|
|
22
|
+
/** Selected primitive data consumed by conversion workers. */
|
|
23
|
+
export type ConversionPrimitive = Omit<GLTFMeshPrimitive, 'attributes' | 'indices' | 'material'> & {
|
|
24
|
+
attributes: Record<string, ConversionAccessor>;
|
|
25
|
+
indices?: ConversionAccessor;
|
|
26
|
+
material?: ConversionMaterial;
|
|
27
|
+
};
|
|
28
|
+
/** Selected mesh data consumed by conversion workers. */
|
|
29
|
+
export type ConversionMesh = {primitives: ConversionPrimitive[]};
|
|
30
|
+
/** Tree of placements passed to a conversion worker. */
|
|
31
|
+
export type ConversionNode = Omit<GLTFNode, 'mesh' | 'children'> & {
|
|
32
|
+
mesh?: ConversionMesh;
|
|
33
|
+
children?: ConversionNode[];
|
|
34
|
+
};
|
|
35
|
+
/** Decoded image and optional encoded storage needed by the I3S writer. */
|
|
36
|
+
export type ConversionImage = Omit<GLTFImage, 'bufferView'> & {
|
|
37
|
+
image: any;
|
|
38
|
+
bufferView?: {data: Uint8Array};
|
|
39
|
+
};
|
|
40
|
+
/** Selected texture data needed by the I3S writer. */
|
|
41
|
+
export type ConversionTexture = Omit<GLTFTexture, 'source' | 'sampler'> & {
|
|
42
|
+
source?: ConversionImage;
|
|
43
|
+
};
|
|
44
|
+
/** Selected material data needed by the I3S writer. */
|
|
45
|
+
export type ConversionMaterial = Omit<GLTFMaterial, 'pbrMetallicRoughness' | 'emissiveTexture'> & {
|
|
46
|
+
id: string;
|
|
47
|
+
uniqueId?: string;
|
|
48
|
+
pbrMetallicRoughness?: Omit<
|
|
49
|
+
NonNullable<GLTFMaterial['pbrMetallicRoughness']>,
|
|
50
|
+
'baseColorTexture'
|
|
51
|
+
> & {baseColorTexture?: {texture: ConversionTexture}};
|
|
52
|
+
emissiveTexture?: {texture: ConversionTexture};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/** Select decoded accessor data for the conversion worker without linking glTF resources. */
|
|
56
|
+
export function getConversionAccessor(
|
|
57
|
+
gltf: GLTFWithBuffers,
|
|
58
|
+
reference: number | GLTFAccessor
|
|
59
|
+
): ConversionAccessor {
|
|
60
|
+
const accessor = getGLTFAccessor(gltf, reference);
|
|
61
|
+
const {bufferView, sparse, ...metadata} = accessor;
|
|
62
|
+
const source = getGLTFAccessorValue(gltf, reference);
|
|
63
|
+
// Invoke the intrinsic typed-array copy; Node Buffer.slice() would retain borrowed storage.
|
|
64
|
+
const value = Uint8Array.prototype.slice.call(source) as TypedArray;
|
|
65
|
+
return {
|
|
66
|
+
...metadata,
|
|
67
|
+
value,
|
|
68
|
+
components: accessor.type === 'SCALAR' ? 1 : Number(accessor.type.slice(3))
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Resolve only the image and texture fields used by the legacy I3S material writer. */
|
|
73
|
+
export function getConversionMaterials(gltf: GLTFWithBuffers): ConversionMaterial[] {
|
|
74
|
+
const scenegraph = new GLTFScenegraph(gltf);
|
|
75
|
+
const getTexture = (index: number): ConversionTexture => {
|
|
76
|
+
const texture = gltf.json.textures![index];
|
|
77
|
+
const image = texture.source === undefined ? undefined : gltf.json.images?.[texture.source];
|
|
78
|
+
return {
|
|
79
|
+
...texture,
|
|
80
|
+
sampler: undefined,
|
|
81
|
+
source: image
|
|
82
|
+
? {
|
|
83
|
+
...image,
|
|
84
|
+
image: gltf.images?.[texture.source!],
|
|
85
|
+
bufferView:
|
|
86
|
+
image.bufferView === undefined
|
|
87
|
+
? undefined
|
|
88
|
+
: {data: scenegraph.getTypedArrayForBufferView(image.bufferView)}
|
|
89
|
+
}
|
|
90
|
+
: undefined
|
|
91
|
+
} as ConversionTexture;
|
|
92
|
+
};
|
|
93
|
+
return (gltf.json.materials || []).map((material, index) => ({
|
|
94
|
+
...material,
|
|
95
|
+
id: String(index),
|
|
96
|
+
pbrMetallicRoughness: material.pbrMetallicRoughness
|
|
97
|
+
? {
|
|
98
|
+
...material.pbrMetallicRoughness,
|
|
99
|
+
baseColorTexture: material.pbrMetallicRoughness.baseColorTexture
|
|
100
|
+
? {texture: getTexture(material.pbrMetallicRoughness.baseColorTexture.index)}
|
|
101
|
+
: undefined
|
|
102
|
+
}
|
|
103
|
+
: undefined,
|
|
104
|
+
emissiveTexture: material.emissiveTexture
|
|
105
|
+
? {texture: getTexture(material.emissiveTexture.index)}
|
|
106
|
+
: undefined
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type {BoundingVolumes, FullExtent, Mbs, Obb} from '@loaders.gl/i3s';
|
|
1
|
+
import type {BoundingVolumes, FullExtent, Mbs, Obb} from '@loaders.gl/tiles-3d/i3s';
|
|
2
2
|
|
|
3
3
|
import {Matrix3, Quaternion, Vector3} from '@math.gl/core';
|
|
4
4
|
import {Ellipsoid} from '@math.gl/geospatial';
|
|
5
5
|
import {
|
|
6
6
|
OrientedBoundingBox,
|
|
7
7
|
makeOrientedBoundingBoxFromPoints,
|
|
8
|
+
getOrientedBoundingBoxQuaternion,
|
|
8
9
|
makeBoundingSphereFromPoints,
|
|
9
10
|
BoundingSphere
|
|
10
|
-
} from '@math.gl/culling';
|
|
11
|
-
import {Geoid} from '@math.gl/geoid';
|
|
11
|
+
} from '@math.gl/geometry/culling';
|
|
12
|
+
import {Geoid} from '@math.gl/earth/geoid';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Create bounding volumes object from tile and geoid height model.
|
|
@@ -38,7 +39,7 @@ export function createBoundingVolumes(
|
|
|
38
39
|
if (sourceBoundingVolume instanceof OrientedBoundingBox) {
|
|
39
40
|
halfSize = sourceBoundingVolume.halfSize;
|
|
40
41
|
radius = new Vector3(halfSize[0], halfSize[1], halfSize[2]).len();
|
|
41
|
-
quaternion = sourceBoundingVolume
|
|
42
|
+
quaternion = getOrientedBoundingBoxQuaternion(sourceBoundingVolume);
|
|
42
43
|
} else {
|
|
43
44
|
radius = sourceBoundingVolume.radius;
|
|
44
45
|
halfSize = [radius, radius, radius];
|
|
@@ -84,7 +85,7 @@ export function createBoundingVolumesFromGeometry(
|
|
|
84
85
|
obb: {
|
|
85
86
|
center: obbCenter,
|
|
86
87
|
halfSize: geometryObb.halfSize,
|
|
87
|
-
quaternion: geometryObb
|
|
88
|
+
quaternion: getOrientedBoundingBoxQuaternion(geometryObb)
|
|
88
89
|
}
|
|
89
90
|
};
|
|
90
91
|
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type {SceneLayer3D} from '@loaders.gl/i3s';
|
|
2
|
-
import {
|
|
3
|
-
import transform from 'json-map-transform';
|
|
1
|
+
import type {SceneLayer3D} from '@loaders.gl/tiles-3d/i3s';
|
|
2
|
+
import {randomUUID} from 'node:crypto';
|
|
4
3
|
import {join} from 'path';
|
|
5
4
|
|
|
6
|
-
import {
|
|
5
|
+
import {createSceneServer} from '../json-templates/scene-server';
|
|
7
6
|
import {writeFile} from '../../lib/utils/file-utils';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -18,12 +17,12 @@ export async function createSceneServerPath(
|
|
|
18
17
|
rootPath: string
|
|
19
18
|
): Promise<void> {
|
|
20
19
|
const sceneServerData = {
|
|
21
|
-
serviceItemId:
|
|
20
|
+
serviceItemId: randomUUID().replace(/-/gi, ''),
|
|
22
21
|
layerName,
|
|
23
22
|
layers0
|
|
24
23
|
};
|
|
25
24
|
|
|
26
|
-
const sceneServer =
|
|
25
|
+
const sceneServer = createSceneServer(sceneServerData);
|
|
27
26
|
const nodePagePath = join(rootPath, 'SceneServer');
|
|
28
27
|
await writeFile(nodePagePath, JSON.stringify(sceneServer));
|
|
29
28
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* eslint-disable camelcase */
|
|
2
|
-
import type {FeatureTableJson} from '@loaders.gl/3d-tiles';
|
|
3
|
-
import type {Attribute} from '@loaders.gl/i3s';
|
|
2
|
+
import type {FeatureTableJson} from '@loaders.gl/tiles-3d/3d-tiles';
|
|
3
|
+
import type {Attribute} from '@loaders.gl/tiles-3d/i3s';
|
|
4
4
|
import type {
|
|
5
|
-
|
|
5
|
+
GLTF,
|
|
6
6
|
GLTF_EXT_feature_metadata_GLTF,
|
|
7
7
|
GLTF_EXT_feature_metadata_ClassProperty,
|
|
8
8
|
GLTF_EXT_structural_metadata_GLTF,
|
|
@@ -130,7 +130,7 @@ export function getAttributeTypesMapFromPropertyTable(
|
|
|
130
130
|
* }
|
|
131
131
|
*/
|
|
132
132
|
export const getAttributeTypesMapFromSchema = (
|
|
133
|
-
gltfJson:
|
|
133
|
+
gltfJson: GLTF,
|
|
134
134
|
metadataClass: string
|
|
135
135
|
): Record<string, Attribute> | null => {
|
|
136
136
|
const attributeTypesMap: Record<string, Attribute> = {};
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
GroupedByFeatureIdAttributes,
|
|
5
5
|
GroupedAttributes
|
|
6
6
|
} from '../types';
|
|
7
|
-
import {concatenateTypedArrays} from '@loaders.gl/loader-utils';
|
|
7
|
+
import {concatenateTypedArrays} from '@loaders.gl/core/loader-utils';
|
|
8
8
|
|
|
9
9
|
const VALUES_PER_VERTEX = 3;
|
|
10
10
|
const POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;
|