@loaders.gl/tile-converter 4.0.0-alpha.10 → 4.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/slpk-extractor.js +4 -0
- package/dist/3d-tiles-attributes-worker.js +1 -1
- package/dist/converter-cli.js +18 -84
- package/dist/converter.min.js +50 -50
- package/dist/dist.min.js +2 -2
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/converter-cli.js +18 -63
- package/dist/es5/converter-cli.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +1 -1
- package/dist/es5/i3s-attributes-worker.js +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +2 -2
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/lib/utils/cli-utils.js +57 -0
- package/dist/es5/lib/utils/cli-utils.js.map +1 -0
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/slpk-extractor/helpers/file-handle-provider.js +181 -0
- package/dist/es5/slpk-extractor/helpers/file-handle-provider.js.map +1 -0
- package/dist/es5/slpk-extractor/slpk-extractor.js +172 -0
- package/dist/es5/slpk-extractor/slpk-extractor.js.map +1 -0
- package/dist/es5/slpk-extractor-cli.js +117 -0
- package/dist/es5/slpk-extractor-cli.js.map +1 -0
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/converter-cli.js +1 -46
- package/dist/esm/converter-cli.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/lib/utils/cli-utils.js +47 -0
- package/dist/esm/lib/utils/cli-utils.js.map +1 -0
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/slpk-extractor/helpers/file-handle-provider.js +43 -0
- package/dist/esm/slpk-extractor/helpers/file-handle-provider.js.map +1 -0
- package/dist/esm/slpk-extractor/slpk-extractor.js +63 -0
- package/dist/esm/slpk-extractor/slpk-extractor.js.map +1 -0
- package/dist/esm/slpk-extractor-cli.js +74 -0
- package/dist/esm/slpk-extractor-cli.js.map +1 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +1 -2
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +1 -2
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +2 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +2 -3
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +1 -2
- package/dist/i3s-converter/i3s-converter.js +1 -1
- package/dist/lib/utils/cli-utils.d.ts +34 -0
- package/dist/lib/utils/cli-utils.d.ts.map +1 -0
- package/dist/lib/utils/cli-utils.js +82 -0
- package/dist/slpk-extractor/helpers/file-handle-provider.d.ts +48 -0
- package/dist/slpk-extractor/helpers/file-handle-provider.d.ts.map +1 -0
- package/dist/slpk-extractor/helpers/file-handle-provider.js +71 -0
- package/dist/slpk-extractor/slpk-extractor.d.ts +23 -0
- package/dist/slpk-extractor/slpk-extractor.d.ts.map +1 -0
- package/dist/slpk-extractor/slpk-extractor.js +78 -0
- package/dist/slpk-extractor-cli.d.ts +17 -0
- package/dist/slpk-extractor-cli.d.ts.map +1 -0
- package/dist/slpk-extractor-cli.js +102 -0
- package/dist/slpk-extractor.min.js +189 -0
- package/package.json +17 -15
- package/src/converter-cli.ts +7 -72
- package/src/i3s-converter/helpers/coordinate-converter.ts +1 -2
- package/src/i3s-converter/helpers/gltf-attributes.ts +7 -8
- package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +1 -3
- package/src/i3s-converter/i3s-converter.ts +1 -1
- package/src/lib/utils/cli-utils.ts +78 -0
- package/src/slpk-extractor/helpers/file-handle-provider.ts +91 -0
- package/src/slpk-extractor/slpk-extractor.ts +102 -0
- package/src/slpk-extractor-cli.ts +128 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter-cli.js","names":["join","I3SConverter","Tiles3DConverter","DepsInstaller","TILESET_TYPE","I3S","_3DTILES","main","args","process","argv","length","printHelp","validatedOptionsArr","validateOptionsWithEqual","options","parseOptions","installDependencies","depthInstaller","install","validatedOptions","validateOptions","convert","catch","error","console","log","exit","concat","inputType","toUpperCase","tiles3DConverter","inputUrl","tileset","outputPath","output","tilesetName","name","maxDepth","egmFilePath","egm","converter","slpk","sevenZipExe","token","draco","mergeMaterials","generateTextures","generateBoundingVolumes","validate","instantNodeWriting","mandatoryOptionsWithExceptions","exceptions","mandatoryOption","optionValue","isWrongInputType","Boolean","Object","values","includes","push","forEach","exeption","reduce","acc","curr","equalSignIndex","indexOf","beforeEqual","slice","afterEqual","condition","startsWith","opts","cwd","arg","index","getStringValue","getURLValue","getBooleanValue","getIntegerValue","warn","value","replace","stringValue","result","Number","parseInt","isFinite","NaN","toLowerCase","trim"],"sources":["../../src/converter-cli.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport '@loaders.gl/polyfills';\nimport {join} from 'path';\nimport {I3SConverter, Tiles3DConverter} from '@loaders.gl/tile-converter';\nimport {DepsInstaller} from './deps-installer/deps-installer';\n\ntype TileConversionOptions = {\n /** \"I3S\" - for I3S to 3DTiles conversion, \"3DTILES\" for 3DTiles to I3S conversion */\n inputType?: string;\n /** \"tileset.json\" file (3DTiles) / \"http://..../SceneServer/layers/0\" resource (I3S) */\n tileset?: string;\n /** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */\n name?: string;\n /** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.\n * Default: \"data\" folder */\n output: string;\n /** Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed */\n instantNodeWriting: boolean;\n /** Try to merge similar materials to be able to merge meshes into one node (I3S to 3DTiles conversion only) */\n mergeMaterials: boolean;\n /** 3DTiles->I3S only. location of 7z.exe archiver to create slpk on Windows OS, default: \"C:\\Program Files\\7-Zip\\7z.exe\" */\n sevenZipExe: string;\n /** location of the Earth Gravity Model (*.pgm) file to convert heights from ellipsoidal to gravity-related format,\n * default: \"./deps/egm2008-5.pgm\". A model file can be loaded from GeographicLib\n * https://geographiclib.sourceforge.io/html/geoid.html */\n egm: string;\n /** 3DTile->I3S only. Token for Cesium ION tileset authentication. */\n token?: string;\n /** 3DTiles->I3S only. Enable draco compression for geometry. Default: true */\n draco: boolean;\n /** Run the script for installing dependencies. Run this options separate from others. Now \"*.pgm\" file installation is\n * implemented */\n installDependencies: boolean;\n /** 3DTile->I3S only. Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture\n * if only KTX2 is provided */\n generateTextures: boolean;\n /** 3DTile->I3S only. Will generate obb and mbs bounding volumes from geometry */\n generateBoundingVolumes: boolean;\n /** Validate the dataset during conversion. Validation messages will be posted in the console output */\n validate: boolean;\n /** Maximal depth of the hierarchical tiles tree traversal, default: infinite */\n maxDepth?: number;\n /** 3DTiles->I3S only. Whether the converter generates *.slpk (Scene Layer Package) I3S output file */\n slpk: boolean;\n};\n\n/* During validation we check that particular options are defined so they can't be undefined */\ntype ValidatedTileConversionOptions = TileConversionOptions & {\n /** \"I3S\" - for I3S to 3DTiles conversion, \"3DTILES\" for 3DTiles to I3S conversion */\n inputType: string;\n /** \"tileset.json\" file (3DTiles) / \"http://..../SceneServer/layers/0\" resource (I3S) */\n tileset: string;\n /** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */\n name: string;\n};\n\nconst TILESET_TYPE = {\n I3S: 'I3S',\n _3DTILES: '3DTILES'\n};\n\n/**\n * CLI entry\n * @returns\n */\nasync function main() {\n const [, , ...args] = process.argv;\n\n if (args.length === 0) {\n printHelp();\n }\n\n const validatedOptionsArr = validateOptionsWithEqual(args);\n\n const options: TileConversionOptions = parseOptions(validatedOptionsArr);\n\n if (options.installDependencies) {\n const depthInstaller = new DepsInstaller();\n depthInstaller.install('deps');\n return;\n }\n\n const validatedOptions: ValidatedTileConversionOptions = validateOptions(options);\n\n await convert(validatedOptions);\n}\n\nmain().catch((error) => {\n console.log(error);\n process.exit(1); // eslint-disable-line\n});\n\n/**\n * Output for `npx tile-converter --help`\n */\nfunction printHelp(): void {\n console.log('cli: converter 3dTiles to I3S or I3S to 3dTiles...');\n console.log(\n '--install-dependencies [Run the script for installing dependencies. Run this options separate from others. Now \"*.pgm\" file installation is implemented]'\n );\n console.log(\n '--max-depth [Maximal depth of hierarchical tiles tree traversal, default: infinite]'\n );\n console.log('--name [Tileset name]');\n console.log('--output [Output folder, default: \"data\" folder]');\n console.log(\n '--instant-node-writing [Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed]'\n );\n console.log(\n '--split-nodes [Prevent to merge similar materials that could lead to incorrect visualization (I3S to 3DTiles conversion only)]'\n );\n console.log('--slpk [Generate slpk (Scene Layer Packages) I3S output file]');\n console.log(\n '--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]'\n );\n console.log('--input-type [tileset input type: I3S or 3DTILES]');\n console.log(\n '--7zExe [location of 7z.exe archiver to create slpk on Windows, default: \"C:\\\\Program Files\\\\7-Zip\\\\7z.exe\"]'\n );\n console.log(\n '--egm [location of Earth Gravity Model *.pgm file to convert heights from ellipsoidal to gravity-related format. A model file can be loaded from GeographicLib https://geographiclib.sourceforge.io/html/geoid.html], default: \"./deps/egm2008-5.zip\"'\n );\n console.log('--token [Token for Cesium ION tilesets authentication]');\n console.log('--no-draco [Disable draco compression for geometry]');\n console.log(\n '--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]'\n );\n console.log(\n '--generate-bounding-volumes [Will generate obb and mbs bounding volumes from geometry]'\n );\n console.log('--validate [Enable validation]');\n process.exit(0); // eslint-disable-line\n}\n\n/**\n * Run conversion process\n * @param options validated tile-converter options\n */\nasync function convert(options: ValidatedTileConversionOptions) {\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Starting conversion of ${options.inputType}`); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n const inputType = options.inputType.toUpperCase();\n switch (inputType) {\n case TILESET_TYPE.I3S:\n const tiles3DConverter = new Tiles3DConverter();\n tiles3DConverter.convert({\n inputUrl: options.tileset,\n outputPath: options.output,\n tilesetName: options.name,\n maxDepth: options.maxDepth,\n egmFilePath: options.egm\n });\n break;\n case TILESET_TYPE._3DTILES:\n const converter = new I3SConverter();\n await converter.convert({\n inputUrl: options.tileset,\n outputPath: options.output,\n tilesetName: options.name,\n maxDepth: options.maxDepth,\n slpk: options.slpk,\n sevenZipExe: options.sevenZipExe,\n egmFilePath: options.egm,\n token: options.token,\n draco: options.draco,\n mergeMaterials: options.mergeMaterials,\n generateTextures: options.generateTextures,\n generateBoundingVolumes: options.generateBoundingVolumes,\n validate: options.validate,\n instantNodeWriting: options.instantNodeWriting\n });\n break;\n default:\n printHelp();\n }\n}\n\n// OPTIONS\n/**\n * Validate input options of the CLI command\n * @param options - input options of the CLI command\n * @returns validated options\n */\nfunction validateOptions(options: TileConversionOptions): ValidatedTileConversionOptions {\n const mandatoryOptionsWithExceptions: {\n [key: string]: () => void;\n } = {\n name: () => console.log('Missed: --name [Tileset name]'),\n output: () => console.log('Missed: --output [Output path name]'),\n sevenZipExe: () => console.log('Missed: --7zExe [7z archiver executable path]'),\n egm: () => console.log('Missed: --egm [*.pgm earth gravity model file path]'),\n tileset: () => console.log('Missed: --tileset [tileset.json file]'),\n inputType: () =>\n console.log('Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]')\n };\n const exceptions: (() => void)[] = [];\n for (const mandatoryOption in mandatoryOptionsWithExceptions) {\n const optionValue = options[mandatoryOption];\n const isWrongInputType =\n Boolean(optionValue) &&\n mandatoryOption === 'inputType' &&\n !Object.values(TILESET_TYPE).includes(optionValue.toUpperCase());\n\n if (!optionValue || isWrongInputType) {\n exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption]);\n }\n }\n if (exceptions.length) {\n exceptions.forEach((exeption) => exeption());\n process.exit(1);\n }\n return <ValidatedTileConversionOptions>options;\n}\n\nfunction validateOptionsWithEqual(args: string[]): string[] {\n return args.reduce((acc: string[], curr) => {\n const equalSignIndex = curr.indexOf('=');\n const beforeEqual = curr.slice(0, equalSignIndex);\n const afterEqual = curr.slice(equalSignIndex + 1, curr.length);\n const condition = curr.includes('=') && curr.startsWith('--') && afterEqual;\n if (condition) {\n return acc.concat(beforeEqual, afterEqual);\n }\n return acc.concat(curr);\n }, []);\n}\n\n/**\n * Parse option from the cli arguments array\n * @param args\n * @returns\n */\nfunction parseOptions(args: string[]): TileConversionOptions {\n const opts: TileConversionOptions = {\n output: 'data',\n instantNodeWriting: false,\n mergeMaterials: true,\n sevenZipExe: 'C:\\\\Program Files\\\\7-Zip\\\\7z.exe',\n egm: join(process.cwd(), 'deps', 'egm2008-5.pgm'),\n draco: true,\n installDependencies: false,\n generateTextures: false,\n generateBoundingVolumes: false,\n validate: false,\n slpk: false\n };\n\n // eslint-disable-next-line complexity\n args.forEach((arg, index) => {\n if (arg.indexOf('--') === 0) {\n switch (arg) {\n case '--input-type':\n opts.inputType = getStringValue(index, args);\n break;\n case '--tileset':\n opts.tileset = getURLValue(index, args);\n break;\n case '--name':\n opts.name = getStringValue(index, args);\n break;\n case '--output':\n opts.output = getStringValue(index, args);\n break;\n case '--instant-node-writing':\n opts.instantNodeWriting = getBooleanValue(index, args);\n break;\n case '--split-nodes':\n opts.mergeMaterials = getBooleanValue(index, args);\n break;\n case '--max-depth':\n opts.maxDepth = getIntegerValue(index, args);\n break;\n case '--slpk':\n opts.slpk = getBooleanValue(index, args);\n break;\n case '--7zExe':\n opts.sevenZipExe = getStringValue(index, args);\n break;\n case '--egm':\n opts.egm = getStringValue(index, args);\n break;\n case '--token':\n opts.token = getStringValue(index, args);\n break;\n case '--no-draco':\n opts.draco = getBooleanValue(index, args);\n break;\n case '--validate':\n opts.validate = getBooleanValue(index, args);\n break;\n case '--install-dependencies':\n opts.installDependencies = getBooleanValue(index, args);\n break;\n case '--generate-textures':\n opts.generateTextures = getBooleanValue(index, args);\n break;\n case '--generate-bounding-volumes':\n opts.generateBoundingVolumes = getBooleanValue(index, args);\n break;\n case '--help':\n printHelp();\n break;\n default:\n console.warn(`Unknown option ${arg}`);\n process.exit(0); // eslint-disable-line\n }\n }\n });\n return opts;\n}\n\n/**\n * Get string option value from cli arguments\n * @param index - option's name index in the argument's array.\n * The value of the option should be next to name of the option.\n * @param args - cli arguments array\n * @returns - string value of the option\n */\nfunction getStringValue(index: number, args: string[]): string {\n if (index + 1 >= args.length) {\n return '';\n }\n const value = args[index + 1];\n if (value.indexOf('--') === 0) {\n return '';\n }\n return value;\n}\n\n/**\n * Modyfy URL path to be compatible with fetch\n * @param index - option's name index in the argument's array.\n * The value of the option should be next to name of the option.\n * @param args - cli arguments array\n * @returns - string value of the option\n */\nfunction getURLValue(index: number, args: string[]): string {\n const value = getStringValue(index, args);\n console.log(`Input tileset value: ${value}`);\n console.log(`Modified tileset value: ${value.replace(/\\\\/g, '/')}`);\n return value.replace(/\\\\/g, '/');\n}\n\n/**\n * Get integer option value from cli arguments\n * @param index - option's name index in the argument's array\n * The value of the option should be next to name of the option.\n * @param args - cli arguments array\n * @returns - number value of the option\n */\nfunction getIntegerValue(index: number, args: string[]): number {\n const stringValue: string = getStringValue(index, args);\n const result: number = Number.parseInt(stringValue);\n if (isFinite(result)) {\n return result;\n }\n return NaN;\n}\n\nfunction getBooleanValue(index: number, args: string[]): boolean {\n const stringValue: string = getStringValue(index, args).toLowerCase().trim();\n if (['--no-draco', '--split-nodes'].includes(args[index]) && !stringValue) {\n return false;\n }\n if (!stringValue || stringValue === 'true') {\n return true;\n }\n return false;\n}\n"],"mappings":"AACA,OAAO,uBAAuB;AAC9B,SAAQA,IAAI,QAAO,MAAM;AACzB,SAAQC,YAAY,EAAEC,gBAAgB,QAAO,4BAA4B;AACzE,SAAQC,aAAa,QAAO,iCAAiC;AAoD7D,MAAMC,YAAY,GAAG;EACnBC,GAAG,EAAE,KAAK;EACVC,QAAQ,EAAE;AACZ,CAAC;AAMD,eAAeC,IAAIA,CAAA,EAAG;EACpB,MAAM,IAAK,GAAGC,IAAI,CAAC,GAAGC,OAAO,CAACC,IAAI;EAElC,IAAIF,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IACrBC,SAAS,CAAC,CAAC;EACb;EAEA,MAAMC,mBAAmB,GAAGC,wBAAwB,CAACN,IAAI,CAAC;EAE1D,MAAMO,OAA8B,GAAGC,YAAY,CAACH,mBAAmB,CAAC;EAExE,IAAIE,OAAO,CAACE,mBAAmB,EAAE;IAC/B,MAAMC,cAAc,GAAG,IAAIf,aAAa,CAAC,CAAC;IAC1Ce,cAAc,CAACC,OAAO,CAAC,MAAM,CAAC;IAC9B;EACF;EAEA,MAAMC,gBAAgD,GAAGC,eAAe,CAACN,OAAO,CAAC;EAEjF,MAAMO,OAAO,CAACF,gBAAgB,CAAC;AACjC;AAEAb,IAAI,CAAC,CAAC,CAACgB,KAAK,CAAEC,KAAK,IAAK;EACtBC,OAAO,CAACC,GAAG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,IAAII,QAAQ,CAACH,MAAM,CAAC,EAAE;IACpB,OAAOA,MAAM;EACf;EACA,OAAOI,GAAG;AACZ;AAEA,SAASV,eAAeA,CAACH,KAAa,EAAEpE,IAAc,EAAW;EAC/D,MAAM4E,WAAmB,GAAGP,cAAc,CAACD,KAAK,EAAEpE,IAAI,CAAC,CAACkF,WAAW,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC;EAC5E,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAAChC,QAAQ,CAACnD,IAAI,CAACoE,KAAK,CAAC,CAAC,IAAI,CAACQ,WAAW,EAAE;IACzE,OAAO,KAAK;EACd;EACA,IAAI,CAACA,WAAW,IAAIA,WAAW,KAAK,MAAM,EAAE;IAC1C,OAAO,IAAI;EACb;EACA,OAAO,KAAK;AACd"}
|
|
1
|
+
{"version":3,"file":"converter-cli.js","names":["join","I3SConverter","Tiles3DConverter","DepsInstaller","getBooleanValue","getIntegerValue","getStringValue","getURLValue","validateOptionsWithEqual","TILESET_TYPE","I3S","_3DTILES","main","args","process","argv","length","printHelp","validatedOptionsArr","options","parseOptions","installDependencies","depthInstaller","install","validatedOptions","validateOptions","convert","catch","error","console","log","exit","concat","inputType","toUpperCase","tiles3DConverter","inputUrl","tileset","outputPath","output","tilesetName","name","maxDepth","egmFilePath","egm","converter","slpk","sevenZipExe","token","draco","mergeMaterials","generateTextures","generateBoundingVolumes","validate","instantNodeWriting","mandatoryOptionsWithExceptions","exceptions","mandatoryOption","optionValue","isWrongInputType","Boolean","Object","values","includes","push","forEach","exeption","opts","cwd","arg","index","indexOf","warn"],"sources":["../../src/converter-cli.ts"],"sourcesContent":["/* eslint-disable no-console */\nimport '@loaders.gl/polyfills';\nimport {join} from 'path';\nimport {I3SConverter, Tiles3DConverter} from '@loaders.gl/tile-converter';\nimport {DepsInstaller} from './deps-installer/deps-installer';\nimport {\n getBooleanValue,\n getIntegerValue,\n getStringValue,\n getURLValue,\n validateOptionsWithEqual\n} from './lib/utils/cli-utils';\n\ntype TileConversionOptions = {\n /** \"I3S\" - for I3S to 3DTiles conversion, \"3DTILES\" for 3DTiles to I3S conversion */\n inputType?: string;\n /** \"tileset.json\" file (3DTiles) / \"http://..../SceneServer/layers/0\" resource (I3S) */\n tileset?: string;\n /** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */\n name?: string;\n /** Output folder. This folder will be created by converter if doesn't exist. It is relative to the converter path.\n * Default: \"data\" folder */\n output: string;\n /** Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed */\n instantNodeWriting: boolean;\n /** Try to merge similar materials to be able to merge meshes into one node (I3S to 3DTiles conversion only) */\n mergeMaterials: boolean;\n /** 3DTiles->I3S only. location of 7z.exe archiver to create slpk on Windows OS, default: \"C:\\Program Files\\7-Zip\\7z.exe\" */\n sevenZipExe: string;\n /** location of the Earth Gravity Model (*.pgm) file to convert heights from ellipsoidal to gravity-related format,\n * default: \"./deps/egm2008-5.pgm\". A model file can be loaded from GeographicLib\n * https://geographiclib.sourceforge.io/html/geoid.html */\n egm: string;\n /** 3DTile->I3S only. Token for Cesium ION tileset authentication. */\n token?: string;\n /** 3DTiles->I3S only. Enable draco compression for geometry. Default: true */\n draco: boolean;\n /** Run the script for installing dependencies. Run this options separate from others. Now \"*.pgm\" file installation is\n * implemented */\n installDependencies: boolean;\n /** 3DTile->I3S only. Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture\n * if only KTX2 is provided */\n generateTextures: boolean;\n /** 3DTile->I3S only. Will generate obb and mbs bounding volumes from geometry */\n generateBoundingVolumes: boolean;\n /** Validate the dataset during conversion. Validation messages will be posted in the console output */\n validate: boolean;\n /** Maximal depth of the hierarchical tiles tree traversal, default: infinite */\n maxDepth?: number;\n /** 3DTiles->I3S only. Whether the converter generates *.slpk (Scene Layer Package) I3S output file */\n slpk: boolean;\n};\n\n/* During validation we check that particular options are defined so they can't be undefined */\ntype ValidatedTileConversionOptions = TileConversionOptions & {\n /** \"I3S\" - for I3S to 3DTiles conversion, \"3DTILES\" for 3DTiles to I3S conversion */\n inputType: string;\n /** \"tileset.json\" file (3DTiles) / \"http://..../SceneServer/layers/0\" resource (I3S) */\n tileset: string;\n /** Tileset name. This option is used for naming in resulting json resouces and for resulting path/*.slpk file naming */\n name: string;\n};\n\nconst TILESET_TYPE = {\n I3S: 'I3S',\n _3DTILES: '3DTILES'\n};\n\n/**\n * CLI entry\n * @returns\n */\nasync function main() {\n const [, , ...args] = process.argv;\n\n if (args.length === 0) {\n printHelp();\n }\n\n const validatedOptionsArr = validateOptionsWithEqual(args);\n\n const options: TileConversionOptions = parseOptions(validatedOptionsArr);\n\n if (options.installDependencies) {\n const depthInstaller = new DepsInstaller();\n depthInstaller.install('deps');\n return;\n }\n\n const validatedOptions: ValidatedTileConversionOptions = validateOptions(options);\n\n await convert(validatedOptions);\n}\n\nmain().catch((error) => {\n console.log(error);\n process.exit(1); // eslint-disable-line\n});\n\n/**\n * Output for `npx tile-converter --help`\n */\nfunction printHelp(): void {\n console.log('cli: converter 3dTiles to I3S or I3S to 3dTiles...');\n console.log(\n '--install-dependencies [Run the script for installing dependencies. Run this options separate from others. Now \"*.pgm\" file installation is implemented]'\n );\n console.log(\n '--max-depth [Maximal depth of hierarchical tiles tree traversal, default: infinite]'\n );\n console.log('--name [Tileset name]');\n console.log('--output [Output folder, default: \"data\" folder]');\n console.log(\n '--instant-node-writing [Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed]'\n );\n console.log(\n '--split-nodes [Prevent to merge similar materials that could lead to incorrect visualization (I3S to 3DTiles conversion only)]'\n );\n console.log('--slpk [Generate slpk (Scene Layer Packages) I3S output file]');\n console.log(\n '--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]'\n );\n console.log('--input-type [tileset input type: I3S or 3DTILES]');\n console.log(\n '--7zExe [location of 7z.exe archiver to create slpk on Windows, default: \"C:\\\\Program Files\\\\7-Zip\\\\7z.exe\"]'\n );\n console.log(\n '--egm [location of Earth Gravity Model *.pgm file to convert heights from ellipsoidal to gravity-related format. A model file can be loaded from GeographicLib https://geographiclib.sourceforge.io/html/geoid.html], default: \"./deps/egm2008-5.zip\"'\n );\n console.log('--token [Token for Cesium ION tilesets authentication]');\n console.log('--no-draco [Disable draco compression for geometry]');\n console.log(\n '--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]'\n );\n console.log(\n '--generate-bounding-volumes [Will generate obb and mbs bounding volumes from geometry]'\n );\n console.log('--validate [Enable validation]');\n process.exit(0); // eslint-disable-line\n}\n\n/**\n * Run conversion process\n * @param options validated tile-converter options\n */\nasync function convert(options: ValidatedTileConversionOptions) {\n console.log(`------------------------------------------------`); // eslint-disable-line\n console.log(`Starting conversion of ${options.inputType}`); // eslint-disable-line\n console.log(`------------------------------------------------`); // eslint-disable-line\n const inputType = options.inputType.toUpperCase();\n switch (inputType) {\n case TILESET_TYPE.I3S:\n const tiles3DConverter = new Tiles3DConverter();\n tiles3DConverter.convert({\n inputUrl: options.tileset,\n outputPath: options.output,\n tilesetName: options.name,\n maxDepth: options.maxDepth,\n egmFilePath: options.egm\n });\n break;\n case TILESET_TYPE._3DTILES:\n const converter = new I3SConverter();\n await converter.convert({\n inputUrl: options.tileset,\n outputPath: options.output,\n tilesetName: options.name,\n maxDepth: options.maxDepth,\n slpk: options.slpk,\n sevenZipExe: options.sevenZipExe,\n egmFilePath: options.egm,\n token: options.token,\n draco: options.draco,\n mergeMaterials: options.mergeMaterials,\n generateTextures: options.generateTextures,\n generateBoundingVolumes: options.generateBoundingVolumes,\n validate: options.validate,\n instantNodeWriting: options.instantNodeWriting\n });\n break;\n default:\n printHelp();\n }\n}\n\n// OPTIONS\n/**\n * Validate input options of the CLI command\n * @param options - input options of the CLI command\n * @returns validated options\n */\nfunction validateOptions(options: TileConversionOptions): ValidatedTileConversionOptions {\n const mandatoryOptionsWithExceptions: {\n [key: string]: () => void;\n } = {\n name: () => console.log('Missed: --name [Tileset name]'),\n output: () => console.log('Missed: --output [Output path name]'),\n sevenZipExe: () => console.log('Missed: --7zExe [7z archiver executable path]'),\n egm: () => console.log('Missed: --egm [*.pgm earth gravity model file path]'),\n tileset: () => console.log('Missed: --tileset [tileset.json file]'),\n inputType: () =>\n console.log('Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]')\n };\n const exceptions: (() => void)[] = [];\n for (const mandatoryOption in mandatoryOptionsWithExceptions) {\n const optionValue = options[mandatoryOption];\n const isWrongInputType =\n Boolean(optionValue) &&\n mandatoryOption === 'inputType' &&\n !Object.values(TILESET_TYPE).includes(optionValue.toUpperCase());\n\n if (!optionValue || isWrongInputType) {\n exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption]);\n }\n }\n if (exceptions.length) {\n exceptions.forEach((exeption) => exeption());\n process.exit(1);\n }\n return <ValidatedTileConversionOptions>options;\n}\n\n/**\n * Parse option from the cli arguments array\n * @param args\n * @returns\n */\nfunction parseOptions(args: string[]): TileConversionOptions {\n const opts: TileConversionOptions = {\n output: 'data',\n instantNodeWriting: false,\n mergeMaterials: true,\n sevenZipExe: 'C:\\\\Program Files\\\\7-Zip\\\\7z.exe',\n egm: join(process.cwd(), 'deps', 'egm2008-5.pgm'),\n draco: true,\n installDependencies: false,\n generateTextures: false,\n generateBoundingVolumes: false,\n validate: false,\n slpk: false\n };\n\n // eslint-disable-next-line complexity\n args.forEach((arg, index) => {\n if (arg.indexOf('--') === 0) {\n switch (arg) {\n case '--input-type':\n opts.inputType = getStringValue(index, args);\n break;\n case '--tileset':\n opts.tileset = getURLValue(index, args);\n break;\n case '--name':\n opts.name = getStringValue(index, args);\n break;\n case '--output':\n opts.output = getStringValue(index, args);\n break;\n case '--instant-node-writing':\n opts.instantNodeWriting = getBooleanValue(index, args);\n break;\n case '--split-nodes':\n opts.mergeMaterials = getBooleanValue(index, args);\n break;\n case '--max-depth':\n opts.maxDepth = getIntegerValue(index, args);\n break;\n case '--slpk':\n opts.slpk = getBooleanValue(index, args);\n break;\n case '--7zExe':\n opts.sevenZipExe = getStringValue(index, args);\n break;\n case '--egm':\n opts.egm = getStringValue(index, args);\n break;\n case '--token':\n opts.token = getStringValue(index, args);\n break;\n case '--no-draco':\n opts.draco = getBooleanValue(index, args);\n break;\n case '--validate':\n opts.validate = getBooleanValue(index, args);\n break;\n case '--install-dependencies':\n opts.installDependencies = getBooleanValue(index, args);\n break;\n case '--generate-textures':\n opts.generateTextures = getBooleanValue(index, args);\n break;\n case '--generate-bounding-volumes':\n opts.generateBoundingVolumes = getBooleanValue(index, args);\n break;\n case '--help':\n printHelp();\n break;\n default:\n console.warn(`Unknown option ${arg}`);\n process.exit(0); // eslint-disable-line\n }\n }\n });\n return opts;\n}\n"],"mappings":"AACA,OAAO,uBAAuB;AAC9B,SAAQA,IAAI,QAAO,MAAM;AACzB,SAAQC,YAAY,EAAEC,gBAAgB,QAAO,4BAA4B;AACzE,SAAQC,aAAa,QAAO,iCAAiC;AAC7D,SACEC,eAAe,EACfC,eAAe,EACfC,cAAc,EACdC,WAAW,EACXC,wBAAwB,QACnB,uBAAuB;AAoD9B,MAAMC,YAAY,GAAG;EACnBC,GAAG,EAAE,KAAK;EACVC,QAAQ,EAAE;AACZ,CAAC;AAMD,eAAeC,IAAIA,CAAA,EAAG;EACpB,MAAM,IAAK,GAAGC,IAAI,CAAC,GAAGC,OAAO,CAACC,IAAI;EAElC,IAAIF,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IACrBC,SAAS,CAAC,CAAC;EACb;EAEA,MAAMC,mBAAmB,GAAGV,wBAAwB,CAACK,IAAI,CAAC;EAE1D,MAAMM,OAA8B,GAAGC,YAAY,CAACF,mBAAmB,CAAC;EAExE,IAAIC,OAAO,CAACE,mBAAmB,EAAE;IAC/B,MAAMC,cAAc,GAAG,IAAInB,aAAa,CAAC,CAAC;IAC1CmB,cAAc,CAACC,OAAO,CAAC,MAAM,CAAC;IAC9B;E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
4
4
|
import { join } from 'path';
|
|
5
5
|
import { ChildProcessProxy } from '@loaders.gl/worker-utils';
|
|
6
|
-
const VERSION = typeof "4.0.0-alpha.
|
|
6
|
+
const VERSION = typeof "4.0.0-alpha.11" !== 'undefined' ? "4.0.0-alpha.11" : 'beta';
|
|
7
7
|
const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
|
|
8
8
|
export class DepsInstaller {
|
|
9
9
|
async install() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { processOnWorker } from '@loaders.gl/worker-utils';
|
|
2
|
-
const VERSION = typeof "4.0.0-alpha.
|
|
2
|
+
const VERSION = typeof "4.0.0-alpha.11" !== 'undefined' ? "4.0.0-alpha.11" : 'latest';
|
|
3
3
|
export const I3SAttributesWorker = {
|
|
4
4
|
id: 'i3s-attributes',
|
|
5
5
|
name: 'I3S Attributes Worker',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coordinate-converter.js","names":["Matrix3","Quaternion","Vector3","Ellipsoid","OrientedBoundingBox","makeOrientedBoundingBoxFromPoints","makeBoundingSphereFromPoints","BoundingSphere","createBoundingVolumes","sourceBoundingVolume","geoidHeightModel","radius","halfSize","quaternion","cartographicCenter","WGS84","cartesianToCartographic","center","getHeight","len","fromMatrix3","normalize","mbs","obb","createBoundingVolumesFromGeometry","cartesianPositions","positionVectors","convertPositionsToVectors","geometryObb","geometryMbs","mbsCenter","obbCenter","positions","result","i","length","positionVector","push","convertBoundingVolumeToI3SFullExtent","boundingVolume","sphere","getBoundingSphere","vertexMax","vertexMin","xmin","Math","min","xmax","max","ymin","ymax","zmin","zmax","createObbFromMbs","halfAxex"],"sources":["../../../../src/i3s-converter/helpers/coordinate-converter.ts"],"sourcesContent":["import type {BoundingVolumes, FullExtent, Mbs, Obb} from '@loaders.gl/i3s';\n\nimport {Matrix3, Quaternion, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {\n OrientedBoundingBox,\n makeOrientedBoundingBoxFromPoints,\n makeBoundingSphereFromPoints,\n BoundingSphere\n} from '@math.gl/culling';\nimport {Geoid} from '@math.gl/geoid';\n\n/**\n * Create bounding volumes object from tile and geoid height model.\n * @param sourceBoundingVolume - initialized bounding volume of the source tile\n * @param geoidHeightModel - instance of Geoid class that converts elevation from geoidal to ellipsoidal and back\n * @returns - Bounding volumes object\n */\nexport function createBoundingVolumes(\n sourceBoundingVolume: OrientedBoundingBox | BoundingSphere,\n geoidHeightModel: Geoid\n): BoundingVolumes {\n let radius;\n let halfSize;\n let quaternion;\n\n const cartographicCenter = Ellipsoid.WGS84.cartesianToCartographic(\n sourceBoundingVolume.center,\n new Vector3()\n );\n cartographicCenter[2] =\n cartographicCenter[2] -\n geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);\n if (sourceBoundingVolume instanceof OrientedBoundingBox) {\n halfSize = sourceBoundingVolume.halfSize;\n radius = new Vector3(halfSize[0], halfSize[1], halfSize[2]).len();\n quaternion = sourceBoundingVolume.quaternion;\n } else {\n radius = sourceBoundingVolume.radius;\n halfSize = [radius, radius, radius];\n quaternion = new Quaternion()\n .fromMatrix3(new Matrix3([halfSize[0], 0, 0, 0, halfSize[1], 0, 0, 0, halfSize[2]]))\n .normalize();\n }\n\n return {\n mbs: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2], radius],\n obb: {\n center: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2]],\n halfSize,\n quaternion\n }\n };\n}\n\n/**\n * Generates bounding volumes from geometry positions\n * @param cartesianPositions\n * @param geoidHeightModel\n */\nexport function createBoundingVolumesFromGeometry(\n cartesianPositions: Float32Array,\n geoidHeightModel: Geoid\n): {mbs: Mbs; obb: Obb} {\n const positionVectors = convertPositionsToVectors(cartesianPositions);\n\n const geometryObb = makeOrientedBoundingBoxFromPoints(positionVectors);\n const geometryMbs = makeBoundingSphereFromPoints(positionVectors);\n\n let mbsCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new Vector3());\n let obbCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new Vector3());\n\n mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);\n obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);\n\n return {\n mbs: [mbsCenter[0], mbsCenter[1], mbsCenter[2], geometryMbs.radius],\n obb: {\n center: obbCenter,\n halfSize: geometryObb.halfSize,\n quaternion: geometryObb.quaternion\n }\n };\n}\n\n/**\n * Create array of posisitons where each vertex is vector\n * @param {array} positions\n * @returns {Vector3[]}\n */\nexport function convertPositionsToVectors(positions: Float32Array): Vector3[] {\n const result: Vector3[] = [];\n\n for (let i = 0; i < positions.length; i += 3) {\n // TODO: (perf) new Vector3 is not optimal but required in `makeOrientedBoundingBoxFromPoints`.\n // modify `makeOrientedBoundingBoxFromPoints` to use scratch vectors\n const positionVector = new Vector3([positions[i], positions[i + 1], positions[i + 2]]);\n result.push(positionVector);\n }\n\n return result;\n}\n\n/**\n * Convert common coordinate to fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md\n * @param\n * @param boundingVolume\n * @returns - fullExtent object\n */\nexport function convertBoundingVolumeToI3SFullExtent(\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): FullExtent {\n let sphere: BoundingSphere;\n if (boundingVolume instanceof BoundingSphere) {\n sphere = boundingVolume;\n } else {\n sphere = boundingVolume.getBoundingSphere();\n }\n const center: Vector3 = sphere.center;\n const radius: number = sphere.radius;\n const vertexMax = Ellipsoid.WGS84.cartesianToCartographic(\n new Vector3(center[0] + radius, center[1] + radius, center[2] + radius),\n new Vector3()\n );\n const vertexMin = Ellipsoid.WGS84.cartesianToCartographic(\n new Vector3(center[0] - radius, center[1] - radius, center[2] - radius),\n new Vector3()\n );\n\n // Converter sometimes returns min values that are bigger then max,\n // so we should check and take bigger value from max and smaller for nim\n return {\n xmin: Math.min(vertexMin[0], vertexMax[0]),\n xmax: Math.max(vertexMin[0], vertexMax[0]),\n ymin: Math.min(vertexMin[1], vertexMax[1]),\n ymax: Math.max(vertexMin[1], vertexMax[1]),\n zmin: Math.min(vertexMin[2], vertexMax[2]),\n zmax: Math.max(vertexMin[2], vertexMax[2])\n };\n}\n\n/**\n * Creates oriented boundinb box from mbs.\n * @param mbs - Minimum Bounding Sphere\n * @returns - Oriented BOunding Box\n */\nexport function createObbFromMbs(mbs: Mbs): Obb {\n const radius = mbs[3];\n const center = new Vector3(mbs[0], mbs[1], mbs[2]);\n const halfAxex = new Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);\n return new OrientedBoundingBox(center, halfAxex);\n}\n"],"mappings":"AAEA,SAAQA,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAAO,eAAe;AAC1D,SAAQC,SAAS,QAAO,qBAAqB;AAC7C,SACEC,mBAAmB,EACnBC,iCAAiC,EACjCC,4BAA4B,EAC5BC,cAAc,QACT,kBAAkB;AASzB,OAAO,SAASC,qBAAqBA,CACnCC,oBAA0D,EAC1DC,gBAAuB,EACN;EACjB,IAAIC,MAAM;EACV,IAAIC,QAAQ;EACZ,IAAIC,UAAU;EAEd,MAAMC,kBAAkB,GAAGX,SAAS,CAACY,KAAK,CAACC,uBAAuB,CAChEP,oBAAoB,CAACQ,MAAM,EAC3B,IAAIf,OAAO,CAAC,CACd,CAAC;EACDY,kBAAkB,CAAC,CAAC,CAAC,GACnBA,kBAAkB,CAAC,CAAC,CAAC,GACrBJ,gBAAgB,CAACQ,SAAS,CAACJ,kBAAkB,CAAC,CAAC,CAAC,EAAEA,kBAAkB,CAAC,CAAC,CAAC,CAAC;EAC1E,IAAIL,oBAAoB,YAAYL,mBAAmB,EAAE;IACvDQ,QAAQ,GAAGH,oBAAoB,CAACG,QAAQ;IACxCD,MAAM,GAAG,IAAIT,OAAO,CAACU,QAAQ,CAAC,CAAC,CAAC,EAAEA,QAAQ,CAA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N,IAAI,CAACC,GAAG,CAACH,SAAS,CAAC,CAAC,CAAC,EAAED,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1CU,IAAI,EAAEP,IAAI,CAACG,GAAG,CAACL,SAAS,CAAC,CAAC,CAAC,EAAED,SAAS,CAAC,CAAC,CAAC;EAC3C,CAAC;AACH;AAOA,OAAO,SAASW,gBAAgBA,CAAC/B,GAAQ,EAAO;EAC9C,MAAMX,MAAM,GAAGW,GAAG,CAAC,CAAC,CAAC;EACrB,MAAML,MAAM,GAAG,IAAIf,OAAO,CAACoB,GAAG,CAAC,CAAC,CAAC,EAAEA,GAAG,CAAC,CAAC,CAAC,EAAEA,GAAG,CAAC,CAAC,CAAC,CAAC;EAClD,MAAMgC,QAAQ,GAAG,IAAItD,OAAO,CAAC,CAACW,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAEA,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAEA,MAAM,CAAC,CAAC;EACxE,OAAO,IAAIP,mBAAmB,CAACa,MAAM,EAAEqC,QAAQ,CAAC;AAClD"}
|
|
1
|
+
{"version":3,"file":"coordinate-converter.js","names":["Matrix3","Quaternion","Vector3","Ellipsoid","OrientedBoundingBox","makeOrientedBoundingBoxFromPoints","makeBoundingSphereFromPoints","BoundingSphere","createBoundingVolumes","sourceBoundingVolume","geoidHeightModel","radius","halfSize","quaternion","cartographicCenter","WGS84","cartesianToCartographic","center","getHeight","len","fromMatrix3","normalize","mbs","obb","createBoundingVolumesFromGeometry","cartesianPositions","positionVectors","convertPositionsToVectors","geometryObb","geometryMbs","mbsCenter","obbCenter","positions","result","i","length","positionVector","push","convertBoundingVolumeToI3SFullExtent","boundingVolume","sphere","getBoundingSphere","vertexMax","vertexMin","xmin","Math","min","xmax","max","ymin","ymax","zmin","zmax","createObbFromMbs","halfAxex"],"sources":["../../../../src/i3s-converter/helpers/coordinate-converter.ts"],"sourcesContent":["import type {BoundingVolumes, FullExtent, Mbs, Obb} from '@loaders.gl/i3s';\n\nimport {Matrix3, Quaternion, Vector3} from '@math.gl/core';\nimport {Ellipsoid} from '@math.gl/geospatial';\nimport {\n OrientedBoundingBox,\n makeOrientedBoundingBoxFromPoints,\n makeBoundingSphereFromPoints,\n BoundingSphere\n} from '@math.gl/culling';\nimport {Geoid} from '@math.gl/geoid';\n\n/**\n * Create bounding volumes object from tile and geoid height model.\n * @param sourceBoundingVolume - initialized bounding volume of the source tile\n * @param geoidHeightModel - instance of Geoid class that converts elevation from geoidal to ellipsoidal and back\n * @returns - Bounding volumes object\n */\nexport function createBoundingVolumes(\n sourceBoundingVolume: OrientedBoundingBox | BoundingSphere,\n geoidHeightModel: Geoid\n): BoundingVolumes {\n let radius;\n let halfSize;\n let quaternion;\n\n const cartographicCenter = Ellipsoid.WGS84.cartesianToCartographic(\n sourceBoundingVolume.center,\n new Vector3()\n );\n cartographicCenter[2] =\n cartographicCenter[2] -\n geoidHeightModel.getHeight(cartographicCenter[1], cartographicCenter[0]);\n if (sourceBoundingVolume instanceof OrientedBoundingBox) {\n halfSize = sourceBoundingVolume.halfSize;\n radius = new Vector3(halfSize[0], halfSize[1], halfSize[2]).len();\n quaternion = sourceBoundingVolume.quaternion;\n } else {\n radius = sourceBoundingVolume.radius;\n halfSize = [radius, radius, radius];\n quaternion = new Quaternion()\n .fromMatrix3(new Matrix3([halfSize[0], 0, 0, 0, halfSize[1], 0, 0, 0, halfSize[2]]))\n .normalize();\n }\n\n return {\n mbs: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2], radius],\n obb: {\n center: [cartographicCenter[0], cartographicCenter[1], cartographicCenter[2]],\n halfSize,\n quaternion\n }\n };\n}\n\n/**\n * Generates bounding volumes from geometry positions\n * @param cartesianPositions\n * @param geoidHeightModel\n */\nexport function createBoundingVolumesFromGeometry(\n cartesianPositions: Float32Array,\n geoidHeightModel: Geoid\n): {mbs: Mbs; obb: Obb} {\n const positionVectors = convertPositionsToVectors(cartesianPositions);\n\n const geometryObb = makeOrientedBoundingBoxFromPoints(positionVectors);\n const geometryMbs = makeBoundingSphereFromPoints(positionVectors);\n\n let mbsCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryMbs.center, new Vector3());\n let obbCenter = Ellipsoid.WGS84.cartesianToCartographic(geometryObb.center, new Vector3());\n\n mbsCenter[2] = mbsCenter[2] - geoidHeightModel.getHeight(mbsCenter[1], mbsCenter[0]);\n obbCenter[2] = obbCenter[2] - geoidHeightModel.getHeight(obbCenter[1], obbCenter[0]);\n\n return {\n mbs: [mbsCenter[0], mbsCenter[1], mbsCenter[2], geometryMbs.radius],\n obb: {\n center: obbCenter,\n halfSize: geometryObb.halfSize,\n quaternion: geometryObb.quaternion\n }\n };\n}\n\n/**\n * Create array of posisitons where each vertex is vector\n * @param {array} positions\n * @returns {Vector3[]}\n */\nexport function convertPositionsToVectors(positions: Float32Array): Vector3[] {\n const result: Vector3[] = [];\n\n for (let i = 0; i < positions.length; i += 3) {\n // TODO: (perf) new Vector3 is not optimal but required in `makeOrientedBoundingBoxFromPoints`.\n // modify `makeOrientedBoundingBoxFromPoints` to use scratch vectors\n const positionVector = new Vector3([positions[i], positions[i + 1], positions[i + 2]]);\n result.push(positionVector);\n }\n\n return result;\n}\n\n/**\n * Convert common coordinate to fullExtent https://github.com/Esri/i3s-spec/blob/master/docs/1.8/fullExtent.cmn.md\n * @param boundingVolume\n * @returns - fullExtent object\n */\nexport function convertBoundingVolumeToI3SFullExtent(\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): FullExtent {\n let sphere: BoundingSphere;\n if (boundingVolume instanceof BoundingSphere) {\n sphere = boundingVolume;\n } else {\n sphere = boundingVolume.getBoundingSphere();\n }\n const center: Vector3 = sphere.center;\n const radius: number = sphere.radius;\n const vertexMax = Ellipsoid.WGS84.cartesianToCartographic(\n new Vector3(center[0] + radius, center[1] + radius, center[2] + radius),\n new Vector3()\n );\n const vertexMin = Ellipsoid.WGS84.cartesianToCartographic(\n new Vector3(center[0] - radius, center[1] - radius, center[2] - radius),\n new Vector3()\n );\n\n // Converter sometimes returns min values that are bigger then max,\n // so we should check and take bigger value from max and smaller for nim\n return {\n xmin: Math.min(vertexMin[0], vertexMax[0]),\n xmax: Math.max(vertexMin[0], vertexMax[0]),\n ymin: Math.min(vertexMin[1], vertexMax[1]),\n ymax: Math.max(vertexMin[1], vertexMax[1]),\n zmin: Math.min(vertexMin[2], vertexMax[2]),\n zmax: Math.max(vertexMin[2], vertexMax[2])\n };\n}\n\n/**\n * Creates oriented boundinb box from mbs.\n * @param mbs - Minimum Bounding Sphere\n * @returns - Oriented Bounding Box\n */\nexport function createObbFromMbs(mbs: Mbs): Obb {\n const radius = mbs[3];\n const center = new Vector3(mbs[0], mbs[1], mbs[2]);\n const halfAxex = new Matrix3([radius, 0, 0, 0, radius, 0, 0, 0, radius]);\n return new OrientedBoundingBox(center, halfAxex);\n}\n"],"mappings":"AAEA,SAAQA,OAAO,EAAEC,UAAU,EAAEC,OAAO,QAAO,eAAe;AAC1D,SAAQC,SAAS,QAAO,qBAAqB;AAC7C,SACEC,mBAAmB,EACnBC,iCAAiC,EACjCC,4BAA4B,EAC5BC,cAAc,QACT,kBAAkB;AASzB,OAAO,SAASC,qBAAqBA,CACnCC,oBAA0D,EAC1DC,gBAAuB,EACN;EACjB,IAAIC,MAAM;EACV,IAAIC,QAAQ;EACZ,IAAIC,UAAU;EAEd,MAAMC,kBAAkB,GAAGX,SAAS,CAACY,KAAK,CAACC,uBAAuB,CAChEP,oBAAoB,CAACQ,MAAM,EAC3B,IAAIf,OAAO,CAAC,CACd,CAAC;EACDY,kBAAkB,CAAC,CAAC,CAAC,GACnBA,kBAAkB,CAAC,CAAC,CAAC,GACrBJ,gBAAgB,CAACQ,SAAS,CAACJ,kBAAkB,CAAC,CAAC,CAAC,EAAEA,kBAAkB,CAAC,CAAC,CAAC,CAAC;EAC1E,IAAIL,oBAAoB,YAAYL,mBAAmB,EAAE;IACvDQ,QAAQ,GAAGH,oBAAoB,CAACG,QAA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CAACL,SAAS,CAAC,CAAC,CAAC,EAAED,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1CS,IAAI,EAAEN,IAAI,CAACC,GAAG,CAACH,SAAS,CAAC,CAAC,CAAC,EAAED,SAAS,CAAC,CAAC,CAAC,CAAC;IAC1CU,IAAI,EAAEP,IAAI,CAACG,GAAG,CAACL,SAAS,CAAC,CAAC,CAAC,EAAED,SAAS,CAAC,CAAC,CAAC;EAC3C,CAAC;AACH;AAOA,OAAO,SAASW,gBAAgBA,CAAC/B,GAAQ,EAAO;EAC9C,MAAMX,MAAM,GAAGW,GAAG,CAAC,CAAC,CAAC;EACrB,MAAML,MAAM,GAAG,IAAIf,OAAO,CAACoB,GAAG,CAAC,CAAC,CAAC,EAAEA,GAAG,CAAC,CAAC,CAAC,EAAEA,GAAG,CAAC,CAAC,CAAC,CAAC;EAClD,MAAMgC,QAAQ,GAAG,IAAItD,OAAO,CAAC,CAACW,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAEA,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAEA,MAAM,CAAC,CAAC;EACxE,OAAO,IAAIP,mBAAmB,CAACa,MAAM,EAAEqC,QAAQ,CAAC;AAClD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gltf-attributes.js","names":["Matrix4","Vector3","Ellipsoid","prepareDataForAttributesConversion","tileContent","tileTransform","boundingVolume","_tileContent$gltf","_tileContent$gltf$sce","_tileContent$gltf2","_tileContent$gltf2$sc","_tileContent$gltf2$sc2","_tileContent$gltf3","_tileContent$gltf4","_tileContent$gltf4$im","nodes","gltf","scene","scenes","images","map","imageObject","_imageObject$image","image","compressed","_imageObject$image2","data","dataCopy","Uint8Array","length","set","height","width","components","mimeType","prepareNodes","cartographicOrigin","modelMatrix","cartesianModelMatrix","calculateTransformProps","getB3DMAttributesWithoutBufferView","attributes","attributesWithoutBufferView","attributeName","value","rtcCenter","gltfUpAxis","center","translate","rotationY","rotateX","Math","PI","multiplyRight","rotationX","rotateY","cartesianOrigin","WGS84","cartesianToCartographic","index","node","mesh","_node$mesh","primitives","primitive","_primitive$indices","_primitive$material","_primitive$material2","indices","material","id","uniqueId","children"],"sources":["../../../../src/i3s-converter/helpers/gltf-attributes.ts"],"sourcesContent":["import type {Tiles3DTileContent} from '@loaders.gl/3d-tiles';\nimport type {GLTFAccessorPostprocessed, GLTFNodePostprocessed} from '@loaders.gl/gltf';\nimport type {B3DMAttributesData} from '../../i3s-attributes-worker';\nimport {Matrix4, Vector3} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\ntype AttributesObject = {\n [k: string]: GLTFAccessorPostprocessed;\n};\n\n/**\n * Prepare attributes for conversion to avoid binary data breaking in worker thread.\n * @param tileContent - 3DTiles tile content\n * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying\n * transform of all parent tiles and transform of the current tile\n * @param boundingVolume - initialized bounding volume of the source tile\n * @returns\n */\nexport function prepareDataForAttributesConversion(\n tileContent: Tiles3DTileContent,\n tileTransform: Matrix4,\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): B3DMAttributesData {\n let nodes =\n tileContent.gltf?.scene?.nodes ||\n tileContent.gltf?.scenes?.[0]?.nodes ||\n tileContent.gltf?.nodes ||\n [];\n\n const images =\n tileContent.gltf?.images?.map((imageObject) => {\n // Need data only for uncompressed images because we can't get batchIds from compressed textures.\n if (imageObject?.image?.compressed) {\n return null;\n } else {\n const data = imageObject?.image?.data;\n const dataCopy = new Uint8Array(data.length);\n dataCopy.set(data);\n return {\n data: dataCopy,\n compressed: false,\n height: imageObject.image.height,\n width: imageObject.image.width,\n components: imageObject.image.components,\n mimeType: imageObject.mimeType\n };\n }\n }) || [];\n\n prepareNodes(nodes);\n\n const {cartographicOrigin, modelMatrix: cartesianModelMatrix} = calculateTransformProps(\n tileContent,\n tileTransform,\n boundingVolume\n );\n\n return {\n nodes,\n images,\n cartographicOrigin,\n cartesianModelMatrix\n };\n}\n\n/**\n * Keep only values for glTF attributes to pass data to worker thread.\n * @param attributes - geometry attributes\n */\nfunction getB3DMAttributesWithoutBufferView(attributes: AttributesObject): AttributesObject {\n const attributesWithoutBufferView = {};\n\n for (const attributeName in attributes) {\n attributesWithoutBufferView[attributeName] = {\n value: attributes[attributeName].value\n };\n }\n\n return attributesWithoutBufferView;\n}\n\n/**\n * Calculate transformation properties to transform vertex attributes (POSITION, NORMAL, etc.)\n * from METER_OFFSET coorditantes to LNGLAT_OFFSET coordinates\n * @param tileContent - 3DTiles tile content\n * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying\n * transform of all parent tiles and transform of the current tile\n * @param boundingVolume - initialized bounding volume of the source tile\n * @returns modelMatrix - transformation matrix to transform coordinates to cartographic coordinates\n * cartographicOrigin - tile origin coordinates to calculate offsets\n */\nexport function calculateTransformProps(\n tileContent: Tiles3DTileContent,\n tileTransform: Matrix4,\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): {modelMatrix: Matrix4; cartographicOrigin: Vector3} {\n const {rtcCenter, gltfUpAxis} = tileContent;\n const {center} = boundingVolume;\n\n let modelMatrix = new Matrix4(tileTransform);\n\n // Translate if appropriate\n if (rtcCenter) {\n modelMatrix.translate(rtcCenter);\n }\n\n // glTF models need to be rotated from Y to Z up\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up\n switch (gltfUpAxis) {\n case 'Z':\n break;\n case 'Y':\n const rotationY = new Matrix4().rotateX(Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationY);\n break;\n case 'X':\n const rotationX = new Matrix4().rotateY(-Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationX);\n break;\n default:\n break;\n }\n\n const cartesianOrigin = new Vector3(center);\n const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(\n cartesianOrigin,\n new Vector3()\n );\n return {modelMatrix, cartographicOrigin};\n}\n\n/**\n * Traverse all nodes to replace all sensible data with copy to avoid data corruption in worker.\n * @param nodes\n */\nfunction prepareNodes(nodes: GLTFNodePostprocessed[]): void {\n for (let index = 0; index < nodes.length; index++) {\n const node = nodes[index] as any;\n\n if (node.mesh) {\n nodes[index] = {\n ...node,\n mesh: {\n ...node.mesh,\n primitives: node.mesh?.primitives.map((primitive) => ({\n ...primitive,\n indices: {value: primitive?.indices?.value},\n attributes: getB3DMAttributesWithoutBufferView(primitive.attributes),\n material: {\n id: primitive?.material?.id,\n uniqueId: primitive?.material?.uniqueId\n }\n }))\n }\n };\n }\n\n if (node.children) {\n prepareNodes(node.children);\n }\n }\n}\n"],"mappings":"AAGA,SAAQA,OAAO,EAAEC,OAAO,QAAO,eAAe;AAE9C,SAAQC,SAAS,QAAO,qBAAqB;AAc7C,OAAO,SAASC,kCAAkCA,CAChDC,WAA+B,EAC/BC,aAAsB,EACtBC,cAAoD,EAChC;EAAA,IAAAC,iBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,sBAAA,EAAAC,kBAAA,EAAAC,kBAAA,EAAAC,qBAAA;EACpB,IAAIC,KAAK,GACP,EAAAR,iBAAA,GAAAH,WAAW,CAACY,IAAI,cAAAT,iBAAA,wBAAAC,qBAAA,GAAhBD,iBAAA,CAAkBU,KAAK,cAAAT,qBAAA,uBAAvBA,qBAAA,CAAyBO,KAAK,OAAAN,kBAAA,GAC9BL,WAAW,CAACY,IAAI,cAAAP,kBAAA,wBAAAC,qBAAA,GAAhBD,kBAAA,CAAkBS,MAAM,cAAAR,qBAAA,wBAAAC,sBAAA,GAAxBD,qBAAA,CAA2B,CAAC,CAAC,cAAAC,sBAAA,uBAA7BA,sBAAA,CAA+BI,KAAK,OAAAH,kBAAA,GACpCR,WAAW,CAACY,IAAI,cAAAJ,kBAAA,uBAAhBA,kBAAA,CAAkBG,KAAK,KACvB,EAAE;EAEJ,MAAMI,MAAM,GACV,EAAAN,kBAAA,GAAAT,WAAW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KAAK,CAACc,MAAM,EAAE8B,KAAK,EAAE,EAAE;IACjD,MAAMC,IAAI,GAAG7C,KAAK,CAAC4C,KAAK,CAAQ;IAEhC,IAAIC,IAAI,CAACC,IAAI,EAAE;MAAA,IAAAC,UAAA;MACb/C,KAAK,CAAC4C,KAAK,CAAC,GAAG;QACb,GAAGC,IAAI;QACPC,IAAI,EAAE;UACJ,GAAGD,IAAI,CAACC,IAAI;UACZE,UAAU,GAAAD,UAAA,GAAEF,IAAI,CAACC,IAAI,cAAAC,UAAA,uBAATA,UAAA,CAAWC,UAAU,CAAC3C,GAAG,CAAE4C,SAAS;YAAA,IAAAC,kBAAA,EAAAC,mBAAA,EAAAC,oBAAA;YAAA,OAAM;cACpD,GAAGH,SAAS;cACZI,OAAO,EAAE;gBAACxB,KAAK,EAAEoB,SAAS,aAATA,SAAS,wBAAAC,kBAAA,GAATD,SAAS,CAAEI,OAAO,cAAAH,kBAAA,uBAAlBA,kBAAA,CAAoBrB;cAAK,CAAC;cAC3CH,UAAU,EAAED,kCAAkC,CAACwB,SAAS,CAACvB,UAAU,CAAC;cACpE4B,QAAQ,EAAE;gBACRC,EAAE,EAAEN,SAAS,aAATA,SAAS,wBAAAE,mBAAA,GAATF,SAAS,CAAEK,QAAQ,cAAAH,mBAAA,uBAAnBA,mBAAA,CAAqBI,EAAE;gBAC3BC,QAAQ,EAAEP,SAAS,aAATA,SAAS,wBAAAG,oBAAA,GAATH,SAAS,CAAEK,QAAQ,cAAAF,oBAAA,uBAAnBA,oBAAA,CAAqBI;cACjC;YACF,CAAC;UAAA,CAAC;QACJ;MACF,CAAC;IACH;IAEA,IAAIX,IAAI,CAACY,QAAQ,EAAE;MACjBrC,YAAY,CAACyB,IAAI,CAACY,QAAQ,CAAC;IAC7B;EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"gltf-attributes.js","names":["Matrix4","Vector3","Ellipsoid","prepareDataForAttributesConversion","tileContent","tileTransform","boundingVolume","_tileContent$gltf","_tileContent$gltf$sce","_tileContent$gltf2","_tileContent$gltf2$sc","_tileContent$gltf2$sc2","_tileContent$gltf3","_tileContent$gltf4","_tileContent$gltf4$im","nodes","gltf","scene","scenes","images","map","imageObject","_imageObject$image","image","compressed","_imageObject$image2","data","dataCopy","Uint8Array","length","set","height","width","components","mimeType","prepareNodes","cartographicOrigin","modelMatrix","cartesianModelMatrix","calculateTransformProps","getB3DMAttributesWithoutBufferView","attributes","attributesWithoutBufferView","attributeName","value","rtcCenter","gltfUpAxis","center","translate","rotationY","rotateX","Math","PI","multiplyRight","rotationX","rotateY","cartesianOrigin","WGS84","cartesianToCartographic","index","node","mesh","_node$mesh","primitives","primitive","_primitive$indices","_primitive$material","_primitive$material2","indices","material","id","uniqueId","children"],"sources":["../../../../src/i3s-converter/helpers/gltf-attributes.ts"],"sourcesContent":["import type {Tiles3DTileContent} from '@loaders.gl/3d-tiles';\nimport type {GLTFAccessorPostprocessed, GLTFNodePostprocessed} from '@loaders.gl/gltf';\nimport type {B3DMAttributesData} from '../../i3s-attributes-worker';\nimport {Matrix4, TypedArray, Vector3} from '@math.gl/core';\nimport {BoundingSphere, OrientedBoundingBox} from '@math.gl/culling';\nimport {Ellipsoid} from '@math.gl/geospatial';\n\n/**\n * Prepare attributes for conversion to avoid binary data breaking in worker thread.\n * @param tileContent - 3DTiles tile content\n * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying\n * transform of all parent tiles and transform of the current tile\n * @param boundingVolume - initialized bounding volume of the source tile\n * @returns 3DTiles content data, prepared for conversion\n */\nexport function prepareDataForAttributesConversion(\n tileContent: Tiles3DTileContent,\n tileTransform: Matrix4,\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): B3DMAttributesData {\n let nodes =\n tileContent.gltf?.scene?.nodes ||\n tileContent.gltf?.scenes?.[0]?.nodes ||\n tileContent.gltf?.nodes ||\n [];\n\n const images =\n tileContent.gltf?.images?.map((imageObject) => {\n // Need data only for uncompressed images because we can't get batchIds from compressed textures.\n if (imageObject?.image?.compressed) {\n return null;\n } else {\n const data = imageObject?.image?.data;\n const dataCopy = new Uint8Array(data.length);\n dataCopy.set(data);\n return {\n data: dataCopy,\n compressed: false,\n height: imageObject.image.height,\n width: imageObject.image.width,\n components: imageObject.image.components,\n mimeType: imageObject.mimeType\n };\n }\n }) || [];\n\n prepareNodes(nodes);\n\n const {cartographicOrigin, modelMatrix: cartesianModelMatrix} = calculateTransformProps(\n tileContent,\n tileTransform,\n boundingVolume\n );\n\n return {\n nodes,\n images,\n cartographicOrigin,\n cartesianModelMatrix\n };\n}\n\n/**\n * Keep only values for glTF attributes to pass data to worker thread.\n * @param attributes - geometry attributes\n * @returns attributes with only `value` item\n */\nfunction getB3DMAttributesWithoutBufferView(\n attributes: Record<string, GLTFAccessorPostprocessed>\n): Record<string, {value: TypedArray}> {\n const attributesWithoutBufferView: Record<string, {value: TypedArray}> = {};\n\n for (const attributeName in attributes) {\n attributesWithoutBufferView[attributeName] = {\n value: attributes[attributeName].value\n };\n }\n\n return attributesWithoutBufferView;\n}\n\n/**\n * Calculate transformation properties to transform vertex attributes (POSITION, NORMAL, etc.)\n * from METER_OFFSET coorditantes to LNGLAT_OFFSET coordinates\n * @param tileContent - 3DTiles tile content\n * @param tileTransform - transformation matrix of the tile, calculated recursively multiplying\n * transform of all parent tiles and transform of the current tile\n * @param boundingVolume - initialized bounding volume of the source tile\n * @returns modelMatrix - transformation matrix to transform coordinates to cartographic coordinates\n * cartographicOrigin - tile origin coordinates to calculate offsets\n */\nexport function calculateTransformProps(\n tileContent: Tiles3DTileContent,\n tileTransform: Matrix4,\n boundingVolume: OrientedBoundingBox | BoundingSphere\n): {modelMatrix: Matrix4; cartographicOrigin: Vector3} {\n const {rtcCenter, gltfUpAxis} = tileContent;\n const {center} = boundingVolume;\n\n let modelMatrix = new Matrix4(tileTransform);\n\n // Translate if appropriate\n if (rtcCenter) {\n modelMatrix.translate(rtcCenter);\n }\n\n // glTF models need to be rotated from Y to Z up\n // https://github.com/AnalyticalGraphicsInc/3d-tiles/tree/master/specification#y-up-to-z-up\n switch (gltfUpAxis) {\n case 'Z':\n break;\n case 'Y':\n const rotationY = new Matrix4().rotateX(Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationY);\n break;\n case 'X':\n const rotationX = new Matrix4().rotateY(-Math.PI / 2);\n modelMatrix = modelMatrix.multiplyRight(rotationX);\n break;\n default:\n break;\n }\n\n const cartesianOrigin = new Vector3(center);\n const cartographicOrigin = Ellipsoid.WGS84.cartesianToCartographic(\n cartesianOrigin,\n new Vector3()\n );\n return {modelMatrix, cartographicOrigin};\n}\n\n/**\n * Traverse all nodes to replace all sensible data with copy to avoid data corruption in worker.\n * @param nodes\n */\nfunction prepareNodes(nodes: GLTFNodePostprocessed[]): void {\n for (let index = 0; index < nodes.length; index++) {\n const node = nodes[index] as any;\n\n if (node.mesh) {\n nodes[index] = {\n ...node,\n mesh: {\n ...node.mesh,\n primitives: node.mesh?.primitives.map((primitive) => ({\n ...primitive,\n indices: {value: primitive?.indices?.value},\n attributes: getB3DMAttributesWithoutBufferView(primitive.attributes),\n material: {\n id: primitive?.material?.id,\n uniqueId: primitive?.material?.uniqueId\n }\n }))\n }\n };\n }\n\n if (node.children) {\n prepareNodes(node.children);\n }\n }\n}\n"],"mappings":"AAGA,SAAQA,OAAO,EAAcC,OAAO,QAAO,eAAe;AAE1D,SAAQC,SAAS,QAAO,qBAAqB;AAU7C,OAAO,SAASC,kCAAkCA,CAChDC,WAA+B,EAC/BC,aAAsB,EACtBC,cAAoD,EAChC;EAAA,IAAAC,iBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,sBAAA,EAAAC,kBAAA,EAAAC,kBAAA,EAAAC,qBAAA;EACpB,IAAIC,KAAK,GACP,EAAAR,iBAAA,GAAAH,WAAW,CAACY,IAAI,cAAAT,iBAAA,wBAAAC,qBAAA,GAAhBD,iBAAA,CAAkBU,KAAK,cAAAT,qBAAA,uBAAvBA,qBAAA,CAAyBO,KAA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wBAAAG,oBAAA,GAATH,SAAS,CAAEK,QAAQ,cAAAF,oBAAA,uBAAnBA,oBAAA,CAAqBI;cACjC;YACF,CAAC;UAAA,CAAC;QACJ;MACF,CAAC;IACH;IAEA,IAAIX,IAAI,CAACY,QAAQ,EAAE;MACjBrC,YAAY,CAACyB,IAAI,CAACY,QAAQ,CAAC;IAC7B;EACF;AACF"}
|
|
@@ -2,7 +2,7 @@ import { GltfPrimitiveModeString } from '../types';
|
|
|
2
2
|
import { GLTFLoader } from '@loaders.gl/gltf';
|
|
3
3
|
import { parse } from '@loaders.gl/core';
|
|
4
4
|
export const GLTF_PRIMITIVE_MODES = [GltfPrimitiveModeString.POINTS, GltfPrimitiveModeString.LINES, GltfPrimitiveModeString.LINE_LOOP, GltfPrimitiveModeString.LINE_STRIP, GltfPrimitiveModeString.TRIANGLES, GltfPrimitiveModeString.TRIANGLE_STRIP, GltfPrimitiveModeString.TRIANGLE_FAN];
|
|
5
|
-
export const analyzeTileContent = async
|
|
5
|
+
export const analyzeTileContent = async tileContent => {
|
|
6
6
|
const result = {
|
|
7
7
|
meshTopologyTypes: new Set()
|
|
8
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprocess-3d-tiles.js","names":["GltfPrimitiveModeString","GLTFLoader","parse","GLTF_PRIMITIVE_MODES","POINTS","LINES","LINE_LOOP","LINE_STRIP","TRIANGLES","TRIANGLE_STRIP","TRIANGLE_FAN","analyzeTileContent","
|
|
1
|
+
{"version":3,"file":"preprocess-3d-tiles.js","names":["GltfPrimitiveModeString","GLTFLoader","parse","GLTF_PRIMITIVE_MODES","POINTS","LINES","LINE_LOOP","LINE_STRIP","TRIANGLES","TRIANGLE_STRIP","TRIANGLE_FAN","analyzeTileContent","tileContent","result","meshTopologyTypes","Set","gltfArrayBuffer","gltfData","gltf","normalize","loadBuffers","loadImages","decompressMeshes","json","meshTypes","getMeshTypesFromGltf","gltfJson","mesh","meshes","primitive","primitives","mode","add","mergePreprocessData","object1","object2","type"],"sources":["../../../../src/i3s-converter/helpers/preprocess-3d-tiles.ts"],"sourcesContent":["import {Tiles3DTileContent} from '@loaders.gl/3d-tiles';\nimport {GltfPrimitiveModeString, PreprocessData} from '../types';\nimport {GLTF, GLTFLoader} from '@loaders.gl/gltf';\nimport {parse} from '@loaders.gl/core';\n\n/**\n * glTF primitive modes\n * @see https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#_mesh_primitive_mode\n */\nexport const GLTF_PRIMITIVE_MODES = [\n GltfPrimitiveModeString.POINTS, // 0\n GltfPrimitiveModeString.LINES, // 1\n GltfPrimitiveModeString.LINE_LOOP, // 2\n GltfPrimitiveModeString.LINE_STRIP, // 3\n GltfPrimitiveModeString.TRIANGLES, // 4\n GltfPrimitiveModeString.TRIANGLE_STRIP, // 5\n GltfPrimitiveModeString.TRIANGLE_FAN // 6\n];\n\n/**\n * Analyze tile content. This function is used during preprocess stage of\n * conversion\n * @param tileContent - 3DTiles tile content ArrayBuffer\n * @returns\n */\nexport const analyzeTileContent = async (\n tileContent: Tiles3DTileContent | null\n): Promise<PreprocessData> => {\n const result: PreprocessData = {\n meshTopologyTypes: new Set()\n };\n if (!tileContent?.gltfArrayBuffer) {\n return result;\n }\n\n const gltfData = await parse(tileContent.gltfArrayBuffer, GLTFLoader, {\n gltf: {normalize: false, loadBuffers: false, loadImages: false, decompressMeshes: false}\n });\n const gltf = gltfData.json;\n\n if (!gltf) {\n return result;\n }\n const meshTypes = getMeshTypesFromGltf(gltf);\n result.meshTopologyTypes = meshTypes;\n return result;\n};\n\n/**\n * Get mesh topology types that the glb content has\n * @param gltfJson - JSON part of GLB content\n * @returns array of mesh types found\n */\nconst getMeshTypesFromGltf = (gltfJson: GLTF): Set<GltfPrimitiveModeString> => {\n const result: Set<GltfPrimitiveModeString> = new Set();\n for (const mesh of gltfJson.meshes || []) {\n for (const primitive of mesh.primitives) {\n let {mode} = primitive;\n if (typeof mode !== 'number') {\n mode = 4; // Default is 4 - TRIANGLES\n }\n result.add(GLTF_PRIMITIVE_MODES[mode]);\n }\n }\n return result;\n};\n\n/**\n * Merge object2 into object1\n * @param object1\n * @param object2\n * @returns nothing\n */\nexport const mergePreprocessData = (object1: PreprocessData, object2: PreprocessData): void => {\n // Merge topology mesh types info\n for (const type of object2.meshTopologyTypes) {\n object1.meshTopologyTypes.add(type);\n }\n};\n"],"mappings":"AACA,SAAQA,uBAAuB,QAAuB,UAAU;AAChE,SAAcC,UAAU,QAAO,kBAAkB;AACjD,SAAQC,KAAK,QAAO,kBAAkB;AAMtC,OAAO,MAAMC,oBAAoB,GAAG,CAClCH,uBAAuB,CAACI,MAAM,EAC9BJ,uBAAuB,CAACK,KAAK,EAC7BL,uBAAuB,CAACM,SAAS,EACjCN,uBAAuB,CAACO,UAAU,EAClCP,uBAAuB,CAACQ,SAAS,EACjCR,uBAAuB,CAACS,cAAc,EACtCT,uBAAuB,CAACU,YAAY,CACrC;AAQD,OAAO,MAAMC,kBAAkB,GAAG,MAChCC,WAAsC,IACV;EAC5B,MAAMC,MAAsB,GAAG;IAC7BC,iBAAiB,EAAE,IAAIC,GAAG,CAAC;EAC7B,CAAC;EACD,IAAI,EAACH,WAAW,aAAXA,WAAW,eAAXA,WAAW,CAAEI,eAAe,GAAE;IACjC,OAAOH,MAAM;EACf;EAEA,MAAMI,QAAQ,GAAG,MAAMf,KAAK,CAACU,WAAW,CAACI,eAAe,EAAEf,UAAU,EAAE;IACpEiB,IAAI,EAAE;MAACC,SAAS,EAAE,KAAK;MAAEC,WAAW,EAAE,KAAK;MAAEC,UAAU,EAAE,KAAK;MAAEC,gBAAgB,EAAE;IAAK;EACzF,CAAC,CAAC;EACF,MAAMJ,IAAI,GAAGD,QAAQ,CAACM,IAAI;EAE1B,IAAI,CAACL,IAAI,EAAE;IACT,OAAOL,MAAM;EACf;EACA,MAAMW,SAAS,GAAGC,oBAAoB,CAACP,IAAI,CAAC;EAC5CL,MAAM,CAACC,iBAAiB,GAAGU,SAAS;EACpC,OAAOX,MAAM;AACf,CAAC;AAOD,MAAMY,oBAAoB,GAAIC,QAAc,IAAmC;EAC7E,MAAMb,MAAoC,GAAG,IAAIE,GAAG,CAAC,CAAC;EACtD,KAAK,MAAMY,IAAI,IAAID,QAAQ,CAACE,MAAM,IAAI,EAAE,EAAE;IACxC,KAAK,MAAMC,SAAS,IAAIF,IAAI,CAACG,UAAU,EAAE;MACvC,IAAI;QAACC;MAAI,CAAC,GAAGF,SAAS;MACtB,IAAI,OAAOE,IAAI,KAAK,QAAQ,EAAE;QAC5BA,IAAI,GAAG,CAAC;MACV;MACAlB,MAAM,CAACmB,GAAG,CAAC7B,oBAAoB,CAAC4B,IAAI,CAAC,CAAC;IACxC;EACF;EACA,OAAOlB,MAAM;AACf,CAAC;AAQD,OAAO,MAAMoB,mBAAmB,GAAGA,CAACC,OAAuB,EAAEC,OAAuB,KAAW;EAE7F,KAAK,MAAMC,IAAI,IAAID,OAAO,CAACrB,iBAAiB,EAAE;IAC5CoB,OAAO,CAACpB,iBAAiB,CAACkB,GAAG,CAACI,IAAI,CAAC;EACrC;AACF,CAAC"}
|
|
@@ -208,7 +208,7 @@ export default class I3SConverter {
|
|
|
208
208
|
loadGLTF: false
|
|
209
209
|
}
|
|
210
210
|
});
|
|
211
|
-
const tilePreprocessData = await analyzeTileContent(
|
|
211
|
+
const tilePreprocessData = await analyzeTileContent(tileContent);
|
|
212
212
|
mergePreprocessData(this.preprocessData, tilePreprocessData);
|
|
213
213
|
return null;
|
|
214
214
|
}
|