@loaders.gl/tile-converter 3.4.11 → 3.4.12
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 +1 -1
- package/dist/converter.min.js +58 -58
- package/dist/dist.min.js +11 -26
- package/dist/es5/3d-tiles-attributes-worker.js +1 -1
- package/dist/es5/deps-installer/deps-installer.js +1 -1
- package/dist/es5/i3s-attributes-worker.js +1 -1
- package/dist/es5/pgm-loader.js +1 -1
- package/dist/esm/3d-tiles-attributes-worker.js +1 -1
- package/dist/esm/deps-installer/deps-installer.js +1 -1
- package/dist/esm/i3s-attributes-worker.js +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/package.json +15 -15
- package/dist/3d-tiles-converter/3d-tiles-converter.js +0 -287
- package/dist/3d-tiles-converter/helpers/b3dm-converter.js +0 -282
- package/dist/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +0 -23
- package/dist/3d-tiles-converter/helpers/texture-atlas.js +0 -52
- package/dist/3d-tiles-converter/json-templates/tileset.js +0 -43
- package/dist/bundle.js +0 -5
- package/dist/constants.js +0 -4
- package/dist/converter-cli.js +0 -280
- package/dist/deps-installer/deps-installer.js +0 -63
- package/dist/i3s-converter/helpers/batch-ids-extensions.js +0 -141
- package/dist/i3s-converter/helpers/coordinate-converter.js +0 -124
- package/dist/i3s-converter/helpers/create-scene-server-path.js +0 -28
- package/dist/i3s-converter/helpers/feature-attributes.js +0 -216
- package/dist/i3s-converter/helpers/geometry-attributes.js +0 -202
- package/dist/i3s-converter/helpers/geometry-converter.js +0 -1195
- package/dist/i3s-converter/helpers/gltf-attributes.js +0 -88
- package/dist/i3s-converter/helpers/node-debug.js +0 -120
- package/dist/i3s-converter/helpers/node-index-document.js +0 -250
- package/dist/i3s-converter/helpers/node-pages.js +0 -316
- package/dist/i3s-converter/i3s-converter.js +0 -890
- package/dist/i3s-converter/json-templates/geometry-definitions.js +0 -87
- package/dist/i3s-converter/json-templates/layers.js +0 -139
- package/dist/i3s-converter/json-templates/metadata.js +0 -25
- package/dist/i3s-converter/json-templates/node.js +0 -89
- package/dist/i3s-converter/json-templates/scene-server.js +0 -31
- package/dist/i3s-converter/json-templates/shared-resources.js +0 -129
- package/dist/i3s-converter/json-templates/store.js +0 -103
- package/dist/i3s-converter/types.js +0 -2
- package/dist/i3s-server/app.js +0 -14
- package/dist/i3s-server/controllers/index-controller.js +0 -23
- package/dist/i3s-server/routes/index.js +0 -16
- package/dist/index.js +0 -10
- package/dist/lib/utils/compress-util.js +0 -257
- package/dist/lib/utils/file-utils.js +0 -138
- package/dist/lib/utils/lod-conversion-utils.js +0 -76
- package/dist/lib/utils/queue.js +0 -18
- package/dist/lib/utils/statistic-utills.js +0 -64
- package/dist/lib/utils/write-queue.js +0 -80
- package/dist/pgm-loader.js +0 -24
- package/dist/workers/3d-tiles-attributes-worker.js +0 -9
- package/dist/workers/i3s-attributes-worker.js +0 -5
package/dist/dist.min.js
CHANGED
|
@@ -48032,33 +48032,18 @@ __export(fs_exports, {
|
|
|
48032
48032
|
writeFileSync: () => writeFileSync
|
|
48033
48033
|
});
|
|
48034
48034
|
var import_fs = __toModule(require("fs"));
|
|
48035
|
-
var readdir;
|
|
48036
|
-
var stat;
|
|
48037
|
-
var readFile;
|
|
48038
|
-
var readFileSync;
|
|
48039
|
-
var writeFile;
|
|
48040
|
-
var writeFileSync;
|
|
48041
|
-
var open;
|
|
48042
|
-
var close;
|
|
48043
|
-
var read;
|
|
48044
|
-
var fstat;
|
|
48045
|
-
var createWriteStream;
|
|
48035
|
+
var readdir = promisify2(import_fs.default.readdir);
|
|
48036
|
+
var stat = promisify2(import_fs.default.stat);
|
|
48037
|
+
var readFile = import_fs.default.readFile;
|
|
48038
|
+
var readFileSync = import_fs.default.readFileSync;
|
|
48039
|
+
var writeFile = promisify3(import_fs.default.writeFile);
|
|
48040
|
+
var writeFileSync = import_fs.default.writeFileSync;
|
|
48041
|
+
var open = import_fs.default.open;
|
|
48042
|
+
var close = (fd) => new Promise((resolve2, reject) => import_fs.default.close(fd, (err) => err ? reject(err) : resolve2()));
|
|
48043
|
+
var read = import_fs.default.read;
|
|
48044
|
+
var fstat = import_fs.default.fstat;
|
|
48045
|
+
var createWriteStream = import_fs.default.createWriteStream;
|
|
48046
48046
|
var isSupported = Boolean(import_fs.default);
|
|
48047
|
-
try {
|
|
48048
|
-
readdir = promisify2(import_fs.default.readdir);
|
|
48049
|
-
stat = promisify2(import_fs.default.stat);
|
|
48050
|
-
readFile = import_fs.default.readFile;
|
|
48051
|
-
readFileSync = import_fs.default.readFileSync;
|
|
48052
|
-
writeFile = promisify3(import_fs.default.writeFile);
|
|
48053
|
-
writeFileSync = import_fs.default.writeFileSync;
|
|
48054
|
-
open = import_fs.default.open;
|
|
48055
|
-
close = (fd) => new Promise((resolve2, reject) => import_fs.default.close(fd, (err) => err ? reject(err) : resolve2()));
|
|
48056
|
-
read = import_fs.default.read;
|
|
48057
|
-
fstat = import_fs.default.fstat;
|
|
48058
|
-
createWriteStream = import_fs.default.createWriteStream;
|
|
48059
|
-
isSupported = Boolean(import_fs.default);
|
|
48060
|
-
} catch {
|
|
48061
|
-
}
|
|
48062
48047
|
async function _readToArrayBuffer(fd, start, length) {
|
|
48063
48048
|
const buffer = Buffer.alloc(length);
|
|
48064
48049
|
const { bytesRead } = await read(fd, buffer, 0, length, start);
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports._typecheckI3SAttributesWorker = exports.Tile3dAttributesWorker = void 0;
|
|
7
7
|
exports.transform3DTilesAttributesOnWorker = transform3DTilesAttributesOnWorker;
|
|
8
8
|
var _workerUtils = require("@loaders.gl/worker-utils");
|
|
9
|
-
var VERSION = typeof "3.4.
|
|
9
|
+
var VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
|
|
10
10
|
var Tile3dAttributesWorker = {
|
|
11
11
|
id: '3d-tiles-attributes',
|
|
12
12
|
name: '3DTiles Attributes Worker',
|
|
@@ -14,7 +14,7 @@ var _zip = require("@loaders.gl/zip");
|
|
|
14
14
|
var _fileUtils = require("../lib/utils/file-utils");
|
|
15
15
|
var _path = require("path");
|
|
16
16
|
var _workerUtils = require("@loaders.gl/worker-utils");
|
|
17
|
-
var VERSION = typeof "3.4.
|
|
17
|
+
var VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
|
|
18
18
|
var PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
|
|
19
19
|
var DepsInstaller = function () {
|
|
20
20
|
function DepsInstaller() {
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports._typecheckI3SAttributesWorker = exports.I3SAttributesWorker = void 0;
|
|
7
7
|
exports.transformI3SAttributesOnWorker = transformI3SAttributesOnWorker;
|
|
8
8
|
var _workerUtils = require("@loaders.gl/worker-utils");
|
|
9
|
-
var VERSION = typeof "3.4.
|
|
9
|
+
var VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
|
|
10
10
|
var I3SAttributesWorker = {
|
|
11
11
|
id: 'i3s-attributes',
|
|
12
12
|
name: 'I3S Attributes Worker',
|
package/dist/es5/pgm-loader.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.PGMLoader = void 0;
|
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _geoid = require("@math.gl/geoid");
|
|
11
|
-
var VERSION = typeof "3.4.
|
|
11
|
+
var VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
|
|
12
12
|
var PGMLoader = {
|
|
13
13
|
name: 'PGM - Netpbm grayscale image format',
|
|
14
14
|
id: 'pgm',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { processOnWorker } from '@loaders.gl/worker-utils';
|
|
2
|
-
const VERSION = typeof "3.4.
|
|
2
|
+
const VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
|
|
3
3
|
export const Tile3dAttributesWorker = {
|
|
4
4
|
id: '3d-tiles-attributes',
|
|
5
5
|
name: '3DTiles Attributes Worker',
|
|
@@ -3,7 +3,7 @@ import { ZipLoader } from '@loaders.gl/zip';
|
|
|
3
3
|
import { writeFile } from '../lib/utils/file-utils';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
import { ChildProcessProxy } from '@loaders.gl/worker-utils';
|
|
6
|
-
const VERSION = typeof "3.4.
|
|
6
|
+
const VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
|
|
7
7
|
const PGM_LINK = 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip';
|
|
8
8
|
export class DepsInstaller {
|
|
9
9
|
async install() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { processOnWorker } from '@loaders.gl/worker-utils';
|
|
2
|
-
const VERSION = typeof "3.4.
|
|
2
|
+
const VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
|
|
3
3
|
export const I3SAttributesWorker = {
|
|
4
4
|
id: 'i3s-attributes',
|
|
5
5
|
name: 'I3S Attributes Worker',
|
package/dist/esm/pgm-loader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parsePGM } from '@math.gl/geoid';
|
|
2
|
-
const VERSION = typeof "3.4.
|
|
2
|
+
const VERSION = typeof "3.4.12" !== 'undefined' ? "3.4.12" : 'latest';
|
|
3
3
|
export const PGMLoader = {
|
|
4
4
|
name: 'PGM - Netpbm grayscale image format',
|
|
5
5
|
id: 'pgm',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/tile-converter",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.12",
|
|
4
4
|
"description": "Converter",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -44,19 +44,19 @@
|
|
|
44
44
|
"build-3d-tiles-attributes-worker": "esbuild src/workers/3d-tiles-attributes-worker.ts --outfile=dist/3d-tiles-attributes-worker.js --platform=node --target=esnext,node14 --external:join-images --minify --bundle --sourcemap --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@loaders.gl/3d-tiles": "3.4.
|
|
48
|
-
"@loaders.gl/crypto": "3.4.
|
|
49
|
-
"@loaders.gl/draco": "3.4.
|
|
50
|
-
"@loaders.gl/gltf": "3.4.
|
|
51
|
-
"@loaders.gl/i3s": "3.4.
|
|
52
|
-
"@loaders.gl/images": "3.4.
|
|
53
|
-
"@loaders.gl/loader-utils": "3.4.
|
|
54
|
-
"@loaders.gl/polyfills": "3.4.
|
|
55
|
-
"@loaders.gl/schema": "3.4.
|
|
56
|
-
"@loaders.gl/textures": "3.4.
|
|
57
|
-
"@loaders.gl/tiles": "3.4.
|
|
58
|
-
"@loaders.gl/worker-utils": "3.4.
|
|
59
|
-
"@loaders.gl/zip": "3.4.
|
|
47
|
+
"@loaders.gl/3d-tiles": "3.4.12",
|
|
48
|
+
"@loaders.gl/crypto": "3.4.12",
|
|
49
|
+
"@loaders.gl/draco": "3.4.12",
|
|
50
|
+
"@loaders.gl/gltf": "3.4.12",
|
|
51
|
+
"@loaders.gl/i3s": "3.4.12",
|
|
52
|
+
"@loaders.gl/images": "3.4.12",
|
|
53
|
+
"@loaders.gl/loader-utils": "3.4.12",
|
|
54
|
+
"@loaders.gl/polyfills": "3.4.12",
|
|
55
|
+
"@loaders.gl/schema": "3.4.12",
|
|
56
|
+
"@loaders.gl/textures": "3.4.12",
|
|
57
|
+
"@loaders.gl/tiles": "3.4.12",
|
|
58
|
+
"@loaders.gl/worker-utils": "3.4.12",
|
|
59
|
+
"@loaders.gl/zip": "3.4.12",
|
|
60
60
|
"@math.gl/core": "^3.5.1",
|
|
61
61
|
"@math.gl/culling": "^3.5.1",
|
|
62
62
|
"@math.gl/geoid": "^3.5.1",
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"join-images": "^1.1.3",
|
|
80
80
|
"sharp": "^0.31.3"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "85254762ae3082f608a863291deef09f2b40c6cf"
|
|
83
83
|
}
|
|
@@ -1,287 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
const process_1 = __importDefault(require("process"));
|
|
8
|
-
const json_map_transform_1 = __importDefault(require("json-map-transform"));
|
|
9
|
-
const core_1 = require("@loaders.gl/core");
|
|
10
|
-
const i3s_1 = require("@loaders.gl/i3s");
|
|
11
|
-
const tiles_1 = require("@loaders.gl/tiles");
|
|
12
|
-
const pgm_loader_1 = require("../pgm-loader");
|
|
13
|
-
const i3s_obb_to_3d_tiles_obb_1 = require("./helpers/i3s-obb-to-3d-tiles-obb");
|
|
14
|
-
const lod_conversion_utils_1 = require("../lib/utils/lod-conversion-utils");
|
|
15
|
-
const file_utils_1 = require("../lib/utils/file-utils");
|
|
16
|
-
const statistic_utills_1 = require("../lib/utils/statistic-utills");
|
|
17
|
-
const tileset_1 = require("./json-templates/tileset");
|
|
18
|
-
const coordinate_converter_1 = require("../i3s-converter/helpers/coordinate-converter");
|
|
19
|
-
const _3d_tiles_attributes_worker_1 = require("../3d-tiles-attributes-worker");
|
|
20
|
-
const worker_utils_1 = require("@loaders.gl/worker-utils");
|
|
21
|
-
const constants_1 = require("../constants");
|
|
22
|
-
const I3S = 'I3S';
|
|
23
|
-
/**
|
|
24
|
-
* Converter from i3s to 3d-tiles
|
|
25
|
-
*/
|
|
26
|
-
class Tiles3DConverter {
|
|
27
|
-
constructor() {
|
|
28
|
-
this.workerSource = {};
|
|
29
|
-
this.options = {};
|
|
30
|
-
this.tilesetPath = '';
|
|
31
|
-
this.vertexCounter = 0;
|
|
32
|
-
this.conversionStartTime = [0, 0];
|
|
33
|
-
this.geoidHeightModel = null;
|
|
34
|
-
this.sourceTileset = null;
|
|
35
|
-
this.attributeStorageInfo = null;
|
|
36
|
-
this.workerSource = {};
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Convert i3s format data to 3dTiles
|
|
40
|
-
* @param options
|
|
41
|
-
* @param options.inputUrl the url to read the tileset from
|
|
42
|
-
* @param options.outputPath the output filename
|
|
43
|
-
* @param options.tilesetName the output name of the tileset
|
|
44
|
-
* @param options.egmFilePath location of *.pgm file to convert heights from ellipsoidal to gravity-related format
|
|
45
|
-
* @param options.maxDepth The max tree depth of conversion
|
|
46
|
-
*/
|
|
47
|
-
async convert(options) {
|
|
48
|
-
if (core_1.isBrowser) {
|
|
49
|
-
console.log(constants_1.BROWSER_ERROR_MESSAGE);
|
|
50
|
-
return constants_1.BROWSER_ERROR_MESSAGE;
|
|
51
|
-
}
|
|
52
|
-
const { inputUrl, outputPath, tilesetName, maxDepth, egmFilePath } = options;
|
|
53
|
-
this.conversionStartTime = process_1.default.hrtime();
|
|
54
|
-
this.options = { maxDepth };
|
|
55
|
-
console.log('Loading egm file...'); // eslint-disable-line
|
|
56
|
-
this.geoidHeightModel = await (0, core_1.load)(egmFilePath, pgm_loader_1.PGMLoader);
|
|
57
|
-
console.log('Loading egm file completed!'); // eslint-disable-line
|
|
58
|
-
await this.loadWorkers();
|
|
59
|
-
const sourceTilesetJson = await (0, core_1.load)(inputUrl, i3s_1.I3SLoader, {});
|
|
60
|
-
this.sourceTileset = new tiles_1.Tileset3D(sourceTilesetJson, {
|
|
61
|
-
loadOptions: {
|
|
62
|
-
_nodeWorkers: true,
|
|
63
|
-
reuseWorkers: true,
|
|
64
|
-
'i3s-content-nodejs': {
|
|
65
|
-
workerUrl: './modules/i3s/dist/i3s-content-nodejs-worker.js'
|
|
66
|
-
},
|
|
67
|
-
i3s: { coordinateSystem: i3s_1.COORDINATE_SYSTEM.LNGLAT_OFFSETS, decodeTextures: false }
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
await this.sourceTileset.tilesetInitializationPromise;
|
|
71
|
-
const rootNode = this.sourceTileset.root;
|
|
72
|
-
if (!rootNode.header.obb) {
|
|
73
|
-
rootNode.header.obb = (0, coordinate_converter_1.createObbFromMbs)(rootNode.header.mbs);
|
|
74
|
-
}
|
|
75
|
-
this.tilesetPath = (0, path_1.join)(`${outputPath}`, `${tilesetName}`);
|
|
76
|
-
this.attributeStorageInfo = sourceTilesetJson.attributeStorageInfo;
|
|
77
|
-
// Removing the tilesetPath needed to exclude erroneous files after conversion
|
|
78
|
-
try {
|
|
79
|
-
await (0, file_utils_1.removeDir)(this.tilesetPath);
|
|
80
|
-
}
|
|
81
|
-
catch (e) {
|
|
82
|
-
// do nothing
|
|
83
|
-
}
|
|
84
|
-
const rootTile = {
|
|
85
|
-
boundingVolume: {
|
|
86
|
-
box: (0, i3s_obb_to_3d_tiles_obb_1.i3sObbTo3dTilesObb)(rootNode.header.obb, this.geoidHeightModel)
|
|
87
|
-
},
|
|
88
|
-
geometricError: (0, lod_conversion_utils_1.convertScreenThresholdToGeometricError)(rootNode),
|
|
89
|
-
children: []
|
|
90
|
-
};
|
|
91
|
-
await this._addChildren(rootNode, rootTile, 1);
|
|
92
|
-
const tileset = (0, json_map_transform_1.default)({ root: rootTile }, (0, tileset_1.TILESET)());
|
|
93
|
-
await (0, file_utils_1.writeFile)(this.tilesetPath, JSON.stringify(tileset), 'tileset.json');
|
|
94
|
-
this._finishConversion({ slpk: false, outputPath, tilesetName });
|
|
95
|
-
// Clean up worker pools
|
|
96
|
-
const workerFarm = worker_utils_1.WorkerFarm.getWorkerFarm({});
|
|
97
|
-
workerFarm.destroy();
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Convert particular I3S Node
|
|
101
|
-
* @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)
|
|
102
|
-
* @param parentNode object in resulting tileset
|
|
103
|
-
* @param level a current level of a tree depth
|
|
104
|
-
* @param childNodeInfo child node to convert
|
|
105
|
-
*/
|
|
106
|
-
async convertChildNode(parentSourceNode, parentNode, level, childNodeInfo) {
|
|
107
|
-
const sourceChild = await this._loadChildNode(parentSourceNode, childNodeInfo);
|
|
108
|
-
parentSourceNode.children.push(sourceChild);
|
|
109
|
-
if (sourceChild.contentUrl) {
|
|
110
|
-
await this.sourceTileset._loadTile(sourceChild);
|
|
111
|
-
this.vertexCounter += sourceChild.content.vertexCount;
|
|
112
|
-
let featureAttributes = null;
|
|
113
|
-
if (this.attributeStorageInfo) {
|
|
114
|
-
featureAttributes = await this._loadChildAttributes(sourceChild, this.attributeStorageInfo);
|
|
115
|
-
}
|
|
116
|
-
if (!sourceChild.header.obb) {
|
|
117
|
-
sourceChild.header.obb = (0, coordinate_converter_1.createObbFromMbs)(sourceChild.header.mbs);
|
|
118
|
-
}
|
|
119
|
-
const boundingVolume = {
|
|
120
|
-
box: (0, i3s_obb_to_3d_tiles_obb_1.i3sObbTo3dTilesObb)(sourceChild.header.obb, this.geoidHeightModel)
|
|
121
|
-
};
|
|
122
|
-
const child = {
|
|
123
|
-
boundingVolume,
|
|
124
|
-
geometricError: (0, lod_conversion_utils_1.convertScreenThresholdToGeometricError)(sourceChild),
|
|
125
|
-
children: []
|
|
126
|
-
};
|
|
127
|
-
const i3sAttributesData = {
|
|
128
|
-
tileContent: sourceChild.content,
|
|
129
|
-
textureFormat: sourceChild?.header?.textureFormat
|
|
130
|
-
};
|
|
131
|
-
const b3dm = await (0, _3d_tiles_attributes_worker_1.transform3DTilesAttributesOnWorker)(i3sAttributesData, {
|
|
132
|
-
source: this.workerSource.tile3dWorkerSource,
|
|
133
|
-
featureAttributes
|
|
134
|
-
});
|
|
135
|
-
child.content = {
|
|
136
|
-
uri: `${sourceChild.id}.b3dm`,
|
|
137
|
-
boundingVolume
|
|
138
|
-
};
|
|
139
|
-
await (0, file_utils_1.writeFile)(this.tilesetPath, new Uint8Array(b3dm), `${sourceChild.id}.b3dm`);
|
|
140
|
-
parentNode.children.push(child);
|
|
141
|
-
sourceChild.unloadContent();
|
|
142
|
-
await this._addChildren(sourceChild, child, level + 1);
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
await this._addChildren(sourceChild, parentNode, level + 1);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* The recursive function of traversal of a nodes tree
|
|
150
|
-
* @param parentSourceNode the parent node tile object (@loaders.gl/tiles/Tile3D)
|
|
151
|
-
* @param parentNode object in resulting tileset
|
|
152
|
-
* @param level a current level of a tree depth
|
|
153
|
-
*/
|
|
154
|
-
async _addChildren(parentSourceNode, parentNode, level) {
|
|
155
|
-
if (this.options.maxDepth && level > this.options.maxDepth) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
const promises = [];
|
|
159
|
-
for (const childNodeInfo of parentSourceNode.header.children || []) {
|
|
160
|
-
promises.push(this.convertChildNode(parentSourceNode, parentNode, level, childNodeInfo));
|
|
161
|
-
}
|
|
162
|
-
await Promise.all(promises);
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Load a child node having information from the node header
|
|
166
|
-
* @param parentNode a parent node tile object (@loaders.gl/tiles/Tile3D)
|
|
167
|
-
* @param childNodeInfo child information from 3DNodeIndexDocument
|
|
168
|
-
* (https://github.com/Esri/i3s-spec/blob/master/docs/1.7/nodeReference.cmn.md)
|
|
169
|
-
*/
|
|
170
|
-
async _loadChildNode(parentNode, childNodeInfo) {
|
|
171
|
-
let header;
|
|
172
|
-
if (this.sourceTileset.tileset.nodePages) {
|
|
173
|
-
console.log(`Node conversion: ${childNodeInfo.id}`); // eslint-disable-line no-console,no-undef
|
|
174
|
-
header = await this.sourceTileset.tileset.nodePagesTile.formTileFromNodePages(childNodeInfo.id);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
const { loader } = this.sourceTileset;
|
|
178
|
-
const nodeUrl = this._relativeUrlToFullUrl(parentNode.url, childNodeInfo.href);
|
|
179
|
-
// load metadata
|
|
180
|
-
const options = {
|
|
181
|
-
i3s: {
|
|
182
|
-
...this.sourceTileset.loadOptions,
|
|
183
|
-
isTileHeader: true,
|
|
184
|
-
loadContent: false
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
console.log(`Node conversion: ${nodeUrl}`); // eslint-disable-line no-console,no-undef
|
|
188
|
-
header = await (0, core_1.load)(nodeUrl, loader, options);
|
|
189
|
-
}
|
|
190
|
-
return new tiles_1.Tile3D(this.sourceTileset, header, parentNode);
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Make an url of a resource from its relative url having the base url
|
|
194
|
-
* @param baseUrl the base url. A resulting url will be related from this url
|
|
195
|
-
* @param relativeUrl a realtive url of a resource
|
|
196
|
-
*/
|
|
197
|
-
_relativeUrlToFullUrl(baseUrl, relativeUrl) {
|
|
198
|
-
let resultArray = baseUrl.split('/');
|
|
199
|
-
const relativeUrlArray = relativeUrl.split('/');
|
|
200
|
-
for (const folder of relativeUrlArray) {
|
|
201
|
-
switch (folder) {
|
|
202
|
-
case '.':
|
|
203
|
-
continue; // eslint-disable-line no-continue
|
|
204
|
-
case '..':
|
|
205
|
-
resultArray = resultArray.slice(0, -1);
|
|
206
|
-
break;
|
|
207
|
-
default:
|
|
208
|
-
resultArray.push(folder);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return resultArray.join('/');
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Do loading all attributes related to particular node.
|
|
215
|
-
* @param sourceChild
|
|
216
|
-
* @param attributeStorageInfo
|
|
217
|
-
* @returns Promise of attributes object.
|
|
218
|
-
*/
|
|
219
|
-
async _loadChildAttributes(sourceChild, attributeStorageInfo) {
|
|
220
|
-
const promises = [];
|
|
221
|
-
const { attributeUrls } = sourceChild.header;
|
|
222
|
-
for (let index = 0; index < attributeUrls.length; index++) {
|
|
223
|
-
const inputUrl = attributeUrls[index];
|
|
224
|
-
const attribute = attributeStorageInfo[index];
|
|
225
|
-
const options = {
|
|
226
|
-
attributeName: attribute.name,
|
|
227
|
-
attributeType: this._getAttributeType(attribute)
|
|
228
|
-
};
|
|
229
|
-
promises.push((0, core_1.load)(inputUrl, i3s_1.I3SAttributeLoader, options));
|
|
230
|
-
}
|
|
231
|
-
const attributesList = await Promise.all(promises);
|
|
232
|
-
this._replaceNestedArrays(attributesList);
|
|
233
|
-
return Object.assign({}, ...attributesList);
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Returns attribute type for loading attributes
|
|
237
|
-
* @param attribute
|
|
238
|
-
* Workaround for I3S v1.6. There is no attribute.attributeValues.valueType field in attribute.
|
|
239
|
-
* There is an 'Oid32' type if attribute has objectIds property.
|
|
240
|
-
* Doc: https://github.com/Esri/i3s-spec/blob/master/docs/1.6/attributeStorageInfo.cmn.md
|
|
241
|
-
*/
|
|
242
|
-
_getAttributeType(attribute) {
|
|
243
|
-
if (attribute.attributeValues) {
|
|
244
|
-
return attribute.attributeValues.valueType;
|
|
245
|
-
}
|
|
246
|
-
else if (attribute.objectIds) {
|
|
247
|
-
return 'Oid32';
|
|
248
|
-
}
|
|
249
|
-
return '';
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Make simple arrays from attribute typed arrays.
|
|
253
|
-
* @param attributesList
|
|
254
|
-
*/
|
|
255
|
-
_replaceNestedArrays(attributesList) {
|
|
256
|
-
for (let index = 0; index < attributesList.length; index++) {
|
|
257
|
-
const attributeObject = attributesList[index];
|
|
258
|
-
for (const key in attributeObject) {
|
|
259
|
-
attributeObject[key] = Array.from(attributeObject[key]);
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Print statistics in the end of conversion
|
|
265
|
-
* @param params - output files data
|
|
266
|
-
*/
|
|
267
|
-
async _finishConversion(params) {
|
|
268
|
-
const filesSize = await (0, statistic_utills_1.calculateFilesSize)(params);
|
|
269
|
-
const diff = process_1.default.hrtime(this.conversionStartTime);
|
|
270
|
-
const conversionTime = (0, statistic_utills_1.timeConverter)(diff);
|
|
271
|
-
console.log(`------------------------------------------------`); // eslint-disable-line
|
|
272
|
-
console.log(`Finish conversion of ${I3S}`); // eslint-disable-line
|
|
273
|
-
console.log(`Total conversion time: ${conversionTime}`); // eslint-disable-line
|
|
274
|
-
console.log(`Vertex count: `, this.vertexCounter); // eslint-disable-line
|
|
275
|
-
console.log(`File(s) size: `, filesSize, ' bytes'); // eslint-disable-line
|
|
276
|
-
console.log(`------------------------------------------------`); // eslint-disable-line
|
|
277
|
-
}
|
|
278
|
-
async loadWorkers() {
|
|
279
|
-
console.log(`Loading workers source...`); // eslint-disable-line no-undef, no-console
|
|
280
|
-
const tile3dAttributesWorkerUrl = (0, worker_utils_1.getWorkerURL)(_3d_tiles_attributes_worker_1.Tile3dAttributesWorker, { ...(0, core_1.getLoaderOptions)() });
|
|
281
|
-
const sourceResponse = await (0, core_1.fetchFile)(tile3dAttributesWorkerUrl);
|
|
282
|
-
const source = await sourceResponse.text();
|
|
283
|
-
this.workerSource.tile3dWorkerSource = source;
|
|
284
|
-
console.log(`Loading workers source completed!`); // eslint-disable-line no-undef, no-console
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
exports.default = Tiles3DConverter;
|