@loaders.gl/tile-converter 4.0.0-alpha.18 → 4.0.0-alpha.20
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/bin/converter.js +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -1
- package/dist/converter-cli.js +10 -2
- package/dist/converter.min.js +172 -103
- package/dist/deps-installer/deps-installer.d.ts +3 -2
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +36 -10
- package/dist/dist.min.js +226 -151
- package/dist/es5/constants.js +5 -1
- package/dist/es5/constants.js.map +1 -1
- package/dist/es5/converter-cli.js +7 -2
- package/dist/es5/converter-cli.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +112 -38
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +21 -8
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +7 -6
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +78 -67
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +38 -9
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +86 -99
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/types.js +11 -11
- package/dist/es5/i3s-converter/types.js.map +1 -1
- package/dist/es5/i3s-server/controllers/slpk-controller.js +1 -1
- package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/es5/index.js +3 -3
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +9 -9
- package/dist/es5/slpk-extractor/helpers/file-handle-file.js.map +1 -0
- package/dist/es5/slpk-extractor/slpk-extractor.js +5 -5
- package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -1
- package/dist/esm/constants.js +2 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/converter-cli.js +7 -2
- package/dist/esm/converter-cli.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +37 -11
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +18 -6
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +7 -6
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +37 -25
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +28 -9
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +49 -36
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/types.js +9 -9
- package/dist/esm/i3s-converter/types.js.map +1 -1
- package/dist/esm/i3s-server/bin/i3s-server.min.js +71 -71
- package/dist/esm/i3s-server/controllers/slpk-controller.js +2 -2
- package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +3 -3
- package/dist/esm/slpk-extractor/helpers/file-handle-file.js.map +1 -0
- package/dist/esm/slpk-extractor/slpk-extractor.js +3 -3
- package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +11 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +33 -13
- package/dist/i3s-converter/helpers/geometry-attributes.js +7 -6
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +7 -6
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +59 -47
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +2 -2
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +39 -14
- package/dist/i3s-converter/i3s-converter.d.ts +2 -1
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +49 -31
- package/dist/i3s-converter/types.d.ts +4 -2
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/i3s-converter/types.js +11 -11
- package/dist/i3s-server/controllers/slpk-controller.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/slpk-extractor/helpers/{file-handle-provider.d.ts → file-handle-file.d.ts} +5 -5
- package/dist/slpk-extractor/helpers/file-handle-file.d.ts.map +1 -0
- package/dist/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +5 -5
- package/dist/slpk-extractor/slpk-extractor.js +5 -5
- package/dist/slpk-extractor.min.js +32 -32
- package/package.json +15 -14
- package/src/constants.ts +3 -0
- package/src/converter-cli.ts +9 -2
- package/src/deps-installer/deps-installer.ts +55 -10
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +39 -12
- package/src/i3s-converter/helpers/geometry-attributes.ts +15 -8
- package/src/i3s-converter/helpers/geometry-converter.ts +84 -48
- package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +48 -18
- package/src/i3s-converter/i3s-converter.ts +65 -39
- package/src/i3s-converter/types.ts +4 -2
- package/src/i3s-server/controllers/slpk-controller.ts +2 -2
- package/src/index.ts +1 -1
- package/src/slpk-extractor/helpers/{file-handle-provider.ts → file-handle-file.ts} +5 -5
- package/src/slpk-extractor/slpk-extractor.ts +3 -3
- package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
- package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
- package/dist/slpk-extractor/helpers/file-handle-provider.d.ts.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import '@loaders.gl/polyfills';
|
|
2
2
|
import { parseSLPK } from '@loaders.gl/i3s';
|
|
3
|
-
import {
|
|
3
|
+
import { FileHandleFile } from '@loaders.gl/tile-converter';
|
|
4
4
|
let slpkArchive;
|
|
5
5
|
export const loadArchive = async fullLayerPath => {
|
|
6
|
-
slpkArchive = await parseSLPK(await
|
|
6
|
+
slpkArchive = await parseSLPK(await FileHandleFile.from(fullLayerPath), msg => console.log(msg));
|
|
7
7
|
console.log('The server is ready to use');
|
|
8
8
|
};
|
|
9
9
|
export async function getFileByUrl(url) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slpk-controller.js","names":["parseSLPK","
|
|
1
|
+
{"version":3,"file":"slpk-controller.js","names":["parseSLPK","FileHandleFile","slpkArchive","loadArchive","fullLayerPath","from","msg","console","log","getFileByUrl","url","trimmedPath","exec","uncompressedFile","Buffer","getFile","e"],"sources":["../../../../src/i3s-server/controllers/slpk-controller.ts"],"sourcesContent":["import '@loaders.gl/polyfills';\nimport {parseSLPK} from '@loaders.gl/i3s';\nimport {FileHandleFile} from '@loaders.gl/tile-converter';\n\nlet slpkArchive;\n\n/**\n * Open SLPK file for reading and load HASH file\n * @param fullLayerPath - full path to SLPK file\n */\nexport const loadArchive = async (fullLayerPath: string): Promise<void> => {\n slpkArchive = await parseSLPK(await FileHandleFile.from(fullLayerPath), (msg) =>\n console.log(msg)\n );\n console.log('The server is ready to use');\n};\n\n/**\n * Get a file from SLPK\n * @param url - I3S HTTP URL\n * @returns - file content\n */\nexport async function getFileByUrl(url: string) {\n const trimmedPath = /^\\/?(.*)\\/?$/.exec(url);\n let uncompressedFile: Buffer | null = null;\n if (trimmedPath) {\n try {\n uncompressedFile = Buffer.from(await slpkArchive.getFile(trimmedPath[1], 'http'));\n } catch (e) {}\n }\n return uncompressedFile;\n}\n"],"mappings":"AAAA,OAAO,uBAAuB;AAC9B,SAAQA,SAAS,QAAO,iBAAiB;AACzC,SAAQC,cAAc,QAAO,4BAA4B;AAEzD,IAAIC,WAAW;AAMf,OAAO,MAAMC,WAAW,GAAG,MAAOC,aAAqB,IAAoB;EACzEF,WAAW,GAAG,MAAMF,SAAS,CAAC,MAAMC,cAAc,CAACI,IAAI,CAACD,aAAa,CAAC,EAAGE,GAAG,IAC1EC,OAAO,CAACC,GAAG,CAACF,GAAG,CACjB,CAAC;EACDC,OAAO,CAACC,GAAG,CAAC,4BAA4B,CAAC;AAC3C,CAAC;AAOD,OAAO,eAAeC,YAAYA,CAACC,GAAW,EAAE;EAC9C,MAAMC,WAAW,GAAG,cAAc,CAACC,IAAI,CAACF,GAAG,CAAC;EAC5C,IAAIG,gBAA+B,GAAG,IAAI;EAC1C,IAAIF,WAAW,EAAE;IACf,IAAI;MACFE,gBAAgB,GAAGC,MAAM,CAACT,IAAI,CAAC,MAAMH,WAAW,CAACa,OAAO,CAACJ,WAAW,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACnF,CAAC,CAAC,OAAOK,CAAC,EAAE,CAAC;EACf;EACA,OAAOH,gBAAgB;AACzB"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as I3SConverter } from './i3s-converter/i3s-converter';
|
|
2
2
|
export { default as Tiles3DConverter } from './3d-tiles-converter/3d-tiles-converter';
|
|
3
|
-
export {
|
|
3
|
+
export { FileHandleFile } from './slpk-extractor/helpers/file-handle-file';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","I3SConverter","Tiles3DConverter","
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","I3SConverter","Tiles3DConverter","FileHandleFile"],"sources":["../../src/index.ts"],"sourcesContent":["export {default as I3SConverter} from './i3s-converter/i3s-converter';\nexport {default as Tiles3DConverter} from './3d-tiles-converter/3d-tiles-converter';\nexport {FileHandleFile} from './slpk-extractor/helpers/file-handle-file';\n"],"mappings":"AAAA,SAAQA,OAAO,IAAIC,YAAY,QAAO,+BAA+B;AACrE,SAAQD,OAAO,IAAIE,gBAAgB,QAAO,yCAAyC;AACnF,SAAQC,cAAc,QAAO,2CAA2C"}
|
package/dist/esm/pgm-loader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parsePGM } from '@math.gl/geoid';
|
|
2
|
-
const VERSION = typeof "4.0.0-alpha.
|
|
2
|
+
const VERSION = typeof "4.0.0-alpha.20" !== 'undefined' ? "4.0.0-alpha.20" : 'latest';
|
|
3
3
|
export const PGMLoader = {
|
|
4
4
|
name: 'PGM - Netpbm grayscale image format',
|
|
5
5
|
id: 'pgm',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { FileHandle } from './fs-promises';
|
|
3
|
-
export class
|
|
3
|
+
export class FileHandleFile {
|
|
4
4
|
static async from(path) {
|
|
5
5
|
const fileDescriptor = await FileHandle.open(path);
|
|
6
|
-
return new
|
|
6
|
+
return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);
|
|
7
7
|
}
|
|
8
8
|
constructor(fileDescriptor, size) {
|
|
9
9
|
_defineProperty(this, "fileDescriptor", void 0);
|
|
@@ -51,4 +51,4 @@ export class FileHandleProvider {
|
|
|
51
51
|
return this.size;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
//# sourceMappingURL=file-handle-
|
|
54
|
+
//# sourceMappingURL=file-handle-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-handle-file.js","names":["FileHandle","FileHandleFile","from","path","fileDescriptor","open","stat","size","constructor","_defineProperty","getUint8","offset","val","Uint8Array","read","Buffer","alloc","buffer","at","undefined","Error","getUint16","Uint16Array","getUint32","Uint32Array","getBigUint64","BigInt64Array","slice","startOffsset","endOffset","bigLength","Number","MAX_SAFE_INTEGER","length"],"sources":["../../../../src/slpk-extractor/helpers/file-handle-file.ts"],"sourcesContent":["import {FileProvider} from '@loaders.gl/zip';\nimport {FileHandle} from './fs-promises';\n\n/**\n * Provides file data using node fs library\n */\nexport class FileHandleFile implements FileProvider {\n /**\n * Returns a new copy of FileHandleFile\n * @param path The path to the file in file system\n */\n static async from(path: string): Promise<FileHandleFile> {\n const fileDescriptor = await FileHandle.open(path);\n return new FileHandleFile(fileDescriptor, fileDescriptor.stat.size);\n }\n\n /**\n * The FileHandle from which data is provided\n */\n private fileDescriptor: FileHandle;\n\n /**\n * The file length in bytes\n */\n private size: bigint;\n\n private constructor(fileDescriptor: FileHandle, size: bigint) {\n this.fileDescriptor = fileDescriptor;\n this.size = size;\n }\n\n /**\n * Gets an unsigned 8-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint8(offset: bigint): Promise<number> {\n const val = new Uint8Array(\n (await this.fileDescriptor.read(Buffer.alloc(1), 0, 1, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 16-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint16(offset: bigint): Promise<number> {\n const val = new Uint16Array(\n (await this.fileDescriptor.read(Buffer.alloc(2), 0, 2, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getUint32(offset: bigint): Promise<number> {\n const val = new Uint32Array(\n (await this.fileDescriptor.read(Buffer.alloc(4), 0, 4, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * Gets an unsigned 32-bit integer at the specified byte offset from the start of the file.\n * @param offset The offset, in bytes, from the start of the file where to read the data.\n */\n async getBigUint64(offset: bigint): Promise<bigint> {\n const val = new BigInt64Array(\n (await this.fileDescriptor.read(Buffer.alloc(8), 0, 8, offset)).buffer.buffer\n ).at(0);\n if (val === undefined) {\n throw new Error('something went wrong');\n }\n return val;\n }\n\n /**\n * returns an ArrayBuffer whose contents are a copy of this file bytes from startOffset, inclusive, up to endOffset, exclusive.\n * @param startOffsset The offset, in byte, from the start of the file where to start reading the data.\n * @param endOffset The offset, in bytes, from the start of the file where to end reading the data.\n */\n async slice(startOffsset: bigint, endOffset: bigint): Promise<ArrayBuffer> {\n const bigLength = endOffset - startOffsset;\n if (bigLength > Number.MAX_SAFE_INTEGER) {\n throw new Error('too big slice');\n }\n const length = Number(bigLength);\n return (await this.fileDescriptor.read(Buffer.alloc(length), 0, length, startOffsset)).buffer\n .buffer;\n }\n\n /**\n * the length (in bytes) of the data.\n */\n get length(): bigint {\n return this.size;\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { isBrowser } from '@loaders.gl/core';
|
|
2
2
|
import { BROWSER_ERROR_MESSAGE } from '../constants';
|
|
3
|
-
import {
|
|
4
|
-
import { parseZipLocalFileHeader } from '@loaders.gl/i3s';
|
|
3
|
+
import { FileHandleFile } from './helpers/file-handle-file';
|
|
5
4
|
import { path } from '@loaders.gl/loader-utils';
|
|
5
|
+
import { parseZipLocalFileHeader } from '@loaders.gl/zip';
|
|
6
6
|
import { GZipCompression } from '@loaders.gl/compression';
|
|
7
7
|
import { writeFile } from '../lib/utils/file-utils';
|
|
8
8
|
const indexNames = ['3dSceneLayer.json.gz', '3dNodeIndexDocument.json.gz', 'sharedResource.json.gz'];
|
|
@@ -15,7 +15,7 @@ export default class SLPKConverter {
|
|
|
15
15
|
const {
|
|
16
16
|
inputUrl
|
|
17
17
|
} = options;
|
|
18
|
-
const provider = await
|
|
18
|
+
const provider = await FileHandleFile.from(inputUrl);
|
|
19
19
|
let localHeader = await parseZipLocalFileHeader(0n, provider);
|
|
20
20
|
while (localHeader) {
|
|
21
21
|
var _localHeader;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slpk-extractor.js","names":["isBrowser","BROWSER_ERROR_MESSAGE","
|
|
1
|
+
{"version":3,"file":"slpk-extractor.js","names":["isBrowser","BROWSER_ERROR_MESSAGE","FileHandleFile","path","parseZipLocalFileHeader","GZipCompression","writeFile","indexNames","SLPKConverter","extract","options","console","log","inputUrl","provider","from","localHeader","_localHeader","unGzip","name","correctIndexNames","fileName","data","slice","fileDataOffset","compressedSize","outputPath","includes","filename","join","dirname","parts","exec","concat","at","file","_file$name","test","_file$name2","compression","decompressedData","decompress","Promise","resolve","finalPath","dirName"],"sources":["../../../src/slpk-extractor/slpk-extractor.ts"],"sourcesContent":["import {isBrowser} from '@loaders.gl/core';\n\nimport {BROWSER_ERROR_MESSAGE} from '../constants';\nimport {FileHandleFile} from './helpers/file-handle-file';\nimport {path} from '@loaders.gl/loader-utils';\nimport {parseZipLocalFileHeader} from '@loaders.gl/zip';\nimport {GZipCompression} from '@loaders.gl/compression';\nimport {writeFile} from '../lib/utils/file-utils';\n\nconst indexNames = [\n '3dSceneLayer.json.gz',\n '3dNodeIndexDocument.json.gz',\n 'sharedResource.json.gz'\n];\n\n/**\n * Description of the file in the SLPK\n */\ntype File = {\n name: string | null;\n data: ArrayBuffer;\n};\n\n/**\n * Converter from slpk to i3s\n */\nexport default class SLPKConverter {\n /**\n * Extract slpk to i3s\n * @param options\n * @param options.inputUrl the url to read SLPK file\n * @param options.outputPath the output filename\n */\n public async extract(options: {inputUrl: string; outputPath: string}): Promise<string> {\n if (isBrowser) {\n console.log(BROWSER_ERROR_MESSAGE);\n return BROWSER_ERROR_MESSAGE;\n }\n const {inputUrl} = options;\n\n const provider = await FileHandleFile.from(inputUrl);\n\n let localHeader = await parseZipLocalFileHeader(0n, provider);\n while (localHeader) {\n await this.writeFile(\n await this.unGzip({\n name: this.correctIndexNames(localHeader.fileName),\n data: await provider.slice(\n localHeader.fileDataOffset,\n localHeader.fileDataOffset + localHeader.compressedSize\n )\n }),\n options.outputPath\n );\n localHeader = await parseZipLocalFileHeader(\n localHeader.fileDataOffset + localHeader?.compressedSize,\n provider\n );\n }\n\n return 'success';\n }\n\n /**\n * Defines file name and path for i3s format\n * @param fileName initial file name and path\n */\n\n private correctIndexNames(fileName: string): string | null {\n if (indexNames.includes(path.filename(path.join('/', fileName)))) {\n return path.join(path.dirname(fileName), 'index.json.gz');\n }\n // finds path with name part and extention part\n let parts = /^(.*\\/[^\\/\\.]*)(\\..+)$/.exec(fileName);\n if (!parts) {\n return null;\n }\n return `${parts?.at(1)}/index${parts?.at(2)}`;\n }\n\n private async unGzip(file: File): Promise<File> {\n if (/\\.gz$/.test(file.name ?? '')) {\n const compression = new GZipCompression();\n\n const decompressedData = await compression.decompress(file.data);\n\n return {data: decompressedData, name: (file.name ?? '').slice(0, -3)};\n }\n return Promise.resolve(file);\n }\n\n private async writeFile(options: File, outputPath: string): Promise<void> {\n if (!options.name) {\n return;\n }\n const finalPath = path.join(outputPath, options.name);\n const dirName = path.dirname(finalPath);\n const fileName = path.filename(finalPath);\n await writeFile(dirName, options.data, fileName);\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { GLTFAccessorPostprocessed, GLTFMeshPrimitivePostprocessed } from '@loaders.gl/gltf';
|
|
2
2
|
import type { NumericArray } from '@loaders.gl/loader-utils';
|
|
3
3
|
import { TextureImageProperties } from '../types';
|
|
4
|
+
import { Tiles3DTileContent } from '@loaders.gl/3d-tiles';
|
|
5
|
+
/**
|
|
6
|
+
* Get featureTexture by metadataClass
|
|
7
|
+
* @param tileContent - 3d tile content
|
|
8
|
+
* @param metadataClass - user selected feature metadata class name
|
|
9
|
+
* @returns featureTexture key
|
|
10
|
+
*/
|
|
11
|
+
export declare function getTextureByMetadataClass(tileContent: Tiles3DTileContent, metadataClass?: string): string | null;
|
|
4
12
|
/**
|
|
5
13
|
* Getting batchIds from 3DTilesNext extensions.
|
|
6
14
|
* @param attributes - gltf accessors
|
|
7
15
|
* @param primitive - gltf primitive data
|
|
8
16
|
* @param images - gltf texture images
|
|
17
|
+
* @param featureTexture - feature texture key
|
|
18
|
+
* @return array of batch IDs
|
|
9
19
|
*/
|
|
10
20
|
export declare function handleBatchIdsExtensions(attributes: {
|
|
11
21
|
[key: string]: GLTFAccessorPostprocessed;
|
|
12
|
-
}, primitive: GLTFMeshPrimitivePostprocessed, images: (TextureImageProperties | null)[]): NumericArray;
|
|
22
|
+
}, primitive: GLTFMeshPrimitivePostprocessed, images: (TextureImageProperties | null)[], featureTexture: string | null): NumericArray;
|
|
13
23
|
//# sourceMappingURL=batch-ids-extensions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-ids-extensions.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/batch-ids-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,yBAAyB,EAAE,8BAA8B,EAAC,MAAM,kBAAkB,CAAC;AAC3F,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"batch-ids-extensions.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/batch-ids-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,yBAAyB,EAAE,8BAA8B,EAAC,MAAM,kBAAkB,CAAC;AAC3F,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAO3D,OAAO,EAAC,sBAAsB,EAAC,MAAM,UAAU,CAAC;AAEhD,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAExD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,kBAAkB,EAC/B,aAAa,CAAC,EAAE,MAAM,GACrB,MAAM,GAAG,IAAI,CAcf;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,UAAU,EAAE;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,yBAAyB,CAAC;CAC1C,EACD,SAAS,EAAE,8BAA8B,EACzC,MAAM,EAAE,CAAC,sBAAsB,GAAG,IAAI,CAAC,EAAE,EACzC,cAAc,EAAE,MAAM,GAAG,IAAI,GAC5B,YAAY,CAyBd"}
|
|
@@ -1,24 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handleBatchIdsExtensions = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
3
|
+
exports.handleBatchIdsExtensions = exports.getTextureByMetadataClass = void 0;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
/**
|
|
6
|
+
* Get featureTexture by metadataClass
|
|
7
|
+
* @param tileContent - 3d tile content
|
|
8
|
+
* @param metadataClass - user selected feature metadata class name
|
|
9
|
+
* @returns featureTexture key
|
|
10
|
+
*/
|
|
11
|
+
function getTextureByMetadataClass(tileContent, metadataClass) {
|
|
12
|
+
const extFeatureMetadata = tileContent.gltf?.extensions?.[constants_1.EXT_FEATURE_METADATA];
|
|
13
|
+
if (!extFeatureMetadata?.featureTextures) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
for (const textureKey in extFeatureMetadata.featureTextures) {
|
|
17
|
+
const texture = extFeatureMetadata.featureTextures[textureKey];
|
|
18
|
+
if (texture.class === metadataClass) {
|
|
19
|
+
return textureKey;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
exports.getTextureByMetadataClass = getTextureByMetadataClass;
|
|
6
25
|
/**
|
|
7
26
|
* Getting batchIds from 3DTilesNext extensions.
|
|
8
27
|
* @param attributes - gltf accessors
|
|
9
28
|
* @param primitive - gltf primitive data
|
|
10
29
|
* @param images - gltf texture images
|
|
30
|
+
* @param featureTexture - feature texture key
|
|
31
|
+
* @return array of batch IDs
|
|
11
32
|
*/
|
|
12
|
-
function handleBatchIdsExtensions(attributes, primitive, images) {
|
|
33
|
+
function handleBatchIdsExtensions(attributes, primitive, images, featureTexture) {
|
|
13
34
|
const extensions = primitive?.extensions;
|
|
14
35
|
if (!extensions) {
|
|
15
36
|
return [];
|
|
16
37
|
}
|
|
17
38
|
for (const [extensionName, extensionData] of Object.entries(extensions || {})) {
|
|
18
39
|
switch (extensionName) {
|
|
19
|
-
case EXT_FEATURE_METADATA:
|
|
20
|
-
return handleExtFeatureMetadataExtension(attributes, extensionData, images);
|
|
21
|
-
case EXT_MESH_FEATURES:
|
|
40
|
+
case constants_1.EXT_FEATURE_METADATA:
|
|
41
|
+
return handleExtFeatureMetadataExtension(attributes, extensionData, images, featureTexture);
|
|
42
|
+
case constants_1.EXT_MESH_FEATURES:
|
|
22
43
|
console.warn('EXT_mesh_features extension is not supported yet');
|
|
23
44
|
return [];
|
|
24
45
|
default:
|
|
@@ -31,11 +52,12 @@ exports.handleBatchIdsExtensions = handleBatchIdsExtensions;
|
|
|
31
52
|
/**
|
|
32
53
|
* Get batchIds from EXT_feature_metadata extension.
|
|
33
54
|
* Docs - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata
|
|
34
|
-
* @param attributes
|
|
35
|
-
* @param extFeatureMetadata
|
|
36
|
-
* @param textures
|
|
55
|
+
* @param attributes - glTF attributes
|
|
56
|
+
* @param extFeatureMetadata - primitive-level EXT_FEATURE_METADATA extension data
|
|
57
|
+
* @param textures - texture images
|
|
58
|
+
* @param featureTexture - feature texture key
|
|
37
59
|
*/
|
|
38
|
-
function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, images) {
|
|
60
|
+
function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, images, featureTexture) {
|
|
39
61
|
// Take only first extension object to get batchIds attribute name.
|
|
40
62
|
const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];
|
|
41
63
|
if (featureIdAttribute?.featureIds?.attribute) {
|
|
@@ -55,8 +77,6 @@ function handleExtFeatureMetadataExtension(attributes, extFeatureMetadata, image
|
|
|
55
77
|
const textureCoordinates = attributes[textCoordAttribute].value;
|
|
56
78
|
return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);
|
|
57
79
|
}
|
|
58
|
-
// Take only first extension texture to get batchIds from the root EXT_feature_metadata object.
|
|
59
|
-
const featureTexture = extFeatureMetadata?.featureTextures && extFeatureMetadata?.featureTextures[0];
|
|
60
80
|
if (featureTexture) {
|
|
61
81
|
const batchIdsAttribute = attributes[featureTexture];
|
|
62
82
|
return batchIdsAttribute.value;
|
|
@@ -153,12 +153,13 @@ function unifyObjectsByFeatureId(sortedData) {
|
|
|
153
153
|
const uniqueObjects = [];
|
|
154
154
|
for (let index = 0; index < sortedData.length; index++) {
|
|
155
155
|
const currentObject = sortedData[index];
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
156
|
+
const existingObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);
|
|
157
|
+
if (existingObject) {
|
|
158
|
+
existingObject.positions = (0, loader_utils_1.concatenateTypedArrays)(existingObject.positions, currentObject.positions);
|
|
159
|
+
existingObject.normals = (0, loader_utils_1.concatenateTypedArrays)(existingObject.normals, currentObject.normals);
|
|
160
|
+
existingObject.colors = (0, loader_utils_1.concatenateTypedArrays)(existingObject.colors, currentObject.colors);
|
|
161
|
+
existingObject.texCoords = (0, loader_utils_1.concatenateTypedArrays)(existingObject.texCoords, currentObject.texCoords);
|
|
162
|
+
existingObject.uvRegions = (0, loader_utils_1.concatenateTypedArrays)(existingObject.uvRegions, currentObject.uvRegions);
|
|
162
163
|
}
|
|
163
164
|
else {
|
|
164
165
|
uniqueObjects.push(currentObject);
|
|
@@ -20,26 +20,27 @@ import { BoundingSphere, OrientedBoundingBox } from '@math.gl/culling';
|
|
|
20
20
|
* @param generateBoundingVolumes - is converter should create accurate bounding voulmes from geometry attributes
|
|
21
21
|
* @param shouldMergeMaterials - Try to merge similar materials to be able to merge meshes into one node
|
|
22
22
|
* @param geoidHeightModel - model to convert elevation from elipsoidal to geoid
|
|
23
|
-
* @param
|
|
23
|
+
* @param libraries - dynamicaly loaded 3rd-party libraries
|
|
24
|
+
* @param metadataClass `- user selected feature metadata class name`
|
|
24
25
|
* @returns Array of node resources to create one or more i3s nodes
|
|
25
26
|
*/
|
|
26
|
-
export default function convertB3dmToI3sGeometry(tileContent: Tiles3DTileContent, tileTransform: Matrix4, tileBoundingVolume: OrientedBoundingBox | BoundingSphere, addNodeToNodePage: () => Promise<number>, propertyTable: FeatureTableJson | null, featuresHashArray: string[], attributeStorageInfo: AttributeStorageInfo[] | undefined, draco: boolean, generateBoundingVolumes: boolean, shouldMergeMaterials: boolean, geoidHeightModel: Geoid,
|
|
27
|
-
[key: string]: string;
|
|
28
|
-
}): Promise<I3SConvertedResources[] | null>;
|
|
27
|
+
export default function convertB3dmToI3sGeometry(tileContent: Tiles3DTileContent, tileTransform: Matrix4, tileBoundingVolume: OrientedBoundingBox | BoundingSphere, addNodeToNodePage: () => Promise<number>, propertyTable: FeatureTableJson | null, featuresHashArray: string[], attributeStorageInfo: AttributeStorageInfo[] | undefined, draco: boolean, generateBoundingVolumes: boolean, shouldMergeMaterials: boolean, geoidHeightModel: Geoid, libraries: Record<string, string>, metadataClass?: string): Promise<I3SConvertedResources[] | null>;
|
|
29
28
|
/**
|
|
30
29
|
* Convert attributes from the gltf nodes tree to i3s plain geometry
|
|
31
30
|
* @param attributesData - geometry attributes from gltf
|
|
32
31
|
* @param materialAndTextureList - array of data about materials and textures of the content
|
|
33
32
|
* @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
|
|
34
33
|
* Cartesian coordinates will be required for creating bounding voulmest from geometry positions
|
|
34
|
+
* @param featureTexture - feature texture key
|
|
35
35
|
* @returns map of converted geometry attributes
|
|
36
36
|
*/
|
|
37
|
-
export declare function convertAttributes(attributesData: GLTFAttributesData, materialAndTextureList: I3SMaterialWithTexture[], useCartesianPositions: boolean): Promise<Map<string, ConvertedAttributes>>;
|
|
37
|
+
export declare function convertAttributes(attributesData: GLTFAttributesData, materialAndTextureList: I3SMaterialWithTexture[], useCartesianPositions: boolean, featureTexture: string | null): Promise<Map<string, ConvertedAttributes>>;
|
|
38
38
|
/**
|
|
39
39
|
* Find property table in tile
|
|
40
40
|
* For example it can be batchTable for b3dm files or property table in gLTF extension.
|
|
41
41
|
* @param tileContent - 3DTiles tile content
|
|
42
|
+
* @param metadataClass - - user selected feature metadata class name
|
|
42
43
|
* @return batch table from b3dm / feature properties from EXT_FEATURE_METADATA
|
|
43
44
|
*/
|
|
44
|
-
export declare function getPropertyTable(tileContent: Tiles3DTileContent | null): FeatureTableJson | null;
|
|
45
|
+
export declare function getPropertyTable(tileContent: Tiles3DTileContent | null, metadataClass?: string): FeatureTableJson | null;
|
|
45
46
|
//# sourceMappingURL=geometry-converter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAW/E,OAAO,EAAU,OAAO,EAAU,MAAM,eAAe,CAAC;AAUxD,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAWrC,OAAO,KAAK,EAAC,kBAAkB,EAAgD,MAAM,UAAU,CAAC;AAEhG,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"geometry-converter.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/geometry-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAE,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAW/E,OAAO,EAAU,OAAO,EAAU,MAAM,eAAe,CAAC;AAUxD,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EAGvB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,oBAAoB,EAIrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAWrC,OAAO,KAAK,EAAC,kBAAkB,EAAgD,MAAM,UAAU,CAAC;AAEhG,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAwBrE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAA8B,wBAAwB,CACpD,WAAW,EAAE,kBAAkB,EAC/B,aAAa,EAAE,OAAO,EACtB,kBAAkB,EAAE,mBAAmB,GAAG,cAAc,EACxD,iBAAiB,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EACxC,aAAa,EAAE,gBAAgB,GAAG,IAAI,EACtC,iBAAiB,EAAE,MAAM,EAAE,EAC3B,oBAAoB,EAAE,oBAAoB,EAAE,GAAG,SAAS,EACxD,KAAK,EAAE,OAAO,EACd,uBAAuB,EAAE,OAAO,EAChC,oBAAoB,EAAE,OAAO,EAC7B,gBAAgB,EAAE,KAAK,EACvB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,qBAAqB,EAAE,GAAG,IAAI,CAAC,CAgEzC;AA6ID;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,cAAc,EAAE,kBAAkB,EAClC,sBAAsB,EAAE,sBAAsB,EAAE,EAChD,qBAAqB,EAAE,OAAO,EAC9B,cAAc,EAAE,MAAM,GAAG,IAAI,GAC5B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAkD3C;AAirCD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,kBAAkB,GAAG,IAAI,EACtC,aAAa,CAAC,EAAE,MAAM,GACrB,gBAAgB,GAAG,IAAI,CA2BzB"}
|
|
@@ -41,6 +41,7 @@ const batch_ids_extensions_1 = require("./batch-ids-extensions");
|
|
|
41
41
|
const feature_attributes_1 = require("./feature-attributes");
|
|
42
42
|
const math_1 = require("@loaders.gl/math");
|
|
43
43
|
const geometry_utils_1 = require("../../lib/utils/geometry-utils");
|
|
44
|
+
const constants_1 = require("../../constants");
|
|
44
45
|
// Spec - https://github.com/Esri/i3s-spec/blob/master/docs/1.7/pbrMetallicRoughness.cmn.md
|
|
45
46
|
const DEFAULT_ROUGHNESS_FACTOR = 1;
|
|
46
47
|
const DEFAULT_METALLIC_FACTOR = 1;
|
|
@@ -57,8 +58,6 @@ const OBJECT_ID_TYPE = 'Oid32';
|
|
|
57
58
|
* BATCHID - Legacy attribute name which includes batch info.
|
|
58
59
|
*/
|
|
59
60
|
const BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
|
|
60
|
-
const EXT_FEATURE_METADATA = 'EXT_feature_metadata';
|
|
61
|
-
const EXT_MESH_FEATURES = 'EXT_mesh_features';
|
|
62
61
|
let scratchVector = new core_1.Vector3();
|
|
63
62
|
/**
|
|
64
63
|
* Convert binary data from b3dm file to i3s resources
|
|
@@ -75,14 +74,16 @@ let scratchVector = new core_1.Vector3();
|
|
|
75
74
|
* @param generateBoundingVolumes - is converter should create accurate bounding voulmes from geometry attributes
|
|
76
75
|
* @param shouldMergeMaterials - Try to merge similar materials to be able to merge meshes into one node
|
|
77
76
|
* @param geoidHeightModel - model to convert elevation from elipsoidal to geoid
|
|
78
|
-
* @param
|
|
77
|
+
* @param libraries - dynamicaly loaded 3rd-party libraries
|
|
78
|
+
* @param metadataClass `- user selected feature metadata class name`
|
|
79
79
|
* @returns Array of node resources to create one or more i3s nodes
|
|
80
80
|
*/
|
|
81
|
-
async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel,
|
|
81
|
+
async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBoundingVolume, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, libraries, metadataClass) {
|
|
82
82
|
const useCartesianPositions = generateBoundingVolumes;
|
|
83
83
|
const materialAndTextureList = await convertMaterials(tileContent.gltf?.materials, shouldMergeMaterials);
|
|
84
84
|
const dataForAttributesConversion = (0, gltf_attributes_1.prepareDataForAttributesConversion)(tileContent, tileTransform, tileBoundingVolume);
|
|
85
|
-
const
|
|
85
|
+
const featureTexture = (0, batch_ids_extensions_1.getTextureByMetadataClass)(tileContent, metadataClass);
|
|
86
|
+
const convertedAttributesMap = await convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions, featureTexture);
|
|
86
87
|
/** Usage of worker here brings more overhead than advantage */
|
|
87
88
|
// const convertedAttributesMap: Map<string, ConvertedAttributes> =
|
|
88
89
|
// await transformI3SAttributesOnWorker(dataForAttributesConversion, {
|
|
@@ -116,7 +117,7 @@ async function convertB3dmToI3sGeometry(tileContent, tileTransform, tileBounding
|
|
|
116
117
|
propertyTable,
|
|
117
118
|
attributeStorageInfo,
|
|
118
119
|
draco,
|
|
119
|
-
|
|
120
|
+
libraries
|
|
120
121
|
}));
|
|
121
122
|
}
|
|
122
123
|
if (!result.length) {
|
|
@@ -157,10 +158,10 @@ function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeigh
|
|
|
157
158
|
* @param params.propertyTable - batch table (corresponding to feature attributes data)
|
|
158
159
|
* @param params.attributeStorageInfo - attributes metadata from 3DSceneLayer json
|
|
159
160
|
* @param params.draco - is converter should create draco compressed geometry
|
|
160
|
-
* @param
|
|
161
|
+
* @param libraries - dynamicaly loaded 3rd-party libraries
|
|
161
162
|
* @returns Array of I3S node resources
|
|
162
163
|
*/
|
|
163
|
-
async function _makeNodeResources({ convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, propertyTable, attributeStorageInfo, draco,
|
|
164
|
+
async function _makeNodeResources({ convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, propertyTable, attributeStorageInfo, draco, libraries }) {
|
|
164
165
|
const boundingVolumes = convertedAttributes.boundingVolumes;
|
|
165
166
|
const vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
|
|
166
167
|
const { faceRange, featureIds, positions, normals, colors, uvRegions, texCoords, featureCount } = (0, geometry_attributes_1.generateAttributes)(convertedAttributes);
|
|
@@ -180,7 +181,7 @@ async function _makeNodeResources({ convertedAttributes, material, texture, tile
|
|
|
180
181
|
uvRegions,
|
|
181
182
|
featureIds,
|
|
182
183
|
faceRange
|
|
183
|
-
},
|
|
184
|
+
}, libraries)
|
|
184
185
|
: null;
|
|
185
186
|
let attributes = [];
|
|
186
187
|
if (attributeStorageInfo && propertyTable) {
|
|
@@ -206,9 +207,10 @@ async function _makeNodeResources({ convertedAttributes, material, texture, tile
|
|
|
206
207
|
* @param materialAndTextureList - array of data about materials and textures of the content
|
|
207
208
|
* @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
|
|
208
209
|
* Cartesian coordinates will be required for creating bounding voulmest from geometry positions
|
|
210
|
+
* @param featureTexture - feature texture key
|
|
209
211
|
* @returns map of converted geometry attributes
|
|
210
212
|
*/
|
|
211
|
-
async function convertAttributes(attributesData, materialAndTextureList, useCartesianPositions) {
|
|
213
|
+
async function convertAttributes(attributesData, materialAndTextureList, useCartesianPositions, featureTexture) {
|
|
212
214
|
const { nodes, images, cartographicOrigin, cartesianModelMatrix } = attributesData;
|
|
213
215
|
const attributesMap = new Map();
|
|
214
216
|
for (const materialAndTexture of materialAndTextureList) {
|
|
@@ -227,7 +229,7 @@ async function convertAttributes(attributesData, materialAndTextureList, useCart
|
|
|
227
229
|
attributesMap.set(mergedMaterial.originalMaterialId, attributes);
|
|
228
230
|
}
|
|
229
231
|
}
|
|
230
|
-
convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
|
|
232
|
+
convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, undefined, featureTexture);
|
|
231
233
|
for (const attrKey of attributesMap.keys()) {
|
|
232
234
|
const attributes = attributesMap.get(attrKey);
|
|
233
235
|
if (!attributes) {
|
|
@@ -256,12 +258,13 @@ exports.convertAttributes = convertAttributes;
|
|
|
256
258
|
* @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
|
|
257
259
|
* Cartesian coordinates will be required for creating bounding voulmest from geometry positions
|
|
258
260
|
* @param matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
|
|
261
|
+
* @param featureTexture - feature texture key
|
|
259
262
|
* @returns {void}
|
|
260
263
|
*/
|
|
261
|
-
function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new core_1.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
|
|
264
|
+
function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new core_1.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
|
|
262
265
|
if (nodes) {
|
|
263
266
|
for (const node of nodes) {
|
|
264
|
-
convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix);
|
|
267
|
+
convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix, featureTexture);
|
|
265
268
|
}
|
|
266
269
|
}
|
|
267
270
|
}
|
|
@@ -294,19 +297,20 @@ function getCompositeTransformationMatrix(node, matrix) {
|
|
|
294
297
|
* @param images - gltf images array
|
|
295
298
|
* @param cartographicOrigin - cartographic origin of bounding volume
|
|
296
299
|
* @param cartesianModelMatrix - cartesian model matrix to convert coordinates to cartographic
|
|
297
|
-
* @param
|
|
300
|
+
* @param attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of
|
|
298
301
|
* attributes
|
|
299
302
|
* @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
|
|
300
303
|
* Cartesian coordinates will be required for creating bounding voulmest from geometry positions
|
|
301
|
-
* @param
|
|
304
|
+
* @param matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
|
|
305
|
+
* @param featureTexture - feature texture key
|
|
302
306
|
*/
|
|
303
|
-
function convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new core_1.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
|
|
307
|
+
function convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix = new core_1.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
|
|
304
308
|
const transformationMatrix = getCompositeTransformationMatrix(node, matrix);
|
|
305
309
|
const mesh = node.mesh;
|
|
306
310
|
if (mesh) {
|
|
307
|
-
convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
|
|
311
|
+
convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix, featureTexture);
|
|
308
312
|
}
|
|
309
|
-
convertNodes(node.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
|
|
313
|
+
convertNodes(node.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix, featureTexture);
|
|
310
314
|
}
|
|
311
315
|
/**
|
|
312
316
|
* Convert all primitives of the mesh
|
|
@@ -320,10 +324,10 @@ function convertNode(node, images, cartographicOrigin, cartesianModelMatrix, att
|
|
|
320
324
|
* Cartesian coordinates will be required for creating bounding voulmest from geometry positions
|
|
321
325
|
* @param attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of
|
|
322
326
|
* attributes
|
|
323
|
-
|
|
324
|
-
* @param
|
|
327
|
+
* @param matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
|
|
328
|
+
* @param featureTexture - feature texture key
|
|
325
329
|
*/
|
|
326
|
-
function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions = false, matrix = new core_1.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
|
|
330
|
+
function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions = false, matrix = new core_1.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]), featureTexture) {
|
|
327
331
|
for (const primitive of mesh.primitives) {
|
|
328
332
|
let outputAttributes = null;
|
|
329
333
|
let materialUvRegion;
|
|
@@ -369,7 +373,7 @@ function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, att
|
|
|
369
373
|
outputAttributes.uvRegions = (0, loader_utils_1.concatenateTypedArrays)(outputAttributes.uvRegions, createUvRegion(materialUvRegion, indices));
|
|
370
374
|
}
|
|
371
375
|
outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
|
|
372
|
-
outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images), indices));
|
|
376
|
+
outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images, featureTexture), indices));
|
|
373
377
|
}
|
|
374
378
|
}
|
|
375
379
|
/**
|
|
@@ -563,9 +567,11 @@ function flattenBatchIds(batchedIds, indices) {
|
|
|
563
567
|
* @param attributes - gltf accessors
|
|
564
568
|
* @param primitive - gltf primitive data
|
|
565
569
|
* @param images - gltf texture images
|
|
570
|
+
* @param featureTexture - feature texture key
|
|
571
|
+
* @return batch IDs
|
|
566
572
|
*/
|
|
567
|
-
function getBatchIds(attributes, primitive, images) {
|
|
568
|
-
const batchIds = (0, batch_ids_extensions_1.handleBatchIdsExtensions)(attributes, primitive, images);
|
|
573
|
+
function getBatchIds(attributes, primitive, images, featureTexture) {
|
|
574
|
+
const batchIds = (0, batch_ids_extensions_1.handleBatchIdsExtensions)(attributes, primitive, images, featureTexture);
|
|
569
575
|
if (batchIds.length) {
|
|
570
576
|
return batchIds;
|
|
571
577
|
}
|
|
@@ -1069,13 +1075,13 @@ function generateBigUint64Array(featureIds) {
|
|
|
1069
1075
|
}
|
|
1070
1076
|
/**
|
|
1071
1077
|
* Generates draco compressed geometry
|
|
1072
|
-
* @param
|
|
1073
|
-
* @param
|
|
1074
|
-
* @param
|
|
1075
|
-
* @param
|
|
1076
|
-
* @returns
|
|
1078
|
+
* @param vertexCount
|
|
1079
|
+
* @param convertedAttributes - get rid of this argument here
|
|
1080
|
+
* @param attributes - geometry attributes to compress
|
|
1081
|
+
* @param libraries - dynamicaly loaded 3rd-party libraries
|
|
1082
|
+
* @returns - Compressed geometry.
|
|
1077
1083
|
*/
|
|
1078
|
-
async function generateCompressedGeometry(vertexCount, convertedAttributes, attributes,
|
|
1084
|
+
async function generateCompressedGeometry(vertexCount, convertedAttributes, attributes, libraries) {
|
|
1079
1085
|
const { positions, normals, texCoords, colors, uvRegions, featureIds, faceRange } = attributes;
|
|
1080
1086
|
const indices = new Uint32Array(vertexCount);
|
|
1081
1087
|
for (let index = 0; index < indices.length; index++) {
|
|
@@ -1106,12 +1112,17 @@ async function generateCompressedGeometry(vertexCount, convertedAttributes, attr
|
|
|
1106
1112
|
}
|
|
1107
1113
|
return (0, core_2.encode)({ attributes: compressedAttributes, indices }, draco_1.DracoWriterWorker, {
|
|
1108
1114
|
...draco_1.DracoWriterWorker.options,
|
|
1109
|
-
source: dracoWorkerSoure,
|
|
1110
1115
|
reuseWorkers: true,
|
|
1111
1116
|
_nodeWorkers: true,
|
|
1117
|
+
modules: libraries,
|
|
1118
|
+
useLocalLibraries: true,
|
|
1112
1119
|
draco: {
|
|
1113
1120
|
method: 'MESH_SEQUENTIAL_ENCODING',
|
|
1114
1121
|
attributesMetadata
|
|
1122
|
+
},
|
|
1123
|
+
['draco-writer']: {
|
|
1124
|
+
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
1125
|
+
workerUrl: './modules/draco/dist/draco-writer-worker-node.js'
|
|
1115
1126
|
}
|
|
1116
1127
|
});
|
|
1117
1128
|
}
|
|
@@ -1137,9 +1148,10 @@ function generateFeatureIndexAttribute(featureIndex, faceRange) {
|
|
|
1137
1148
|
* Find property table in tile
|
|
1138
1149
|
* For example it can be batchTable for b3dm files or property table in gLTF extension.
|
|
1139
1150
|
* @param tileContent - 3DTiles tile content
|
|
1151
|
+
* @param metadataClass - - user selected feature metadata class name
|
|
1140
1152
|
* @return batch table from b3dm / feature properties from EXT_FEATURE_METADATA
|
|
1141
1153
|
*/
|
|
1142
|
-
function getPropertyTable(tileContent) {
|
|
1154
|
+
function getPropertyTable(tileContent, metadataClass) {
|
|
1143
1155
|
if (!tileContent) {
|
|
1144
1156
|
return null;
|
|
1145
1157
|
}
|
|
@@ -1149,12 +1161,12 @@ function getPropertyTable(tileContent) {
|
|
|
1149
1161
|
}
|
|
1150
1162
|
const { extensionName, extension } = getPropertyTableExtension(tileContent);
|
|
1151
1163
|
switch (extensionName) {
|
|
1152
|
-
case EXT_MESH_FEATURES: {
|
|
1164
|
+
case constants_1.EXT_MESH_FEATURES: {
|
|
1153
1165
|
console.warn('The I3S converter does not yet support the EXT_mesh_features extension');
|
|
1154
1166
|
return null;
|
|
1155
1167
|
}
|
|
1156
|
-
case EXT_FEATURE_METADATA: {
|
|
1157
|
-
return getPropertyTableFromExtFeatureMetadata(extension);
|
|
1168
|
+
case constants_1.EXT_FEATURE_METADATA: {
|
|
1169
|
+
return getPropertyTableFromExtFeatureMetadata(extension, metadataClass);
|
|
1158
1170
|
}
|
|
1159
1171
|
default:
|
|
1160
1172
|
return null;
|
|
@@ -1166,7 +1178,7 @@ exports.getPropertyTable = getPropertyTable;
|
|
|
1166
1178
|
* @param tileContent - 3DTiles tile content
|
|
1167
1179
|
*/
|
|
1168
1180
|
function getPropertyTableExtension(tileContent) {
|
|
1169
|
-
const extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_MESH_FEATURES];
|
|
1181
|
+
const extensionsWithPropertyTables = [constants_1.EXT_FEATURE_METADATA, constants_1.EXT_MESH_FEATURES];
|
|
1170
1182
|
const extensionsUsed = tileContent?.gltf?.extensionsUsed;
|
|
1171
1183
|
if (!extensionsUsed) {
|
|
1172
1184
|
return { extensionName: null, extension: null };
|
|
@@ -1186,9 +1198,9 @@ function getPropertyTableExtension(tileContent) {
|
|
|
1186
1198
|
}
|
|
1187
1199
|
/**
|
|
1188
1200
|
* Handle EXT_feature_metadata to get property table
|
|
1189
|
-
* @param extension
|
|
1201
|
+
* @param extension - global level of EXT_FEATURE_METADATA extension
|
|
1190
1202
|
*/
|
|
1191
|
-
function getPropertyTableFromExtFeatureMetadata(extension) {
|
|
1203
|
+
function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
|
|
1192
1204
|
if (extension?.featureTables) {
|
|
1193
1205
|
/**
|
|
1194
1206
|
* Take only first feature table to generate attributes storage info object.
|
|
@@ -1207,15 +1219,15 @@ function getPropertyTableFromExtFeatureMetadata(extension) {
|
|
|
1207
1219
|
}
|
|
1208
1220
|
}
|
|
1209
1221
|
if (extension?.featureTextures) {
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
if (
|
|
1218
|
-
const featureTable = extension?.featureTextures[
|
|
1222
|
+
let featureTexture;
|
|
1223
|
+
for (const textureKey in extension.featureTextures) {
|
|
1224
|
+
const texture = extension.featureTextures[textureKey];
|
|
1225
|
+
if (texture.class === metadataClass) {
|
|
1226
|
+
featureTexture = textureKey;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
if (typeof featureTexture === 'string') {
|
|
1230
|
+
const featureTable = extension?.featureTextures[featureTexture];
|
|
1219
1231
|
const propertyTable = {};
|
|
1220
1232
|
for (const propertyName in featureTable.properties) {
|
|
1221
1233
|
propertyTable[propertyName] = featureTable.properties[propertyName].data;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Tiles3DTileContent } from '@loaders.gl/3d-tiles';
|
|
2
|
-
import {
|
|
2
|
+
import { GLTFPrimitiveModeString, PreprocessData } from '../types';
|
|
3
3
|
/**
|
|
4
4
|
* glTF primitive modes
|
|
5
5
|
* @see https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#_mesh_primitive_mode
|
|
6
6
|
*/
|
|
7
|
-
export declare const GLTF_PRIMITIVE_MODES:
|
|
7
|
+
export declare const GLTF_PRIMITIVE_MODES: GLTFPrimitiveModeString[];
|
|
8
8
|
/**
|
|
9
9
|
* Analyze tile content. This function is used during preprocess stage of
|
|
10
10
|
* conversion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprocess-3d-tiles.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/preprocess-3d-tiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,uBAAuB,EAAE,cAAc,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"preprocess-3d-tiles.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/preprocess-3d-tiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,uBAAuB,EAAE,cAAc,EAAC,MAAM,UAAU,CAAC;AAKjE;;;GAGG;AACH,eAAO,MAAM,oBAAoB,2BAQhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,gBAChB,kBAAkB,GAAG,IAAI,KACrC,QAAQ,cAAc,CAuBxB,CAAC;AAyCF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,YAAa,cAAc,WAAW,cAAc,KAAG,IAUtF,CAAC"}
|