@loaders.gl/tile-converter 3.3.0-alpha.8 → 3.4.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3d-tiles-attributes-worker.js +1 -1
- package/dist/converter-cli.js +14 -2
- package/dist/converter.min.js +22 -22
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +8 -0
- package/dist/dist.min.js +1014 -693
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/converter-cli.js +14 -2
- package/dist/es5/converter-cli.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +13 -2
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +16 -7
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +363 -113
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +6 -11
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-index-document.js +517 -0
- package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/node-pages.js +455 -173
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +549 -618
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/geometry-definitions.js +107 -0
- package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
- package/dist/es5/i3s-converter/json-templates/layers.js +2 -93
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/shared-resources.js +3 -3
- package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/es5/i3s-converter/types.js.map +1 -1
- package/dist/es5/lib/utils/file-utils.js +93 -9
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/write-queue.js +38 -25
- package/dist/es5/lib/utils/write-queue.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/workers/i3s-attributes-worker.js +1 -1
- package/dist/es5/workers/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/converter-cli.js +14 -2
- package/dist/esm/converter-cli.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +9 -1
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +16 -7
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +150 -40
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +6 -9
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-index-document.js +202 -0
- package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/node-pages.js +162 -76
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +115 -220
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/geometry-definitions.js +89 -0
- package/dist/esm/i3s-converter/json-templates/geometry-definitions.js.map +1 -0
- package/dist/esm/i3s-converter/json-templates/layers.js +2 -85
- package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/shared-resources.js +3 -3
- package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/esm/i3s-converter/types.js.map +1 -1
- package/dist/esm/lib/utils/file-utils.js +44 -3
- package/dist/esm/lib/utils/file-utils.js.map +1 -1
- package/dist/esm/lib/utils/write-queue.js +19 -10
- package/dist/esm/lib/utils/write-queue.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/workers/i3s-attributes-worker.js +1 -1
- package/dist/esm/workers/i3s-attributes-worker.js.map +1 -1
- package/dist/i3s-attributes-worker.js +2 -2
- package/dist/i3s-attributes-worker.js.map +2 -2
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +3 -3
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +3 -3
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js +16 -10
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +8 -4
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +200 -44
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +2 -3
- package/dist/i3s-converter/helpers/node-index-document.d.ts +95 -0
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-index-document.js +250 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts +78 -43
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +194 -93
- package/dist/i3s-converter/i3s-converter.d.ts +33 -58
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +122 -233
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts +7 -0
- package/dist/i3s-converter/json-templates/geometry-definitions.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/geometry-definitions.js +87 -0
- package/dist/i3s-converter/json-templates/layers.d.ts +1 -30
- package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
- package/dist/i3s-converter/json-templates/layers.js +2 -86
- package/dist/i3s-converter/json-templates/shared-resources.js +3 -3
- package/dist/i3s-converter/types.d.ts +28 -2
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.d.ts +17 -1
- package/dist/lib/utils/file-utils.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.js +64 -7
- package/dist/lib/utils/write-queue.d.ts +18 -2
- package/dist/lib/utils/write-queue.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.js +18 -12
- package/dist/workers/i3s-attributes-worker.js +1 -1
- package/package.json +23 -19
- package/src/converter-cli.ts +22 -2
- package/src/deps-installer/deps-installer.ts +9 -0
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +3 -3
- package/src/i3s-converter/helpers/geometry-attributes.ts +16 -11
- package/src/i3s-converter/helpers/geometry-converter.ts +217 -48
- package/src/i3s-converter/helpers/gltf-attributes.ts +2 -3
- package/src/i3s-converter/helpers/node-index-document.ts +315 -0
- package/src/i3s-converter/helpers/node-pages.ts +215 -110
- package/src/i3s-converter/i3s-converter.ts +170 -312
- package/src/i3s-converter/json-templates/geometry-definitions.ts +83 -0
- package/src/i3s-converter/json-templates/layers.ts +2 -91
- package/src/i3s-converter/json-templates/shared-resources.ts +3 -3
- package/src/i3s-converter/types.ts +29 -2
- package/src/lib/utils/file-utils.ts +62 -7
- package/src/lib/utils/write-queue.ts +36 -15
- package/src/workers/i3s-attributes-worker.ts +2 -1
|
@@ -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","inputType","toUpperCase","tiles3DConverter","inputUrl","tileset","outputPath","output","tilesetName","name","maxDepth","egmFilePath","egm","converter","slpk","sevenZipExe","token","draco","generateTextures","generateBoundingVolumes","validate","mandatoryOptionsWithExceptions","exceptions","mandatoryOption","optionValue","isWrongInputType","Boolean","Object","values","includes","push","forEach","exeption","reduce","acc","curr","equalSignIndex","indexOf","beforeEqual","slice","afterEqual","condition","startsWith","concat","opts","cwd","arg","index","getStringValue","getURLValue","getIntegerValue","getBooleanValue","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 /** 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('--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 generateTextures: options.generateTextures,\n generateBoundingVolumes: options.generateBoundingVolumes,\n validate: options.validate\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 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 '--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 (args[index] === '--no-draco' && !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;AAgD7D,MAAMC,YAAY,GAAG;EACnBC,GAAG,EAAE,KAAK;EACVC,QAAQ,EAAE;AACZ,CAAC;;AAMD,eAAeC,IAAI,GAAG;EACpB,MAAM,IAAK,GAAGC,IAAI,CAAC,GAAGC,OAAO,CAACC,IAAI;EAElC,IAAIF,IAAI,CAACG,MAAM,KAAK,CAAC,EAAE;IACrBC,SAAS,EAAE;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,EAAE;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,EAAE,CAACgB,KAAK,CAAEC,KAAK,IAAK;EACtBC,OAAO,CAACC,GAAG,CAACF,KAAK,CAAC;EAClBf,OAAO,CAACkB,IAAI,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C,IAAI,CAAC,KAAK,CAAC,EAAE;IAC7B,OAAO,EAAE;EACX;EACA,OAAOgB,KAAK;AACd;;AASA,SAASJ,WAAW,CAACF,KAAa,EAAElE,IAAc,EAAU;EAC1D,MAAMwE,KAAK,GAAGL,cAAc,CAACD,KAAK,EAAElE,IAAI,CAAC;EACzCiB,OAAO,CAACC,GAAG,gCAAyBsD,KAAK,EAAG;EAC5CvD,OAAO,CAACC,GAAG,mCAA4BsD,KAAK,CAACC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAG;EACnE,OAAOD,KAAK,CAACC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;AAClC;;AASA,SAASJ,eAAe,CAACH,KAAa,EAAElE,IAAc,EAAU;EAC9D,MAAM0E,WAAmB,GAAGP,cAAc,CAACD,KAAK,EAAElE,IAAI,CAAC;EACvD,MAAM2E,MAAc,GAAGC,MAAM,CAACC,QAAQ,CAACH,WAAW,CAAC;EACnD,IAAII,QAAQ,CAACH,MAAM,CAAC,EAAE;IACpB,OAAOA,MAAM;EACf;EACA,OAAOI,GAAG;AACZ;AAEA,SAAST,eAAe,CAACJ,KAAa,EAAElE,IAAc,EAAW;EAC/D,MAAM0E,WAAmB,GAAGP,cAAc,CAACD,KAAK,EAAElE,IAAI,CAAC,CAACgF,WAAW,EAAE,CAACC,IAAI,EAAE;EAC5E,IAAIjF,IAAI,CAACkE,KAAK,CAAC,KAAK,YAAY,IAAI,CAACQ,WAAW,EAAE;IAChD,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","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","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","concat","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,IAAI,GAAG;EACpB,MAAM,IAAK,GAAGC,IAAI,CAAC,GAAGC,OAAO,CAACC,IAAI;EAElC,IAAIF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,CAACC,GAAG,mCAA4BwD,KAAK,CAACC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,EAAG;EACnE,OAAOD,KAAK,CAACC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;AAClC;;AASA,SAASH,eAAe,CAACJ,KAAa,EAAEpE,IAAc,EAAU;EAC9D,MAAM4E,WAAmB,GAAGP,cAAc,CAACD,KAAK,EAAEpE,IAAI,CAAC;EACvD,MAAM6E,MAAc,GAAGC,MAAM,CAACC,QAAQ,CAACH,WAAW,CAAC;EACnD,IAAII,QAAQ,CAACH,MAAM,CAAC,EAAE;IACpB,OAAOA,MAAM;EACf;EACA,OAAOI,GAAG;AACZ;AAEA,SAASV,eAAe,CAACH,KAAa,EAAEpE,IAAc,EAAW;EAC/D,MAAM4E,WAAmB,GAAGP,cAAc,CAACD,KAAK,EAAEpE,IAAI,CAAC,CAACkF,WAAW,EAAE,CAACC,IAAI,EAAE;EAC5E,IAAI,CAAC,YAAY,EAAE,eAAe,CAAC,CAACjC,QAAQ,CAAClD,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"}
|
|
@@ -2,8 +2,9 @@ import { load, fetchFile } from '@loaders.gl/core';
|
|
|
2
2
|
import { ZipLoader } from '@loaders.gl/zip';
|
|
3
3
|
import { writeFile } from '../lib/utils/file-utils';
|
|
4
4
|
import { join } from 'path';
|
|
5
|
+
import { ChildProcessProxy } from '@loaders.gl/worker-utils';
|
|
5
6
|
|
|
6
|
-
const VERSION = typeof "3.
|
|
7
|
+
const VERSION = typeof "3.4.0-alpha.1" !== 'undefined' ? "3.4.0-alpha.1" : 'beta';
|
|
7
8
|
const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
|
|
8
9
|
|
|
9
10
|
export class DepsInstaller {
|
|
@@ -23,6 +24,13 @@ export class DepsInstaller {
|
|
|
23
24
|
await this.installWorker('draco', 'draco-nodejs-worker.js', workersPath);
|
|
24
25
|
console.log('Installing "Basis Loader worker"');
|
|
25
26
|
await this.installWorker('textures', 'basis-nodejs-worker.js', workersPath);
|
|
27
|
+
console.log('Installing "join-images" npm package');
|
|
28
|
+
const childProcess = new ChildProcessProxy();
|
|
29
|
+
await childProcess.start({
|
|
30
|
+
command: 'npm',
|
|
31
|
+
arguments: ['install', 'sharp', 'join-images'],
|
|
32
|
+
wait: 0
|
|
33
|
+
});
|
|
26
34
|
console.log('All dependencies were installed succesfully.');
|
|
27
35
|
}
|
|
28
36
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deps-installer.js","names":["load","fetchFile","ZipLoader","writeFile","join","VERSION","PGM_LINK","DepsInstaller","install","path","workersPath","console","log","fileMap","depsPath","process","cwd","Uint8Array","installWorker","module","name","extraPath","fileResponse","fileData","arrayBuffer"],"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} from 'path';\n\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';\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 = '', workersPath: 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.installWorker('i3s', 'i3s-content-nodejs-worker.js', workersPath);\n\n console.log('Installing \"Draco Loader worker\"'); // eslint-disable-line no-console\n await this.installWorker('draco', 'draco-nodejs-worker.js', workersPath);\n\n console.log('Installing \"Basis Loader worker\"'); // eslint-disable-line no-console\n await this.installWorker('textures', 'basis-nodejs-worker.js', workersPath);\n\n console.log('All dependencies were installed succesfully.'); // eslint-disable-line no-console\n }\n\n private async installWorker(module: string, name: string, extraPath: string) {\n const fileResponse = await fetchFile(\n `https://unpkg.com/@loaders.gl/${module}@${VERSION}/dist/${name}`\n );\n const fileData = await fileResponse.arrayBuffer();\n if (!fileData) {\n return;\n }\n const path = join(process.cwd(), extraPath, 'modules', module, 'dist');\n await writeFile(path, fileData, name);\n }\n}\n"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,SAAS,QAAO,kBAAkB;AAChD,SAAQC,SAAS,QAAO,iBAAiB;AACzC,SAAQC,SAAS,QAAO,yBAAyB;AACjD,SAAQC,IAAI,QAAO,MAAM;;
|
|
1
|
+
{"version":3,"file":"deps-installer.js","names":["load","fetchFile","ZipLoader","writeFile","join","ChildProcessProxy","VERSION","PGM_LINK","DepsInstaller","install","path","workersPath","console","log","fileMap","depsPath","process","cwd","Uint8Array","installWorker","childProcess","start","command","arguments","wait","module","name","extraPath","fileResponse","fileData","arrayBuffer"],"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} from 'path';\nimport {ChildProcessProxy} from '@loaders.gl/worker-utils';\n\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';\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 = '', workersPath: 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.installWorker('i3s', 'i3s-content-nodejs-worker.js', workersPath);\n\n console.log('Installing \"Draco Loader worker\"'); // eslint-disable-line no-console\n await this.installWorker('draco', 'draco-nodejs-worker.js', workersPath);\n\n console.log('Installing \"Basis Loader worker\"'); // eslint-disable-line no-console\n await this.installWorker('textures', 'basis-nodejs-worker.js', workersPath);\n\n console.log('Installing \"join-images\" npm package');\n const childProcess = new ChildProcessProxy();\n await childProcess.start({\n command: 'npm',\n arguments: ['install', 'sharp', 'join-images'],\n wait: 0\n });\n\n console.log('All dependencies were installed succesfully.'); // eslint-disable-line no-console\n }\n\n private async installWorker(module: string, name: string, extraPath: string) {\n const fileResponse = await fetchFile(\n `https://unpkg.com/@loaders.gl/${module}@${VERSION}/dist/${name}`\n );\n const fileData = await fileResponse.arrayBuffer();\n if (!fileData) {\n return;\n }\n const path = join(process.cwd(), extraPath, 'modules', module, 'dist');\n await writeFile(path, fileData, name);\n }\n}\n"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,SAAS,QAAO,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e,YAAY,CAACC,KAAK,CAAC;MACvBC,OAAO,EAAE,KAAK;MACdC,SAAS,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,CAAC;MAC9CC,IAAI,EAAE;IACR,CAAC,CAAC;IAEFZ,OAAO,CAACC,GAAG,CAAC,8CAA8C,CAAC;EAC7D;;EAEA,MAAcM,aAAa,CAACM,MAAc,EAAEC,IAAY,EAAEC,SAAiB,EAAE;IAC3E,MAAMC,YAAY,GAAG,MAAM3B,SAAS,yCACDwB,MAAM,cAAInB,OAAO,mBAASoB,IAAI,EAChE;IACD,MAAMG,QAAQ,GAAG,MAAMD,YAAY,CAACE,WAAW,EAAE;IACjD,IAAI,CAACD,QAAQ,EAAE;MACb;IACF;IACA,MAAMnB,IAAI,GAAGN,IAAI,CAACY,OAAO,CAACC,GAAG,EAAE,EAAEU,SAAS,EAAE,SAAS,EAAEF,MAAM,EAAE,MAAM,CAAC;IACtE,MAAMtB,SAAS,CAACO,IAAI,EAAEmB,QAAQ,EAAEH,IAAI,CAAC;EACvC;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { processOnWorker } from '@loaders.gl/worker-utils';
|
|
2
2
|
|
|
3
|
-
const VERSION = typeof "3.
|
|
3
|
+
const VERSION = typeof "3.4.0-alpha.1" !== 'undefined' ? "3.4.0-alpha.1" : 'latest';
|
|
4
4
|
export const I3SAttributesWorker = {
|
|
5
5
|
id: 'i3s-attributes',
|
|
6
6
|
name: 'I3S Attributes Worker',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"batch-ids-extensions.js","names":["EXT_MESH_FEATURES","EXT_FEATURE_METADATA","handleBatchIdsExtensions","attributes","primitive","images","extensions","extensionName","extensionData","Object","entries","handleExtFeatureMetadataExtension","console","warn","extFeatureMetadata","featureIdAttribute","featureIdAttributes","featureIds","attribute","batchIdsAttribute","value","hasOwnProperty","featuresCount","POSITIONS","length","generateImplicitFeatureIds","constant","divisor","featureIdTexture","featureIdTextures","textureAttributeIndex","texture","texCoord","textCoordAttribute","textureCoordinates","generateBatchIdsFromTexture","featureTexture","featureTextures","currentValue","devisorCounter","index","push","Array","fill","CHANNELS_MAP","r","g","b","a","textureIndex","featureChannel","channels","undefined","image","batchIds","compressed","u","v","tx","Math","min","emod","width","ty","height","offset","components","batchId","Uint8Array","data","mimeType","n"],"sources":["../../../../src/i3s-converter/helpers/batch-ids-extensions.ts"],"sourcesContent":["import {\n GLTFAccessorPostprocessed,\n GLTFImagePostprocessed,\n GLTFMeshPrimitivePostprocessed\n} from '@loaders.gl/gltf';\nimport type {\n GLTF_EXT_feature_metadata_attribute,\n GLTF_EXT_feature_metadata_primitive\n} from 'modules/gltf/src/lib/types/gltf-json-schema';\n\nconst EXT_MESH_FEATURES = 'EXT_mesh_features';\nconst EXT_FEATURE_METADATA = 'EXT_feature_metadata';\n\n/**\n * Getting batchIds from 3DTilesNext extensions.\n * @param attributes\n * @param primitive\n * @param textures\n */\nexport function handleBatchIdsExtensions(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n primitive: GLTFMeshPrimitivePostprocessed,\n images: GLTFImagePostprocessed[]\n): number[] {\n const extensions = primitive?.extensions;\n\n if (!extensions) {\n return [];\n }\n\n for (const [extensionName, extensionData] of Object.entries(extensions || {})) {\n switch (extensionName) {\n case EXT_FEATURE_METADATA:\n return handleExtFeatureMetadataExtension(\n attributes,\n extensionData as GLTF_EXT_feature_metadata_primitive,\n images\n );\n case EXT_MESH_FEATURES:\n console.warn('EXT_mesh_features extension is not supported yet');\n return [];\n default:\n return [];\n }\n }\n\n return [];\n}\n\n/**\n * Get batchIds from EXT_feature_metadata extension.\n * Docs - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata\n * @param attributes\n * @param extFeatureMetadata\n * @param textures\n */\nfunction handleExtFeatureMetadataExtension(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n extFeatureMetadata: GLTF_EXT_feature_metadata_primitive,\n images: GLTFImagePostprocessed[]\n): number[] {\n // Take only first extension object to get batchIds attribute name.\n const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];\n\n if (featureIdAttribute?.featureIds?.attribute) {\n const batchIdsAttribute = attributes[featureIdAttribute.featureIds.attribute];\n return batchIdsAttribute.value;\n }\n\n if (\n featureIdAttribute?.featureIds?.hasOwnProperty('constant') &&\n featureIdAttribute?.featureIds?.hasOwnProperty('divisor')\n ) {\n const featuresCount = attributes?.POSITIONS?.value.length / 3 || 0;\n return generateImplicitFeatureIds(\n featuresCount,\n featureIdAttribute.featureIds.constant,\n featureIdAttribute.featureIds.divisor\n );\n }\n\n // Take only first extension object to get batchIds attribute name.\n const featureIdTexture =\n extFeatureMetadata?.featureIdTextures && extFeatureMetadata?.featureIdTextures[0];\n\n if (featureIdTexture) {\n const textureAttributeIndex = featureIdTexture?.featureIds?.texture?.texCoord || 0;\n const textCoordAttribute = `TEXCOORD_${textureAttributeIndex}`;\n const textureCoordinates = attributes[textCoordAttribute].value;\n return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);\n }\n\n // Take only first extension texture to get batchIds from the root EXT_feature_metadata object.\n const featureTexture =\n extFeatureMetadata?.featureTextures && extFeatureMetadata?.featureTextures[0];\n\n /**\n * TODO need to get batchIds from root extension\n */\n if (featureTexture) {\n console.warn(\"EXT_feature_metadata doesn't yet support featureTextures in primitive\");\n return [];\n }\n\n return [];\n}\n\n/**\n * Generates implicit feature ids\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#implicit-feature-ids\n * @param featuresCount\n * @param constant\n * @param devisor\n */\nfunction generateImplicitFeatureIds(\n featuresCount: number,\n constant: number = 0,\n divisor: number = 0\n): number[] {\n let featureIds: number[] = [];\n\n if (divisor > 0) {\n let currentValue = constant;\n let devisorCounter = divisor;\n\n for (let index = 0; index < featuresCount; index++) {\n featureIds.push(currentValue);\n\n devisorCounter -= 1;\n\n if (devisorCounter === 0) {\n currentValue++;\n devisorCounter = divisor;\n }\n }\n } else {\n featureIds = Array<number>(featuresCount).fill(constant, 0, featuresCount);\n }\n\n return featureIds;\n}\n\n/**\n * Get batchIds from texture.\n * @param primitive\n * @param featureIdTextures\n */\nfunction generateBatchIdsFromTexture(\n featureIdTexture: GLTF_EXT_feature_metadata_attribute,\n textureCoordinates: Float32Array,\n images: GLTFImagePostprocessed[]\n) {\n if (!images?.length) {\n return [];\n }\n\n const CHANNELS_MAP = {\n r: 0,\n g: 1,\n b: 2,\n a: 3\n };\n\n const textureIndex = featureIdTexture?.featureIds?.texture?.index;\n const featureChannel = featureIdTexture?.featureIds?.channels;\n\n if (!featureChannel || textureIndex === undefined) {\n return [];\n }\n\n const image = images[textureIndex];\n const batchIds: number[] = [];\n const channels = CHANNELS_MAP[featureChannel];\n\n if (!image.compressed) {\n for (let index = 0; index < textureCoordinates.length; index += 2) {\n const u = textureCoordinates[index];\n const v = textureCoordinates[index + 1];\n\n const tx = Math.min((emod(u) * image.width) | 0, image.width - 1);\n const ty = Math.min((emod(v) * image.height) | 0, image.height - 1);\n\n const offset = (ty * image.width + tx) * image.components + channels;\n const batchId = new Uint8Array(image.data)[offset];\n\n batchIds.push(batchId);\n }\n } else {\n console.warn(`Can't get batch Ids from ${image.mimeType} compressed texture`);\n }\n\n return batchIds;\n}\n\n/**\n * Handle UVs if they are out of range [0,1].\n * @param n\n * @param m\n */\nfunction emod(n: number): number {\n return ((n % 1) + 1) % 1;\n}\n"],"mappings":"AAUA,MAAMA,iBAAiB,GAAG,mBAAmB;AAC7C,MAAMC,oBAAoB,GAAG,sBAAsB;;AAQnD,OAAO,SAASC,wBAAwB,CACtCC,UAEC,EACDC,SAAyC,EACzCC,MAAgC,EACtB;EACV,MAAMC,UAAU,GAAGF,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEE,UAAU;EAExC,IAAI,CAACA,UAAU,EAAE;IACf,OAAO,EAAE;EACX;EAEA,KAAK,MAA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;MACjE,MAAMgB,CAAC,GAAGtB,kBAAkB,CAACM,KAAK,CAAC;MACnC,MAAMiB,CAAC,GAAGvB,kBAAkB,CAACM,KAAK,GAAG,CAAC,CAAC;MAEvC,MAAMkB,EAAE,GAAGC,IAAI,CAACC,GAAG,CAAEC,IAAI,CAACL,CAAC,CAAC,GAAGH,KAAK,CAACS,KAAK,GAAI,CAAC,EAAET,KAAK,CAACS,KAAK,GAAG,CAAC,CAAC;MACjE,MAAMC,EAAE,GAAGJ,IAAI,CAACC,GAAG,CAAEC,IAAI,CAACJ,CAAC,CAAC,GAAGJ,KAAK,CAACW,MAAM,GAAI,CAAC,EAAEX,KAAK,CAACW,MAAM,GAAG,CAAC,CAAC;MAEnE,MAAMC,MAAM,GAAG,CAACF,EAAE,GAAGV,KAAK,CAACS,KAAK,GAAGJ,EAAE,IAAIL,KAAK,CAACa,UAAU,GAAGf,QAAQ;MACpE,MAAMgB,OAAO,GAAG,IAAIC,UAAU,CAACf,KAAK,CAACgB,IAAI,CAAC,CAACJ,MAAM,CAAC;MAElDX,QAAQ,CAACb,IAAI,CAAC0B,OAAO,CAAC;IACxB;EACF,CAAC,MAAM;IACLvD,OAAO,CAACC,IAAI,oCAA6BwC,KAAK,CAACiB,QAAQ,yBAAsB;EAC/E;EAEA,OAAOhB,QAAQ;AACjB;;AAOA,SAASO,IAAI,CAACU,CAAS,EAAU;EAC/B,OAAO,CAAEA,CAAC,GAAG,CAAC,GAAI,CAAC,IAAI,CAAC;AAC1B"}
|
|
1
|
+
{"version":3,"file":"batch-ids-extensions.js","names":["EXT_MESH_FEATURES","EXT_FEATURE_METADATA","handleBatchIdsExtensions","attributes","primitive","images","extensions","extensionName","extensionData","Object","entries","handleExtFeatureMetadataExtension","console","warn","extFeatureMetadata","featureIdAttribute","featureIdAttributes","featureIds","attribute","batchIdsAttribute","value","hasOwnProperty","featuresCount","POSITIONS","length","generateImplicitFeatureIds","constant","divisor","featureIdTexture","featureIdTextures","textureAttributeIndex","texture","texCoord","textCoordAttribute","textureCoordinates","generateBatchIdsFromTexture","featureTexture","featureTextures","currentValue","devisorCounter","index","push","Array","fill","CHANNELS_MAP","r","g","b","a","textureIndex","featureChannel","channels","undefined","image","batchIds","compressed","u","v","tx","Math","min","emod","width","ty","height","offset","components","batchId","Uint8Array","data","mimeType","n"],"sources":["../../../../src/i3s-converter/helpers/batch-ids-extensions.ts"],"sourcesContent":["import {\n GLTFAccessorPostprocessed,\n GLTFImagePostprocessed,\n GLTFMeshPrimitivePostprocessed\n} from '@loaders.gl/gltf';\nimport type {\n GLTF_EXT_feature_metadata_attribute,\n GLTF_EXT_feature_metadata_primitive\n} from 'modules/gltf/src/lib/types/gltf-json-schema';\n\nconst EXT_MESH_FEATURES = 'EXT_mesh_features';\nconst EXT_FEATURE_METADATA = 'EXT_feature_metadata';\n\n/**\n * Getting batchIds from 3DTilesNext extensions.\n * @param attributes - gltf accessors\n * @param primitive - gltf primitive data\n * @param images - gltf texture images\n */\nexport function handleBatchIdsExtensions(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n primitive: GLTFMeshPrimitivePostprocessed,\n images: GLTFImagePostprocessed[]\n): number[] {\n const extensions = primitive?.extensions;\n\n if (!extensions) {\n return [];\n }\n\n for (const [extensionName, extensionData] of Object.entries(extensions || {})) {\n switch (extensionName) {\n case EXT_FEATURE_METADATA:\n return handleExtFeatureMetadataExtension(\n attributes,\n extensionData as GLTF_EXT_feature_metadata_primitive,\n images\n );\n case EXT_MESH_FEATURES:\n console.warn('EXT_mesh_features extension is not supported yet');\n return [];\n default:\n return [];\n }\n }\n\n return [];\n}\n\n/**\n * Get batchIds from EXT_feature_metadata extension.\n * Docs - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata\n * @param attributes\n * @param extFeatureMetadata\n * @param textures\n */\nfunction handleExtFeatureMetadataExtension(\n attributes: {\n [key: string]: GLTFAccessorPostprocessed;\n },\n extFeatureMetadata: GLTF_EXT_feature_metadata_primitive,\n images: GLTFImagePostprocessed[]\n): number[] {\n // Take only first extension object to get batchIds attribute name.\n const featureIdAttribute = extFeatureMetadata?.featureIdAttributes?.[0];\n\n if (featureIdAttribute?.featureIds?.attribute) {\n const batchIdsAttribute = attributes[featureIdAttribute.featureIds.attribute];\n return batchIdsAttribute.value;\n }\n\n if (\n featureIdAttribute?.featureIds?.hasOwnProperty('constant') &&\n featureIdAttribute?.featureIds?.hasOwnProperty('divisor')\n ) {\n const featuresCount = attributes?.POSITIONS?.value.length / 3 || 0;\n return generateImplicitFeatureIds(\n featuresCount,\n featureIdAttribute.featureIds.constant,\n featureIdAttribute.featureIds.divisor\n );\n }\n\n // Take only first extension object to get batchIds attribute name.\n const featureIdTexture =\n extFeatureMetadata?.featureIdTextures && extFeatureMetadata?.featureIdTextures[0];\n\n if (featureIdTexture) {\n const textureAttributeIndex = featureIdTexture?.featureIds?.texture?.texCoord || 0;\n const textCoordAttribute = `TEXCOORD_${textureAttributeIndex}`;\n const textureCoordinates = attributes[textCoordAttribute].value;\n return generateBatchIdsFromTexture(featureIdTexture, textureCoordinates, images);\n }\n\n // Take only first extension texture to get batchIds from the root EXT_feature_metadata object.\n const featureTexture =\n extFeatureMetadata?.featureTextures && extFeatureMetadata?.featureTextures[0];\n\n /**\n * TODO need to get batchIds from root extension\n */\n if (featureTexture) {\n console.warn(\"EXT_feature_metadata doesn't yet support featureTextures in primitive\");\n return [];\n }\n\n return [];\n}\n\n/**\n * Generates implicit feature ids\n * Spec - https://github.com/CesiumGS/glTF/tree/3d-tiles-next/extensions/2.0/Vendor/EXT_feature_metadata#implicit-feature-ids\n * @param featuresCount\n * @param constant\n * @param devisor\n */\nfunction generateImplicitFeatureIds(\n featuresCount: number,\n constant: number = 0,\n divisor: number = 0\n): number[] {\n let featureIds: number[] = [];\n\n if (divisor > 0) {\n let currentValue = constant;\n let devisorCounter = divisor;\n\n for (let index = 0; index < featuresCount; index++) {\n featureIds.push(currentValue);\n\n devisorCounter -= 1;\n\n if (devisorCounter === 0) {\n currentValue++;\n devisorCounter = divisor;\n }\n }\n } else {\n featureIds = Array<number>(featuresCount).fill(constant, 0, featuresCount);\n }\n\n return featureIds;\n}\n\n/**\n * Get batchIds from texture.\n * @param primitive\n * @param featureIdTextures\n */\nfunction generateBatchIdsFromTexture(\n featureIdTexture: GLTF_EXT_feature_metadata_attribute,\n textureCoordinates: Float32Array,\n images: GLTFImagePostprocessed[]\n) {\n if (!images?.length) {\n return [];\n }\n\n const CHANNELS_MAP = {\n r: 0,\n g: 1,\n b: 2,\n a: 3\n };\n\n const textureIndex = featureIdTexture?.featureIds?.texture?.index;\n const featureChannel = featureIdTexture?.featureIds?.channels;\n\n if (!featureChannel || textureIndex === undefined) {\n return [];\n }\n\n const image = images[textureIndex];\n const batchIds: number[] = [];\n const channels = CHANNELS_MAP[featureChannel];\n\n if (!image.compressed) {\n for (let index = 0; index < textureCoordinates.length; index += 2) {\n const u = textureCoordinates[index];\n const v = textureCoordinates[index + 1];\n\n const tx = Math.min((emod(u) * image.width) | 0, image.width - 1);\n const ty = Math.min((emod(v) * image.height) | 0, image.height - 1);\n\n const offset = (ty * image.width + tx) * image.components + channels;\n const batchId = new Uint8Array(image.data)[offset];\n\n batchIds.push(batchId);\n }\n } else {\n console.warn(`Can't get batch Ids from ${image.mimeType} compressed texture`);\n }\n\n return batchIds;\n}\n\n/**\n * Handle UVs if they are out of range [0,1].\n * @param n\n * @param m\n */\nfunction emod(n: number): number {\n return ((n % 1) + 1) % 1;\n}\n"],"mappings":"AAUA,MAAMA,iBAAiB,GAAG,mBAAmB;AAC7C,MAAMC,oBAAoB,GAAG,sBAAsB;;AAQnD,OAAO,SAASC,wBAAwB,CACtCC,UAEC,EACDC,SAAyC,EACzCC,MAAgC,EACtB;EACV,MAAMC,UAAU,GAAGF,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEE,UAAU;EAExC,IAAI,CAACA,UAAU,EAAE;IACf,OAAO,EAAE;EACX;EAEA,KAAK,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AAE;MACjE,MAAMgB,CAAC,GAAGtB,kBAAkB,CAACM,KAAK,CAAC;MACnC,MAAMiB,CAAC,GAAGvB,kBAAkB,CAACM,KAAK,GAAG,CAAC,CAAC;MAEvC,MAAMkB,EAAE,GAAGC,IAAI,CAACC,GAAG,CAAEC,IAAI,CAACL,CAAC,CAAC,GAAGH,KAAK,CAACS,KAAK,GAAI,CAAC,EAAET,KAAK,CAACS,KAAK,GAAG,CAAC,CAAC;MACjE,MAAMC,EAAE,GAAGJ,IAAI,CAACC,GAAG,CAAEC,IAAI,CAACJ,CAAC,CAAC,GAAGJ,KAAK,CAACW,MAAM,GAAI,CAAC,EAAEX,KAAK,CAACW,MAAM,GAAG,CAAC,CAAC;MAEnE,MAAMC,MAAM,GAAG,CAACF,EAAE,GAAGV,KAAK,CAACS,KAAK,GAAGJ,EAAE,IAAIL,KAAK,CAACa,UAAU,GAAGf,QAAQ;MACpE,MAAMgB,OAAO,GAAG,IAAIC,UAAU,CAACf,KAAK,CAACgB,IAAI,CAAC,CAACJ,MAAM,CAAC;MAElDX,QAAQ,CAACb,IAAI,CAAC0B,OAAO,CAAC;IACxB;EACF,CAAC,MAAM;IACLvD,OAAO,CAACC,IAAI,oCAA6BwC,KAAK,CAACiB,QAAQ,yBAAsB;EAC/E;EAEA,OAAOhB,QAAQ;AACjB;;AAOA,SAASO,IAAI,CAACU,CAAS,EAAU;EAC/B,OAAO,CAAEA,CAAC,GAAG,CAAC,GAAI,CAAC,IAAI,CAAC;AAC1B"}
|
|
@@ -8,6 +8,7 @@ export function generateAttributes(attributes) {
|
|
|
8
8
|
normals,
|
|
9
9
|
texCoords,
|
|
10
10
|
colors,
|
|
11
|
+
uvRegions,
|
|
11
12
|
featureIndices
|
|
12
13
|
} = attributes;
|
|
13
14
|
const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
@@ -19,7 +20,8 @@ export function generateAttributes(attributes) {
|
|
|
19
20
|
positions,
|
|
20
21
|
normals,
|
|
21
22
|
texCoords,
|
|
22
|
-
colors
|
|
23
|
+
colors,
|
|
24
|
+
uvRegions
|
|
23
25
|
};
|
|
24
26
|
}
|
|
25
27
|
const data = calculateFaceRangesAndFeaturesCount(featureIndices);
|
|
@@ -83,6 +85,7 @@ function makeAttributeObjects(attributes) {
|
|
|
83
85
|
positions,
|
|
84
86
|
normals,
|
|
85
87
|
colors,
|
|
88
|
+
uvRegions,
|
|
86
89
|
texCoords,
|
|
87
90
|
faceRange = new Uint32Array(0)
|
|
88
91
|
} = attributes;
|
|
@@ -91,32 +94,34 @@ function makeAttributeObjects(attributes) {
|
|
|
91
94
|
let normalsList = new Float32Array(normals);
|
|
92
95
|
let colorsList = new Uint8Array(colors);
|
|
93
96
|
let texCoordsList = new Float32Array(texCoords);
|
|
94
|
-
let
|
|
97
|
+
let uvRegionsList = new Uint16Array(uvRegions);
|
|
95
98
|
for (let index = 0; index < featureIds.length; index++) {
|
|
96
|
-
const startIndex = faceRange[index
|
|
97
|
-
const endIndex = faceRange[index
|
|
99
|
+
const startIndex = faceRange[index * 2];
|
|
100
|
+
const endIndex = faceRange[index * 2 + 1];
|
|
98
101
|
const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);
|
|
99
102
|
const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);
|
|
100
103
|
const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);
|
|
104
|
+
const uvRegionsCount = getSliceAttributeCount('uvRegions', startIndex, endIndex);
|
|
101
105
|
const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);
|
|
102
106
|
groupedData.push({
|
|
103
107
|
featureId: featureIds[index],
|
|
104
108
|
positions: positionsList.slice(0, positionsCount),
|
|
105
109
|
normals: normalsList.slice(0, normalsCount),
|
|
106
110
|
colors: colorsList.slice(0, colorsCount),
|
|
111
|
+
uvRegions: uvRegionsList.slice(0, uvRegionsCount),
|
|
107
112
|
texCoords: texCoordsList.slice(0, texCoordsCount)
|
|
108
113
|
});
|
|
109
114
|
positionsList = positionsList.slice(positionsCount);
|
|
110
115
|
normalsList = normalsList.slice(normalsCount);
|
|
111
116
|
colorsList = colorsList.slice(colorsCount);
|
|
117
|
+
uvRegionsList = uvRegionsList.slice(uvRegionsCount);
|
|
112
118
|
texCoordsList = texCoordsList.slice(texCoordsCount);
|
|
113
|
-
faceRangeIndex += 1;
|
|
114
119
|
}
|
|
115
120
|
return groupedData.sort((first, second) => first.featureId - second.featureId);
|
|
116
121
|
}
|
|
117
122
|
|
|
118
123
|
function getSliceAttributeCount(attributeName, startIndex, endIndex) {
|
|
119
|
-
const
|
|
124
|
+
const itemsPerVertex4 = 4;
|
|
120
125
|
const texCoordsPerVertex = 2;
|
|
121
126
|
const trianglesCount = endIndex - startIndex + 1;
|
|
122
127
|
const vertexCount = trianglesCount * 3;
|
|
@@ -125,7 +130,8 @@ function getSliceAttributeCount(attributeName, startIndex, endIndex) {
|
|
|
125
130
|
case 'normals':
|
|
126
131
|
return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;
|
|
127
132
|
case 'colors':
|
|
128
|
-
|
|
133
|
+
case 'uvRegions':
|
|
134
|
+
return vertexCount * itemsPerVertex4;
|
|
129
135
|
case 'texCoords':
|
|
130
136
|
return vertexCount * texCoordsPerVertex;
|
|
131
137
|
default:
|
|
@@ -156,6 +162,7 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
|
|
|
156
162
|
let positions = new Float32Array(firstAttributeObject.positions);
|
|
157
163
|
let normals = new Float32Array(firstAttributeObject.normals);
|
|
158
164
|
let colors = new Uint8Array(firstAttributeObject.colors);
|
|
165
|
+
let uvRegions = new Uint16Array(firstAttributeObject.uvRegions);
|
|
159
166
|
let texCoords = new Float32Array(firstAttributeObject.texCoords);
|
|
160
167
|
const range = [0];
|
|
161
168
|
let objIndex = 0;
|
|
@@ -166,6 +173,7 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
|
|
|
166
173
|
positions = concatenateTypedArrays(positions, currentAttributesObject.positions);
|
|
167
174
|
normals = concatenateTypedArrays(normals, currentAttributesObject.normals);
|
|
168
175
|
colors = concatenateTypedArrays(colors, currentAttributesObject.colors);
|
|
176
|
+
uvRegions = concatenateTypedArrays(uvRegions, currentAttributesObject.uvRegions);
|
|
169
177
|
texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);
|
|
170
178
|
const groupedObject = unifiedObjects[objIndex];
|
|
171
179
|
range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);
|
|
@@ -181,6 +189,7 @@ function groupAttributesAndRangesByFeatureId(unifiedObjects, featureCount) {
|
|
|
181
189
|
positions,
|
|
182
190
|
normals,
|
|
183
191
|
colors,
|
|
192
|
+
uvRegions,
|
|
184
193
|
texCoords,
|
|
185
194
|
featureCount
|
|
186
195
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-attributes.js","names":["concatenateTypedArrays","VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","featureIndices","triangleCount","length","faceRange","Uint32Array","featureIds","featureCount","data","calculateFaceRangesAndFeaturesCount","attributeObjects","makeAttributeObjects","unifiedAttributeObjectsByFeatureIds","unifyObjectsByFeatureId","groupedAttributes","groupAttributesAndRangesByFeatureId","rangeIndex","featureIndex","currentFeatureId","getFrequentValue","slice","faceRangeList","uniqueFeatureIds","index","newFeatureId","includes","push","values","map","mostFrequentValue","maxCount","value","groupedData","positionsList","Float32Array","normalsList","colorsList","Uint8Array","texCoordsList","faceRangeIndex","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","texCoordsCount","featureId","sort","first","second","attributeName","colorsPerVertex","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","uniqueObjects","currentObject","existedObject","find","obj","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject"],"sources":["../../../../src/i3s-converter/helpers/geometry-attributes.ts"],"sourcesContent":["import type {GeometryAttributes, ConvertedAttributes, GroupedByFeatureIdAttributes} from '../types';\nimport {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nconst VALUES_PER_VERTEX = 3;\nconst POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;\n\n/**\n * Generate geometry attributes with faceRange and featureCount\n * @param attributes\n * @returns attirbutes with featureCount, featureIds and changed faceRange.\n */\nexport function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes {\n const {positions, normals, texCoords, colors, featureIndices} = attributes;\n const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n\n if (!featureIndices.length) {\n return {\n faceRange: new Uint32Array([0, triangleCount - 1]),\n featureIds: [0],\n featureCount: 1,\n positions,\n normals,\n texCoords,\n colors\n };\n }\n\n const data = calculateFaceRangesAndFeaturesCount(featureIndices);\n const attributeObjects = makeAttributeObjects({...data, ...attributes});\n const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);\n const groupedAttributes = groupAttributesAndRangesByFeatureId(\n unifiedAttributeObjectsByFeatureIds,\n data.featureCount\n );\n return groupedAttributes;\n}\n\n/**\n * Calculates face Ranges and feature count based on featureIndices.\n * @param featureIndices\n * @returns Object with featureCount, reordered attributes and changed faceRange.\n */\nfunction calculateFaceRangesAndFeaturesCount(featureIndices: number[]): {\n faceRange: Uint32Array;\n featureCount: number;\n featureIds: number[];\n} {\n let rangeIndex = 1;\n let featureIndex = 1;\n let currentFeatureId = getFrequentValue(featureIndices.slice(0, VALUES_PER_VERTEX));\n const faceRangeList: any[] = [];\n const featureIds: any[] = [];\n const uniqueFeatureIds = [currentFeatureId];\n\n faceRangeList[0] = 0;\n featureIds[0] = currentFeatureId;\n\n for (let index = VALUES_PER_VERTEX; index < featureIndices.length; index += VALUES_PER_VERTEX) {\n const newFeatureId = getFrequentValue(featureIndices.slice(index, index + VALUES_PER_VERTEX));\n if (currentFeatureId !== newFeatureId) {\n faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;\n faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;\n featureIds[featureIndex] = newFeatureId;\n\n if (!uniqueFeatureIds.includes(newFeatureId)) {\n uniqueFeatureIds.push(newFeatureId);\n }\n\n rangeIndex += 2;\n featureIndex += 1;\n }\n currentFeatureId = newFeatureId;\n }\n\n faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;\n\n const faceRange = new Uint32Array(faceRangeList);\n const featureCount = uniqueFeatureIds.length;\n\n return {faceRange, featureCount, featureIds};\n}\n\n/**\n * Find most frequent value to avoid situation where one vertex can be part of multiple features (objects).\n * @param values\n */\nfunction getFrequentValue(values: number[]): number {\n const map: {[key: number]: number} = {};\n\n let mostFrequentValue = values[0];\n let maxCount = 1;\n\n for (const value of values) {\n // Save item and it's frequency count to the map.\n map[value] = (map[value] || 0) + 1;\n // Find max count of frequency.\n maxCount = maxCount > map[value] ? maxCount : map[value];\n // Find the most frequent value.\n mostFrequentValue = maxCount > map[value] ? mostFrequentValue : value;\n }\n\n return mostFrequentValue;\n}\n\n/**\n * Generate list of attribute object grouped by feature ids.\n * @param attributes\n * @returns sorted list of attribute objects.\n */\nfunction makeAttributeObjects(attributes: GeometryAttributes): GroupedByFeatureIdAttributes[] {\n const {\n featureIds,\n positions,\n normals,\n colors,\n texCoords,\n faceRange = new Uint32Array(0)\n } = attributes;\n const groupedData: GroupedByFeatureIdAttributes[] = [];\n\n let positionsList = new Float32Array(positions);\n let normalsList = new Float32Array(normals);\n let colorsList = new Uint8Array(colors);\n let texCoordsList = new Float32Array(texCoords);\n\n let faceRangeIndex = 0;\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index + faceRangeIndex];\n const endIndex = faceRange[index + faceRangeIndex + 1];\n\n const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);\n const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);\n const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);\n const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);\n\n groupedData.push({\n featureId: featureIds[index],\n positions: positionsList.slice(0, positionsCount),\n normals: normalsList.slice(0, normalsCount),\n colors: colorsList.slice(0, colorsCount),\n texCoords: texCoordsList.slice(0, texCoordsCount)\n });\n\n positionsList = positionsList.slice(positionsCount);\n normalsList = normalsList.slice(normalsCount);\n colorsList = colorsList.slice(colorsCount);\n texCoordsList = texCoordsList.slice(texCoordsCount);\n\n faceRangeIndex += 1;\n }\n\n return groupedData.sort((first, second) => first.featureId - second.featureId);\n}\n\n/**\n * Generate sliced count for generating attribute objects depends on attribute name and range.\n * @param attributeName\n * @param startIndex\n * @param endIndex\n * @returns sliced count\n */\nfunction getSliceAttributeCount(\n attributeName: string,\n startIndex: number,\n endIndex: number\n): number {\n const colorsPerVertex = 4;\n const texCoordsPerVertex = 2;\n\n const trianglesCount = endIndex - startIndex + 1;\n const vertexCount = trianglesCount * 3;\n\n switch (attributeName) {\n case 'positions':\n case 'normals':\n return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;\n case 'colors':\n return vertexCount * colorsPerVertex;\n case 'texCoords':\n return vertexCount * texCoordsPerVertex;\n default:\n return 0;\n }\n}\n\n/**\n * Generates unique object list depends on feature ids and concantenate their attributes.\n * @param sortedData\n * @returns unique list of objects\n */\nfunction unifyObjectsByFeatureId(\n sortedData: GroupedByFeatureIdAttributes[]\n): GroupedByFeatureIdAttributes[] {\n const uniqueObjects: GroupedByFeatureIdAttributes[] = [];\n\n for (let index = 0; index < sortedData.length; index++) {\n const currentObject = sortedData[index];\n const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);\n\n if (existedObject) {\n existedObject.positions = concatenateTypedArrays(\n existedObject.positions,\n currentObject.positions\n );\n existedObject.normals = concatenateTypedArrays(existedObject.normals, currentObject.normals);\n existedObject.colors = concatenateTypedArrays(existedObject.colors, currentObject.colors);\n existedObject.texCoords = concatenateTypedArrays(\n existedObject.texCoords,\n currentObject.texCoords\n );\n } else {\n uniqueObjects.push(currentObject);\n }\n }\n\n return uniqueObjects;\n}\n\n/**\n * Generates attribute objects with new faceRange and reordered attributes.\n * @param unifiedObjects\n * @returns generated attributes with new faceRange.\n */\nfunction groupAttributesAndRangesByFeatureId(\n unifiedObjects: GroupedByFeatureIdAttributes[],\n featureCount: number\n): GeometryAttributes {\n const firstAttributeObject = unifiedObjects[0];\n const featureIds = [firstAttributeObject.featureId || 0];\n\n let positions = new Float32Array(firstAttributeObject.positions);\n let normals = new Float32Array(firstAttributeObject.normals);\n let colors = new Uint8Array(firstAttributeObject.colors);\n let texCoords = new Float32Array(firstAttributeObject.texCoords);\n const range = [0];\n\n let objIndex = 0;\n let sum = 0;\n\n for (let index = 1; index < unifiedObjects.length; index++) {\n const currentAttributesObject = unifiedObjects[index];\n featureIds.push(currentAttributesObject.featureId || 0);\n\n positions = concatenateTypedArrays(positions, currentAttributesObject.positions);\n normals = concatenateTypedArrays(normals, currentAttributesObject.normals);\n colors = concatenateTypedArrays(colors, currentAttributesObject.colors);\n texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);\n\n const groupedObject = unifiedObjects[objIndex];\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);\n\n sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n objIndex += 1;\n }\n\n range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);\n\n const faceRange = new Uint32Array(range);\n return {faceRange, featureIds, positions, normals, colors, texCoords, featureCount};\n}\n"],"mappings":"AACA,SAAQA,sBAAsB,QAAO,0BAA0B;AAE/D,MAAMC,iBAAiB,GAAG,CAAC;AAC3B,MAAMC,kCAAkC,GAAG,CAAC;;AAO5C,OAAO,SAASC,kBAAkB,CAACC,UAA+B,EAAsB;EACtF,MAAM;IAACC,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AAK,CAACtC,IAAI,CAAC7B,SAAS,CAACM,MAAM,GAAGT,kCAAkC,GAAG,CAAC,CAAC;EAErE,MAAMU,SAAS,GAAG,IAAIC,WAAW,CAAC2D,KAAK,CAAC;EACxC,OAAO;IAAC5D,SAAS;IAAEE,UAAU;IAAET,SAAS;IAAEC,OAAO;IAAEE,MAAM;IAAED,SAAS;IAAEQ;EAAY,CAAC;AACrF"}
|
|
1
|
+
{"version":3,"file":"geometry-attributes.js","names":["concatenateTypedArrays","VALUES_PER_VERTEX","POSITIONS_AND_NORMALS_PER_TRIANGLE","generateAttributes","attributes","positions","normals","texCoords","colors","uvRegions","featureIndices","triangleCount","length","faceRange","Uint32Array","featureIds","featureCount","data","calculateFaceRangesAndFeaturesCount","attributeObjects","makeAttributeObjects","unifiedAttributeObjectsByFeatureIds","unifyObjectsByFeatureId","groupedAttributes","groupAttributesAndRangesByFeatureId","rangeIndex","featureIndex","currentFeatureId","getFrequentValue","slice","faceRangeList","uniqueFeatureIds","index","newFeatureId","includes","push","values","map","mostFrequentValue","maxCount","value","groupedData","positionsList","Float32Array","normalsList","colorsList","Uint8Array","texCoordsList","uvRegionsList","Uint16Array","startIndex","endIndex","positionsCount","getSliceAttributeCount","normalsCount","colorsCount","uvRegionsCount","texCoordsCount","featureId","sort","first","second","attributeName","itemsPerVertex4","texCoordsPerVertex","trianglesCount","vertexCount","sortedData","uniqueObjects","currentObject","existedObject","find","obj","unifiedObjects","firstAttributeObject","range","objIndex","sum","currentAttributesObject","groupedObject"],"sources":["../../../../src/i3s-converter/helpers/geometry-attributes.ts"],"sourcesContent":["import type {GeometryAttributes, ConvertedAttributes, GroupedByFeatureIdAttributes} from '../types';\nimport {concatenateTypedArrays} from '@loaders.gl/loader-utils';\n\nconst VALUES_PER_VERTEX = 3;\nconst POSITIONS_AND_NORMALS_PER_TRIANGLE = 9;\n\n/**\n * Generate geometry attributes with faceRange and featureCount\n * @param attributes\n * @returns attirbutes with featureCount, featureIds and changed faceRange.\n */\nexport function generateAttributes(attributes: ConvertedAttributes): GeometryAttributes {\n const {positions, normals, texCoords, colors, uvRegions, featureIndices} = attributes;\n const triangleCount = positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n\n if (!featureIndices.length) {\n return {\n faceRange: new Uint32Array([0, triangleCount - 1]),\n featureIds: [0],\n featureCount: 1,\n positions,\n normals,\n texCoords,\n colors,\n uvRegions\n };\n }\n\n const data = calculateFaceRangesAndFeaturesCount(featureIndices);\n const attributeObjects = makeAttributeObjects({...data, ...attributes});\n const unifiedAttributeObjectsByFeatureIds = unifyObjectsByFeatureId(attributeObjects);\n const groupedAttributes = groupAttributesAndRangesByFeatureId(\n unifiedAttributeObjectsByFeatureIds,\n data.featureCount\n );\n return groupedAttributes;\n}\n\n/**\n * Calculates face Ranges and feature count based on featureIndices.\n * @param featureIndices\n * @returns Object with featureCount, reordered attributes and changed faceRange.\n */\nfunction calculateFaceRangesAndFeaturesCount(featureIndices: number[]): {\n faceRange: Uint32Array;\n featureCount: number;\n featureIds: number[];\n} {\n let rangeIndex = 1;\n let featureIndex = 1;\n let currentFeatureId = getFrequentValue(featureIndices.slice(0, VALUES_PER_VERTEX));\n const faceRangeList: any[] = [];\n const featureIds: any[] = [];\n const uniqueFeatureIds = [currentFeatureId];\n\n faceRangeList[0] = 0;\n featureIds[0] = currentFeatureId;\n\n for (let index = VALUES_PER_VERTEX; index < featureIndices.length; index += VALUES_PER_VERTEX) {\n const newFeatureId = getFrequentValue(featureIndices.slice(index, index + VALUES_PER_VERTEX));\n if (currentFeatureId !== newFeatureId) {\n faceRangeList[rangeIndex] = index / VALUES_PER_VERTEX - 1;\n faceRangeList[rangeIndex + 1] = index / VALUES_PER_VERTEX;\n featureIds[featureIndex] = newFeatureId;\n\n if (!uniqueFeatureIds.includes(newFeatureId)) {\n uniqueFeatureIds.push(newFeatureId);\n }\n\n rangeIndex += 2;\n featureIndex += 1;\n }\n currentFeatureId = newFeatureId;\n }\n\n faceRangeList[rangeIndex] = featureIndices.length / VALUES_PER_VERTEX - 1;\n\n const faceRange = new Uint32Array(faceRangeList);\n const featureCount = uniqueFeatureIds.length;\n\n return {faceRange, featureCount, featureIds};\n}\n\n/**\n * Find most frequent value to avoid situation where one vertex can be part of multiple features (objects).\n * @param values\n */\nfunction getFrequentValue(values: number[]): number {\n const map: {[key: number]: number} = {};\n\n let mostFrequentValue = values[0];\n let maxCount = 1;\n\n for (const value of values) {\n // Save item and it's frequency count to the map.\n map[value] = (map[value] || 0) + 1;\n // Find max count of frequency.\n maxCount = maxCount > map[value] ? maxCount : map[value];\n // Find the most frequent value.\n mostFrequentValue = maxCount > map[value] ? mostFrequentValue : value;\n }\n\n return mostFrequentValue;\n}\n\n/**\n * Generate list of attribute object grouped by feature ids.\n * @param attributes\n * @returns sorted list of attribute objects.\n */\nfunction makeAttributeObjects(attributes: GeometryAttributes): GroupedByFeatureIdAttributes[] {\n const {\n featureIds,\n positions,\n normals,\n colors,\n uvRegions,\n texCoords,\n faceRange = new Uint32Array(0)\n } = attributes;\n const groupedData: GroupedByFeatureIdAttributes[] = [];\n\n let positionsList = new Float32Array(positions);\n let normalsList = new Float32Array(normals);\n let colorsList = new Uint8Array(colors);\n let texCoordsList = new Float32Array(texCoords);\n let uvRegionsList = new Uint16Array(uvRegions);\n\n for (let index = 0; index < featureIds.length; index++) {\n const startIndex = faceRange[index * 2];\n const endIndex = faceRange[index * 2 + 1];\n\n const positionsCount = getSliceAttributeCount('positions', startIndex, endIndex);\n const normalsCount = getSliceAttributeCount('normals', startIndex, endIndex);\n const colorsCount = getSliceAttributeCount('colors', startIndex, endIndex);\n const uvRegionsCount = getSliceAttributeCount('uvRegions', startIndex, endIndex);\n const texCoordsCount = getSliceAttributeCount('texCoords', startIndex, endIndex);\n\n groupedData.push({\n featureId: featureIds[index],\n positions: positionsList.slice(0, positionsCount),\n normals: normalsList.slice(0, normalsCount),\n colors: colorsList.slice(0, colorsCount),\n uvRegions: uvRegionsList.slice(0, uvRegionsCount),\n texCoords: texCoordsList.slice(0, texCoordsCount)\n });\n\n positionsList = positionsList.slice(positionsCount);\n normalsList = normalsList.slice(normalsCount);\n colorsList = colorsList.slice(colorsCount);\n uvRegionsList = uvRegionsList.slice(uvRegionsCount);\n texCoordsList = texCoordsList.slice(texCoordsCount);\n }\n\n return groupedData.sort((first, second) => first.featureId - second.featureId);\n}\n\n/**\n * Generate sliced count for generating attribute objects depends on attribute name and range.\n * @param attributeName\n * @param startIndex\n * @param endIndex\n * @returns sliced count\n */\nfunction getSliceAttributeCount(\n attributeName: string,\n startIndex: number,\n endIndex: number\n): number {\n const itemsPerVertex4 = 4;\n const texCoordsPerVertex = 2;\n\n const trianglesCount = endIndex - startIndex + 1;\n const vertexCount = trianglesCount * 3;\n\n switch (attributeName) {\n case 'positions':\n case 'normals':\n return trianglesCount * POSITIONS_AND_NORMALS_PER_TRIANGLE;\n case 'colors':\n case 'uvRegions':\n return vertexCount * itemsPerVertex4;\n case 'texCoords':\n return vertexCount * texCoordsPerVertex;\n default:\n return 0;\n }\n}\n\n/**\n * Generates unique object list depends on feature ids and concantenate their attributes.\n * @param sortedData\n * @returns unique list of objects\n */\nfunction unifyObjectsByFeatureId(\n sortedData: GroupedByFeatureIdAttributes[]\n): GroupedByFeatureIdAttributes[] {\n const uniqueObjects: GroupedByFeatureIdAttributes[] = [];\n\n for (let index = 0; index < sortedData.length; index++) {\n const currentObject = sortedData[index];\n const existedObject = uniqueObjects.find((obj) => obj.featureId === currentObject.featureId);\n\n if (existedObject) {\n existedObject.positions = concatenateTypedArrays(\n existedObject.positions,\n currentObject.positions\n );\n existedObject.normals = concatenateTypedArrays(existedObject.normals, currentObject.normals);\n existedObject.colors = concatenateTypedArrays(existedObject.colors, currentObject.colors);\n existedObject.texCoords = concatenateTypedArrays(\n existedObject.texCoords,\n currentObject.texCoords\n );\n } else {\n uniqueObjects.push(currentObject);\n }\n }\n\n return uniqueObjects;\n}\n\n/**\n * Generates attribute objects with new faceRange and reordered attributes.\n * @param unifiedObjects\n * @returns generated attributes with new faceRange.\n */\nfunction groupAttributesAndRangesByFeatureId(\n unifiedObjects: GroupedByFeatureIdAttributes[],\n featureCount: number\n): GeometryAttributes {\n const firstAttributeObject = unifiedObjects[0];\n const featureIds = [firstAttributeObject.featureId || 0];\n\n let positions = new Float32Array(firstAttributeObject.positions);\n let normals = new Float32Array(firstAttributeObject.normals);\n let colors = new Uint8Array(firstAttributeObject.colors);\n let uvRegions = new Uint16Array(firstAttributeObject.uvRegions);\n let texCoords = new Float32Array(firstAttributeObject.texCoords);\n const range = [0];\n\n let objIndex = 0;\n let sum = 0;\n\n for (let index = 1; index < unifiedObjects.length; index++) {\n const currentAttributesObject = unifiedObjects[index];\n featureIds.push(currentAttributesObject.featureId || 0);\n\n positions = concatenateTypedArrays(positions, currentAttributesObject.positions);\n normals = concatenateTypedArrays(normals, currentAttributesObject.normals);\n colors = concatenateTypedArrays(colors, currentAttributesObject.colors);\n uvRegions = concatenateTypedArrays(uvRegions, currentAttributesObject.uvRegions);\n texCoords = concatenateTypedArrays(texCoords, currentAttributesObject.texCoords);\n\n const groupedObject = unifiedObjects[objIndex];\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1 + sum);\n range.push(groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE + sum);\n\n sum += groupedObject.positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE;\n objIndex += 1;\n }\n\n range.push(positions.length / POSITIONS_AND_NORMALS_PER_TRIANGLE - 1);\n\n const faceRange = new Uint32Array(range);\n return {faceRange, featureIds, positions, normals, colors, uvRegions, texCoords, featureCount};\n}\n"],"mappings":"AACA,SAAQA,sBAAsB,QAAO,0BAA0B;AAE/D,MAAMC,iBAAiB,GAAG,CAAC;AAC3B,MAAMC,kCAAkC,GAAG,CAAC;;AAO5C,OAAO,SAASC,kBAAkB,CAACC,UAA+B,EAAsB;EACtF,MAAM;IAACC,SAAS;IAAEC,OAAO;IAAEC,SAAS;I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