@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
|
@@ -12,6 +12,9 @@ export default class Tiles3DConverter {
|
|
|
12
12
|
geoidHeightModel: Geoid | null;
|
|
13
13
|
sourceTileset: Tileset3D | null;
|
|
14
14
|
attributeStorageInfo: AttributeStorageInfo | null;
|
|
15
|
+
workerSource: {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
};
|
|
15
18
|
constructor();
|
|
16
19
|
/**
|
|
17
20
|
* Convert i3s format data to 3dTiles
|
|
@@ -26,7 +29,7 @@ export default class Tiles3DConverter {
|
|
|
26
29
|
inputUrl: string;
|
|
27
30
|
outputPath: string;
|
|
28
31
|
tilesetName: string;
|
|
29
|
-
maxDepth
|
|
32
|
+
maxDepth?: number;
|
|
30
33
|
egmFilePath: string;
|
|
31
34
|
}): Promise<any>;
|
|
32
35
|
/**
|
|
@@ -74,5 +77,6 @@ export default class Tiles3DConverter {
|
|
|
74
77
|
* @param params - output files data
|
|
75
78
|
*/
|
|
76
79
|
private _finishConversion;
|
|
80
|
+
private loadWorkers;
|
|
77
81
|
}
|
|
78
82
|
//# sourceMappingURL=3d-tiles-converter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"3d-tiles-converter.d.ts","sourceRoot":"","sources":["../../src/3d-tiles-converter/3d-tiles-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAkC,MAAM,iBAAiB,CAAC;AAQ3F,OAAO,EAAC,SAAS,EAAS,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"3d-tiles-converter.d.ts","sourceRoot":"","sources":["../../src/3d-tiles-converter/3d-tiles-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAkC,MAAM,iBAAiB,CAAC;AAQ3F,OAAO,EAAC,SAAS,EAAS,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAC,KAAK,EAAC,MAAM,gBAAgB,CAAC;AAoBrC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,OAAO,EAAE,GAAG,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,gBAAgB,EAAE,KAAK,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,SAAS,GAAG,IAAI,CAAC;IAChC,oBAAoB,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAClD,YAAY,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAC,CAAM;;IAa3C;;;;;;;;OAQG;IACU,OAAO,CAAC,OAAO,EAAE;QAC5B,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,GAAG,OAAO,CAAC,GAAG,CAAC;IA0DhB;;;;;OAKG;YACW,YAAY;IAgE1B;;;;;OAKG;YACW,cAAc;IAyB5B;;;;OAIG;IACH,OAAO,CAAC,qBAAqB;IAiB7B;;;;;OAKG;YACW,oBAAoB;IAsBlC;;;;;;OAMG;IACH,OAAO,CAAC,iBAAiB;IASzB;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAU5B;;;OAGG;YACW,iBAAiB;YAiBjB,WAAW;CAS1B"}
|
|
@@ -17,12 +17,16 @@ const statistic_utills_1 = require("../lib/utils/statistic-utills");
|
|
|
17
17
|
const tileset_1 = require("./json-templates/tileset");
|
|
18
18
|
const b3dm_converter_1 = __importDefault(require("./helpers/b3dm-converter"));
|
|
19
19
|
const coordinate_converter_1 = require("../i3s-converter/helpers/coordinate-converter");
|
|
20
|
+
const _3d_tiles_attributes_worker_1 = require("../3d-tiles-attributes-worker");
|
|
21
|
+
const worker_utils_1 = require("@loaders.gl/worker-utils");
|
|
22
|
+
const constants_1 = require("../constants");
|
|
20
23
|
const I3S = 'I3S';
|
|
21
24
|
/**
|
|
22
25
|
* Converter from i3s to 3d-tiles
|
|
23
26
|
*/
|
|
24
27
|
class Tiles3DConverter {
|
|
25
28
|
constructor() {
|
|
29
|
+
this.workerSource = {};
|
|
26
30
|
this.options = {};
|
|
27
31
|
this.tilesetPath = '';
|
|
28
32
|
this.vertexCounter = 0;
|
|
@@ -30,6 +34,7 @@ class Tiles3DConverter {
|
|
|
30
34
|
this.geoidHeightModel = null;
|
|
31
35
|
this.sourceTileset = null;
|
|
32
36
|
this.attributeStorageInfo = null;
|
|
37
|
+
this.workerSource = {};
|
|
33
38
|
}
|
|
34
39
|
/**
|
|
35
40
|
* Convert i3s format data to 3dTiles
|
|
@@ -41,18 +46,24 @@ class Tiles3DConverter {
|
|
|
41
46
|
* @param options.maxDepth The max tree depth of conversion
|
|
42
47
|
*/
|
|
43
48
|
async convert(options) {
|
|
49
|
+
if (core_1.isBrowser) {
|
|
50
|
+
console.log(constants_1.BROWSER_ERROR_MESSAGE);
|
|
51
|
+
return constants_1.BROWSER_ERROR_MESSAGE;
|
|
52
|
+
}
|
|
44
53
|
const { inputUrl, outputPath, tilesetName, maxDepth, egmFilePath } = options;
|
|
45
54
|
this.conversionStartTime = process_1.default.hrtime();
|
|
46
55
|
this.options = { maxDepth };
|
|
47
56
|
console.log('Loading egm file...'); // eslint-disable-line
|
|
48
57
|
this.geoidHeightModel = await (0, core_1.load)(egmFilePath, pgm_loader_1.PGMLoader);
|
|
49
58
|
console.log('Loading egm file completed!'); // eslint-disable-line
|
|
59
|
+
await this.loadWorkers();
|
|
50
60
|
const sourceTilesetJson = await (0, core_1.load)(inputUrl, i3s_1.I3SLoader, {});
|
|
51
61
|
this.sourceTileset = new tiles_1.Tileset3D(sourceTilesetJson, {
|
|
52
62
|
loadOptions: {
|
|
53
63
|
i3s: { coordinateSystem: i3s_1.COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false }
|
|
54
64
|
}
|
|
55
65
|
});
|
|
66
|
+
await this.sourceTileset.tilesetInitializationPromise;
|
|
56
67
|
const rootNode = this.sourceTileset.root;
|
|
57
68
|
if (!rootNode.header.obb) {
|
|
58
69
|
rootNode.header.obb = (0, coordinate_converter_1.createObbFromMbs)(rootNode.header.mbs);
|
|
@@ -77,6 +88,9 @@ class Tiles3DConverter {
|
|
|
77
88
|
const tileset = (0, json_map_transform_1.default)({ root: rootTile }, (0, tileset_1.TILESET)());
|
|
78
89
|
await (0, file_utils_1.writeFile)(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');
|
|
79
90
|
this._finishConversion({ slpk: false, outputPath, tilesetName });
|
|
91
|
+
// Clean up worker pools
|
|
92
|
+
const workerFarm = worker_utils_1.WorkerFarm.getWorkerFarm({});
|
|
93
|
+
workerFarm.destroy();
|
|
80
94
|
}
|
|
81
95
|
/**
|
|
82
96
|
* The recursive function of traversal of a nodes tree
|
|
@@ -94,9 +108,9 @@ class Tiles3DConverter {
|
|
|
94
108
|
if (sourceChild.contentUrl) {
|
|
95
109
|
await this.sourceTileset._loadTile(sourceChild);
|
|
96
110
|
this.vertexCounter += sourceChild.content.vertexCount;
|
|
97
|
-
let
|
|
111
|
+
let featureAttributes = null;
|
|
98
112
|
if (this.attributeStorageInfo) {
|
|
99
|
-
|
|
113
|
+
featureAttributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);
|
|
100
114
|
}
|
|
101
115
|
if (!sourceChild.header.obb) {
|
|
102
116
|
sourceChild.header.obb = (0, coordinate_converter_1.createObbFromMbs)(sourceChild.header.mbs);
|
|
@@ -109,7 +123,16 @@ class Tiles3DConverter {
|
|
|
109
123
|
geometricError: (0, lod_conversion_utils_1.convertScreenThresholdToGeometricError)(sourceChild),
|
|
110
124
|
children: []
|
|
111
125
|
};
|
|
112
|
-
const
|
|
126
|
+
const i3sAttributesData = {
|
|
127
|
+
tileContent: sourceChild.content,
|
|
128
|
+
textureFormat: sourceChild?.header?.textureFormat
|
|
129
|
+
};
|
|
130
|
+
// TODO Uncomment when 3d-tiles-attributes-worker will be published on CDN.
|
|
131
|
+
// const b3dm = await transform3DTilesAttributesOnWorker(i3sAttributesData, {
|
|
132
|
+
// source: this.workerSource.tile3dWorkerSource,
|
|
133
|
+
// featureAttributes
|
|
134
|
+
// });
|
|
135
|
+
const b3dm = await new b3dm_converter_1.default().convert(i3sAttributesData, featureAttributes);
|
|
113
136
|
child.content = {
|
|
114
137
|
uri: `${sourceChild.id}.b3dm`,
|
|
115
138
|
boundingVolume
|
|
@@ -238,5 +261,13 @@ class Tiles3DConverter {
|
|
|
238
261
|
console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line
|
|
239
262
|
console.log(`------------------------------------------------`); // eslint-disable-line
|
|
240
263
|
}
|
|
264
|
+
async loadWorkers() {
|
|
265
|
+
console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console
|
|
266
|
+
const tile3dAttributesWorkerUrl = (0, worker_utils_1.getWorkerURL)(_3d_tiles_attributes_worker_1.Tile3dAttributesWorker, { ...(0, core_1.getLoaderOptions)() });
|
|
267
|
+
const sourceResponse = await (0, core_1.fetchFile)(tile3dAttributesWorkerUrl);
|
|
268
|
+
const source = await sourceResponse.text();
|
|
269
|
+
this.workerSource.tile3dWorkerSource = source;
|
|
270
|
+
console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console
|
|
271
|
+
}
|
|
241
272
|
}
|
|
242
273
|
exports.default = Tiles3DConverter;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { I3SAttributesData } from '../../3d-tiles-attributes-worker';
|
|
1
2
|
import { Matrix4 } from '@math.gl/core';
|
|
2
3
|
/**
|
|
3
4
|
* Converts content of an I3S node to *.b3dm's file content
|
|
@@ -10,20 +11,20 @@ export default class B3dmConverter {
|
|
|
10
11
|
* @param i3sTile - Tile3D instance for I3S node
|
|
11
12
|
* @returns - encoded content
|
|
12
13
|
*/
|
|
13
|
-
convert(
|
|
14
|
+
convert(i3sAttributesData: I3SAttributesData, featureAttributes?: any): Promise<ArrayBuffer>;
|
|
14
15
|
/**
|
|
15
16
|
* Build and encode gltf
|
|
16
17
|
* @param i3sTile - Tile3D instance for I3S node
|
|
17
18
|
* @returns - encoded glb content
|
|
18
19
|
*/
|
|
19
|
-
buildGltf(
|
|
20
|
+
buildGltf(i3sAttributesData: I3SAttributesData): Promise<ArrayBuffer>;
|
|
20
21
|
/**
|
|
21
22
|
* Update gltfBuilder with texture from I3S tile
|
|
22
23
|
* @param {object} i3sTile - Tile3D object
|
|
23
24
|
* @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF
|
|
24
25
|
* @returns {Promise<number | null>} - GLTF texture index
|
|
25
26
|
*/
|
|
26
|
-
_addI3sTextureToGltf(
|
|
27
|
+
_addI3sTextureToGltf(tileContent: any, textureFormat: any, gltfBuilder: any): Promise<null>;
|
|
27
28
|
/**
|
|
28
29
|
* Generate a positions array which is correct for 3DTiles/GLTF format
|
|
29
30
|
* @param {Float64Array} positionsValue - the input geometry positions array
|
|
@@ -62,7 +63,7 @@ export default class B3dmConverter {
|
|
|
62
63
|
* @param {string} format - format name
|
|
63
64
|
* @returns {string} mime type.
|
|
64
65
|
*/
|
|
65
|
-
_deduceMimeTypeFromFormat(format: any): "image/jpeg" | "image/
|
|
66
|
+
_deduceMimeTypeFromFormat(format: any): "image/jpeg" | "image/png" | "image/ktx2";
|
|
66
67
|
/**
|
|
67
68
|
* Convert i3s material to GLTF compatible material
|
|
68
69
|
* @param {object} material - i3s material definition
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"b3dm-converter.d.ts","sourceRoot":"","sources":["../../../src/3d-tiles-converter/helpers/b3dm-converter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"b3dm-converter.d.ts","sourceRoot":"","sources":["../../../src/3d-tiles-converter/helpers/b3dm-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,kCAAkC,CAAC;AAKxE,OAAO,EAAC,OAAO,EAAU,MAAM,eAAe,CAAC;AAO/C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAEhC,SAAS,EAAE,YAAY,CAAC;IACxB,OAAO,EAAE,GAAG,CAAC;IAEb;;;;OAIG;IACG,OAAO,CACX,iBAAiB,EAAE,iBAAiB,EACpC,iBAAiB,GAAE,GAAU,GAC5B,OAAO,CAAC,WAAW,CAAC;IAcvB;;;;OAIG;IACG,SAAS,CAAC,iBAAiB,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAuD3E;;;;;OAKG;IACG,oBAAoB,CAAC,WAAW,KAAA,EAAE,aAAa,KAAA,EAAE,WAAW,KAAA;IAmBlE;;;;;;;OAOG;IACH,mBAAmB,CAAC,cAAc,KAAA,EAAE,eAAe,KAAA,EAAE,kBAAkB,KAAA,EAAE,WAAW,KAAA;IAepF;;;;;;;OAOG;IACH,wBAAwB,CAAC,eAAe,KAAA;IAMxC;;;;OAIG;IACH,gBAAgB,CAAC,UAAU,KAAA;IAiB3B;;;;;;OAMG;IACH,wBAAwB,CAAC,WAAW,KAAA;IAQpC;;;;;OAKG;IACH,yBAAyB,CAAC,MAAM,KAAA;IAchC;;;;;OAKG;IACH,iCAAiC,CAAC,QAAQ,KAAA,EAAE,YAAY,KAAA;IAgCxD;;;;;OAKG;IACH,eAAe,CAAC,kBAAkB,KAAA,EAAE,YAAY,KAAA;IA+ChD,kBAAkB,CAAC,UAAU,KAAA;IAY7B,aAAa,CAAC,OAAO,KAAA;CAItB"}
|
|
@@ -17,14 +17,13 @@ class B3dmConverter {
|
|
|
17
17
|
* @param i3sTile - Tile3D instance for I3S node
|
|
18
18
|
* @returns - encoded content
|
|
19
19
|
*/
|
|
20
|
-
async convert(
|
|
21
|
-
|
|
22
|
-
const gltf = await this.buildGltf(i3sTile);
|
|
20
|
+
async convert(i3sAttributesData, featureAttributes = null) {
|
|
21
|
+
const gltf = await this.buildGltf(i3sAttributesData);
|
|
23
22
|
const b3dm = (0, core_1.encodeSync)({
|
|
24
23
|
gltfEncoded: new Uint8Array(gltf),
|
|
25
24
|
type: 'b3dm',
|
|
26
|
-
featuresLength: this._getFeaturesLength(
|
|
27
|
-
batchTable:
|
|
25
|
+
featuresLength: this._getFeaturesLength(featureAttributes),
|
|
26
|
+
batchTable: featureAttributes
|
|
28
27
|
}, _3d_tiles_1.Tile3DWriter);
|
|
29
28
|
return b3dm;
|
|
30
29
|
}
|
|
@@ -33,10 +32,11 @@ class B3dmConverter {
|
|
|
33
32
|
* @param i3sTile - Tile3D instance for I3S node
|
|
34
33
|
* @returns - encoded glb content
|
|
35
34
|
*/
|
|
36
|
-
async buildGltf(
|
|
37
|
-
const {
|
|
35
|
+
async buildGltf(i3sAttributesData) {
|
|
36
|
+
const { tileContent, textureFormat } = i3sAttributesData;
|
|
37
|
+
const { material, attributes, indices: originalIndices, cartesianOrigin, cartographicOrigin, modelMatrix } = tileContent;
|
|
38
38
|
const gltfBuilder = new gltf_1.GLTFScenegraph();
|
|
39
|
-
const textureIndex = await this._addI3sTextureToGltf(
|
|
39
|
+
const textureIndex = await this._addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder);
|
|
40
40
|
const pbrMaterialInfo = this._convertI3sMaterialToGltfMaterial(material, textureIndex);
|
|
41
41
|
const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
|
|
42
42
|
const positions = attributes.positions;
|
|
@@ -69,8 +69,8 @@ class B3dmConverter {
|
|
|
69
69
|
* @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF
|
|
70
70
|
* @returns {Promise<number | null>} - GLTF texture index
|
|
71
71
|
*/
|
|
72
|
-
async _addI3sTextureToGltf(
|
|
73
|
-
const {
|
|
72
|
+
async _addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder) {
|
|
73
|
+
const { texture, material, attributes } = tileContent;
|
|
74
74
|
let textureIndex = null;
|
|
75
75
|
let selectedTexture = texture;
|
|
76
76
|
if (!texture && material) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,yEACsC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"converter-cli.d.ts","sourceRoot":"","sources":["../src/converter-cli.ts"],"names":[],"mappings":"AACA,OAAO,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable no-console */
|
|
4
|
+
require("@loaders.gl/polyfills");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const tile_converter_1 = require("@loaders.gl/tile-converter");
|
|
7
|
+
const deps_installer_1 = require("./deps-installer/deps-installer");
|
|
8
|
+
const TILESET_TYPE = {
|
|
9
|
+
I3S: 'I3S',
|
|
10
|
+
_3DTILES: '3DTILES'
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* CLI entry
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
async function main() {
|
|
17
|
+
const [, , ...args] = process.argv;
|
|
18
|
+
if (args.length === 0) {
|
|
19
|
+
printHelp();
|
|
20
|
+
}
|
|
21
|
+
const options = parseOptions(args);
|
|
22
|
+
if (options.installDependencies) {
|
|
23
|
+
const depthInstaller = new deps_installer_1.DepsInstaller();
|
|
24
|
+
depthInstaller.install('deps');
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const validatedOptions = validateOptions(options);
|
|
28
|
+
await convert(validatedOptions);
|
|
29
|
+
}
|
|
30
|
+
main().catch((error) => {
|
|
31
|
+
console.log(error);
|
|
32
|
+
process.exit(1); // eslint-disable-line
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Output for `npx tile-converter --help`
|
|
36
|
+
*/
|
|
37
|
+
function printHelp() {
|
|
38
|
+
console.log('cli: converter 3dTiles to I3S or I3S to 3dTiles...');
|
|
39
|
+
console.log('--install-dependencies [Run the script for installing dependencies. Run this options separate from others. Now "*.pgm" file installation is implemented]');
|
|
40
|
+
console.log('--max-depth [Maximal depth of hierarchical tiles tree traversal, default: infinite]');
|
|
41
|
+
console.log('--name [Tileset name]');
|
|
42
|
+
console.log('--output [Output folder, default: "data" folder]');
|
|
43
|
+
console.log('--slpk [Generate slpk (Scene Layer Packages) I3S output file]');
|
|
44
|
+
console.log('--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]');
|
|
45
|
+
console.log('--input-type [tileset input type: I3S or 3DTILES]');
|
|
46
|
+
console.log('--7zExe [location of 7z.exe archiver to create slpk on Windows, default: "C:\\Program Files\\7-Zip\\7z.exe"]');
|
|
47
|
+
console.log('--egm [location of Earth Gravity Model *.pgm file to convert heights from ellipsoidal to gravity-related format. A model file can be loaded from GeographicLib https://geographiclib.sourceforge.io/html/geoid.html], default: "./deps/egm2008-5.zip"');
|
|
48
|
+
console.log('--token [Token for Cesium ION tilesets authentication]');
|
|
49
|
+
console.log('--no-draco [Disable draco compression for geometry]');
|
|
50
|
+
console.log('--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]');
|
|
51
|
+
console.log('--generate-bounding-volumes [Will generate obb and mbs bounding volumes from geometry]');
|
|
52
|
+
console.log('--validate [Enable validation]');
|
|
53
|
+
process.exit(0); // eslint-disable-line
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Run conversion process
|
|
57
|
+
* @param options validated tile-converter options
|
|
58
|
+
*/
|
|
59
|
+
async function convert(options) {
|
|
60
|
+
console.log(`------------------------------------------------`); // eslint-disable-line
|
|
61
|
+
console.log(`Starting conversion of ${options.inputType}`); // eslint-disable-line
|
|
62
|
+
console.log(`------------------------------------------------`); // eslint-disable-line
|
|
63
|
+
const inputType = options.inputType.toUpperCase();
|
|
64
|
+
switch (inputType) {
|
|
65
|
+
case TILESET_TYPE.I3S:
|
|
66
|
+
const tiles3DConverter = new tile_converter_1.Tiles3DConverter();
|
|
67
|
+
tiles3DConverter.convert({
|
|
68
|
+
inputUrl: options.tileset,
|
|
69
|
+
outputPath: options.output,
|
|
70
|
+
tilesetName: options.name,
|
|
71
|
+
maxDepth: options.maxDepth,
|
|
72
|
+
egmFilePath: options.egm
|
|
73
|
+
});
|
|
74
|
+
break;
|
|
75
|
+
case TILESET_TYPE._3DTILES:
|
|
76
|
+
const converter = new tile_converter_1.I3SConverter();
|
|
77
|
+
await converter.convert({
|
|
78
|
+
inputUrl: options.tileset,
|
|
79
|
+
outputPath: options.output,
|
|
80
|
+
tilesetName: options.name,
|
|
81
|
+
maxDepth: options.maxDepth,
|
|
82
|
+
slpk: options.slpk,
|
|
83
|
+
sevenZipExe: options.sevenZipExe,
|
|
84
|
+
egmFilePath: options.egm,
|
|
85
|
+
token: options.token,
|
|
86
|
+
draco: options.draco,
|
|
87
|
+
generateTextures: options.generateTextures,
|
|
88
|
+
generateBoundingVolumes: options.generateBoundingVolumes,
|
|
89
|
+
validate: options.validate
|
|
90
|
+
});
|
|
91
|
+
break;
|
|
92
|
+
default:
|
|
93
|
+
printHelp();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// OPTIONS
|
|
97
|
+
/**
|
|
98
|
+
* Validate input options of the CLI command
|
|
99
|
+
* @param options - input options of the CLI command
|
|
100
|
+
* @returns validated options
|
|
101
|
+
*/
|
|
102
|
+
function validateOptions(options) {
|
|
103
|
+
const mandatoryOptionsWithExceptions = {
|
|
104
|
+
name: () => console.log('Missed: --name [Tileset name]'),
|
|
105
|
+
output: () => console.log('Missed: --output [Output path name]'),
|
|
106
|
+
sevenZipExe: () => console.log('Missed: --7zExe [7z archiver executable path]'),
|
|
107
|
+
egm: () => console.log('Missed: --egm [*.pgm earth gravity model file path]'),
|
|
108
|
+
tileset: () => console.log('Missed: --tileset [tileset.json file]'),
|
|
109
|
+
inputType: () => console.log('Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]')
|
|
110
|
+
};
|
|
111
|
+
const exceptions = [];
|
|
112
|
+
for (const mandatoryOption in mandatoryOptionsWithExceptions) {
|
|
113
|
+
const optionValue = options[mandatoryOption];
|
|
114
|
+
const isWrongInputType = Boolean(optionValue) &&
|
|
115
|
+
mandatoryOption === 'inputType' &&
|
|
116
|
+
!Object.values(TILESET_TYPE).includes(optionValue.toUpperCase());
|
|
117
|
+
if (!optionValue || isWrongInputType) {
|
|
118
|
+
exceptions.push(mandatoryOptionsWithExceptions[mandatoryOption]);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (exceptions.length) {
|
|
122
|
+
exceptions.forEach((exeption) => exeption());
|
|
123
|
+
process.exit(0); // eslint-disable-line
|
|
124
|
+
}
|
|
125
|
+
return options;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Parse option from the cli arguments array
|
|
129
|
+
* @param args
|
|
130
|
+
* @returns
|
|
131
|
+
*/
|
|
132
|
+
function parseOptions(args) {
|
|
133
|
+
const opts = {
|
|
134
|
+
output: 'data',
|
|
135
|
+
sevenZipExe: 'C:\\Program Files\\7-Zip\\7z.exe',
|
|
136
|
+
egm: (0, path_1.join)(process.cwd(), 'deps', 'egm2008-5.pgm'),
|
|
137
|
+
draco: true,
|
|
138
|
+
installDependencies: false,
|
|
139
|
+
generateTextures: false,
|
|
140
|
+
generateBoundingVolumes: false,
|
|
141
|
+
validate: false,
|
|
142
|
+
slpk: false
|
|
143
|
+
};
|
|
144
|
+
// eslint-disable-next-line complexity
|
|
145
|
+
args.forEach((arg, index) => {
|
|
146
|
+
if (arg.indexOf('--') === 0) {
|
|
147
|
+
switch (arg) {
|
|
148
|
+
case '--input-type':
|
|
149
|
+
opts.inputType = getStringValue(index, args);
|
|
150
|
+
break;
|
|
151
|
+
case '--tileset':
|
|
152
|
+
opts.tileset = getStringValue(index, args);
|
|
153
|
+
break;
|
|
154
|
+
case '--name':
|
|
155
|
+
opts.name = getStringValue(index, args);
|
|
156
|
+
break;
|
|
157
|
+
case '--output':
|
|
158
|
+
opts.output = getStringValue(index, args);
|
|
159
|
+
break;
|
|
160
|
+
case '--max-depth':
|
|
161
|
+
opts.maxDepth = getIntegerValue(index, args);
|
|
162
|
+
break;
|
|
163
|
+
case '--slpk':
|
|
164
|
+
opts.slpk = true;
|
|
165
|
+
break;
|
|
166
|
+
case '--7zExe':
|
|
167
|
+
opts.sevenZipExe = getStringValue(index, args);
|
|
168
|
+
break;
|
|
169
|
+
case '--egm':
|
|
170
|
+
opts.egm = getStringValue(index, args);
|
|
171
|
+
break;
|
|
172
|
+
case '--token':
|
|
173
|
+
opts.token = getStringValue(index, args);
|
|
174
|
+
break;
|
|
175
|
+
case '--no-draco':
|
|
176
|
+
opts.draco = false;
|
|
177
|
+
break;
|
|
178
|
+
case '--validate':
|
|
179
|
+
opts.validate = true;
|
|
180
|
+
break;
|
|
181
|
+
case '--install-dependencies':
|
|
182
|
+
opts.installDependencies = true;
|
|
183
|
+
break;
|
|
184
|
+
case '--generate-textures':
|
|
185
|
+
opts.generateTextures = true;
|
|
186
|
+
break;
|
|
187
|
+
case '--generate-bounding-volumes':
|
|
188
|
+
opts.generateBoundingVolumes = true;
|
|
189
|
+
break;
|
|
190
|
+
case '--help':
|
|
191
|
+
printHelp();
|
|
192
|
+
break;
|
|
193
|
+
default:
|
|
194
|
+
console.warn(`Unknown option ${arg}`);
|
|
195
|
+
process.exit(0); // eslint-disable-line
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
return opts;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Get string option value from cli arguments
|
|
203
|
+
* @param index - option's name index in the argument's array.
|
|
204
|
+
* The value of the option should be next to name of the option.
|
|
205
|
+
* @param args - cli arguments array
|
|
206
|
+
* @returns - string value of the option
|
|
207
|
+
*/
|
|
208
|
+
function getStringValue(index, args) {
|
|
209
|
+
if (index + 1 >= args.length) {
|
|
210
|
+
return '';
|
|
211
|
+
}
|
|
212
|
+
const value = args[index + 1];
|
|
213
|
+
if (value.indexOf('--') === 0) {
|
|
214
|
+
return '';
|
|
215
|
+
}
|
|
216
|
+
return value;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Get integer option value from cli arguments
|
|
220
|
+
* @param index - option's name index in the argument's array
|
|
221
|
+
* The value of the option should be next to name of the option.
|
|
222
|
+
* @param args - cli arguments array
|
|
223
|
+
* @returns - number value of the option
|
|
224
|
+
*/
|
|
225
|
+
function getIntegerValue(index, args) {
|
|
226
|
+
const stringValue = getStringValue(index, args);
|
|
227
|
+
const result = Number.parseInt(stringValue);
|
|
228
|
+
if (isFinite(result)) {
|
|
229
|
+
return result;
|
|
230
|
+
}
|
|
231
|
+
return NaN;
|
|
232
|
+
}
|