@loaders.gl/tile-converter 4.0.0-alpha.4 → 4.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +78 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.js +9 -7
- package/dist/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +78 -18
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +19 -9
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +4 -7
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +9 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +1 -1
- package/dist/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts +15 -0
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -0
- package/dist/3d-tiles-converter/json-templates/tileset.js +12 -9
- package/dist/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/converter.min.js +22 -22
- package/dist/deps-installer/deps-installer.d.ts.map +1 -0
- package/dist/deps-installer/deps-installer.js +2 -6
- package/dist/deps-installer/deps-installer.js.map +1 -1
- package/dist/dist.min.js +86527 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +41 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/coordinate-converter.js +35 -3
- package/dist/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.js +2 -2
- package/dist/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +23 -0
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +5 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/geometry-converter.js +88 -42
- package/dist/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/i3s-converter/helpers/node-debug.d.ts +2 -0
- package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-debug.js +2 -4
- package/dist/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.d.ts +83 -111
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-pages.js +15 -4
- package/dist/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/i3s-converter/i3s-converter.d.ts +320 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
- package/dist/i3s-converter/i3s-converter.js +158 -65
- package/dist/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/i3s-converter/json-templates/layers.d.ts +95 -0
- package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/layers.js +37 -27
- package/dist/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
- package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/metadata.js +2 -2
- package/dist/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/i3s-converter/json-templates/node.d.ts +61 -0
- package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/node.js +16 -12
- package/dist/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
- package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/scene-server.js +2 -2
- package/dist/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
- package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/shared-resources.js +19 -14
- package/dist/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/i3s-converter/json-templates/store.d.ts +95 -0
- package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/i3s-converter/types.d.ts +14 -0
- package/dist/i3s-converter/types.d.ts.map +1 -0
- package/dist/i3s-converter/types.js +2 -0
- package/dist/i3s-converter/types.js.map +1 -0
- package/dist/i3s-server/app.d.ts +3 -0
- package/dist/i3s-server/app.d.ts.map +1 -0
- package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
- package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
- package/dist/i3s-server/routes/index.d.ts +3 -0
- package/dist/i3s-server/routes/index.d.ts.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/utils/{compress-utils.d.ts → compress-util.d.ts} +0 -0
- package/dist/lib/utils/compress-util.d.ts.map +1 -0
- package/dist/lib/utils/file-utils.d.ts.map +1 -0
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
- package/dist/pgm-loader.d.ts +6 -0
- package/dist/pgm-loader.d.ts.map +1 -0
- package/dist/pgm-loader.js +3 -3
- package/dist/pgm-loader.js.map +1 -1
- package/package.json +21 -19
- package/src/3d-tiles-converter/3d-tiles-converter.ts +25 -21
- package/src/3d-tiles-converter/helpers/{b3dm-converter.js → b3dm-converter.ts} +35 -11
- 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 +110 -33
- 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 +214 -136
- 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/lib/geoid-height-model.d.ts +0 -41
- package/dist/lib/geoid-height-model.js +0 -140
- package/dist/lib/geoid-height-model.js.map +0 -1
- package/dist/lib/pgm-parser.d.ts +0 -14
- package/dist/lib/pgm-parser.js +0 -183
- package/dist/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,8 +1,17 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import { join } from 'path';
|
|
2
3
|
import transform from 'json-map-transform';
|
|
3
4
|
import { METADATA as metadataTemplate } from '../json-templates/metadata';
|
|
4
5
|
export default class NodePages {
|
|
5
6
|
constructor(writeFileFunc, nodesPerPage) {
|
|
7
|
+
_defineProperty(this, "nodesPerPage", void 0);
|
|
8
|
+
|
|
9
|
+
_defineProperty(this, "nodesCounter", void 0);
|
|
10
|
+
|
|
11
|
+
_defineProperty(this, "writeFile", void 0);
|
|
12
|
+
|
|
13
|
+
_defineProperty(this, "nodePages", void 0);
|
|
14
|
+
|
|
6
15
|
this.nodesPerPage = nodesPerPage;
|
|
7
16
|
this.nodesCounter = 0;
|
|
8
17
|
this.nodePages = [{}];
|
|
@@ -74,12 +83,14 @@ export default class NodePages {
|
|
|
74
83
|
}
|
|
75
84
|
|
|
76
85
|
addChildRelation(parentId, childId) {
|
|
77
|
-
|
|
86
|
+
var _parentNode$children;
|
|
87
|
+
|
|
88
|
+
if (parentId === null || parentId === undefined) {
|
|
78
89
|
return;
|
|
79
90
|
}
|
|
80
91
|
|
|
81
92
|
const parentNode = this.getNodeById(parentId);
|
|
82
|
-
parentNode.children.push(childId);
|
|
93
|
+
(_parentNode$children = parentNode.children) === null || _parentNode$children === void 0 ? void 0 : _parentNode$children.push(childId);
|
|
83
94
|
}
|
|
84
95
|
|
|
85
96
|
updateResourceInMesh(node) {
|
|
@@ -88,7 +99,7 @@ export default class NodePages {
|
|
|
88
99
|
}
|
|
89
100
|
}
|
|
90
101
|
|
|
91
|
-
push(node, parentId
|
|
102
|
+
push(node, parentId) {
|
|
92
103
|
let currentNodePage = this.nodePages[this.nodePages.length - 1];
|
|
93
104
|
|
|
94
105
|
if (currentNodePage.nodes.length === this.nodesPerPage) {
|
|
@@ -118,7 +129,7 @@ export default class NodePages {
|
|
|
118
129
|
|
|
119
130
|
const metadata = transform({
|
|
120
131
|
nodeCount: this.nodesCounter
|
|
121
|
-
}, metadataTemplate);
|
|
132
|
+
}, metadataTemplate());
|
|
122
133
|
const compress = false;
|
|
123
134
|
fileMap['metadata.json'] = await this.writeFile(layers0Path, JSON.stringify(metadata), 'metadata.json', compress);
|
|
124
135
|
} else {
|
|
@@ -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,SA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AO,CAAC,eAAD,CAAP,GAA2B,MAAM,KAAKrC,SAAL,CAC/BoC,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,CAACjC,KAAD,EAAQwB,QAAR,CAAX,IAAgC,KAAK1C,SAAL,CAAe2C,OAAf,EAAhC,EAA0D;AACxD,cAAMC,WAAW,GAAGC,IAAI,CAACC,SAAL,CAAeJ,QAAf,CAApB;AACA,cAAMU,YAAY,GAAG7D,IAAI,CAAC+C,WAAD,EAAc,WAAd,EAA2BpB,KAAK,CAAC8B,QAAN,EAA3B,CAAzB;AACAP,QAAAA,QAAQ,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,IAAR,QAAmB,MAAnB;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,SAAQC,QAAQ,IAAIC,gBAApB,QAA2C,4BAA3C;AAoCA,eAAe,MAAMC,SAAN,CAAgB;AAY7BC,EAAAA,WAAW,CAACC,aAAD,EAAgBC,YAAhB,EAA8B;AAAA;;AAAA;;AAAA;;AAAA;;AACvC,SAAKA,YAAL,GAAoBA,YAApB;AACA,SAAKC,YAAL,GAAoB,CAApB;AAEA,SAAKC,SAAL,GAAiB,CAAC,EAAD,CAAjB;AACA,SAAKA,SAAL,CAAe,CAAf,EAAkBC,KAAlB,GAA0B,EAA1B;AACA,SAAKC,SAAL,GAAiBL,aAAjB;AACD;;AAMDM,EAAAA,gBAAgB,CAACC,IAAD,EAAuB;AACrC,SAAKF,SAAL,GAAiBE,IAAjB;AACD;;AAODC,EAAAA,WAAW,CAACC,EAAD,EAAyB;AAClC,UAAMC,SAAS,GAAGC,IAAI,CAACC,KAAL,CAAWH,EAAE,GAAG,KAAKR,YAArB,CAAlB;AACA,UAAMY,SAAS,GAAGJ,EAAE,GAAG,KAAKR,YAA5B;AACA,WAAO,KAAKE,SAAL,CAAeO,SAAf,EAA0BN,KAA1B,CAAgCS,SAAhC,CAAP;AACD;;AAODC,EA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R,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"}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import type { SceneLayer3D } from '@loaders.gl/i3s';
|
|
2
|
+
import { Tileset3D } from '@loaders.gl/tiles';
|
|
3
|
+
import { Geoid } from '@math.gl/geoid';
|
|
4
|
+
import NodePages from './helpers/node-pages';
|
|
5
|
+
import { LoaderWithParser } from '@loaders.gl/loader-utils';
|
|
6
|
+
import { I3SMaterialDefinition } from '@loaders.gl/i3s/src/types';
|
|
7
|
+
/**
|
|
8
|
+
* Converter from 3d-tiles tileset to i3s layer
|
|
9
|
+
*/
|
|
10
|
+
export default class I3SConverter {
|
|
11
|
+
nodePages: NodePages;
|
|
12
|
+
fileMap: {
|
|
13
|
+
[key: string]: string;
|
|
14
|
+
};
|
|
15
|
+
options: any;
|
|
16
|
+
layers0Path: string;
|
|
17
|
+
materialMap: Map<any, any>;
|
|
18
|
+
materialDefinitions: I3SMaterialDefinition[];
|
|
19
|
+
vertexCounter: number;
|
|
20
|
+
layers0: SceneLayer3D | null;
|
|
21
|
+
featuresHashArray: string[];
|
|
22
|
+
refinementCounter: {
|
|
23
|
+
tilesCount: number;
|
|
24
|
+
tilesWithAddRefineCount: number;
|
|
25
|
+
};
|
|
26
|
+
validate: boolean;
|
|
27
|
+
boundingVolumeWarnings?: string[];
|
|
28
|
+
conversionStartTime: [number, number];
|
|
29
|
+
refreshTokenTime: [number, number];
|
|
30
|
+
sourceTileset: Tileset3D | null;
|
|
31
|
+
geoidHeightModel: Geoid | null;
|
|
32
|
+
Loader: LoaderWithParser;
|
|
33
|
+
generateTextures: boolean;
|
|
34
|
+
generateBoundingVolumes: boolean;
|
|
35
|
+
constructor();
|
|
36
|
+
/**
|
|
37
|
+
* Convert a 3d tileset
|
|
38
|
+
* @param options
|
|
39
|
+
* @param options.inputUrl the url to read the tileset from
|
|
40
|
+
* @param options.outputPath the output filename
|
|
41
|
+
* @param options.tilesetName the output name of the tileset
|
|
42
|
+
* @param options.maxDepth The max tree depth of conversion
|
|
43
|
+
* @param options.slpk Generate slpk (Scene Layer Packages) output file
|
|
44
|
+
* @param options.sevenZipExe Location of 7z.exe archiver to create slpk on Windows
|
|
45
|
+
* @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
|
|
46
|
+
* @param options.token Token for Cesium ION tilesets authentication
|
|
47
|
+
* @param options.draco Generate I3S 1.7 draco compressed geometries
|
|
48
|
+
* @param options.validate -enable validation
|
|
49
|
+
*/
|
|
50
|
+
convert(options: {
|
|
51
|
+
inputUrl: string;
|
|
52
|
+
outputPath: string;
|
|
53
|
+
tilesetName: string;
|
|
54
|
+
sevenZipExe: string;
|
|
55
|
+
egmFilePath: string;
|
|
56
|
+
maxDepth?: number;
|
|
57
|
+
slpk?: boolean;
|
|
58
|
+
token?: string;
|
|
59
|
+
draco?: boolean;
|
|
60
|
+
validate?: boolean;
|
|
61
|
+
generateTextures?: boolean;
|
|
62
|
+
generateBoundingVolumes?: boolean;
|
|
63
|
+
/** @deprecated */
|
|
64
|
+
inputType?: string;
|
|
65
|
+
}): Promise<any>;
|
|
66
|
+
/**
|
|
67
|
+
* Convert and save the layer and embedded tiles
|
|
68
|
+
* @param outputPath - path to save output data
|
|
69
|
+
* @param tilesetName - new tileset path
|
|
70
|
+
*/
|
|
71
|
+
private _createAndSaveTileset;
|
|
72
|
+
/**
|
|
73
|
+
* Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md
|
|
74
|
+
* @param tilesetName - Name of layer
|
|
75
|
+
*/
|
|
76
|
+
private _formLayers0;
|
|
77
|
+
/**
|
|
78
|
+
* Convert and save the layer and embedded tiles
|
|
79
|
+
* @param boundingVolumes - mbs and obb data about node's bounding volume
|
|
80
|
+
* @return 3DNodeIndexDocument data https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md
|
|
81
|
+
*/
|
|
82
|
+
private _formRootNodeIndexDocument;
|
|
83
|
+
/**
|
|
84
|
+
* Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md
|
|
85
|
+
* @param root0 - 3DNodeIndexDocument of root node https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md
|
|
86
|
+
* @param sourceRootTile - Source (3DTile) tile data
|
|
87
|
+
* @param parentId - node id in node pages
|
|
88
|
+
* @param boundingVolumes - mbs and obb data about node's bounding volume
|
|
89
|
+
*/
|
|
90
|
+
private _convertNodesTree;
|
|
91
|
+
/**
|
|
92
|
+
* Write 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md in file
|
|
93
|
+
*/
|
|
94
|
+
private _writeLayers0;
|
|
95
|
+
/**
|
|
96
|
+
* Write 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md in file
|
|
97
|
+
*/
|
|
98
|
+
private _writeNodeIndexDocument;
|
|
99
|
+
/**
|
|
100
|
+
* Pack files into *.slpk archive
|
|
101
|
+
* @param tilesetPath - Path to save file
|
|
102
|
+
*/
|
|
103
|
+
private _createSlpk;
|
|
104
|
+
/**
|
|
105
|
+
* Add child nodes recursively and write them to files
|
|
106
|
+
* @param data - arguments
|
|
107
|
+
* @param data.sourceTiles - array of source child nodes
|
|
108
|
+
* @param data.parentNode - 3DNodeIndexDocument of parent node for processing child nodes
|
|
109
|
+
* @param data.parentId - id of parent node in node pages
|
|
110
|
+
* @param data.level - level of node (distanse to root node in the tree)
|
|
111
|
+
*/
|
|
112
|
+
private _addChildrenWithNeighborsAndWriteFile;
|
|
113
|
+
/**
|
|
114
|
+
* Add child nodes recursively and write them to files
|
|
115
|
+
* @param data - arguments
|
|
116
|
+
* @param data.childNodes - array of target child nodes
|
|
117
|
+
* @param data.sourceTiles - array of source child nodes
|
|
118
|
+
* @param data.parentNode - 3DNodeIndexDocument of parent node for processing child nodes
|
|
119
|
+
* @param data.parentId - id of parent node in node pages
|
|
120
|
+
* @param data.level - level of node (distanse to root node in the tree)
|
|
121
|
+
*/
|
|
122
|
+
private _addChildren;
|
|
123
|
+
/**
|
|
124
|
+
* Add neightbors to 3DNodeIndexDocument and write it in a file
|
|
125
|
+
* @param parentNode - arguments
|
|
126
|
+
* @param childNodes - array of target child nodes
|
|
127
|
+
*/
|
|
128
|
+
private _addNeighborsAndWriteFile;
|
|
129
|
+
/**
|
|
130
|
+
* Convert tile to one or more I3S nodes
|
|
131
|
+
* @param parentTile - parent 3DNodeIndexDocument
|
|
132
|
+
* @param sourceTile - source tile (3DTile)
|
|
133
|
+
* @param parentId - id of parent node in node pages
|
|
134
|
+
* @param level - level of node (distanse to root node in the tree)
|
|
135
|
+
*/
|
|
136
|
+
private _createNode;
|
|
137
|
+
/**
|
|
138
|
+
* Convert attributesStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
|
|
139
|
+
* from B3DM batch table
|
|
140
|
+
* @param sourceTileContent - tile content of 3DTile
|
|
141
|
+
* @return {void}
|
|
142
|
+
*/
|
|
143
|
+
private _convertAttributeStorageInfo;
|
|
144
|
+
/**
|
|
145
|
+
* Convert tile to one or more I3S nodes
|
|
146
|
+
* @param sourceTile - source tile (3DTile)
|
|
147
|
+
* result.geometry - ArrayBuffer with geometry attributes
|
|
148
|
+
* result.compressedGeometry - ArrayBuffer with compressed (draco) geometry
|
|
149
|
+
* result.texture - texture image
|
|
150
|
+
* result.sharedResources - shared resource data object
|
|
151
|
+
* result.meshMaterial - PBR-like material object
|
|
152
|
+
* result.vertexCount - number of vertices in geometry
|
|
153
|
+
* result.attributes - feature attributes
|
|
154
|
+
* result.featureCount - number of features
|
|
155
|
+
*/
|
|
156
|
+
private _convertResources;
|
|
157
|
+
/**
|
|
158
|
+
* Create a new node object (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/node.cmn.md)
|
|
159
|
+
* in node pages (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodePage.cmn.md)
|
|
160
|
+
* @param maxScreenThresholdSQ - Level of Details (LOD) metric
|
|
161
|
+
* @param boundingVolumes - Bounding volumes
|
|
162
|
+
* @param sourceTile - source tile (3DTile)
|
|
163
|
+
* @param parentId - id of parent node in node pages
|
|
164
|
+
* @param resources - the node resources data
|
|
165
|
+
* @param resources.meshMaterial - PBR-like material object
|
|
166
|
+
* @param resources.texture - texture image
|
|
167
|
+
* @param resources.vertexCount - number of vertices in geometry
|
|
168
|
+
* @param resources.featureCount - number of features
|
|
169
|
+
* @return the node object in node pages
|
|
170
|
+
*/
|
|
171
|
+
private _createNodeInNodePages;
|
|
172
|
+
/**
|
|
173
|
+
* Create a new node page object in node pages
|
|
174
|
+
* @param parentNode - 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object of the parent node
|
|
175
|
+
* @param boundingVolumes - Bounding volumes
|
|
176
|
+
* @param lodSelection - Level of Details (LOD) metrics
|
|
177
|
+
* @param nodeInPage - corresponding node object in a node page
|
|
178
|
+
* @param resources - the node resources data
|
|
179
|
+
* @param resources.texture - texture image
|
|
180
|
+
* @param resources.attributes - feature attributes
|
|
181
|
+
* @return 3DNodeIndexDocument https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md object
|
|
182
|
+
*/
|
|
183
|
+
private _createNodeIndexDocument;
|
|
184
|
+
/**
|
|
185
|
+
* Write node resources in files
|
|
186
|
+
* @param resources - source tile (3DTile)
|
|
187
|
+
* @param resources.geometry - Uint8Array with geometry attributes
|
|
188
|
+
* @param resources.compressedGeometry - Uint8Array with compressed (draco) geometry
|
|
189
|
+
* @param resources.texture - texture image
|
|
190
|
+
* @param resources.sharedResources - shared resource data object
|
|
191
|
+
* @param resources.attributes - feature attributes
|
|
192
|
+
* @return {Promise<void>}
|
|
193
|
+
*/
|
|
194
|
+
private _writeResources;
|
|
195
|
+
/**
|
|
196
|
+
* Write non-compressed and compressed geometries in files
|
|
197
|
+
* @param geometryBuffer - Uint8Array with geometry attributes
|
|
198
|
+
* @param compressedGeometry - Uint8Array with compressed (draco) geometry
|
|
199
|
+
* @param childPath - a child path to write resources
|
|
200
|
+
* @param slpkChildPath - resource path inside *slpk file
|
|
201
|
+
*/
|
|
202
|
+
private _writeGeometries;
|
|
203
|
+
/**
|
|
204
|
+
* Write shared resources in a file
|
|
205
|
+
* @param sharedResources - shared resource data object
|
|
206
|
+
* @param childPath - a child path to write resources
|
|
207
|
+
* @param slpkChildPath - resource path inside *slpk file
|
|
208
|
+
* @param nodePath - a node path
|
|
209
|
+
*/
|
|
210
|
+
private _writeShared;
|
|
211
|
+
/**
|
|
212
|
+
* Generates textures based on texture mime type and fill in textureSetDefinitions data.
|
|
213
|
+
* @param texture - the texture image
|
|
214
|
+
* @param childPath - a child path to write resources
|
|
215
|
+
* @param slpkChildPath - the resource path inside *slpk file
|
|
216
|
+
*/
|
|
217
|
+
private _writeTexture;
|
|
218
|
+
/**
|
|
219
|
+
* Write the texture image in a file
|
|
220
|
+
* @param textureData
|
|
221
|
+
* @param name
|
|
222
|
+
* @param format
|
|
223
|
+
* @param childPath
|
|
224
|
+
* @param slpkChildPath
|
|
225
|
+
*/
|
|
226
|
+
private writeTextureFile;
|
|
227
|
+
/**
|
|
228
|
+
* Write feature attributes in files
|
|
229
|
+
* @param attributes - feature attributes
|
|
230
|
+
* @param childPath - a child path to write resources
|
|
231
|
+
* @param slpkChildPath - the resource path inside *slpk file
|
|
232
|
+
*/
|
|
233
|
+
private _writeAttributes;
|
|
234
|
+
/**
|
|
235
|
+
* Return file format by its MIME type
|
|
236
|
+
* @param mimeType - feature attributes
|
|
237
|
+
*/
|
|
238
|
+
private _getFormatByMimeType;
|
|
239
|
+
/**
|
|
240
|
+
* Find or create material in materialDefinitions array
|
|
241
|
+
* @param material - end-to-end index of the node
|
|
242
|
+
* @return material id
|
|
243
|
+
*/
|
|
244
|
+
private _findOrCreateMaterial;
|
|
245
|
+
/**
|
|
246
|
+
* Generate storage attribute for map segmentation.
|
|
247
|
+
* @param attributeIndex - order index of attribute (f_0, f_1 ...).
|
|
248
|
+
* @param key - attribute key from batch table.\
|
|
249
|
+
* @param attributeType - attribute type.
|
|
250
|
+
* @return Updated storageAttribute.
|
|
251
|
+
*/
|
|
252
|
+
private _createdStorageAttribute;
|
|
253
|
+
/**
|
|
254
|
+
* Get the attribute type for attributeStorageInfo https://github.com/Esri/i3s-spec/blob/master/docs/1.7/attributeStorageInfo.cmn.md
|
|
255
|
+
* @param key - attribute's key
|
|
256
|
+
* @param attribute - attribute's type in batchTable
|
|
257
|
+
*/
|
|
258
|
+
private getAttributeType;
|
|
259
|
+
/**
|
|
260
|
+
* Setup storage attribute as string.
|
|
261
|
+
* @param storageAttribute - attribute for map segmentation.
|
|
262
|
+
*/
|
|
263
|
+
private _setupStringAttribute;
|
|
264
|
+
/**
|
|
265
|
+
* Setup Id attribute for map segmentation.
|
|
266
|
+
* @param storageAttribute - attribute for map segmentation .
|
|
267
|
+
*/
|
|
268
|
+
private _setupIdAttribute;
|
|
269
|
+
/**
|
|
270
|
+
* Setup double attribute for map segmentation.
|
|
271
|
+
* @param storageAttribute - attribute for map segmentation .
|
|
272
|
+
*/
|
|
273
|
+
private _setupDoubleAttribute;
|
|
274
|
+
/**
|
|
275
|
+
* Setup field attribute for map segmentation.
|
|
276
|
+
* @param key - attribute for map segmentation.
|
|
277
|
+
* @param fieldAttributeType - esri attribute type ('esriFieldTypeString' or 'esriFieldTypeOID').
|
|
278
|
+
*/
|
|
279
|
+
private _createFieldAttribute;
|
|
280
|
+
/**
|
|
281
|
+
* Do conversion of 3DTiles batch table to I3s node attributes.
|
|
282
|
+
* @param batchTable - Table with layer meta data.
|
|
283
|
+
*/
|
|
284
|
+
private _convertBatchTableInfoToNodeAttributes;
|
|
285
|
+
/**
|
|
286
|
+
* Find and return attribute type based on key form Batch table.
|
|
287
|
+
* @param attributeType
|
|
288
|
+
*/
|
|
289
|
+
private _getFieldAttributeType;
|
|
290
|
+
/**
|
|
291
|
+
* Generate popup info to show metadata on the map.
|
|
292
|
+
* @param batchTable - Batch table data with OBJECTID.
|
|
293
|
+
* @return data for correct rendering of popup.
|
|
294
|
+
*/
|
|
295
|
+
private _createPopupInfo;
|
|
296
|
+
/**
|
|
297
|
+
* Print statistics in the end of conversion
|
|
298
|
+
* @param params - output files data
|
|
299
|
+
*/
|
|
300
|
+
private _finishConversion;
|
|
301
|
+
/**
|
|
302
|
+
* Fetch preload options for ION tileset
|
|
303
|
+
*/
|
|
304
|
+
private _fetchPreloadOptions;
|
|
305
|
+
/**
|
|
306
|
+
* Update options of source tileset
|
|
307
|
+
*/
|
|
308
|
+
private _updateTilesetOptions;
|
|
309
|
+
/** Do calculations of all tiles and tiles with "ADD" type of refinement.
|
|
310
|
+
* @param tile
|
|
311
|
+
*/
|
|
312
|
+
private _checkAddRefinementTypeForTile;
|
|
313
|
+
/**
|
|
314
|
+
* Check if the tile's content format is supported by the converter
|
|
315
|
+
* @param sourceRootTile
|
|
316
|
+
* @returns
|
|
317
|
+
*/
|
|
318
|
+
private isContentSupported;
|
|
319
|
+
}
|
|
320
|
+
//# sourceMappingURL=i3s-converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,YAAY,EAab,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAE5C,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAOrC,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAuB7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAC,qBAAqB,EAA8B,MAAM,2BAA2B,CAAC;AAmB7F;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAC;IACjC,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC3B,m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