@loaders.gl/tile-converter 4.1.0 → 4.2.0-alpha.1

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 (27) hide show
  1. package/dist/converter.min.cjs +82 -82
  2. package/dist/deps-installer/deps-installer.js +1 -1
  3. package/dist/deps-installer/deps-installer.js.map +1 -1
  4. package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts +10 -0
  5. package/dist/i3s-converter/helpers/attribute-metadata-info.d.ts.map +1 -1
  6. package/dist/i3s-converter/helpers/attribute-metadata-info.js +5 -0
  7. package/dist/i3s-converter/helpers/attribute-metadata-info.js.map +1 -1
  8. package/dist/i3s-converter/helpers/node-index-document.d.ts +2 -1
  9. package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
  10. package/dist/i3s-converter/helpers/node-index-document.js +6 -8
  11. package/dist/i3s-converter/helpers/node-index-document.js.map +1 -1
  12. package/dist/i3s-converter/i3s-converter.d.ts +18 -0
  13. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  14. package/dist/i3s-converter/i3s-converter.js +121 -24
  15. package/dist/i3s-converter/i3s-converter.js.map +1 -1
  16. package/dist/index.cjs +283 -56
  17. package/dist/lib/utils/conversion-dump.d.ts +55 -5
  18. package/dist/lib/utils/conversion-dump.d.ts.map +1 -1
  19. package/dist/lib/utils/conversion-dump.js +77 -17
  20. package/dist/lib/utils/conversion-dump.js.map +1 -1
  21. package/dist/pgm-loader.js +1 -1
  22. package/dist/pgm-loader.js.map +1 -1
  23. package/package.json +14 -14
  24. package/src/i3s-converter/helpers/attribute-metadata-info.ts +16 -0
  25. package/src/i3s-converter/helpers/node-index-document.ts +18 -8
  26. package/src/i3s-converter/i3s-converter.ts +198 -41
  27. package/src/lib/utils/conversion-dump.ts +143 -21
@@ -5,7 +5,7 @@ import { join, dirname } from 'path';
5
5
  import { ChildProcessProxy } from '@loaders.gl/worker-utils';
6
6
  import { DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS } from '@loaders.gl/draco';
7
7
  import { BASIS_EXTERNAL_LIBRARIES } from '@loaders.gl/textures';
8
- const VERSION = typeof "4.1.0" !== 'undefined' ? "4.1.0" : 'latest';
8
+ const VERSION = typeof "4.2.0-alpha.1" !== 'undefined' ? "4.2.0-alpha.1" : 'latest';
9
9
  const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
10
10
  export class DepsInstaller {
11
11
  async install() {
@@ -1 +1 @@
1
- {"version":3,"file":"deps-installer.js","names":["load","fetchFile","ZipLoader","writeFile","join","dirname","ChildProcessProxy","DRACO_EXTERNAL_LIBRARIES","DRACO_EXTERNAL_LIBRARY_URLS","BASIS_EXTERNAL_LIBRARIES","VERSION","PGM_LINK","DepsInstaller","install","path","arguments","length","undefined","console","log","fileMap","depsPath","process","cwd","Uint8Array","installFromNpm","installFromUrl","DECODER","DECODER_WASM","ENCODER","TRANSCODER","TRANSCODER_WASM","ENCODER_WASM","childProcess","nodeDir","execPath","start","command","platform","wait","ignoreStderr","module","name","extraPath","fileResponse","fileData","arrayBuffer","url"],"sources":["../../src/deps-installer/deps-installer.ts"],"sourcesContent":["import {load, fetchFile} from '@loaders.gl/core';\nimport {ZipLoader} from '@loaders.gl/zip';\nimport {writeFile} from '../lib/utils/file-utils';\nimport {join, dirname} from 'path';\nimport {ChildProcessProxy} from '@loaders.gl/worker-utils';\nimport {DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS} from '@loaders.gl/draco';\nimport {BASIS_EXTERNAL_LIBRARIES} from '@loaders.gl/textures';\n\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nconst PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';\n\n/**\n * Install external dependencies for converter:\n * * PGM file (implemented);\n * * Draco library (not implemented);\n * * 7z archiver (not implemented);\n */\nexport class DepsInstaller {\n /**\n * Run instalation\n * @param path destination folder\n * @param workersPath destination folder for workers.\n * This path is '' by default and is not used by tile-converter.\n * It is used in tests to prevent rewriting actual workers during tests running\n */\n async install(path: string = ''): Promise<void> {\n console.log('Installing \"EGM2008-5\" model...'); // eslint-disable-line no-console\n const fileMap = await load(PGM_LINK, ZipLoader, {});\n\n let depsPath = process.cwd();\n if (path) {\n depsPath = join(depsPath, path);\n }\n\n await writeFile(depsPath, new Uint8Array(fileMap['geoids/egm2008-5.pgm']), 'egm2008-5.pgm');\n\n console.log('Installing \"I3S Content Loader\" worker'); // eslint-disable-line no-console\n await this.installFromNpm('i3s', 'i3s-content-worker-node.js');\n\n console.log('Installing \"Draco Loader\" worker'); // eslint-disable-line no-console\n await this.installFromNpm('draco', 'draco-worker-node.js');\n\n console.log('Installing \"Draco Writer\" worker'); // eslint-disable-line no-console\n await this.installFromNpm('draco', 'draco-writer-worker-node.js');\n\n console.log('Installing \"Basis Loader\" worker'); // eslint-disable-line no-console\n await this.installFromNpm('textures', 'basis-worker-node.js');\n\n console.log('Installing \"KTX2 Basis Writer\" worker'); // eslint-disable-line no-console\n await this.installFromNpm('textures', 'ktx2-basis-writer-worker-node.js');\n\n console.log('Installing \"Draco decoder\" library'); // eslint-disable-line no-console\n await this.installFromUrl(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],\n 'draco',\n DRACO_EXTERNAL_LIBRARIES.DECODER\n );\n await this.installFromUrl(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],\n 'draco',\n DRACO_EXTERNAL_LIBRARIES.DECODER_WASM\n );\n\n console.log('Installing \"Draco encoder\" library'); // eslint-disable-line no-console\n await this.installFromUrl(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.ENCODER],\n 'draco',\n DRACO_EXTERNAL_LIBRARIES.ENCODER\n );\n\n console.log('Installing \"Basis transcoder\" library'); // eslint-disable-line no-console\n await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.TRANSCODER, 'libs');\n await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, 'libs');\n\n console.log('Installing \"Basis encoder\" library'); // eslint-disable-line no-console\n await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.ENCODER, 'libs');\n await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, 'libs');\n\n console.log('Installing \"join-images\" npm package');\n const childProcess = new ChildProcessProxy();\n const nodeDir = dirname(process.execPath);\n await childProcess.start({\n command: `${nodeDir}/${process.platform === 'win32' ? 'npm.cmd' : 'npm'}`,\n // `npm install sharp join-images` works unstable. It fails because installed `sharp` version\n // may be different from the version required by `join-images`. Pointing to specific versions\n // resolve this issue\n arguments: ['install', 'sharp@0.30.4', 'join-images@1.1.3'],\n wait: 0,\n ignoreStderr: true\n });\n\n console.log('All dependencies were installed succesfully.'); // eslint-disable-line no-console\n }\n\n private async installFromNpm(module: string, name: string, extraPath: string = '') {\n const fileResponse = await fetchFile(\n `https://unpkg.com/@loaders.gl/${module}@${VERSION}/dist/${extraPath}/${name}`\n );\n const fileData = await fileResponse.arrayBuffer();\n if (!fileData) {\n return;\n }\n const path = join(process.cwd(), 'modules', module, 'dist', extraPath);\n await writeFile(path, fileData, name);\n }\n\n private async installFromUrl(url: string, module: string, name: string) {\n const fileResponse = await fetchFile(url);\n const fileData = await fileResponse.arrayBuffer();\n if (!fileData) {\n return;\n }\n const path = join(process.cwd(), 'modules', module, 'dist', 'libs');\n await writeFile(path, fileData, name);\n }\n}\n"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,SAAS,QAAO,kBAAkB;AAChD,SAAQC,SAAS,QAAO,iBAAiB;AAAC,SAClCC,SAAS;AACjB,SAAQC,IAAI,EAAEC,OAAO,QAAO,MAAM;AAClC,SAAQC,iBAAiB,Q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tC,SAAS,CAACW,IAAI,EAAE+B,QAAQ,EAAEH,IAAI,CAAC;EACvC;AACF"}
1
+ {"version":3,"file":"deps-installer.js","names":["load","fetchFile","ZipLoader","writeFile","join","dirname","ChildProcessProxy","DRACO_EXTERNAL_LIBRARIES","DRACO_EXTERNAL_LIBRARY_URLS","BASIS_EXTERNAL_LIBRARIES","VERSION","PGM_LINK","DepsInstaller","install","path","arguments","length","undefined","console","log","fileMap","depsPath","process","cwd","Uint8Array","installFromNpm","installFromUrl","DECODER","DECODER_WASM","ENCODER","TRANSCODER","TRANSCODER_WASM","ENCODER_WASM","childProcess","nodeDir","execPath","start","command","platform","wait","ignoreStderr","module","name","extraPath","fileResponse","fileData","arrayBuffer","url"],"sources":["../../src/deps-installer/deps-installer.ts"],"sourcesContent":["import {load, fetchFile} from '@loaders.gl/core';\nimport {ZipLoader} from '@loaders.gl/zip';\nimport {writeFile} from '../lib/utils/file-utils';\nimport {join, dirname} from 'path';\nimport {ChildProcessProxy} from '@loaders.gl/worker-utils';\nimport {DRACO_EXTERNAL_LIBRARIES, DRACO_EXTERNAL_LIBRARY_URLS} from '@loaders.gl/draco';\nimport {BASIS_EXTERNAL_LIBRARIES} from '@loaders.gl/textures';\n\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nconst PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';\n\n/**\n * Install external dependencies for converter:\n * * PGM file (implemented);\n * * Draco library (not implemented);\n * * 7z archiver (not implemented);\n */\nexport class DepsInstaller {\n /**\n * Run instalation\n * @param path destination folder\n * @param workersPath destination folder for workers.\n * This path is '' by default and is not used by tile-converter.\n * It is used in tests to prevent rewriting actual workers during tests running\n */\n async install(path: string = ''): Promise<void> {\n console.log('Installing \"EGM2008-5\" model...'); // eslint-disable-line no-console\n const fileMap = await load(PGM_LINK, ZipLoader, {});\n\n let depsPath = process.cwd();\n if (path) {\n depsPath = join(depsPath, path);\n }\n\n await writeFile(depsPath, new Uint8Array(fileMap['geoids/egm2008-5.pgm']), 'egm2008-5.pgm');\n\n console.log('Installing \"I3S Content Loader\" worker'); // eslint-disable-line no-console\n await this.installFromNpm('i3s', 'i3s-content-worker-node.js');\n\n console.log('Installing \"Draco Loader\" worker'); // eslint-disable-line no-console\n await this.installFromNpm('draco', 'draco-worker-node.js');\n\n console.log('Installing \"Draco Writer\" worker'); // eslint-disable-line no-console\n await this.installFromNpm('draco', 'draco-writer-worker-node.js');\n\n console.log('Installing \"Basis Loader\" worker'); // eslint-disable-line no-console\n await this.installFromNpm('textures', 'basis-worker-node.js');\n\n console.log('Installing \"KTX2 Basis Writer\" worker'); // eslint-disable-line no-console\n await this.installFromNpm('textures', 'ktx2-basis-writer-worker-node.js');\n\n console.log('Installing \"Draco decoder\" library'); // eslint-disable-line no-console\n await this.installFromUrl(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],\n 'draco',\n DRACO_EXTERNAL_LIBRARIES.DECODER\n );\n await this.installFromUrl(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],\n 'draco',\n DRACO_EXTERNAL_LIBRARIES.DECODER_WASM\n );\n\n console.log('Installing \"Draco encoder\" library'); // eslint-disable-line no-console\n await this.installFromUrl(\n DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.ENCODER],\n 'draco',\n DRACO_EXTERNAL_LIBRARIES.ENCODER\n );\n\n console.log('Installing \"Basis transcoder\" library'); // eslint-disable-line no-console\n await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.TRANSCODER, 'libs');\n await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, 'libs');\n\n console.log('Installing \"Basis encoder\" library'); // eslint-disable-line no-console\n await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.ENCODER, 'libs');\n await this.installFromNpm('textures', BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, 'libs');\n\n console.log('Installing \"join-images\" npm package');\n const childProcess = new ChildProcessProxy();\n const nodeDir = dirname(process.execPath);\n await childProcess.start({\n command: `${nodeDir}/${process.platform === 'win32' ? 'npm.cmd' : 'npm'}`,\n // `npm install sharp join-images` works unstable. It fails because installed `sharp` version\n // may be different from the version required by `join-images`. Pointing to specific versions\n // resolve this issue\n arguments: ['install', 'sharp@0.30.4', 'join-images@1.1.3'],\n wait: 0,\n ignoreStderr: true\n });\n\n console.log('All dependencies were installed succesfully.'); // eslint-disable-line no-console\n }\n\n private async installFromNpm(module: string, name: string, extraPath: string = '') {\n const fileResponse = await fetchFile(\n `https://unpkg.com/@loaders.gl/${module}@${VERSION}/dist/${extraPath}/${name}`\n );\n const fileData = await fileResponse.arrayBuffer();\n if (!fileData) {\n return;\n }\n const path = join(process.cwd(), 'modules', module, 'dist', extraPath);\n await writeFile(path, fileData, name);\n }\n\n private async installFromUrl(url: string, module: string, name: string) {\n const fileResponse = await fetchFile(url);\n const fileData = await fileResponse.arrayBuffer();\n if (!fileData) {\n return;\n }\n const path = join(process.cwd(), 'modules', module, 'dist', 'libs');\n await writeFile(path, fileData, name);\n }\n}\n"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,SAAS,QAAO,kBAAkB;AAChD,SAAQC,SAAS,QAAO,iBAAiB;AAAC,SAClCC,SAAS;AACjB,SAAQC,IAAI,EAAEC,OAAO,QAAO,MAAM;AAClC,SAAQC,iBAAiB,QAAO,0BAA0B;AAC1D,SAAQC,wBAAwB,EAAEC,2BAA2B,QAAO,mBAAmB;AACvF,SAAQC,wBAAwB,QAAO,sBAAsB;AAG7D,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAE3E,MAAMC,QAAQ,GAAG,+EAA+E;AAQhG,OAAO,MAAMC,aAAa,CAAC;EAQzB,MAAMC,OAAOA,CAAA,EAA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8CAA8C,CAAC;EAC7D;EAEA,MAAcM,cAAcA,CAACgB,MAAc,EAAEC,IAAY,EAA0B;IAAA,IAAxBC,SAAiB,GAAA5B,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAC/E,MAAM6B,YAAY,GAAG,MAAM3C,SAAS,CACjC,iCAAgCwC,MAAO,IAAG/B,OAAQ,SAAQiC,SAAU,IAAGD,IAAK,EAC/E,CAAC;IACD,MAAMG,QAAQ,GAAG,MAAMD,YAAY,CAACE,WAAW,CAAC,CAAC;IACjD,IAAI,CAACD,QAAQ,EAAE;MACb;IACF;IACA,MAAM/B,IAAI,GAAGV,IAAI,CAACkB,OAAO,CAACC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAEkB,MAAM,EAAE,MAAM,EAAEE,SAAS,CAAC;IACtE,MAAMxC,SAAS,CAACW,IAAI,EAAE+B,QAAQ,EAAEH,IAAI,CAAC;EACvC;EAEA,MAAchB,cAAcA,CAACqB,GAAW,EAAEN,MAAc,EAAEC,IAAY,EAAE;IACtE,MAAME,YAAY,GAAG,MAAM3C,SAAS,CAAC8C,GAAG,CAAC;IACzC,MAAMF,QAAQ,GAAG,MAAMD,YAAY,CAACE,WAAW,CAAC,CAAC;IACjD,IAAI,CAACD,QAAQ,EAAE;MACb;IACF;IACA,MAAM/B,IAAI,GAAGV,IAAI,CAACkB,OAAO,CAACC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAEkB,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IACnE,MAAMtC,SAAS,CAACW,IAAI,EAAE+B,QAAQ,EAAEH,IAAI,CAAC;EACvC;AACF"}
@@ -1,4 +1,9 @@
1
1
  import type { Attribute, AttributeStorageInfo, Field, PopupInfo } from '@loaders.gl/i3s';
2
+ export type AttributeMetadataInfoObject = {
3
+ attributeStorageInfo: AttributeStorageInfo[];
4
+ fields: Field[];
5
+ popupInfo: PopupInfo | undefined;
6
+ };
2
7
  export declare class AttributeMetadataInfo {
3
8
  private _attributeStorageInfo;
4
9
  private _fields;
@@ -30,6 +35,11 @@ export declare class AttributeMetadataInfo {
30
35
  * The method creates and stores objects for opt_uint64, opt_float32 attributes.
31
36
  */
32
37
  addMetadataInfo(attributeTypesMap: Record<string, Attribute>): void;
38
+ /**
39
+ * Set AttributeMetadataInfo from object
40
+ * @param object - object with AttributeMetadataInfo props
41
+ */
42
+ fromObject(object: AttributeMetadataInfoObject): void;
33
43
  /**
34
44
  * Generates storage attribute for map segmentation.
35
45
  * @param attributeIndex - order index of attribute (f_0, f_1 ...).
@@ -1 +1 @@
1
- {"version":3,"file":"attribute-metadata-info.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/attribute-metadata-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,oBAAoB,EAEpB,KAAK,EAEL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAIzB,qBAAa,qBAAqB;IAChC,OAAO,CAAC,qBAAqB,CAAyB;IACtD,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,UAAU,CAAwB;;IAO1C,IAAI,oBAAoB,IAAI,oBAAoB,EAAE,CAEjD;IAED,IAAI,MAAM,IAAI,KAAK,EAAE,CAEpB;IAED,IAAI,SAAS,IAAI,SAAS,GAAG,SAAS,CAErC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,eAAe,CAAC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;IA0CnE;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;IAgC9B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAe7B;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAe5B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAO5B;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAQ5B;;;;OAIG;IACH,OAAO,CAAC,eAAe;CA+BxB"}
1
+ {"version":3,"file":"attribute-metadata-info.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/attribute-metadata-info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACT,oBAAoB,EAEpB,KAAK,EAEL,SAAS,EACV,MAAM,iBAAiB,CAAC;AAIzB,MAAM,MAAM,2BAA2B,GAAG;IACxC,oBAAoB,EAAE,oBAAoB,EAAE,CAAC;IAC7C,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;CAClC,CAAC;AAEF,qBAAa,qBAAqB;IAChC,OAAO,CAAC,qBAAqB,CAAyB;IACtD,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,UAAU,CAAwB;;IAO1C,IAAI,oBAAoB,IAAI,oBAAoB,EAAE,CAEjD;IAED,IAAI,MAAM,IAAI,KAAK,EAAE,CAEpB;IAED,IAAI,SAAS,IAAI,SAAS,GAAG,SAAS,CAErC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,eAAe,CAAC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI;IA0CnE;;;OAGG;IACH,UAAU,CAAC,MAAM,EAAE,2BAA2B;IAM9C;;;;;;OAMG;IACH,OAAO,CAAC,sBAAsB;IAgC9B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAe7B;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAOxB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAe5B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAO5B;;;;OAIG;IACH,OAAO,CAAC,oBAAoB;IAQ5B;;;;OAIG;IACH,OAAO,CAAC,eAAe;CA+BxB"}
@@ -47,6 +47,11 @@ export class AttributeMetadataInfo {
47
47
  this._popupInfo = this.createPopupInfo(attributeNames);
48
48
  }
49
49
  }
50
+ fromObject(object) {
51
+ this._attributeStorageInfo = object.attributeStorageInfo;
52
+ this._fields = object.fields;
53
+ this._popupInfo = object.popupInfo;
54
+ }
50
55
  createStorageAttribute(attributeIndex, key, attributeType) {
51
56
  const storageAttribute = {
52
57
  key: `f_${attributeIndex}`,
@@ -1 +1 @@
1
- {"version":3,"file":"attribute-metadata-info.js","names":["AttributeType","AttributeMetadataInfo","constructor","_attributeStorageInfo","_fields","_popupInfo","attributeStorageInfo","fields","popupInfo","addMetadataInfo","attributeTypesMap","Object","keys","length","attributeTypes","OBJECTID","OBJECT_ID_TYPE","isUpdated","attributeIndex","key","elementFound","find","element","name","attributeType","storageAttribute","createStorageAttribute","fieldAttributeType","getFieldAttributeType","fieldAttribute","createFieldAttribute","push","attributeNames","info","createPopupInfo","ordering","header","property","valueType","attributeValues","valuesPerElement","setupIdAttribute","STRING_TYPE","setupStringAttribute","DOUBLE_TYPE","setupDoubleAttribute","SHORT_INT_TYPE","unshift","encoding","attributeByteCounts","type","alias","propertyNames","title","mediaInfos","fieldInfos","popupElements","expressionInfos","propertyName","fieldName","visible","isEditable","label"],"sources":["../../../src/i3s-converter/helpers/attribute-metadata-info.ts"],"sourcesContent":["import type {\n Attribute,\n AttributeStorageInfo,\n ESRIField,\n Field,\n FieldInfo,\n PopupInfo\n} from '@loaders.gl/i3s';\n\nimport {AttributeType} from '../types';\n\nexport class AttributeMetadataInfo {\n private _attributeStorageInfo: AttributeStorageInfo[];\n private _fields: Field[];\n private _popupInfo: PopupInfo | undefined;\n\n constructor() {\n this._attributeStorageInfo = [];\n this._fields = [];\n }\n\n get attributeStorageInfo(): AttributeStorageInfo[] {\n return this._attributeStorageInfo;\n }\n\n get fields(): Field[] {\n return this._fields;\n }\n\n get popupInfo(): PopupInfo | undefined {\n return this._popupInfo;\n }\n\n /**\n * Creates and stores Attribute Storage Info, Fields and PopupInfo objects based on attribute's types.\n * Appends objects that have not been stored yet.\n * @param attributeTypesMap - set of attribute's types\n * @example AttributeStorageInfo, Fields and PopupInfo already contain objects for the following attributes:\n * {\n * color: 'string',\n * name: 'string',\n * opt_uint8: 'Int32'\n * }\n * Then, we call the addMetadataInfo method with the following attributeTypesMap:\n * {\n * // The same attributes\n * color: 'string',\n * name: 'string',\n * opt_uint8: 'Int32',\n * // New attributes\n * opt_uint64: 'string',\n * opt_float32: 'double',\n * }\n * The method creates and stores objects for opt_uint64, opt_float32 attributes.\n */\n addMetadataInfo(attributeTypesMap: Record<string, Attribute>): void {\n if (!Object.keys(attributeTypesMap).length) {\n return;\n }\n const attributeTypes: Record<string, Attribute> = {\n OBJECTID: AttributeType.OBJECT_ID_TYPE,\n ...attributeTypesMap\n };\n\n let isUpdated = false;\n let attributeIndex = this._attributeStorageInfo.length;\n for (const key in attributeTypes) {\n /*\n We will append a new attribute only in case it has not been added to the attribute storage info yet.\n */\n const elementFound = this._attributeStorageInfo.find((element) => element.name === key);\n if (!elementFound) {\n const attributeType = attributeTypes[key];\n\n const storageAttribute = this.createStorageAttribute(attributeIndex, key, attributeType);\n const fieldAttributeType = this.getFieldAttributeType(attributeType);\n const fieldAttribute = this.createFieldAttribute(key, fieldAttributeType);\n\n this._attributeStorageInfo.push(storageAttribute);\n this._fields.push(fieldAttribute);\n attributeIndex += 1;\n isUpdated = true;\n }\n }\n if (isUpdated) {\n /*\n The attributeStorageInfo is updated. So, popupInfo should be recreated.\n Use attributeStorageInfo as a source of attribute names to create the popupInfo.\n */\n const attributeNames: string[] = [];\n for (let info of this._attributeStorageInfo) {\n attributeNames.push(info.name);\n }\n this._popupInfo = this.createPopupInfo(attributeNames);\n }\n }\n\n /**\n * Generates storage attribute for map segmentation.\n * @param attributeIndex - order index of attribute (f_0, f_1 ...).\n * @param key - attribute key from propertyTable.\n * @param attributeType - attribute type.\n * @return Updated storageAttribute.\n */\n private createStorageAttribute(\n attributeIndex: number,\n key: string,\n attributeType: Attribute\n ): AttributeStorageInfo {\n const storageAttribute = {\n key: `f_${attributeIndex}`,\n name: key,\n ordering: ['attributeValues'],\n header: [{property: 'count', valueType: 'UInt32'}],\n attributeValues: {valueType: 'Int32', valuesPerElement: 1}\n };\n\n switch (attributeType) {\n case AttributeType.OBJECT_ID_TYPE:\n this.setupIdAttribute(storageAttribute);\n break;\n case AttributeType.STRING_TYPE:\n this.setupStringAttribute(storageAttribute);\n break;\n case AttributeType.DOUBLE_TYPE:\n this.setupDoubleAttribute(storageAttribute);\n break;\n case AttributeType.SHORT_INT_TYPE:\n break;\n default:\n this.setupStringAttribute(storageAttribute);\n }\n\n return storageAttribute;\n }\n\n /**\n * Finds and returns attribute type based on key form propertyTable.\n * @param attributeType\n */\n private getFieldAttributeType(attributeType: Attribute): ESRIField {\n switch (attributeType) {\n case AttributeType.OBJECT_ID_TYPE:\n return 'esriFieldTypeOID';\n case AttributeType.STRING_TYPE:\n return 'esriFieldTypeString';\n case AttributeType.SHORT_INT_TYPE:\n return 'esriFieldTypeInteger';\n case AttributeType.DOUBLE_TYPE:\n return 'esriFieldTypeDouble';\n default:\n return 'esriFieldTypeString';\n }\n }\n\n /**\n * Sets up Id attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\n private setupIdAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Oid32',\n valuesPerElement: 1\n };\n }\n\n /**\n * Sets up storage attribute as string.\n * @param storageAttribute - attribute for map segmentation.\n */\n private setupStringAttribute(storageAttribute: AttributeStorageInfo): void {\n // @ts-expect-error\n storageAttribute.ordering.unshift('attributeByteCounts');\n storageAttribute.header.push({property: 'attributeValuesByteCount', valueType: 'UInt32'});\n storageAttribute.attributeValues = {\n valueType: 'String',\n encoding: 'UTF-8',\n valuesPerElement: 1\n };\n storageAttribute.attributeByteCounts = {\n valueType: 'UInt32',\n valuesPerElement: 1\n };\n }\n\n /**\n * Sets up double attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\n private setupDoubleAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Float64',\n valuesPerElement: 1\n };\n }\n\n /**\n * Sets up field attribute for map segmentation.\n * @param key - attribute for map segmentation.\n * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').\n */\n private createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field {\n return {\n name: key,\n type: fieldAttributeType,\n alias: key\n };\n }\n\n /**\n * Generates popup info to show metadata on the map.\n * @param propertyNames - array of property names including OBJECTID.\n * @return data for correct rendering of popup.\n */\n private createPopupInfo(propertyNames: string[]): PopupInfo {\n const title = '{OBJECTID}';\n const mediaInfos = [];\n const fieldInfos: FieldInfo[] = [];\n const popupElements: {\n fieldInfos: FieldInfo[];\n type: string;\n }[] = [];\n const expressionInfos = [];\n\n for (const propertyName of propertyNames) {\n fieldInfos.push({\n fieldName: propertyName,\n visible: true,\n isEditable: false,\n label: propertyName\n });\n }\n popupElements.push({\n fieldInfos,\n type: 'fields'\n });\n\n return {\n title,\n mediaInfos,\n popupElements,\n fieldInfos,\n expressionInfos\n };\n }\n}\n"],"mappings":"SASQA,aAAa;AAErB,OAAO,MAAMC,qBAAqB,CAAC;EAKjCC,WAAWA,CAAA,EAAG;IAAA,KAJNC,qBAAqB;IAAA,KACrBC,OAAO;IAAA,KACPC,UAAU;IAGhB,IAAI,CAACF,qBAAqB,GAAG,EAAE;IAC/B,IAAI,CAACC,OAAO,GAAG,EAAE;EACnB;EAEA,IAAIE,oBAAoBA,CAAA,EAA2B;IACjD,OAAO,IAAI,CAACH,qBAAqB;EACnC;EAEA,IAAII,MAAMA,CAAA,EAAY;IACpB,OAAO,IAAI,CAACH,OAAO;EACrB;EAEA,IAAII,SAASA,CAAA,EAA0B;IACrC,OAAO,IAAI,CAACH,UAAU;EACxB;EAwBAI,eAAeA,CAACC,iBAA4C,EAAQ;IAClE,IAAI,CAACC,MAAM,CAACC,IAAI,CAACF,iBAAiB,CAAC,CAACG,MAAM,EAAE;MAC1C;IACF;IACA,MAAMC,cAAyC,GAAG;MAChDC,QAAQ,EAAEf,aAAa,CAACg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AE,0BAA0B;MAAEC,SAAS,EAAE;IAAQ,CAAC,CAAC;IACzFb,gBAAgB,CAACc,eAAe,GAAG;MACjCD,SAAS,EAAE,QAAQ;MACnBU,QAAQ,EAAE,OAAO;MACjBR,gBAAgB,EAAE;IACpB,CAAC;IACDf,gBAAgB,CAACwB,mBAAmB,GAAG;MACrCX,SAAS,EAAE,QAAQ;MACnBE,gBAAgB,EAAE;IACpB,CAAC;EACH;EAMQK,oBAAoBA,CAACpB,gBAAsC,EAAQ;IACzEA,gBAAgB,CAACc,eAAe,GAAG;MACjCD,SAAS,EAAE,SAAS;MACpBE,gBAAgB,EAAE;IACpB,CAAC;EACH;EAOQV,oBAAoBA,CAACX,GAAW,EAAEQ,kBAA6B,EAAS;IAC9E,OAAO;MACLJ,IAAI,EAAEJ,GAAG;MACT+B,IAAI,EAAEvB,kBAAkB;MACxBwB,KAAK,EAAEhC;IACT,CAAC;EACH;EAOQe,eAAeA,CAACkB,aAAuB,EAAa;IAC1D,MAAMC,KAAK,GAAG,YAAY;IAC1B,MAAMC,UAAU,GAAG,EAAE;IACrB,MAAMC,UAAuB,GAAG,EAAE;IAClC,MAAMC,aAGH,GAAG,EAAE;IACR,MAAMC,eAAe,GAAG,EAAE;IAE1B,KAAK,MAAMC,YAAY,IAAIN,aAAa,EAAE;MACxCG,UAAU,CAACxB,IAAI,CAAC;QACd4B,SAAS,EAAED,YAAY;QACvBE,OAAO,EAAE,IAAI;QACbC,UAAU,EAAE,KAAK;QACjBC,KAAK,EAAEJ;MACT,CAAC,CAAC;IACJ;IACAF,aAAa,CAACzB,IAAI,CAAC;MACjBwB,UAAU;MACVL,IAAI,EAAE;IACR,CAAC,CAAC;IAEF,OAAO;MACLG,KAAK;MACLC,UAAU;MACVE,aAAa;MACbD,UAAU;MACVE;IACF,CAAC;EACH;AACF"}
1
+ {"version":3,"file":"attribute-metadata-info.js","names":["AttributeType","AttributeMetadataInfo","constructor","_attributeStorageInfo","_fields","_popupInfo","attributeStorageInfo","fields","popupInfo","addMetadataInfo","attributeTypesMap","Object","keys","length","attributeTypes","OBJECTID","OBJECT_ID_TYPE","isUpdated","attributeIndex","key","elementFound","find","element","name","attributeType","storageAttribute","createStorageAttribute","fieldAttributeType","getFieldAttributeType","fieldAttribute","createFieldAttribute","push","attributeNames","info","createPopupInfo","fromObject","object","ordering","header","property","valueType","attributeValues","valuesPerElement","setupIdAttribute","STRING_TYPE","setupStringAttribute","DOUBLE_TYPE","setupDoubleAttribute","SHORT_INT_TYPE","unshift","encoding","attributeByteCounts","type","alias","propertyNames","title","mediaInfos","fieldInfos","popupElements","expressionInfos","propertyName","fieldName","visible","isEditable","label"],"sources":["../../../src/i3s-converter/helpers/attribute-metadata-info.ts"],"sourcesContent":["import type {\n Attribute,\n AttributeStorageInfo,\n ESRIField,\n Field,\n FieldInfo,\n PopupInfo\n} from '@loaders.gl/i3s';\n\nimport {AttributeType} from '../types';\n\nexport type AttributeMetadataInfoObject = {\n attributeStorageInfo: AttributeStorageInfo[];\n fields: Field[];\n popupInfo: PopupInfo | undefined;\n};\n\nexport class AttributeMetadataInfo {\n private _attributeStorageInfo: AttributeStorageInfo[];\n private _fields: Field[];\n private _popupInfo: PopupInfo | undefined;\n\n constructor() {\n this._attributeStorageInfo = [];\n this._fields = [];\n }\n\n get attributeStorageInfo(): AttributeStorageInfo[] {\n return this._attributeStorageInfo;\n }\n\n get fields(): Field[] {\n return this._fields;\n }\n\n get popupInfo(): PopupInfo | undefined {\n return this._popupInfo;\n }\n\n /**\n * Creates and stores Attribute Storage Info, Fields and PopupInfo objects based on attribute's types.\n * Appends objects that have not been stored yet.\n * @param attributeTypesMap - set of attribute's types\n * @example AttributeStorageInfo, Fields and PopupInfo already contain objects for the following attributes:\n * {\n * color: 'string',\n * name: 'string',\n * opt_uint8: 'Int32'\n * }\n * Then, we call the addMetadataInfo method with the following attributeTypesMap:\n * {\n * // The same attributes\n * color: 'string',\n * name: 'string',\n * opt_uint8: 'Int32',\n * // New attributes\n * opt_uint64: 'string',\n * opt_float32: 'double',\n * }\n * The method creates and stores objects for opt_uint64, opt_float32 attributes.\n */\n addMetadataInfo(attributeTypesMap: Record<string, Attribute>): void {\n if (!Object.keys(attributeTypesMap).length) {\n return;\n }\n const attributeTypes: Record<string, Attribute> = {\n OBJECTID: AttributeType.OBJECT_ID_TYPE,\n ...attributeTypesMap\n };\n\n let isUpdated = false;\n let attributeIndex = this._attributeStorageInfo.length;\n for (const key in attributeTypes) {\n /*\n We will append a new attribute only in case it has not been added to the attribute storage info yet.\n */\n const elementFound = this._attributeStorageInfo.find((element) => element.name === key);\n if (!elementFound) {\n const attributeType = attributeTypes[key];\n\n const storageAttribute = this.createStorageAttribute(attributeIndex, key, attributeType);\n const fieldAttributeType = this.getFieldAttributeType(attributeType);\n const fieldAttribute = this.createFieldAttribute(key, fieldAttributeType);\n\n this._attributeStorageInfo.push(storageAttribute);\n this._fields.push(fieldAttribute);\n attributeIndex += 1;\n isUpdated = true;\n }\n }\n if (isUpdated) {\n /*\n The attributeStorageInfo is updated. So, popupInfo should be recreated.\n Use attributeStorageInfo as a source of attribute names to create the popupInfo.\n */\n const attributeNames: string[] = [];\n for (let info of this._attributeStorageInfo) {\n attributeNames.push(info.name);\n }\n this._popupInfo = this.createPopupInfo(attributeNames);\n }\n }\n\n /**\n * Set AttributeMetadataInfo from object\n * @param object - object with AttributeMetadataInfo props\n */\n fromObject(object: AttributeMetadataInfoObject) {\n this._attributeStorageInfo = object.attributeStorageInfo;\n this._fields = object.fields;\n this._popupInfo = object.popupInfo;\n }\n\n /**\n * Generates storage attribute for map segmentation.\n * @param attributeIndex - order index of attribute (f_0, f_1 ...).\n * @param key - attribute key from propertyTable.\n * @param attributeType - attribute type.\n * @return Updated storageAttribute.\n */\n private createStorageAttribute(\n attributeIndex: number,\n key: string,\n attributeType: Attribute\n ): AttributeStorageInfo {\n const storageAttribute = {\n key: `f_${attributeIndex}`,\n name: key,\n ordering: ['attributeValues'],\n header: [{property: 'count', valueType: 'UInt32'}],\n attributeValues: {valueType: 'Int32', valuesPerElement: 1}\n };\n\n switch (attributeType) {\n case AttributeType.OBJECT_ID_TYPE:\n this.setupIdAttribute(storageAttribute);\n break;\n case AttributeType.STRING_TYPE:\n this.setupStringAttribute(storageAttribute);\n break;\n case AttributeType.DOUBLE_TYPE:\n this.setupDoubleAttribute(storageAttribute);\n break;\n case AttributeType.SHORT_INT_TYPE:\n break;\n default:\n this.setupStringAttribute(storageAttribute);\n }\n\n return storageAttribute;\n }\n\n /**\n * Finds and returns attribute type based on key form propertyTable.\n * @param attributeType\n */\n private getFieldAttributeType(attributeType: Attribute): ESRIField {\n switch (attributeType) {\n case AttributeType.OBJECT_ID_TYPE:\n return 'esriFieldTypeOID';\n case AttributeType.STRING_TYPE:\n return 'esriFieldTypeString';\n case AttributeType.SHORT_INT_TYPE:\n return 'esriFieldTypeInteger';\n case AttributeType.DOUBLE_TYPE:\n return 'esriFieldTypeDouble';\n default:\n return 'esriFieldTypeString';\n }\n }\n\n /**\n * Sets up Id attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\n private setupIdAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Oid32',\n valuesPerElement: 1\n };\n }\n\n /**\n * Sets up storage attribute as string.\n * @param storageAttribute - attribute for map segmentation.\n */\n private setupStringAttribute(storageAttribute: AttributeStorageInfo): void {\n // @ts-expect-error\n storageAttribute.ordering.unshift('attributeByteCounts');\n storageAttribute.header.push({property: 'attributeValuesByteCount', valueType: 'UInt32'});\n storageAttribute.attributeValues = {\n valueType: 'String',\n encoding: 'UTF-8',\n valuesPerElement: 1\n };\n storageAttribute.attributeByteCounts = {\n valueType: 'UInt32',\n valuesPerElement: 1\n };\n }\n\n /**\n * Sets up double attribute for map segmentation.\n * @param storageAttribute - attribute for map segmentation .\n */\n private setupDoubleAttribute(storageAttribute: AttributeStorageInfo): void {\n storageAttribute.attributeValues = {\n valueType: 'Float64',\n valuesPerElement: 1\n };\n }\n\n /**\n * Sets up field attribute for map segmentation.\n * @param key - attribute for map segmentation.\n * @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').\n */\n private createFieldAttribute(key: string, fieldAttributeType: ESRIField): Field {\n return {\n name: key,\n type: fieldAttributeType,\n alias: key\n };\n }\n\n /**\n * Generates popup info to show metadata on the map.\n * @param propertyNames - array of property names including OBJECTID.\n * @return data for correct rendering of popup.\n */\n private createPopupInfo(propertyNames: string[]): PopupInfo {\n const title = '{OBJECTID}';\n const mediaInfos = [];\n const fieldInfos: FieldInfo[] = [];\n const popupElements: {\n fieldInfos: FieldInfo[];\n type: string;\n }[] = [];\n const expressionInfos = [];\n\n for (const propertyName of propertyNames) {\n fieldInfos.push({\n fieldName: propertyName,\n visible: true,\n isEditable: false,\n label: propertyName\n });\n }\n popupElements.push({\n fieldInfos,\n type: 'fields'\n });\n\n return {\n title,\n mediaInfos,\n popupElements,\n fieldInfos,\n expressionInfos\n };\n }\n}\n"],"mappings":"SASQA,aAAa;AAQrB,OAAO,MAAMC,qBAAqB,CAAC;EAKjCC,WAAWA,CAAA,EAAG;IAAA,KAJNC,qBAAqB;IAAA,KACrBC,OAAO;IAAA,KACPC,UAAU;IAGhB,IAAI,CAACF,qBAAqB,GAAG,EAAE;IAC/B,IAAI,CAACC,OAAO,GAAG,EAAE;EACnB;EAEA,IAAIE,oBAAoBA,CAAA,EAA2B;IACjD,OAAO,IAAI,CAACH,qBAAqB;EACnC;EAEA,IAAII,MAAMA,CAAA,EAAY;IACpB,OAAO,IAAI,CAACH,OAAO;EACrB;EAEA,IAAII,SAASA,CAAA,EAA0B;IACrC,OAAO,IAAI,CAACH,UAAU;EACxB;EAwBAI,eAAeA,CAACC,iBAA4C,EAAQ;IAClE,IAAI,CAACC,MAAM,CAACC,IAAI,CAACF,iBAAiB,CAAC,CAACG,MAAM,EAAE;MAC1C;IACF;IACA,MAAMC,cAAyC,GAAG;MAChDC,QAAQ,EAAEf,aAAa,CAACg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AI,EAAE;IACR,CAAC,CAAC;IAEF,OAAO;MACLG,KAAK;MACLC,UAAU;MACVE,aAAa;MACbD,UAAU;MACVE;IACF,CAAC;EACH;AACF"}
@@ -1,6 +1,7 @@
1
1
  import { BoundingVolumes, LodSelection, Node3DIndexDocument, NodeInPage } from '@loaders.gl/i3s';
2
2
  import I3SConverter from '../i3s-converter';
3
3
  import { I3SConvertedResources } from '../types';
4
+ import { DumpMetadata } from '../../lib/utils/conversion-dump';
4
5
  /**
5
6
  * Wrapper for https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md data
6
7
  * The class allows working with 3DNodeIndexDocument in 2 modes:
@@ -98,6 +99,6 @@ export declare class NodeIndexDocument {
98
99
  * @param resources.attributes - feature attributes
99
100
  * @return 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object
100
101
  */
101
- static createNodeIndexDocument(parentNode: NodeIndexDocument, boundingVolumes: BoundingVolumes, lodSelection: LodSelection[], nodeInPage: NodeInPage, resources: I3SConvertedResources): Promise<Node3DIndexDocument>;
102
+ static createNodeIndexDocument(parentNode: NodeIndexDocument, boundingVolumes: BoundingVolumes, lodSelection: LodSelection[], nodeInPage: NodeInPage, resources: I3SConvertedResources | DumpMetadata): Promise<Node3DIndexDocument>;
102
103
  }
103
104
  //# sourceMappingURL=node-index-document.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-index-document.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/node-index-document.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,UAAU,EAEX,MAAM,iBAAiB,CAAC;AAIzB,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAC,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAE/C;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,cAAc;IACP,EAAE,EAAE,MAAM,CAAC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U,EAAE,iBAAiB,EAC7B,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAAE,EAC5B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,qBAAqB,GAC/B,OAAO,CAAC,mBAAmB,CAAC;CAgDhC"}
1
+ {"version":3,"file":"node-index-document.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/node-index-document.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,UAAU,EAEX,MAAM,iBAAiB,CAAC;AAIzB,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAC,qBAAqB,EAAC,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAC,YAAY,EAAC,MAAM,iCAAiC,CAAC;AAE7D;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,cAAc;IACP,EAAE,EAAE,MAAM,CAAC;IAClB,uBAAuB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACxB,+BAA+B;IACxB,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAQ;IAC/C,eAAe;IACR,QAAQ,EAAE,iBAAiB,EAAE,CAAM;IAC1C,yBAAyB;IACzB,OAAO,CAAC,SAAS,CAAe;IAEhC;;;OAGG;IACH,OAAO,CAAC,UAAU,CAAkB;IACpC,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;;;OAIG;gBACS,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY;IAM/C;;;;OAIG;IACU,OAAO,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAS3E;;;OAGG;IACU,WAAW,CAAC,UAAU,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BxE;;OAEG;IACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAmC1C,+CAA+C;IAClC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAMlC,wBAAwB;IACxB,OAAO,CAAC,QAAQ;IAOhB;;;OAGG;YACW,KAAK;IAyBnB;;;OAGG;YACW,IAAI;IAalB;;OAEG;IACH,OAAO,CAAC,KAAK;IAIb;;;;;OAKG;WACU,cAAc,CACzB,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,iBAAiB,CAAC;IAM7B;;;;;;;;;OASG;WACU,UAAU,CACrB,UAAU,EAAE,iBAAiB,EAC7B,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAAE,EAC5B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,qBAAqB,EAChC,SAAS,EAAE,YAAY,GACtB,OAAO,CAAC,iBAAiB,CAAC;IAY7B;;;;OAIG;IACH,MAAM,CAAC,2BAA2B,CAAC,eAAe,EAAE,eAAe,GAAG,mBAAmB;IAqBzF;;;;;;;;;;OAUG;WACU,uBAAuB,CAClC,UAAU,EAAE,iBAAiB,EAC7B,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,EAAE,EAC5B,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,qBAAqB,GAAG,YAAY,GAC9C,OAAO,CAAC,mBAAmB,CAAC;CAyDhC"}
@@ -147,10 +147,6 @@ export class NodeIndexDocument {
147
147
  return transform(root0data, nodeTemplate());
148
148
  }
149
149
  static async createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources) {
150
- const {
151
- texture,
152
- attributes
153
- } = resources;
154
150
  const nodeId = nodeInPage.index;
155
151
  const parentNodeData = await parentNode.load();
156
152
  const nodeData = {
@@ -170,23 +166,25 @@ export class NodeIndexDocument {
170
166
  };
171
167
  const node = transform(nodeData, nodeTemplate());
172
168
  if (nodeInPage.mesh) {
173
- var _parentNode$converter, _parentNode$converter2;
169
+ var _parentNode$converter, _parentNode$converter2, _parentNode$converter3, _parentNode$converter4;
174
170
  node.geometryData = [{
175
171
  href: './geometries/0'
176
172
  }];
177
173
  node.sharedResource = {
178
174
  href: './shared'
179
175
  };
180
- if (texture) {
176
+ if ('texture' in resources && resources.texture || 'texelCountHint' in resources && resources.texelCountHint) {
181
177
  node.textureData = [{
182
178
  href: './textures/0'
183
179
  }, {
184
180
  href: './textures/1'
185
181
  }];
186
182
  }
187
- if (attributes && attributes.length && (_parentNode$converter = parentNode.converter.layers0) !== null && _parentNode$converter !== void 0 && (_parentNode$converter2 = _parentNode$converter.attributeStorageInfo) !== null && _parentNode$converter2 !== void 0 && _parentNode$converter2.length) {
183
+ if ('attributes' in resources && resources.attributes && resources.attributes.length && (_parentNode$converter = parentNode.converter.layers0) !== null && _parentNode$converter !== void 0 && (_parentNode$converter2 = _parentNode$converter.attributeStorageInfo) !== null && _parentNode$converter2 !== void 0 && _parentNode$converter2.length || 'attributesCount' in resources && resources.attributesCount && (_parentNode$converter3 = parentNode.converter.layers0) !== null && _parentNode$converter3 !== void 0 && (_parentNode$converter4 = _parentNode$converter3.attributeStorageInfo) !== null && _parentNode$converter4 !== void 0 && _parentNode$converter4.length) {
184
+ var _resources$attributes;
185
+ const attributesLength = ('attributes' in resources ? (_resources$attributes = resources.attributes) === null || _resources$attributes === void 0 ? void 0 : _resources$attributes.length : resources.attributesCount) || 0;
188
186
  node.attributeData = [];
189
- const minimumLength = attributes.length < parentNode.converter.layers0.attributeStorageInfo.length ? attributes.length : parentNode.converter.layers0.attributeStorageInfo.length;
187
+ const minimumLength = attributesLength < parentNode.converter.layers0.attributeStorageInfo.length ? attributesLength : parentNode.converter.layers0.attributeStorageInfo.length;
190
188
  for (let index = 0; index < minimumLength; index++) {
191
189
  const folderName = parentNode.converter.layers0.attributeStorageInfo[index].key;
192
190
  node.attributeData.push({
@@ -1 +1 @@
1
- {"version":3,"file":"node-index-document.js","names":["join","transform","v4","uuidv4","openJson","writeFile","writeFileForSlpk","NODE","nodeTemplate","NodeIndexDocument","finalized","_finalized","constructor","id","converter","inPageId","data","children","toString","addData","options","instantNodeWriting","write","addChildren","childNodes","newChildren","node","nodeData","load","push","href","obb","mbs","concat","_data$children","addNeighbors","childNode","_childNodeData$neighb","_nodeData$children","childNodeData","neighbors","Number","length","neighbor","console","warn","save","finalize","child","flush","path","layers0Path","slpk","writeQueue","enqueue","archiveKey","writePromise","JSON","stringify","compressList","parentNodePath","parentNodeFileName","createRootNode","boundingVolumes","rootData","createRootNodeIndexDocument","rootNode","createNode","parentNode","lodSelection","nodeInPage","resources","createNodeIndexDocument","index","root0data","version","toUpperCase","level","metricType","maxError","texture","attributes","nodeId","parentNodeData","mesh","_parentNode$converter","_parentNode$converter2","geometryData","sharedResource","textureData","layers0","attributeStorageInfo","attributeData","minimumLength","folderName","key"],"sources":["../../../src/i3s-converter/helpers/node-index-document.ts"],"sourcesContent":["import {join} from 'path';\nimport {\n BoundingVolumes,\n LodSelection,\n Node3DIndexDocument,\n NodeInPage,\n NodeReference\n} from '@loaders.gl/i3s';\nimport transform from 'json-map-transform';\nimport {v4 as uuidv4} from 'uuid';\nimport {openJson, writeFile, writeFileForSlpk} from '../../lib/utils/file-utils';\nimport I3SConverter from '../i3s-converter';\nimport {NODE as nodeTemplate} from '../json-templates/node';\nimport {I3SConvertedResources} from '../types';\n\n/**\n * Wrapper for https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md data\n * The class allows working with 3DNodeIndexDocument in 2 modes:\n * in memory: the data is stored in `data` field\n * on disk: the data is written on disk in a file. The file can be rewritten when new childrend or neighbors have to be added\n */\nexport class NodeIndexDocument {\n /** Node id */\n public id: string;\n /** Id in node pages */\n public inPageId: number;\n /** 3DNodeIndexDocument data */\n public data: Node3DIndexDocument | null = null;\n /** children */\n public children: NodeIndexDocument[] = [];\n /** converter instance */\n private converter: I3SConverter;\n\n /**\n * Finalized property. It means that all child nodes are saved and their data\n * is unloaded\n */\n private _finalized: boolean = false;\n get finalized(): boolean {\n return this._finalized;\n }\n\n /**\n * Constructor\n * @param id - id of the node in node pages\n * @param converter - converter instance\n */\n constructor(id: number, converter: I3SConverter) {\n this.inPageId = id;\n this.id = id === 0 ? 'root' : id.toString();\n this.converter = converter;\n }\n\n /**\n * Add Node3DIndexDocument data to the node\n * @param data Node3DIndexDocument data\n * @returns this NodeIndexDocument instance (to recurring with constructor)\n */\n public async addData(data: Node3DIndexDocument): Promise<NodeIndexDocument> {\n if (this.converter.options.instantNodeWriting) {\n await this.write(data);\n } else {\n this.data = data;\n }\n return this;\n }\n\n /**\n * Add child node references\n * @param childNodes - child NodeIndexDocument instances\n */\n public async addChildren(childNodes: NodeIndexDocument[]): Promise<void> {\n const newChildren: NodeReference[] = [];\n for (const node of childNodes) {\n const nodeData = await node.load();\n newChildren.push({\n id: node.id,\n href: `../${node.id}`,\n obb: nodeData.obb,\n mbs: nodeData.mbs\n });\n }\n this.children = this.children.concat(childNodes);\n\n let data: Node3DIndexDocument | null = this.data;\n if (this.converter.options.instantNodeWriting) {\n data = (await this.load()) as Node3DIndexDocument;\n }\n if (data) {\n data.children = data.children ?? [];\n data.children = data.children.concat(newChildren);\n }\n if (this.converter.options.instantNodeWriting && data) {\n await this.write(data);\n }\n }\n\n /**\n * Add neighbors to child nodes of this node\n */\n public async addNeighbors(): Promise<void> {\n if (this.finalized) {\n return;\n }\n const nodeData = await this.load();\n for (const childNode of this.children) {\n const childNodeData = await childNode.load();\n childNodeData.neighbors = childNodeData.neighbors ?? [];\n\n // Don't do large amount of \"neightbors\" to avoid big memory consumption\n if (Number(nodeData?.children?.length) < 1000) {\n for (const neighbor of nodeData.children || []) {\n if (childNode.id === neighbor.id) {\n continue; // eslint-disable-line\n }\n\n childNodeData.neighbors.push({...neighbor});\n }\n } else {\n // eslint-disable-next-line no-console, no-undef\n console.warn(\n `Node ${childNode.id}: neighbors attribute is omited because of large number of neigbors`\n );\n delete childNodeData.neighbors;\n }\n\n if (this.converter.options.instantNodeWriting && childNodeData) {\n await childNode.write(childNodeData);\n }\n await childNode.save();\n }\n // The save after adding neighbors is the last one. Finalize the the node\n this.finalize();\n }\n\n /** Save 3DNodeIndexDocument in file on disk */\n public async save(): Promise<void> {\n if (this.data) {\n await this.write(this.data);\n }\n }\n\n /** Finalize the node */\n private finalize(): void {\n this._finalized = true;\n for (const child of this.children) {\n child.flush();\n }\n }\n\n /**\n * Write 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md\n * @param node - Node3DIndexDocument object\n */\n private async write(node: Node3DIndexDocument): Promise<void> {\n const path = join(this.converter.layers0Path, 'nodes', this.id);\n if (this.converter.options.slpk) {\n await this.converter.writeQueue.enqueue(\n {\n archiveKey: `nodes/${this.id}/3dNodeIndexDocument.json.gz`,\n writePromise: () =>\n writeFileForSlpk(\n path,\n JSON.stringify(node),\n '3dNodeIndexDocument.json',\n true,\n this.converter.compressList\n )\n },\n true\n );\n } else {\n await this.converter.writeQueue.enqueue(\n {writePromise: () => writeFile(path, JSON.stringify(node))},\n true\n );\n }\n }\n\n /**\n * Load 3DNodeIndexDocument data from file on disk\n * @returns 3DNodeIndexDocument object\n */\n private async load(): Promise<Node3DIndexDocument> {\n if (this.data) {\n return this.data;\n }\n const path = this.id;\n const parentNodePath = join(this.converter.layers0Path, 'nodes', path);\n let parentNodeFileName = 'index.json';\n if (this.converter.options.slpk) {\n parentNodeFileName = '3dNodeIndexDocument.json';\n }\n return (await openJson(parentNodePath, parentNodeFileName)) as Node3DIndexDocument;\n }\n\n /**\n * Unload the Node data\n */\n private flush(): void {\n this.data = null;\n }\n\n /**\n * Create root node of the tree\n * @param boundingVolumes - MBS and OOB bounding volumes data\n * @param converter - I3SConverter instance\n * @returns instance of NodeIndexDocument\n */\n static async createRootNode(\n boundingVolumes: BoundingVolumes,\n converter: I3SConverter\n ): Promise<NodeIndexDocument> {\n const rootData = NodeIndexDocument.createRootNodeIndexDocument(boundingVolumes);\n const rootNode = await new NodeIndexDocument(0, converter).addData(rootData);\n return rootNode;\n }\n\n /**\n * Create NodeIndexDocument instance\n * @param parentNode - parent NodeIndexDocument\n * @param boundingVolumes - MBS and OOB bounding volumes data\n * @param lodSelection - LOD metrics data\n * @param nodeInPage - node data in node pages\n * @param resources - resources extracted from gltf/b3dm file\n * @param converter - I3SConverter instance\n * @returns NodeIndexDocument instance\n */\n static async createNode(\n parentNode: NodeIndexDocument,\n boundingVolumes: BoundingVolumes,\n lodSelection: LodSelection[],\n nodeInPage: NodeInPage,\n resources: I3SConvertedResources,\n converter: I3SConverter\n ): Promise<NodeIndexDocument> {\n const data = await NodeIndexDocument.createNodeIndexDocument(\n parentNode,\n boundingVolumes,\n lodSelection,\n nodeInPage,\n resources\n );\n const node = await new NodeIndexDocument(nodeInPage.index, converter).addData(data);\n return node;\n }\n\n /**\n * Form 3DNodeIndexDocument data for the root node\n * @param boundingVolumes - mbs and obb data about node's bounding volume\n * @return 3DNodeIndexDocument data https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md\n */\n static createRootNodeIndexDocument(boundingVolumes: BoundingVolumes): Node3DIndexDocument {\n const root0data = {\n version: `{${uuidv4().toUpperCase()}}`,\n id: 'root',\n level: 0,\n lodSelection: [\n {\n metricType: 'maxScreenThresholdSQ',\n maxError: 0\n },\n {\n metricType: 'maxScreenThreshold',\n maxError: 0\n }\n ],\n ...boundingVolumes,\n children: []\n };\n return transform(root0data, nodeTemplate());\n }\n\n /**\n * Create a new Node3DIndexDocument\n * @param parentNode - 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object of the parent node\n * @param boundingVolumes - Bounding volumes\n * @param lodSelection - Level of Details (LOD) metrics\n * @param nodeInPage - corresponding node object in a node page\n * @param resources - the node resources data\n * @param resources.texture - texture image\n * @param resources.attributes - feature attributes\n * @return 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object\n */\n static async createNodeIndexDocument(\n parentNode: NodeIndexDocument,\n boundingVolumes: BoundingVolumes,\n lodSelection: LodSelection[],\n nodeInPage: NodeInPage,\n resources: I3SConvertedResources\n ): Promise<Node3DIndexDocument> {\n const {texture, attributes} = resources;\n const nodeId = nodeInPage.index!;\n const parentNodeData = await parentNode.load();\n const nodeData = {\n version: parentNodeData.version,\n id: nodeId.toString(),\n level: parentNodeData.level! + 1,\n ...boundingVolumes,\n lodSelection,\n parentNode: {\n id: parentNode.id,\n href: `../${parentNode.id}`,\n mbs: parentNodeData.mbs,\n obb: parentNodeData.obb\n },\n children: [],\n neighbors: []\n };\n const node = transform(nodeData, nodeTemplate());\n\n if (nodeInPage.mesh) {\n node.geometryData = [{href: './geometries/0'}];\n node.sharedResource = {href: './shared'};\n\n if (texture) {\n node.textureData = [{href: './textures/0'}, {href: './textures/1'}];\n }\n\n if (\n attributes &&\n attributes.length &&\n parentNode.converter.layers0?.attributeStorageInfo?.length\n ) {\n node.attributeData = [];\n const minimumLength =\n attributes.length < parentNode.converter.layers0.attributeStorageInfo.length\n ? attributes.length\n : parentNode.converter.layers0.attributeStorageInfo.length;\n for (let index = 0; index < minimumLength; index++) {\n const folderName = parentNode.converter.layers0.attributeStorageInfo[index].key;\n node.attributeData.push({href: `./attributes/${folderName}/0`});\n }\n }\n }\n\n return node;\n }\n}\n"],"mappings":"AAAA,SAAQA,IAAI,QAAO,MAAM;AAQzB,OAAOC,SAAS,MAAM,oBAAoB;AAC1C,SAAQC,EAAE,IAAIC,MAAM,QAAO,MAAM;AAAC,SAC1BC,QAAQ,EAAEC,SAAS,EAAEC,gBAAgB;AAAA,SAErCC,IAAI,IAAIC,YAAY;AAS5B,OAAO,MAAMC,iBAAiB,CAAC;EAiB7B,IAAIC,SAASA,CAAA,EAAY;IACvB,OAAO,IAAI,CAACC,UAAU;EACxB;EAOAC,WAAWA,CAACC,EAAU,EAAEC,SAAuB,EAAE;IAAA,KAxB1CD,EAAE;IAAA,KAEFE,QAAQ;IAAA,KAERC,IAAI,GAA+B,IAAI;IAAA,KAEvCC,QAAQ,GAAwB,EAAE;IAAA,KAEjCH,SAAS;IA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+ {"version":3,"file":"node-index-document.js","names":["join","transform","v4","uuidv4","openJson","writeFile","writeFileForSlpk","NODE","nodeTemplate","NodeIndexDocument","finalized","_finalized","constructor","id","converter","inPageId","data","children","toString","addData","options","instantNodeWriting","write","addChildren","childNodes","newChildren","node","nodeData","load","push","href","obb","mbs","concat","_data$children","addNeighbors","childNode","_childNodeData$neighb","_nodeData$children","childNodeData","neighbors","Number","length","neighbor","console","warn","save","finalize","child","flush","path","layers0Path","slpk","writeQueue","enqueue","archiveKey","writePromise","JSON","stringify","compressList","parentNodePath","parentNodeFileName","createRootNode","boundingVolumes","rootData","createRootNodeIndexDocument","rootNode","createNode","parentNode","lodSelection","nodeInPage","resources","createNodeIndexDocument","index","root0data","version","toUpperCase","level","metricType","maxError","nodeId","parentNodeData","mesh","_parentNode$converter","_parentNode$converter2","_parentNode$converter3","_parentNode$converter4","geometryData","sharedResource","texture","texelCountHint","textureData","attributes","layers0","attributeStorageInfo","attributesCount","_resources$attributes","attributesLength","attributeData","minimumLength","folderName","key"],"sources":["../../../src/i3s-converter/helpers/node-index-document.ts"],"sourcesContent":["import {join} from 'path';\nimport {\n BoundingVolumes,\n LodSelection,\n Node3DIndexDocument,\n NodeInPage,\n NodeReference\n} from '@loaders.gl/i3s';\nimport transform from 'json-map-transform';\nimport {v4 as uuidv4} from 'uuid';\nimport {openJson, writeFile, writeFileForSlpk} from '../../lib/utils/file-utils';\nimport I3SConverter from '../i3s-converter';\nimport {NODE as nodeTemplate} from '../json-templates/node';\nimport {I3SConvertedResources} from '../types';\nimport {DumpMetadata} from '../../lib/utils/conversion-dump';\n\n/**\n * Wrapper for https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md data\n * The class allows working with 3DNodeIndexDocument in 2 modes:\n * in memory: the data is stored in `data` field\n * on disk: the data is written on disk in a file. The file can be rewritten when new childrend or neighbors have to be added\n */\nexport class NodeIndexDocument {\n /** Node id */\n public id: string;\n /** Id in node pages */\n public inPageId: number;\n /** 3DNodeIndexDocument data */\n public data: Node3DIndexDocument | null = null;\n /** children */\n public children: NodeIndexDocument[] = [];\n /** converter instance */\n private converter: I3SConverter;\n\n /**\n * Finalized property. It means that all child nodes are saved and their data\n * is unloaded\n */\n private _finalized: boolean = false;\n get finalized(): boolean {\n return this._finalized;\n }\n\n /**\n * Constructor\n * @param id - id of the node in node pages\n * @param converter - converter instance\n */\n constructor(id: number, converter: I3SConverter) {\n this.inPageId = id;\n this.id = id === 0 ? 'root' : id.toString();\n this.converter = converter;\n }\n\n /**\n * Add Node3DIndexDocument data to the node\n * @param data Node3DIndexDocument data\n * @returns this NodeIndexDocument instance (to recurring with constructor)\n */\n public async addData(data: Node3DIndexDocument): Promise<NodeIndexDocument> {\n if (this.converter.options.instantNodeWriting) {\n await this.write(data);\n } else {\n this.data = data;\n }\n return this;\n }\n\n /**\n * Add child node references\n * @param childNodes - child NodeIndexDocument instances\n */\n public async addChildren(childNodes: NodeIndexDocument[]): Promise<void> {\n const newChildren: NodeReference[] = [];\n for (const node of childNodes) {\n const nodeData = await node.load();\n newChildren.push({\n id: node.id,\n href: `../${node.id}`,\n obb: nodeData.obb,\n mbs: nodeData.mbs\n });\n }\n this.children = this.children.concat(childNodes);\n\n let data: Node3DIndexDocument | null = this.data;\n if (this.converter.options.instantNodeWriting) {\n data = (await this.load()) as Node3DIndexDocument;\n }\n if (data) {\n data.children = data.children ?? [];\n data.children = data.children.concat(newChildren);\n }\n if (this.converter.options.instantNodeWriting && data) {\n await this.write(data);\n }\n }\n\n /**\n * Add neighbors to child nodes of this node\n */\n public async addNeighbors(): Promise<void> {\n if (this.finalized) {\n return;\n }\n const nodeData = await this.load();\n for (const childNode of this.children) {\n const childNodeData = await childNode.load();\n childNodeData.neighbors = childNodeData.neighbors ?? [];\n\n // Don't do large amount of \"neightbors\" to avoid big memory consumption\n if (Number(nodeData?.children?.length) < 1000) {\n for (const neighbor of nodeData.children || []) {\n if (childNode.id === neighbor.id) {\n continue; // eslint-disable-line\n }\n\n childNodeData.neighbors.push({...neighbor});\n }\n } else {\n // eslint-disable-next-line no-console, no-undef\n console.warn(\n `Node ${childNode.id}: neighbors attribute is omited because of large number of neigbors`\n );\n delete childNodeData.neighbors;\n }\n\n if (this.converter.options.instantNodeWriting && childNodeData) {\n await childNode.write(childNodeData);\n }\n await childNode.save();\n }\n // The save after adding neighbors is the last one. Finalize the the node\n this.finalize();\n }\n\n /** Save 3DNodeIndexDocument in file on disk */\n public async save(): Promise<void> {\n if (this.data) {\n await this.write(this.data);\n }\n }\n\n /** Finalize the node */\n private finalize(): void {\n this._finalized = true;\n for (const child of this.children) {\n child.flush();\n }\n }\n\n /**\n * Write 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md\n * @param node - Node3DIndexDocument object\n */\n private async write(node: Node3DIndexDocument): Promise<void> {\n const path = join(this.converter.layers0Path, 'nodes', this.id);\n if (this.converter.options.slpk) {\n await this.converter.writeQueue.enqueue(\n {\n archiveKey: `nodes/${this.id}/3dNodeIndexDocument.json.gz`,\n writePromise: () =>\n writeFileForSlpk(\n path,\n JSON.stringify(node),\n '3dNodeIndexDocument.json',\n true,\n this.converter.compressList\n )\n },\n true\n );\n } else {\n await this.converter.writeQueue.enqueue(\n {writePromise: () => writeFile(path, JSON.stringify(node))},\n true\n );\n }\n }\n\n /**\n * Load 3DNodeIndexDocument data from file on disk\n * @returns 3DNodeIndexDocument object\n */\n private async load(): Promise<Node3DIndexDocument> {\n if (this.data) {\n return this.data;\n }\n const path = this.id;\n const parentNodePath = join(this.converter.layers0Path, 'nodes', path);\n let parentNodeFileName = 'index.json';\n if (this.converter.options.slpk) {\n parentNodeFileName = '3dNodeIndexDocument.json';\n }\n return (await openJson(parentNodePath, parentNodeFileName)) as Node3DIndexDocument;\n }\n\n /**\n * Unload the Node data\n */\n private flush(): void {\n this.data = null;\n }\n\n /**\n * Create root node of the tree\n * @param boundingVolumes - MBS and OOB bounding volumes data\n * @param converter - I3SConverter instance\n * @returns instance of NodeIndexDocument\n */\n static async createRootNode(\n boundingVolumes: BoundingVolumes,\n converter: I3SConverter\n ): Promise<NodeIndexDocument> {\n const rootData = NodeIndexDocument.createRootNodeIndexDocument(boundingVolumes);\n const rootNode = await new NodeIndexDocument(0, converter).addData(rootData);\n return rootNode;\n }\n\n /**\n * Create NodeIndexDocument instance\n * @param parentNode - parent NodeIndexDocument\n * @param boundingVolumes - MBS and OOB bounding volumes data\n * @param lodSelection - LOD metrics data\n * @param nodeInPage - node data in node pages\n * @param resources - resources extracted from gltf/b3dm file\n * @param converter - I3SConverter instance\n * @returns NodeIndexDocument instance\n */\n static async createNode(\n parentNode: NodeIndexDocument,\n boundingVolumes: BoundingVolumes,\n lodSelection: LodSelection[],\n nodeInPage: NodeInPage,\n resources: I3SConvertedResources,\n converter: I3SConverter\n ): Promise<NodeIndexDocument> {\n const data = await NodeIndexDocument.createNodeIndexDocument(\n parentNode,\n boundingVolumes,\n lodSelection,\n nodeInPage,\n resources\n );\n const node = await new NodeIndexDocument(nodeInPage.index, converter).addData(data);\n return node;\n }\n\n /**\n * Form 3DNodeIndexDocument data for the root node\n * @param boundingVolumes - mbs and obb data about node's bounding volume\n * @return 3DNodeIndexDocument data https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md\n */\n static createRootNodeIndexDocument(boundingVolumes: BoundingVolumes): Node3DIndexDocument {\n const root0data = {\n version: `{${uuidv4().toUpperCase()}}`,\n id: 'root',\n level: 0,\n lodSelection: [\n {\n metricType: 'maxScreenThresholdSQ',\n maxError: 0\n },\n {\n metricType: 'maxScreenThreshold',\n maxError: 0\n }\n ],\n ...boundingVolumes,\n children: []\n };\n return transform(root0data, nodeTemplate());\n }\n\n /**\n * Create a new Node3DIndexDocument\n * @param parentNode - 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object of the parent node\n * @param boundingVolumes - Bounding volumes\n * @param lodSelection - Level of Details (LOD) metrics\n * @param nodeInPage - corresponding node object in a node page\n * @param resources - the node resources data\n * @param resources.texture - texture image\n * @param resources.attributes - feature attributes\n * @return 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object\n */\n static async createNodeIndexDocument(\n parentNode: NodeIndexDocument,\n boundingVolumes: BoundingVolumes,\n lodSelection: LodSelection[],\n nodeInPage: NodeInPage,\n resources: I3SConvertedResources | DumpMetadata\n ): Promise<Node3DIndexDocument> {\n const nodeId = nodeInPage.index!;\n const parentNodeData = await parentNode.load();\n const nodeData = {\n version: parentNodeData.version,\n id: nodeId.toString(),\n level: parentNodeData.level! + 1,\n ...boundingVolumes,\n lodSelection,\n parentNode: {\n id: parentNode.id,\n href: `../${parentNode.id}`,\n mbs: parentNodeData.mbs,\n obb: parentNodeData.obb\n },\n children: [],\n neighbors: []\n };\n const node = transform(nodeData, nodeTemplate());\n\n if (nodeInPage.mesh) {\n node.geometryData = [{href: './geometries/0'}];\n node.sharedResource = {href: './shared'};\n\n if (\n ('texture' in resources && resources.texture) ||\n ('texelCountHint' in resources && resources.texelCountHint)\n ) {\n node.textureData = [{href: './textures/0'}, {href: './textures/1'}];\n }\n\n if (\n ('attributes' in resources &&\n resources.attributes &&\n resources.attributes.length &&\n parentNode.converter.layers0?.attributeStorageInfo?.length) ||\n ('attributesCount' in resources &&\n resources.attributesCount &&\n parentNode.converter.layers0?.attributeStorageInfo?.length)\n ) {\n const attributesLength =\n ('attributes' in resources ? resources.attributes?.length : resources.attributesCount) ||\n 0;\n node.attributeData = [];\n const minimumLength =\n attributesLength < parentNode.converter.layers0.attributeStorageInfo.length\n ? attributesLength\n : parentNode.converter.layers0.attributeStorageInfo.length;\n for (let index = 0; index < minimumLength; index++) {\n const folderName = parentNode.converter.layers0.attributeStorageInfo[index].key;\n node.attributeData.push({href: `./attributes/${folderName}/0`});\n }\n }\n }\n\n return node;\n }\n}\n"],"mappings":"AAAA,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AI6B,SAAS,IAC7BA,SAAS,CAACwB,eAAe,KAAAV,sBAAA,GACzBjB,UAAU,CAACtD,SAAS,CAAC+E,OAAO,cAAAR,sBAAA,gBAAAC,sBAAA,GAA5BD,sBAAA,CAA8BS,oBAAoB,cAAAR,sBAAA,eAAlDA,sBAAA,CAAoD5C,MAAO,EAC7D;QAAA,IAAAsD,qBAAA;QACA,MAAMC,gBAAgB,GACpB,CAAC,YAAY,IAAI1B,SAAS,IAAAyB,qBAAA,GAAGzB,SAAS,CAACqB,UAAU,cAAAI,qBAAA,uBAApBA,qBAAA,CAAsBtD,MAAM,GAAG6B,SAAS,CAACwB,eAAe,KACrF,CAAC;QACHrE,IAAI,CAACwE,aAAa,GAAG,EAAE;QACvB,MAAMC,aAAa,GACjBF,gBAAgB,GAAG7B,UAAU,CAACtD,SAAS,CAAC+E,OAAO,CAACC,oBAAoB,CAACpD,MAAM,GACvEuD,gBAAgB,GAChB7B,UAAU,CAACtD,SAAS,CAAC+E,OAAO,CAACC,oBAAoB,CAACpD,MAAM;QAC9D,KAAK,IAAI+B,KAAK,GAAG,CAAC,EAAEA,KAAK,GAAG0B,aAAa,EAAE1B,KAAK,EAAE,EAAE;UAClD,MAAM2B,UAAU,GAAGhC,UAAU,CAACtD,SAAS,CAAC+E,OAAO,CAACC,oBAAoB,CAACrB,KAAK,CAAC,CAAC4B,GAAG;UAC/E3E,IAAI,CAACwE,aAAa,CAACrE,IAAI,CAAC;YAACC,IAAI,EAAG,gBAAesE,UAAW;UAAG,CAAC,CAAC;QACjE;MACF;IACF;IAEA,OAAO1E,IAAI;EACb;AACF"}
@@ -142,6 +142,24 @@ export default class I3SConverter {
142
142
  * @param currentTraversalProps - traversal properties of the current node
143
143
  */
144
144
  private finalizeTile;
145
+ /**
146
+ * Generate NodeIndexDocument
147
+ * @param boundingVolumes - Bounding volumes
148
+ * @param resources - converted or dumped node resources data
149
+ * @param parentNode - 3DNodeIndexDocument of parent node
150
+ * @param sourceTile - source 3DTile data
151
+ * @param isDumped - indicator if the node is dumped
152
+ * @return NodeIndexDocument, nodeInPage and node data
153
+ */
154
+ private _generateNodeIndexDocument;
155
+ /**
156
+ * Restore 3DNodeIndexDocument from a comversion dump file
157
+ * @param parentNode - 3DNodeIndexDocument of parent node
158
+ * @param sourceTile - source 3DTile data
159
+ * @param transformationMatrix - transformation matrix of the current tile, calculated recursively multiplying
160
+ * transform of all parent tiles and transform of the current tile
161
+ */
162
+ private _restoreNode;
145
163
  /**
146
164
  * Convert tile to one or more I3S nodes
147
165
  * @param parentNode - 3DNodeIndexDocument of parent node
@@ -1 +1 @@
1
- {"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,qBAAqB,EAAC,MAAM,mCAAmC,CAAC;AAExE,OAAO,KAAK,EAEV,oBAAoB,EAGpB,+BAA+B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EACV,YAAY,EAKb,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAOrC,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAkB7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAA8B,MAAM,iBAAiB,CAAC;AAGnF,OAAO,EAGL,cAAc,EAGf,MAAM,SAAS,CAAC;AAEjB,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAkBlD,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAwB,MAAM,8BAA8B,CAAC;AAWnF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,qBAAqB,EAAE,qBAAqB,CAAC;IAC7C,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAA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;YACW,iBAAiB;IAkC/B;;;;;;;;;;;;;;OAcG;YACW,sBAAsB;IAyEpC;;;;;;;;;;;OAWG;YACW,eAAe;IA+C7B;;;;;;;;OAQG;YACW,gBAAgB;IAsD9B;;;;;;;;OAQG;YACW,YAAY;IAmC1B;;;;;;;OAOG;YACW,aAAa;IA4H3B;;;;;;;;;OASG;YACW,gBAAgB;IAgC9B;;;;;;;OAOG;YACW,gBAAgB;IA4C9B;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAa5B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAU7B;;;;;;OAMG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IA4BlC;;;OAGG;YACW,iBAAiB;IAqB/B;;OAEG;YACW,oBAAoB;IAYlC;;OAEG;YACW,qBAAqB;IAiBnC;;OAEG;IACH,OAAO,CAAC,8BAA8B;IAWtC;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;CAG3B"}
@@ -166,7 +166,6 @@ export default class I3SConverter {
166
166
  if (slpk) {
167
167
  this.nodePages.useWriteFunction(writeFileForSlpk);
168
168
  }
169
- await this.conversionDump.createDumpFile(options);
170
169
  try {
171
170
  const preloadOptions = await this._fetchPreloadOptions();
172
171
  let tilesetUrl = inputUrl;
@@ -279,12 +278,34 @@ export default class I3SConverter {
279
278
  async _createAndSaveTileset(outputPath, tilesetName) {
280
279
  var _this$sourceTileset, _this$sourceTileset$r, _this$sourceTileset$r2;
281
280
  const tilesetPath = join(`${outputPath}`, `${tilesetName}`);
281
+ await this.conversionDump.createDump(this.options);
282
+ if (this.conversionDump.restored && this.options.inquirer) {
283
+ const result = await this.options.inquirer.prompt([{
284
+ name: 'resumeConversion',
285
+ type: 'confirm',
286
+ message: 'Dump file of the previous conversion exists, do you want to resume that conversion?'
287
+ }]);
288
+ if (!result.resumeConversion) {
289
+ this.conversionDump.reset();
290
+ }
291
+ }
292
+ this.layers0Path = join(tilesetPath, 'SceneServer', 'layers', '0');
293
+ const removePath = this.conversionDump.restored ? join(this.layers0Path, 'nodepages') : tilesetPath;
282
294
  try {
283
- await removeDir(tilesetPath);
295
+ await removeDir(removePath);
284
296
  } catch (e) {}
285
- this.layers0Path = join(tilesetPath, 'SceneServer', 'layers', '0');
297
+ if (this.conversionDump.restored && this.conversionDump.attributeMetadataInfo) {
298
+ this.attributeMetadataInfo.fromObject(this.conversionDump.attributeMetadataInfo);
299
+ }
286
300
  this.materialDefinitions = [];
287
301
  this.materialMap = new Map();
302
+ if (this.conversionDump.restored && this.conversionDump.materialDefinitions) {
303
+ for (let i = 0; i < this.conversionDump.materialDefinitions.length; i++) {
304
+ const hash = md5(JSON.stringify(this.conversionDump.materialDefinitions[i]));
305
+ this.materialMap.set(hash, i);
306
+ }
307
+ this.materialDefinitions = this.conversionDump.materialDefinitions;
308
+ }
288
309
  const sourceRootTile = this.sourceTileset.root;
289
310
  const sourceBoundingVolume = createBoundingVolume(sourceRootTile.boundingVolume, new Matrix4(sourceRootTile.transform), null);
290
311
  this._formLayers0(tilesetName, sourceBoundingVolume, (_this$sourceTileset = this.sourceTileset) === null || _this$sourceTileset === void 0 ? void 0 : (_this$sourceTileset$r = _this$sourceTileset.root) === null || _this$sourceTileset$r === void 0 ? void 0 : (_this$sourceTileset$r2 = _this$sourceTileset$r.boundingVolume) === null || _this$sourceTileset$r2 === void 0 ? void 0 : _this$sourceTileset$r2.region);
@@ -309,6 +330,9 @@ export default class I3SConverter {
309
330
  if (this.attributeMetadataInfo.attributeStorageInfo.length) {
310
331
  this.layers0.layerType = _3D_OBJECT_LAYER_TYPE;
311
332
  }
333
+ if (this.conversionDump.restored && this.conversionDump.textureSetDefinitions) {
334
+ this.layers0.textureSetDefinitions = this.conversionDump.textureSetDefinitions;
335
+ }
312
336
  this.layers0.materialDefinitions = this.materialDefinitions;
313
337
  this.layers0.geometryDefinitions = transform(this.geometryConfigs.map(config => ({
314
338
  geometryConfig: {
@@ -406,7 +430,13 @@ export default class I3SConverter {
406
430
  transformationMatrix = transformationMatrix.multiplyRight(sourceTile.transform);
407
431
  }
408
432
  const parentNode = parentNodes[0];
409
- const childNodes = await this._createNode(parentNode, sourceTile, transformationMatrix);
433
+ const restoreResult = await this._restoreNode(parentNode, sourceTile, transformationMatrix);
434
+ let childNodes;
435
+ if (restoreResult === null) {
436
+ childNodes = await this._createNode(parentNode, sourceTile, transformationMatrix);
437
+ } else {
438
+ childNodes = restoreResult;
439
+ }
410
440
  await parentNode.addChildren(childNodes);
411
441
  const newTraversalProps = {
412
442
  transform: transformationMatrix,
@@ -435,6 +465,57 @@ export default class I3SConverter {
435
465
  await node.save();
436
466
  }
437
467
  }
468
+ async _generateNodeIndexDocument(boundingVolumes, resources, parentNode, sourceTile, isDumped) {
469
+ this.layersHasTexture = this.layersHasTexture || Boolean('texture' in resources && resources.texture || 'texelCountHint' in resources && resources.texelCountHint);
470
+ if (this.generateBoundingVolumes && resources.boundingVolumes) {
471
+ boundingVolumes = resources.boundingVolumes;
472
+ }
473
+ const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);
474
+ const maxScreenThresholdSQ = lodSelection.find(val => val.metricType === 'maxScreenThresholdSQ') || {
475
+ maxError: 0
476
+ };
477
+ if (isDumped) {
478
+ const draftObb = {
479
+ center: [],
480
+ halfSize: [],
481
+ quaternion: []
482
+ };
483
+ await this.nodePages.push({
484
+ index: 0,
485
+ obb: draftObb
486
+ }, parentNode.inPageId);
487
+ }
488
+ const nodeInPage = await this._updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentNode.inPageId, resources);
489
+ const nodeData = await NodeIndexDocument.createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources);
490
+ const node = await new NodeIndexDocument(nodeInPage.index, this).addData(nodeData);
491
+ return {
492
+ node,
493
+ nodeInPage,
494
+ nodeData
495
+ };
496
+ }
497
+ async _restoreNode(parentNode, sourceTile, transformationMatrix) {
498
+ this._checkAddRefinementTypeForTile(sourceTile);
499
+ await this._updateTilesetOptions();
500
+ if (this.conversionDump.restored && sourceTile.id && this.conversionDump.isFileConversionComplete(sourceTile.id)) {
501
+ const sourceBoundingVolume = createBoundingVolume(sourceTile.boundingVolume, transformationMatrix, null);
502
+ let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
503
+ const nodes = [];
504
+ for (const convertedNode of this.conversionDump.tilesConverted[sourceTile.id].nodes) {
505
+ const {
506
+ node
507
+ } = await this._generateNodeIndexDocument(boundingVolumes, {
508
+ ...convertedNode.dumpMetadata,
509
+ nodeId: convertedNode.nodeId
510
+ }, parentNode, sourceTile, true);
511
+ nodes.push(node);
512
+ }
513
+ return nodes;
514
+ } else if (this.conversionDump.restored && sourceTile.id) {
515
+ this.conversionDump.clearDumpRecord(sourceTile.id);
516
+ }
517
+ return null;
518
+ }
438
519
  async _createNode(parentNode, sourceTile, transformationMatrix) {
439
520
  this._checkAddRefinementTypeForTile(sourceTile);
440
521
  await this._updateTilesetOptions();
@@ -448,6 +529,11 @@ export default class I3SConverter {
448
529
  let boundingVolumes = createBoundingVolumes(sourceBoundingVolume, this.geoidHeightModel);
449
530
  const propertyTable = getPropertyTable(tileContent, this.options.metadataClass);
450
531
  this.createAttributeStorageInfo(tileContent, propertyTable);
532
+ this.conversionDump.attributeMetadataInfo = {
533
+ attributeStorageInfo: this.attributeMetadataInfo.attributeStorageInfo,
534
+ fields: this.attributeMetadataInfo.fields,
535
+ popupInfo: this.attributeMetadataInfo.popupInfo
536
+ };
451
537
  const resourcesData = await this._convertResources(sourceTile, transformationMatrix, sourceBoundingVolume, tileContent, parentNode.inPageId, propertyTable);
452
538
  const nodes = [];
453
539
  const nodeIds = [];
@@ -465,21 +551,27 @@ export default class I3SConverter {
465
551
  boundingVolumes: null
466
552
  };
467
553
  for (const resources of resourcesData || [emptyResources]) {
468
- this.layersHasTexture = this.layersHasTexture || Boolean(resources.texture);
469
- if (this.generateBoundingVolumes && resources.boundingVolumes) {
470
- boundingVolumes = resources.boundingVolumes;
471
- }
472
- const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);
473
- const maxScreenThresholdSQ = lodSelection.find(val => val.metricType === 'maxScreenThresholdSQ') || {
474
- maxError: 0
475
- };
476
- const nodeInPage = await this._updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentNode.inPageId, resources);
477
- const nodeData = await NodeIndexDocument.createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources);
478
- const node = await new NodeIndexDocument(nodeInPage.index, this).addData(nodeData);
554
+ const {
555
+ node,
556
+ nodeInPage,
557
+ nodeData
558
+ } = await this._generateNodeIndexDocument(boundingVolumes, resources, parentNode, sourceTile, false);
479
559
  nodes.push(node);
480
560
  if (nodeInPage.mesh) {
481
561
  if (sourceTile.id) {
482
- await this.conversionDump.addNode(sourceTile.id, nodeInPage.index);
562
+ var _resources$attributes;
563
+ const dumpMetadata = {
564
+ boundingVolumes: resources.boundingVolumes,
565
+ attributesCount: (_resources$attributes = resources.attributes) === null || _resources$attributes === void 0 ? void 0 : _resources$attributes.length,
566
+ featureCount: resources.featureCount,
567
+ geometry: Boolean(resources.geometry),
568
+ hasUvRegions: resources.hasUvRegions,
569
+ materialId: nodeInPage.mesh.material.definition,
570
+ texelCountHint: nodeInPage.mesh.material.texelCountHint,
571
+ vertexCount: resources.vertexCount
572
+ };
573
+ this.conversionDump.setMaterialsDefinitions(this.materialDefinitions);
574
+ await this.conversionDump.addNode(sourceTile.id, nodeInPage.index, dumpMetadata);
483
575
  }
484
576
  await this._writeResources(resources, node.id, sourceTile);
485
577
  }
@@ -511,8 +603,6 @@ export default class I3SConverter {
511
603
  }
512
604
  async _updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
513
605
  const {
514
- meshMaterial,
515
- texture,
516
606
  vertexCount,
517
607
  featureCount,
518
608
  geometry,
@@ -527,7 +617,7 @@ export default class I3SConverter {
527
617
  if (geometry && this.isContentSupported(sourceTile)) {
528
618
  nodeInPage.mesh = {
529
619
  geometry: {
530
- definition: this.findOrCreateGeometryDefinition(Boolean(texture), hasUvRegions),
620
+ definition: this.findOrCreateGeometryDefinition(Boolean('texture' in resources && resources.texture || 'texelCountHint' in resources && resources.texelCountHint), hasUvRegions),
531
621
  resource: 0
532
622
  },
533
623
  attribute: {
@@ -538,7 +628,7 @@ export default class I3SConverter {
538
628
  }
539
629
  };
540
630
  }
541
- let nodeId = resources.nodeId;
631
+ let nodeId = 'nodeId' in resources ? resources.nodeId : undefined;
542
632
  let node;
543
633
  if (!nodeId) {
544
634
  node = await this.nodePages.push(nodeInPage, parentId);
@@ -549,12 +639,16 @@ export default class I3SConverter {
549
639
  console.log(`[warning]: node ${node.index} is created with empty content`);
550
640
  }
551
641
  NodePages.updateAll(node, nodeInPage);
552
- if (meshMaterial) {
553
- NodePages.updateMaterialByNodeId(node, this._findOrCreateMaterial(meshMaterial));
642
+ if ('meshMaterial' in resources && resources.meshMaterial) {
643
+ NodePages.updateMaterialByNodeId(node, this._findOrCreateMaterial(resources.meshMaterial));
644
+ } else if ('materialId' in resources && resources.materialId !== null) {
645
+ NodePages.updateMaterialByNodeId(node, resources.materialId);
554
646
  }
555
- if (texture) {
556
- const texelCountHint = texture.image.height * texture.image.width;
647
+ if ('texture' in resources && resources.texture) {
648
+ const texelCountHint = resources.texture.image.height * resources.texture.image.width;
557
649
  NodePages.updateTexelCountHintByNodeId(node, texelCountHint);
650
+ } else if ('texelCountHint' in resources && resources.texelCountHint) {
651
+ NodePages.updateTexelCountHintByNodeId(node, resources.texelCountHint);
558
652
  }
559
653
  if (vertexCount) {
560
654
  this.vertexCounter += vertexCount;
@@ -717,6 +811,9 @@ export default class I3SConverter {
717
811
  formats,
718
812
  atlas: true
719
813
  });
814
+ if (this.layers0.textureSetDefinitions) {
815
+ this.conversionDump.addTexturesDefinitions(this.layers0.textureSetDefinitions);
816
+ }
720
817
  }
721
818
  }
722
819
  }