@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { load, encode } from '@loaders.gl/core';
|
|
2
|
+
import { load, encode, fetchFile, getLoaderOptions } from '@loaders.gl/core';
|
|
3
3
|
import { Tileset3D } from '@loaders.gl/tiles';
|
|
4
4
|
import { CesiumIonLoader, Tiles3DLoader } from '@loaders.gl/3d-tiles';
|
|
5
5
|
import { join } from 'path';
|
|
@@ -12,7 +12,7 @@ import { writeFile, removeDir, writeFileForSlpk } from '../lib/utils/file-utils'
|
|
|
12
12
|
import { compressWithChildProcess } from '../lib/utils/compress-util';
|
|
13
13
|
import { calculateFilesSize, timeConverter } from '../lib/utils/statistic-utills';
|
|
14
14
|
import convertB3dmToI3sGeometry from './helpers/geometry-converter';
|
|
15
|
-
import { createBoundingVolumes,
|
|
15
|
+
import { createBoundingVolumes, convertBoundingVolumeToI3SFullExtent } from './helpers/coordinate-converter';
|
|
16
16
|
import { createSceneServerPath } from './helpers/create-scene-server-path';
|
|
17
17
|
import { convertGeometricErrorToScreenThreshold } from '../lib/utils/lod-conversion-utils';
|
|
18
18
|
import { PGMLoader } from '../pgm-loader';
|
|
@@ -20,8 +20,12 @@ import { LAYERS as layersTemplate } from './json-templates/layers';
|
|
|
20
20
|
import { NODE as nodeTemplate } from './json-templates/node';
|
|
21
21
|
import { SHARED_RESOURCES as sharedResourcesTemplate } from './json-templates/shared-resources';
|
|
22
22
|
import { validateNodeBoundingVolumes } from './helpers/node-debug';
|
|
23
|
-
import {
|
|
23
|
+
import { KTX2BasisWriterWorker } from '@loaders.gl/textures';
|
|
24
24
|
import { ImageWriter } from '@loaders.gl/images';
|
|
25
|
+
import { getWorkerURL, WorkerFarm } from '@loaders.gl/worker-utils';
|
|
26
|
+
import { DracoWriterWorker } from '@loaders.gl/draco';
|
|
27
|
+
import WriteQueue from '../lib/utils/write-queue';
|
|
28
|
+
import { I3SAttributesWorker } from '../i3s-attributes-worker';
|
|
25
29
|
const ION_DEFAULT_TOKEN = process.env.IonToken || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ';
|
|
26
30
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
27
31
|
const _3D_TILES = '3DTILES';
|
|
@@ -36,8 +40,6 @@ export default class I3SConverter {
|
|
|
36
40
|
constructor() {
|
|
37
41
|
_defineProperty(this, "nodePages", void 0);
|
|
38
42
|
|
|
39
|
-
_defineProperty(this, "fileMap", void 0);
|
|
40
|
-
|
|
41
43
|
_defineProperty(this, "options", void 0);
|
|
42
44
|
|
|
43
45
|
_defineProperty(this, "layers0Path", void 0);
|
|
@@ -72,8 +74,13 @@ export default class I3SConverter {
|
|
|
72
74
|
|
|
73
75
|
_defineProperty(this, "generateBoundingVolumes", void 0);
|
|
74
76
|
|
|
77
|
+
_defineProperty(this, "layersHasTexture", void 0);
|
|
78
|
+
|
|
79
|
+
_defineProperty(this, "workerSource", {});
|
|
80
|
+
|
|
81
|
+
_defineProperty(this, "writeQueue", new WriteQueue());
|
|
82
|
+
|
|
75
83
|
this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
|
|
76
|
-
this.fileMap = {};
|
|
77
84
|
this.options = {};
|
|
78
85
|
this.layers0Path = '';
|
|
79
86
|
this.materialMap = new Map();
|
|
@@ -88,6 +95,7 @@ export default class I3SConverter {
|
|
|
88
95
|
this.validate = false;
|
|
89
96
|
this.generateTextures = false;
|
|
90
97
|
this.generateBoundingVolumes = false;
|
|
98
|
+
this.layersHasTexture = false;
|
|
91
99
|
}
|
|
92
100
|
|
|
93
101
|
async convert(options) {
|
|
@@ -119,6 +127,8 @@ export default class I3SConverter {
|
|
|
119
127
|
this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;
|
|
120
128
|
this.generateTextures = Boolean(generateTextures);
|
|
121
129
|
this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
|
|
130
|
+
this.writeQueue = new WriteQueue();
|
|
131
|
+
this.writeQueue.startListening();
|
|
122
132
|
console.log('Loading egm file...');
|
|
123
133
|
this.geoidHeightModel = await load(egmFilePath, PGMLoader);
|
|
124
134
|
console.log('Loading egm file completed!');
|
|
@@ -127,31 +137,40 @@ export default class I3SConverter {
|
|
|
127
137
|
this.nodePages.useWriteFunction(writeFileForSlpk);
|
|
128
138
|
}
|
|
129
139
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
140
|
+
await this.loadWorkers();
|
|
141
|
+
|
|
142
|
+
try {
|
|
143
|
+
const preloadOptions = await this._fetchPreloadOptions();
|
|
144
|
+
const tilesetOptions = {
|
|
145
|
+
loadOptions: {
|
|
146
|
+
basis: {
|
|
147
|
+
format: 'rgba32'
|
|
148
|
+
}
|
|
135
149
|
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
if (preloadOptions.headers) {
|
|
153
|
+
tilesetOptions.loadOptions.fetch = {
|
|
154
|
+
headers: preloadOptions.headers
|
|
155
|
+
};
|
|
136
156
|
}
|
|
137
|
-
};
|
|
138
157
|
|
|
139
|
-
|
|
140
|
-
tilesetOptions.loadOptions
|
|
141
|
-
|
|
142
|
-
|
|
158
|
+
Object.assign(tilesetOptions, preloadOptions);
|
|
159
|
+
const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);
|
|
160
|
+
this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
161
|
+
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
162
|
+
await this._finishConversion({
|
|
163
|
+
slpk: Boolean(slpk),
|
|
164
|
+
outputPath,
|
|
165
|
+
tilesetName
|
|
166
|
+
});
|
|
167
|
+
return sourceTilesetJson;
|
|
168
|
+
} catch (error) {
|
|
169
|
+
throw error;
|
|
170
|
+
} finally {
|
|
171
|
+
const workerFarm = WorkerFarm.getWorkerFarm({});
|
|
172
|
+
workerFarm.destroy();
|
|
143
173
|
}
|
|
144
|
-
|
|
145
|
-
Object.assign(tilesetOptions, preloadOptions);
|
|
146
|
-
const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);
|
|
147
|
-
this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
148
|
-
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
149
|
-
await this._finishConversion({
|
|
150
|
-
slpk: Boolean(slpk),
|
|
151
|
-
outputPath,
|
|
152
|
-
tilesetName
|
|
153
|
-
});
|
|
154
|
-
return sourceTilesetJson;
|
|
155
174
|
}
|
|
156
175
|
|
|
157
176
|
async _createAndSaveTileset(outputPath, tilesetName) {
|
|
@@ -181,15 +200,24 @@ export default class I3SConverter {
|
|
|
181
200
|
|
|
182
201
|
await this._convertNodesTree(root0, sourceRootTile, parentId, boundingVolumes);
|
|
183
202
|
this.layers0.materialDefinitions = this.materialDefinitions;
|
|
203
|
+
|
|
204
|
+
if (this.layersHasTexture === false) {
|
|
205
|
+
this.layers0.store.defaultGeometrySchema.ordering = this.layers0.store.defaultGeometrySchema.ordering.filter(attribute => attribute !== 'uv0');
|
|
206
|
+
}
|
|
207
|
+
|
|
184
208
|
await this._writeLayers0();
|
|
185
209
|
createSceneServerPath(tilesetName, this.layers0, tilesetPath);
|
|
186
210
|
await this._writeNodeIndexDocument(root0, 'root', join(this.layers0Path, 'nodes', 'root'));
|
|
187
|
-
await this.nodePages.save(this.layers0Path, this.
|
|
211
|
+
await this.nodePages.save(this.layers0Path, this.writeQueue, isCreateSlpk);
|
|
212
|
+
await this.writeQueue.finalize();
|
|
188
213
|
await this._createSlpk(tilesetPath);
|
|
189
214
|
}
|
|
190
215
|
|
|
191
216
|
_formLayers0(tilesetName) {
|
|
192
|
-
|
|
217
|
+
var _this$sourceTileset, _this$sourceTileset2, _this$sourceTileset2$;
|
|
218
|
+
|
|
219
|
+
const fullExtent = convertBoundingVolumeToI3SFullExtent(((_this$sourceTileset = this.sourceTileset) === null || _this$sourceTileset === void 0 ? void 0 : _this$sourceTileset.boundingVolume) || ((_this$sourceTileset2 = this.sourceTileset) === null || _this$sourceTileset2 === void 0 ? void 0 : (_this$sourceTileset2$ = _this$sourceTileset2.root) === null || _this$sourceTileset2$ === void 0 ? void 0 : _this$sourceTileset2$.boundingVolume));
|
|
220
|
+
const extent = [fullExtent.xmin, fullExtent.ymin, fullExtent.xmax, fullExtent.ymax];
|
|
193
221
|
const layers0data = {
|
|
194
222
|
version: "{".concat(uuidv4().toUpperCase(), "}"),
|
|
195
223
|
id: 0,
|
|
@@ -239,9 +267,14 @@ export default class I3SConverter {
|
|
|
239
267
|
const childPath = join(this.layers0Path, 'nodes', child.path);
|
|
240
268
|
|
|
241
269
|
if (this.options.slpk) {
|
|
242
|
-
this.
|
|
270
|
+
this.writeQueue.enqueue({
|
|
271
|
+
archiveKey: 'nodes/1/3dNodeIndexDocument.json.gz',
|
|
272
|
+
writePromise: writeFileForSlpk(childPath, JSON.stringify(child), '3dNodeIndexDocument.json')
|
|
273
|
+
});
|
|
243
274
|
} else {
|
|
244
|
-
|
|
275
|
+
this.writeQueue.enqueue({
|
|
276
|
+
writePromise: writeFile(childPath, JSON.stringify(child))
|
|
277
|
+
});
|
|
245
278
|
}
|
|
246
279
|
} else {
|
|
247
280
|
await this._addChildrenWithNeighborsAndWriteFile({
|
|
@@ -257,17 +290,27 @@ export default class I3SConverter {
|
|
|
257
290
|
|
|
258
291
|
async _writeLayers0() {
|
|
259
292
|
if (this.options.slpk) {
|
|
260
|
-
this.
|
|
293
|
+
this.writeQueue.enqueue({
|
|
294
|
+
archiveKey: '3dSceneLayer.json.gz',
|
|
295
|
+
writePromise: writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
|
|
296
|
+
});
|
|
261
297
|
} else {
|
|
262
|
-
|
|
298
|
+
this.writeQueue.enqueue({
|
|
299
|
+
writePromise: writeFile(this.layers0Path, JSON.stringify(this.layers0))
|
|
300
|
+
});
|
|
263
301
|
}
|
|
264
302
|
}
|
|
265
303
|
|
|
266
304
|
async _writeNodeIndexDocument(root0, nodePath, rootPath) {
|
|
267
305
|
if (this.options.slpk) {
|
|
268
|
-
this.
|
|
306
|
+
this.writeQueue.enqueue({
|
|
307
|
+
archiveKey: "nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz"),
|
|
308
|
+
writePromise: writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json')
|
|
309
|
+
});
|
|
269
310
|
} else {
|
|
270
|
-
|
|
311
|
+
this.writeQueue.enqueue({
|
|
312
|
+
writePromise: writeFile(rootPath, JSON.stringify(root0))
|
|
313
|
+
});
|
|
271
314
|
}
|
|
272
315
|
}
|
|
273
316
|
|
|
@@ -397,6 +440,8 @@ export default class I3SConverter {
|
|
|
397
440
|
};
|
|
398
441
|
|
|
399
442
|
for (const resources of resourcesData || [emptyResources]) {
|
|
443
|
+
this.layersHasTexture = this.layersHasTexture || Boolean(resources.texture);
|
|
444
|
+
|
|
400
445
|
if (this.generateBoundingVolumes && resources.boundingVolumes) {
|
|
401
446
|
boundingVolumes = resources.boundingVolumes;
|
|
402
447
|
}
|
|
@@ -453,7 +498,7 @@ export default class I3SConverter {
|
|
|
453
498
|
return null;
|
|
454
499
|
}
|
|
455
500
|
|
|
456
|
-
const resourcesData = await convertB3dmToI3sGeometry(sourceTile.content, Number(this.nodePages.nodesCounter), this.featuresHashArray, (_this$layers2 = this.layers0) === null || _this$layers2 === void 0 ? void 0 : _this$layers2.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.geoidHeightModel);
|
|
501
|
+
const resourcesData = await convertB3dmToI3sGeometry(sourceTile.content, Number(this.nodePages.nodesCounter), this.featuresHashArray, (_this$layers2 = this.layers0) === null || _this$layers2 === void 0 ? void 0 : _this$layers2.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.geoidHeightModel, this.workerSource);
|
|
457
502
|
return resourcesData;
|
|
458
503
|
}
|
|
459
504
|
|
|
@@ -588,34 +633,53 @@ export default class I3SConverter {
|
|
|
588
633
|
async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
|
|
589
634
|
if (this.options.slpk) {
|
|
590
635
|
const slpkGeometryPath = join(childPath, 'geometries');
|
|
591
|
-
this.
|
|
636
|
+
this.writeQueue.enqueue({
|
|
637
|
+
archiveKey: "".concat(slpkChildPath, "/geometries/0.bin.gz"),
|
|
638
|
+
writePromise: writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')
|
|
639
|
+
});
|
|
592
640
|
} else {
|
|
593
641
|
const geometryPath = join(childPath, 'geometries/0/');
|
|
594
|
-
|
|
642
|
+
this.writeQueue.enqueue({
|
|
643
|
+
writePromise: writeFile(geometryPath, geometryBuffer, 'index.bin')
|
|
644
|
+
});
|
|
595
645
|
}
|
|
596
646
|
|
|
597
647
|
if (this.options.draco) {
|
|
598
648
|
if (this.options.slpk) {
|
|
599
649
|
const slpkCompressedGeometryPath = join(childPath, 'geometries');
|
|
600
|
-
this.
|
|
650
|
+
this.writeQueue.enqueue({
|
|
651
|
+
archiveKey: "".concat(slpkChildPath, "/geometries/1.bin.gz"),
|
|
652
|
+
writePromise: writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
|
|
653
|
+
});
|
|
601
654
|
} else {
|
|
602
655
|
const compressedGeometryPath = join(childPath, 'geometries/1/');
|
|
603
|
-
|
|
656
|
+
this.writeQueue.enqueue({
|
|
657
|
+
writePromise: writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')
|
|
658
|
+
});
|
|
604
659
|
}
|
|
605
660
|
}
|
|
606
661
|
}
|
|
607
662
|
|
|
608
663
|
async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
|
|
664
|
+
if (!sharedResources) {
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
|
|
609
668
|
sharedResources.nodePath = nodePath;
|
|
610
669
|
const sharedData = transform(sharedResources, sharedResourcesTemplate());
|
|
611
670
|
const sharedDataStr = JSON.stringify(sharedData);
|
|
612
671
|
|
|
613
672
|
if (this.options.slpk) {
|
|
614
673
|
const slpkSharedPath = join(childPath, 'shared');
|
|
615
|
-
this.
|
|
674
|
+
this.writeQueue.enqueue({
|
|
675
|
+
archiveKey: "".concat(slpkChildPath, "/shared/sharedResource.json.gz"),
|
|
676
|
+
writePromise: writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')
|
|
677
|
+
});
|
|
616
678
|
} else {
|
|
617
679
|
const sharedPath = join(childPath, 'shared/');
|
|
618
|
-
|
|
680
|
+
this.writeQueue.enqueue({
|
|
681
|
+
writePromise: writeFile(sharedPath, sharedDataStr)
|
|
682
|
+
});
|
|
619
683
|
}
|
|
620
684
|
}
|
|
621
685
|
|
|
@@ -641,7 +705,11 @@ export default class I3SConverter {
|
|
|
641
705
|
name: '1',
|
|
642
706
|
format: 'ktx2'
|
|
643
707
|
});
|
|
644
|
-
const ktx2TextureData =
|
|
708
|
+
const ktx2TextureData = encode(texture.image, KTX2BasisWriterWorker, { ...KTX2BasisWriterWorker.options,
|
|
709
|
+
source: this.workerSource.ktx2,
|
|
710
|
+
reuseWorkers: true,
|
|
711
|
+
_nodeWorkers: true
|
|
712
|
+
});
|
|
645
713
|
await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
|
|
646
714
|
}
|
|
647
715
|
|
|
@@ -661,7 +729,7 @@ export default class I3SConverter {
|
|
|
661
729
|
name: '0',
|
|
662
730
|
format: 'jpg'
|
|
663
731
|
});
|
|
664
|
-
const decodedFromKTX2TextureData =
|
|
732
|
+
const decodedFromKTX2TextureData = encode(texture.image.data[0], ImageWriter);
|
|
665
733
|
await this.writeTextureFile(decodedFromKTX2TextureData, '0', 'jpg', childPath, slpkChildPath);
|
|
666
734
|
}
|
|
667
735
|
}
|
|
@@ -679,27 +747,37 @@ export default class I3SConverter {
|
|
|
679
747
|
if (this.options.slpk) {
|
|
680
748
|
const slpkTexturePath = join(childPath, 'textures');
|
|
681
749
|
const compress = false;
|
|
682
|
-
this.
|
|
750
|
+
this.writeQueue.enqueue({
|
|
751
|
+
archiveKey: "".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format),
|
|
752
|
+
writePromise: writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress)
|
|
753
|
+
});
|
|
683
754
|
} else {
|
|
684
755
|
const texturePath = join(childPath, "textures/".concat(name, "/"));
|
|
685
|
-
|
|
756
|
+
this.writeQueue.enqueue({
|
|
757
|
+
writePromise: writeFile(texturePath, textureData, "index.".concat(format))
|
|
758
|
+
});
|
|
686
759
|
}
|
|
687
760
|
}
|
|
688
761
|
|
|
689
|
-
async _writeAttributes(attributes, childPath, slpkChildPath) {
|
|
762
|
+
async _writeAttributes(attributes = [], childPath, slpkChildPath) {
|
|
690
763
|
var _this$layers4, _this$layers4$attribu;
|
|
691
764
|
|
|
692
|
-
if (attributes.length && (_this$layers4 = this.layers0) !== null && _this$layers4 !== void 0 && (_this$layers4$attribu = _this$layers4.attributeStorageInfo) !== null && _this$layers4$attribu !== void 0 && _this$layers4$attribu.length) {
|
|
765
|
+
if (attributes !== null && attributes !== void 0 && attributes.length && (_this$layers4 = this.layers0) !== null && _this$layers4 !== void 0 && (_this$layers4$attribu = _this$layers4.attributeStorageInfo) !== null && _this$layers4$attribu !== void 0 && _this$layers4$attribu.length) {
|
|
693
766
|
for (let index = 0; index < attributes.length; index++) {
|
|
694
767
|
const folderName = this.layers0.attributeStorageInfo[index].key;
|
|
695
768
|
const fileBuffer = new Uint8Array(attributes[index]);
|
|
696
769
|
|
|
697
770
|
if (this.options.slpk) {
|
|
698
771
|
const slpkAttributesPath = join(childPath, 'attributes', folderName);
|
|
699
|
-
this.
|
|
772
|
+
this.writeQueue.enqueue({
|
|
773
|
+
archiveKey: "".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz"),
|
|
774
|
+
writePromise: writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')
|
|
775
|
+
});
|
|
700
776
|
} else {
|
|
701
777
|
const attributesPath = join(childPath, "attributes/".concat(folderName, "/0"));
|
|
702
|
-
|
|
778
|
+
this.writeQueue.enqueue({
|
|
779
|
+
writePromise: writeFile(attributesPath, fileBuffer, 'index.bin')
|
|
780
|
+
});
|
|
703
781
|
}
|
|
704
782
|
}
|
|
705
783
|
}
|
|
@@ -976,5 +1054,32 @@ export default class I3SConverter {
|
|
|
976
1054
|
return ['b3dm', 'glTF'].includes(sourceRootTile === null || sourceRootTile === void 0 ? void 0 : (_sourceRootTile$conte = sourceRootTile.content) === null || _sourceRootTile$conte === void 0 ? void 0 : _sourceRootTile$conte.type);
|
|
977
1055
|
}
|
|
978
1056
|
|
|
1057
|
+
async loadWorkers() {
|
|
1058
|
+
console.log("Loading workers source...");
|
|
1059
|
+
|
|
1060
|
+
if (this.options.draco) {
|
|
1061
|
+
const url = getWorkerURL(DracoWriterWorker, { ...getLoaderOptions()
|
|
1062
|
+
});
|
|
1063
|
+
const sourceResponse = await fetchFile(url);
|
|
1064
|
+
const source = await sourceResponse.text();
|
|
1065
|
+
this.workerSource.draco = source;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
if (this.generateTextures) {
|
|
1069
|
+
const url = getWorkerURL(KTX2BasisWriterWorker, { ...getLoaderOptions()
|
|
1070
|
+
});
|
|
1071
|
+
const sourceResponse = await fetchFile(url);
|
|
1072
|
+
const source = await sourceResponse.text();
|
|
1073
|
+
this.workerSource.ktx2 = source;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
const i3sAttributesWorkerUrl = getWorkerURL(I3SAttributesWorker, { ...getLoaderOptions()
|
|
1077
|
+
});
|
|
1078
|
+
const sourceResponse = await fetchFile(i3sAttributesWorkerUrl);
|
|
1079
|
+
const source = await sourceResponse.text();
|
|
1080
|
+
this.workerSource.I3SAttributes = source;
|
|
1081
|
+
console.log("Loading workers source completed!");
|
|
1082
|
+
}
|
|
1083
|
+
|
|
979
1084
|
}
|
|
980
1085
|
//# sourceMappingURL=i3s-converter.js.map
|