@loaders.gl/tile-converter 3.3.0-alpha.2 → 3.3.0-alpha.4
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/3d-tiles-converter/3d-tiles-converter.d.ts +8 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +57 -43
- package/dist/converter.min.js +21 -21
- package/dist/deps-installer/deps-installer.d.ts +5 -1
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +21 -1
- package/dist/dist.min.js +671 -1028
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +115 -101
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +70 -6
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +1 -1
- package/dist/es5/i3s-attributes-worker.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +4 -0
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/feature-attributes.js +153 -0
- package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +40 -44
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +55 -36
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-pages.js +10 -2
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +364 -435
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +59 -44
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +21 -2
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +4 -0
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/feature-attributes.js +138 -0
- package/dist/esm/i3s-converter/helpers/feature-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +19 -21
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +55 -36
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-pages.js +9 -2
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +93 -183
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/i3s-attributes-worker.d.ts +5 -1
- package/dist/i3s-attributes-worker.d.ts.map +1 -1
- package/dist/i3s-attributes-worker.js +3 -3
- package/dist/i3s-attributes-worker.js.map +2 -2
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +2 -3
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +3 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +2 -2
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.d.ts +32 -0
- package/dist/i3s-converter/helpers/feature-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/feature-attributes.js +162 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +5 -4
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +29 -27
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +50 -30
- package/dist/i3s-converter/helpers/node-pages.d.ts +4 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +9 -2
- package/dist/i3s-converter/i3s-converter.d.ts +24 -48
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +88 -186
- package/dist/i3s-converter/types.d.ts +4 -0
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/3d-tiles-converter/3d-tiles-converter.ts +71 -55
- package/src/deps-installer/deps-installer.ts +29 -2
- package/src/i3s-attributes-worker.ts +5 -1
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +13 -6
- package/src/i3s-converter/helpers/coordinate-converter.ts +2 -2
- package/src/i3s-converter/helpers/feature-attributes.ts +182 -0
- package/src/i3s-converter/helpers/geometry-converter.ts +45 -36
- package/src/i3s-converter/helpers/gltf-attributes.ts +54 -33
- package/src/i3s-converter/helpers/node-pages.ts +10 -2
- package/src/i3s-converter/i3s-converter.ts +125 -210
- package/src/i3s-converter/types.ts +4 -0
|
@@ -18,51 +18,70 @@ export function prepareDataForAttributesConversion(tileContent) {
|
|
|
18
18
|
}));
|
|
19
19
|
let nodes = ((_tileContent$gltf2 = tileContent.gltf) === null || _tileContent$gltf2 === void 0 ? void 0 : (_tileContent$gltf2$sc = _tileContent$gltf2.scene) === null || _tileContent$gltf2$sc === void 0 ? void 0 : _tileContent$gltf2$sc.nodes) || ((_tileContent$gltf3 = tileContent.gltf) === null || _tileContent$gltf3 === void 0 ? void 0 : (_tileContent$gltf3$sc = _tileContent$gltf3.scenes) === null || _tileContent$gltf3$sc === void 0 ? void 0 : (_tileContent$gltf3$sc2 = _tileContent$gltf3$sc[0]) === null || _tileContent$gltf3$sc2 === void 0 ? void 0 : _tileContent$gltf3$sc2.nodes) || ((_tileContent$gltf4 = tileContent.gltf) === null || _tileContent$gltf4 === void 0 ? void 0 : _tileContent$gltf4.nodes) || [];
|
|
20
20
|
const images = ((_tileContent$gltf5 = tileContent.gltf) === null || _tileContent$gltf5 === void 0 ? void 0 : (_tileContent$gltf5$im = _tileContent$gltf5.images) === null || _tileContent$gltf5$im === void 0 ? void 0 : _tileContent$gltf5$im.map(imageObject => {
|
|
21
|
-
var _imageObject$image
|
|
21
|
+
var _imageObject$image;
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
mimeType: imageObject.mimeType
|
|
31
|
-
};
|
|
32
|
-
})) || [];
|
|
33
|
-
const prepearedNodes = nodes.map(node => {
|
|
34
|
-
var _node$mesh;
|
|
23
|
+
if (imageObject !== null && imageObject !== void 0 && (_imageObject$image = imageObject.image) !== null && _imageObject$image !== void 0 && _imageObject$image.compressed) {
|
|
24
|
+
return {
|
|
25
|
+
data: null,
|
|
26
|
+
compressed: true
|
|
27
|
+
};
|
|
28
|
+
} else {
|
|
29
|
+
var _imageObject$image2;
|
|
35
30
|
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
const data = imageObject === null || imageObject === void 0 ? void 0 : (_imageObject$image2 = imageObject.image) === null || _imageObject$image2 === void 0 ? void 0 : _imageObject$image2.data;
|
|
32
|
+
const dataCopy = new Uint8Array(data.length);
|
|
33
|
+
dataCopy.set(data);
|
|
34
|
+
return {
|
|
35
|
+
data: dataCopy,
|
|
36
|
+
compressed: false,
|
|
37
|
+
height: imageObject.image.height,
|
|
38
|
+
width: imageObject.image.width,
|
|
39
|
+
components: imageObject.image.components,
|
|
40
|
+
mimeType: imageObject.mimeType
|
|
41
|
+
};
|
|
38
42
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
images,
|
|
42
|
-
mesh: { ...node.mesh,
|
|
43
|
-
primitives: (_node$mesh = node.mesh) === null || _node$mesh === void 0 ? void 0 : _node$mesh.primitives.map(primitive => {
|
|
44
|
-
var _primitive$indices, _primitive$material;
|
|
45
|
-
|
|
46
|
-
return { ...primitive,
|
|
47
|
-
indices: {
|
|
48
|
-
value: primitive === null || primitive === void 0 ? void 0 : (_primitive$indices = primitive.indices) === null || _primitive$indices === void 0 ? void 0 : _primitive$indices.value
|
|
49
|
-
},
|
|
50
|
-
attributes: getB3DMAttributesWithoutBufferView(primitive.attributes),
|
|
51
|
-
material: {
|
|
52
|
-
id: primitive === null || primitive === void 0 ? void 0 : (_primitive$material = primitive.material) === null || _primitive$material === void 0 ? void 0 : _primitive$material.id
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
});
|
|
43
|
+
})) || [];
|
|
44
|
+
prepareNodes(nodes);
|
|
59
45
|
const cartographicOrigin = tileContent.cartographicOrigin;
|
|
60
46
|
const cartesianModelMatrix = tileContent.cartesianModelMatrix;
|
|
61
47
|
return {
|
|
62
48
|
gltfMaterials,
|
|
63
|
-
nodes
|
|
49
|
+
nodes,
|
|
50
|
+
images,
|
|
64
51
|
cartographicOrigin,
|
|
65
52
|
cartesianModelMatrix
|
|
66
53
|
};
|
|
67
54
|
}
|
|
55
|
+
|
|
56
|
+
function prepareNodes(nodes) {
|
|
57
|
+
for (let index = 0; index < nodes.length; index++) {
|
|
58
|
+
const node = nodes[index];
|
|
59
|
+
|
|
60
|
+
if (node.mesh) {
|
|
61
|
+
var _node$mesh;
|
|
62
|
+
|
|
63
|
+
nodes[index] = { ...node,
|
|
64
|
+
mesh: { ...node.mesh,
|
|
65
|
+
primitives: (_node$mesh = node.mesh) === null || _node$mesh === void 0 ? void 0 : _node$mesh.primitives.map(primitive => {
|
|
66
|
+
var _primitive$indices, _primitive$material;
|
|
67
|
+
|
|
68
|
+
return { ...primitive,
|
|
69
|
+
indices: {
|
|
70
|
+
value: primitive === null || primitive === void 0 ? void 0 : (_primitive$indices = primitive.indices) === null || _primitive$indices === void 0 ? void 0 : _primitive$indices.value
|
|
71
|
+
},
|
|
72
|
+
attributes: getB3DMAttributesWithoutBufferView(primitive.attributes),
|
|
73
|
+
material: {
|
|
74
|
+
id: primitive === null || primitive === void 0 ? void 0 : (_primitive$material = primitive.material) === null || _primitive$material === void 0 ? void 0 : _primitive$material.id
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (node.children) {
|
|
83
|
+
prepareNodes(node.children);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
68
87
|
//# sourceMappingURL=gltf-attributes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/i3s-converter/helpers/gltf-attributes.ts"],"names":["getB3DMAttributesWithoutBufferView","attributes","attributesWithoutBufferView","attributeName","value","prepareDataForAttributesConversion","tileContent","gltfMaterials","gltf","materials","map","material","id","nodes","scene","scenes","images","imageObject","data","
|
|
1
|
+
{"version":3,"sources":["../../../../src/i3s-converter/helpers/gltf-attributes.ts"],"names":["getB3DMAttributesWithoutBufferView","attributes","attributesWithoutBufferView","attributeName","value","prepareDataForAttributesConversion","tileContent","gltfMaterials","gltf","materials","map","material","id","nodes","scene","scenes","images","imageObject","image","compressed","data","dataCopy","Uint8Array","length","set","height","width","components","mimeType","prepareNodes","cartographicOrigin","cartesianModelMatrix","index","node","mesh","primitives","primitive","indices","children"],"mappings":"AAYA,SAASA,kCAAT,CAA4CC,UAA5C,EAA4F;AAC1F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,OAAb,uDAAE,mBAAoBjC;AAA5B,eAF2C;AAGpDH,cAAAA,UAAU,EAAED,kCAAkC,CAACoC,SAAS,CAACnC,UAAX,CAHM;AAIpDU,cAAAA,QAAQ,EAAE;AACRC,gBAAAA,EAAE,EAAEwB,SAAF,aAAEA,SAAF,8CAAEA,SAAS,CAAEzB,QAAb,wDAAE,oBAAqBC;AADjB;AAJ0C,aAAhB;AAAA,WAA1B;AAFR;AAFO,OAAf;AAcD;;AAED,QAAIqB,IAAI,CAACK,QAAT,EAAmB;AACjBT,MAAAA,YAAY,CAACI,IAAI,CAACK,QAAN,CAAZ;AACD;AACF;AACF","sourcesContent":["import type {B3DMContent} from '@loaders.gl/3d-tiles';\nimport type {GLTFAccessorPostprocessed, GLTFNodePostprocessed} from '@loaders.gl/gltf';\nimport type {B3DMAttributesData} from '../../i3s-attributes-worker';\n\ntype AttributesObject = {\n [k: string]: GLTFAccessorPostprocessed;\n};\n\n/**\n * Keep only values for B3DM attributes to pass data to worker thread.\n * @param attributes\n */\nfunction getB3DMAttributesWithoutBufferView(attributes: AttributesObject): AttributesObject {\n const attributesWithoutBufferView = {};\n\n for (const attributeName in attributes) {\n attributesWithoutBufferView[attributeName] = {\n value: attributes[attributeName].value\n };\n }\n\n return attributesWithoutBufferView;\n}\n\n/**\n * Prepare attributes for conversion to avoid binary data breaking in worker thread.\n * @param tileContent\n * @returns\n */\nexport function prepareDataForAttributesConversion(tileContent: B3DMContent): B3DMAttributesData {\n const gltfMaterials = tileContent.gltf?.materials?.map((material) => ({id: material.id}));\n let nodes =\n tileContent.gltf?.scene?.nodes ||\n tileContent.gltf?.scenes?.[0]?.nodes ||\n tileContent.gltf?.nodes ||\n [];\n\n const images =\n tileContent.gltf?.images?.map((imageObject) => {\n // Need data only for uncompressed images because we can't get batchIds from compressed textures.\n if (imageObject?.image?.compressed) {\n return {\n data: null,\n compressed: true\n };\n } else {\n const data = imageObject?.image?.data;\n const dataCopy = new Uint8Array(data.length);\n dataCopy.set(data);\n return {\n data: dataCopy,\n compressed: false,\n height: imageObject.image.height,\n width: imageObject.image.width,\n components: imageObject.image.components,\n mimeType: imageObject.mimeType\n };\n }\n }) || [];\n\n prepareNodes(nodes);\n\n const cartographicOrigin = tileContent.cartographicOrigin;\n const cartesianModelMatrix = tileContent.cartesianModelMatrix;\n\n return {\n gltfMaterials,\n nodes,\n images,\n cartographicOrigin,\n cartesianModelMatrix\n };\n}\n\n/**\n * Traverse all nodes to replace all sensible data with copy to avoid data corruption in worker.\n * @param nodes\n */\nfunction prepareNodes(nodes: GLTFNodePostprocessed[]): void {\n for (let index = 0; index < nodes.length; index++) {\n const node = nodes[index] as any;\n\n if (node.mesh) {\n nodes[index] = {\n ...node,\n mesh: {\n ...node.mesh,\n primitives: node.mesh?.primitives.map((primitive) => ({\n ...primitive,\n indices: {value: primitive?.indices?.value},\n attributes: getB3DMAttributesWithoutBufferView(primitive.attributes),\n material: {\n id: primitive?.material?.id\n }\n }))\n }\n };\n }\n\n if (node.children) {\n prepareNodes(node.children);\n }\n }\n}\n"],"file":"gltf-attributes.js"}
|
|
@@ -29,6 +29,13 @@ export default class NodePages {
|
|
|
29
29
|
return this.nodePages[pageIndex].nodes[nodeIndex];
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
updateAll(id, data) {
|
|
33
|
+
const node = this.getNodeById(id);
|
|
34
|
+
Object.assign(node, data, {
|
|
35
|
+
index: node.index
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
32
39
|
updateMaterialByNodeId(id, materialId) {
|
|
33
40
|
const node = this.getNodeById(id);
|
|
34
41
|
|
|
@@ -55,7 +62,7 @@ export default class NodePages {
|
|
|
55
62
|
updateNodeAttributeByNodeId(id) {
|
|
56
63
|
const node = this.getNodeById(id);
|
|
57
64
|
|
|
58
|
-
if (!node.mesh) {
|
|
65
|
+
if (!node.mesh || !node.index) {
|
|
59
66
|
return;
|
|
60
67
|
}
|
|
61
68
|
|
|
@@ -94,7 +101,7 @@ export default class NodePages {
|
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
updateResourceInMesh(node) {
|
|
97
|
-
if (node.mesh) {
|
|
104
|
+
if (node.mesh && isFinite(node.index)) {
|
|
98
105
|
node.mesh.geometry.resource = node.index;
|
|
99
106
|
}
|
|
100
107
|
}
|
|
@@ -1 +1 @@
|
|
|
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","writeQueue","slpk","nodePage","entries","nodePageStr","JSON","stringify","slpkPath","enqueue","archiveKey","toString","writePromise","metadata","nodeCount","compress","nodePagePath"],"mappings":";AAEA,SAAQA,IAAR,QAAmB,MAAnB;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,SAAQC,QAAQ,IAAIC,gBAApB,QAA2C,4BAA3C;AAqCA,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;;AA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X,IAAgC,KAAK1C,SAAL,CAAe2C,OAAf,EAAhC,EAA0D;AACxD,cAAMC,WAAW,GAAGC,IAAI,CAACC,SAAL,CAAeJ,QAAf,CAApB;AACA,cAAMa,YAAY,GAAGhE,IAAI,CAACgD,WAAD,EAAc,WAAd,EAA2BrB,KAAK,CAACgC,QAAN,EAA3B,CAAzB;AACA,cAAMV,UAAU,CAACQ,OAAX,CAAmB;AAACG,UAAAA,YAAY,EAAE,KAAKjD,SAAL,CAAeqD,YAAf,EAA6BX,WAA7B;AAAf,SAAnB,CAAN;AACD;AACF;AACF;;AA5L4B","sourcesContent":["import type {WriteQueueItem} from '../../lib/utils/write-queue';\n\nimport {join} from 'path';\nimport transform from 'json-map-transform';\nimport {METADATA as metadataTemplate} from '../json-templates/metadata';\nimport {NodeInPage} from '@loaders.gl/i3s';\nimport WriteQueue from '../../lib/utils/write-queue';\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 layers0Path - path of layer\n * @param writeQueue - write queue that controlls files write concurrency\n * @param slpk\n */\n async save(\n layers0Path: string,\n writeQueue: WriteQueue<WriteQueueItem>,\n slpk: boolean = false\n ): Promise<void> {\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 await writeQueue.enqueue({\n archiveKey: `nodePages/${index.toString()}.json.gz`,\n writePromise: this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`)\n });\n }\n const metadata = transform({nodeCount: this.nodesCounter}, metadataTemplate());\n const compress = false;\n await writeQueue.enqueue({\n archiveKey: 'metadata.json',\n writePromise: this.writeFile(\n layers0Path,\n JSON.stringify(metadata),\n 'metadata.json',\n compress\n )\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 await writeQueue.enqueue({writePromise: this.writeFile(nodePagePath, nodePageStr)});\n }\n }\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","updateAll","data","node","Object","assign","index","updateMaterialByNodeId","materialId","mesh","material","definition","resource","updateVertexCountByNodeId","vertexCount","geometry","updateNodeAttributeByNodeId","attribute","updateFeatureCountByNodeId","featureCount","updateTexelCountHintByNodeId","texelCountHint","addChildRelation","parentId","childId","undefined","parentNode","children","push","updateResourceInMesh","isFinite","currentNodePage","length","save","layers0Path","writeQueue","slpk","nodePage","entries","nodePageStr","JSON","stringify","slpkPath","enqueue","archiveKey","toString","writePromise","metadata","nodeCount","compress","nodePagePath"],"mappings":";AAEA,SAAQA,IAAR,QAAmB,MAAnB;AACA,OAAOC,SAAP,MAAsB,oBAAtB;AACA,SAAQC,QAAQ,IAAIC,gBAApB,QAA2C,4BAA3C;AAqCA,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,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AACA,YAAMd,UAAU,CAACQ,OAAX,CAAmB;AACvBC,QAAAA,UAAU,EAAE,eADW;AAEvBE,QAAAA,YAAY,EAAE,KAAKtD,SAAL,CACZ0C,WADY,EAEZM,IAAI,CAACC,SAAL,CAAeM,QAAf,CAFY,EAGZ,eAHY,EAIZE,QAJY;AAFS,OAAnB,CAAN;AASD,KApBD,MAoBO;AACL,WAAK,MAAM,CAAC3C,KAAD,EAAQ+B,QAAR,CAAX,IAAgC,KAAK/C,SAAL,CAAegD,OAAf,EAAhC,EAA0D;AACxD,cAAMC,WAAW,GAAGC,IAAI,CAACC,SAAL,CAAeJ,QAAf,CAApB;AACA,cAAMa,YAAY,GAAGrE,IAAI,CAACqD,WAAD,EAAc,WAAd,EAA2B5B,KAAK,CAACuC,QAAN,EAA3B,CAAzB;AACA,cAAMV,UAAU,CAACQ,OAAX,CAAmB;AAACG,UAAAA,YAAY,EAAE,KAAKtD,SAAL,CAAe0D,YAAf,EAA6BX,WAA7B;AAAf,SAAnB,CAAN;AACD;AACF;AACF;;AApM4B","sourcesContent":["import type {WriteQueueItem} from '../../lib/utils/write-queue';\n\nimport {join} from 'path';\nimport transform from 'json-map-transform';\nimport {METADATA as metadataTemplate} from '../json-templates/metadata';\nimport {NodeInPage} from '@loaders.gl/i3s';\nimport WriteQueue from '../../lib/utils/write-queue';\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 all fields in the node excluding id\n */\n updateAll(id: number, data: NodeInPage): void {\n const node = this.getNodeById(id);\n Object.assign(node, data, {index: node.index});\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 || !node.index) {\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 && isFinite(node.index)) {\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 layers0Path - path of layer\n * @param writeQueue - write queue that controlls files write concurrency\n * @param slpk\n */\n async save(\n layers0Path: string,\n writeQueue: WriteQueue<WriteQueueItem>,\n slpk: boolean = false\n ): Promise<void> {\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 await writeQueue.enqueue({\n archiveKey: `nodePages/${index.toString()}.json.gz`,\n writePromise: this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`)\n });\n }\n const metadata = transform({nodeCount: this.nodesCounter}, metadataTemplate());\n const compress = false;\n await writeQueue.enqueue({\n archiveKey: 'metadata.json',\n writePromise: this.writeFile(\n layers0Path,\n JSON.stringify(metadata),\n 'metadata.json',\n compress\n )\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 await writeQueue.enqueue({writePromise: this.writeFile(nodePagePath, nodePageStr)});\n }\n }\n }\n}\n"],"file":"node-pages.js"}
|
|
@@ -30,14 +30,11 @@ import { DracoWriterWorker } from '@loaders.gl/draco';
|
|
|
30
30
|
import WriteQueue from '../lib/utils/write-queue';
|
|
31
31
|
import { I3SAttributesWorker } from '../i3s-attributes-worker';
|
|
32
32
|
import { BROWSER_ERROR_MESSAGE } from '../constants';
|
|
33
|
+
import { createdStorageAttribute, createFieldAttribute, createPopupInfo, getAttributeType, getFieldAttributeType } from './helpers/feature-attributes';
|
|
33
34
|
const ION_DEFAULT_TOKEN = ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.IonToken) || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ';
|
|
34
35
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
35
36
|
const _3D_TILES = '3DTILES';
|
|
36
37
|
const _3D_OBJECT_LAYER_TYPE = '3DObject';
|
|
37
|
-
const STRING_TYPE = 'string';
|
|
38
|
-
const SHORT_INT_TYPE = 'Int32';
|
|
39
|
-
const DOUBLE_TYPE = 'double';
|
|
40
|
-
const OBJECT_ID_TYPE = 'OBJECTID';
|
|
41
38
|
const REFRESH_TOKEN_TIMEOUT = 1800;
|
|
42
39
|
const CESIUM_DATASET_PREFIX = 'https://';
|
|
43
40
|
export default class I3SConverter {
|
|
@@ -152,8 +149,17 @@ export default class I3SConverter {
|
|
|
152
149
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
153
150
|
const tilesetOptions = {
|
|
154
151
|
loadOptions: {
|
|
152
|
+
_nodeWorkers: true,
|
|
153
|
+
reuseWorkers: true,
|
|
155
154
|
basis: {
|
|
156
155
|
format: 'rgba32'
|
|
156
|
+
},
|
|
157
|
+
'basis-nodejs': {
|
|
158
|
+
format: 'rgba32',
|
|
159
|
+
workerUrl: './modules/textures/dist/basis-nodejs-worker.js'
|
|
160
|
+
},
|
|
161
|
+
'draco-nodejs': {
|
|
162
|
+
workerUrl: './modules/draco/dist/draco-nodejs-worker.js'
|
|
157
163
|
}
|
|
158
164
|
}
|
|
159
165
|
};
|
|
@@ -344,6 +350,45 @@ export default class I3SConverter {
|
|
|
344
350
|
await this._addNeighborsAndWriteFile(data.parentNode, childNodes);
|
|
345
351
|
}
|
|
346
352
|
|
|
353
|
+
async convertNestedTileset({
|
|
354
|
+
sourceTile,
|
|
355
|
+
parentNode,
|
|
356
|
+
childNodes,
|
|
357
|
+
parentId,
|
|
358
|
+
level
|
|
359
|
+
}) {
|
|
360
|
+
await this.sourceTileset._loadTile(sourceTile);
|
|
361
|
+
await this._addChildren({
|
|
362
|
+
parentNode,
|
|
363
|
+
sourceTiles: sourceTile.children,
|
|
364
|
+
childNodes,
|
|
365
|
+
parentId,
|
|
366
|
+
level: level + 1
|
|
367
|
+
});
|
|
368
|
+
await sourceTile.unloadContent();
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
async convertNode({
|
|
372
|
+
sourceTile,
|
|
373
|
+
parentNode,
|
|
374
|
+
childNodes,
|
|
375
|
+
parentId,
|
|
376
|
+
level
|
|
377
|
+
}) {
|
|
378
|
+
const children = await this._createNode(parentNode, sourceTile, parentId, level);
|
|
379
|
+
parentNode.children = parentNode.children || [];
|
|
380
|
+
|
|
381
|
+
for (const child of children) {
|
|
382
|
+
parentNode.children.push({
|
|
383
|
+
id: child.id,
|
|
384
|
+
href: "../".concat(child.path),
|
|
385
|
+
obb: child.obb,
|
|
386
|
+
mbs: child.mbs
|
|
387
|
+
});
|
|
388
|
+
childNodes.push(child);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
347
392
|
async _addChildren(data) {
|
|
348
393
|
const {
|
|
349
394
|
childNodes,
|
|
@@ -357,32 +402,29 @@ export default class I3SConverter {
|
|
|
357
402
|
return;
|
|
358
403
|
}
|
|
359
404
|
|
|
405
|
+
const promises = [];
|
|
406
|
+
|
|
360
407
|
for (const sourceTile of sourceTiles) {
|
|
361
408
|
if (sourceTile.type === 'json') {
|
|
362
|
-
|
|
363
|
-
|
|
409
|
+
promises.push(this.convertNestedTileset({
|
|
410
|
+
sourceTile,
|
|
364
411
|
parentNode,
|
|
365
|
-
sourceTiles: sourceTile.children,
|
|
366
412
|
childNodes,
|
|
367
413
|
parentId,
|
|
368
|
-
level
|
|
369
|
-
});
|
|
370
|
-
await sourceTile.unloadContent();
|
|
414
|
+
level
|
|
415
|
+
}));
|
|
371
416
|
} else {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
obb: child.obb,
|
|
380
|
-
mbs: child.mbs
|
|
381
|
-
});
|
|
382
|
-
childNodes.push(child);
|
|
383
|
-
}
|
|
417
|
+
promises.push(this.convertNode({
|
|
418
|
+
sourceTile,
|
|
419
|
+
parentNode,
|
|
420
|
+
childNodes,
|
|
421
|
+
parentId,
|
|
422
|
+
level
|
|
423
|
+
}));
|
|
384
424
|
}
|
|
385
425
|
|
|
426
|
+
await Promise.all(promises);
|
|
427
|
+
|
|
386
428
|
if (sourceTile.id) {
|
|
387
429
|
console.log(sourceTile.id);
|
|
388
430
|
}
|
|
@@ -428,13 +470,13 @@ export default class I3SConverter {
|
|
|
428
470
|
await this._updateTilesetOptions();
|
|
429
471
|
await this.sourceTileset._loadTile(sourceTile);
|
|
430
472
|
let boundingVolumes = createBoundingVolumes(sourceTile, this.geoidHeightModel);
|
|
431
|
-
const propertyTable = getPropertyTable(sourceTile);
|
|
473
|
+
const propertyTable = getPropertyTable(sourceTile.content);
|
|
432
474
|
|
|
433
475
|
if (propertyTable && !((_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)) {
|
|
434
476
|
this._convertPropertyTableToNodeAttributes(propertyTable);
|
|
435
477
|
}
|
|
436
478
|
|
|
437
|
-
const resourcesData = await this._convertResources(sourceTile, propertyTable);
|
|
479
|
+
const resourcesData = await this._convertResources(sourceTile, parentId, propertyTable);
|
|
438
480
|
const nodes = [];
|
|
439
481
|
const nodesInPage = [];
|
|
440
482
|
const emptyResources = {
|
|
@@ -461,7 +503,7 @@ export default class I3SConverter {
|
|
|
461
503
|
maxError: 0
|
|
462
504
|
};
|
|
463
505
|
|
|
464
|
-
const nodeInPage = this.
|
|
506
|
+
const nodeInPage = this._updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources);
|
|
465
507
|
|
|
466
508
|
const node = this._createNodeIndexDocument(parentTile, boundingVolumes, lodSelection, nodeInPage, resources);
|
|
467
509
|
|
|
@@ -491,18 +533,26 @@ export default class I3SConverter {
|
|
|
491
533
|
return nodes;
|
|
492
534
|
}
|
|
493
535
|
|
|
494
|
-
async _convertResources(sourceTile, propertyTable) {
|
|
536
|
+
async _convertResources(sourceTile, parentId, propertyTable) {
|
|
495
537
|
var _this$layers2;
|
|
496
538
|
|
|
497
539
|
if (!this.isContentSupported(sourceTile)) {
|
|
498
540
|
return null;
|
|
499
541
|
}
|
|
500
542
|
|
|
501
|
-
const
|
|
543
|
+
const draftObb = {
|
|
544
|
+
center: [],
|
|
545
|
+
halfSize: [],
|
|
546
|
+
quaternion: []
|
|
547
|
+
};
|
|
548
|
+
const resourcesData = await convertB3dmToI3sGeometry(sourceTile.content, () => this.nodePages.push({
|
|
549
|
+
index: 0,
|
|
550
|
+
obb: draftObb
|
|
551
|
+
}, parentId), propertyTable, this.featuresHashArray, (_this$layers2 = this.layers0) === null || _this$layers2 === void 0 ? void 0 : _this$layers2.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.geoidHeightModel, this.workerSource);
|
|
502
552
|
return resourcesData;
|
|
503
553
|
}
|
|
504
554
|
|
|
505
|
-
|
|
555
|
+
_updateNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
|
|
506
556
|
const {
|
|
507
557
|
meshMaterial,
|
|
508
558
|
texture,
|
|
@@ -532,7 +582,15 @@ export default class I3SConverter {
|
|
|
532
582
|
};
|
|
533
583
|
}
|
|
534
584
|
|
|
535
|
-
|
|
585
|
+
let nodeId = resources.nodeId;
|
|
586
|
+
|
|
587
|
+
if (nodeId) {
|
|
588
|
+
this.nodePages.updateAll(nodeId, nodeInPage);
|
|
589
|
+
const node = this.nodePages.getNodeById(nodeId);
|
|
590
|
+
this.nodePages.updateResourceInMesh(node);
|
|
591
|
+
} else {
|
|
592
|
+
nodeId = this.nodePages.push(nodeInPage, parentId);
|
|
593
|
+
}
|
|
536
594
|
|
|
537
595
|
if (meshMaterial) {
|
|
538
596
|
this.nodePages.updateMaterialByNodeId(nodeId, this._findOrCreateMaterial(meshMaterial));
|
|
@@ -554,7 +612,7 @@ export default class I3SConverter {
|
|
|
554
612
|
this.nodePages.updateFeatureCountByNodeId(nodeId, featureCount);
|
|
555
613
|
}
|
|
556
614
|
|
|
557
|
-
return
|
|
615
|
+
return this.nodePages.getNodeById(nodeId);
|
|
558
616
|
}
|
|
559
617
|
|
|
560
618
|
_createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources) {
|
|
@@ -815,101 +873,6 @@ export default class I3SConverter {
|
|
|
815
873
|
return newMaterialId;
|
|
816
874
|
}
|
|
817
875
|
|
|
818
|
-
_createdStorageAttribute(attributeIndex, key, attributeType) {
|
|
819
|
-
const storageAttribute = {
|
|
820
|
-
key: "f_".concat(attributeIndex),
|
|
821
|
-
name: key,
|
|
822
|
-
ordering: ['attributeValues'],
|
|
823
|
-
header: [{
|
|
824
|
-
property: 'count',
|
|
825
|
-
valueType: 'UInt32'
|
|
826
|
-
}],
|
|
827
|
-
attributeValues: {
|
|
828
|
-
valueType: 'Int32',
|
|
829
|
-
valuesPerElement: 1
|
|
830
|
-
}
|
|
831
|
-
};
|
|
832
|
-
|
|
833
|
-
switch (attributeType) {
|
|
834
|
-
case OBJECT_ID_TYPE:
|
|
835
|
-
this._setupIdAttribute(storageAttribute);
|
|
836
|
-
|
|
837
|
-
break;
|
|
838
|
-
|
|
839
|
-
case STRING_TYPE:
|
|
840
|
-
this._setupStringAttribute(storageAttribute);
|
|
841
|
-
|
|
842
|
-
break;
|
|
843
|
-
|
|
844
|
-
case DOUBLE_TYPE:
|
|
845
|
-
this._setupDoubleAttribute(storageAttribute);
|
|
846
|
-
|
|
847
|
-
break;
|
|
848
|
-
|
|
849
|
-
case SHORT_INT_TYPE:
|
|
850
|
-
break;
|
|
851
|
-
|
|
852
|
-
default:
|
|
853
|
-
this._setupStringAttribute(storageAttribute);
|
|
854
|
-
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
return storageAttribute;
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
getAttributeType(key, attribute) {
|
|
861
|
-
if (key === OBJECT_ID_TYPE) {
|
|
862
|
-
return OBJECT_ID_TYPE;
|
|
863
|
-
}
|
|
864
|
-
|
|
865
|
-
if (typeof attribute === STRING_TYPE) {
|
|
866
|
-
return STRING_TYPE;
|
|
867
|
-
} else if (typeof attribute === 'number') {
|
|
868
|
-
return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
return STRING_TYPE;
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
_setupStringAttribute(storageAttribute) {
|
|
875
|
-
storageAttribute.ordering.unshift('attributeByteCounts');
|
|
876
|
-
storageAttribute.header.push({
|
|
877
|
-
property: 'attributeValuesByteCount',
|
|
878
|
-
valueType: 'UInt32'
|
|
879
|
-
});
|
|
880
|
-
storageAttribute.attributeValues = {
|
|
881
|
-
valueType: 'String',
|
|
882
|
-
encoding: 'UTF-8',
|
|
883
|
-
valuesPerElement: 1
|
|
884
|
-
};
|
|
885
|
-
storageAttribute.attributeByteCounts = {
|
|
886
|
-
valueType: 'UInt32',
|
|
887
|
-
valuesPerElement: 1
|
|
888
|
-
};
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
_setupIdAttribute(storageAttribute) {
|
|
892
|
-
storageAttribute.attributeValues = {
|
|
893
|
-
valueType: 'Oid32',
|
|
894
|
-
valuesPerElement: 1
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
_setupDoubleAttribute(storageAttribute) {
|
|
899
|
-
storageAttribute.attributeValues = {
|
|
900
|
-
valueType: 'Float64',
|
|
901
|
-
valuesPerElement: 1
|
|
902
|
-
};
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
_createFieldAttribute(key, fieldAttributeType) {
|
|
906
|
-
return {
|
|
907
|
-
name: key,
|
|
908
|
-
type: fieldAttributeType,
|
|
909
|
-
alias: key
|
|
910
|
-
};
|
|
911
|
-
}
|
|
912
|
-
|
|
913
876
|
_convertPropertyTableToNodeAttributes(propertyTable) {
|
|
914
877
|
let attributeIndex = 0;
|
|
915
878
|
const propertyTableWithObjectId = {
|
|
@@ -919,16 +882,11 @@ export default class I3SConverter {
|
|
|
919
882
|
|
|
920
883
|
for (const key in propertyTableWithObjectId) {
|
|
921
884
|
const firstAttribute = propertyTableWithObjectId[key][0];
|
|
922
|
-
const attributeType =
|
|
923
|
-
|
|
924
|
-
const
|
|
925
|
-
|
|
926
|
-
const
|
|
927
|
-
|
|
928
|
-
const fieldAttribute = this._createFieldAttribute(key, fieldAttributeType);
|
|
929
|
-
|
|
930
|
-
const popupInfo = this._createPopupInfo(propertyTableWithObjectId);
|
|
931
|
-
|
|
885
|
+
const attributeType = getAttributeType(key, firstAttribute);
|
|
886
|
+
const storageAttribute = createdStorageAttribute(attributeIndex, key, attributeType);
|
|
887
|
+
const fieldAttributeType = getFieldAttributeType(attributeType);
|
|
888
|
+
const fieldAttribute = createFieldAttribute(key, fieldAttributeType);
|
|
889
|
+
const popupInfo = createPopupInfo(propertyTableWithObjectId);
|
|
932
890
|
this.layers0.attributeStorageInfo.push(storageAttribute);
|
|
933
891
|
this.layers0.fields.push(fieldAttribute);
|
|
934
892
|
this.layers0.popupInfo = popupInfo;
|
|
@@ -937,54 +895,6 @@ export default class I3SConverter {
|
|
|
937
895
|
}
|
|
938
896
|
}
|
|
939
897
|
|
|
940
|
-
_getFieldAttributeType(attributeType) {
|
|
941
|
-
switch (attributeType) {
|
|
942
|
-
case OBJECT_ID_TYPE:
|
|
943
|
-
return 'esriFieldTypeOID';
|
|
944
|
-
|
|
945
|
-
case STRING_TYPE:
|
|
946
|
-
return 'esriFieldTypeString';
|
|
947
|
-
|
|
948
|
-
case SHORT_INT_TYPE:
|
|
949
|
-
return 'esriFieldTypeInteger';
|
|
950
|
-
|
|
951
|
-
case DOUBLE_TYPE:
|
|
952
|
-
return 'esriFieldTypeDouble';
|
|
953
|
-
|
|
954
|
-
default:
|
|
955
|
-
return 'esriFieldTypeString';
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
_createPopupInfo(propertyTable) {
|
|
960
|
-
const title = '{OBJECTID}';
|
|
961
|
-
const mediaInfos = [];
|
|
962
|
-
const fieldInfos = [];
|
|
963
|
-
const popupElements = [];
|
|
964
|
-
const expressionInfos = [];
|
|
965
|
-
|
|
966
|
-
for (const key in propertyTable) {
|
|
967
|
-
fieldInfos.push({
|
|
968
|
-
fieldName: key,
|
|
969
|
-
visible: true,
|
|
970
|
-
isEditable: false,
|
|
971
|
-
label: key
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
popupElements.push({
|
|
976
|
-
fieldInfos,
|
|
977
|
-
type: 'fields'
|
|
978
|
-
});
|
|
979
|
-
return {
|
|
980
|
-
title,
|
|
981
|
-
mediaInfos,
|
|
982
|
-
popupElements,
|
|
983
|
-
fieldInfos,
|
|
984
|
-
expressionInfos
|
|
985
|
-
};
|
|
986
|
-
}
|
|
987
|
-
|
|
988
898
|
async _finishConversion(params) {
|
|
989
899
|
const {
|
|
990
900
|
tilesCount,
|