@loaders.gl/tile-converter 3.1.0-beta.7 → 3.1.3
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/converter.min.js +20 -20
- package/dist/{bundle.js → dist.min.js} +2228 -1482
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +429 -189
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +306 -209
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +8 -4
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +13 -13
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js +51 -32
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +61 -17
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +55 -16
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +33 -9
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +103 -93
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.d.ts +5 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +547 -336
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-debug.js +27 -31
- package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-pages.js +209 -101
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +1645 -700
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/layers.js +213 -177
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/metadata.js +24 -20
- package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/node.js +92 -74
- package/dist/es5/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/scene-server.js +34 -28
- package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/shared-resources.js +162 -107
- package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/store.js +4 -2
- package/dist/es5/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/es5/i3s-converter/types.js +2 -0
- package/dist/es5/i3s-converter/types.js.map +1 -0
- package/dist/es5/i3s-server/app.js +6 -6
- package/dist/es5/i3s-server/app.js.map +1 -1
- package/dist/es5/i3s-server/controllers/index-controller.js +60 -20
- package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/es5/i3s-server/routes/index.js +41 -14
- package/dist/es5/i3s-server/routes/index.js.map +1 -1
- package/dist/es5/index.js +4 -4
- package/dist/es5/lib/utils/{compress-utils.d.ts → compress-util.d.ts} +0 -0
- package/dist/es5/lib/utils/compress-util.js +345 -123
- package/dist/es5/lib/utils/compress-util.js.map +1 -1
- package/dist/es5/lib/utils/file-utils.js +98 -20
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js +9 -9
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/lib/utils/statistic-utills.js +152 -41
- package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
- package/dist/es5/pgm-loader.js +31 -4
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +7 -6
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +7 -0
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +1 -1
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/esm/3d-tiles-converter/json-templates/tileset.js +12 -9
- package/dist/esm/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +2 -6
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js +35 -3
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js +2 -2
- package/dist/esm/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +5 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +50 -16
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-debug.js +2 -4
- package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-pages.js +15 -4
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +147 -62
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/layers.js +37 -27
- package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/metadata.js +2 -2
- package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/node.js +16 -12
- package/dist/esm/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/scene-server.js +2 -2
- package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/shared-resources.js +19 -14
- package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/esm/i3s-converter/types.js +2 -0
- package/dist/esm/i3s-converter/types.js.map +1 -0
- package/dist/esm/lib/utils/{compress-utils.d.ts → compress-util.d.ts} +0 -0
- package/dist/esm/pgm-loader.js +3 -3
- package/dist/esm/pgm-loader.js.map +1 -1
- package/package.json +17 -15
- package/src/3d-tiles-converter/3d-tiles-converter.ts +21 -20
- package/src/3d-tiles-converter/helpers/{b3dm-converter.js → b3dm-converter.ts} +19 -2
- package/src/3d-tiles-converter/helpers/{i3s-obb-to-3d-tiles-obb.js → i3s-obb-to-3d-tiles-obb.ts} +16 -1
- package/src/3d-tiles-converter/helpers/texture-atlas.ts +4 -4
- package/src/3d-tiles-converter/json-templates/{tileset.js → tileset.ts} +9 -9
- package/src/deps-installer/deps-installer.js +2 -2
- package/src/i3s-converter/helpers/coordinate-converter.ts +62 -9
- package/src/i3s-converter/helpers/{create-scene-server-path.js → create-scene-server-path.ts} +2 -2
- package/src/i3s-converter/helpers/{geometry-attributes.js → geometry-attributes.ts} +4 -4
- package/src/i3s-converter/helpers/geometry-converter.d.ts +5 -1
- package/src/i3s-converter/helpers/geometry-converter.js +63 -13
- package/src/i3s-converter/helpers/{node-debug.js → node-debug.ts} +3 -2
- package/src/i3s-converter/helpers/{node-pages.js → node-pages.ts} +41 -26
- package/src/i3s-converter/i3s-converter.ts +204 -133
- package/src/i3s-converter/json-templates/{layers.js → layers.ts} +29 -27
- package/src/i3s-converter/json-templates/{metadata.js → metadata.ts} +2 -2
- package/src/i3s-converter/json-templates/{node.js → node.ts} +12 -12
- package/src/i3s-converter/json-templates/{scene-server.js → scene-server.ts} +2 -2
- package/src/i3s-converter/json-templates/{shared-resources.js → shared-resources.ts} +14 -14
- package/src/i3s-converter/json-templates/{store.js → store.ts} +0 -0
- package/src/i3s-converter/types.ts +14 -0
- package/src/lib/utils/{compress-utils.d.ts → compress-util.d.ts} +0 -0
- package/src/pgm-loader.ts +2 -2
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -23
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -16
- package/dist/es5/i3s-converter/helpers/node-pages.d.ts +0 -144
- package/dist/es5/lib/geoid-height-model.d.ts +0 -41
- package/dist/es5/lib/geoid-height-model.js +0 -149
- package/dist/es5/lib/geoid-height-model.js.map +0 -1
- package/dist/es5/lib/pgm-parser.d.ts +0 -14
- package/dist/es5/lib/pgm-parser.js +0 -192
- package/dist/es5/lib/pgm-parser.js.map +0 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -23
- package/dist/esm/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -16
- package/dist/esm/i3s-converter/helpers/node-pages.d.ts +0 -144
- package/dist/esm/lib/geoid-height-model.d.ts +0 -41
- package/dist/esm/lib/geoid-height-model.js +0 -140
- package/dist/esm/lib/geoid-height-model.js.map +0 -1
- package/dist/esm/lib/pgm-parser.d.ts +0 -14
- package/dist/esm/lib/pgm-parser.js +0 -183
- package/dist/esm/lib/pgm-parser.js.map +0 -1
- package/src/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -23
- package/src/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +0 -16
- package/src/i3s-converter/helpers/node-pages.d.ts +0 -144
- package/src/lib/geoid-height-model.d.ts +0 -41
- package/src/lib/geoid-height-model.js +0 -239
- package/src/lib/pgm-parser.d.ts +0 -14
- package/src/lib/pgm-parser.js +0 -179
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/i3s-converter/helpers/node-pages.js"],"names":["join","transform","METADATA","metadataTemplate","NodePages","constructor","writeFileFunc","nodesPerPage","nodesCounter","nodePages","nodes","writeFile","useWriteFunction","func","getNodeById","id","pageIndex","Math","floor","nodeIndex","updateMaterialByNodeId","materialId","node","mesh","material","definition","resource","index","updateVertexCountByNodeId","vertexCount","geometry","updateNodeAttributeByNodeId","attribute","updateFeatureCountByNodeId","featureCount","updateTexelCountHintByNodeId","texelCountHint","addChildRelation","parentId","childId","parentNode","children","push","updateResourceInMesh","currentNodePage","length","save","layers0Path","fileMap","slpk","promises","nodePage","entries","nodePageStr","JSON","stringify","slpkPath","toString","metadata","nodeCount","compress","nodePagePath","Promise","all"],"mappings":"AAAA,SAAQA,IAAR,QAAmB,MAAnB;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,SAAQC,QAAQ,IAAIC,gBAApB,QAA2C,4BAA3C;AAkCA,eAAe,MAAMC,SAAN,CAAgB;AAO7BC,EAAAA,WAAW,CAACC,aAAD,EAAgBC,YAAhB,EAA8B;AACvC,SAAKA,YAAL,GAAoBA,YAApB;AACA,SAAKC,YAAL,GAAoB,CAApB;AACA,SAAKC,SAAL,GAAiB,CAAC,EAAD,CAAjB;AACA,SAAKA,SAAL,CAAe,CAAf,EAAkBC,KAAlB,GAA0B,EAA1B;AACA,SAAKC,SAAL,GAAiBL,aAAjB;AACD;;AAEDM,EAAAA,gBAAgB,CAACC,IAAD,EAAO;AACrB,SAAKF,SAAL,GAAiBE,IAAjB;AACD;;AAODC,EAAAA,WAAW,CAACC,EAAD,EAAK;AACd,UAAMC,SAAS,GAAGC,IAAI,CAACC,KAAL,CAAWH,EAAE,GAAG,KAAKR,YAArB,CAAlB;AACA,UAAMY,SAAS,GAAGJ,EAAE,GAAG,KAAKR,YAA5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AAQ,CAACR,IAAT,CAAc,KAAK/B,SAAL,CAAekD,YAAf,EAA6BR,WAA7B,CAAd;AACD;AACF;;AAED,UAAMS,OAAO,CAACC,GAAR,CAAYb,QAAZ,CAAN;AACD;;AA1K4B","sourcesContent":["import {join} from 'path';\nimport transform from 'json-map-transform';\nimport {METADATA as metadataTemplate} from '../json-templates/metadata';\n\n/**\n * class NodePages - wrapper of nodePages array\n *\n * @example\n * import {writeFile} from './helpers/write-file';\n *\n * // create an instance of the class\n * const nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);\n * ...\n * // push root node\n * const parentId = nodePages.push({\n lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,\n obb: coordinates.obb,\n children: []\n });\n * ...\n * // push node with parent relation\n * const nodeInPage = {\n lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,\n obb: coordinates.obb,\n children: [],\n mesh: {\n geometry: {\n definition: 0\n }\n }\n };\n * const nodeId = this.nodePages.push(nodeInPage, parentId);\n * ...\n * // save all the nodePages in the end of pushing all the nodes\n * await this.nodePages.save(layers0path);\n */\nexport default class NodePages {\n /**\n * @constructs\n * Create a nodePages instance.\n * @param writeFileFunc - function to save one nodePage into a file\n * @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met\n */\n constructor(writeFileFunc, nodesPerPage) {\n this.nodesPerPage = nodesPerPage;\n this.nodesCounter = 0;\n this.nodePages = [{}];\n this.nodePages[0].nodes = [];\n this.writeFile = writeFileFunc;\n }\n\n useWriteFunction(func) {\n this.writeFile = func;\n }\n\n /**\n * Get the node by its end-to-end index\n * @param {number} id - end-to-end index of the node\n * @return {object} the node object\n */\n getNodeById(id) {\n const pageIndex = Math.floor(id / this.nodesPerPage);\n const nodeIndex = id % this.nodesPerPage;\n return this.nodePages[pageIndex].nodes[nodeIndex];\n }\n\n /**\n * Update material in node.mesh object by node id\n * @param id - end-to-end index of the node\n * @param materialId - id from scene layer materialDefinitions\n */\n updateMaterialByNodeId(id, materialId) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.material = {\n definition: materialId,\n resource: node.index\n };\n }\n\n /**\n * Update vertexCount in node.mesh.geometry object by node id\n * @param id - end-to-end index of the node\n * @param vertexCount - vertex count for particular node\n */\n updateVertexCountByNodeId(id, vertexCount) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.vertexCount = vertexCount;\n }\n\n /**\n * Update resource in node.mesh.attribute object by node id\n * @param id - end-to-end index of the node\n */\n updateNodeAttributeByNodeId(id) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.attribute.resource = node.index;\n }\n\n /**\n * Update featureCount in node.mesh.geometry object by node id\n * @param id - end-to-end index of the node\n * @param featureCount - features count of the node\n */\n updateFeatureCountByNodeId(id, featureCount) {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.featureCount = featureCount;\n }\n\n updateTexelCountHintByNodeId(id, texelCountHint) {\n const node = this.getNodeById(id);\n if (!node.mesh || !node.mesh.material) {\n return;\n }\n node.mesh.material.texelCountHint = texelCountHint;\n }\n\n /**\n * Add a child id into the parent node.children array\n * @param {number | null} parentId - end-to-end parent node index\n * @param {number} childId - end-to-end child node index\n * @return {void}\n */\n addChildRelation(parentId, childId) {\n if (parentId === null) {\n return;\n }\n const parentNode = this.getNodeById(parentId);\n parentNode.children.push(childId);\n }\n\n /**\n * Update resource index in node.mesh object\n * @param {object} node - node object\n * @return {void}\n */\n updateResourceInMesh(node) {\n if (node.mesh) {\n node.mesh.geometry.resource = node.index;\n }\n }\n\n /**\n * Put new node in nodePages array\n * @param {object} node - node object\n * @param {number | null} parentId - index of parent node\n * @return {number}\n */\n push(node, parentId = null) {\n let currentNodePage = this.nodePages[this.nodePages.length - 1];\n if (currentNodePage.nodes.length === this.nodesPerPage) {\n currentNodePage = {nodes: []};\n this.nodePages.push(currentNodePage);\n }\n node.index = this.nodesCounter++;\n currentNodePage.nodes.push(node);\n this.addChildRelation(parentId, node.index);\n this.updateResourceInMesh(node);\n return node.index;\n }\n\n /**\n * Save all the node pages\n * Run this method when all nodes is pushed in nodePages\n * @param {string} layers0Path - path of layer\n * @param {Object} fileMap\n * @param {boolean} slpk\n * @return {promise}\n */\n async save(layers0Path, fileMap, slpk = false) {\n const promises = [];\n if (slpk) {\n for (const [index, nodePage] of this.nodePages.entries()) {\n const nodePageStr = JSON.stringify(nodePage);\n const slpkPath = join(layers0Path, 'nodepages');\n promises.push(this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`));\n fileMap[`nodePages/${index.toString()}.json.gz`] = `${slpkPath}.json.gz`;\n }\n const metadata = transform({nodeCount: this.nodesCounter}, metadataTemplate);\n const compress = false;\n fileMap['metadata.json'] = await this.writeFile(\n layers0Path,\n JSON.stringify(metadata),\n 'metadata.json',\n compress\n );\n } else {\n for (const [index, nodePage] of this.nodePages.entries()) {\n const nodePageStr = JSON.stringify(nodePage);\n const nodePagePath = join(layers0Path, 'nodepages', index.toString());\n promises.push(this.writeFile(nodePagePath, nodePageStr));\n }\n }\n\n await Promise.all(promises);\n }\n}\n"],"file":"node-pages.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/i3s-converter/helpers/node-pages.ts"],"names":["join","transform","METADATA","metadataTemplate","NodePages","constructor","writeFileFunc","nodesPerPage","nodesCounter","nodePages","nodes","writeFile","useWriteFunction","func","getNodeById","id","pageIndex","Math","floor","nodeIndex","updateMaterialByNodeId","materialId","node","mesh","material","definition","resource","index","updateVertexCountByNodeId","vertexCount","geometry","updateNodeAttributeByNodeId","attribute","updateFeatureCountByNodeId","featureCount","updateTexelCountHintByNodeId","texelCountHint","addChildRelation","parentId","childId","undefined","parentNode","children","push","updateResourceInMesh","currentNodePage","length","save","layers0Path","fileMap","slpk","promises","nodePage","entries","nodePageStr","JSON","stringify","slpkPath","toString","metadata","nodeCount","compress","nodePagePath","Promise","all"],"mappings":";AAAA,SAAQA,I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QAAN,EAAzC,WAAd;AACAT,QAAAA,OAAO,qBAActB,KAAK,CAAC+B,QAAN,EAAd,cAAP,aAAsDD,QAAtD;AACD;;AACD,YAAME,QAAQ,GAAG1D,SAAS,CAAC;AAAC2D,QAAAA,SAAS,EAAE,KAAKpD;AAAjB,OAAD,EAAiCL,gBAAgB,EAAjD,CAA1B;AACA,YAAM0D,QAAQ,GAAG,KAAjB;AACAZ,MAAAA,OAAO,CAAC,eAAD,CAAP,GAA2B,MAAM,KAAKtC,SAAL,CAC/BqC,WAD+B,EAE/BO,IAAI,CAACC,SAAL,CAAeG,QAAf,CAF+B,EAG/B,eAH+B,EAI/BE,QAJ+B,CAAjC;AAMD,KAfD,MAeO;AACL,WAAK,MAAM,CAAClC,KAAD,EAAQyB,QAAR,CAAX,IAAgC,KAAK3C,SAAL,CAAe4C,OAAf,EAAhC,EAA0D;AACxD,cAAMC,WAAW,GAAGC,IAAI,CAACC,SAAL,CAAeJ,QAAf,CAApB;AACA,cAAMU,YAAY,GAAG9D,IAAI,CAACgD,WAAD,EAAc,WAAd,EAA2BrB,KAAK,CAAC+B,QAAN,EAA3B,CAAzB;AACAP,QAAAA,QAAQ,CAACR,IAAT,CAAc,KAAKhC,SAAL,CAAemD,YAAf,EAA6BR,WAA7B,CAAd;AACD;AACF;;AAED,UAAMS,OAAO,CAACC,GAAR,CAAYb,QAAZ,CAAN;AACD;;AAvL4B","sourcesContent":["import {join} from 'path';\nimport transform from 'json-map-transform';\nimport {METADATA as metadataTemplate} from '../json-templates/metadata';\nimport {NodeInPage} from '@loaders.gl/i3s';\n\n// @ts-nocheck\n/**\n * class NodePages - wrapper of nodePages array\n *\n * @example\n * import {writeFile} from './helpers/write-file';\n *\n * // create an instance of the class\n * const nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);\n * ...\n * // push root node\n * const parentId = nodePages.push({\n lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,\n obb: coordinates.obb,\n children: []\n });\n * ...\n * // push node with parent relation\n * const nodeInPage = {\n lodThreshold: HARDCODED_MAX_SCREEN_THRESHOLD_SQ,\n obb: coordinates.obb,\n children: [],\n mesh: {\n geometry: {\n definition: 0\n }\n }\n };\n * const nodeId = this.nodePages.push(nodeInPage, parentId);\n * ...\n * // save all the nodePages in the end of pushing all the nodes\n * await this.nodePages.save(layers0path);\n */\nexport default class NodePages {\n readonly nodesPerPage: number;\n nodesCounter: number;\n writeFile: Function;\n readonly nodePages: {nodes: NodeInPage[]}[];\n\n /**\n * @constructs\n * Create a nodePages instance.\n * @param writeFileFunc - function to save one nodePage into a file\n * @param nodesPerPage - length limit for one nodePage. An additional nodePage is created when this limit is met\n */\n constructor(writeFileFunc, nodesPerPage) {\n this.nodesPerPage = nodesPerPage;\n this.nodesCounter = 0;\n // @ts-expect-error\n this.nodePages = [{}];\n this.nodePages[0].nodes = [];\n this.writeFile = writeFileFunc;\n }\n\n /**\n * Setup function to save node pages\n * @param func - function which should be used to save node pages\n */\n useWriteFunction(func: Function): void {\n this.writeFile = func;\n }\n\n /**\n * Get the node by its end-to-end index\n * @param id - end-to-end index of the node\n * @return the node object\n */\n getNodeById(id: number): NodeInPage {\n const pageIndex = Math.floor(id / this.nodesPerPage);\n const nodeIndex = id % this.nodesPerPage;\n return this.nodePages[pageIndex].nodes[nodeIndex];\n }\n\n /**\n * Update material in node.mesh object by node id\n * @param id - end-to-end index of the node\n * @param materialId - id from scene layer materialDefinitions\n */\n updateMaterialByNodeId(id: number, materialId: number): void {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.material = {\n definition: materialId,\n resource: node.index\n };\n }\n\n /**\n * Update vertexCount in node.mesh.geometry object by node id\n * @param id - end-to-end index of the node\n * @param vertexCount - vertex count for particular node\n */\n updateVertexCountByNodeId(id: number, vertexCount: number): void {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.vertexCount = vertexCount;\n }\n\n /**\n * Update resource in node.mesh.attribute object by node id\n * @param id - end-to-end index of the node\n */\n updateNodeAttributeByNodeId(id: number): void {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.attribute.resource = node.index;\n }\n\n /**\n * Update featureCount in node.mesh.geometry object by node id\n * @param id - end-to-end index of the node\n * @param featureCount - features count of the node\n */\n updateFeatureCountByNodeId(id: number, featureCount: number): void {\n const node = this.getNodeById(id);\n if (!node.mesh) {\n return;\n }\n node.mesh.geometry.featureCount = featureCount;\n }\n\n /**\n * Update texelCountHint in node.mesh.material object by node id\n * @param id - end-to-end index of the node\n * @param texelCountHint - texelCountHint of particular node\n */\n updateTexelCountHintByNodeId(id: number, texelCountHint: number): void {\n const node = this.getNodeById(id);\n if (!node.mesh || !node.mesh.material) {\n return;\n }\n node.mesh.material.texelCountHint = texelCountHint;\n }\n\n /**\n * Add a child id into the parent node.children array\n * @param parentId - end-to-end parent node index\n * @param childId - end-to-end child node index\n */\n addChildRelation(parentId: number | undefined, childId: number): void {\n if (parentId === null || parentId === undefined) {\n return;\n }\n const parentNode = this.getNodeById(parentId);\n parentNode.children?.push(childId);\n }\n\n /**\n * Update resource index in node.mesh object\n * @param node - node object\n */\n updateResourceInMesh(node: NodeInPage): void {\n if (node.mesh) {\n node.mesh.geometry.resource = node.index;\n }\n }\n\n /**\n * Put new node in nodePages array\n * @param node - node object\n * @param parentId - index of parent node\n * @return\n */\n push(node: NodeInPage, parentId?: number): number {\n let currentNodePage = this.nodePages[this.nodePages.length - 1];\n if (currentNodePage.nodes.length === this.nodesPerPage) {\n currentNodePage = {nodes: []};\n this.nodePages.push(currentNodePage);\n }\n node.index = this.nodesCounter++;\n currentNodePage.nodes.push(node);\n this.addChildRelation(parentId, node.index);\n this.updateResourceInMesh(node);\n return node.index;\n }\n\n /**\n * Save all the node pages\n * Run this method when all nodes is pushed in nodePages\n * @param {string} layers0Path - path of layer\n * @param {Object} fileMap - fileMap which keep info for slpk archive\n * @param {boolean} slpk\n * @return {promise}\n */\n async save(layers0Path: string, fileMap: Object, slpk: boolean = false): Promise<void> {\n const promises: Promise<any>[] = [];\n if (slpk) {\n for (const [index, nodePage] of this.nodePages.entries()) {\n const nodePageStr = JSON.stringify(nodePage);\n const slpkPath = join(layers0Path, 'nodepages');\n promises.push(this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`));\n fileMap[`nodePages/${index.toString()}.json.gz`] = `${slpkPath}.json.gz`;\n }\n const metadata = transform({nodeCount: this.nodesCounter}, metadataTemplate());\n const compress = false;\n fileMap['metadata.json'] = await this.writeFile(\n layers0Path,\n JSON.stringify(metadata),\n 'metadata.json',\n compress\n );\n } else {\n for (const [index, nodePage] of this.nodePages.entries()) {\n const nodePageStr = JSON.stringify(nodePage);\n const nodePagePath = join(layers0Path, 'nodepages', index.toString());\n promises.push(this.writeFile(nodePagePath, nodePageStr));\n }\n }\n\n await Promise.all(promises);\n }\n}\n"],"file":"node-pages.js"}
|
|
@@ -18,9 +18,10 @@ import { convertGeometricErrorToScreenThreshold } from '../lib/utils/lod-convers
|
|
|
18
18
|
import { PGMLoader } from '../pgm-loader';
|
|
19
19
|
import { LAYERS as layersTemplate } from './json-templates/layers';
|
|
20
20
|
import { NODE as nodeTemplate } from './json-templates/node';
|
|
21
|
-
import {
|
|
21
|
+
import { SHARED_RESOURCES as sharedResourcesTemplate } from './json-templates/shared-resources';
|
|
22
22
|
import { validateNodeBoundingVolumes } from './helpers/node-debug';
|
|
23
23
|
import { KTX2BasisUniversalTextureWriter } from '@loaders.gl/textures';
|
|
24
|
+
import { ImageWriter } from '@loaders.gl/images';
|
|
24
25
|
const ION_DEFAULT_TOKEN = process.env.IonToken || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ';
|
|
25
26
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
26
27
|
const _3D_TILES = '3DTILES';
|
|
@@ -55,18 +56,22 @@ export default class I3SConverter {
|
|
|
55
56
|
|
|
56
57
|
_defineProperty(this, "validate", void 0);
|
|
57
58
|
|
|
58
|
-
_defineProperty(this, "boundingVolumeWarnings",
|
|
59
|
+
_defineProperty(this, "boundingVolumeWarnings", []);
|
|
59
60
|
|
|
60
|
-
_defineProperty(this, "conversionStartTime",
|
|
61
|
+
_defineProperty(this, "conversionStartTime", [0, 0]);
|
|
61
62
|
|
|
62
|
-
_defineProperty(this, "refreshTokenTime",
|
|
63
|
+
_defineProperty(this, "refreshTokenTime", [0, 0]);
|
|
63
64
|
|
|
64
|
-
_defineProperty(this, "sourceTileset",
|
|
65
|
+
_defineProperty(this, "sourceTileset", null);
|
|
65
66
|
|
|
66
|
-
_defineProperty(this, "geoidHeightModel",
|
|
67
|
+
_defineProperty(this, "geoidHeightModel", null);
|
|
67
68
|
|
|
68
69
|
_defineProperty(this, "Loader", Tiles3DLoader);
|
|
69
70
|
|
|
71
|
+
_defineProperty(this, "generateTextures", void 0);
|
|
72
|
+
|
|
73
|
+
_defineProperty(this, "generateBoundingVolumes", void 0);
|
|
74
|
+
|
|
70
75
|
this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
|
|
71
76
|
this.fileMap = {};
|
|
72
77
|
this.options = {};
|
|
@@ -81,7 +86,8 @@ export default class I3SConverter {
|
|
|
81
86
|
tilesWithAddRefineCount: 0
|
|
82
87
|
};
|
|
83
88
|
this.validate = false;
|
|
84
|
-
this.
|
|
89
|
+
this.generateTextures = false;
|
|
90
|
+
this.generateBoundingVolumes = false;
|
|
85
91
|
}
|
|
86
92
|
|
|
87
93
|
async convert(options) {
|
|
@@ -96,7 +102,9 @@ export default class I3SConverter {
|
|
|
96
102
|
draco,
|
|
97
103
|
sevenZipExe,
|
|
98
104
|
maxDepth,
|
|
99
|
-
token
|
|
105
|
+
token,
|
|
106
|
+
generateTextures,
|
|
107
|
+
generateBoundingVolumes
|
|
100
108
|
} = options;
|
|
101
109
|
this.options = {
|
|
102
110
|
maxDepth,
|
|
@@ -107,8 +115,10 @@ export default class I3SConverter {
|
|
|
107
115
|
token,
|
|
108
116
|
inputUrl
|
|
109
117
|
};
|
|
110
|
-
this.validate = validate;
|
|
118
|
+
this.validate = Boolean(validate);
|
|
111
119
|
this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;
|
|
120
|
+
this.generateTextures = Boolean(generateTextures);
|
|
121
|
+
this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
|
|
112
122
|
console.log('Loading egm file...');
|
|
113
123
|
this.geoidHeightModel = await load(egmFilePath, PGMLoader);
|
|
114
124
|
console.log('Loading egm file completed!');
|
|
@@ -119,7 +129,11 @@ export default class I3SConverter {
|
|
|
119
129
|
|
|
120
130
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
121
131
|
const tilesetOptions = {
|
|
122
|
-
loadOptions: {
|
|
132
|
+
loadOptions: {
|
|
133
|
+
basis: {
|
|
134
|
+
format: 'rgba32'
|
|
135
|
+
}
|
|
136
|
+
}
|
|
123
137
|
};
|
|
124
138
|
|
|
125
139
|
if (preloadOptions.headers) {
|
|
@@ -133,7 +147,7 @@ export default class I3SConverter {
|
|
|
133
147
|
this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
134
148
|
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
135
149
|
await this._finishConversion({
|
|
136
|
-
slpk,
|
|
150
|
+
slpk: Boolean(slpk),
|
|
137
151
|
outputPath,
|
|
138
152
|
tilesetName
|
|
139
153
|
});
|
|
@@ -156,6 +170,7 @@ export default class I3SConverter {
|
|
|
156
170
|
const sourceRootTile = this.sourceTileset.root;
|
|
157
171
|
const boundingVolumes = createBoundingVolumes(sourceRootTile, this.geoidHeightModel);
|
|
158
172
|
const parentId = this.nodePages.push({
|
|
173
|
+
index: 0,
|
|
159
174
|
lodThreshold: 0,
|
|
160
175
|
obb: boundingVolumes.obb,
|
|
161
176
|
children: []
|
|
@@ -189,7 +204,7 @@ export default class I3SConverter {
|
|
|
189
204
|
},
|
|
190
205
|
compressGeometry: this.options.draco
|
|
191
206
|
};
|
|
192
|
-
this.layers0 = transform(layers0data, layersTemplate);
|
|
207
|
+
this.layers0 = transform(layers0data, layersTemplate());
|
|
193
208
|
}
|
|
194
209
|
|
|
195
210
|
_formRootNodeIndexDocument(boundingVolumes) {
|
|
@@ -207,13 +222,14 @@ export default class I3SConverter {
|
|
|
207
222
|
...boundingVolumes,
|
|
208
223
|
children: []
|
|
209
224
|
};
|
|
210
|
-
return transform(root0data, nodeTemplate);
|
|
225
|
+
return transform(root0data, nodeTemplate());
|
|
211
226
|
}
|
|
212
227
|
|
|
213
228
|
async _convertNodesTree(root0, sourceRootTile, parentId, boundingVolumes) {
|
|
214
229
|
await this.sourceTileset._loadTile(sourceRootTile);
|
|
215
230
|
|
|
216
|
-
if (
|
|
231
|
+
if (this.isContentSupported(sourceRootTile)) {
|
|
232
|
+
root0.children = root0.children || [];
|
|
217
233
|
root0.children.push({
|
|
218
234
|
id: '1',
|
|
219
235
|
href: './1',
|
|
@@ -300,14 +316,15 @@ export default class I3SConverter {
|
|
|
300
316
|
});
|
|
301
317
|
await sourceTile.unloadContent();
|
|
302
318
|
} else {
|
|
303
|
-
const boundingVolumes = createBoundingVolumes(sourceTile, this.geoidHeightModel);
|
|
304
319
|
const children = await this._createNode(parentNode, sourceTile, parentId, level);
|
|
320
|
+
parentNode.children = parentNode.children || [];
|
|
305
321
|
|
|
306
322
|
for (const child of children) {
|
|
307
323
|
parentNode.children.push({
|
|
308
324
|
id: child.id,
|
|
309
325
|
href: "../".concat(child.path),
|
|
310
|
-
|
|
326
|
+
obb: child.obb,
|
|
327
|
+
mbs: child.mbs
|
|
311
328
|
});
|
|
312
329
|
childNodes.push(child);
|
|
313
330
|
}
|
|
@@ -321,18 +338,22 @@ export default class I3SConverter {
|
|
|
321
338
|
|
|
322
339
|
async _addNeighborsAndWriteFile(parentNode, childNodes) {
|
|
323
340
|
for (const node of childNodes) {
|
|
341
|
+
var _parentNode$children;
|
|
342
|
+
|
|
324
343
|
const childPath = join(this.layers0Path, 'nodes', node.path);
|
|
325
344
|
const nodePath = node.path;
|
|
326
345
|
delete node.path;
|
|
327
346
|
|
|
328
|
-
if (parentNode.children.length < 1000) {
|
|
329
|
-
for (const neighbor of parentNode.children) {
|
|
347
|
+
if (Number(parentNode === null || parentNode === void 0 ? void 0 : (_parentNode$children = parentNode.children) === null || _parentNode$children === void 0 ? void 0 : _parentNode$children.length) < 1000) {
|
|
348
|
+
for (const neighbor of parentNode.children || []) {
|
|
330
349
|
if (node.id === neighbor.id) {
|
|
331
350
|
continue;
|
|
332
351
|
}
|
|
333
352
|
|
|
334
|
-
node.neighbors
|
|
335
|
-
|
|
353
|
+
if (node.neighbors) {
|
|
354
|
+
node.neighbors.push({ ...neighbor
|
|
355
|
+
});
|
|
356
|
+
}
|
|
336
357
|
}
|
|
337
358
|
} else {
|
|
338
359
|
console.warn("Node ".concat(node.id, ": neighbors attribute is omited because of large number of neigbors"));
|
|
@@ -353,11 +374,7 @@ export default class I3SConverter {
|
|
|
353
374
|
|
|
354
375
|
await this._updateTilesetOptions();
|
|
355
376
|
await this.sourceTileset._loadTile(sourceTile);
|
|
356
|
-
|
|
357
|
-
const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);
|
|
358
|
-
const maxScreenThresholdSQ = lodSelection.find(val => val.metricType === 'maxScreenThresholdSQ') || {
|
|
359
|
-
maxError: 0
|
|
360
|
-
};
|
|
377
|
+
let boundingVolumes = createBoundingVolumes(sourceTile, this.geoidHeightModel);
|
|
361
378
|
const batchTable = sourceTile === null || sourceTile === void 0 ? void 0 : (_sourceTile$content = sourceTile.content) === null || _sourceTile$content === void 0 ? void 0 : _sourceTile$content.batchTableJson;
|
|
362
379
|
|
|
363
380
|
if (batchTable) {
|
|
@@ -366,6 +383,7 @@ export default class I3SConverter {
|
|
|
366
383
|
|
|
367
384
|
const resourcesData = await this._convertResources(sourceTile);
|
|
368
385
|
const nodes = [];
|
|
386
|
+
const nodesInPage = [];
|
|
369
387
|
const emptyResources = {
|
|
370
388
|
geometry: null,
|
|
371
389
|
compressedGeometry: null,
|
|
@@ -374,10 +392,20 @@ export default class I3SConverter {
|
|
|
374
392
|
meshMaterial: null,
|
|
375
393
|
vertexCount: null,
|
|
376
394
|
attributes: null,
|
|
377
|
-
featureCount: null
|
|
395
|
+
featureCount: null,
|
|
396
|
+
boundingVolumes: null
|
|
378
397
|
};
|
|
379
398
|
|
|
380
399
|
for (const resources of resourcesData || [emptyResources]) {
|
|
400
|
+
if (this.generateBoundingVolumes && resources.boundingVolumes) {
|
|
401
|
+
boundingVolumes = resources.boundingVolumes;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
const lodSelection = convertGeometricErrorToScreenThreshold(sourceTile, boundingVolumes);
|
|
405
|
+
const maxScreenThresholdSQ = lodSelection.find(val => val.metricType === 'maxScreenThresholdSQ') || {
|
|
406
|
+
maxError: 0
|
|
407
|
+
};
|
|
408
|
+
|
|
381
409
|
const nodeInPage = this._createNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources);
|
|
382
410
|
|
|
383
411
|
const node = this._createNodeIndexDocument(parentTile, boundingVolumes, lodSelection, nodeInPage, resources);
|
|
@@ -395,33 +423,37 @@ export default class I3SConverter {
|
|
|
395
423
|
}
|
|
396
424
|
|
|
397
425
|
nodes.push(node);
|
|
426
|
+
nodesInPage.push(nodeInPage);
|
|
398
427
|
}
|
|
399
428
|
|
|
400
429
|
sourceTile.unloadContent();
|
|
401
|
-
const firstNode = nodes[0];
|
|
402
430
|
await this._addChildrenWithNeighborsAndWriteFile({
|
|
403
|
-
parentNode:
|
|
431
|
+
parentNode: nodes[0],
|
|
404
432
|
sourceTiles: sourceTile.children,
|
|
405
|
-
parentId:
|
|
433
|
+
parentId: nodesInPage[0].index,
|
|
406
434
|
level: level + 1
|
|
407
435
|
});
|
|
408
436
|
return nodes;
|
|
409
437
|
}
|
|
410
438
|
|
|
411
439
|
_convertAttributeStorageInfo(sourceTileContent) {
|
|
440
|
+
var _this$layers, _this$layers$attribut;
|
|
441
|
+
|
|
412
442
|
const batchTable = sourceTileContent && sourceTileContent.batchTableJson;
|
|
413
443
|
|
|
414
|
-
if (batchTable && !this.layers0.attributeStorageInfo.length) {
|
|
444
|
+
if (batchTable && !((_this$layers = this.layers0) !== null && _this$layers !== void 0 && (_this$layers$attribut = _this$layers.attributeStorageInfo) !== null && _this$layers$attribut !== void 0 && _this$layers$attribut.length)) {
|
|
415
445
|
this._convertBatchTableInfoToNodeAttributes(batchTable);
|
|
416
446
|
}
|
|
417
447
|
}
|
|
418
448
|
|
|
419
449
|
async _convertResources(sourceTile) {
|
|
420
|
-
|
|
450
|
+
var _this$layers2;
|
|
451
|
+
|
|
452
|
+
if (!this.isContentSupported(sourceTile)) {
|
|
421
453
|
return null;
|
|
422
454
|
}
|
|
423
455
|
|
|
424
|
-
const resourcesData = await convertB3dmToI3sGeometry(sourceTile.content, Number(this.nodePages.nodesCounter), this.featuresHashArray, this.layers0.attributeStorageInfo, this.options.draco);
|
|
456
|
+
const resourcesData = await convertB3dmToI3sGeometry(sourceTile.content, Number(this.nodePages.nodesCounter), this.featuresHashArray, (_this$layers2 = this.layers0) === null || _this$layers2 === void 0 ? void 0 : _this$layers2.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.geoidHeightModel);
|
|
425
457
|
return resourcesData;
|
|
426
458
|
}
|
|
427
459
|
|
|
@@ -434,18 +466,24 @@ export default class I3SConverter {
|
|
|
434
466
|
geometry
|
|
435
467
|
} = resources;
|
|
436
468
|
const nodeInPage = {
|
|
469
|
+
index: 0,
|
|
437
470
|
lodThreshold: maxScreenThresholdSQ.maxError,
|
|
438
471
|
obb: boundingVolumes.obb,
|
|
439
|
-
children: []
|
|
440
|
-
mesh: null
|
|
472
|
+
children: []
|
|
441
473
|
};
|
|
442
474
|
|
|
443
|
-
if (geometry &&
|
|
475
|
+
if (geometry && this.isContentSupported(sourceTile)) {
|
|
444
476
|
nodeInPage.mesh = {
|
|
445
477
|
geometry: {
|
|
446
|
-
definition: texture ? 0 : 1
|
|
478
|
+
definition: texture ? 0 : 1,
|
|
479
|
+
resource: 0
|
|
447
480
|
},
|
|
448
|
-
attribute: {
|
|
481
|
+
attribute: {
|
|
482
|
+
resource: 0
|
|
483
|
+
},
|
|
484
|
+
material: {
|
|
485
|
+
definition: 0
|
|
486
|
+
}
|
|
449
487
|
};
|
|
450
488
|
}
|
|
451
489
|
|
|
@@ -496,9 +534,11 @@ export default class I3SConverter {
|
|
|
496
534
|
children: [],
|
|
497
535
|
neighbors: []
|
|
498
536
|
};
|
|
499
|
-
const node = transform(nodeData, nodeTemplate);
|
|
537
|
+
const node = transform(nodeData, nodeTemplate());
|
|
500
538
|
|
|
501
539
|
if (nodeInPage.mesh) {
|
|
540
|
+
var _this$layers3, _this$layers3$attribu;
|
|
541
|
+
|
|
502
542
|
node.geometryData = [{
|
|
503
543
|
href: './geometries/0'
|
|
504
544
|
}];
|
|
@@ -514,7 +554,7 @@ export default class I3SConverter {
|
|
|
514
554
|
}];
|
|
515
555
|
}
|
|
516
556
|
|
|
517
|
-
if (attributes && attributes.length && this.layers0.attributeStorageInfo &&
|
|
557
|
+
if (attributes && attributes.length && (_this$layers3 = this.layers0) !== null && _this$layers3 !== void 0 && (_this$layers3$attribu = _this$layers3.attributeStorageInfo) !== null && _this$layers3$attribu !== void 0 && _this$layers3$attribu.length) {
|
|
518
558
|
node.attributeData = [];
|
|
519
559
|
|
|
520
560
|
for (let index = 0; index < attributes.length; index++) {
|
|
@@ -567,7 +607,7 @@ export default class I3SConverter {
|
|
|
567
607
|
|
|
568
608
|
async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
|
|
569
609
|
sharedResources.nodePath = nodePath;
|
|
570
|
-
const sharedData = transform(sharedResources,
|
|
610
|
+
const sharedData = transform(sharedResources, sharedResourcesTemplate());
|
|
571
611
|
const sharedDataStr = JSON.stringify(sharedData);
|
|
572
612
|
|
|
573
613
|
if (this.options.slpk) {
|
|
@@ -581,39 +621,75 @@ export default class I3SConverter {
|
|
|
581
621
|
|
|
582
622
|
async _writeTexture(texture, childPath, slpkChildPath) {
|
|
583
623
|
if (texture) {
|
|
584
|
-
const format = this._getFormatByMimeType(texture.mimeType);
|
|
624
|
+
const format = this._getFormatByMimeType(texture === null || texture === void 0 ? void 0 : texture.mimeType);
|
|
625
|
+
|
|
626
|
+
const formats = [];
|
|
627
|
+
const textureData = texture.bufferView.data;
|
|
628
|
+
|
|
629
|
+
switch (format) {
|
|
630
|
+
case 'jpg':
|
|
631
|
+
case 'png':
|
|
632
|
+
{
|
|
633
|
+
formats.push({
|
|
634
|
+
name: '0',
|
|
635
|
+
format
|
|
636
|
+
});
|
|
637
|
+
await this.writeTextureFile(textureData, '0', format, childPath, slpkChildPath);
|
|
638
|
+
|
|
639
|
+
if (this.generateTextures) {
|
|
640
|
+
formats.push({
|
|
641
|
+
name: '1',
|
|
642
|
+
format: 'ktx2'
|
|
643
|
+
});
|
|
644
|
+
const ktx2TextureData = new Uint8Array(await encode(texture.image, KTX2BasisUniversalTextureWriter));
|
|
645
|
+
await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
break;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
case 'ktx2':
|
|
652
|
+
{
|
|
653
|
+
formats.push({
|
|
654
|
+
name: '1',
|
|
655
|
+
format
|
|
656
|
+
});
|
|
657
|
+
await this.writeTextureFile(textureData, '1', format, childPath, slpkChildPath);
|
|
658
|
+
|
|
659
|
+
if (this.generateTextures) {
|
|
660
|
+
formats.push({
|
|
661
|
+
name: '0',
|
|
662
|
+
format: 'jpg'
|
|
663
|
+
});
|
|
664
|
+
const decodedFromKTX2TextureData = new Uint8Array(await encode(texture.image.data[0], ImageWriter));
|
|
665
|
+
await this.writeTextureFile(decodedFromKTX2TextureData, '0', 'jpg', childPath, slpkChildPath);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
585
669
|
|
|
586
670
|
if (!this.layers0.textureSetDefinitions.length) {
|
|
587
671
|
this.layers0.textureSetDefinitions.push({
|
|
588
|
-
formats
|
|
589
|
-
name: '0',
|
|
590
|
-
format
|
|
591
|
-
}, {
|
|
592
|
-
name: '1',
|
|
593
|
-
format: 'ktx2'
|
|
594
|
-
}]
|
|
672
|
+
formats
|
|
595
673
|
});
|
|
596
674
|
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
597
677
|
|
|
598
|
-
|
|
599
|
-
|
|
678
|
+
async writeTextureFile(textureData, name, format, childPath, slpkChildPath) {
|
|
679
|
+
const texturePath = join(childPath, "textures/".concat(name, "/"));
|
|
680
|
+
await writeFile(texturePath, textureData, "index.".concat(format));
|
|
600
681
|
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
this.fileMap["".concat(slpkChildPath, "/textures/1.ktx2")] = await writeFileForSlpk(slpkTexturePath, ktx2TextureData, "1.ktx2", compress);
|
|
606
|
-
} else {
|
|
607
|
-
const texturePath = join(childPath, 'textures/0/');
|
|
608
|
-
await writeFile(texturePath, textureData, "index.".concat(format));
|
|
609
|
-
const ktx2TexturePath = join(childPath, 'textures/1/');
|
|
610
|
-
await writeFile(ktx2TexturePath, ktx2TextureData, "index.ktx2");
|
|
611
|
-
}
|
|
682
|
+
if (this.options.slpk) {
|
|
683
|
+
const slpkTexturePath = join(childPath, 'textures');
|
|
684
|
+
const compress = false;
|
|
685
|
+
this.fileMap["".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format)] = await writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress);
|
|
612
686
|
}
|
|
613
687
|
}
|
|
614
688
|
|
|
615
689
|
async _writeAttributes(attributes, childPath, slpkChildPath) {
|
|
616
|
-
|
|
690
|
+
var _this$layers4, _this$layers4$attribu;
|
|
691
|
+
|
|
692
|
+
if (attributes.length && (_this$layers4 = this.layers0) !== null && _this$layers4 !== void 0 && (_this$layers4$attribu = _this$layers4.attributeStorageInfo) !== null && _this$layers4$attribu !== void 0 && _this$layers4$attribu.length) {
|
|
617
693
|
for (let index = 0; index < attributes.length; index++) {
|
|
618
694
|
const folderName = this.layers0.attributeStorageInfo[index].key;
|
|
619
695
|
const fileBuffer = new Uint8Array(attributes[index]);
|
|
@@ -637,6 +713,9 @@ export default class I3SConverter {
|
|
|
637
713
|
case 'image/png':
|
|
638
714
|
return 'png';
|
|
639
715
|
|
|
716
|
+
case 'image/ktx2':
|
|
717
|
+
return 'ktx2';
|
|
718
|
+
|
|
640
719
|
default:
|
|
641
720
|
return 'jpg';
|
|
642
721
|
}
|
|
@@ -891,5 +970,11 @@ export default class I3SConverter {
|
|
|
891
970
|
this.refinementCounter.tilesCount += 1;
|
|
892
971
|
}
|
|
893
972
|
|
|
973
|
+
isContentSupported(sourceRootTile) {
|
|
974
|
+
var _sourceRootTile$conte;
|
|
975
|
+
|
|
976
|
+
return ['b3dm', 'glTF'].includes(sourceRootTile === null || sourceRootTile === void 0 ? void 0 : (_sourceRootTile$conte = sourceRootTile.content) === null || _sourceRootTile$conte === void 0 ? void 0 : _sourceRootTile$conte.type);
|
|
977
|
+
}
|
|
978
|
+
|
|
894
979
|
}
|
|
895
980
|
//# sourceMappingURL=i3s-converter.js.map
|