@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,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const queue_1 = require("./queue");
|
|
4
|
+
class WriteQueue extends queue_1.Queue {
|
|
5
|
+
constructor(listeningInterval = 2000, writeConcurrency = 400) {
|
|
6
|
+
super();
|
|
7
|
+
this.writePromise = null;
|
|
8
|
+
this.fileMap = {};
|
|
9
|
+
this.listeningInterval = listeningInterval;
|
|
10
|
+
this.writeConcurrency = writeConcurrency;
|
|
11
|
+
}
|
|
12
|
+
startListening() {
|
|
13
|
+
this.intervalId = setInterval(this.startWrite.bind(this), this.listeningInterval);
|
|
14
|
+
}
|
|
15
|
+
stopListening() {
|
|
16
|
+
if (this.intervalId) {
|
|
17
|
+
clearInterval(this.intervalId);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async startWrite() {
|
|
21
|
+
if (this.writePromise) {
|
|
22
|
+
await this.writePromise;
|
|
23
|
+
this.writePromise = null;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.writePromise = this.doWrite();
|
|
27
|
+
await this.writePromise;
|
|
28
|
+
this.writePromise = null;
|
|
29
|
+
}
|
|
30
|
+
async finalize() {
|
|
31
|
+
this.stopListening();
|
|
32
|
+
await this.startWrite();
|
|
33
|
+
}
|
|
34
|
+
async doWrite() {
|
|
35
|
+
while (this.length) {
|
|
36
|
+
const promises = [];
|
|
37
|
+
const archiveKeys = [];
|
|
38
|
+
for (let i = 0; i < this.writeConcurrency; i++) {
|
|
39
|
+
const item = this.dequeue();
|
|
40
|
+
if (!item) {
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
const { archiveKey, writePromise } = item;
|
|
44
|
+
archiveKeys.push(archiveKey);
|
|
45
|
+
promises.push(writePromise);
|
|
46
|
+
}
|
|
47
|
+
const writeResults = await Promise.all(promises);
|
|
48
|
+
this.updateFileMap(archiveKeys, writeResults);
|
|
49
|
+
}
|
|
50
|
+
this.writePromise = null;
|
|
51
|
+
}
|
|
52
|
+
updateFileMap(archiveKeys, writeResults) {
|
|
53
|
+
for (let i = 0; i < archiveKeys.length; i++) {
|
|
54
|
+
const archiveKey = archiveKeys[i];
|
|
55
|
+
if (!archiveKey) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
this.fileMap[archiveKey] = writeResults[i];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.default = WriteQueue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3d-tiles-attributes-worker.d.ts","sourceRoot":"","sources":["../../src/workers/3d-tiles-attributes-worker.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const worker_utils_1 = require("@loaders.gl/worker-utils");
|
|
7
|
+
const b3dm_converter_1 = __importDefault(require("../3d-tiles-converter/helpers/b3dm-converter"));
|
|
8
|
+
const b3dmConverter = new b3dm_converter_1.default();
|
|
9
|
+
(0, worker_utils_1.createWorker)(async (data, options = {}) => b3dmConverter.convert(data, options.attributes));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i3s-attributes-worker.d.ts","sourceRoot":"","sources":["../../src/workers/i3s-attributes-worker.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const worker_utils_1 = require("@loaders.gl/worker-utils");
|
|
4
|
+
const geometry_converter_1 = require("../i3s-converter/helpers/geometry-converter");
|
|
5
|
+
(0, worker_utils_1.createWorker)(async (data, options = {}) => await (0, geometry_converter_1.convertAttributes)(data, options.useCartesianPositions));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/tile-converter",
|
|
3
|
-
"version": "3.2.0-alpha.
|
|
3
|
+
"version": "3.2.0-alpha.4",
|
|
4
4
|
"description": "Converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -30,27 +30,32 @@
|
|
|
30
30
|
"README.md"
|
|
31
31
|
],
|
|
32
32
|
"browser": {
|
|
33
|
-
"fs": false
|
|
33
|
+
"fs": false,
|
|
34
|
+
"path": false,
|
|
35
|
+
"process": false,
|
|
36
|
+
"archiver": false
|
|
34
37
|
},
|
|
35
38
|
"scripts": {
|
|
36
|
-
"pre-build": "npm run build-bundle
|
|
39
|
+
"pre-build": "npm run build-bundle && npm run build-converter-bundle && npm run build-i3s-attributes-worker && npm run build-3d-tiles-attributes-worker",
|
|
37
40
|
"build-bundle": "esbuild ./src/index.ts --bundle --outfile=dist/dist.min.js --platform=node",
|
|
38
41
|
"build-converter-bundle": "webpack --display errors-only --config ./converter-webpack/bundle.js",
|
|
39
|
-
"build-
|
|
42
|
+
"build-i3s-attributes-worker": "esbuild src/workers/i3s-attributes-worker.ts --outfile=dist/i3s-attributes-worker.js --platform=node --target=esnext,node12 --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\"",
|
|
43
|
+
"build-3d-tiles-attributes-worker": "esbuild src/workers/3d-tiles-attributes-worker.ts --outfile=dist/3d-tiles-attributes-worker.js --platform=node --target=esnext,node12 --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
40
44
|
},
|
|
41
45
|
"dependencies": {
|
|
42
|
-
"@loaders.gl/3d-tiles": "3.2.0-alpha.
|
|
43
|
-
"@loaders.gl/crypto": "3.2.0-alpha.
|
|
44
|
-
"@loaders.gl/draco": "3.2.0-alpha.
|
|
45
|
-
"@loaders.gl/gltf": "3.2.0-alpha.
|
|
46
|
-
"@loaders.gl/i3s": "3.2.0-alpha.
|
|
47
|
-
"@loaders.gl/images": "3.2.0-alpha.
|
|
48
|
-
"@loaders.gl/loader-utils": "3.2.0-alpha.
|
|
49
|
-
"@loaders.gl/polyfills": "3.2.0-alpha.
|
|
50
|
-
"@loaders.gl/
|
|
51
|
-
"@loaders.gl/
|
|
52
|
-
"@loaders.gl/
|
|
53
|
-
"@loaders.gl/
|
|
46
|
+
"@loaders.gl/3d-tiles": "3.2.0-alpha.4",
|
|
47
|
+
"@loaders.gl/crypto": "3.2.0-alpha.4",
|
|
48
|
+
"@loaders.gl/draco": "3.2.0-alpha.4",
|
|
49
|
+
"@loaders.gl/gltf": "3.2.0-alpha.4",
|
|
50
|
+
"@loaders.gl/i3s": "3.2.0-alpha.4",
|
|
51
|
+
"@loaders.gl/images": "3.2.0-alpha.4",
|
|
52
|
+
"@loaders.gl/loader-utils": "3.2.0-alpha.4",
|
|
53
|
+
"@loaders.gl/polyfills": "3.2.0-alpha.4",
|
|
54
|
+
"@loaders.gl/schema": "3.2.0-alpha.4",
|
|
55
|
+
"@loaders.gl/textures": "3.2.0-alpha.4",
|
|
56
|
+
"@loaders.gl/tiles": "3.2.0-alpha.4",
|
|
57
|
+
"@loaders.gl/worker-utils": "3.2.0-alpha.4",
|
|
58
|
+
"@loaders.gl/zip": "3.2.0-alpha.4",
|
|
54
59
|
"@luma.gl/engine": "^8.5.4",
|
|
55
60
|
"@math.gl/core": "^3.5.1",
|
|
56
61
|
"@math.gl/culling": "^3.5.1",
|
|
@@ -68,7 +73,7 @@
|
|
|
68
73
|
"uuid": "^8.1.0"
|
|
69
74
|
},
|
|
70
75
|
"peerDependencies": {
|
|
71
|
-
"@loaders.gl/core": "
|
|
76
|
+
"@loaders.gl/core": "3.2.0-alpha.3"
|
|
72
77
|
},
|
|
73
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "f030d39d5cdedb137e43e757a9da10dd637857fd"
|
|
74
79
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type {WorkerObject} from '@loaders.gl/worker-utils';
|
|
2
|
+
import type {FeatureAttribute} from '@loaders.gl/i3s';
|
|
3
|
+
|
|
4
|
+
import {processOnWorker} from '@loaders.gl/worker-utils';
|
|
5
|
+
|
|
6
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
7
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
8
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
9
|
+
|
|
10
|
+
export type Tile3DAttributesWorkerOptions = {
|
|
11
|
+
featureAttributes: FeatureAttribute | null;
|
|
12
|
+
source: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type I3SAttributesData = {
|
|
16
|
+
tileContent: any;
|
|
17
|
+
textureFormat: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* I3S Attributes Worker to handle B3DM object
|
|
22
|
+
*/
|
|
23
|
+
export const Tile3dAttributesWorker = {
|
|
24
|
+
id: '3d-tiles-attributes',
|
|
25
|
+
name: '3DTiles Attributes Worker',
|
|
26
|
+
module: 'tile-converter',
|
|
27
|
+
version: VERSION,
|
|
28
|
+
options: {
|
|
29
|
+
attributes: null
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Performs I3S attributes transformation
|
|
35
|
+
*/
|
|
36
|
+
export function transform3DTilesAttributesOnWorker(
|
|
37
|
+
i3sAttributesData: I3SAttributesData,
|
|
38
|
+
options: Tile3DAttributesWorkerOptions
|
|
39
|
+
): Promise<ArrayBuffer> {
|
|
40
|
+
return processOnWorker(Tile3dAttributesWorker, i3sAttributesData, options);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const _typecheckI3SAttributesWorker: WorkerObject = Tile3dAttributesWorker;
|
|
@@ -4,7 +4,7 @@ import type {Node3D} from '@loaders.gl/3d-tiles';
|
|
|
4
4
|
import {join} from 'path';
|
|
5
5
|
import process from 'process';
|
|
6
6
|
import transform from 'json-map-transform';
|
|
7
|
-
import {load} from '@loaders.gl/core';
|
|
7
|
+
import {fetchFile, getLoaderOptions, load, isBrowser} from '@loaders.gl/core';
|
|
8
8
|
import {I3SLoader, I3SAttributeLoader, COORDINATE_SYSTEM} from '@loaders.gl/i3s';
|
|
9
9
|
import {Tileset3D, Tile3D} from '@loaders.gl/tiles';
|
|
10
10
|
import {Geoid} from '@math.gl/geoid';
|
|
@@ -17,6 +17,13 @@ import {calculateFilesSize, timeConverter} from '../lib/utils/statistic-utills';
|
|
|
17
17
|
import {TILESET as tilesetTemplate} from './json-templates/tileset';
|
|
18
18
|
import B3dmConverter from './helpers/b3dm-converter';
|
|
19
19
|
import {createObbFromMbs} from '../i3s-converter/helpers/coordinate-converter';
|
|
20
|
+
import {
|
|
21
|
+
I3SAttributesData,
|
|
22
|
+
Tile3dAttributesWorker
|
|
23
|
+
/*transform3DTilesAttributesOnWorker*/
|
|
24
|
+
} from '../3d-tiles-attributes-worker';
|
|
25
|
+
import {getWorkerURL, WorkerFarm} from '@loaders.gl/worker-utils';
|
|
26
|
+
import {BROWSER_ERROR_MESSAGE} from '../constants';
|
|
20
27
|
|
|
21
28
|
const I3S = 'I3S';
|
|
22
29
|
|
|
@@ -31,6 +38,7 @@ export default class Tiles3DConverter {
|
|
|
31
38
|
geoidHeightModel: Geoid | null;
|
|
32
39
|
sourceTileset: Tileset3D | null;
|
|
33
40
|
attributeStorageInfo: AttributeStorageInfo | null;
|
|
41
|
+
workerSource: {[key: string]: string} = {};
|
|
34
42
|
|
|
35
43
|
constructor() {
|
|
36
44
|
this.options = {};
|
|
@@ -40,6 +48,7 @@ export default class Tiles3DConverter {
|
|
|
40
48
|
this.geoidHeightModel = null;
|
|
41
49
|
this.sourceTileset = null;
|
|
42
50
|
this.attributeStorageInfo = null;
|
|
51
|
+
this.workerSource = {};
|
|
43
52
|
}
|
|
44
53
|
|
|
45
54
|
/**
|
|
@@ -55,9 +64,13 @@ export default class Tiles3DConverter {
|
|
|
55
64
|
inputUrl: string;
|
|
56
65
|
outputPath: string;
|
|
57
66
|
tilesetName: string;
|
|
58
|
-
maxDepth
|
|
67
|
+
maxDepth?: number;
|
|
59
68
|
egmFilePath: string;
|
|
60
69
|
}): Promise<any> {
|
|
70
|
+
if (isBrowser) {
|
|
71
|
+
console.log(BROWSER_ERROR_MESSAGE);
|
|
72
|
+
return BROWSER_ERROR_MESSAGE;
|
|
73
|
+
}
|
|
61
74
|
const {inputUrl, outputPath, tilesetName, maxDepth, egmFilePath} = options;
|
|
62
75
|
this.conversionStartTime = process.hrtime();
|
|
63
76
|
this.options = {maxDepth};
|
|
@@ -66,6 +79,8 @@ export default class Tiles3DConverter {
|
|
|
66
79
|
this.geoidHeightModel = await load(egmFilePath, PGMLoader);
|
|
67
80
|
console.log('Loading egm file completed!'); // eslint-disable-line
|
|
68
81
|
|
|
82
|
+
await this.loadWorkers();
|
|
83
|
+
|
|
69
84
|
const sourceTilesetJson = await load(inputUrl, I3SLoader, {});
|
|
70
85
|
|
|
71
86
|
this.sourceTileset = new Tileset3D(sourceTilesetJson, {
|
|
@@ -74,6 +89,7 @@ export default class Tiles3DConverter {
|
|
|
74
89
|
}
|
|
75
90
|
});
|
|
76
91
|
|
|
92
|
+
await this.sourceTileset.tilesetInitializationPromise;
|
|
77
93
|
const rootNode = this.sourceTileset.root!;
|
|
78
94
|
if (!rootNode.header.obb) {
|
|
79
95
|
rootNode.header.obb = createObbFromMbs(rootNode.header.mbs);
|
|
@@ -102,6 +118,10 @@ export default class Tiles3DConverter {
|
|
|
102
118
|
await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');
|
|
103
119
|
|
|
104
120
|
this._finishConversion({slpk: false, outputPath, tilesetName});
|
|
121
|
+
|
|
122
|
+
// Clean up worker pools
|
|
123
|
+
const workerFarm = WorkerFarm.getWorkerFarm({});
|
|
124
|
+
workerFarm.destroy();
|
|
105
125
|
}
|
|
106
126
|
|
|
107
127
|
/**
|
|
@@ -125,9 +145,12 @@ export default class Tiles3DConverter {
|
|
|
125
145
|
await this.sourceTileset!._loadTile(sourceChild);
|
|
126
146
|
this.vertexCounter += sourceChild.content.vertexCount;
|
|
127
147
|
|
|
128
|
-
let
|
|
148
|
+
let featureAttributes: FeatureAttribute | null = null;
|
|
129
149
|
if (this.attributeStorageInfo) {
|
|
130
|
-
|
|
150
|
+
featureAttributes = await this._loadChildAttributes(
|
|
151
|
+
sourceChild,
|
|
152
|
+
this.attributeStorageInfo
|
|
153
|
+
);
|
|
131
154
|
}
|
|
132
155
|
|
|
133
156
|
if (!sourceChild.header.obb) {
|
|
@@ -143,7 +166,19 @@ export default class Tiles3DConverter {
|
|
|
143
166
|
children: []
|
|
144
167
|
};
|
|
145
168
|
|
|
146
|
-
const
|
|
169
|
+
const i3sAttributesData: I3SAttributesData = {
|
|
170
|
+
tileContent: sourceChild.content,
|
|
171
|
+
textureFormat: sourceChild?.header?.textureFormat
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// TODO Uncomment when 3d-tiles-attributes-worker will be published on CDN.
|
|
175
|
+
// const b3dm = await transform3DTilesAttributesOnWorker(i3sAttributesData, {
|
|
176
|
+
// source: this.workerSource.tile3dWorkerSource,
|
|
177
|
+
// featureAttributes
|
|
178
|
+
// });
|
|
179
|
+
|
|
180
|
+
const b3dm = await new B3dmConverter().convert(i3sAttributesData, featureAttributes);
|
|
181
|
+
|
|
147
182
|
child.content = {
|
|
148
183
|
uri: `${sourceChild.id}.b3dm`,
|
|
149
184
|
boundingVolume
|
|
@@ -290,4 +325,14 @@ export default class Tiles3DConverter {
|
|
|
290
325
|
console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line
|
|
291
326
|
console.log(`------------------------------------------------`); // eslint-disable-line
|
|
292
327
|
}
|
|
328
|
+
|
|
329
|
+
private async loadWorkers(): Promise<void> {
|
|
330
|
+
console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console
|
|
331
|
+
const tile3dAttributesWorkerUrl = getWorkerURL(Tile3dAttributesWorker, {...getLoaderOptions()});
|
|
332
|
+
const sourceResponse = await fetchFile(tile3dAttributesWorkerUrl);
|
|
333
|
+
const source = await sourceResponse.text();
|
|
334
|
+
|
|
335
|
+
this.workerSource.tile3dWorkerSource = source;
|
|
336
|
+
console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console
|
|
337
|
+
}
|
|
293
338
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type {I3SAttributesData} from '../../3d-tiles-attributes-worker';
|
|
2
|
+
|
|
1
3
|
import {encodeSync} from '@loaders.gl/core';
|
|
2
4
|
import {GLTFScenegraph, GLTFWriter} from '@loaders.gl/gltf';
|
|
3
5
|
import {Tile3DWriter} from '@loaders.gl/3d-tiles';
|
|
@@ -21,15 +23,17 @@ export default class B3dmConverter {
|
|
|
21
23
|
* @param i3sTile - Tile3D instance for I3S node
|
|
22
24
|
* @returns - encoded content
|
|
23
25
|
*/
|
|
24
|
-
async convert(
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
async convert(
|
|
27
|
+
i3sAttributesData: I3SAttributesData,
|
|
28
|
+
featureAttributes: any = null
|
|
29
|
+
): Promise<ArrayBuffer> {
|
|
30
|
+
const gltf = await this.buildGltf(i3sAttributesData);
|
|
27
31
|
const b3dm = encodeSync(
|
|
28
32
|
{
|
|
29
33
|
gltfEncoded: new Uint8Array(gltf),
|
|
30
34
|
type: 'b3dm',
|
|
31
|
-
featuresLength: this._getFeaturesLength(
|
|
32
|
-
batchTable:
|
|
35
|
+
featuresLength: this._getFeaturesLength(featureAttributes),
|
|
36
|
+
batchTable: featureAttributes
|
|
33
37
|
},
|
|
34
38
|
Tile3DWriter
|
|
35
39
|
);
|
|
@@ -41,7 +45,8 @@ export default class B3dmConverter {
|
|
|
41
45
|
* @param i3sTile - Tile3D instance for I3S node
|
|
42
46
|
* @returns - encoded glb content
|
|
43
47
|
*/
|
|
44
|
-
async buildGltf(
|
|
48
|
+
async buildGltf(i3sAttributesData: I3SAttributesData): Promise<ArrayBuffer> {
|
|
49
|
+
const {tileContent, textureFormat} = i3sAttributesData;
|
|
45
50
|
const {
|
|
46
51
|
material,
|
|
47
52
|
attributes,
|
|
@@ -49,10 +54,10 @@ export default class B3dmConverter {
|
|
|
49
54
|
cartesianOrigin,
|
|
50
55
|
cartographicOrigin,
|
|
51
56
|
modelMatrix
|
|
52
|
-
} =
|
|
57
|
+
} = tileContent;
|
|
53
58
|
const gltfBuilder = new GLTFScenegraph();
|
|
54
59
|
|
|
55
|
-
const textureIndex = await this._addI3sTextureToGltf(
|
|
60
|
+
const textureIndex = await this._addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder);
|
|
56
61
|
const pbrMaterialInfo = this._convertI3sMaterialToGltfMaterial(material, textureIndex);
|
|
57
62
|
const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
|
|
58
63
|
|
|
@@ -101,11 +106,8 @@ export default class B3dmConverter {
|
|
|
101
106
|
* @param {GLTFScenegraph} gltfBuilder - gltfScenegraph instance to construct GLTF
|
|
102
107
|
* @returns {Promise<number | null>} - GLTF texture index
|
|
103
108
|
*/
|
|
104
|
-
async _addI3sTextureToGltf(
|
|
105
|
-
const {
|
|
106
|
-
content: {texture, material, attributes},
|
|
107
|
-
header: {textureFormat}
|
|
108
|
-
} = i3sTile;
|
|
109
|
+
async _addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder) {
|
|
110
|
+
const {texture, material, attributes} = tileContent;
|
|
109
111
|
let textureIndex = null;
|
|
110
112
|
let selectedTexture = texture;
|
|
111
113
|
if (!texture && material) {
|
package/src/constants.ts
ADDED