@loaders.gl/tile-converter 3.2.0-alpha.1 → 3.2.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.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 +5 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +34 -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/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +4 -0
- package/dist/converter-cli.d.ts +2 -0
- package/dist/converter-cli.d.ts.map +1 -0
- package/dist/converter-cli.js +232 -0
- package/dist/converter.min.js +68 -68
- package/dist/deps-installer/deps-installer.d.ts +11 -1
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +10 -0
- package/dist/dist.min.js +910 -790
- 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 +116 -46
- 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/constants.js +9 -0
- package/dist/es5/constants.js.map +1 -0
- package/dist/es5/converter-cli.js +306 -0
- package/dist/es5/converter-cli.js.map +1 -0
- package/dist/es5/deps-installer/deps-installer.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 +271 -182
- 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 +293 -223
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/layers.js +29 -0
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/es5/index.js +0 -16
- 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 +36 -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/constants.js +2 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/converter-cli.js +230 -0
- package/dist/esm/converter-cli.js.map +1 -0
- package/dist/esm/deps-installer/deps-installer.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 +121 -62
- 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 +157 -52
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/layers.js +25 -0
- package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/esm/index.js +0 -2
- 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 +223 -113
- 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 -5
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +126 -40
- package/dist/i3s-converter/json-templates/layers.d.ts +4 -0
- package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
- package/dist/i3s-converter/json-templates/layers.js +24 -0
- package/dist/i3s-converter/types.d.ts +83 -8
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- 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 +23 -18
- package/src/3d-tiles-attributes-worker.ts +43 -0
- package/src/3d-tiles-converter/3d-tiles-converter.ts +50 -5
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +15 -13
- package/src/constants.ts +2 -0
- package/src/converter-cli.ts +310 -0
- package/src/deps-installer/{deps-installer.js → deps-installer.ts} +11 -1
- 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} +425 -179
- 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 +150 -90
- package/src/i3s-converter/json-templates/layers.ts +25 -0
- package/src/i3s-converter/types.ts +90 -8
- package/src/index.ts +0 -4
- 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/deps-installer/deps-installer.d.ts +0 -10
- 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/deps-installer/deps-installer.d.ts +0 -10
- 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/deps-installer/deps-installer.d.ts +0 -10
- 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,9 @@
|
|
|
1
|
+
import type { B3DMContent } from '@loaders.gl/3d-tiles';
|
|
2
|
+
import type { B3DMAttributesData } from '../../i3s-attributes-worker';
|
|
3
|
+
/**
|
|
4
|
+
* Prepare attributes for conversion to avoid binary data breaking in worker thread.
|
|
5
|
+
* @param tileContent
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare function prepareDataForAttributesConversion(tileContent: B3DMContent): B3DMAttributesData;
|
|
9
|
+
//# sourceMappingURL=gltf-attributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gltf-attributes.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/gltf-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAC,kBAAkB,EAAC,MAAM,6BAA6B,CAAC;AAsBpE;;;;GAIG;AACH,wBAAgB,kCAAkC,CAAC,WAAW,EAAE,WAAW,GAAG,kBAAkB,CAsC/F"}
|
|
@@ -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":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node-pages.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/helpers/node-pages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAKhE,OAAO,EAAC,UAAU,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,UAAU,MAAM,6BAA6B,CAAC;AAGrD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,QAAQ,CAAC;IACpB,QAAQ,CAAC,SAAS,EAAE;QAAC,KAAK,EAAE,UAAU,EAAE,CAAA;KAAC,EAAE,CAAC;IAE5C;;;;;OAKG;gBACS,aAAa,KAAA,EAAE,YAAY,KAAA;IASvC;;;OAGG;IACH,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI;IAItC;;;;OAIG;IACH,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU;IAMnC;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAW5D;;;;OAIG;IACH,yBAAyB,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAQhE;;;OAGG;IACH,2BAA2B,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAQ7C;;;;OAIG;IACH,0BAA0B,CAAC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAQlE;;;;OAIG;IACH,4BAA4B,CAAC,EAAE,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI;IAQtE;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,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
|
|
@@ -61,8 +64,6 @@ export default class I3SConverter {
|
|
|
61
64
|
validate?: boolean;
|
|
62
65
|
generateTextures?: boolean;
|
|
63
66
|
generateBoundingVolumes?: boolean;
|
|
64
|
-
/** @deprecated */
|
|
65
|
-
inputType?: string;
|
|
66
67
|
}): Promise<any>;
|
|
67
68
|
/**
|
|
68
69
|
* Convert and save the layer and embedded tiles
|
|
@@ -317,5 +318,6 @@ export default class I3SConverter {
|
|
|
317
318
|
* @returns
|
|
318
319
|
*/
|
|
319
320
|
private isContentSupported;
|
|
321
|
+
private loadWorkers;
|
|
320
322
|
}
|
|
321
323
|
//# 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":"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"}
|
|
@@ -26,7 +26,12 @@ 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
|
|
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");
|
|
33
|
+
const constants_1 = require("../constants");
|
|
34
|
+
const ION_DEFAULT_TOKEN = process_1.default.env?.IonToken || // eslint-disable-line
|
|
30
35
|
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ'; // eslint-disable-line
|
|
31
36
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
32
37
|
const _3D_TILES = '3DTILES';
|
|
@@ -49,8 +54,9 @@ class I3SConverter {
|
|
|
49
54
|
this.sourceTileset = null;
|
|
50
55
|
this.geoidHeightModel = null;
|
|
51
56
|
this.Loader = _3d_tiles_1.Tiles3DLoader;
|
|
57
|
+
this.workerSource = {};
|
|
58
|
+
this.writeQueue = new write_queue_1.default();
|
|
52
59
|
this.nodePages = new node_pages_1.default(file_utils_1.writeFile, HARDCODED_NODES_PER_PAGE);
|
|
53
|
-
this.fileMap = {};
|
|
54
60
|
this.options = {};
|
|
55
61
|
this.layers0Path = '';
|
|
56
62
|
this.materialMap = new Map();
|
|
@@ -82,6 +88,10 @@ class I3SConverter {
|
|
|
82
88
|
* @param options.validate -enable validation
|
|
83
89
|
*/
|
|
84
90
|
async convert(options) {
|
|
91
|
+
if (core_1.isBrowser) {
|
|
92
|
+
console.log(constants_1.BROWSER_ERROR_MESSAGE);
|
|
93
|
+
return constants_1.BROWSER_ERROR_MESSAGE;
|
|
94
|
+
}
|
|
85
95
|
this.conversionStartTime = process_1.default.hrtime();
|
|
86
96
|
const { tilesetName, slpk, egmFilePath, inputUrl, validate, outputPath, draco, sevenZipExe, maxDepth, token, generateTextures, generateBoundingVolumes } = options;
|
|
87
97
|
this.options = { maxDepth, slpk, sevenZipExe, egmFilePath, draco, token, inputUrl };
|
|
@@ -89,24 +99,37 @@ class I3SConverter {
|
|
|
89
99
|
this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? _3d_tiles_1.CesiumIonLoader : _3d_tiles_1.Tiles3DLoader;
|
|
90
100
|
this.generateTextures = Boolean(generateTextures);
|
|
91
101
|
this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
|
|
102
|
+
this.writeQueue = new write_queue_1.default();
|
|
103
|
+
this.writeQueue.startListening();
|
|
92
104
|
console.log('Loading egm file...'); // eslint-disable-line
|
|
93
105
|
this.geoidHeightModel = await (0, core_1.load)(egmFilePath, pgm_loader_1.PGMLoader);
|
|
94
106
|
console.log('Loading egm file completed!'); // eslint-disable-line
|
|
95
107
|
if (slpk) {
|
|
96
108
|
this.nodePages.useWriteFunction(file_utils_1.writeFileForSlpk);
|
|
97
109
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
tilesetOptions
|
|
110
|
+
await this.loadWorkers();
|
|
111
|
+
try {
|
|
112
|
+
const preloadOptions = await this._fetchPreloadOptions();
|
|
113
|
+
const tilesetOptions = { loadOptions: { basis: { format: 'rgba32' } } };
|
|
114
|
+
if (preloadOptions.headers) {
|
|
115
|
+
tilesetOptions.loadOptions.fetch = { headers: preloadOptions.headers };
|
|
116
|
+
}
|
|
117
|
+
Object.assign(tilesetOptions, preloadOptions);
|
|
118
|
+
const sourceTilesetJson = await (0, core_1.load)(inputUrl, this.Loader, tilesetOptions.loadOptions);
|
|
119
|
+
// console.log(tilesetJson); // eslint-disable-line
|
|
120
|
+
this.sourceTileset = new tiles_1.Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
121
|
+
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
122
|
+
await this._finishConversion({ slpk: Boolean(slpk), outputPath, tilesetName });
|
|
123
|
+
return sourceTilesetJson;
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
// Clean up worker pools
|
|
130
|
+
const workerFarm = worker_utils_1.WorkerFarm.getWorkerFarm({});
|
|
131
|
+
workerFarm.destroy();
|
|
102
132
|
}
|
|
103
|
-
Object.assign(tilesetOptions, preloadOptions);
|
|
104
|
-
const sourceTilesetJson = await (0, core_1.load)(inputUrl, this.Loader, tilesetOptions.loadOptions);
|
|
105
|
-
// console.log(tilesetJson); // eslint-disable-line
|
|
106
|
-
this.sourceTileset = new tiles_1.Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
107
|
-
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
108
|
-
await this._finishConversion({ slpk: Boolean(slpk), outputPath, tilesetName });
|
|
109
|
-
return sourceTilesetJson;
|
|
110
133
|
}
|
|
111
134
|
/**
|
|
112
135
|
* Convert and save the layer and embedded tiles
|
|
@@ -145,7 +168,8 @@ class I3SConverter {
|
|
|
145
168
|
await this._writeLayers0();
|
|
146
169
|
(0, create_scene_server_path_1.createSceneServerPath)(tilesetName, this.layers0, tilesetPath);
|
|
147
170
|
await this._writeNodeIndexDocument(root0, 'root', (0, path_1.join)(this.layers0Path, 'nodes', 'root'));
|
|
148
|
-
await this.nodePages.save(this.layers0Path, this.
|
|
171
|
+
await this.nodePages.save(this.layers0Path, this.writeQueue, isCreateSlpk);
|
|
172
|
+
await this.writeQueue.finalize();
|
|
149
173
|
await this._createSlpk(tilesetPath);
|
|
150
174
|
}
|
|
151
175
|
/**
|
|
@@ -153,7 +177,8 @@ class I3SConverter {
|
|
|
153
177
|
* @param tilesetName - Name of layer
|
|
154
178
|
*/
|
|
155
179
|
_formLayers0(tilesetName) {
|
|
156
|
-
const
|
|
180
|
+
const fullExtent = (0, coordinate_converter_1.convertBoundingVolumeToI3SFullExtent)(this.sourceTileset?.boundingVolume || this.sourceTileset?.root?.boundingVolume);
|
|
181
|
+
const extent = [fullExtent.xmin, fullExtent.ymin, fullExtent.xmax, fullExtent.ymax];
|
|
157
182
|
const layers0data = {
|
|
158
183
|
version: `{${(0, uuid_1.v4)().toUpperCase()}}`,
|
|
159
184
|
id: 0,
|
|
@@ -166,7 +191,8 @@ class I3SConverter {
|
|
|
166
191
|
nodePages: {
|
|
167
192
|
nodesPerPage: HARDCODED_NODES_PER_PAGE
|
|
168
193
|
},
|
|
169
|
-
compressGeometry: this.options.draco
|
|
194
|
+
compressGeometry: this.options.draco,
|
|
195
|
+
fullExtent
|
|
170
196
|
};
|
|
171
197
|
this.layers0 = (0, json_map_transform_1.default)(layers0data, (0, layers_1.LAYERS)());
|
|
172
198
|
}
|
|
@@ -214,10 +240,13 @@ class I3SConverter {
|
|
|
214
240
|
const [child] = await this._createNode(root0, sourceRootTile, parentId, 0);
|
|
215
241
|
const childPath = (0, path_1.join)(this.layers0Path, 'nodes', child.path);
|
|
216
242
|
if (this.options.slpk) {
|
|
217
|
-
this.
|
|
243
|
+
this.writeQueue.enqueue({
|
|
244
|
+
archiveKey: 'nodes/1/3dNodeIndexDocument.json.gz',
|
|
245
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(childPath, JSON.stringify(child), '3dNodeIndexDocument.json')
|
|
246
|
+
});
|
|
218
247
|
}
|
|
219
248
|
else {
|
|
220
|
-
|
|
249
|
+
this.writeQueue.enqueue({ writePromise: (0, file_utils_1.writeFile)(childPath, JSON.stringify(child)) });
|
|
221
250
|
}
|
|
222
251
|
}
|
|
223
252
|
else {
|
|
@@ -235,10 +264,15 @@ class I3SConverter {
|
|
|
235
264
|
*/
|
|
236
265
|
async _writeLayers0() {
|
|
237
266
|
if (this.options.slpk) {
|
|
238
|
-
this.
|
|
267
|
+
this.writeQueue.enqueue({
|
|
268
|
+
archiveKey: '3dSceneLayer.json.gz',
|
|
269
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
|
|
270
|
+
});
|
|
239
271
|
}
|
|
240
272
|
else {
|
|
241
|
-
|
|
273
|
+
this.writeQueue.enqueue({
|
|
274
|
+
writePromise: (0, file_utils_1.writeFile)(this.layers0Path, JSON.stringify(this.layers0))
|
|
275
|
+
});
|
|
242
276
|
}
|
|
243
277
|
}
|
|
244
278
|
/**
|
|
@@ -246,10 +280,13 @@ class I3SConverter {
|
|
|
246
280
|
*/
|
|
247
281
|
async _writeNodeIndexDocument(root0, nodePath, rootPath) {
|
|
248
282
|
if (this.options.slpk) {
|
|
249
|
-
this.
|
|
283
|
+
this.writeQueue.enqueue({
|
|
284
|
+
archiveKey: `nodes/${nodePath}/3dNodeIndexDocument.json.gz`,
|
|
285
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json')
|
|
286
|
+
});
|
|
250
287
|
}
|
|
251
288
|
else {
|
|
252
|
-
|
|
289
|
+
this.writeQueue.enqueue({ writePromise: (0, file_utils_1.writeFile)(rootPath, JSON.stringify(root0)) });
|
|
253
290
|
}
|
|
254
291
|
}
|
|
255
292
|
/**
|
|
@@ -260,9 +297,7 @@ class I3SConverter {
|
|
|
260
297
|
if (this.options.slpk) {
|
|
261
298
|
const slpkTilesetPath = (0, path_1.join)(tilesetPath, 'SceneServer', 'layers', '0');
|
|
262
299
|
const slpkFileName = `${tilesetPath}.slpk`;
|
|
263
|
-
await (0, compress_util_1.compressWithChildProcess)(slpkTilesetPath, slpkFileName, 0, '.',
|
|
264
|
-
// @ts-expect-error
|
|
265
|
-
this.options.sevenZipExe);
|
|
300
|
+
await (0, compress_util_1.compressWithChildProcess)(slpkTilesetPath, slpkFileName, 0, '.', this.options.sevenZipExe);
|
|
266
301
|
// TODO: `addFileToZip` corrupts archive so it can't be validated with windows i3s_converter.exe
|
|
267
302
|
// const fileHash128Path = `${tilesetPath}/@specialIndexFileHASH128@`;
|
|
268
303
|
// try {
|
|
@@ -468,7 +503,7 @@ class I3SConverter {
|
|
|
468
503
|
if (!this.isContentSupported(sourceTile)) {
|
|
469
504
|
return null;
|
|
470
505
|
}
|
|
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);
|
|
506
|
+
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
507
|
return resourcesData;
|
|
473
508
|
}
|
|
474
509
|
/**
|
|
@@ -601,20 +636,30 @@ class I3SConverter {
|
|
|
601
636
|
async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
|
|
602
637
|
if (this.options.slpk) {
|
|
603
638
|
const slpkGeometryPath = (0, path_1.join)(childPath, 'geometries');
|
|
604
|
-
this.
|
|
639
|
+
this.writeQueue.enqueue({
|
|
640
|
+
archiveKey: `${slpkChildPath}/geometries/0.bin.gz`,
|
|
641
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(slpkGeometryPath, geometryBuffer, '0.bin')
|
|
642
|
+
});
|
|
605
643
|
}
|
|
606
644
|
else {
|
|
607
645
|
const geometryPath = (0, path_1.join)(childPath, 'geometries/0/');
|
|
608
|
-
|
|
646
|
+
this.writeQueue.enqueue({
|
|
647
|
+
writePromise: (0, file_utils_1.writeFile)(geometryPath, geometryBuffer, 'index.bin')
|
|
648
|
+
});
|
|
609
649
|
}
|
|
610
650
|
if (this.options.draco) {
|
|
611
651
|
if (this.options.slpk) {
|
|
612
652
|
const slpkCompressedGeometryPath = (0, path_1.join)(childPath, 'geometries');
|
|
613
|
-
this.
|
|
653
|
+
this.writeQueue.enqueue({
|
|
654
|
+
archiveKey: `${slpkChildPath}/geometries/1.bin.gz`,
|
|
655
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
|
|
656
|
+
});
|
|
614
657
|
}
|
|
615
658
|
else {
|
|
616
659
|
const compressedGeometryPath = (0, path_1.join)(childPath, 'geometries/1/');
|
|
617
|
-
|
|
660
|
+
this.writeQueue.enqueue({
|
|
661
|
+
writePromise: (0, file_utils_1.writeFile)(compressedGeometryPath, compressedGeometry, 'index.bin')
|
|
662
|
+
});
|
|
618
663
|
}
|
|
619
664
|
}
|
|
620
665
|
}
|
|
@@ -626,16 +671,22 @@ class I3SConverter {
|
|
|
626
671
|
* @param nodePath - a node path
|
|
627
672
|
*/
|
|
628
673
|
async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
|
|
674
|
+
if (!sharedResources) {
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
629
677
|
sharedResources.nodePath = nodePath;
|
|
630
678
|
const sharedData = (0, json_map_transform_1.default)(sharedResources, (0, shared_resources_1.SHARED_RESOURCES)());
|
|
631
679
|
const sharedDataStr = JSON.stringify(sharedData);
|
|
632
680
|
if (this.options.slpk) {
|
|
633
681
|
const slpkSharedPath = (0, path_1.join)(childPath, 'shared');
|
|
634
|
-
this.
|
|
682
|
+
this.writeQueue.enqueue({
|
|
683
|
+
archiveKey: `${slpkChildPath}/shared/sharedResource.json.gz`,
|
|
684
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(slpkSharedPath, sharedDataStr, 'sharedResource.json')
|
|
685
|
+
});
|
|
635
686
|
}
|
|
636
687
|
else {
|
|
637
688
|
const sharedPath = (0, path_1.join)(childPath, 'shared/');
|
|
638
|
-
|
|
689
|
+
this.writeQueue.enqueue({ writePromise: (0, file_utils_1.writeFile)(sharedPath, sharedDataStr) });
|
|
639
690
|
}
|
|
640
691
|
}
|
|
641
692
|
/**
|
|
@@ -656,7 +707,12 @@ class I3SConverter {
|
|
|
656
707
|
await this.writeTextureFile(textureData, '0', format, childPath, slpkChildPath);
|
|
657
708
|
if (this.generateTextures) {
|
|
658
709
|
formats.push({ name: '1', format: 'ktx2' });
|
|
659
|
-
const ktx2TextureData =
|
|
710
|
+
const ktx2TextureData = (0, core_1.encode)(texture.image, textures_1.KTX2BasisWriterWorker, {
|
|
711
|
+
...textures_1.KTX2BasisWriterWorker.options,
|
|
712
|
+
source: this.workerSource.ktx2,
|
|
713
|
+
reuseWorkers: true,
|
|
714
|
+
_nodeWorkers: true
|
|
715
|
+
});
|
|
660
716
|
await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
|
|
661
717
|
}
|
|
662
718
|
break;
|
|
@@ -666,7 +722,7 @@ class I3SConverter {
|
|
|
666
722
|
await this.writeTextureFile(textureData, '1', format, childPath, slpkChildPath);
|
|
667
723
|
if (this.generateTextures) {
|
|
668
724
|
formats.push({ name: '0', format: 'jpg' });
|
|
669
|
-
const decodedFromKTX2TextureData =
|
|
725
|
+
const decodedFromKTX2TextureData = (0, core_1.encode)(texture.image.data[0], images_1.ImageWriter);
|
|
670
726
|
await this.writeTextureFile(decodedFromKTX2TextureData, '0', 'jpg', childPath, slpkChildPath);
|
|
671
727
|
}
|
|
672
728
|
}
|
|
@@ -688,11 +744,16 @@ class I3SConverter {
|
|
|
688
744
|
if (this.options.slpk) {
|
|
689
745
|
const slpkTexturePath = (0, path_1.join)(childPath, 'textures');
|
|
690
746
|
const compress = false;
|
|
691
|
-
this.
|
|
747
|
+
this.writeQueue.enqueue({
|
|
748
|
+
archiveKey: `${slpkChildPath}/textures/${name}.${format}`,
|
|
749
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(slpkTexturePath, textureData, `${name}.${format}`, compress)
|
|
750
|
+
});
|
|
692
751
|
}
|
|
693
752
|
else {
|
|
694
753
|
const texturePath = (0, path_1.join)(childPath, `textures/${name}/`);
|
|
695
|
-
|
|
754
|
+
this.writeQueue.enqueue({
|
|
755
|
+
writePromise: (0, file_utils_1.writeFile)(texturePath, textureData, `index.${format}`)
|
|
756
|
+
});
|
|
696
757
|
}
|
|
697
758
|
}
|
|
698
759
|
/**
|
|
@@ -701,18 +762,23 @@ class I3SConverter {
|
|
|
701
762
|
* @param childPath - a child path to write resources
|
|
702
763
|
* @param slpkChildPath - the resource path inside *slpk file
|
|
703
764
|
*/
|
|
704
|
-
async _writeAttributes(attributes, childPath, slpkChildPath) {
|
|
705
|
-
if (attributes
|
|
765
|
+
async _writeAttributes(attributes = [], childPath, slpkChildPath) {
|
|
766
|
+
if (attributes?.length && this.layers0?.attributeStorageInfo?.length) {
|
|
706
767
|
for (let index = 0; index < attributes.length; index++) {
|
|
707
768
|
const folderName = this.layers0.attributeStorageInfo[index].key;
|
|
708
769
|
const fileBuffer = new Uint8Array(attributes[index]);
|
|
709
770
|
if (this.options.slpk) {
|
|
710
771
|
const slpkAttributesPath = (0, path_1.join)(childPath, 'attributes', folderName);
|
|
711
|
-
this.
|
|
772
|
+
this.writeQueue.enqueue({
|
|
773
|
+
archiveKey: `${slpkChildPath}/attributes/${folderName}.bin.gz`,
|
|
774
|
+
writePromise: (0, file_utils_1.writeFileForSlpk)(slpkAttributesPath, fileBuffer, '0.bin')
|
|
775
|
+
});
|
|
712
776
|
}
|
|
713
777
|
else {
|
|
714
778
|
const attributesPath = (0, path_1.join)(childPath, `attributes/${folderName}/0`);
|
|
715
|
-
|
|
779
|
+
this.writeQueue.enqueue({
|
|
780
|
+
writePromise: (0, file_utils_1.writeFile)(attributesPath, fileBuffer, 'index.bin')
|
|
781
|
+
});
|
|
716
782
|
}
|
|
717
783
|
}
|
|
718
784
|
}
|
|
@@ -990,5 +1056,25 @@ class I3SConverter {
|
|
|
990
1056
|
isContentSupported(sourceRootTile) {
|
|
991
1057
|
return ['b3dm', 'glTF'].includes(sourceRootTile?.content?.type);
|
|
992
1058
|
}
|
|
1059
|
+
async loadWorkers() {
|
|
1060
|
+
console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console
|
|
1061
|
+
if (this.options.draco) {
|
|
1062
|
+
const url = (0, worker_utils_1.getWorkerURL)(draco_1.DracoWriterWorker, { ...(0, core_1.getLoaderOptions)() });
|
|
1063
|
+
const sourceResponse = await (0, core_1.fetchFile)(url);
|
|
1064
|
+
const source = await sourceResponse.text();
|
|
1065
|
+
this.workerSource.draco = source;
|
|
1066
|
+
}
|
|
1067
|
+
if (this.generateTextures) {
|
|
1068
|
+
const url = (0, worker_utils_1.getWorkerURL)(textures_1.KTX2BasisWriterWorker, { ...(0, core_1.getLoaderOptions)() });
|
|
1069
|
+
const sourceResponse = await (0, core_1.fetchFile)(url);
|
|
1070
|
+
const source = await sourceResponse.text();
|
|
1071
|
+
this.workerSource.ktx2 = source;
|
|
1072
|
+
}
|
|
1073
|
+
const i3sAttributesWorkerUrl = (0, worker_utils_1.getWorkerURL)(i3s_attributes_worker_1.I3SAttributesWorker, { ...(0, core_1.getLoaderOptions)() });
|
|
1074
|
+
const sourceResponse = await (0, core_1.fetchFile)(i3sAttributesWorkerUrl);
|
|
1075
|
+
const source = await sourceResponse.text();
|
|
1076
|
+
this.workerSource.I3SAttributes = source;
|
|
1077
|
+
console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console
|
|
1078
|
+
}
|
|
993
1079
|
}
|
|
994
1080
|
exports.default = I3SConverter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layers.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/json-templates/layers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"layers.d.ts","sourceRoot":"","sources":["../../../src/i3s-converter/json-templates/layers.ts"],"names":[],"mappings":"AA0IA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuFjB,CAAC"}
|
|
@@ -113,6 +113,26 @@ const NODE_PAGES = () => ({
|
|
|
113
113
|
default: 'maxScreenThresholdSQ'
|
|
114
114
|
}
|
|
115
115
|
});
|
|
116
|
+
const FULL_EXTENT = () => ({
|
|
117
|
+
xmin: {
|
|
118
|
+
path: 'xmin'
|
|
119
|
+
},
|
|
120
|
+
ymin: {
|
|
121
|
+
path: 'ymin'
|
|
122
|
+
},
|
|
123
|
+
xmax: {
|
|
124
|
+
path: 'xmax'
|
|
125
|
+
},
|
|
126
|
+
ymax: {
|
|
127
|
+
path: 'ymax'
|
|
128
|
+
},
|
|
129
|
+
zmin: {
|
|
130
|
+
path: 'zmin'
|
|
131
|
+
},
|
|
132
|
+
zmax: {
|
|
133
|
+
path: 'zmax'
|
|
134
|
+
}
|
|
135
|
+
});
|
|
116
136
|
const LAYERS = () => ({
|
|
117
137
|
version: {
|
|
118
138
|
path: 'version',
|
|
@@ -145,6 +165,10 @@ const LAYERS = () => ({
|
|
|
145
165
|
path: 'store',
|
|
146
166
|
transform: (val) => (0, json_map_transform_1.default)(val, store_1.STORE)
|
|
147
167
|
},
|
|
168
|
+
fullExtent: {
|
|
169
|
+
path: 'fullExtent',
|
|
170
|
+
transform: (val) => (0, json_map_transform_1.default)(val, FULL_EXTENT())
|
|
171
|
+
},
|
|
148
172
|
heightModelInfo: {
|
|
149
173
|
path: 'heightModelInfo',
|
|
150
174
|
transform: (val) => (0, json_map_transform_1.default)(val, HEIGHT_MODEL_INFO())
|