@loaders.gl/tile-converter 4.0.0-alpha.7 → 4.0.0-alpha.9
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.js +2 -2
- package/dist/3d-tiles-attributes-worker.js.map +2 -2
- package/dist/converter.min.js +67 -67
- package/dist/deps-installer/deps-installer.d.ts.map +1 -1
- package/dist/deps-installer/deps-installer.js +3 -2
- package/dist/dist.min.js +698 -340
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +4 -3
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-attributes-worker.js +1 -1
- package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +2 -2
- 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 +25 -14
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/gltf-attributes.js +45 -12
- 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 -516
- 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/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.map +1 -1
- package/dist/esm/deps-installer/deps-installer.js +4 -3
- package/dist/esm/deps-installer/deps-installer.js.map +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/i3s-converter/helpers/batch-ids-extensions.js +2 -2
- 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 +19 -8
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/gltf-attributes.js +49 -12
- 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 -120
- 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/lod-conversion-utils.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/i3s-attributes-worker.js +2 -2
- package/dist/i3s-attributes-worker.js.map +2 -2
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +2 -5
- 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 +34 -12
- 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 +61 -18
- 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 -126
- 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/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 -15
- package/src/3d-tiles-converter/3d-tiles-converter.ts +5 -5
- package/src/deps-installer/deps-installer.ts +3 -2
- package/src/i3s-converter/helpers/batch-ids-extensions.ts +2 -5
- package/src/i3s-converter/helpers/coordinate-converter.ts +11 -10
- package/src/i3s-converter/helpers/geometry-converter.ts +51 -19
- package/src/i3s-converter/helpers/gltf-attributes.ts +84 -21
- 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 +228 -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/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,45 +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
|
-
// TODO - should no longer be needed with new Node workers
|
|
159
|
-
// 'basis-nodejs': {
|
|
160
|
-
// format: 'rgba32',
|
|
161
|
-
// workerUrl: './modules/textures/dist/basis-worker-node.js'
|
|
162
|
-
// },
|
|
163
|
-
// 'draco-nodejs': {workerUrl: './modules/draco/dist/draco-worker-node.js'}
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
173
|
if (preloadOptions.headers) {
|
|
167
|
-
|
|
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 });
|
|
168
181
|
}
|
|
169
|
-
Object.assign(tilesetOptions, preloadOptions);
|
|
170
|
-
const sourceTilesetJson = await (0, core_1.load)(inputUrl, this.Loader, tilesetOptions.loadOptions);
|
|
171
|
-
// console.log(tilesetJson); // eslint-disable-line
|
|
172
|
-
this.sourceTileset = new tiles_1.Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
173
|
-
await this._createAndSaveTileset(outputPath, tilesetName, sourceTilesetJson?.root?.boundingVolume?.region);
|
|
174
|
-
await this._finishConversion({ slpk: Boolean(slpk), outputPath, tilesetName });
|
|
175
|
-
return sourceTilesetJson;
|
|
176
182
|
}
|
|
177
183
|
catch (error) {
|
|
178
184
|
throw error;
|
|
179
185
|
}
|
|
180
186
|
finally {
|
|
187
|
+
await this.writeQueue.finalize();
|
|
181
188
|
// Clean up worker pools
|
|
182
189
|
const workerFarm = worker_utils_1.WorkerFarm.getWorkerFarm({});
|
|
183
190
|
workerFarm.destroy();
|
|
184
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;
|
|
185
237
|
}
|
|
186
238
|
/**
|
|
187
239
|
* Convert and save the layer and embedded tiles
|
|
188
240
|
* @param outputPath - path to save output data
|
|
189
241
|
* @param tilesetName - new tileset path
|
|
190
242
|
*/
|
|
191
|
-
async _createAndSaveTileset(outputPath, tilesetName
|
|
243
|
+
async _createAndSaveTileset(outputPath, tilesetName) {
|
|
192
244
|
const tilesetPath = (0, path_1.join)(`${outputPath}`, `${tilesetName}`);
|
|
193
245
|
// Removing the tilesetPath needed to exclude erroneous files after conversion
|
|
194
246
|
try {
|
|
@@ -198,11 +250,12 @@ class I3SConverter {
|
|
|
198
250
|
// do nothing
|
|
199
251
|
}
|
|
200
252
|
this.layers0Path = (0, path_1.join)(tilesetPath, 'SceneServer', 'layers', '0');
|
|
201
|
-
this._formLayers0(tilesetName, boundingVolumeRegion);
|
|
202
253
|
this.materialDefinitions = [];
|
|
203
254
|
this.materialMap = new Map();
|
|
204
255
|
const sourceRootTile = this.sourceTileset.root;
|
|
205
|
-
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);
|
|
206
259
|
await this.nodePages.push({
|
|
207
260
|
index: 0,
|
|
208
261
|
lodThreshold: 0,
|
|
@@ -210,7 +263,10 @@ class I3SConverter {
|
|
|
210
263
|
children: []
|
|
211
264
|
});
|
|
212
265
|
const rootNode = await node_index_document_1.NodeIndexDocument.createRootNode(boundingVolumes, this);
|
|
213
|
-
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);
|
|
214
270
|
this.layers0.materialDefinitions = this.materialDefinitions;
|
|
215
271
|
// @ts-ignore
|
|
216
272
|
this.layers0.geometryDefinitions = (0, json_map_transform_1.default)(this.geometryConfigs.map((config) => ({
|
|
@@ -232,10 +288,15 @@ class I3SConverter {
|
|
|
232
288
|
}
|
|
233
289
|
/**
|
|
234
290
|
* Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md
|
|
235
|
-
* @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
|
|
236
294
|
*/
|
|
237
|
-
_formLayers0(tilesetName, boundingVolumeRegion) {
|
|
238
|
-
|
|
295
|
+
_formLayers0(tilesetName, sourceBoundingVolume, boundingVolumeRegion) {
|
|
296
|
+
if (!this.sourceTileset?.root) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const fullExtent = (0, coordinate_converter_1.convertBoundingVolumeToI3SFullExtent)(sourceBoundingVolume);
|
|
239
300
|
if (boundingVolumeRegion) {
|
|
240
301
|
fullExtent.zmin = boundingVolumeRegion[4];
|
|
241
302
|
fullExtent.zmax = boundingVolumeRegion[5];
|
|
@@ -258,30 +319,6 @@ class I3SConverter {
|
|
|
258
319
|
};
|
|
259
320
|
this.layers0 = (0, json_map_transform_1.default)(layers0data, (0, layers_1.LAYERS)());
|
|
260
321
|
}
|
|
261
|
-
/**
|
|
262
|
-
* Form object of 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md
|
|
263
|
-
* @param rootNode - 3DNodeIndexDocument of root node https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DNodeIndexDocument.cmn.md
|
|
264
|
-
* @param sourceRootTile - Source (3DTile) tile data
|
|
265
|
-
*/
|
|
266
|
-
async _convertNodesTree(rootNode, sourceRootTile) {
|
|
267
|
-
await this.sourceTileset._loadTile(sourceRootTile);
|
|
268
|
-
if (this.isContentSupported(sourceRootTile)) {
|
|
269
|
-
const childNodes = await this._createNode(rootNode, sourceRootTile, 0);
|
|
270
|
-
for (const childNode of childNodes) {
|
|
271
|
-
await childNode.save();
|
|
272
|
-
}
|
|
273
|
-
await rootNode.addChildren(childNodes);
|
|
274
|
-
}
|
|
275
|
-
else {
|
|
276
|
-
await this._addChildrenWithNeighborsAndWriteFile({
|
|
277
|
-
parentNode: rootNode,
|
|
278
|
-
sourceTiles: sourceRootTile.children,
|
|
279
|
-
level: 1
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
await sourceRootTile.unloadContent();
|
|
283
|
-
await rootNode.save();
|
|
284
|
-
}
|
|
285
322
|
/**
|
|
286
323
|
* Write 3DSceneLayer https://github.com/Esri/i3s-spec/blob/master/docs/1.7/3DSceneLayer.cmn.md in file
|
|
287
324
|
*/
|
|
@@ -334,83 +371,73 @@ class I3SConverter {
|
|
|
334
371
|
}
|
|
335
372
|
}
|
|
336
373
|
/**
|
|
337
|
-
*
|
|
338
|
-
*
|
|
339
|
-
* @param
|
|
340
|
-
* @param
|
|
341
|
-
* @
|
|
342
|
-
*/
|
|
343
|
-
async _addChildrenWithNeighborsAndWriteFile(data) {
|
|
344
|
-
await this._addChildren(data);
|
|
345
|
-
await data.parentNode.addNeighbors();
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Convert nested subtree of 3DTiles dataset
|
|
349
|
-
* @param param0
|
|
350
|
-
* @param data.parentNode - 3DNodeIndexDocument of parent node
|
|
351
|
-
* @param param0.sourceTile - source 3DTile data
|
|
352
|
-
* @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
|
|
353
379
|
*/
|
|
354
|
-
async
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
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);
|
|
372
400
|
await parentNode.addChildren(childNodes);
|
|
401
|
+
const newTraversalProps = {
|
|
402
|
+
transform: transformationMatrix,
|
|
403
|
+
parentNodes: childNodes
|
|
404
|
+
};
|
|
405
|
+
return newTraversalProps;
|
|
373
406
|
}
|
|
374
407
|
/**
|
|
375
|
-
*
|
|
376
|
-
* @param
|
|
377
|
-
* @param
|
|
378
|
-
* @param param0.sourceTile - source 3DTile data
|
|
379
|
-
* @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
|
|
380
411
|
*/
|
|
381
|
-
async
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
for (const sourceTile of sourceTiles) {
|
|
387
|
-
if (sourceTile.type === 'json') {
|
|
388
|
-
await this.convertNestedTileset({ parentNode, sourceTile, level });
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
await this.convertNode({ parentNode, sourceTile, level });
|
|
392
|
-
}
|
|
393
|
-
if (sourceTile.id) {
|
|
394
|
-
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();
|
|
395
416
|
}
|
|
396
417
|
}
|
|
418
|
+
for (const node of currentTraversalProps.parentNodes) {
|
|
419
|
+
await node.save();
|
|
420
|
+
}
|
|
397
421
|
}
|
|
398
422
|
/**
|
|
399
423
|
* Convert tile to one or more I3S nodes
|
|
400
424
|
* @param parentNode - 3DNodeIndexDocument of parent node
|
|
401
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
|
|
402
428
|
* @param level - tree level
|
|
403
429
|
*/
|
|
404
|
-
async _createNode(parentNode, sourceTile,
|
|
430
|
+
async _createNode(parentNode, sourceTile, transformationMatrix) {
|
|
405
431
|
this._checkAddRefinementTypeForTile(sourceTile);
|
|
406
432
|
await this._updateTilesetOptions();
|
|
407
|
-
await this.sourceTileset.
|
|
408
|
-
|
|
409
|
-
|
|
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);
|
|
410
437
|
if (propertyTable && !this.layers0?.attributeStorageInfo?.length) {
|
|
411
438
|
this._convertPropertyTableToNodeAttributes(propertyTable);
|
|
412
439
|
}
|
|
413
|
-
const resourcesData = await this._convertResources(sourceTile, parentNode.inPageId, propertyTable);
|
|
440
|
+
const resourcesData = await this._convertResources(sourceTile, transformationMatrix, sourceBoundingVolume, tileContent, parentNode.inPageId, propertyTable);
|
|
414
441
|
const nodes = [];
|
|
415
442
|
const nodeIds = [];
|
|
416
443
|
const nodesInPage = [];
|
|
@@ -449,23 +476,21 @@ class I3SConverter {
|
|
|
449
476
|
nodeIds.push(nodeInPage.index);
|
|
450
477
|
nodesInPage.push(nodeInPage);
|
|
451
478
|
}
|
|
452
|
-
sourceTile.unloadContent();
|
|
453
|
-
await this._addChildrenWithNeighborsAndWriteFile({
|
|
454
|
-
parentNode: nodes[0],
|
|
455
|
-
sourceTiles: sourceTile.children,
|
|
456
|
-
level: level + 1
|
|
457
|
-
});
|
|
458
479
|
return nodes;
|
|
459
480
|
}
|
|
460
481
|
/**
|
|
461
482
|
* Convert tile to one or more I3S nodes
|
|
462
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
|
|
463
488
|
* @param parentId - id of parent node in node pages
|
|
464
489
|
* @param propertyTable - batch table from b3dm / feature properties from EXT_FEATURE_METADATA
|
|
465
490
|
* @returns - converted node resources
|
|
466
491
|
*/
|
|
467
|
-
async _convertResources(sourceTile, parentId, propertyTable) {
|
|
468
|
-
if (!this.isContentSupported(sourceTile)) {
|
|
492
|
+
async _convertResources(sourceTile, transformationMatrix, boundingVolume, tileContent, parentId, propertyTable) {
|
|
493
|
+
if (!this.isContentSupported(sourceTile) || !tileContent) {
|
|
469
494
|
return null;
|
|
470
495
|
}
|
|
471
496
|
const draftObb = {
|
|
@@ -473,7 +498,7 @@ class I3SConverter {
|
|
|
473
498
|
halfSize: [],
|
|
474
499
|
quaternion: []
|
|
475
500
|
};
|
|
476
|
-
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);
|
|
477
502
|
return resourcesData;
|
|
478
503
|
}
|
|
479
504
|
/**
|
|
@@ -835,10 +860,9 @@ class I3SConverter {
|
|
|
835
860
|
}
|
|
836
861
|
this.refreshTokenTime = process_1.default.hrtime();
|
|
837
862
|
const preloadOptions = await this._fetchPreloadOptions();
|
|
838
|
-
this.sourceTileset.options = { ...this.sourceTileset.options, ...preloadOptions };
|
|
839
863
|
if (preloadOptions.headers) {
|
|
840
|
-
this.
|
|
841
|
-
...this.
|
|
864
|
+
this.loadOptions.fetch = {
|
|
865
|
+
...this.loadOptions.fetch,
|
|
842
866
|
headers: preloadOptions.headers
|
|
843
867
|
};
|
|
844
868
|
console.log('Authorization Bearer token has been updated'); // eslint-disable-line no-undef, no-console
|
|
@@ -857,11 +881,11 @@ class I3SConverter {
|
|
|
857
881
|
}
|
|
858
882
|
/**
|
|
859
883
|
* Check if the tile's content format is supported by the converter
|
|
860
|
-
* @param
|
|
884
|
+
* @param sourceTile
|
|
861
885
|
* @returns
|
|
862
886
|
*/
|
|
863
|
-
isContentSupported(
|
|
864
|
-
return ['b3dm', 'glTF'].includes(
|
|
887
|
+
isContentSupported(sourceTile) {
|
|
888
|
+
return ['b3dm', 'glTF', 'scenegraph'].includes(sourceTile.type || '');
|
|
865
889
|
}
|
|
866
890
|
async loadWorkers() {
|
|
867
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,MAA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ports, "__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,GA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AAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOrE;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,iBAGrC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,iBAEtC;AAED;;;GAGG;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
|
/**
|