@loaders.gl/tile-converter 4.0.0-alpha.19 → 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.
Files changed (100) hide show
  1. package/dist/constants.d.ts +2 -0
  2. package/dist/constants.d.ts.map +1 -1
  3. package/dist/constants.js +3 -1
  4. package/dist/converter-cli.js +10 -2
  5. package/dist/converter.min.js +172 -103
  6. package/dist/dist.min.js +151 -86
  7. package/dist/es5/constants.js +5 -1
  8. package/dist/es5/constants.js.map +1 -1
  9. package/dist/es5/converter-cli.js +7 -2
  10. package/dist/es5/converter-cli.js.map +1 -1
  11. package/dist/es5/deps-installer/deps-installer.js +1 -1
  12. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +21 -8
  13. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  14. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +7 -6
  15. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  16. package/dist/es5/i3s-converter/helpers/geometry-converter.js +67 -59
  17. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  18. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +38 -9
  19. package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  20. package/dist/es5/i3s-converter/i3s-converter.js +55 -13
  21. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  22. package/dist/es5/i3s-converter/types.js +11 -11
  23. package/dist/es5/i3s-converter/types.js.map +1 -1
  24. package/dist/es5/i3s-server/controllers/slpk-controller.js +1 -1
  25. package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -1
  26. package/dist/es5/index.js +3 -3
  27. package/dist/es5/index.js.map +1 -1
  28. package/dist/es5/pgm-loader.js +1 -1
  29. package/dist/es5/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +9 -9
  30. package/dist/es5/slpk-extractor/helpers/file-handle-file.js.map +1 -0
  31. package/dist/es5/slpk-extractor/slpk-extractor.js +5 -5
  32. package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -1
  33. package/dist/esm/constants.js +2 -0
  34. package/dist/esm/constants.js.map +1 -1
  35. package/dist/esm/converter-cli.js +7 -2
  36. package/dist/esm/converter-cli.js.map +1 -1
  37. package/dist/esm/deps-installer/deps-installer.js +1 -1
  38. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +18 -6
  39. package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  40. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +7 -6
  41. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  42. package/dist/esm/i3s-converter/helpers/geometry-converter.js +28 -20
  43. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  44. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +28 -9
  45. package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
  46. package/dist/esm/i3s-converter/i3s-converter.js +39 -9
  47. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  48. package/dist/esm/i3s-converter/types.js +9 -9
  49. package/dist/esm/i3s-converter/types.js.map +1 -1
  50. package/dist/esm/i3s-server/bin/i3s-server.min.js +71 -71
  51. package/dist/esm/i3s-server/controllers/slpk-controller.js +2 -2
  52. package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -1
  53. package/dist/esm/index.js +1 -1
  54. package/dist/esm/index.js.map +1 -1
  55. package/dist/esm/pgm-loader.js +1 -1
  56. package/dist/esm/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +3 -3
  57. package/dist/esm/slpk-extractor/helpers/file-handle-file.js.map +1 -0
  58. package/dist/esm/slpk-extractor/slpk-extractor.js +3 -3
  59. package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -1
  60. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +11 -1
  61. package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
  62. package/dist/i3s-converter/helpers/batch-ids-extensions.js +33 -13
  63. package/dist/i3s-converter/helpers/geometry-attributes.js +7 -6
  64. package/dist/i3s-converter/helpers/geometry-converter.d.ts +6 -3
  65. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  66. package/dist/i3s-converter/helpers/geometry-converter.js +42 -35
  67. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +2 -2
  68. package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
  69. package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +39 -14
  70. package/dist/i3s-converter/i3s-converter.d.ts +2 -0
  71. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  72. package/dist/i3s-converter/i3s-converter.js +40 -10
  73. package/dist/i3s-converter/types.d.ts +4 -2
  74. package/dist/i3s-converter/types.d.ts.map +1 -1
  75. package/dist/i3s-converter/types.js +11 -11
  76. package/dist/i3s-server/controllers/slpk-controller.js +1 -1
  77. package/dist/index.d.ts +1 -1
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +3 -3
  80. package/dist/slpk-extractor/helpers/{file-handle-provider.d.ts → file-handle-file.d.ts} +5 -5
  81. package/dist/slpk-extractor/helpers/file-handle-file.d.ts.map +1 -0
  82. package/dist/slpk-extractor/helpers/{file-handle-provider.js → file-handle-file.js} +5 -5
  83. package/dist/slpk-extractor/slpk-extractor.js +5 -5
  84. package/dist/slpk-extractor.min.js +32 -32
  85. package/package.json +15 -14
  86. package/src/constants.ts +3 -0
  87. package/src/converter-cli.ts +9 -2
  88. package/src/i3s-converter/helpers/batch-ids-extensions.ts +39 -12
  89. package/src/i3s-converter/helpers/geometry-attributes.ts +15 -8
  90. package/src/i3s-converter/helpers/geometry-converter.ts +66 -35
  91. package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +48 -18
  92. package/src/i3s-converter/i3s-converter.ts +54 -12
  93. package/src/i3s-converter/types.ts +4 -2
  94. package/src/i3s-server/controllers/slpk-controller.ts +2 -2
  95. package/src/index.ts +1 -1
  96. package/src/slpk-extractor/helpers/{file-handle-provider.ts → file-handle-file.ts} +5 -5
  97. package/src/slpk-extractor/slpk-extractor.ts +3 -3
  98. package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
  99. package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +0 -1
  100. 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 { FileHandleProvider } from '@loaders.gl/tile-converter';
3
+ import { FileHandleFile } from '@loaders.gl/tile-converter';
4
4
  let slpkArchive;
5
5
  export const loadArchive = async fullLayerPath => {
6
- slpkArchive = await parseSLPK(await FileHandleProvider.from(fullLayerPath), msg => console.log(msg));
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","FileHandleProvider","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 {FileHandleProvider} 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 FileHandleProvider.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,kBAAkB,QAAO,4BAA4B;AAE7D,IAAIC,WAAW;AAMf,OAAO,MAAMC,WAAW,GAAG,MAAOC,aAAqB,IAAoB;EACzEF,WAAW,GAAG,MAAMF,SAAS,CAAC,MAAMC,kBAAkB,CAACI,IAAI,CAACD,aAAa,CAAC,EAAGE,GAAG,IAC9EC,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"}
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 { FileHandleProvider } from './slpk-extractor/helpers/file-handle-provider';
3
+ export { FileHandleFile } from './slpk-extractor/helpers/file-handle-file';
4
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["default","I3SConverter","Tiles3DConverter","FileHandleProvider"],"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 {FileHandleProvider} from './slpk-extractor/helpers/file-handle-provider';\n"],"mappings":"AAAA,SAAQA,OAAO,IAAIC,YAAY,QAAO,+BAA+B;AACrE,SAAQD,OAAO,IAAIE,gBAAgB,QAAO,yCAAyC;AACnF,SAAQC,kBAAkB,QAAO,+CAA+C"}
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"}
@@ -1,5 +1,5 @@
1
1
  import { parsePGM } from '@math.gl/geoid';
2
- const VERSION = typeof "4.0.0-alpha.19" !== 'undefined' ? "4.0.0-alpha.19" : 'latest';
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 FileHandleProvider {
3
+ export class FileHandleFile {
4
4
  static async from(path) {
5
5
  const fileDescriptor = await FileHandle.open(path);
6
- return new FileHandleProvider(fileDescriptor, fileDescriptor.stat.size);
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-provider.js.map
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":";AACA,SAAQA,UAAU,QAAO,eAAe;AAK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@
1
1
  import { isBrowser } from '@loaders.gl/core';
2
2
  import { BROWSER_ERROR_MESSAGE } from '../constants';
3
- import { FileHandleProvider } from './helpers/file-handle-provider';
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 FileHandleProvider.from(inputUrl);
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","FileHandleProvider","parseZipLocalFileHeader","path","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 {FileHandleProvider} from './helpers/file-handle-provider';\nimport {parseZipLocalFileHeader} from '@loaders.gl/i3s';\nimport {path} from '@loaders.gl/loader-utils';\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 FileHandleProvider.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":"AAAA,SAAQA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AI,EAAE;MACjB;IACF;IACA,MAAMyB,SAAS,GAAGxC,IAAI,CAACyB,IAAI,CAACH,UAAU,EAAEhB,OAAO,CAACS,IAAI,CAAC;IACrD,MAAM0B,OAAO,GAAGzC,IAAI,CAAC0B,OAAO,CAACc,SAAS,CAAC;IACvC,MAAMvB,QAAQ,GAAGjB,IAAI,CAACwB,QAAQ,CAACgB,SAAS,CAAC;IACzC,MAAMtC,SAAS,CAACuC,OAAO,EAAEnC,OAAO,CAACY,IAAI,EAAED,QAAQ,CAAC;EAClD;AACF"}
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":"AAAA,SAAQA,SAAS,QAAO,kBAAkB;AAE1C,SAAQC,qBAAqB,QAAO,cAAc;AAClD,SAAQC,cAAc,QAAO,4BAA4B;AACzD,SAAQC,IAAI,QAAO,0BAA0B;AAC7C,SAAQC,uBAAuB,QAAO,iBAAiB;AACvD,SAAQC,eAAe,QAAO,yBAAyB;AACvD,SAAQC,SAAS,QAAO,yBAAyB;AAEjD,MAAMC,UAAU,GAAG,CACjB,sBAAsB,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AS,CAACuC,OAAO,EAAEnC,OAAO,CAACY,IAAI,EAAED,QAAQ,CAAC;EAClD;AACF"}
@@ -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;AAM3D,OAAO,EAAC,sBAAsB,EAAC,MAAM,UAAU,CAAC;AAKhD;;;;;GAKG;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,GACxC,YAAY,CAwBd"}
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 EXT_MESH_FEATURES = 'EXT_mesh_features';
5
- const EXT_FEATURE_METADATA = 'EXT_feature_metadata';
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 existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);
157
- if (existedObject) {
158
- existedObject.positions = (0, loader_utils_1.concatenateTypedArrays)(existedObject.positions, currentObject.positions);
159
- existedObject.normals = (0, loader_utils_1.concatenateTypedArrays)(existedObject.normals, currentObject.normals);
160
- existedObject.colors = (0, loader_utils_1.concatenateTypedArrays)(existedObject.colors, currentObject.colors);
161
- existedObject.texCoords = (0, loader_utils_1.concatenateTypedArrays)(existedObject.texCoords, currentObject.texCoords);
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);
@@ -21,23 +21,26 @@ import { BoundingSphere, OrientedBoundingBox } from '@math.gl/culling';
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
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, libraries: Record<string, string>): 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>;
27
28
  /**
28
29
  * Convert attributes from the gltf nodes tree to i3s plain geometry
29
30
  * @param attributesData - geometry attributes from gltf
30
31
  * @param materialAndTextureList - array of data about materials and textures of the content
31
32
  * @param useCartesianPositions - convert positions to absolute cartesian coordinates instead of cartographic offsets.
32
33
  * Cartesian coordinates will be required for creating bounding voulmest from geometry positions
34
+ * @param featureTexture - feature texture key
33
35
  * @returns map of converted geometry attributes
34
36
  */
35
- 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>>;
36
38
  /**
37
39
  * Find property table in tile
38
40
  * For example it can be batchTable for b3dm files or property table in gLTF extension.
39
41
  * @param tileContent - 3DTiles tile content
42
+ * @param metadataClass - - user selected feature metadata class name
40
43
  * @return batch table from b3dm / feature properties from EXT_FEATURE_METADATA
41
44
  */
42
- export declare function getPropertyTable(tileContent: Tiles3DTileContent | null): FeatureTableJson | null;
45
+ export declare function getPropertyTable(tileContent: Tiles3DTileContent | null, metadataClass?: string): FeatureTableJson | null;
43
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;AA0BrE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAA8B,wBAAwB,CACpD,WAAW,EAAE,kBAAkB,EAC/B,aAAa,EAAE,OAAO,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AAE,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
@@ -76,13 +75,15 @@ let scratchVector = new core_1.Vector3();
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
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, libraries) {
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 convertedAttributesMap = await convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions);
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, {
@@ -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 {Map} attributesMap Map<{positions: Float32Array, normals: Float32Array, texCoords: Float32Array, colors: Uint8Array, featureIndices: Array}> - for recursive concatenation of
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 {Matrix4} matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
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 {Matrix4} matrix - transformation matrix - cumulative transformation matrix formed from all parent node matrices
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
  }
@@ -1142,9 +1148,10 @@ function generateFeatureIndexAttribute(featureIndex, faceRange) {
1142
1148
  * Find property table in tile
1143
1149
  * For example it can be batchTable for b3dm files or property table in gLTF extension.
1144
1150
  * @param tileContent - 3DTiles tile content
1151
+ * @param metadataClass - - user selected feature metadata class name
1145
1152
  * @return batch table from b3dm / feature properties from EXT_FEATURE_METADATA
1146
1153
  */
1147
- function getPropertyTable(tileContent) {
1154
+ function getPropertyTable(tileContent, metadataClass) {
1148
1155
  if (!tileContent) {
1149
1156
  return null;
1150
1157
  }
@@ -1154,12 +1161,12 @@ function getPropertyTable(tileContent) {
1154
1161
  }
1155
1162
  const { extensionName, extension } = getPropertyTableExtension(tileContent);
1156
1163
  switch (extensionName) {
1157
- case EXT_MESH_FEATURES: {
1164
+ case constants_1.EXT_MESH_FEATURES: {
1158
1165
  console.warn('The I3S converter does not yet support the EXT_mesh_features extension');
1159
1166
  return null;
1160
1167
  }
1161
- case EXT_FEATURE_METADATA: {
1162
- return getPropertyTableFromExtFeatureMetadata(extension);
1168
+ case constants_1.EXT_FEATURE_METADATA: {
1169
+ return getPropertyTableFromExtFeatureMetadata(extension, metadataClass);
1163
1170
  }
1164
1171
  default:
1165
1172
  return null;
@@ -1171,7 +1178,7 @@ exports.getPropertyTable = getPropertyTable;
1171
1178
  * @param tileContent - 3DTiles tile content
1172
1179
  */
1173
1180
  function getPropertyTableExtension(tileContent) {
1174
- const extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_MESH_FEATURES];
1181
+ const extensionsWithPropertyTables = [constants_1.EXT_FEATURE_METADATA, constants_1.EXT_MESH_FEATURES];
1175
1182
  const extensionsUsed = tileContent?.gltf?.extensionsUsed;
1176
1183
  if (!extensionsUsed) {
1177
1184
  return { extensionName: null, extension: null };
@@ -1191,9 +1198,9 @@ function getPropertyTableExtension(tileContent) {
1191
1198
  }
1192
1199
  /**
1193
1200
  * Handle EXT_feature_metadata to get property table
1194
- * @param extension
1201
+ * @param extension - global level of EXT_FEATURE_METADATA extension
1195
1202
  */
1196
- function getPropertyTableFromExtFeatureMetadata(extension) {
1203
+ function getPropertyTableFromExtFeatureMetadata(extension, metadataClass) {
1197
1204
  if (extension?.featureTables) {
1198
1205
  /**
1199
1206
  * Take only first feature table to generate attributes storage info object.
@@ -1212,15 +1219,15 @@ function getPropertyTableFromExtFeatureMetadata(extension) {
1212
1219
  }
1213
1220
  }
1214
1221
  if (extension?.featureTextures) {
1215
- /**
1216
- * Take only first feature texture to generate attributes storage info object.
1217
- * TODO: Think about getting data from all feature textures?
1218
- * It can be tricky just because 3dTiles is able to have multiple featureTextures.
1219
- * In I3S we should decide which featureTextures will be passed to geometry data.
1220
- */
1221
- const firstTextureName = Object.keys(extension.featureTextures)?.[0];
1222
- if (firstTextureName) {
1223
- const featureTable = extension?.featureTextures[firstTextureName];
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];
1224
1231
  const propertyTable = {};
1225
1232
  for (const propertyName in featureTable.properties) {
1226
1233
  propertyTable[propertyName] = featureTable.properties[propertyName].data;
@@ -1,10 +1,10 @@
1
1
  import { Tiles3DTileContent } from '@loaders.gl/3d-tiles';
2
- import { GltfPrimitiveModeString, PreprocessData } from '../types';
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: GltfPrimitiveModeString[];
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;AAIjE;;;GAGG;AACH,eAAO,MAAM,oBAAoB,2BAQhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,gBAChB,kBAAkB,GAAG,IAAI,KACrC,QAAQ,cAAc,CAmBxB,CAAC;AAqBF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,YAAa,cAAc,WAAW,cAAc,KAAG,IAKtF,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"}