@loaders.gl/tile-converter 3.1.8 → 3.2.0-alpha.3
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 +82 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -0
- package/dist/3d-tiles-converter/3d-tiles-converter.js +268 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +84 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +278 -0
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts +13 -0
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +23 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts +9 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.d.ts.map +1 -0
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +52 -0
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts +15 -0
- package/dist/3d-tiles-converter/json-templates/tileset.d.ts.map +1 -0
- package/dist/3d-tiles-converter/json-templates/tileset.js +43 -0
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +5 -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 +14 -0
- package/dist/deps-installer/deps-installer.d.ts.map +1 -0
- package/dist/deps-installer/deps-installer.js +31 -0
- package/dist/dist.min.js +1151 -1264
- 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 +104 -44
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +34 -43
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- 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 +311 -245
- package/dist/es5/i3s-converter/i3s-converter.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/pgm-loader.js.map +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 +32 -5
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +23 -23
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- 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 +155 -50
- package/dist/esm/i3s-converter/i3s-converter.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/pgm-loader.js.map +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 +41 -0
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/coordinate-converter.js +122 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts +9 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/create-scene-server-path.js +28 -0
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts +8 -0
- package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/geometry-attributes.js +177 -0
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +29 -0
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/geometry-converter.js +901 -0
- 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-debug.d.ts +8 -0
- package/dist/i3s-converter/helpers/node-debug.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-debug.js +114 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts +117 -0
- package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/node-pages.js +208 -0
- package/dist/i3s-converter/i3s-converter.d.ts +323 -0
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -0
- package/dist/i3s-converter/i3s-converter.js +1074 -0
- package/dist/i3s-converter/json-templates/layers.d.ts +95 -0
- package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/layers.js +199 -0
- package/dist/i3s-converter/json-templates/metadata.d.ts +22 -0
- package/dist/i3s-converter/json-templates/metadata.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/metadata.js +25 -0
- package/dist/i3s-converter/json-templates/node.d.ts +61 -0
- package/dist/i3s-converter/json-templates/node.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/node.js +89 -0
- package/dist/i3s-converter/json-templates/scene-server.d.ts +28 -0
- package/dist/i3s-converter/json-templates/scene-server.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/scene-server.js +31 -0
- package/dist/i3s-converter/json-templates/shared-resources.d.ts +14 -0
- package/dist/i3s-converter/json-templates/shared-resources.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/shared-resources.js +129 -0
- package/dist/i3s-converter/json-templates/store.d.ts +95 -0
- package/dist/i3s-converter/json-templates/store.d.ts.map +1 -0
- package/dist/i3s-converter/json-templates/store.js +103 -0
- package/dist/i3s-converter/types.d.ts +114 -0
- package/dist/i3s-converter/types.d.ts.map +1 -0
- package/dist/i3s-converter/types.js +2 -0
- package/dist/i3s-server/app.d.ts +3 -0
- package/dist/i3s-server/app.d.ts.map +1 -0
- package/dist/i3s-server/app.js +14 -0
- package/dist/i3s-server/controllers/index-controller.d.ts +2 -0
- package/dist/i3s-server/controllers/index-controller.d.ts.map +1 -0
- package/dist/i3s-server/controllers/index-controller.js +23 -0
- package/dist/i3s-server/routes/index.d.ts +3 -0
- package/dist/i3s-server/routes/index.d.ts.map +1 -0
- package/dist/i3s-server/routes/index.js +16 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/lib/utils/compress-util.d.ts +45 -0
- package/dist/lib/utils/compress-util.d.ts.map +1 -0
- package/dist/lib/utils/compress-util.js +257 -0
- package/dist/{esm/lib → lib}/utils/file-utils.d.ts +6 -14
- package/dist/lib/utils/file-utils.d.ts.map +1 -0
- package/dist/lib/utils/file-utils.js +81 -0
- package/dist/lib/utils/lod-conversion-utils.d.ts +41 -0
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -0
- package/dist/lib/utils/lod-conversion-utils.js +76 -0
- 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 +3 -0
- package/dist/lib/utils/statistic-utills.d.ts.map +1 -0
- package/dist/lib/utils/statistic-utills.js +64 -0
- 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/pgm-loader.d.ts +6 -0
- package/dist/pgm-loader.d.ts.map +1 -0
- package/dist/pgm-loader.js +23 -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 +19 -18
- package/src/3d-tiles-attributes-worker.ts +43 -0
- package/src/3d-tiles-converter/3d-tiles-converter.ts +49 -6
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +21 -18
- 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 +154 -87
- 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/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":"pgm-loader.d.ts","sourceRoot":"","sources":["../src/pgm-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAQ/D;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,gBAYvB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PGMLoader = void 0;
|
|
4
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
5
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
6
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
7
|
+
const geoid_1 = require("@math.gl/geoid");
|
|
8
|
+
/**
|
|
9
|
+
* Loader for PGM - Netpbm grayscale image format
|
|
10
|
+
*/
|
|
11
|
+
exports.PGMLoader = {
|
|
12
|
+
name: 'PGM - Netpbm grayscale image format',
|
|
13
|
+
id: 'pgm',
|
|
14
|
+
module: 'tile-converter',
|
|
15
|
+
version: VERSION,
|
|
16
|
+
mimeTypes: ['image/x-portable-graymap'],
|
|
17
|
+
parse: async (arrayBuffer, options) => (0, geoid_1.parsePGM)(new Uint8Array(arrayBuffer), options),
|
|
18
|
+
extensions: ['pgm'],
|
|
19
|
+
options: {
|
|
20
|
+
// TODO - use pgm namespace
|
|
21
|
+
cubic: false
|
|
22
|
+
}
|
|
23
|
+
};
|
|
@@ -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.
|
|
3
|
+
"version": "3.2.0-alpha.3",
|
|
4
4
|
"description": "Converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -33,25 +33,26 @@
|
|
|
33
33
|
"fs": false
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
|
-
"pre-build": "npm run build-bundle",
|
|
37
|
-
"post-build": "npm run build-converter-bundle",
|
|
36
|
+
"pre-build": "npm run build-bundle && npm run build-converter-bundle && npm run build-i3s-attributes-worker && npm run build-3d-tiles-attributes-worker",
|
|
38
37
|
"build-bundle": "esbuild ./src/index.ts --bundle --outfile=dist/dist.min.js --platform=node",
|
|
39
38
|
"build-converter-bundle": "webpack --display errors-only --config ./converter-webpack/bundle.js",
|
|
40
|
-
"build-
|
|
39
|
+
"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\\\"",
|
|
40
|
+
"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\\\""
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@loaders.gl/3d-tiles": "3.
|
|
44
|
-
"@loaders.gl/crypto": "3.
|
|
45
|
-
"@loaders.gl/draco": "3.
|
|
46
|
-
"@loaders.gl/gltf": "3.
|
|
47
|
-
"@loaders.gl/i3s": "3.
|
|
48
|
-
"@loaders.gl/images": "3.
|
|
49
|
-
"@loaders.gl/loader-utils": "3.
|
|
50
|
-
"@loaders.gl/polyfills": "3.
|
|
51
|
-
"@loaders.gl/
|
|
52
|
-
"@loaders.gl/
|
|
53
|
-
"@loaders.gl/
|
|
54
|
-
"@loaders.gl/
|
|
43
|
+
"@loaders.gl/3d-tiles": "3.2.0-alpha.3",
|
|
44
|
+
"@loaders.gl/crypto": "3.2.0-alpha.3",
|
|
45
|
+
"@loaders.gl/draco": "3.2.0-alpha.3",
|
|
46
|
+
"@loaders.gl/gltf": "3.2.0-alpha.3",
|
|
47
|
+
"@loaders.gl/i3s": "3.2.0-alpha.3",
|
|
48
|
+
"@loaders.gl/images": "3.2.0-alpha.3",
|
|
49
|
+
"@loaders.gl/loader-utils": "3.2.0-alpha.3",
|
|
50
|
+
"@loaders.gl/polyfills": "3.2.0-alpha.3",
|
|
51
|
+
"@loaders.gl/schema": "3.2.0-alpha.3",
|
|
52
|
+
"@loaders.gl/textures": "3.2.0-alpha.3",
|
|
53
|
+
"@loaders.gl/tiles": "3.2.0-alpha.3",
|
|
54
|
+
"@loaders.gl/worker-utils": "3.2.0-alpha.3",
|
|
55
|
+
"@loaders.gl/zip": "3.2.0-alpha.3",
|
|
55
56
|
"@luma.gl/engine": "^8.5.4",
|
|
56
57
|
"@math.gl/core": "^3.5.1",
|
|
57
58
|
"@math.gl/culling": "^3.5.1",
|
|
@@ -69,7 +70,7 @@
|
|
|
69
70
|
"uuid": "^8.1.0"
|
|
70
71
|
},
|
|
71
72
|
"peerDependencies": {
|
|
72
|
-
"@loaders.gl/core": "
|
|
73
|
+
"@loaders.gl/core": "3.2.0-alpha.2"
|
|
73
74
|
},
|
|
74
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "f0d4b801efeb7094283106352ee759eccfb21f10"
|
|
75
76
|
}
|
|
@@ -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} 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,12 @@ 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';
|
|
20
26
|
|
|
21
27
|
const I3S = 'I3S';
|
|
22
28
|
|
|
@@ -31,6 +37,7 @@ export default class Tiles3DConverter {
|
|
|
31
37
|
geoidHeightModel: Geoid | null;
|
|
32
38
|
sourceTileset: Tileset3D | null;
|
|
33
39
|
attributeStorageInfo: AttributeStorageInfo | null;
|
|
40
|
+
workerSource: {[key: string]: string} = {};
|
|
34
41
|
|
|
35
42
|
constructor() {
|
|
36
43
|
this.options = {};
|
|
@@ -40,6 +47,7 @@ export default class Tiles3DConverter {
|
|
|
40
47
|
this.geoidHeightModel = null;
|
|
41
48
|
this.sourceTileset = null;
|
|
42
49
|
this.attributeStorageInfo = null;
|
|
50
|
+
this.workerSource = {};
|
|
43
51
|
}
|
|
44
52
|
|
|
45
53
|
/**
|
|
@@ -55,7 +63,7 @@ export default class Tiles3DConverter {
|
|
|
55
63
|
inputUrl: string;
|
|
56
64
|
outputPath: string;
|
|
57
65
|
tilesetName: string;
|
|
58
|
-
maxDepth
|
|
66
|
+
maxDepth?: number;
|
|
59
67
|
egmFilePath: string;
|
|
60
68
|
}): Promise<any> {
|
|
61
69
|
const {inputUrl, outputPath, tilesetName, maxDepth, egmFilePath} = options;
|
|
@@ -66,11 +74,17 @@ export default class Tiles3DConverter {
|
|
|
66
74
|
this.geoidHeightModel = await load(egmFilePath, PGMLoader);
|
|
67
75
|
console.log('Loading egm file completed!'); // eslint-disable-line
|
|
68
76
|
|
|
77
|
+
await this.loadWorkers();
|
|
78
|
+
|
|
69
79
|
const sourceTilesetJson = await load(inputUrl, I3SLoader, {});
|
|
80
|
+
|
|
70
81
|
this.sourceTileset = new Tileset3D(sourceTilesetJson, {
|
|
71
|
-
loadOptions: {
|
|
82
|
+
loadOptions: {
|
|
83
|
+
i3s: {coordinateSystem: COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false}
|
|
84
|
+
}
|
|
72
85
|
});
|
|
73
86
|
|
|
87
|
+
await this.sourceTileset.tilesetInitializationPromise;
|
|
74
88
|
const rootNode = this.sourceTileset.root!;
|
|
75
89
|
if (!rootNode.header.obb) {
|
|
76
90
|
rootNode.header.obb = createObbFromMbs(rootNode.header.mbs);
|
|
@@ -99,6 +113,10 @@ export default class Tiles3DConverter {
|
|
|
99
113
|
await writeFile(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');
|
|
100
114
|
|
|
101
115
|
this._finishConversion({slpk: false, outputPath, tilesetName});
|
|
116
|
+
|
|
117
|
+
// Clean up worker pools
|
|
118
|
+
const workerFarm = WorkerFarm.getWorkerFarm({});
|
|
119
|
+
workerFarm.destroy();
|
|
102
120
|
}
|
|
103
121
|
|
|
104
122
|
/**
|
|
@@ -122,9 +140,12 @@ export default class Tiles3DConverter {
|
|
|
122
140
|
await this.sourceTileset!._loadTile(sourceChild);
|
|
123
141
|
this.vertexCounter += sourceChild.content.vertexCount;
|
|
124
142
|
|
|
125
|
-
let
|
|
143
|
+
let featureAttributes: FeatureAttribute | null = null;
|
|
126
144
|
if (this.attributeStorageInfo) {
|
|
127
|
-
|
|
145
|
+
featureAttributes = await this._loadChildAttributes(
|
|
146
|
+
sourceChild,
|
|
147
|
+
this.attributeStorageInfo
|
|
148
|
+
);
|
|
128
149
|
}
|
|
129
150
|
|
|
130
151
|
if (!sourceChild.header.obb) {
|
|
@@ -140,7 +161,19 @@ export default class Tiles3DConverter {
|
|
|
140
161
|
children: []
|
|
141
162
|
};
|
|
142
163
|
|
|
143
|
-
const
|
|
164
|
+
const i3sAttributesData: I3SAttributesData = {
|
|
165
|
+
tileContent: sourceChild.content,
|
|
166
|
+
textureFormat: sourceChild?.header?.textureFormat
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// TODO Uncomment when 3d-tiles-attributes-worker will be published on CDN.
|
|
170
|
+
// const b3dm = await transform3DTilesAttributesOnWorker(i3sAttributesData, {
|
|
171
|
+
// source: this.workerSource.tile3dWorkerSource,
|
|
172
|
+
// featureAttributes
|
|
173
|
+
// });
|
|
174
|
+
|
|
175
|
+
const b3dm = await new B3dmConverter().convert(i3sAttributesData, featureAttributes);
|
|
176
|
+
|
|
144
177
|
child.content = {
|
|
145
178
|
uri: `${sourceChild.id}.b3dm`,
|
|
146
179
|
boundingVolume
|
|
@@ -287,4 +320,14 @@ export default class Tiles3DConverter {
|
|
|
287
320
|
console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line
|
|
288
321
|
console.log(`------------------------------------------------`); // eslint-disable-line
|
|
289
322
|
}
|
|
323
|
+
|
|
324
|
+
private async loadWorkers(): Promise<void> {
|
|
325
|
+
console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console
|
|
326
|
+
const tile3dAttributesWorkerUrl = getWorkerURL(Tile3dAttributesWorker, {...getLoaderOptions()});
|
|
327
|
+
const sourceResponse = await fetchFile(tile3dAttributesWorkerUrl);
|
|
328
|
+
const source = await sourceResponse.text();
|
|
329
|
+
|
|
330
|
+
this.workerSource.tile3dWorkerSource = source;
|
|
331
|
+
console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console
|
|
332
|
+
}
|
|
290
333
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {I3SAttributesData} from '../../3d-tiles-attributes-worker';
|
|
2
|
+
|
|
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';
|
|
4
|
-
import {ImageWriter} from '@loaders.gl/images';
|
|
5
6
|
import {Matrix4, Vector3} from '@math.gl/core';
|
|
6
7
|
import {Ellipsoid} from '@math.gl/geospatial';
|
|
7
8
|
import {convertTextureAtlas} from './texture-atlas';
|
|
@@ -22,15 +23,17 @@ export default class B3dmConverter {
|
|
|
22
23
|
* @param i3sTile - Tile3D instance for I3S node
|
|
23
24
|
* @returns - encoded content
|
|
24
25
|
*/
|
|
25
|
-
async convert(
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
async convert(
|
|
27
|
+
i3sAttributesData: I3SAttributesData,
|
|
28
|
+
featureAttributes: any = null
|
|
29
|
+
): Promise<ArrayBuffer> {
|
|
30
|
+
const gltf = await this.buildGltf(i3sAttributesData);
|
|
28
31
|
const b3dm = encodeSync(
|
|
29
32
|
{
|
|
30
33
|
gltfEncoded: new Uint8Array(gltf),
|
|
31
34
|
type: 'b3dm',
|
|
32
|
-
featuresLength: this._getFeaturesLength(
|
|
33
|
-
batchTable:
|
|
35
|
+
featuresLength: this._getFeaturesLength(featureAttributes),
|
|
36
|
+
batchTable: featureAttributes
|
|
34
37
|
},
|
|
35
38
|
Tile3DWriter
|
|
36
39
|
);
|
|
@@ -42,7 +45,8 @@ export default class B3dmConverter {
|
|
|
42
45
|
* @param i3sTile - Tile3D instance for I3S node
|
|
43
46
|
* @returns - encoded glb content
|
|
44
47
|
*/
|
|
45
|
-
async buildGltf(
|
|
48
|
+
async buildGltf(i3sAttributesData: I3SAttributesData): Promise<ArrayBuffer> {
|
|
49
|
+
const {tileContent, textureFormat} = i3sAttributesData;
|
|
46
50
|
const {
|
|
47
51
|
material,
|
|
48
52
|
attributes,
|
|
@@ -50,10 +54,10 @@ export default class B3dmConverter {
|
|
|
50
54
|
cartesianOrigin,
|
|
51
55
|
cartographicOrigin,
|
|
52
56
|
modelMatrix
|
|
53
|
-
} =
|
|
57
|
+
} = tileContent;
|
|
54
58
|
const gltfBuilder = new GLTFScenegraph();
|
|
55
59
|
|
|
56
|
-
const textureIndex = await this._addI3sTextureToGltf(
|
|
60
|
+
const textureIndex = await this._addI3sTextureToGltf(tileContent, textureFormat, gltfBuilder);
|
|
57
61
|
const pbrMaterialInfo = this._convertI3sMaterialToGltfMaterial(material, textureIndex);
|
|
58
62
|
const materialIndex = gltfBuilder.addMaterial(pbrMaterialInfo);
|
|
59
63
|
|
|
@@ -81,7 +85,8 @@ export default class B3dmConverter {
|
|
|
81
85
|
const meshIndex = gltfBuilder.addMesh({
|
|
82
86
|
attributes,
|
|
83
87
|
indices,
|
|
84
|
-
material: materialIndex
|
|
88
|
+
material: materialIndex,
|
|
89
|
+
mode: 4
|
|
85
90
|
});
|
|
86
91
|
const transformMatrix = this._generateTransformMatrix(cartesianOrigin);
|
|
87
92
|
const nodeIndex = gltfBuilder.addNode({meshIndex, matrix: transformMatrix});
|
|
@@ -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) {
|
|
@@ -116,8 +118,7 @@ export default class B3dmConverter {
|
|
|
116
118
|
}
|
|
117
119
|
if (selectedTexture) {
|
|
118
120
|
const mimeType = this._deduceMimeTypeFromFormat(textureFormat);
|
|
119
|
-
const
|
|
120
|
-
const imageIndex = gltfBuilder.addImage(imageBuffer, mimeType);
|
|
121
|
+
const imageIndex = gltfBuilder.addImage(selectedTexture, mimeType);
|
|
121
122
|
textureIndex = gltfBuilder.addTexture({imageIndex});
|
|
122
123
|
delete attributes.colors;
|
|
123
124
|
}
|
|
@@ -210,6 +211,8 @@ export default class B3dmConverter {
|
|
|
210
211
|
return 'image/jpeg';
|
|
211
212
|
case 'png':
|
|
212
213
|
return 'image/png';
|
|
214
|
+
case 'ktx2':
|
|
215
|
+
return 'image/ktx2';
|
|
213
216
|
default:
|
|
214
217
|
console.warn(`Unexpected texture format in I3S: ${format}`); // eslint-disable-line no-console, no-undef
|
|
215
218
|
return 'image/jpeg';
|