@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
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
var _process$env;
|
|
4
|
+
|
|
5
|
+
import { load, encode, fetchFile, getLoaderOptions, isBrowser } from '@loaders.gl/core';
|
|
3
6
|
import { Tileset3D } from '@loaders.gl/tiles';
|
|
4
7
|
import { CesiumIonLoader, Tiles3DLoader } from '@loaders.gl/3d-tiles';
|
|
5
8
|
import { join } from 'path';
|
|
@@ -12,7 +15,7 @@ import { writeFile, removeDir, writeFileForSlpk } from '../lib/utils/file-utils'
|
|
|
12
15
|
import { compressWithChildProcess } from '../lib/utils/compress-util';
|
|
13
16
|
import { calculateFilesSize, timeConverter } from '../lib/utils/statistic-utills';
|
|
14
17
|
import convertB3dmToI3sGeometry from './helpers/geometry-converter';
|
|
15
|
-
import { createBoundingVolumes,
|
|
18
|
+
import { createBoundingVolumes, convertBoundingVolumeToI3SFullExtent } from './helpers/coordinate-converter';
|
|
16
19
|
import { createSceneServerPath } from './helpers/create-scene-server-path';
|
|
17
20
|
import { convertGeometricErrorToScreenThreshold } from '../lib/utils/lod-conversion-utils';
|
|
18
21
|
import { PGMLoader } from '../pgm-loader';
|
|
@@ -20,9 +23,14 @@ import { LAYERS as layersTemplate } from './json-templates/layers';
|
|
|
20
23
|
import { NODE as nodeTemplate } from './json-templates/node';
|
|
21
24
|
import { SHARED_RESOURCES as sharedResourcesTemplate } from './json-templates/shared-resources';
|
|
22
25
|
import { validateNodeBoundingVolumes } from './helpers/node-debug';
|
|
23
|
-
import {
|
|
26
|
+
import { KTX2BasisWriterWorker } from '@loaders.gl/textures';
|
|
24
27
|
import { ImageWriter } from '@loaders.gl/images';
|
|
25
|
-
|
|
28
|
+
import { getWorkerURL, WorkerFarm } from '@loaders.gl/worker-utils';
|
|
29
|
+
import { DracoWriterWorker } from '@loaders.gl/draco';
|
|
30
|
+
import WriteQueue from '../lib/utils/write-queue';
|
|
31
|
+
import { I3SAttributesWorker } from '../i3s-attributes-worker';
|
|
32
|
+
import { BROWSER_ERROR_MESSAGE } from '../constants';
|
|
33
|
+
const ION_DEFAULT_TOKEN = ((_process$env = process.env) === null || _process$env === void 0 ? void 0 : _process$env.IonToken) || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ';
|
|
26
34
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
27
35
|
const _3D_TILES = '3DTILES';
|
|
28
36
|
const _3D_OBJECT_LAYER_TYPE = '3DObject';
|
|
@@ -36,8 +44,6 @@ export default class I3SConverter {
|
|
|
36
44
|
constructor() {
|
|
37
45
|
_defineProperty(this, "nodePages", void 0);
|
|
38
46
|
|
|
39
|
-
_defineProperty(this, "fileMap", void 0);
|
|
40
|
-
|
|
41
47
|
_defineProperty(this, "options", void 0);
|
|
42
48
|
|
|
43
49
|
_defineProperty(this, "layers0Path", void 0);
|
|
@@ -74,8 +80,11 @@ export default class I3SConverter {
|
|
|
74
80
|
|
|
75
81
|
_defineProperty(this, "layersHasTexture", void 0);
|
|
76
82
|
|
|
83
|
+
_defineProperty(this, "workerSource", {});
|
|
84
|
+
|
|
85
|
+
_defineProperty(this, "writeQueue", new WriteQueue());
|
|
86
|
+
|
|
77
87
|
this.nodePages = new NodePages(writeFile, HARDCODED_NODES_PER_PAGE);
|
|
78
|
-
this.fileMap = {};
|
|
79
88
|
this.options = {};
|
|
80
89
|
this.layers0Path = '';
|
|
81
90
|
this.materialMap = new Map();
|
|
@@ -94,6 +103,11 @@ export default class I3SConverter {
|
|
|
94
103
|
}
|
|
95
104
|
|
|
96
105
|
async convert(options) {
|
|
106
|
+
if (isBrowser) {
|
|
107
|
+
console.log(BROWSER_ERROR_MESSAGE);
|
|
108
|
+
return BROWSER_ERROR_MESSAGE;
|
|
109
|
+
}
|
|
110
|
+
|
|
97
111
|
this.conversionStartTime = process.hrtime();
|
|
98
112
|
const {
|
|
99
113
|
tilesetName,
|
|
@@ -122,6 +136,8 @@ export default class I3SConverter {
|
|
|
122
136
|
this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? CesiumIonLoader : Tiles3DLoader;
|
|
123
137
|
this.generateTextures = Boolean(generateTextures);
|
|
124
138
|
this.generateBoundingVolumes = Boolean(generateBoundingVolumes);
|
|
139
|
+
this.writeQueue = new WriteQueue();
|
|
140
|
+
this.writeQueue.startListening();
|
|
125
141
|
console.log('Loading egm file...');
|
|
126
142
|
this.geoidHeightModel = await load(egmFilePath, PGMLoader);
|
|
127
143
|
console.log('Loading egm file completed!');
|
|
@@ -130,31 +146,40 @@ export default class I3SConverter {
|
|
|
130
146
|
this.nodePages.useWriteFunction(writeFileForSlpk);
|
|
131
147
|
}
|
|
132
148
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
149
|
+
await this.loadWorkers();
|
|
150
|
+
|
|
151
|
+
try {
|
|
152
|
+
const preloadOptions = await this._fetchPreloadOptions();
|
|
153
|
+
const tilesetOptions = {
|
|
154
|
+
loadOptions: {
|
|
155
|
+
basis: {
|
|
156
|
+
format: 'rgba32'
|
|
157
|
+
}
|
|
138
158
|
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
if (preloadOptions.headers) {
|
|
162
|
+
tilesetOptions.loadOptions.fetch = {
|
|
163
|
+
headers: preloadOptions.headers
|
|
164
|
+
};
|
|
139
165
|
}
|
|
140
|
-
};
|
|
141
166
|
|
|
142
|
-
|
|
143
|
-
tilesetOptions.loadOptions
|
|
144
|
-
|
|
145
|
-
|
|
167
|
+
Object.assign(tilesetOptions, preloadOptions);
|
|
168
|
+
const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);
|
|
169
|
+
this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
170
|
+
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
171
|
+
await this._finishConversion({
|
|
172
|
+
slpk: Boolean(slpk),
|
|
173
|
+
outputPath,
|
|
174
|
+
tilesetName
|
|
175
|
+
});
|
|
176
|
+
return sourceTilesetJson;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
throw error;
|
|
179
|
+
} finally {
|
|
180
|
+
const workerFarm = WorkerFarm.getWorkerFarm({});
|
|
181
|
+
workerFarm.destroy();
|
|
146
182
|
}
|
|
147
|
-
|
|
148
|
-
Object.assign(tilesetOptions, preloadOptions);
|
|
149
|
-
const sourceTilesetJson = await load(inputUrl, this.Loader, tilesetOptions.loadOptions);
|
|
150
|
-
this.sourceTileset = new Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
151
|
-
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
152
|
-
await this._finishConversion({
|
|
153
|
-
slpk: Boolean(slpk),
|
|
154
|
-
outputPath,
|
|
155
|
-
tilesetName
|
|
156
|
-
});
|
|
157
|
-
return sourceTilesetJson;
|
|
158
183
|
}
|
|
159
184
|
|
|
160
185
|
async _createAndSaveTileset(outputPath, tilesetName) {
|
|
@@ -192,12 +217,16 @@ export default class I3SConverter {
|
|
|
192
217
|
await this._writeLayers0();
|
|
193
218
|
createSceneServerPath(tilesetName, this.layers0, tilesetPath);
|
|
194
219
|
await this._writeNodeIndexDocument(root0, 'root', join(this.layers0Path, 'nodes', 'root'));
|
|
195
|
-
await this.nodePages.save(this.layers0Path, this.
|
|
220
|
+
await this.nodePages.save(this.layers0Path, this.writeQueue, isCreateSlpk);
|
|
221
|
+
await this.writeQueue.finalize();
|
|
196
222
|
await this._createSlpk(tilesetPath);
|
|
197
223
|
}
|
|
198
224
|
|
|
199
225
|
_formLayers0(tilesetName) {
|
|
200
|
-
|
|
226
|
+
var _this$sourceTileset, _this$sourceTileset2, _this$sourceTileset2$;
|
|
227
|
+
|
|
228
|
+
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));
|
|
229
|
+
const extent = [fullExtent.xmin, fullExtent.ymin, fullExtent.xmax, fullExtent.ymax];
|
|
201
230
|
const layers0data = {
|
|
202
231
|
version: "{".concat(uuidv4().toUpperCase(), "}"),
|
|
203
232
|
id: 0,
|
|
@@ -210,7 +239,8 @@ export default class I3SConverter {
|
|
|
210
239
|
nodePages: {
|
|
211
240
|
nodesPerPage: HARDCODED_NODES_PER_PAGE
|
|
212
241
|
},
|
|
213
|
-
compressGeometry: this.options.draco
|
|
242
|
+
compressGeometry: this.options.draco,
|
|
243
|
+
fullExtent
|
|
214
244
|
};
|
|
215
245
|
this.layers0 = transform(layers0data, layersTemplate());
|
|
216
246
|
}
|
|
@@ -247,9 +277,14 @@ export default class I3SConverter {
|
|
|
247
277
|
const childPath = join(this.layers0Path, 'nodes', child.path);
|
|
248
278
|
|
|
249
279
|
if (this.options.slpk) {
|
|
250
|
-
this.
|
|
280
|
+
this.writeQueue.enqueue({
|
|
281
|
+
archiveKey: 'nodes/1/3dNodeIndexDocument.json.gz',
|
|
282
|
+
writePromise: writeFileForSlpk(childPath, JSON.stringify(child), '3dNodeIndexDocument.json')
|
|
283
|
+
});
|
|
251
284
|
} else {
|
|
252
|
-
|
|
285
|
+
this.writeQueue.enqueue({
|
|
286
|
+
writePromise: writeFile(childPath, JSON.stringify(child))
|
|
287
|
+
});
|
|
253
288
|
}
|
|
254
289
|
} else {
|
|
255
290
|
await this._addChildrenWithNeighborsAndWriteFile({
|
|
@@ -265,17 +300,27 @@ export default class I3SConverter {
|
|
|
265
300
|
|
|
266
301
|
async _writeLayers0() {
|
|
267
302
|
if (this.options.slpk) {
|
|
268
|
-
this.
|
|
303
|
+
this.writeQueue.enqueue({
|
|
304
|
+
archiveKey: '3dSceneLayer.json.gz',
|
|
305
|
+
writePromise: writeFileForSlpk(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json')
|
|
306
|
+
});
|
|
269
307
|
} else {
|
|
270
|
-
|
|
308
|
+
this.writeQueue.enqueue({
|
|
309
|
+
writePromise: writeFile(this.layers0Path, JSON.stringify(this.layers0))
|
|
310
|
+
});
|
|
271
311
|
}
|
|
272
312
|
}
|
|
273
313
|
|
|
274
314
|
async _writeNodeIndexDocument(root0, nodePath, rootPath) {
|
|
275
315
|
if (this.options.slpk) {
|
|
276
|
-
this.
|
|
316
|
+
this.writeQueue.enqueue({
|
|
317
|
+
archiveKey: "nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz"),
|
|
318
|
+
writePromise: writeFileForSlpk(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json')
|
|
319
|
+
});
|
|
277
320
|
} else {
|
|
278
|
-
|
|
321
|
+
this.writeQueue.enqueue({
|
|
322
|
+
writePromise: writeFile(rootPath, JSON.stringify(root0))
|
|
323
|
+
});
|
|
279
324
|
}
|
|
280
325
|
}
|
|
281
326
|
|
|
@@ -463,7 +508,7 @@ export default class I3SConverter {
|
|
|
463
508
|
return null;
|
|
464
509
|
}
|
|
465
510
|
|
|
466
|
-
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);
|
|
511
|
+
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);
|
|
467
512
|
return resourcesData;
|
|
468
513
|
}
|
|
469
514
|
|
|
@@ -598,34 +643,53 @@ export default class I3SConverter {
|
|
|
598
643
|
async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
|
|
599
644
|
if (this.options.slpk) {
|
|
600
645
|
const slpkGeometryPath = join(childPath, 'geometries');
|
|
601
|
-
this.
|
|
646
|
+
this.writeQueue.enqueue({
|
|
647
|
+
archiveKey: "".concat(slpkChildPath, "/geometries/0.bin.gz"),
|
|
648
|
+
writePromise: writeFileForSlpk(slpkGeometryPath, geometryBuffer, '0.bin')
|
|
649
|
+
});
|
|
602
650
|
} else {
|
|
603
651
|
const geometryPath = join(childPath, 'geometries/0/');
|
|
604
|
-
|
|
652
|
+
this.writeQueue.enqueue({
|
|
653
|
+
writePromise: writeFile(geometryPath, geometryBuffer, 'index.bin')
|
|
654
|
+
});
|
|
605
655
|
}
|
|
606
656
|
|
|
607
657
|
if (this.options.draco) {
|
|
608
658
|
if (this.options.slpk) {
|
|
609
659
|
const slpkCompressedGeometryPath = join(childPath, 'geometries');
|
|
610
|
-
this.
|
|
660
|
+
this.writeQueue.enqueue({
|
|
661
|
+
archiveKey: "".concat(slpkChildPath, "/geometries/1.bin.gz"),
|
|
662
|
+
writePromise: writeFileForSlpk(slpkCompressedGeometryPath, compressedGeometry, '1.bin')
|
|
663
|
+
});
|
|
611
664
|
} else {
|
|
612
665
|
const compressedGeometryPath = join(childPath, 'geometries/1/');
|
|
613
|
-
|
|
666
|
+
this.writeQueue.enqueue({
|
|
667
|
+
writePromise: writeFile(compressedGeometryPath, compressedGeometry, 'index.bin')
|
|
668
|
+
});
|
|
614
669
|
}
|
|
615
670
|
}
|
|
616
671
|
}
|
|
617
672
|
|
|
618
673
|
async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
|
|
674
|
+
if (!sharedResources) {
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
|
|
619
678
|
sharedResources.nodePath = nodePath;
|
|
620
679
|
const sharedData = transform(sharedResources, sharedResourcesTemplate());
|
|
621
680
|
const sharedDataStr = JSON.stringify(sharedData);
|
|
622
681
|
|
|
623
682
|
if (this.options.slpk) {
|
|
624
683
|
const slpkSharedPath = join(childPath, 'shared');
|
|
625
|
-
this.
|
|
684
|
+
this.writeQueue.enqueue({
|
|
685
|
+
archiveKey: "".concat(slpkChildPath, "/shared/sharedResource.json.gz"),
|
|
686
|
+
writePromise: writeFileForSlpk(slpkSharedPath, sharedDataStr, 'sharedResource.json')
|
|
687
|
+
});
|
|
626
688
|
} else {
|
|
627
689
|
const sharedPath = join(childPath, 'shared/');
|
|
628
|
-
|
|
690
|
+
this.writeQueue.enqueue({
|
|
691
|
+
writePromise: writeFile(sharedPath, sharedDataStr)
|
|
692
|
+
});
|
|
629
693
|
}
|
|
630
694
|
}
|
|
631
695
|
|
|
@@ -651,7 +715,11 @@ export default class I3SConverter {
|
|
|
651
715
|
name: '1',
|
|
652
716
|
format: 'ktx2'
|
|
653
717
|
});
|
|
654
|
-
const ktx2TextureData =
|
|
718
|
+
const ktx2TextureData = encode(texture.image, KTX2BasisWriterWorker, { ...KTX2BasisWriterWorker.options,
|
|
719
|
+
source: this.workerSource.ktx2,
|
|
720
|
+
reuseWorkers: true,
|
|
721
|
+
_nodeWorkers: true
|
|
722
|
+
});
|
|
655
723
|
await this.writeTextureFile(ktx2TextureData, '1', 'ktx2', childPath, slpkChildPath);
|
|
656
724
|
}
|
|
657
725
|
|
|
@@ -671,7 +739,7 @@ export default class I3SConverter {
|
|
|
671
739
|
name: '0',
|
|
672
740
|
format: 'jpg'
|
|
673
741
|
});
|
|
674
|
-
const decodedFromKTX2TextureData =
|
|
742
|
+
const decodedFromKTX2TextureData = encode(texture.image.data[0], ImageWriter);
|
|
675
743
|
await this.writeTextureFile(decodedFromKTX2TextureData, '0', 'jpg', childPath, slpkChildPath);
|
|
676
744
|
}
|
|
677
745
|
}
|
|
@@ -689,27 +757,37 @@ export default class I3SConverter {
|
|
|
689
757
|
if (this.options.slpk) {
|
|
690
758
|
const slpkTexturePath = join(childPath, 'textures');
|
|
691
759
|
const compress = false;
|
|
692
|
-
this.
|
|
760
|
+
this.writeQueue.enqueue({
|
|
761
|
+
archiveKey: "".concat(slpkChildPath, "/textures/").concat(name, ".").concat(format),
|
|
762
|
+
writePromise: writeFileForSlpk(slpkTexturePath, textureData, "".concat(name, ".").concat(format), compress)
|
|
763
|
+
});
|
|
693
764
|
} else {
|
|
694
765
|
const texturePath = join(childPath, "textures/".concat(name, "/"));
|
|
695
|
-
|
|
766
|
+
this.writeQueue.enqueue({
|
|
767
|
+
writePromise: writeFile(texturePath, textureData, "index.".concat(format))
|
|
768
|
+
});
|
|
696
769
|
}
|
|
697
770
|
}
|
|
698
771
|
|
|
699
|
-
async _writeAttributes(attributes, childPath, slpkChildPath) {
|
|
772
|
+
async _writeAttributes(attributes = [], childPath, slpkChildPath) {
|
|
700
773
|
var _this$layers4, _this$layers4$attribu;
|
|
701
774
|
|
|
702
|
-
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) {
|
|
775
|
+
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) {
|
|
703
776
|
for (let index = 0; index < attributes.length; index++) {
|
|
704
777
|
const folderName = this.layers0.attributeStorageInfo[index].key;
|
|
705
778
|
const fileBuffer = new Uint8Array(attributes[index]);
|
|
706
779
|
|
|
707
780
|
if (this.options.slpk) {
|
|
708
781
|
const slpkAttributesPath = join(childPath, 'attributes', folderName);
|
|
709
|
-
this.
|
|
782
|
+
this.writeQueue.enqueue({
|
|
783
|
+
archiveKey: "".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz"),
|
|
784
|
+
writePromise: writeFileForSlpk(slpkAttributesPath, fileBuffer, '0.bin')
|
|
785
|
+
});
|
|
710
786
|
} else {
|
|
711
787
|
const attributesPath = join(childPath, "attributes/".concat(folderName, "/0"));
|
|
712
|
-
|
|
788
|
+
this.writeQueue.enqueue({
|
|
789
|
+
writePromise: writeFile(attributesPath, fileBuffer, 'index.bin')
|
|
790
|
+
});
|
|
713
791
|
}
|
|
714
792
|
}
|
|
715
793
|
}
|
|
@@ -986,5 +1064,32 @@ export default class I3SConverter {
|
|
|
986
1064
|
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);
|
|
987
1065
|
}
|
|
988
1066
|
|
|
1067
|
+
async loadWorkers() {
|
|
1068
|
+
console.log("Loading workers source...");
|
|
1069
|
+
|
|
1070
|
+
if (this.options.draco) {
|
|
1071
|
+
const url = getWorkerURL(DracoWriterWorker, { ...getLoaderOptions()
|
|
1072
|
+
});
|
|
1073
|
+
const sourceResponse = await fetchFile(url);
|
|
1074
|
+
const source = await sourceResponse.text();
|
|
1075
|
+
this.workerSource.draco = source;
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
if (this.generateTextures) {
|
|
1079
|
+
const url = getWorkerURL(KTX2BasisWriterWorker, { ...getLoaderOptions()
|
|
1080
|
+
});
|
|
1081
|
+
const sourceResponse = await fetchFile(url);
|
|
1082
|
+
const source = await sourceResponse.text();
|
|
1083
|
+
this.workerSource.ktx2 = source;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
const i3sAttributesWorkerUrl = getWorkerURL(I3SAttributesWorker, { ...getLoaderOptions()
|
|
1087
|
+
});
|
|
1088
|
+
const sourceResponse = await fetchFile(i3sAttributesWorkerUrl);
|
|
1089
|
+
const source = await sourceResponse.text();
|
|
1090
|
+
this.workerSource.I3SAttributes = source;
|
|
1091
|
+
console.log("Loading workers source completed!");
|
|
1092
|
+
}
|
|
1093
|
+
|
|
989
1094
|
}
|
|
990
1095
|
//# sourceMappingURL=i3s-converter.js.map
|