@loaders.gl/tile-converter 4.1.0-alpha.9 → 4.1.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.
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +4 -4
- package/dist/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +8 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -1
- package/dist/3d-tiles-converter/json-templates/tileset.js +3 -0
- package/dist/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +1 -0
- package/dist/constants.js.map +1 -1
- package/dist/converter-cli.js +3 -3
- package/dist/converter-cli.js.map +1 -1
- package/dist/converter.min.cjs +131 -220
- package/dist/deps-installer/deps-installer.js +1 -1
- package/dist/deps-installer/deps-installer.js.map +1 -1
- package/dist/i3s-converter/helpers/progress.js +1 -1
- package/dist/i3s-converter/helpers/progress.js.map +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts +14 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +76 -25
- package/dist/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/i3s-converter/types.d.ts +7 -0
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/i3s-converter/types.js +8 -0
- package/dist/i3s-converter/types.js.map +1 -1
- package/dist/i3s-server/bin/i3s-server.min.cjs +76 -76
- package/dist/index.cjs +376 -104
- package/dist/lib/utils/compress-util.d.ts +0 -37
- package/dist/lib/utils/compress-util.d.ts.map +1 -1
- package/dist/lib/utils/compress-util.js +1 -149
- package/dist/lib/utils/compress-util.js.map +1 -1
- package/dist/lib/utils/conversion-dump.d.ts +81 -0
- package/dist/lib/utils/conversion-dump.d.ts.map +1 -0
- package/dist/lib/utils/conversion-dump.js +131 -0
- package/dist/lib/utils/conversion-dump.js.map +1 -0
- package/dist/lib/utils/statistic-utills.js +1 -1
- package/dist/lib/utils/statistic-utills.js.map +1 -1
- package/dist/lib/utils/write-queue.d.ts +6 -1
- package/dist/lib/utils/write-queue.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.js +15 -3
- package/dist/lib/utils/write-queue.js.map +1 -1
- package/dist/pgm-loader.js +1 -1
- package/dist/pgm-loader.js.map +1 -1
- package/dist/slpk-extractor.min.cjs +31 -31
- package/package.json +16 -16
- package/src/3d-tiles-converter/3d-tiles-converter.ts +5 -4
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +19 -0
- package/src/3d-tiles-converter/json-templates/tileset.ts +3 -0
- package/src/constants.ts +1 -0
- package/src/converter-cli.ts +3 -3
- package/src/i3s-converter/helpers/progress.ts +1 -1
- package/src/i3s-converter/i3s-converter.ts +192 -57
- package/src/i3s-converter/types.ts +8 -0
- package/src/lib/utils/compress-util.ts +1 -264
- package/src/lib/utils/conversion-dump.ts +203 -0
- package/src/lib/utils/statistic-utills.ts +1 -1
- package/src/lib/utils/write-queue.ts +15 -2
|
@@ -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.
|
|
8
|
+
const VERSION = typeof "4.1.1" !== 'undefined' ? "4.1.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,QAAO,0BAA0B;AAC1D,SAAQC,wBAAwB,EAAEC,2BAA2B,QAAO,mBAAmB;AACvF,SAAQC,wBAAwB,QAAO,sBAAsB;AAG7D,MAAMC,OAAO,GAAG,
|
|
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,cAAkB,KAAK,WAAW,aAAiB,QAAQ;AAE3E,MAAMC,QAAQ,GAAG,+EAA+E;AAQhG,OAAO,MAAMC,aAAa,CAAC;EAQzB,MAAMC,OAAOA,CAAA,EAAmC;IAAA,IAAlCC,IAAY,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAC7BG,OAAO,CAACC,GAAG,CAAC,iCAAiC,CAAC;IAC9C,MAAMC,OAAO,GAAG,MAAMpB,IAAI,CAACW,QAAQ,EAAET,SAAS,EAA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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"}
|
|
@@ -65,7 +65,7 @@ export class Progress {
|
|
|
65
65
|
return diff;
|
|
66
66
|
}
|
|
67
67
|
getTimeRemaining() {
|
|
68
|
-
if (!this._stepsDone || !this.startTime) {
|
|
68
|
+
if (!this._stepsTotal || !this._stepsDone || !this.startTime) {
|
|
69
69
|
return null;
|
|
70
70
|
}
|
|
71
71
|
const timeRemainingInMilliSeconds = (this._stepsTotal - this._stepsDone) * this.milliSecForOneStep;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"progress.js","names":["process","timeConverter","THRESHOLD_DEFAULT","Progress","constructor","options","arguments","length","undefined","_stepsTotal","_stepsDone","startTime","stopTime","timeOfUpdatingStepsDone","milliSecForOneStep","trust","numberOfDigitsInPercentage","threshold","getTime","hrtime","bigint","stepsTotal","Math","ceil","log10","stepsDone","getCurrentTimeInMilliSeconds","diff","isVelocityTrust","startMonitoring","stopMonitoring","getPercent","percent","getPercentString","toFixed","getTimeCurrentlyElapsed","currentTime","getTimeRemaining","timeRemainingInMilliSeconds","timeRemaining","getTimeRemainingString","timeRemainingObject","current","previous","dev","abs","Number","BigInt"],"sources":["../../../src/i3s-converter/helpers/progress.ts"],"sourcesContent":["import process from 'process';\nimport {timeConverter} from '../../lib/utils/statistic-utills';\n\n/** Defines a threshold that is used to check if the process velocity can be consifered trust. */\nconst THRESHOLD_DEFAULT = 0.2;\n\n/**\n * Implements methods to keep track on the progress of a long process.\n */\nexport class Progress {\n /** Total amount of work, e.g. number of files to save or number of bytes to send */\n private _stepsTotal: number = 0;\n /** Amount of work already done */\n private _stepsDone: number = 0;\n /** Time in milli-seconds when the process started */\n private startTime: number = 0;\n /** Time in milli-seconds when the process stopped */\n private stopTime: number = 0;\n /** Time in milli-seconds when stepsDone was updated */\n private timeOfUpdatingStepsDone: number = 0;\n /** Time in milli-seconds spent for performing one step*/\n private milliSecForOneStep: number = 0;\n private trust: boolean = false;\n /**\n * The number of digits to appear after decimal point in the string representation of the count of steps already done.\n * It's calculated based on the total count of steps.\n */\n private numberOfDigitsInPercentage: number = 0;\n /** Defines a threshold that is used to check if the process velocity can be consifered trust. */\n private threshold: number;\n /** Function that is used to get the time stamp */\n private getTime: () => bigint;\n\n constructor(options: {threshold?: number; getTime?: () => bigint} = {}) {\n this.getTime = options.getTime || process.hrtime.bigint;\n this.threshold = options.threshold || THRESHOLD_DEFAULT;\n }\n\n /** Total amount of work, e.g. number of files to save or number of bytes to send */\n get stepsTotal() {\n return this._stepsTotal;\n }\n\n set stepsTotal(stepsTotal) {\n this._stepsTotal = stepsTotal;\n this.numberOfDigitsInPercentage =\n this.stepsTotal > 100 ? Math.ceil(Math.log10(this.stepsTotal)) - 2 : 0;\n }\n\n /** Amount of work already done */\n get stepsDone() {\n return this._stepsDone;\n }\n\n set stepsDone(stepsDone) {\n this._stepsDone = stepsDone;\n this.timeOfUpdatingStepsDone = this.getCurrentTimeInMilliSeconds();\n if (this._stepsDone) {\n const diff = this.timeOfUpdatingStepsDone - this.startTime;\n const milliSecForOneStep = diff / this._stepsDone;\n\n this.trust = this.isVelocityTrust(milliSecForOneStep, this.milliSecForOneStep);\n this.milliSecForOneStep = milliSecForOneStep;\n }\n }\n\n /**\n * Saves the current time as we start monitoring the process.\n */\n startMonitoring() {\n this.startTime = this.getCurrentTimeInMilliSeconds();\n this.milliSecForOneStep = 0;\n this.trust = false;\n this.timeOfUpdatingStepsDone = 0;\n this.stopTime = 0;\n this.stepsDone = 0;\n }\n\n /**\n * Saves the current time as we stop monitoring the process.\n */\n stopMonitoring() {\n this.stopTime = this.getCurrentTimeInMilliSeconds();\n }\n\n /**\n * Gets percentage of the work already done.\n * @returns percentage of the work already done.\n */\n getPercent(): number | null {\n if (!this._stepsTotal) {\n return null;\n }\n const percent = (this._stepsDone / this._stepsTotal) * 100.0;\n return percent;\n }\n\n /**\n * Gets string representation of percentage of the work already done.\n * @returns string representation of percentage or an empty string if the percetage value cannot be calculated.\n */\n getPercentString() {\n const percent = this.getPercent();\n return percent !== null ? percent.toFixed(this.numberOfDigitsInPercentage) : '';\n }\n\n /**\n * Gets the time elapsed since the monitoring started\n * @returns Number of milliseconds elapsed\n */\n getTimeCurrentlyElapsed(): number {\n const currentTime = this.stopTime ? this.stopTime : this.getCurrentTimeInMilliSeconds();\n const diff = currentTime - this.startTime;\n return diff;\n }\n\n /**\n * Gets the time remaining (expected at the moment of updating 'stepsDone') to complete the work.\n * @returns Number of milliseconds remaining\n */\n getTimeRemaining(): {timeRemaining: number; trust: boolean} | null {\n if (!this._stepsDone || !this.startTime) {\n return null;\n }\n\n const timeRemainingInMilliSeconds =\n (this._stepsTotal - this._stepsDone) * this.milliSecForOneStep;\n return {timeRemaining: timeRemainingInMilliSeconds, trust: this.trust};\n }\n\n /**\n * Gets the string representation of the time remaining (expected at the moment of updating 'stepsDone') to complete the work.\n * @returns string representation of the time remaining.\n * It's an empty string if the time cannot be pedicted or it's still being calculated.\n */\n getTimeRemainingString(): string {\n const timeRemainingObject = this.getTimeRemaining();\n return timeRemainingObject?.trust ? timeConverter(timeRemainingObject.timeRemaining) : '';\n }\n\n /**\n * Check if the computed velociy of the process can be considered trust.\n * At the beginning of the process the number of samples collected ('time necessary to perform one step' averaged) is too small,\n * which results in huge deviation of the cumputed velocity of the process.\n * It makes sense to perform the check before reporting the time remainig so the end user is not confused.\n * @param current - current value\n * @param previous - previous value\n * @returns true if the computed velociy can be considered trust, or false otherwise\n */\n private isVelocityTrust(current: number, previous: number): boolean {\n if (previous) {\n const dev = Math.abs((current - previous) / previous);\n return dev < this.threshold;\n }\n return false;\n }\n\n /**\n * Gets current time in milliseconds.\n * @returns current time in milliseconds.\n */\n private getCurrentTimeInMilliSeconds(): number {\n // process.hrtime.bigint() returns the time in nanoseconds. We need the time in milliseconds.\n return Number(this.getTime() / BigInt(1e6));\n }\n}\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,SAAS;AAAC,SACtBC,aAAa;AAGrB,MAAMC,iBAAiB,GAAG,GAAG;AAK7B,OAAO,MAAMC,QAAQ,CAAC;EAwBpBC,WAAWA,CAAA,EAA6D;IAAA,IAA5DC,OAAqD,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,KAtB9DG,WAAW,GAAW,CAAC;IAAA,KAEvBC,UAAU,GAAW,CAAC;IAAA,KAEtBC,SAAS,GAAW,CAAC;IAAA,KAErBC,QAAQ,GAAW,CAAC;IAAA,KAEpBC,uBAAuB,GAAW,CAAC;IAAA,KAEnCC,kBAAkB,GAAW,CAAC;IAAA,KAC9BC,KAAK,GAAY,KAAK;IAAA,KAKtBC,0BAA0B,GAAW,C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,IAAI,CAACF,uBAAuB,GAAG,CAAC;IAChC,IAAI,CAACD,QAAQ,GAAG,CAAC;IACjB,IAAI,CAACa,SAAS,GAAG,CAAC;EACpB;EAKAK,cAAcA,CAAA,EAAG;IACf,IAAI,CAAClB,QAAQ,GAAG,IAAI,CAACc,4BAA4B,CAAC,CAAC;EACrD;EAMAK,UAAUA,CAAA,EAAkB;IAC1B,IAAI,CAAC,IAAI,CAACtB,WAAW,EAAE;MACrB,OAAO,IAAI;IACb;IACA,MAAMuB,OAAO,GAAI,IAAI,CAACtB,UAAU,GAAG,IAAI,CAACD,WAAW,GAAI,KAAK;IAC5D,OAAOuB,OAAO;EAChB;EAMAC,gBAAgBA,CAAA,EAAG;IACjB,MAAMD,OAAO,GAAG,IAAI,CAACD,UAAU,CAAC,CAAC;IACjC,OAAOC,OAAO,KAAK,IAAI,GAAGA,OAAO,CAACE,OAAO,CAAC,IAAI,CAAClB,0BAA0B,CAAC,GAAG,EAAE;EACjF;EAMAmB,uBAAuBA,CAAA,EAAW;IAChC,MAAMC,WAAW,GAAG,IAAI,CAACxB,QAAQ,GAAG,IAAI,CAACA,QAAQ,GAAG,IAAI,CAACc,4BAA4B,CAAC,CAAC;IACvF,MAAMC,IAAI,GAAGS,WAAW,GAAG,IAAI,CAACzB,SAAS;IACzC,OAAOgB,IAAI;EACb;EAMAU,gBAAgBA,CAAA,EAAmD;IACjE,IAAI,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"progress.js","names":["process","timeConverter","THRESHOLD_DEFAULT","Progress","constructor","options","arguments","length","undefined","_stepsTotal","_stepsDone","startTime","stopTime","timeOfUpdatingStepsDone","milliSecForOneStep","trust","numberOfDigitsInPercentage","threshold","getTime","hrtime","bigint","stepsTotal","Math","ceil","log10","stepsDone","getCurrentTimeInMilliSeconds","diff","isVelocityTrust","startMonitoring","stopMonitoring","getPercent","percent","getPercentString","toFixed","getTimeCurrentlyElapsed","currentTime","getTimeRemaining","timeRemainingInMilliSeconds","timeRemaining","getTimeRemainingString","timeRemainingObject","current","previous","dev","abs","Number","BigInt"],"sources":["../../../src/i3s-converter/helpers/progress.ts"],"sourcesContent":["import process from 'process';\nimport {timeConverter} from '../../lib/utils/statistic-utills';\n\n/** Defines a threshold that is used to check if the process velocity can be consifered trust. */\nconst THRESHOLD_DEFAULT = 0.2;\n\n/**\n * Implements methods to keep track on the progress of a long process.\n */\nexport class Progress {\n /** Total amount of work, e.g. number of files to save or number of bytes to send */\n private _stepsTotal: number = 0;\n /** Amount of work already done */\n private _stepsDone: number = 0;\n /** Time in milli-seconds when the process started */\n private startTime: number = 0;\n /** Time in milli-seconds when the process stopped */\n private stopTime: number = 0;\n /** Time in milli-seconds when stepsDone was updated */\n private timeOfUpdatingStepsDone: number = 0;\n /** Time in milli-seconds spent for performing one step*/\n private milliSecForOneStep: number = 0;\n private trust: boolean = false;\n /**\n * The number of digits to appear after decimal point in the string representation of the count of steps already done.\n * It's calculated based on the total count of steps.\n */\n private numberOfDigitsInPercentage: number = 0;\n /** Defines a threshold that is used to check if the process velocity can be consifered trust. */\n private threshold: number;\n /** Function that is used to get the time stamp */\n private getTime: () => bigint;\n\n constructor(options: {threshold?: number; getTime?: () => bigint} = {}) {\n this.getTime = options.getTime || process.hrtime.bigint;\n this.threshold = options.threshold || THRESHOLD_DEFAULT;\n }\n\n /** Total amount of work, e.g. number of files to save or number of bytes to send */\n get stepsTotal() {\n return this._stepsTotal;\n }\n\n set stepsTotal(stepsTotal) {\n this._stepsTotal = stepsTotal;\n this.numberOfDigitsInPercentage =\n this.stepsTotal > 100 ? Math.ceil(Math.log10(this.stepsTotal)) - 2 : 0;\n }\n\n /** Amount of work already done */\n get stepsDone() {\n return this._stepsDone;\n }\n\n set stepsDone(stepsDone) {\n this._stepsDone = stepsDone;\n this.timeOfUpdatingStepsDone = this.getCurrentTimeInMilliSeconds();\n if (this._stepsDone) {\n const diff = this.timeOfUpdatingStepsDone - this.startTime;\n const milliSecForOneStep = diff / this._stepsDone;\n\n this.trust = this.isVelocityTrust(milliSecForOneStep, this.milliSecForOneStep);\n this.milliSecForOneStep = milliSecForOneStep;\n }\n }\n\n /**\n * Saves the current time as we start monitoring the process.\n */\n startMonitoring() {\n this.startTime = this.getCurrentTimeInMilliSeconds();\n this.milliSecForOneStep = 0;\n this.trust = false;\n this.timeOfUpdatingStepsDone = 0;\n this.stopTime = 0;\n this.stepsDone = 0;\n }\n\n /**\n * Saves the current time as we stop monitoring the process.\n */\n stopMonitoring() {\n this.stopTime = this.getCurrentTimeInMilliSeconds();\n }\n\n /**\n * Gets percentage of the work already done.\n * @returns percentage of the work already done.\n */\n getPercent(): number | null {\n if (!this._stepsTotal) {\n return null;\n }\n const percent = (this._stepsDone / this._stepsTotal) * 100.0;\n return percent;\n }\n\n /**\n * Gets string representation of percentage of the work already done.\n * @returns string representation of percentage or an empty string if the percetage value cannot be calculated.\n */\n getPercentString() {\n const percent = this.getPercent();\n return percent !== null ? percent.toFixed(this.numberOfDigitsInPercentage) : '';\n }\n\n /**\n * Gets the time elapsed since the monitoring started\n * @returns Number of milliseconds elapsed\n */\n getTimeCurrentlyElapsed(): number {\n const currentTime = this.stopTime ? this.stopTime : this.getCurrentTimeInMilliSeconds();\n const diff = currentTime - this.startTime;\n return diff;\n }\n\n /**\n * Gets the time remaining (expected at the moment of updating 'stepsDone') to complete the work.\n * @returns Number of milliseconds remaining\n */\n getTimeRemaining(): {timeRemaining: number; trust: boolean} | null {\n if (!this._stepsTotal || !this._stepsDone || !this.startTime) {\n return null;\n }\n\n const timeRemainingInMilliSeconds =\n (this._stepsTotal - this._stepsDone) * this.milliSecForOneStep;\n return {timeRemaining: timeRemainingInMilliSeconds, trust: this.trust};\n }\n\n /**\n * Gets the string representation of the time remaining (expected at the moment of updating 'stepsDone') to complete the work.\n * @returns string representation of the time remaining.\n * It's an empty string if the time cannot be pedicted or it's still being calculated.\n */\n getTimeRemainingString(): string {\n const timeRemainingObject = this.getTimeRemaining();\n return timeRemainingObject?.trust ? timeConverter(timeRemainingObject.timeRemaining) : '';\n }\n\n /**\n * Check if the computed velociy of the process can be considered trust.\n * At the beginning of the process the number of samples collected ('time necessary to perform one step' averaged) is too small,\n * which results in huge deviation of the cumputed velocity of the process.\n * It makes sense to perform the check before reporting the time remainig so the end user is not confused.\n * @param current - current value\n * @param previous - previous value\n * @returns true if the computed velociy can be considered trust, or false otherwise\n */\n private isVelocityTrust(current: number, previous: number): boolean {\n if (previous) {\n const dev = Math.abs((current - previous) / previous);\n return dev < this.threshold;\n }\n return false;\n }\n\n /**\n * Gets current time in milliseconds.\n * @returns current time in milliseconds.\n */\n private getCurrentTimeInMilliSeconds(): number {\n // process.hrtime.bigint() returns the time in nanoseconds. We need the time in milliseconds.\n return Number(this.getTime() / BigInt(1e6));\n }\n}\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,SAAS;AAAC,SACtBC,aAAa;AAGrB,MAAMC,iBAAiB,GAAG,GAAG;AAK7B,OAAO,MAAMC,QAAQ,CAAC;EAwBpBC,WAAWA,CAAA,EAA6D;IAAA,IAA5DC,OAAqD,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,KAtB9DG,WAAW,GAAW,CAAC;IAAA,KAEvBC,UAAU,GAAW,CAAC;IAAA,KAEtBC,SAAS,GAAW,CAAC;IAAA,KAErBC,QAAQ,GAAW,CAAC;IAAA,KAEpBC,uBAAuB,GAAW,CAAC;IAAA,KAEnCC,kBAAkB,GAAW,CAAC;IAAA,KAC9BC,KAAK,GAAY,KAAK;IAAA,KAKtBC,0BAA0B,GAAW,CAAC;IAAA,KAEtCC,SAAS;IAAA,KAETC,OAAO;IAGb,IAAI,CAACA,OAAO,GAAGb,OAAO,CAACa,OAAO,IAAIlB,OAAO,CAACmB,MAAM,CAACC,MAAM;IACvD,IAAI,CAACH,SAAS,GAAGZ,OAAO,CAACY,SAAS,IAAIf,iBAAiB;EACzD;EAGA,IAAImB,UAAUA,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W;IAClE,IAAIA,QAAQ,EAAE;MACZ,MAAMC,GAAG,GAAGtB,IAAI,CAACuB,GAAG,CAAC,CAACH,OAAO,GAAGC,QAAQ,IAAIA,QAAQ,CAAC;MACrD,OAAOC,GAAG,GAAG,IAAI,CAAC3B,SAAS;IAC7B;IACA,OAAO,KAAK;EACd;EAMQS,4BAA4BA,CAAA,EAAW;IAE7C,OAAOoB,MAAM,CAAC,IAAI,CAAC5B,OAAO,CAAC,CAAC,GAAG6B,MAAM,CAAC,GAAG,CAAC,CAAC;EAC7C;AACF"}
|
|
@@ -9,6 +9,7 @@ import { I3SMaterialDefinition } from '@loaders.gl/i3s';
|
|
|
9
9
|
import { PreprocessData } from './types';
|
|
10
10
|
import WriteQueue from '../lib/utils/write-queue';
|
|
11
11
|
import { Progress } from './helpers/progress';
|
|
12
|
+
import { ConversionDump } from '../lib/utils/conversion-dump';
|
|
12
13
|
/**
|
|
13
14
|
* Converter from 3d-tiles tileset to i3s layer
|
|
14
15
|
*/
|
|
@@ -49,6 +50,7 @@ export default class I3SConverter {
|
|
|
49
50
|
compressList: string[] | null;
|
|
50
51
|
preprocessData: PreprocessData;
|
|
51
52
|
progresses: Record<string, Progress>;
|
|
53
|
+
conversionDump: ConversionDump;
|
|
52
54
|
constructor();
|
|
53
55
|
/**
|
|
54
56
|
* Convert a 3d tileset
|
|
@@ -185,6 +187,8 @@ export default class I3SConverter {
|
|
|
185
187
|
* @param resources.texture - texture image
|
|
186
188
|
* @param resources.sharedResources - shared resource data object
|
|
187
189
|
* @param resources.attributes - feature attributes
|
|
190
|
+
* @param nodePath - node path
|
|
191
|
+
* @param sourceTile - source tile (3DTile)
|
|
188
192
|
* @return {Promise<void>}
|
|
189
193
|
*/
|
|
190
194
|
private _writeResources;
|
|
@@ -194,6 +198,8 @@ export default class I3SConverter {
|
|
|
194
198
|
* @param compressedGeometry - Uint8Array with compressed (draco) geometry
|
|
195
199
|
* @param childPath - a child path to write resources
|
|
196
200
|
* @param slpkChildPath - resource path inside *slpk file
|
|
201
|
+
* @param sourceId - source filename
|
|
202
|
+
* @param nodeId - nodeId of a converted node for the writing
|
|
197
203
|
*/
|
|
198
204
|
private _writeGeometries;
|
|
199
205
|
/**
|
|
@@ -202,6 +208,8 @@ export default class I3SConverter {
|
|
|
202
208
|
* @param childPath - a child path to write resources
|
|
203
209
|
* @param slpkChildPath - resource path inside *slpk file
|
|
204
210
|
* @param nodePath - a node path
|
|
211
|
+
* @param sourceId - source filename
|
|
212
|
+
* @param nodeId - nodeId of a converted node for the writing
|
|
205
213
|
*/
|
|
206
214
|
private _writeShared;
|
|
207
215
|
/**
|
|
@@ -209,6 +217,8 @@ export default class I3SConverter {
|
|
|
209
217
|
* @param texture - the texture image
|
|
210
218
|
* @param childPath - a child path to write resources
|
|
211
219
|
* @param slpkChildPath - the resource path inside *slpk file
|
|
220
|
+
* @param sourceId - source filename
|
|
221
|
+
* @param nodeId - nodeId of a converted node for the writing
|
|
212
222
|
*/
|
|
213
223
|
private _writeTexture;
|
|
214
224
|
/**
|
|
@@ -218,6 +228,8 @@ export default class I3SConverter {
|
|
|
218
228
|
* @param format
|
|
219
229
|
* @param childPath
|
|
220
230
|
* @param slpkChildPath
|
|
231
|
+
* @param sourceId
|
|
232
|
+
* @param nodeId
|
|
221
233
|
*/
|
|
222
234
|
private writeTextureFile;
|
|
223
235
|
/**
|
|
@@ -225,6 +237,8 @@ export default class I3SConverter {
|
|
|
225
237
|
* @param attributes - feature attributes
|
|
226
238
|
* @param childPath - a child path to write resources
|
|
227
239
|
* @param slpkChildPath - the resource path inside *slpk file
|
|
240
|
+
* @param sourceId - source filename
|
|
241
|
+
* @param nodeId - nodeId of a converted node for the writing
|
|
228
242
|
*/
|
|
229
243
|
private _writeAttributes;
|
|
230
244
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,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;;;;;;;;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"}
|
|
@@ -9,7 +9,7 @@ import transform from 'json-map-transform';
|
|
|
9
9
|
import md5 from 'md5';
|
|
10
10
|
import NodePages from "./helpers/node-pages.js";
|
|
11
11
|
import { writeFile, removeDir, writeFileForSlpk, removeFile } from "../lib/utils/file-utils.js";
|
|
12
|
-
import { compressFileWithGzip
|
|
12
|
+
import { compressFileWithGzip } from "../lib/utils/compress-util.js";
|
|
13
13
|
import { calculateFilesSize, timeConverter } from "../lib/utils/statistic-utills.js";
|
|
14
14
|
import convertB3dmToI3sGeometry, { getPropertyTable } from "./helpers/geometry-converter.js";
|
|
15
15
|
import { createBoundingVolumes, convertBoundingVolumeToI3SFullExtent } from "./helpers/coordinate-converter.js";
|
|
@@ -21,9 +21,8 @@ import { GEOMETRY_DEFINITION as geometryDefinitionTemlate } from "./json-templat
|
|
|
21
21
|
import { SHARED_RESOURCES as sharedResourcesTemplate } from "./json-templates/shared-resources.js";
|
|
22
22
|
import { validateNodeBoundingVolumes } from "./helpers/node-debug.js";
|
|
23
23
|
import { KTX2BasisWriterWorker } from '@loaders.gl/textures';
|
|
24
|
-
import { FileHandleFile } from '@loaders.gl/loader-utils';
|
|
25
24
|
import { ImageWriter } from '@loaders.gl/images';
|
|
26
|
-
import { GLTFPrimitiveModeString } from "./types.js";
|
|
25
|
+
import { GLTFPrimitiveModeString, ResourceType } from "./types.js";
|
|
27
26
|
import { WorkerFarm } from '@loaders.gl/worker-utils';
|
|
28
27
|
import WriteQueue from "../lib/utils/write-queue.js";
|
|
29
28
|
import { BROWSER_ERROR_MESSAGE } from "../constants.js";
|
|
@@ -35,7 +34,8 @@ import { createBoundingVolume } from '@loaders.gl/tiles';
|
|
|
35
34
|
import { traverseDatasetWith } from "./helpers/tileset-traversal.js";
|
|
36
35
|
import { analyzeTileContent, mergePreprocessData } from "./helpers/preprocess-3d-tiles.js";
|
|
37
36
|
import { Progress } from "./helpers/progress.js";
|
|
38
|
-
import {
|
|
37
|
+
import { composeHashFile, createZip } from '@loaders.gl/zip';
|
|
38
|
+
import { ConversionDump } from "../lib/utils/conversion-dump.js";
|
|
39
39
|
const ION_DEFAULT_TOKEN = (_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.IonToken;
|
|
40
40
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
41
41
|
const _3D_TILES = '3DTILES';
|
|
@@ -82,13 +82,14 @@ export default class I3SConverter {
|
|
|
82
82
|
this.generateBoundingVolumes = void 0;
|
|
83
83
|
this.layersHasTexture = void 0;
|
|
84
84
|
this.workerSource = {};
|
|
85
|
-
this.writeQueue = new WriteQueue();
|
|
85
|
+
this.writeQueue = new WriteQueue(new ConversionDump());
|
|
86
86
|
this.compressList = null;
|
|
87
87
|
this.preprocessData = {
|
|
88
88
|
meshTopologyTypes: new Set(),
|
|
89
89
|
metadataClasses: new Set()
|
|
90
90
|
};
|
|
91
91
|
this.progresses = {};
|
|
92
|
+
this.conversionDump = void 0;
|
|
92
93
|
this.attributeMetadataInfo = new AttributeMetadataInfo();
|
|
93
94
|
this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE, this);
|
|
94
95
|
this.options = {};
|
|
@@ -109,6 +110,7 @@ export default class I3SConverter {
|
|
|
109
110
|
this.generateBoundingVolumes = false;
|
|
110
111
|
this.layersHasTexture = false;
|
|
111
112
|
this.compressList = null;
|
|
113
|
+
this.conversionDump = new ConversionDump();
|
|
112
114
|
}
|
|
113
115
|
async convert(options) {
|
|
114
116
|
if (isBrowser) {
|
|
@@ -136,6 +138,8 @@ export default class I3SConverter {
|
|
|
136
138
|
analyze = false
|
|
137
139
|
} = options;
|
|
138
140
|
this.options = {
|
|
141
|
+
outputPath,
|
|
142
|
+
tilesetName,
|
|
139
143
|
maxDepth,
|
|
140
144
|
slpk,
|
|
141
145
|
sevenZipExe,
|
|
@@ -154,7 +158,7 @@ export default class I3SConverter {
|
|
|
154
158
|
this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;
|
|
155
159
|
this.generateTextures = Boolean(generateTextures);
|
|
156
160
|
this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
|
|
157
|
-
this.writeQueue = new WriteQueue();
|
|
161
|
+
this.writeQueue = new WriteQueue(this.conversionDump);
|
|
158
162
|
this.writeQueue.startListening();
|
|
159
163
|
console.log('Loading egm file...');
|
|
160
164
|
this.geoidHeightModel = await load(egmFilePath, PGMLoader);
|
|
@@ -162,6 +166,7 @@ export default class I3SConverter {
|
|
|
162
166
|
if (slpk) {
|
|
163
167
|
this.nodePages.useWriteFunction(writeFileForSlpk);
|
|
164
168
|
}
|
|
169
|
+
await this.conversionDump.createDumpFile(options);
|
|
165
170
|
try {
|
|
166
171
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
167
172
|
let tilesetUrl = inputUrl;
|
|
@@ -365,12 +370,14 @@ export default class I3SConverter {
|
|
|
365
370
|
}
|
|
366
371
|
}
|
|
367
372
|
async _createSlpk(tilesetPath) {
|
|
373
|
+
await this.conversionDump.deleteDumpFile();
|
|
368
374
|
if (this.options.slpk) {
|
|
369
375
|
const slpkTilesetPath = join(tilesetPath, 'SceneServer', 'layers', '0');
|
|
370
376
|
const slpkFileName = `${tilesetPath}.slpk`;
|
|
371
|
-
await
|
|
372
|
-
|
|
373
|
-
|
|
377
|
+
await createZip(slpkTilesetPath, slpkFileName, async fileList => ({
|
|
378
|
+
path: '@specialIndexFileHASH128@',
|
|
379
|
+
file: await composeHashFile(fileList)
|
|
380
|
+
}));
|
|
374
381
|
try {
|
|
375
382
|
await removeDir(tilesetPath);
|
|
376
383
|
} catch (e) {}
|
|
@@ -412,8 +419,9 @@ export default class I3SConverter {
|
|
|
412
419
|
if (timeRemainingStringBasedOnCount) {
|
|
413
420
|
timeRemainingString = `${timeRemainingStringBasedOnCount} left`;
|
|
414
421
|
}
|
|
415
|
-
|
|
416
|
-
|
|
422
|
+
const percentString = this.progresses[PROGRESS_PHASE1_COUNT].getPercentString();
|
|
423
|
+
const progressString = percentString ? ` ${percentString}%, ${timeRemainingString}` : '';
|
|
424
|
+
console.log(`[converted${progressString}]: ${sourceTile.id}`);
|
|
417
425
|
}
|
|
418
426
|
return newTraversalProps;
|
|
419
427
|
}
|
|
@@ -470,7 +478,10 @@ export default class I3SConverter {
|
|
|
470
478
|
const node = await new NodeIndexDocument(nodeInPage.index, this).addData(nodeData);
|
|
471
479
|
nodes.push(node);
|
|
472
480
|
if (nodeInPage.mesh) {
|
|
473
|
-
|
|
481
|
+
if (sourceTile.id) {
|
|
482
|
+
await this.conversionDump.addNode(sourceTile.id, nodeInPage.index);
|
|
483
|
+
}
|
|
484
|
+
await this._writeResources(resources, node.id, sourceTile);
|
|
474
485
|
}
|
|
475
486
|
if (this.validate) {
|
|
476
487
|
this.boundingVolumeWarnings = validateNodeBoundingVolumes(nodeData);
|
|
@@ -556,7 +567,7 @@ export default class I3SConverter {
|
|
|
556
567
|
this.nodePages.saveNode(node);
|
|
557
568
|
return node;
|
|
558
569
|
}
|
|
559
|
-
async _writeResources(resources, nodePath) {
|
|
570
|
+
async _writeResources(resources, nodePath, sourceTile) {
|
|
560
571
|
const {
|
|
561
572
|
geometry: geometryBuffer,
|
|
562
573
|
compressedGeometry,
|
|
@@ -566,60 +577,81 @@ export default class I3SConverter {
|
|
|
566
577
|
} = resources;
|
|
567
578
|
const childPath = join(this.layers0Path, 'nodes', nodePath);
|
|
568
579
|
const slpkChildPath = join('nodes', nodePath);
|
|
569
|
-
await this._writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath);
|
|
570
|
-
await this._writeShared(sharedResources, childPath, slpkChildPath, nodePath);
|
|
571
|
-
await this._writeTexture(texture, childPath, slpkChildPath);
|
|
572
|
-
await this._writeAttributes(attributes, childPath, slpkChildPath);
|
|
580
|
+
await this._writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath, sourceTile.id || '', parseInt(nodePath));
|
|
581
|
+
await this._writeShared(sharedResources, childPath, slpkChildPath, nodePath, sourceTile.id || '', parseInt(nodePath));
|
|
582
|
+
await this._writeTexture(texture, childPath, slpkChildPath, sourceTile.id || '', parseInt(nodePath));
|
|
583
|
+
await this._writeAttributes(attributes, childPath, slpkChildPath, sourceTile.id || '', parseInt(nodePath));
|
|
573
584
|
}
|
|
574
|
-
async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
|
|
585
|
+
async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath, sourceId, nodeId) {
|
|
586
|
+
this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.GEOMETRY, false);
|
|
575
587
|
if (this.options.slpk) {
|
|
576
588
|
const slpkGeometryPath = join(childPath, 'geometries');
|
|
577
589
|
await this.writeQueue.enqueue({
|
|
578
590
|
archiveKey: `${slpkChildPath}/geometries/0.bin.gz`,
|
|
591
|
+
sourceId,
|
|
592
|
+
outputId: nodeId,
|
|
593
|
+
resourceType: ResourceType.GEOMETRY,
|
|
579
594
|
writePromise: () => writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')
|
|
580
595
|
});
|
|
581
596
|
} else {
|
|
582
597
|
const geometryPath = join(childPath, 'geometries/0/');
|
|
583
598
|
await this.writeQueue.enqueue({
|
|
599
|
+
sourceId,
|
|
600
|
+
outputId: nodeId,
|
|
601
|
+
resourceType: ResourceType.GEOMETRY,
|
|
584
602
|
writePromise: () => writeFile(geometryPath, geometryBuffer, 'index.bin')
|
|
585
603
|
});
|
|
586
604
|
}
|
|
587
605
|
if (this.options.draco) {
|
|
606
|
+
this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.DRACO_GEOMETRY, false);
|
|
588
607
|
if (this.options.slpk) {
|
|
589
608
|
const slpkCompressedGeometryPath = join(childPath, 'geometries');
|
|
590
609
|
await this.writeQueue.enqueue({
|
|
591
610
|
archiveKey: `${slpkChildPath}/geometries/1.bin.gz`,
|
|
611
|
+
sourceId,
|
|
612
|
+
outputId: nodeId,
|
|
613
|
+
resourceType: ResourceType.DRACO_GEOMETRY,
|
|
592
614
|
writePromise: () => writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
|
|
593
615
|
});
|
|
594
616
|
} else {
|
|
595
617
|
const compressedGeometryPath = join(childPath, 'geometries/1/');
|
|
596
618
|
await this.writeQueue.enqueue({
|
|
619
|
+
sourceId,
|
|
620
|
+
outputId: nodeId,
|
|
621
|
+
resourceType: ResourceType.DRACO_GEOMETRY,
|
|
597
622
|
writePromise: () => writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')
|
|
598
623
|
});
|
|
599
624
|
}
|
|
600
625
|
}
|
|
601
626
|
}
|
|
602
|
-
async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
|
|
627
|
+
async _writeShared(sharedResources, childPath, slpkChildPath, nodePath, sourceId, nodeId) {
|
|
603
628
|
if (!sharedResources) {
|
|
604
629
|
return;
|
|
605
630
|
}
|
|
606
631
|
sharedResources.nodePath = nodePath;
|
|
607
632
|
const sharedData = transform(sharedResources, sharedResourcesTemplate());
|
|
608
633
|
const sharedDataStr = JSON.stringify(sharedData);
|
|
634
|
+
this.conversionDump.updateDoneStatus(sourceId, nodeId, ResourceType.SHARED, false);
|
|
609
635
|
if (this.options.slpk) {
|
|
610
636
|
const slpkSharedPath = join(childPath, 'shared');
|
|
611
637
|
await this.writeQueue.enqueue({
|
|
612
638
|
archiveKey: `${slpkChildPath}/shared/sharedResource.json.gz`,
|
|
639
|
+
sourceId,
|
|
640
|
+
outputId: nodeId,
|
|
641
|
+
resourceType: ResourceType.SHARED,
|
|
613
642
|
writePromise: () => writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')
|
|
614
643
|
});
|
|
615
644
|
} else {
|
|
616
645
|
const sharedPath = join(childPath, 'shared/');
|
|
617
646
|
await this.writeQueue.enqueue({
|
|
647
|
+
sourceId,
|
|
648
|
+
outputId: nodeId,
|
|
649
|
+
resourceType: ResourceType.SHARED,
|
|
618
650
|
writePromise: () => writeFile(sharedPath, sharedDataStr)
|
|
619
651
|
});
|
|
620
652
|
}
|
|
621
653
|
}
|
|
622
|
-
async _writeTexture(texture, childPath, slpkChildPath) {
|
|
654
|
+
async _writeTexture(texture, childPath, slpkChildPath, sourceId, nodeId) {
|
|
623
655
|
if (texture) {
|
|
624
656
|
const format = this._getFormatByMimeType(texture === null || texture === void 0 ? void 0 : texture.mimeType);
|
|
625
657
|
const formats = [];
|
|
@@ -632,7 +664,8 @@ export default class I3SConverter {
|
|
|
632
664
|
name: '0',
|
|
633
665
|
format
|
|
634
666
|
});
|
|
635
|
-
|
|
667
|
+
this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/${format}`, false);
|
|
668
|
+
await this.writeTextureFile(textureData, '0', format, childPath, slpkChildPath, sourceId, nodeId);
|
|
636
669
|
if (this.generateTextures) {
|
|
637
670
|
formats.push({
|
|
638
671
|
name: '1',
|
|
@@ -652,7 +685,8 @@ export default class I3SConverter {
|
|
|
652
685
|
_nodeWorkers: true,
|
|
653
686
|
useLocalLibraries: true
|
|
654
687
|
});
|
|
655
|
-
|
|
688
|
+
this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/ktx2`, false);
|
|
689
|
+
await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath, sourceId, nodeId);
|
|
656
690
|
}
|
|
657
691
|
break;
|
|
658
692
|
}
|
|
@@ -662,14 +696,16 @@ export default class I3SConverter {
|
|
|
662
696
|
name: '1',
|
|
663
697
|
format
|
|
664
698
|
});
|
|
665
|
-
|
|
699
|
+
this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/${format}`, false);
|
|
700
|
+
await this.writeTextureFile(textureData, '1', format, childPath, slpkChildPath, sourceId, nodeId);
|
|
666
701
|
if (this.generateTextures) {
|
|
667
702
|
formats.push({
|
|
668
703
|
name: '0',
|
|
669
704
|
format: 'jpg'
|
|
670
705
|
});
|
|
671
706
|
const decodedFromKTX2TextureData = encode(texture.image.data[0], ImageWriter);
|
|
672
|
-
|
|
707
|
+
this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.TEXTURE}/jpg`, false);
|
|
708
|
+
await this.writeTextureFile(decodedFromKTX2TextureData, '0', 'jpg', childPath, slpkChildPath, sourceId, nodeId);
|
|
673
709
|
}
|
|
674
710
|
}
|
|
675
711
|
}
|
|
@@ -684,17 +720,23 @@ export default class I3SConverter {
|
|
|
684
720
|
}
|
|
685
721
|
}
|
|
686
722
|
}
|
|
687
|
-
async writeTextureFile(textureData, name, format, childPath, slpkChildPath) {
|
|
723
|
+
async writeTextureFile(textureData, name, format, childPath, slpkChildPath, sourceId, nodeId) {
|
|
688
724
|
if (this.options.slpk) {
|
|
689
725
|
const slpkTexturePath = join(childPath, 'textures');
|
|
690
726
|
const compress = false;
|
|
691
727
|
await this.writeQueue.enqueue({
|
|
692
728
|
archiveKey: `${slpkChildPath}/textures/${name}.${format}`,
|
|
729
|
+
sourceId,
|
|
730
|
+
outputId: nodeId,
|
|
731
|
+
resourceType: `${ResourceType.TEXTURE}/${format}`,
|
|
693
732
|
writePromise: () => writeFileForSlpk(slpkTexturePath, textureData, `${name}.${format}`, compress)
|
|
694
733
|
});
|
|
695
734
|
} else {
|
|
696
735
|
const texturePath = join(childPath, `textures/${name}/`);
|
|
697
736
|
await this.writeQueue.enqueue({
|
|
737
|
+
sourceId,
|
|
738
|
+
outputId: nodeId,
|
|
739
|
+
resourceType: `${ResourceType.TEXTURE}/${format}`,
|
|
698
740
|
writePromise: () => writeFile(texturePath, textureData, `index.${format}`)
|
|
699
741
|
});
|
|
700
742
|
}
|
|
@@ -703,20 +745,29 @@ export default class I3SConverter {
|
|
|
703
745
|
let attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
704
746
|
let childPath = arguments.length > 1 ? arguments[1] : undefined;
|
|
705
747
|
let slpkChildPath = arguments.length > 2 ? arguments[2] : undefined;
|
|
748
|
+
let sourceId = arguments.length > 3 ? arguments[3] : undefined;
|
|
749
|
+
let nodeId = arguments.length > 4 ? arguments[4] : undefined;
|
|
706
750
|
if (attributes !== null && attributes !== void 0 && attributes.length && this.attributeMetadataInfo.attributeStorageInfo.length) {
|
|
707
751
|
const minimumLength = attributes.length < this.attributeMetadataInfo.attributeStorageInfo.length ? attributes.length : this.attributeMetadataInfo.attributeStorageInfo.length;
|
|
708
752
|
for (let index = 0; index < minimumLength; index++) {
|
|
709
753
|
const folderName = this.attributeMetadataInfo.attributeStorageInfo[index].key;
|
|
710
754
|
const fileBuffer = new Uint8Array(attributes[index]);
|
|
755
|
+
this.conversionDump.updateDoneStatus(sourceId, nodeId, `${ResourceType.ATTRIBUTES}/${folderName}`, false);
|
|
711
756
|
if (this.options.slpk) {
|
|
712
757
|
const slpkAttributesPath = join(childPath, 'attributes', folderName);
|
|
713
758
|
await this.writeQueue.enqueue({
|
|
714
759
|
archiveKey: `${slpkChildPath}/attributes/${folderName}.bin.gz`,
|
|
760
|
+
sourceId,
|
|
761
|
+
outputId: nodeId,
|
|
762
|
+
resourceType: `${ResourceType.ATTRIBUTES}/${folderName}`,
|
|
715
763
|
writePromise: () => writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')
|
|
716
764
|
});
|
|
717
765
|
} else {
|
|
718
766
|
const attributesPath = join(childPath, `attributes/${folderName}/0`);
|
|
719
767
|
await this.writeQueue.enqueue({
|
|
768
|
+
sourceId,
|
|
769
|
+
outputId: nodeId,
|
|
770
|
+
resourceType: `${ResourceType.ATTRIBUTES}/${folderName}`,
|
|
720
771
|
writePromise: () => writeFile(attributesPath, fileBuffer, 'index.bin')
|
|
721
772
|
});
|
|
722
773
|
}
|