@loaders.gl/tile-converter 4.0.0-alpha.6 → 4.0.0-alpha.8
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/bin/converter.js +1 -1
- package/dist/3d-tiles-attributes-worker.js +2 -2
- package/dist/3d-tiles-attributes-worker.js.map +3 -3
- package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/3d-tiles-converter.js +4 -3
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +0 -8
- package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +2 -15
- package/dist/converter.min.js +75 -76
- package/dist/deps-installer/deps-installer.js +4 -4
- package/dist/dist.min.js +2529 -1884
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +0 -3
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +2 -10
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +5 -5
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +1 -1
- package/dist/es5/i3s-attributes-worker.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +4 -4
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +6 -7
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +49 -30
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +46 -16
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/load-3d-tiles.js +82 -0
- package/dist/es5/i3s-converter/helpers/load-3d-tiles.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/node-index-document.js +74 -45
- package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js +111 -0
- package/dist/es5/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -0
- package/dist/es5/i3s-converter/helpers/tileset-traversal.js +82 -0
- package/dist/es5/i3s-converter/helpers/tileset-traversal.js.map +1 -0
- package/dist/es5/i3s-converter/i3s-converter.js +545 -523
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/types.js +16 -0
- package/dist/es5/i3s-converter/types.js.map +1 -1
- package/dist/es5/i3s-server/README.md +19 -0
- package/dist/es5/i3s-server/app.js +10 -1
- package/dist/es5/i3s-server/app.js.map +1 -1
- package/dist/es5/i3s-server/controllers/slpk-controller.js +84 -0
- package/dist/es5/i3s-server/controllers/slpk-controller.js.map +1 -0
- package/dist/es5/i3s-server/routes/slpk-router.js +71 -0
- package/dist/es5/i3s-server/routes/slpk-router.js.map +1 -0
- package/dist/es5/i3s-server/utils/create-scene-server.js +17 -0
- package/dist/es5/i3s-server/utils/create-scene-server.js.map +1 -0
- package/dist/es5/lib/utils/file-utils.js +1 -1
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/geometry-utils.js +15 -0
- package/dist/es5/lib/utils/geometry-utils.js.map +1 -0
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +0 -3
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +2 -8
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +5 -5
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/i3s-attributes-worker.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +4 -4
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js +6 -7
- package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +37 -18
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +50 -16
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/load-3d-tiles.js +35 -0
- package/dist/esm/i3s-converter/helpers/load-3d-tiles.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/node-index-document.js +14 -1
- package/dist/esm/i3s-converter/helpers/node-index-document.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js +48 -0
- package/dist/esm/i3s-converter/helpers/preprocess-3d-tiles.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/tileset-traversal.js +14 -0
- package/dist/esm/i3s-converter/helpers/tileset-traversal.js.map +1 -0
- package/dist/esm/i3s-converter/i3s-converter.js +134 -127
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/types.js +10 -1
- package/dist/esm/i3s-converter/types.js.map +1 -1
- package/dist/esm/i3s-server/README.md +19 -0
- package/dist/esm/i3s-server/app.js +11 -1
- package/dist/esm/i3s-server/app.js.map +1 -1
- package/dist/esm/i3s-server/controllers/slpk-controller.js +36 -0
- package/dist/esm/i3s-server/controllers/slpk-controller.js.map +1 -0
- package/dist/esm/i3s-server/routes/slpk-router.js +33 -0
- package/dist/esm/i3s-server/routes/slpk-router.js.map +1 -0
- package/dist/esm/i3s-server/utils/create-scene-server.js +16 -0
- package/dist/esm/i3s-server/utils/create-scene-server.js.map +1 -0
- package/dist/esm/lib/utils/file-utils.js +1 -1
- package/dist/esm/lib/utils/file-utils.js.map +1 -1
- package/dist/esm/lib/utils/geometry-utils.js +8 -0
- package/dist/esm/lib/utils/geometry-utils.js.map +1 -0
- package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/i3s-attributes-worker.d.ts +10 -2
- package/dist/i3s-attributes-worker.d.ts.map +1 -1
- package/dist/i3s-attributes-worker.js +2 -2
- package/dist/i3s-attributes-worker.js.map +3 -3
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts +4 -2
- package/dist/i3s-converter/helpers/batch-ids-extensions.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +4 -7
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts +3 -4
- package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/coordinate-converter.js +8 -9
- package/dist/i3s-converter/helpers/geometry-converter.d.ts +9 -4
- package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/geometry-converter.js +84 -54
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts +22 -3
- package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/gltf-attributes.js +62 -22
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts +18 -0
- package/dist/i3s-converter/helpers/load-3d-tiles.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/load-3d-tiles.js +53 -0
- package/dist/i3s-converter/helpers/node-index-document.d.ts +8 -0
- package/dist/i3s-converter/helpers/node-index-document.d.ts.map +1 -1
- package/dist/i3s-converter/helpers/node-index-document.js +20 -2
- package/dist/i3s-converter/helpers/node-pages.js +1 -1
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts +23 -0
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/preprocess-3d-tiles.js +76 -0
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts +25 -0
- package/dist/i3s-converter/helpers/tileset-traversal.d.ts.map +1 -0
- package/dist/i3s-converter/helpers/tileset-traversal.js +29 -0
- package/dist/i3s-converter/i3s-converter.d.ts +40 -40
- package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
- package/dist/i3s-converter/i3s-converter.js +150 -125
- package/dist/i3s-converter/types.d.ts +18 -0
- package/dist/i3s-converter/types.d.ts.map +1 -1
- package/dist/i3s-converter/types.js +15 -0
- package/dist/i3s-server/app.d.ts.map +1 -1
- package/dist/i3s-server/app.js +9 -1
- package/dist/i3s-server/controllers/slpk-controller.d.ts +3 -0
- package/dist/i3s-server/controllers/slpk-controller.d.ts.map +1 -0
- package/dist/i3s-server/controllers/slpk-controller.js +32 -0
- package/dist/i3s-server/routes/slpk-router.d.ts +3 -0
- package/dist/i3s-server/routes/slpk-router.d.ts.map +1 -0
- package/dist/i3s-server/routes/slpk-router.js +33 -0
- package/dist/i3s-server/utils/create-scene-server.d.ts +11 -0
- package/dist/i3s-server/utils/create-scene-server.d.ts.map +1 -0
- package/dist/i3s-server/utils/create-scene-server.js +14 -0
- package/dist/lib/utils/file-utils.d.ts.map +1 -1
- package/dist/lib/utils/file-utils.js +2 -1
- package/dist/lib/utils/geometry-utils.d.ts +9 -0
- package/dist/lib/utils/geometry-utils.d.ts.map +1 -0
- package/dist/lib/utils/geometry-utils.js +18 -0
- package/dist/lib/utils/lod-conversion-utils.d.ts +3 -2
- package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
- package/dist/lib/utils/lod-conversion-utils.js +1 -1
- package/package.json +15 -16
- package/src/3d-tiles-converter/3d-tiles-converter.ts +9 -8
- package/src/3d-tiles-converter/helpers/b3dm-converter.ts +2 -16
- package/src/deps-installer/deps-installer.ts +4 -4
- package/src/i3s-attributes-worker.ts +11 -2
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +15 -19
- package/src/i3s-converter/helpers/coordinate-converter.ts +11 -10
- package/src/i3s-converter/helpers/geometry-converter.ts +154 -95
- package/src/i3s-converter/helpers/gltf-attributes.ts +85 -25
- package/src/i3s-converter/helpers/load-3d-tiles.ts +68 -0
- package/src/i3s-converter/helpers/node-index-document.ts +22 -2
- package/src/i3s-converter/helpers/preprocess-3d-tiles.ts +81 -0
- package/src/i3s-converter/helpers/tileset-traversal.ts +51 -0
- package/src/i3s-converter/i3s-converter.ts +229 -178
- package/src/i3s-converter/types.ts +20 -0
- package/src/i3s-server/README.md +19 -0
- package/src/i3s-server/app.js +8 -1
- package/src/i3s-server/controllers/slpk-controller.js +38 -0
- package/src/i3s-server/routes/slpk-router.js +33 -0
- package/src/i3s-server/utils/create-scene-server.js +15 -0
- package/src/lib/utils/file-utils.ts +2 -1
- package/src/lib/utils/geometry-utils.ts +14 -0
- package/src/lib/utils/lod-conversion-utils.ts +6 -2
|
@@ -28,7 +28,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
const core_1 = require("@loaders.gl/core");
|
|
31
|
-
const tiles_1 = require("@loaders.gl/tiles");
|
|
32
31
|
const _3d_tiles_1 = require("@loaders.gl/3d-tiles");
|
|
33
32
|
const path_1 = require("path");
|
|
34
33
|
const uuid_1 = require("uuid");
|
|
@@ -50,6 +49,7 @@ const shared_resources_1 = require("./json-templates/shared-resources");
|
|
|
50
49
|
const node_debug_1 = require("./helpers/node-debug");
|
|
51
50
|
const textures_1 = require("@loaders.gl/textures");
|
|
52
51
|
const images_1 = require("@loaders.gl/images");
|
|
52
|
+
const types_1 = require("./types");
|
|
53
53
|
const worker_utils_1 = require("@loaders.gl/worker-utils");
|
|
54
54
|
const draco_1 = require("@loaders.gl/draco");
|
|
55
55
|
const write_queue_1 = __importDefault(require("../lib/utils/write-queue"));
|
|
@@ -57,6 +57,11 @@ const i3s_attributes_worker_1 = require("../i3s-attributes-worker");
|
|
|
57
57
|
const constants_1 = require("../constants");
|
|
58
58
|
const feature_attributes_1 = require("./helpers/feature-attributes");
|
|
59
59
|
const node_index_document_1 = require("./helpers/node-index-document");
|
|
60
|
+
const load_3d_tiles_1 = require("./helpers/load-3d-tiles");
|
|
61
|
+
const core_2 = require("@math.gl/core");
|
|
62
|
+
const tiles_1 = require("@loaders.gl/tiles");
|
|
63
|
+
const tileset_traversal_1 = require("./helpers/tileset-traversal");
|
|
64
|
+
const preprocess_3d_tiles_1 = require("./helpers/preprocess-3d-tiles");
|
|
60
65
|
const ION_DEFAULT_TOKEN = process_1.default.env?.IonToken || // eslint-disable-line
|
|
61
66
|
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ'; // eslint-disable-line
|
|
62
67
|
const HARDCODED_NODES_PER_PAGE = 64;
|
|
@@ -74,11 +79,26 @@ class I3SConverter {
|
|
|
74
79
|
this.conversionStartTime = [0, 0];
|
|
75
80
|
this.refreshTokenTime = [0, 0];
|
|
76
81
|
this.sourceTileset = null;
|
|
82
|
+
this.loadOptions = {
|
|
83
|
+
_nodeWorkers: true,
|
|
84
|
+
reuseWorkers: true,
|
|
85
|
+
basis: {
|
|
86
|
+
format: 'rgba32',
|
|
87
|
+
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
88
|
+
workerUrl: './modules/textures/dist/basis-worker-node.js'
|
|
89
|
+
},
|
|
90
|
+
// We need to load local fs workers because nodejs can't load workers from the Internet
|
|
91
|
+
draco: { workerUrl: './modules/draco/dist/draco-worker-node.js' },
|
|
92
|
+
fetch: {}
|
|
93
|
+
};
|
|
77
94
|
this.geoidHeightModel = null;
|
|
78
95
|
this.Loader = _3d_tiles_1.Tiles3DLoader;
|
|
79
96
|
this.workerSource = {};
|
|
80
97
|
this.writeQueue = new write_queue_1.default();
|
|
81
98
|
this.compressList = null;
|
|
99
|
+
this.preprocessData = {
|
|
100
|
+
meshTopologyTypes: new Set()
|
|
101
|
+
};
|
|
82
102
|
this.nodePages = new node_pages_1.default(file_utils_1.writeFile, HARDCODED_NODES_PER_PAGE, this);
|
|
83
103
|
this.options = {};
|
|
84
104
|
this.layers0Path = '';
|
|
@@ -150,44 +170,77 @@ class I3SConverter {
|
|
|
150
170
|
await this.loadWorkers();
|
|
151
171
|
try {
|
|
152
172
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
153
|
-
const tilesetOptions = {
|
|
154
|
-
loadOptions: {
|
|
155
|
-
_nodeWorkers: true,
|
|
156
|
-
reuseWorkers: true,
|
|
157
|
-
basis: { format: 'rgba32' },
|
|
158
|
-
'basis-nodejs': {
|
|
159
|
-
format: 'rgba32',
|
|
160
|
-
workerUrl: './modules/textures/dist/basis-nodejs-worker.js'
|
|
161
|
-
},
|
|
162
|
-
'draco-nodejs': { workerUrl: './modules/draco/dist/draco-nodejs-worker.js' }
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
173
|
if (preloadOptions.headers) {
|
|
166
|
-
|
|
174
|
+
this.loadOptions.fetch = { headers: preloadOptions.headers };
|
|
175
|
+
}
|
|
176
|
+
this.sourceTileset = await (0, core_1.load)(inputUrl, this.Loader, this.loadOptions);
|
|
177
|
+
const preprocessResult = await this.preprocessConversion();
|
|
178
|
+
if (preprocessResult) {
|
|
179
|
+
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
180
|
+
await this._finishConversion({ slpk: Boolean(slpk), outputPath, tilesetName });
|
|
167
181
|
}
|
|
168
|
-
Object.assign(tilesetOptions, preloadOptions);
|
|
169
|
-
const sourceTilesetJson = await (0, core_1.load)(inputUrl, this.Loader, tilesetOptions.loadOptions);
|
|
170
|
-
// console.log(tilesetJson); // eslint-disable-line
|
|
171
|
-
this.sourceTileset = new tiles_1.Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
172
|
-
await this._createAndSaveTileset(outputPath, tilesetName, sourceTilesetJson?.root?.boundingVolume?.region);
|
|
173
|
-
await this._finishConversion({ slpk: Boolean(slpk), outputPath, tilesetName });
|
|
174
|
-
return sourceTilesetJson;
|
|
175
182
|
}
|
|
176
183
|
catch (error) {
|
|
177
184
|
throw error;
|
|
178
185
|
}
|
|
179
186
|
finally {
|
|
187
|
+
await this.writeQueue.finalize();
|
|
180
188
|
// Clean up worker pools
|
|
181
189
|
const workerFarm = worker_utils_1.WorkerFarm.getWorkerFarm({});
|
|
182
190
|
workerFarm.destroy();
|
|
183
191
|
}
|
|
192
|
+
return 'success';
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Preprocess stage of the tile converter. Traverse all the tiles tree and
|
|
196
|
+
* check a tile content to be sure that the data is supported
|
|
197
|
+
* @returns true - the conversion is possible, false - the tileset's content is not supported
|
|
198
|
+
*/
|
|
199
|
+
async preprocessConversion() {
|
|
200
|
+
console.log(`Analyze source tileset`);
|
|
201
|
+
const sourceRootTile = this.sourceTileset.root;
|
|
202
|
+
await (0, tileset_traversal_1.traverseDatasetWith)(sourceRootTile, null, this.analyzeTile.bind(this), undefined, this.options.maxDepth);
|
|
203
|
+
const { meshTopologyTypes } = this.preprocessData;
|
|
204
|
+
console.log(`------------------------------------------------`);
|
|
205
|
+
console.log(`Preprocess results:`);
|
|
206
|
+
console.log(`glTF mesh topology types: ${Array.from(meshTopologyTypes).join(', ')}`);
|
|
207
|
+
console.log(`------------------------------------------------`);
|
|
208
|
+
if (!meshTopologyTypes.has(types_1.GltfPrimitiveModeString.TRIANGLES) &&
|
|
209
|
+
!meshTopologyTypes.has(types_1.GltfPrimitiveModeString.TRIANGLE_STRIP)) {
|
|
210
|
+
console.log('The tileset is of unsupported mesh topology types. The conversion will be interrupted.');
|
|
211
|
+
console.log(`------------------------------------------------`);
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Analyze a tile content. The callback for preprocess stage.
|
|
218
|
+
* @param sourceTile - 3DTiles tile JSON metadata
|
|
219
|
+
* @param traversalProps - mandatory argument but it is not used for the preprocess stage
|
|
220
|
+
* @returns - nothing
|
|
221
|
+
*/
|
|
222
|
+
async analyzeTile(sourceTile, traversalProps) {
|
|
223
|
+
if (sourceTile.type === 'json') {
|
|
224
|
+
await (0, load_3d_tiles_1.loadNestedTileset)(this.sourceTileset, sourceTile, this.loadOptions);
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
if (sourceTile.id) {
|
|
228
|
+
console.log(`[analyze]: ${sourceTile.id}`); // eslint-disable-line
|
|
229
|
+
}
|
|
230
|
+
const tileContent = await (0, load_3d_tiles_1.loadTile3DContent)(this.sourceTileset, sourceTile, {
|
|
231
|
+
...this.loadOptions,
|
|
232
|
+
'3d-tiles': { ...this.loadOptions['3d-tiles'], loadGLTF: false }
|
|
233
|
+
});
|
|
234
|
+
const tilePreprocessData = await (0, preprocess_3d_tiles_1.analyzeTileContent)(sourceTile, tileContent);
|
|
235
|
+
(0, preprocess_3d_tiles_1.mergePreprocessData)(this.preprocessData, tilePreprocessData);
|
|
236
|
+
return null;
|
|
184
237
|
}
|
|
185
238
|
/**
|
|
186
239
|
* Convert and save the layer and embedded tiles
|
|
187
240
|
* @param outputPath - path to save output data
|
|
188
241
|
* @param tilesetName - new tileset path
|
|
189
242
|
*/
|
|
190
|
-
async _createAndSaveTileset(outputPath, tilesetName
|
|
243
|
+
async _createAndSaveTileset(outputPath, tilesetName) {
|
|
191
244
|
const tilesetPath = (0, path_1.join)(`${outputPath}`, `${tilesetName}`);
|
|
192
245
|
// Removing the tilesetPath needed to exclude erroneous files after conversion
|
|
193
246
|
try {
|
|
@@ -197,11 +250,12 @@ class I3SConverter {
|
|
|
197
250
|
// do nothing
|
|
198
251
|
}
|
|
199
252
|
this.layers0Path = (0, path_1.join)(tilesetPath, 'SceneServer', 'layers', '0');
|
|
200
|
-
this._formLayers0(tilesetName, boundingVolumeRegion);
|
|
201
253
|
this.materialDefinitions = [];
|
|
202
254
|
this.materialMap = new Map();
|
|
203
255
|
const sourceRootTile = this.sourceTileset.root;
|
|
204
|
-
const
|
|
256
|
+
const sourceBoundingVolume = (0, tiles_1.createBoundingVolume)(sourceRootTile.boundingVolume, new core_2.Matrix4(sourceRootTile.transform), null);
|
|
257
|
+
this._formLayers0(tilesetName, sourceBoundingVolume, this.sourceTileset?.root?.boundingVolume?.region);
|
|
258
|
+
const boundingVolumes = (0, coordinate_converter_1.createBoundingVolumes)(sourceBoundingVolume, this.geoidHeightModel);
|
|
205
259
|
await this.nodePages.push({
|
|
206
260
|
index: 0,
|
|
207
261
|
lodThreshold: 0,
|
|
@@ -209,7 +263,10 @@ class I3SConverter {
|
|
|
209
263
|
children: []
|
|
210
264
|
});
|
|
211
265
|
const rootNode = await node_index_document_1.NodeIndexDocument.createRootNode(boundingVolumes, this);
|
|
212
|
-
await
|
|
266
|
+
await (0, tileset_traversal_1.traverseDatasetWith)(sourceRootTile, {
|
|
267
|
+
transform: new core_2.Matrix4(sourceRootTile.transform),
|
|
268
|
+
parentNodes: [rootNode]
|
|
269
|
+
}, this.convertTile.bind(this), this.finalizeTile.bind(this), this.options.maxDepth);
|
|
213
270
|
this.layers0.materialDefinitions = this.materialDefinitions;
|
|
214
271
|
// @ts-ignore
|
|
215
272
|
this.layers0.geometryDefinitions = (0, json_map_transform_1.default)(this.geometryConfigs.map((config) => ({
|
|
@@ -231,10 +288,15 @@ class I3SConverter {
|
|
|
231
288
|
}
|
|
232
289
|
/**
|
|
233
290
|
* Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md
|
|
234
|
-
* @param
|
|
291
|
+
* @param tilesetName - Name of layer
|
|
292
|
+
* @param sourceBoundingVolume - initialized bounding volume of the source root tile
|
|
293
|
+
* @param boundingVolumeRegion - region bounding volume of the source root tile
|
|
235
294
|
*/
|
|
236
|
-
_formLayers0(tilesetName, boundingVolumeRegion) {
|
|
237
|
-
|
|
295
|
+
_formLayers0(tilesetName, sourceBoundingVolume, boundingVolumeRegion) {
|
|
296
|
+
if (!this.sourceTileset?.root) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const fullExtent = (0, coordinate_converter_1.convertBoundingVolumeToI3SFullExtent)(sourceBoundingVolume);
|
|
238
300
|
if (boundingVolumeRegion) {
|
|
239
301
|
fullExtent.zmin = boundingVolumeRegion[4];
|
|
240
302
|
fullExtent.zmax = boundingVolumeRegion[5];
|
|
@@ -257,30 +319,6 @@ class I3SConverter {
|
|
|
257
319
|
};
|
|
258
320
|
this.layers0 = (0, json_map_transform_1.default)(layers0data, (0, layers_1.LAYERS)());
|
|
259
321
|
}
|
|
260
|
-
/**
|
|
261
|
-
* Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md
|
|
262
|
-
* @param rootNode - 3DNodeIndexDocument of root node https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md
|
|
263
|
-
* @param sourceRootTile - Source (3DTile) tile data
|
|
264
|
-
*/
|
|
265
|
-
async _convertNodesTree(rootNode, sourceRootTile) {
|
|
266
|
-
await this.sourceTileset._loadTile(sourceRootTile);
|
|
267
|
-
if (this.isContentSupported(sourceRootTile)) {
|
|
268
|
-
const childNodes = await this._createNode(rootNode, sourceRootTile, 0);
|
|
269
|
-
for (const childNode of childNodes) {
|
|
270
|
-
await childNode.save();
|
|
271
|
-
}
|
|
272
|
-
await rootNode.addChildren(childNodes);
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
await this._addChildrenWithNeighborsAndWriteFile({
|
|
276
|
-
parentNode: rootNode,
|
|
277
|
-
sourceTiles: sourceRootTile.children,
|
|
278
|
-
level: 1
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
await sourceRootTile.unloadContent();
|
|
282
|
-
await rootNode.save();
|
|
283
|
-
}
|
|
284
322
|
/**
|
|
285
323
|
* Write 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md in file
|
|
286
324
|
*/
|
|
@@ -333,83 +371,73 @@ class I3SConverter {
|
|
|
333
371
|
}
|
|
334
372
|
}
|
|
335
373
|
/**
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* @param
|
|
339
|
-
* @param
|
|
340
|
-
* @
|
|
341
|
-
*/
|
|
342
|
-
async _addChildrenWithNeighborsAndWriteFile(data) {
|
|
343
|
-
await this._addChildren(data);
|
|
344
|
-
await data.parentNode.addNeighbors();
|
|
345
|
-
}
|
|
346
|
-
/**
|
|
347
|
-
* Convert nested subtree of 3DTiles dataset
|
|
348
|
-
* @param param0
|
|
349
|
-
* @param data.parentNode - 3DNodeIndexDocument of parent node
|
|
350
|
-
* @param param0.sourceTile - source 3DTile data
|
|
351
|
-
* @param param0.level - tree level
|
|
374
|
+
* Convert the specific 3DTiles tile to I3S nodes.
|
|
375
|
+
* This is callback function for the traversal generic function
|
|
376
|
+
* @param sourceTile - current 3DTiles tile JSON metadata
|
|
377
|
+
* @param traversalProps - traversal properties calculated recursively
|
|
378
|
+
* @returns - traversal properties for the child tiles
|
|
352
379
|
*/
|
|
353
|
-
async
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
380
|
+
async convertTile(sourceTile, traversalProps) {
|
|
381
|
+
if (sourceTile.type === 'json' || sourceTile.type === 'empty') {
|
|
382
|
+
if (sourceTile.type === 'json') {
|
|
383
|
+
if (sourceTile.id) {
|
|
384
|
+
console.log(`[load]: ${sourceTile.id}`); // eslint-disable-line
|
|
385
|
+
}
|
|
386
|
+
await (0, load_3d_tiles_1.loadNestedTileset)(this.sourceTileset, sourceTile, this.loadOptions);
|
|
387
|
+
}
|
|
388
|
+
return traversalProps;
|
|
389
|
+
}
|
|
390
|
+
if (sourceTile.id) {
|
|
391
|
+
console.log(`[convert]: ${sourceTile.id}`); // eslint-disable-line
|
|
392
|
+
}
|
|
393
|
+
const { parentNodes, transform } = traversalProps;
|
|
394
|
+
let transformationMatrix = transform.clone();
|
|
395
|
+
if (sourceTile.transform) {
|
|
396
|
+
transformationMatrix = transformationMatrix.multiplyRight(sourceTile.transform);
|
|
397
|
+
}
|
|
398
|
+
const parentNode = parentNodes[0];
|
|
399
|
+
const childNodes = await this._createNode(parentNode, sourceTile, transformationMatrix);
|
|
371
400
|
await parentNode.addChildren(childNodes);
|
|
401
|
+
const newTraversalProps = {
|
|
402
|
+
transform: transformationMatrix,
|
|
403
|
+
parentNodes: childNodes
|
|
404
|
+
};
|
|
405
|
+
return newTraversalProps;
|
|
372
406
|
}
|
|
373
407
|
/**
|
|
374
|
-
*
|
|
375
|
-
* @param
|
|
376
|
-
* @param
|
|
377
|
-
* @param param0.sourceTile - source 3DTile data
|
|
378
|
-
* @param param0.level - tree level
|
|
408
|
+
* Do final action with nodes after the current node and all child nodes been converted.
|
|
409
|
+
* @param conversionResults - array of conversion results of the current node
|
|
410
|
+
* @param currentTraversalProps - traversal properties of the current node
|
|
379
411
|
*/
|
|
380
|
-
async
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
for (const sourceTile of sourceTiles) {
|
|
386
|
-
if (sourceTile.type === 'json') {
|
|
387
|
-
await this.convertNestedTileset({ parentNode, sourceTile, level });
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
await this.convertNode({ parentNode, sourceTile, level });
|
|
391
|
-
}
|
|
392
|
-
if (sourceTile.id) {
|
|
393
|
-
console.log(sourceTile.id); // eslint-disable-line
|
|
412
|
+
async finalizeTile(conversionResults, currentTraversalProps) {
|
|
413
|
+
for (const result of conversionResults) {
|
|
414
|
+
for (const node of result.parentNodes) {
|
|
415
|
+
await node.addNeighbors();
|
|
394
416
|
}
|
|
395
417
|
}
|
|
418
|
+
for (const node of currentTraversalProps.parentNodes) {
|
|
419
|
+
await node.save();
|
|
420
|
+
}
|
|
396
421
|
}
|
|
397
422
|
/**
|
|
398
423
|
* Convert tile to one or more I3S nodes
|
|
399
424
|
* @param parentNode - 3DNodeIndexDocument of parent node
|
|
400
425
|
* @param sourceTile - source 3DTile data
|
|
426
|
+
* @param transformationMatrix - transformation matrix of the current tile, calculated recursively multiplying
|
|
427
|
+
* transform of all parent tiles and transform of the current tile
|
|
401
428
|
* @param level - tree level
|
|
402
429
|
*/
|
|
403
|
-
async _createNode(parentNode, sourceTile,
|
|
430
|
+
async _createNode(parentNode, sourceTile, transformationMatrix) {
|
|
404
431
|
this._checkAddRefinementTypeForTile(sourceTile);
|
|
405
432
|
await this._updateTilesetOptions();
|
|
406
|
-
await this.sourceTileset.
|
|
407
|
-
|
|
408
|
-
|
|
433
|
+
const tileContent = await (0, load_3d_tiles_1.loadTile3DContent)(this.sourceTileset, sourceTile, this.loadOptions);
|
|
434
|
+
const sourceBoundingVolume = (0, tiles_1.createBoundingVolume)(sourceTile.boundingVolume, transformationMatrix, null);
|
|
435
|
+
let boundingVolumes = (0, coordinate_converter_1.createBoundingVolumes)(sourceBoundingVolume, this.geoidHeightModel);
|
|
436
|
+
const propertyTable = (0, geometry_converter_1.getPropertyTable)(tileContent);
|
|
409
437
|
if (propertyTable && !this.layers0?.attributeStorageInfo?.length) {
|
|
410
438
|
this._convertPropertyTableToNodeAttributes(propertyTable);
|
|
411
439
|
}
|
|
412
|
-
const resourcesData = await this._convertResources(sourceTile, parentNode.inPageId, propertyTable);
|
|
440
|
+
const resourcesData = await this._convertResources(sourceTile, transformationMatrix, sourceBoundingVolume, tileContent, parentNode.inPageId, propertyTable);
|
|
413
441
|
const nodes = [];
|
|
414
442
|
const nodeIds = [];
|
|
415
443
|
const nodesInPage = [];
|
|
@@ -448,23 +476,21 @@ class I3SConverter {
|
|
|
448
476
|
nodeIds.push(nodeInPage.index);
|
|
449
477
|
nodesInPage.push(nodeInPage);
|
|
450
478
|
}
|
|
451
|
-
sourceTile.unloadContent();
|
|
452
|
-
await this._addChildrenWithNeighborsAndWriteFile({
|
|
453
|
-
parentNode: nodes[0],
|
|
454
|
-
sourceTiles: sourceTile.children,
|
|
455
|
-
level: level + 1
|
|
456
|
-
});
|
|
457
479
|
return nodes;
|
|
458
480
|
}
|
|
459
481
|
/**
|
|
460
482
|
* Convert tile to one or more I3S nodes
|
|
461
483
|
* @param sourceTile - source tile (3DTile)
|
|
484
|
+
* @param transformationMatrix - transformation matrix of the current tile, calculated recursively multiplying
|
|
485
|
+
* transform of all parent tiles and transform of the current tile
|
|
486
|
+
* @param boundingVolume - initialized bounding volume of the source tile
|
|
487
|
+
* @param tileContent - content of the source tile
|
|
462
488
|
* @param parentId - id of parent node in node pages
|
|
463
489
|
* @param propertyTable - batch table from b3dm / feature properties from EXT_FEATURE_METADATA
|
|
464
490
|
* @returns - converted node resources
|
|
465
491
|
*/
|
|
466
|
-
async _convertResources(sourceTile, parentId, propertyTable) {
|
|
467
|
-
if (!this.isContentSupported(sourceTile)) {
|
|
492
|
+
async _convertResources(sourceTile, transformationMatrix, boundingVolume, tileContent, parentId, propertyTable) {
|
|
493
|
+
if (!this.isContentSupported(sourceTile) || !tileContent) {
|
|
468
494
|
return null;
|
|
469
495
|
}
|
|
470
496
|
const draftObb = {
|
|
@@ -472,7 +498,7 @@ class I3SConverter {
|
|
|
472
498
|
halfSize: [],
|
|
473
499
|
quaternion: []
|
|
474
500
|
};
|
|
475
|
-
const resourcesData = await (0, geometry_converter_1.default)(
|
|
501
|
+
const resourcesData = await (0, geometry_converter_1.default)(tileContent, transformationMatrix, boundingVolume, async () => (await this.nodePages.push({ index: 0, obb: draftObb }, parentId)).index, propertyTable, this.featuresHashArray, this.layers0?.attributeStorageInfo, this.options.draco, this.generateBoundingVolumes, this.options.mergeMaterials, this.geoidHeightModel, this.workerSource);
|
|
476
502
|
return resourcesData;
|
|
477
503
|
}
|
|
478
504
|
/**
|
|
@@ -834,10 +860,9 @@ class I3SConverter {
|
|
|
834
860
|
}
|
|
835
861
|
this.refreshTokenTime = process_1.default.hrtime();
|
|
836
862
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
837
|
-
this.sourceTileset.options = { ...this.sourceTileset.options, ...preloadOptions };
|
|
838
863
|
if (preloadOptions.headers) {
|
|
839
|
-
this.
|
|
840
|
-
...this.
|
|
864
|
+
this.loadOptions.fetch = {
|
|
865
|
+
...this.loadOptions.fetch,
|
|
841
866
|
headers: preloadOptions.headers
|
|
842
867
|
};
|
|
843
868
|
console.log('Authorization Bearer token has been updated'); // eslint-disable-line no-undef, no-console
|
|
@@ -856,11 +881,11 @@ class I3SConverter {
|
|
|
856
881
|
}
|
|
857
882
|
/**
|
|
858
883
|
* Check if the tile's content format is supported by the converter
|
|
859
|
-
* @param
|
|
884
|
+
* @param sourceTile
|
|
860
885
|
* @returns
|
|
861
886
|
*/
|
|
862
|
-
isContentSupported(
|
|
863
|
-
return ['b3dm', 'glTF'].includes(
|
|
887
|
+
isContentSupported(sourceTile) {
|
|
888
|
+
return ['b3dm', 'glTF', 'scenegraph'].includes(sourceTile.type || '');
|
|
864
889
|
}
|
|
865
890
|
async loadWorkers() {
|
|
866
891
|
console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console
|
|
@@ -142,4 +142,22 @@ export type MergedMaterial = {
|
|
|
142
142
|
uvRegion?: Uint16Array;
|
|
143
143
|
};
|
|
144
144
|
export type TypedArrayConstructor = Uint8ArrayConstructor | Int8ArrayConstructor | Uint16ArrayConstructor | Int16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor;
|
|
145
|
+
/**
|
|
146
|
+
* glTF primitive modes (mesh topology types)
|
|
147
|
+
* @see https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#_mesh_primitive_mode
|
|
148
|
+
*/
|
|
149
|
+
export declare enum GltfPrimitiveModeString {
|
|
150
|
+
POINTS = "POINTS",
|
|
151
|
+
LINES = "LINES",
|
|
152
|
+
LINE_LOOP = "LINE_LOOP",
|
|
153
|
+
LINE_STRIP = "LINE_STRIP",
|
|
154
|
+
TRIANGLES = "TRIANGLES",
|
|
155
|
+
TRIANGLE_STRIP = "TRIANGLE_STRIP",
|
|
156
|
+
TRIANGLE_FAN = "TRIANGLE_FAN"
|
|
157
|
+
}
|
|
158
|
+
/** Preprocessed data gathered from child tiles binary content */
|
|
159
|
+
export type PreprocessData = {
|
|
160
|
+
/** Mesh topology types used in gltf primitives of the tileset */
|
|
161
|
+
meshTopologyTypes: Set<GltfPrimitiveModeString>;
|
|
162
|
+
};
|
|
145
163
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/i3s-converter/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,kBAAkB,CAAC;AACxD,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,iBAAiB,CAAC;AAEzB,4CAA4C;AAC5C,MAAM,MAAM,qBAAqB,GAAG;IAClC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC;IAC7B;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;IACjD;;OAEG;IACH,OAAO,EAAE,GAAG,GAAG,I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AAM,CAAC;CACnB,CAAC;AAEF,2EAA2E;AAC3E,MAAM,MAAM,sBAAsB,GAAG;IACnC,2GAA2G;IAC3G,QAAQ,EAAE,qBAAqB,CAAC;IAChC,8BAA8B;IAC9B,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,uCAAuC;IACvC,eAAe,EAAE,cAAc,EAAE,CAAC;CACnC,CAAC;AAEF,wCAAwC;AACxC,MAAM,MAAM,cAAc,GAAG;IAC3B,uBAAuB;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4BAA4B;IAC5B,WAAW,CAAC,EAAE;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,8GAA8G;IAC9G,QAAQ,CAAC,EAAE,WAAW,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAC7B,qBAAqB,GACrB,oBAAoB,GACpB,sBAAsB,GACtB,qBAAqB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,uBAAuB,GACvB,uBAAuB,CAAC;AAE5B;;;GAGG;AACH,oBAAY,uBAAuB;IACjC,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,UAAU,eAAe;IACzB,SAAS,cAAc;IACvB,cAAc,mBAAmB;IACjC,YAAY,iBAAiB;CAC9B;AAED,iEAAiE;AACjE,MAAM,MAAM,cAAc,GAAG;IAC3B,iEAAiE;IACjE,iBAAiB,EAAE,GAAG,CAAC,uBAAuB,CAAC,CAAC;CACjD,CAAC"}
|
|
@@ -1,2 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GltfPrimitiveModeString = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* glTF primitive modes (mesh topology types)
|
|
6
|
+
* @see https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#_mesh_primitive_mode
|
|
7
|
+
*/
|
|
8
|
+
var GltfPrimitiveModeString;
|
|
9
|
+
(function (GltfPrimitiveModeString) {
|
|
10
|
+
GltfPrimitiveModeString["POINTS"] = "POINTS";
|
|
11
|
+
GltfPrimitiveModeString["LINES"] = "LINES";
|
|
12
|
+
GltfPrimitiveModeString["LINE_LOOP"] = "LINE_LOOP";
|
|
13
|
+
GltfPrimitiveModeString["LINE_STRIP"] = "LINE_STRIP";
|
|
14
|
+
GltfPrimitiveModeString["TRIANGLES"] = "TRIANGLES";
|
|
15
|
+
GltfPrimitiveModeString["TRIANGLE_STRIP"] = "TRIANGLE_STRIP";
|
|
16
|
+
GltfPrimitiveModeString["TRIANGLE_FAN"] = "TRIANGLE_FAN";
|
|
17
|
+
})(GltfPrimitiveModeString = exports.GltfPrimitiveModeString || (exports.GltfPrimitiveModeString = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/i3s-server/app.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/i3s-server/app.js"],"names":[],"mappings":";AASA,uBAAsB"}
|
package/dist/i3s-server/app.js
CHANGED
|
@@ -4,11 +4,19 @@ const path = require('path');
|
|
|
4
4
|
const logger = require('morgan');
|
|
5
5
|
const cors = require('cors');
|
|
6
6
|
const indexRouter = require('./routes/index');
|
|
7
|
+
const { sceneServerRouter, router } = require('./routes/slpk-router');
|
|
8
|
+
const I3S_LAYER_PATH = process.env.I3sLayerPath || ''; // eslint-disable-line no-process-env, no-undef
|
|
7
9
|
const app = express();
|
|
8
10
|
app.use(logger('dev'));
|
|
9
11
|
app.use(express.json());
|
|
10
12
|
app.use(express.urlencoded({ extended: false }));
|
|
11
13
|
app.use(express.static(path.join(__dirname, 'public')));
|
|
12
14
|
app.use(cors());
|
|
13
|
-
|
|
15
|
+
if (/\.slpk$/.test(I3S_LAYER_PATH)) {
|
|
16
|
+
app.use('/SceneServer/layers/0', router);
|
|
17
|
+
app.use('/SceneServer', sceneServerRouter);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
app.use('/', indexRouter);
|
|
21
|
+
}
|
|
14
22
|
module.exports = app;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slpk-controller.d.ts","sourceRoot":"","sources":["../../../src/i3s-server/controllers/slpk-controller.js"],"names":[],"mappings":"AAOA,+DAEC;AAOD,oEAgBC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require('@loaders.gl/polyfills');
|
|
3
|
+
const { fetchFile, parse } = require('@loaders.gl/core');
|
|
4
|
+
const { SLPKLoader } = require('@loaders.gl/i3s');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
let slpkArchive;
|
|
7
|
+
const loadArchive = async (fullLayerPath) => {
|
|
8
|
+
slpkArchive = await (await fetchFile(fullLayerPath)).arrayBuffer();
|
|
9
|
+
};
|
|
10
|
+
const I3S_LAYER_PATH = process.env.I3sLayerPath || ''; // eslint-disable-line no-process-env, no-undef
|
|
11
|
+
const FULL_LAYER_PATH = path.join(process.cwd(), I3S_LAYER_PATH); // eslint-disable-line no-undef
|
|
12
|
+
loadArchive(FULL_LAYER_PATH);
|
|
13
|
+
async function getFileByUrl(url) {
|
|
14
|
+
const trimmedPath = /^\/?(.*)\/?$/.exec(url);
|
|
15
|
+
let uncompressedFile;
|
|
16
|
+
if (trimmedPath) {
|
|
17
|
+
try {
|
|
18
|
+
uncompressedFile = Buffer.from(await parse(slpkArchive, SLPKLoader, {
|
|
19
|
+
slpk: {
|
|
20
|
+
path: trimmedPath[1],
|
|
21
|
+
pathMode: 'http'
|
|
22
|
+
}
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
catch (e) { }
|
|
26
|
+
}
|
|
27
|
+
return uncompressedFile;
|
|
28
|
+
}
|
|
29
|
+
module.exports = {
|
|
30
|
+
loadArchive,
|
|
31
|
+
getFileByUrl
|
|
32
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slpk-router.d.ts","sourceRoot":"","sources":["../../../src/i3s-server/routes/slpk-router.js"],"names":[],"mappings":"AAIA,oCAA2C;AAa3C,yBAAgC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const express = require('express');
|
|
3
|
+
const { getFileByUrl } = require('../controllers/slpk-controller');
|
|
4
|
+
const createSceneServer = require('../utils/create-scene-server');
|
|
5
|
+
const sceneServerRouter = express.Router();
|
|
6
|
+
sceneServerRouter.get('*', async function (req, res, next) {
|
|
7
|
+
const file = await getFileByUrl('/');
|
|
8
|
+
if (file) {
|
|
9
|
+
const layer = JSON.parse(file.toString());
|
|
10
|
+
const sceneServerResponse = createSceneServer(layer.name, layer);
|
|
11
|
+
res.send(sceneServerResponse);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
res.status(404);
|
|
15
|
+
res.send('File not found');
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
const router = express.Router();
|
|
19
|
+
router.get('*', async function (req, res, next) {
|
|
20
|
+
console.log(req.path);
|
|
21
|
+
const file = await getFileByUrl(req.path);
|
|
22
|
+
if (file) {
|
|
23
|
+
res.send(file);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
res.status(404);
|
|
27
|
+
res.send('File not found');
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
module.exports = {
|
|
31
|
+
sceneServerRouter,
|
|
32
|
+
router
|
|
33
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export = createSceneServer;
|
|
2
|
+
declare function createSceneServer(name: any, layer: any): {
|
|
3
|
+
serviceItemId: any;
|
|
4
|
+
serviceName: any;
|
|
5
|
+
name: any;
|
|
6
|
+
currentVersion: string;
|
|
7
|
+
serviceVersion: string;
|
|
8
|
+
supportedBindings: string[];
|
|
9
|
+
layers: any[];
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=create-scene-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-scene-server.d.ts","sourceRoot":"","sources":["../../../src/i3s-server/utils/create-scene-server.js"],"names":[],"mappings":";AAEA;;;;;;;;EAUC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { v4: uuidv4 } = require('uuid');
|
|
3
|
+
const createSceneServer = (name, layer) => {
|
|
4
|
+
return {
|
|
5
|
+
serviceItemId: uuidv4().replace(/-/gi, ''),
|
|
6
|
+
serviceName: name,
|
|
7
|
+
name,
|
|
8
|
+
currentVersion: '10.7',
|
|
9
|
+
serviceVersion: '1.8',
|
|
10
|
+
supportedBindings: ['REST'],
|
|
11
|
+
layers: [layer]
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
module.exports = createSceneServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/file-utils.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,EAC9D,QAAQ,GAAE,MAAqB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAkBjB;AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,EAC9D,QAAQ,GAAE,MAAqB,EAC/B,QAAQ,GAAE,OAAc,EACxB,YAAY,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,GAC7B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkBxB;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,C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AGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UAEnD"}
|
|
@@ -116,7 +116,8 @@ exports.isFileExists = isFileExists;
|
|
|
116
116
|
* @param path
|
|
117
117
|
*/
|
|
118
118
|
function removeDir(path) {
|
|
119
|
-
|
|
119
|
+
// (node:35607) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
|
|
120
|
+
return fs_1.promises.rm(path, { recursive: true });
|
|
120
121
|
}
|
|
121
122
|
exports.removeDir = removeDir;
|
|
122
123
|
/**
|