@loaders.gl/tile-converter 3.2.0-alpha.1 → 3.2.0-alpha.2
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.d.ts +28 -0
- package/dist/3d-tiles-attributes-worker.d.ts.map +1 -0
- package/dist/3d-tiles-attributes-worker.js +4 -0
- package/dist/3d-tiles-attributes-worker.js.map +7 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +4 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +29 -3
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +5 -4
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +10 -10
- package/dist/converter.min.js +20 -20
- package/dist/dist.min.js +789 -645
- package/dist/es5/3d-tiles-attributes-worker.js +29 -0
- package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +102 -43
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +21 -23
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +29 -0
- package/dist/es5/i3s-attributes-worker.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +19 -11
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +2 -2
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +267 -178
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +71 -0
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/node-pages.js +47 -99
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +230 -195
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/index.js +8 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/utils/compress-util.js +14 -17
- package/dist/es5/lib/utils/compress-util.js.map +1 -1
- package/dist/es5/lib/utils/file-utils.js +39 -14
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/lib/utils/queue.js +61 -0
- package/dist/es5/lib/utils/queue.js.map +1 -0
- package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
- package/dist/es5/lib/utils/write-queue.js +225 -0
- package/dist/es5/lib/utils/write-queue.js.map +1 -0
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/es5/workers/3d-tiles-attributes-worker.js +37 -0
- package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/es5/workers/i3s-attributes-worker.js +40 -0
- package/dist/es5/workers/i3s-attributes-worker.js.map +1 -0
- package/dist/esm/3d-tiles-attributes-worker.js +16 -0
- package/dist/esm/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +30 -4
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +16 -18
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +16 -0
- package/dist/esm/i3s-attributes-worker.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js +19 -11
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js +2 -2
- package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +117 -58
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +54 -0
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/node-pages.js +12 -4
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +105 -28
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/utils/compress-util.js +6 -8
- package/dist/esm/lib/utils/compress-util.js.map +1 -1
- package/dist/esm/lib/utils/file-utils.js +11 -1
- package/dist/esm/lib/utils/file-utils.js.map +1 -1
- package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/esm/lib/utils/queue.js +19 -0
- package/dist/esm/lib/utils/queue.js.map +1 -0
- package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
- package/dist/esm/lib/utils/write-queue.js +88 -0
- package/dist/esm/lib/utils/write-queue.js.map +1 -0
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/workers/3d-tiles-attributes-worker.js +5 -0
- package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
- package/dist/esm/workers/i3s-attributes-worker.js +4 -0
- package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
- package/dist/i3s-attributes-worker.d.ts +33 -0
- package/dist/i3s-attributes-worker.d.ts.map +1 -0
- package/dist/i3s-attributes-worker.js +10 -0
- package/dist/i3s-attributes-worker.js.map +7 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +7 -7
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +25 -21
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +2 -2
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-attributes.js +2 -1
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +28 -11
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +220 -110
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +9 -0
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/gltf-attributes.js +56 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts +6 -5
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-pages.js +13 -8
- package/dist/i3s-converter/i3s-converter.d.ts +7 -3
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +88 -26
- package/dist/i3s-converter/types.d.ts +83 -8
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/utils/compress-util.d.ts +44 -5
- package/dist/lib/utils/compress-util.d.ts.map +1 -1
- package/dist/lib/utils/compress-util.js +73 -6
- package/dist/lib/utils/file-utils.d.ts +34 -5
- package/dist/lib/utils/file-utils.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.js +40 -1
- package/dist/lib/utils/lod-conversion-utils.d.ts +25 -4
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
- package/dist/lib/utils/lod-conversion-utils.js +21 -2
- package/dist/lib/utils/queue.d.ts +7 -0
- package/dist/lib/utils/queue.d.ts.map +1 -0
- package/dist/lib/utils/queue.js +18 -0
- package/dist/lib/utils/statistic-utills.d.ts +2 -2
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
- package/dist/lib/utils/write-queue.d.ts +22 -0
- package/dist/lib/utils/write-queue.d.ts.map +1 -0
- package/dist/lib/utils/write-queue.js +62 -0
- package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
- package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
- package/dist/workers/3d-tiles-attributes-worker.js +9 -0
- package/dist/workers/i3s-attributes-worker.d.ts +2 -0
- package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
- package/dist/workers/i3s-attributes-worker.js +5 -0
- package/package.json +20 -17
- package/src/3d-tiles-attributes-worker.ts +43 -0
- package/src/3d-tiles-converter/3d-tiles-converter.ts +44 -4
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +15 -13
- package/src/i3s-attributes-worker.ts +46 -0
- package/src/i3s-converter/helpers/coordinate-converter.ts +29 -24
- package/src/i3s-converter/helpers/geometry-attributes.ts +4 -3
- package/src/i3s-converter/helpers/{geometry-converter.js → geometry-converter.ts} +421 -175
- package/src/i3s-converter/helpers/gltf-attributes.ts +68 -0
- package/src/i3s-converter/helpers/node-pages.ts +25 -17
- package/src/i3s-converter/i3s-converter.ts +112 -69
- package/src/i3s-converter/types.ts +90 -8
- package/src/index.ts +1 -0
- package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
- package/src/lib/utils/file-utils.ts +84 -0
- package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +27 -5
- package/src/lib/utils/queue.ts +17 -0
- package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
- package/src/lib/utils/write-queue.ts +75 -0
- package/src/workers/3d-tiles-attributes-worker.ts +6 -0
- package/src/workers/i3s-attributes-worker.ts +6 -0
- package/dist/es5/i3s-converter/helpers/geometry-converter.d.ts +0 -44
- package/dist/es5/lib/utils/compress-util.d.ts +0 -53
- package/dist/es5/lib/utils/file-utils.d.ts +0 -43
- package/dist/es5/lib/utils/lod-conversion-utils.d.ts +0 -32
- package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +0 -44
- package/dist/esm/lib/utils/compress-util.d.ts +0 -53
- package/dist/esm/lib/utils/file-utils.d.ts +0 -43
- package/dist/esm/lib/utils/lod-conversion-utils.d.ts +0 -32
- package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -44
- package/src/lib/utils/compress-util.d.ts +0 -53
- package/src/lib/utils/file-utils.d.ts +0 -43
- package/src/lib/utils/file-utils.js +0 -38
- package/src/lib/utils/lod-conversion-utils.d.ts +0 -32
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prepareDataForAttributesConversion = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Keep only values for B3DM attributes to pass data to worker thread.
|
|
6
|
+
* @param attributes
|
|
7
|
+
*/
|
|
8
|
+
function getB3DMAttributesWithoutBufferView(attributes) {
|
|
9
|
+
const attributesWithoutBufferView = {};
|
|
10
|
+
for (const attributeName in attributes) {
|
|
11
|
+
attributesWithoutBufferView[attributeName] = {
|
|
12
|
+
value: attributes[attributeName].value
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return attributesWithoutBufferView;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Prepare attributes for conversion to avoid binary data breaking in worker thread.
|
|
19
|
+
* @param tileContent
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
function prepareDataForAttributesConversion(tileContent) {
|
|
23
|
+
const gltfMaterials = tileContent.gltf?.materials?.map((material) => ({ id: material.id }));
|
|
24
|
+
let nodes = tileContent.gltf?.scene?.nodes ||
|
|
25
|
+
tileContent.gltf?.scenes?.[0]?.nodes ||
|
|
26
|
+
tileContent.gltf?.nodes ||
|
|
27
|
+
[];
|
|
28
|
+
const prepearedNodes = nodes.map((node) => {
|
|
29
|
+
if (!node.mesh) {
|
|
30
|
+
return node;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
...node,
|
|
34
|
+
mesh: {
|
|
35
|
+
...node.mesh,
|
|
36
|
+
primitives: node.mesh?.primitives.map((primitive) => ({
|
|
37
|
+
...primitive,
|
|
38
|
+
indices: { value: primitive?.indices?.value },
|
|
39
|
+
attributes: getB3DMAttributesWithoutBufferView(primitive.attributes),
|
|
40
|
+
material: {
|
|
41
|
+
id: primitive?.material?.id
|
|
42
|
+
}
|
|
43
|
+
}))
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
const cartographicOrigin = tileContent.cartographicOrigin;
|
|
48
|
+
const cartesianModelMatrix = tileContent.cartesianModelMatrix;
|
|
49
|
+
return {
|
|
50
|
+
gltfMaterials,
|
|
51
|
+
nodes: prepearedNodes,
|
|
52
|
+
cartographicOrigin,
|
|
53
|
+
cartesianModelMatrix
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
exports.prepareDataForAttributesConversion = prepareDataForAttributesConversion;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { WriteQueueItem } from '../../lib/utils/write-queue';
|
|
1
2
|
import { NodeInPage } from '@loaders.gl/i3s';
|
|
3
|
+
import WriteQueue from '../../lib/utils/write-queue';
|
|
2
4
|
/**
|
|
3
5
|
* class NodePages - wrapper of nodePages array
|
|
4
6
|
*
|
|
@@ -106,11 +108,10 @@ export default class NodePages {
|
|
|
106
108
|
/**
|
|
107
109
|
* Save all the node pages
|
|
108
110
|
* Run this method when all nodes is pushed in nodePages
|
|
109
|
-
* @param
|
|
110
|
-
* @param
|
|
111
|
-
* @param
|
|
112
|
-
* @return {promise}
|
|
111
|
+
* @param layers0Path - path of layer
|
|
112
|
+
* @param writeQueue - write queue that controlls files write concurrency
|
|
113
|
+
* @param slpk
|
|
113
114
|
*/
|
|
114
|
-
save(layers0Path: string,
|
|
115
|
+
save(layers0Path: string, writeQueue: WriteQueue<WriteQueueItem>, slpk?: boolean): Promise<void>;
|
|
115
116
|
}
|
|
116
117
|
//# sourceMappingURL=node-pages.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-pages.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/node-pages.ts"],"names":[],"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G,IAAI;IAQrE;;;OAGG;IACH,oBAAoB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAM5C;;;;;OAKG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAajD;;;;;;OAMG;IACG,IAAI,CACR,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,UAAU,CAAC,cAAc,CAAC,EACtC,IAAI,GAAE,OAAe,GACpB,OAAO,CAAC,IAAI,CAAC;CA6BjB"}
|
|
@@ -175,27 +175,32 @@ class NodePages {
|
|
|
175
175
|
/**
|
|
176
176
|
* Save all the node pages
|
|
177
177
|
* Run this method when all nodes is pushed in nodePages
|
|
178
|
-
* @param
|
|
179
|
-
* @param
|
|
180
|
-
* @param
|
|
181
|
-
* @return {promise}
|
|
178
|
+
* @param layers0Path - path of layer
|
|
179
|
+
* @param writeQueue - write queue that controlls files write concurrency
|
|
180
|
+
* @param slpk
|
|
182
181
|
*/
|
|
183
|
-
async save(layers0Path,
|
|
182
|
+
async save(layers0Path, writeQueue, slpk = false) {
|
|
184
183
|
if (slpk) {
|
|
185
184
|
for (const [index, nodePage] of this.nodePages.entries()) {
|
|
186
185
|
const nodePageStr = JSON.stringify(nodePage);
|
|
187
186
|
const slpkPath = (0, path_1.join)(layers0Path, 'nodepages');
|
|
188
|
-
|
|
187
|
+
writeQueue.enqueue({
|
|
188
|
+
archiveKey: `nodePages/${index.toString()}.json.gz`,
|
|
189
|
+
writePromise: this.writeFile(slpkPath, nodePageStr, `${index.toString()}.json`)
|
|
190
|
+
});
|
|
189
191
|
}
|
|
190
192
|
const metadata = (0, json_map_transform_1.default)({ nodeCount: this.nodesCounter }, (0, metadata_1.METADATA)());
|
|
191
193
|
const compress = false;
|
|
192
|
-
|
|
194
|
+
writeQueue.enqueue({
|
|
195
|
+
archiveKey: 'metadata.json',
|
|
196
|
+
writePromise: this.writeFile(layers0Path, JSON.stringify(metadata), 'metadata.json', compress)
|
|
197
|
+
});
|
|
193
198
|
}
|
|
194
199
|
else {
|
|
195
200
|
for (const [index, nodePage] of this.nodePages.entries()) {
|
|
196
201
|
const nodePageStr = JSON.stringify(nodePage);
|
|
197
202
|
const nodePagePath = (0, path_1.join)(layers0Path, 'nodepages', index.toString());
|
|
198
|
-
|
|
203
|
+
writeQueue.enqueue({ writePromise: this.writeFile(nodePagePath, nodePageStr) });
|
|
199
204
|
}
|
|
200
205
|
}
|
|
201
206
|
}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
+
import type { WriteQueueItem } from '../lib/utils/write-queue';
|
|
1
2
|
import type { SceneLayer3D } from '@loaders.gl/i3s';
|
|
2
3
|
import { Tileset3D } from '@loaders.gl/tiles';
|
|
3
4
|
import { Geoid } from '@math.gl/geoid';
|
|
4
5
|
import NodePages from './helpers/node-pages';
|
|
5
6
|
import { LoaderWithParser } from '@loaders.gl/loader-utils';
|
|
6
7
|
import { I3SMaterialDefinition } from '@loaders.gl/i3s/src/types';
|
|
8
|
+
import WriteQueue from '../lib/utils/write-queue';
|
|
7
9
|
/**
|
|
8
10
|
* Converter from 3d-tiles tileset to i3s layer
|
|
9
11
|
*/
|
|
10
12
|
export default class I3SConverter {
|
|
11
13
|
nodePages: NodePages;
|
|
12
|
-
fileMap: {
|
|
13
|
-
[key: string]: string;
|
|
14
|
-
};
|
|
15
14
|
options: any;
|
|
16
15
|
layers0Path: string;
|
|
17
16
|
materialMap: Map<any, any>;
|
|
@@ -33,6 +32,10 @@ export default class I3SConverter {
|
|
|
33
32
|
generateTextures: boolean;
|
|
34
33
|
generateBoundingVolumes: boolean;
|
|
35
34
|
layersHasTexture: boolean;
|
|
35
|
+
workerSource: {
|
|
36
|
+
[key: string]: string;
|
|
37
|
+
};
|
|
38
|
+
writeQueue: WriteQueue<WriteQueueItem>;
|
|
36
39
|
constructor();
|
|
37
40
|
/**
|
|
38
41
|
* Convert a 3d tileset
|
|
@@ -317,5 +320,6 @@ export default class I3SConverter {
|
|
|
317
320
|
* @returns
|
|
318
321
|
*/
|
|
319
322
|
private isContentSupported;
|
|
323
|
+
private loadWorkers;
|
|
320
324
|
}
|
|
321
325
|
//# sourceMappingURL=i3s-converter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"i3s-converter.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/i3s-converter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAEV,YAAY,EAYb,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;AAM7F,OAAO,UAAU,MAAM,0BAA0B,CAAC;AAiBlD;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,SAAS,EAAE,SAAS,CAAC;IACrB,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC3B,mBAAmB,EAAE,qBAAqB,EAAE,CAAC;IAC7C,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7B,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,iBAAiB,EAAE;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,uBAAuB,EAAE,MAAM,CAAC;KACjC,CAAC;IACF,QAAQ,EAAE,OAAO,CAAC;IACl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
@@ -26,6 +26,10 @@ const shared_resources_1 = require("./json-templates/shared-resources");
|
|
|
26
26
|
const node_debug_1 = require("./helpers/node-debug");
|
|
27
27
|
const textures_1 = require("@loaders.gl/textures");
|
|
28
28
|
const images_1 = require("@loaders.gl/images");
|
|
29
|
+
const worker_utils_1 = require("@loaders.gl/worker-utils");
|
|
30
|
+
const draco_1 = require("@loaders.gl/draco");
|
|
31
|
+
const write_queue_1 = __importDefault(require("../lib/utils/write-queue"));
|
|
32
|
+
const i3s_attributes_worker_1 = require("../i3s-attributes-worker");
|
|
29
33
|
const ION_DEFAULT_TOKEN = process_1.default.env.IonToken || // eslint-disable-line
|
|
30
34
|
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ'; // eslint-disable-line
|
|
31
35
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
@@ -49,8 +53,9 @@ class I3SConverter {
|
|
|
49
53
|
this.sourceTileset = null;
|
|
50
54
|
this.geoidHeightModel = null;
|
|
51
55
|
this.Loader = _3d_tiles_1.Tiles3DLoader;
|
|
56
|
+
this.workerSource = {};
|
|
57
|
+
this.writeQueue = new write_queue_1.default();
|
|
52
58
|
this.nodePages = new node_pages_1.default(file_utils_1.writeFile, HARDCODED_NODES_PER_PAGE);
|
|
53
|
-
this.fileMap = {};
|
|
54
59
|
this.options = {};
|
|
55
60
|
this.layers0Path = '';
|
|
56
61
|
this.materialMap = new Map();
|
|
@@ -89,12 +94,15 @@ class I3SConverter {
|
|
|
89
94
|
this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? _3d_tiles_1.CesiumIonLoader : _3d_tiles_1.Tiles3DLoader;
|
|
90
95
|
this.generateTextures = Boolean(generateTextures);
|
|
91
96
|
this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
|
|
97
|
+
this.writeQueue = new write_queue_1.default();
|
|
98
|
+
this.writeQueue.startListening();
|
|
92
99
|
console.log('Loading egm file...'); // eslint-disable-line
|
|
93
100
|
this.geoidHeightModel = await (0, core_1.load)(egmFilePath, pgm_loader_1.PGMLoader);
|
|
94
101
|
console.log('Loading egm file completed!'); // eslint-disable-line
|
|
95
102
|
if (slpk) {
|
|
96
103
|
this.nodePages.useWriteFunction(file_utils_1.writeFileForSlpk);
|
|
97
104
|
}
|
|
105
|
+
await this.loadWorkers();
|
|
98
106
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
99
107
|
const tilesetOptions = { loadOptions: { basis: { format: 'rgba32' } } };
|
|
100
108
|
if (preloadOptions.headers) {
|
|
@@ -106,6 +114,9 @@ class I3SConverter {
|
|
|
106
114
|
this.sourceTileset = new tiles_1.Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
107
115
|
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
108
116
|
await this._finishConversion({ slpk: Boolean(slpk), outputPath, tilesetName });
|
|
117
|
+
// Clean up worker pools
|
|
118
|
+
const workerFarm = worker_utils_1.WorkerFarm.getWorkerFarm({});
|
|
119
|
+
workerFarm.destroy();
|
|
109
120
|
return sourceTilesetJson;
|
|
110
121
|
}
|
|
111
122
|
/**
|
|
@@ -145,7 +156,8 @@ class I3SConverter {
|
|
|
145
156
|
await this._writeLayers0();
|
|
146
157
|
(0, create_scene_server_path_1.createSceneServerPath)(tilesetName, this.layers0, tilesetPath);
|
|
147
158
|
await this._writeNodeIndexDocument(root0, 'root', (0, path_1.join)(this.layers0Path, 'nodes', 'root'));
|
|
148
|
-
await this.nodePages.save(this.layers0Path, this.
|
|
159
|
+
await this.nodePages.save(this.layers0Path, this.writeQueue, isCreateSlpk);
|
|
160
|
+
await this.writeQueue.finalize();
|
|
149
161
|
await this._createSlpk(tilesetPath);
|
|
150
162
|
}
|
|
151
163
|
/**
|
|
@@ -153,7 +165,8 @@ class I3SConverter {
|
|
|
153
165
|
* @param tilesetName - Name of layer
|
|
154
166
|
*/
|
|
155
167
|
_formLayers0(tilesetName) {
|
|
156
|
-
const
|
|
168
|
+
const fullExtent = (0, coordinate_converter_1.convertBoundingVolumeToI3SFullExtent)(this.sourceTileset?.boundingVolume || this.sourceTileset?.root?.boundingVolume);
|
|
169
|
+
const extent = [fullExtent.xmin, fullExtent.ymin, fullExtent.xmax, fullExtent.ymax];
|
|
157
170
|
const layers0data = {
|
|
158
171
|
version: `{${(0, uuid_1.v4)().toUpperCase()}}`,
|
|
159
172
|
id: 0,
|
|
@@ -214,10 +227,13 @@ class I3SConverter {
|
|
|
214
227
|
const [child] = await this._createNode(root0, sourceRootTile, parentId, 0);
|
|
215
228
|
const childPath = (0, path_1.join)(this.layers0Path, 'nodes', child.path);
|
|
216
229
|
if (this.options.slpk) {
|
|
217
|
-
this.
|
|
230
|
+
this.writeQueue.enqueue({
|
|
231
|
+
archiveKey: 'nodes/1/3dNodeIndexDocument.json.gz',
|
|
232
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(childPath, JSON.stringify(child), '3dNodeIndexDocument.json')
|
|
233
|
+
});
|
|
218
234
|
}
|
|
219
235
|
else {
|
|
220
|
-
|
|
236
|
+
this.writeQueue.enqueue({ writePromise: (0, file_utils_1.writeFile)(childPath, JSON.stringify(child)) });
|
|
221
237
|
}
|
|
222
238
|
}
|
|
223
239
|
else {
|
|
@@ -235,10 +251,15 @@ class I3SConverter {
|
|
|
235
251
|
*/
|
|
236
252
|
async _writeLayers0() {
|
|
237
253
|
if (this.options.slpk) {
|
|
238
|
-
this.
|
|
254
|
+
this.writeQueue.enqueue({
|
|
255
|
+
archiveKey: '3dSceneLayer.json.gz',
|
|
256
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
|
|
257
|
+
});
|
|
239
258
|
}
|
|
240
259
|
else {
|
|
241
|
-
|
|
260
|
+
this.writeQueue.enqueue({
|
|
261
|
+
writePromise: (0, file_utils_1.writeFile)(this.layers0Path, JSON.stringify(this.layers0))
|
|
262
|
+
});
|
|
242
263
|
}
|
|
243
264
|
}
|
|
244
265
|
/**
|
|
@@ -246,10 +267,13 @@ class I3SConverter {
|
|
|
246
267
|
*/
|
|
247
268
|
async _writeNodeIndexDocument(root0, nodePath, rootPath) {
|
|
248
269
|
if (this.options.slpk) {
|
|
249
|
-
this.
|
|
270
|
+
this.writeQueue.enqueue({
|
|
271
|
+
archiveKey: `nodes/${nodePath}/3dNodeIndexDocument.json.gz`,
|
|
272
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json')
|
|
273
|
+
});
|
|
250
274
|
}
|
|
251
275
|
else {
|
|
252
|
-
|
|
276
|
+
this.writeQueue.enqueue({ writePromise: (0, file_utils_1.writeFile)(rootPath, JSON.stringify(root0)) });
|
|
253
277
|
}
|
|
254
278
|
}
|
|
255
279
|
/**
|
|
@@ -260,9 +284,7 @@ class I3SConverter {
|
|
|
260
284
|
if (this.options.slpk) {
|
|
261
285
|
const slpkTilesetPath = (0, path_1.join)(tilesetPath, 'SceneServer', 'layers', '0');
|
|
262
286
|
const slpkFileName = `${tilesetPath}.slpk`;
|
|
263
|
-
await (0, compress_util_1.compressWithChildProcess)(slpkTilesetPath, slpkFileName, 0, '.',
|
|
264
|
-
// @ts-expect-error
|
|
265
|
-
this.options.sevenZipExe);
|
|
287
|
+
await (0, compress_util_1.compressWithChildProcess)(slpkTilesetPath, slpkFileName, 0, '.', this.options.sevenZipExe);
|
|
266
288
|
// TODO: `addFileToZip` corrupts archive so it can't be validated with windows i3s_converter.exe
|
|
267
289
|
// const fileHash128Path = `${tilesetPath}/@specialIndexFileHASH128@`;
|
|
268
290
|
// try {
|
|
@@ -468,7 +490,7 @@ class I3SConverter {
|
|
|
468
490
|
if (!this.isContentSupported(sourceTile)) {
|
|
469
491
|
return null;
|
|
470
492
|
}
|
|
471
|
-
const resourcesData = await (0, geometry_converter_1.default)(sourceTile.content, Number(this.nodePages.nodesCounter), this.featuresHashArray, this.layers0?.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.geoidHeightModel);
|
|
493
|
+
const resourcesData = await (0, geometry_converter_1.default)(sourceTile.content, Number(this.nodePages.nodesCounter), this.featuresHashArray, this.layers0?.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.geoidHeightModel, this.workerSource);
|
|
472
494
|
return resourcesData;
|
|
473
495
|
}
|
|
474
496
|
/**
|
|
@@ -601,20 +623,30 @@ class I3SConverter {
|
|
|
601
623
|
async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
|
|
602
624
|
if (this.options.slpk) {
|
|
603
625
|
const slpkGeometryPath = (0, path_1.join)(childPath, 'geometries');
|
|
604
|
-
this.
|
|
626
|
+
this.writeQueue.enqueue({
|
|
627
|
+
archiveKey: `${slpkChildPath}/geometries/0.bin.gz`,
|
|
628
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(slpkGeometryPath, geometryBuffer, '0.bin')
|
|
629
|
+
});
|
|
605
630
|
}
|
|
606
631
|
else {
|
|
607
632
|
const geometryPath = (0, path_1.join)(childPath, 'geometries/0/');
|
|
608
|
-
|
|
633
|
+
this.writeQueue.enqueue({
|
|
634
|
+
writePromise: (0, file_utils_1.writeFile)(geometryPath, geometryBuffer, 'index.bin')
|
|
635
|
+
});
|
|
609
636
|
}
|
|
610
637
|
if (this.options.draco) {
|
|
611
638
|
if (this.options.slpk) {
|
|
612
639
|
const slpkCompressedGeometryPath = (0, path_1.join)(childPath, 'geometries');
|
|
613
|
-
this.
|
|
640
|
+
this.writeQueue.enqueue({
|
|
641
|
+
archiveKey: `${slpkChildPath}/geometries/1.bin.gz`,
|
|
642
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
|
|
643
|
+
});
|
|
614
644
|
}
|
|
615
645
|
else {
|
|
616
646
|
const compressedGeometryPath = (0, path_1.join)(childPath, 'geometries/1/');
|
|
617
|
-
|
|
647
|
+
this.writeQueue.enqueue({
|
|
648
|
+
writePromise: (0, file_utils_1.writeFile)(compressedGeometryPath, compressedGeometry, 'index.bin')
|
|
649
|
+
});
|
|
618
650
|
}
|
|
619
651
|
}
|
|
620
652
|
}
|
|
@@ -626,16 +658,22 @@ class I3SConverter {
|
|
|
626
658
|
* @param nodePath - a node path
|
|
627
659
|
*/
|
|
628
660
|
async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
|
|
661
|
+
if (!sharedResources) {
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
629
664
|
sharedResources.nodePath = nodePath;
|
|
630
665
|
const sharedData = (0, json_map_transform_1.default)(sharedResources, (0, shared_resources_1.SHARED_RESOURCES)());
|
|
631
666
|
const sharedDataStr = JSON.stringify(sharedData);
|
|
632
667
|
if (this.options.slpk) {
|
|
633
668
|
const slpkSharedPath = (0, path_1.join)(childPath, 'shared');
|
|
634
|
-
this.
|
|
669
|
+
this.writeQueue.enqueue({
|
|
670
|
+
archiveKey: `${slpkChildPath}/shared/sharedResource.json.gz`,
|
|
671
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(slpkSharedPath, sharedDataStr, 'sharedResource.json')
|
|
672
|
+
});
|
|
635
673
|
}
|
|
636
674
|
else {
|
|
637
675
|
const sharedPath = (0, path_1.join)(childPath, 'shared/');
|
|
638
|
-
|
|
676
|
+
this.writeQueue.enqueue({ writePromise: (0, file_utils_1.writeFile)(sharedPath, sharedDataStr) });
|
|
639
677
|
}
|
|
640
678
|
}
|
|
641
679
|
/**
|
|
@@ -656,7 +694,7 @@ class I3SConverter {
|
|
|
656
694
|
await this.writeTextureFile(textureData, '0', format, childPath, slpkChildPath);
|
|
657
695
|
if (this.generateTextures) {
|
|
658
696
|
formats.push({ name: '1', format: 'ktx2' });
|
|
659
|
-
const ktx2TextureData = new Uint8Array(await (0, core_1.encode)(texture.image, textures_1.
|
|
697
|
+
const ktx2TextureData = new Uint8Array(await (0, core_1.encode)(texture.image, textures_1.KTX2BasisWriter));
|
|
660
698
|
await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
|
|
661
699
|
}
|
|
662
700
|
break;
|
|
@@ -688,11 +726,16 @@ class I3SConverter {
|
|
|
688
726
|
if (this.options.slpk) {
|
|
689
727
|
const slpkTexturePath = (0, path_1.join)(childPath, 'textures');
|
|
690
728
|
const compress = false;
|
|
691
|
-
this.
|
|
729
|
+
this.writeQueue.enqueue({
|
|
730
|
+
archiveKey: `${slpkChildPath}/textures/${name}.${format}`,
|
|
731
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(slpkTexturePath, textureData, `${name}.${format}`, compress)
|
|
732
|
+
});
|
|
692
733
|
}
|
|
693
734
|
else {
|
|
694
735
|
const texturePath = (0, path_1.join)(childPath, `textures/${name}/`);
|
|
695
|
-
|
|
736
|
+
this.writeQueue.enqueue({
|
|
737
|
+
writePromise: (0, file_utils_1.writeFile)(texturePath, textureData, `index.${format}`)
|
|
738
|
+
});
|
|
696
739
|
}
|
|
697
740
|
}
|
|
698
741
|
/**
|
|
@@ -701,18 +744,23 @@ class I3SConverter {
|
|
|
701
744
|
* @param childPath - a child path to write resources
|
|
702
745
|
* @param slpkChildPath - the resource path inside *slpk file
|
|
703
746
|
*/
|
|
704
|
-
async _writeAttributes(attributes, childPath, slpkChildPath) {
|
|
705
|
-
if (attributes
|
|
747
|
+
async _writeAttributes(attributes = [], childPath, slpkChildPath) {
|
|
748
|
+
if (attributes?.length && this.layers0?.attributeStorageInfo?.length) {
|
|
706
749
|
for (let index = 0; index < attributes.length; index++) {
|
|
707
750
|
const folderName = this.layers0.attributeStorageInfo[index].key;
|
|
708
751
|
const fileBuffer = new Uint8Array(attributes[index]);
|
|
709
752
|
if (this.options.slpk) {
|
|
710
753
|
const slpkAttributesPath = (0, path_1.join)(childPath, 'attributes', folderName);
|
|
711
|
-
this.
|
|
754
|
+
this.writeQueue.enqueue({
|
|
755
|
+
archiveKey: `${slpkChildPath}/attributes/${folderName}.bin.gz`,
|
|
756
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(slpkAttributesPath, fileBuffer, '0.bin')
|
|
757
|
+
});
|
|
712
758
|
}
|
|
713
759
|
else {
|
|
714
760
|
const attributesPath = (0, path_1.join)(childPath, `attributes/${folderName}/0`);
|
|
715
|
-
|
|
761
|
+
this.writeQueue.enqueue({
|
|
762
|
+
writePromise: (0, file_utils_1.writeFile)(attributesPath, fileBuffer, 'index.bin')
|
|
763
|
+
});
|
|
716
764
|
}
|
|
717
765
|
}
|
|
718
766
|
}
|
|
@@ -990,5 +1038,19 @@ class I3SConverter {
|
|
|
990
1038
|
isContentSupported(sourceRootTile) {
|
|
991
1039
|
return ['b3dm', 'glTF'].includes(sourceRootTile?.content?.type);
|
|
992
1040
|
}
|
|
1041
|
+
async loadWorkers() {
|
|
1042
|
+
console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console
|
|
1043
|
+
if (this.options.draco) {
|
|
1044
|
+
const url = (0, worker_utils_1.getWorkerURL)(draco_1.DracoWriterWorker, { ...(0, core_1.getLoaderOptions)() });
|
|
1045
|
+
const sourceResponse = await (0, core_1.fetchFile)(url);
|
|
1046
|
+
const source = await sourceResponse.text();
|
|
1047
|
+
this.workerSource.draco = source;
|
|
1048
|
+
}
|
|
1049
|
+
const i3sAttributesWorkerUrl = (0, worker_utils_1.getWorkerURL)(i3s_attributes_worker_1.I3SAttributesWorker, { ...(0, core_1.getLoaderOptions)() });
|
|
1050
|
+
const sourceResponse = await (0, core_1.fetchFile)(i3sAttributesWorkerUrl);
|
|
1051
|
+
const source = await sourceResponse.text();
|
|
1052
|
+
this.workerSource.I3SAttributes = source;
|
|
1053
|
+
console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console
|
|
1054
|
+
}
|
|
993
1055
|
}
|
|
994
1056
|
exports.default = I3SConverter;
|
|
@@ -1,39 +1,114 @@
|
|
|
1
|
-
import { BoundingVolumes, I3SMaterialDefinition,
|
|
1
|
+
import { BoundingVolumes, I3SMaterialDefinition, MaterialDefinitionInfo, TextureDefinitionInfo } from '@loaders.gl/i3s';
|
|
2
|
+
import { ImageDataType } from '@loaders.gl/images';
|
|
3
|
+
/** Converted resources for specific node */
|
|
2
4
|
export declare type I3SConvertedResources = {
|
|
5
|
+
/** Non-compressed geometry buffer that have structure met
|
|
6
|
+
* https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md
|
|
7
|
+
* (Geometry buffer)
|
|
8
|
+
*/
|
|
3
9
|
geometry: ArrayBuffer | null;
|
|
4
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Draco compressed geometry
|
|
12
|
+
*/
|
|
13
|
+
compressedGeometry?: Promise<ArrayBuffer> | null;
|
|
14
|
+
/**
|
|
15
|
+
* Texture image content
|
|
16
|
+
*/
|
|
5
17
|
texture: any | null;
|
|
6
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Shared resources built from GLTF material
|
|
20
|
+
*/
|
|
21
|
+
sharedResources: SharedResourcesArrays | null;
|
|
22
|
+
/**
|
|
23
|
+
* Material definition of the node
|
|
24
|
+
*/
|
|
7
25
|
meshMaterial?: I3SMaterialDefinition | null;
|
|
26
|
+
/**
|
|
27
|
+
* Number of vertices in the node
|
|
28
|
+
*/
|
|
8
29
|
vertexCount: number | null;
|
|
9
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Feature attributes contents
|
|
32
|
+
*/
|
|
33
|
+
attributes: ArrayBuffer[] | null;
|
|
34
|
+
/**
|
|
35
|
+
* Number of features in the node
|
|
36
|
+
*/
|
|
10
37
|
featureCount: number | null;
|
|
11
|
-
|
|
38
|
+
/**
|
|
39
|
+
* MBS and/or OBB bounding volumes of the node
|
|
40
|
+
*/
|
|
12
41
|
boundingVolumes: BoundingVolumes | null;
|
|
13
42
|
};
|
|
14
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Geometry and feature attributes converted from GLTF primitives
|
|
45
|
+
*/
|
|
46
|
+
export declare type ConvertedAttributes = {
|
|
47
|
+
/** POSITION attribute value */
|
|
15
48
|
positions: Float32Array;
|
|
49
|
+
/** NORMAL attribute value */
|
|
16
50
|
normals: Float32Array;
|
|
51
|
+
/** TEXCOORD_0 attribute value */
|
|
17
52
|
texCoords: Float32Array;
|
|
53
|
+
/** COLOR_0 attribute value */
|
|
18
54
|
colors: Uint8Array;
|
|
55
|
+
/** Feature indices grouped by ...
|
|
56
|
+
* converted from "batch ids" of GLTF
|
|
57
|
+
*/
|
|
58
|
+
featureIndicesGroups?: number[][];
|
|
59
|
+
/** Feature indices converted from "batch ids" */
|
|
19
60
|
featureIndices: number[];
|
|
20
|
-
|
|
21
|
-
|
|
61
|
+
/**
|
|
62
|
+
* MBS and/or OBB bounding volumes of the node
|
|
63
|
+
*/
|
|
64
|
+
boundingVolumes: null | BoundingVolumes;
|
|
22
65
|
};
|
|
66
|
+
/** Postprocessed geometry and feature attributes
|
|
67
|
+
* https://github.com/Esri/i3s-spec/blob/master/docs/1.8/defaultGeometrySchema.cmn.md
|
|
68
|
+
*/
|
|
23
69
|
export declare type GeometryAttributes = {
|
|
70
|
+
/** POSITION attribute value */
|
|
24
71
|
positions: Float32Array;
|
|
72
|
+
/** NORMAL attribute value */
|
|
25
73
|
normals: Float32Array;
|
|
74
|
+
/** TEXCOORD_0 attribute value */
|
|
26
75
|
texCoords: Float32Array;
|
|
76
|
+
/** COLOR_0 attribute value */
|
|
27
77
|
colors: Uint8Array;
|
|
78
|
+
/** faceRanges attribute value */
|
|
28
79
|
faceRange: Uint32Array;
|
|
80
|
+
/** feature Ids attribute value */
|
|
29
81
|
featureIds: number[];
|
|
82
|
+
/** number of features in the node */
|
|
30
83
|
featureCount: number;
|
|
31
84
|
};
|
|
85
|
+
/** Geometry attributes specific for the particular feature */
|
|
32
86
|
export declare type GroupedByFeatureIdAttributes = {
|
|
87
|
+
/** Feature Id */
|
|
33
88
|
featureId: number;
|
|
89
|
+
/** POSITION attribute value */
|
|
34
90
|
positions: Float32Array;
|
|
91
|
+
/** NORMAL attribute value */
|
|
35
92
|
normals: Float32Array;
|
|
93
|
+
/** COLOR_0 attribute value */
|
|
36
94
|
colors: Uint8Array;
|
|
95
|
+
/** TEXCOORD_0 attribute value */
|
|
37
96
|
texCoords: Float32Array;
|
|
38
97
|
};
|
|
98
|
+
/** Shared resources made from GLTF material */
|
|
99
|
+
export declare type SharedResourcesArrays = {
|
|
100
|
+
/** material definitions list https://github.com/Esri/i3s-spec/blob/master/docs/1.8/materialDefinitionInfo.cmn.md */
|
|
101
|
+
materialDefinitionInfos?: MaterialDefinitionInfo[];
|
|
102
|
+
/** texture definitions list https://github.com/Esri/i3s-spec/blob/master/docs/1.8/textureDefinitionInfo.cmn.md*/
|
|
103
|
+
textureDefinitionInfos?: TextureDefinitionInfo[];
|
|
104
|
+
/** node id to make unique SharedResource ids */
|
|
105
|
+
nodePath?: string;
|
|
106
|
+
};
|
|
107
|
+
/** I3S material definition and texture content taken from GLTF material */
|
|
108
|
+
export declare type I3SMaterialWithTexture = {
|
|
109
|
+
/** Material definition https://github.com/Esri/i3s-spec/blob/master/docs/1.8/materialDefinitions.cmn.md */
|
|
110
|
+
material: I3SMaterialDefinition;
|
|
111
|
+
/** Texture content (image) */
|
|
112
|
+
texture?: ImageDataType;
|
|
113
|
+
};
|
|
39
114
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/types.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/types.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACtB,MAAM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,CAAC;IACxB,8BAA8B;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,kCAAkC;IAClC,SAAS,EAAE,WAAW,CAAC;IACvB,kCAAkC;IAClC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,8DAA8D;AAC9D,oBAAY,4BAA4B,GAAG;IACzC,iBAAiB;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,+BAA+B;IAC/B,SAAS,EAAE,YAAY,CAAC;IACxB,6BAA6B;IAC7B,OAAO,EAAE,YAAY,CAAC;IACtB,8BAA8B;IAC9B,MAAM,EAAE,UAAU,CAAC;IACnB,iCAAiC;IACjC,SAAS,EAAE,YAAY,CAAC;CACzB,CAAC;AAEF,+CAA+C;AAC/C,oBAAY,qBAAqB,GAAG;IAClC,oHAAoH;IACpH,uBAAuB,CAAC,EAAE,sBAAsB,EAAE,CAAC;IACnD,kHAAkH;IAClH,sBAAsB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACjD,gDAAgD;IAChD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,2EAA2E;AAC3E,oBAAY,sBAAsB,GAAG;IACnC,2GAA2G;IAC3G,QAAQ,EAAE,qBAAqB,CAAC;IAChC,8BAA8B;IAC9B,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { default as I3SConverter } from './i3s-converter/i3s-converter';
|
|
|
2
2
|
export { default as NodePages } from './i3s-converter/helpers/node-pages';
|
|
3
3
|
export { default as Tiles3DConverter } from './3d-tiles-converter/3d-tiles-converter';
|
|
4
4
|
export { DepsInstaller } from './deps-installer/deps-installer';
|
|
5
|
+
export { prepareDataForAttributesConversion } from './i3s-converter/helpers/gltf-attributes';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,oCAAoC,CAAC;AAExE,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,yCAAyC,CAAC;AAEpF,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,oCAAoC,CAAC;AAExE,OAAO,EAAC,OAAO,IAAI,gBAAgB,EAAC,MAAM,yCAAyC,CAAC;AAEpF,OAAO,EAAC,aAAa,EAAC,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAC,kCAAkC,EAAC,MAAM,yCAAyC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DepsInstaller = exports.Tiles3DConverter = exports.NodePages = exports.I3SConverter = void 0;
|
|
6
|
+
exports.prepareDataForAttributesConversion = exports.DepsInstaller = exports.Tiles3DConverter = exports.NodePages = exports.I3SConverter = void 0;
|
|
7
7
|
var i3s_converter_1 = require("./i3s-converter/i3s-converter");
|
|
8
8
|
Object.defineProperty(exports, "I3SConverter", { enumerable: true, get: function () { return __importDefault(i3s_converter_1).default; } });
|
|
9
9
|
var node_pages_1 = require("./i3s-converter/helpers/node-pages");
|
|
@@ -12,3 +12,5 @@ var _3d_tiles_converter_1 = require("./3d-tiles-converter/3d-tiles-converter");
|
|
|
12
12
|
Object.defineProperty(exports, "Tiles3DConverter", { enumerable: true, get: function () { return __importDefault(_3d_tiles_converter_1).default; } });
|
|
13
13
|
var deps_installer_1 = require("./deps-installer/deps-installer");
|
|
14
14
|
Object.defineProperty(exports, "DepsInstaller", { enumerable: true, get: function () { return deps_installer_1.DepsInstaller; } });
|
|
15
|
+
var gltf_attributes_1 = require("./i3s-converter/helpers/gltf-attributes");
|
|
16
|
+
Object.defineProperty(exports, "prepareDataForAttributesConversion", { enumerable: true, get: function () { return gltf_attributes_1.prepareDataForAttributesConversion; } });
|