@loaders.gl/tile-converter 3.1.0-alpha.4 → 3.1.0-beta.5
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/bundle.js +86025 -0
- package/dist/converter.min.js +292 -0
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +189 -421
- package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +214 -296
- package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +4 -8
- package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +40 -0
- package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js +7 -17
- package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -1
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/deps-installer/deps-installer.js +17 -65
- package/dist/es5/deps-installer/deps-installer.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js +16 -16
- package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +9 -33
- package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js +93 -103
- package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/geometry-converter.js +348 -511
- package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-debug.js +30 -26
- package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/es5/i3s-converter/helpers/node-pages.js +102 -203
- package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/es5/i3s-converter/i3s-converter.js +701 -1501
- package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/layers.js +15 -25
- package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/metadata.js +2 -2
- package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/node.js +12 -21
- package/dist/es5/i3s-converter/json-templates/node.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/scene-server.js +3 -5
- package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/shared-resources.js +15 -55
- package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/es5/i3s-converter/json-templates/store.js +4 -6
- package/dist/es5/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/es5/i3s-server/app.js +6 -6
- package/dist/es5/i3s-server/app.js.map +1 -1
- package/dist/es5/i3s-server/controllers/index-controller.js +20 -60
- package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/es5/i3s-server/routes/index.js +14 -41
- package/dist/es5/i3s-server/routes/index.js.map +1 -1
- package/dist/es5/index.js +4 -4
- package/dist/es5/lib/geoid-height-model.js +100 -114
- package/dist/es5/lib/geoid-height-model.js.map +1 -1
- package/dist/es5/lib/pgm-parser.js +68 -122
- package/dist/es5/lib/pgm-parser.js.map +1 -1
- package/dist/es5/lib/utils/compress-util.js +123 -345
- package/dist/es5/lib/utils/compress-util.js.map +1 -1
- package/dist/es5/lib/utils/file-utils.js +20 -98
- package/dist/es5/lib/utils/file-utils.js.map +1 -1
- package/dist/es5/lib/utils/lod-conversion-utils.js +9 -9
- package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
- package/dist/es5/lib/utils/statistic-utills.js +41 -152
- package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
- package/dist/es5/pgm-loader.js +3 -5
- package/dist/es5/pgm-loader.js.map +1 -1
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +19 -13
- package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +19 -8
- package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js +33 -0
- package/dist/esm/3d-tiles-converter/helpers/texture-atlas.js.map +1 -0
- package/dist/esm/i3s-converter/helpers/geometry-converter.js +29 -31
- package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-debug.js +2 -2
- package/dist/esm/i3s-converter/helpers/node-debug.js.map +1 -1
- package/dist/esm/i3s-converter/helpers/node-pages.js +2 -2
- package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
- package/dist/esm/i3s-converter/i3s-converter.js +50 -31
- package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/metadata.js +1 -1
- package/dist/esm/i3s-converter/json-templates/metadata.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/scene-server.js +1 -1
- package/dist/esm/i3s-converter/json-templates/scene-server.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/shared-resources.js +2 -2
- package/dist/esm/i3s-converter/json-templates/shared-resources.js.map +1 -1
- package/dist/esm/i3s-converter/json-templates/store.js +2 -2
- package/dist/esm/i3s-converter/json-templates/store.js.map +1 -1
- package/dist/esm/i3s-server/controllers/index-controller.js +2 -2
- package/dist/esm/i3s-server/controllers/index-controller.js.map +1 -1
- package/dist/esm/lib/utils/compress-util.js +13 -13
- package/dist/esm/lib/utils/compress-util.js.map +1 -1
- 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/statistic-utills.js +5 -5
- package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
- package/dist/esm/pgm-loader.js +1 -1
- package/dist/esm/pgm-loader.js.map +1 -1
- package/package.json +22 -19
- package/src/3d-tiles-converter/3d-tiles-converter.ts +4 -2
- package/src/3d-tiles-converter/helpers/b3dm-converter.js +35 -7
- package/src/3d-tiles-converter/helpers/texture-atlas.ts +55 -0
- package/src/i3s-converter/helpers/geometry-converter.js +21 -22
- package/src/i3s-converter/i3s-converter.ts +32 -7
- package/src/i3s-converter/json-templates/metadata.js +1 -1
- package/src/i3s-converter/json-templates/scene-server.js +1 -1
- package/src/i3s-converter/json-templates/store.js +2 -2
- package/src/i3s-server/controllers/index-controller.js +1 -1
- package/dist/dist.min.js +0 -94
- package/dist/dist.min.js.map +0 -1
- package/dist/scripts/converter.js +0 -274
|
@@ -7,20 +7,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
|
-
|
|
16
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
17
|
-
|
|
18
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
19
|
-
|
|
20
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
21
|
-
|
|
22
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
23
|
-
|
|
24
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
11
|
|
|
26
12
|
var _core = require("@loaders.gl/core");
|
|
@@ -65,29 +51,21 @@ var _sharedResources = require("./json-templates/shared-resources");
|
|
|
65
51
|
|
|
66
52
|
var _nodeDebug = require("./helpers/node-debug");
|
|
67
53
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var SHORT_INT_TYPE = 'Int32';
|
|
84
|
-
var DOUBLE_TYPE = 'double';
|
|
85
|
-
var OBJECT_ID_TYPE = 'OBJECTID';
|
|
86
|
-
var REFRESH_TOKEN_TIMEOUT = 1800;
|
|
87
|
-
|
|
88
|
-
var I3SConverter = function () {
|
|
89
|
-
function I3SConverter() {
|
|
90
|
-
(0, _classCallCheck2.default)(this, I3SConverter);
|
|
54
|
+
var _textures = require("@loaders.gl/textures");
|
|
55
|
+
|
|
56
|
+
const ION_DEFAULT_TOKEN = _process.default.env.IonToken || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ';
|
|
57
|
+
const HARDCODED_NODES_PER_PAGE = 64;
|
|
58
|
+
const _3D_TILES = '3DTILES';
|
|
59
|
+
const _3D_OBJECT_LAYER_TYPE = '3DObject';
|
|
60
|
+
const STRING_TYPE = 'string';
|
|
61
|
+
const SHORT_INT_TYPE = 'Int32';
|
|
62
|
+
const DOUBLE_TYPE = 'double';
|
|
63
|
+
const OBJECT_ID_TYPE = 'OBJECTID';
|
|
64
|
+
const REFRESH_TOKEN_TIMEOUT = 1800;
|
|
65
|
+
const CESIUM_DATASET_PREFIX = 'https://';
|
|
66
|
+
|
|
67
|
+
class I3SConverter {
|
|
68
|
+
constructor() {
|
|
91
69
|
(0, _defineProperty2.default)(this, "nodePages", void 0);
|
|
92
70
|
(0, _defineProperty2.default)(this, "fileMap", void 0);
|
|
93
71
|
(0, _defineProperty2.default)(this, "options", void 0);
|
|
@@ -104,6 +82,7 @@ var I3SConverter = function () {
|
|
|
104
82
|
(0, _defineProperty2.default)(this, "refreshTokenTime", void 0);
|
|
105
83
|
(0, _defineProperty2.default)(this, "sourceTileset", void 0);
|
|
106
84
|
(0, _defineProperty2.default)(this, "geoidHeightModel", void 0);
|
|
85
|
+
(0, _defineProperty2.default)(this, "Loader", _dTiles.Tiles3DLoader);
|
|
107
86
|
this.nodePages = new _nodePages.default(_fileUtils.writeFile, HARDCODED_NODES_PER_PAGE);
|
|
108
87
|
this.fileMap = {};
|
|
109
88
|
this.options = {};
|
|
@@ -121,1595 +100,816 @@ var I3SConverter = function () {
|
|
|
121
100
|
this.boundingVolumeWarnings = null;
|
|
122
101
|
}
|
|
123
102
|
|
|
124
|
-
(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
_context.next = 12;
|
|
158
|
-
return this._fetchPreloadOptions();
|
|
159
|
-
|
|
160
|
-
case 12:
|
|
161
|
-
preloadOptions = _context.sent;
|
|
162
|
-
tilesetOptions = {
|
|
163
|
-
loadOptions: {}
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
if (preloadOptions.headers) {
|
|
167
|
-
tilesetOptions.loadOptions.fetch = {
|
|
168
|
-
headers: preloadOptions.headers
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
Object.assign(tilesetOptions, preloadOptions);
|
|
173
|
-
_context.next = 18;
|
|
174
|
-
return (0, _core.load)(inputUrl, _dTiles.CesiumIonLoader, tilesetOptions.loadOptions);
|
|
175
|
-
|
|
176
|
-
case 18:
|
|
177
|
-
sourceTilesetJson = _context.sent;
|
|
178
|
-
this.sourceTileset = new _tiles.Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
179
|
-
_context.next = 22;
|
|
180
|
-
return this._createAndSaveTileset(outputPath, tilesetName);
|
|
181
|
-
|
|
182
|
-
case 22:
|
|
183
|
-
_context.next = 24;
|
|
184
|
-
return this._finishConversion({
|
|
185
|
-
slpk: slpk,
|
|
186
|
-
outputPath: outputPath,
|
|
187
|
-
tilesetName: tilesetName
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
case 24:
|
|
191
|
-
return _context.abrupt("return", sourceTilesetJson);
|
|
192
|
-
|
|
193
|
-
case 25:
|
|
194
|
-
case "end":
|
|
195
|
-
return _context.stop();
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}, _callee, this);
|
|
199
|
-
}));
|
|
200
|
-
|
|
201
|
-
function convert(_x) {
|
|
202
|
-
return _convert.apply(this, arguments);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return convert;
|
|
206
|
-
}()
|
|
207
|
-
}, {
|
|
208
|
-
key: "_createAndSaveTileset",
|
|
209
|
-
value: function () {
|
|
210
|
-
var _createAndSaveTileset2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(outputPath, tilesetName) {
|
|
211
|
-
var tilesetPath, sourceRootTile, boundingVolumes, parentId, isCreateSlpk, root0;
|
|
212
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
213
|
-
while (1) {
|
|
214
|
-
switch (_context2.prev = _context2.next) {
|
|
215
|
-
case 0:
|
|
216
|
-
tilesetPath = (0, _path.join)("".concat(outputPath), "".concat(tilesetName));
|
|
217
|
-
_context2.prev = 1;
|
|
218
|
-
_context2.next = 4;
|
|
219
|
-
return (0, _fileUtils.removeDir)(tilesetPath);
|
|
220
|
-
|
|
221
|
-
case 4:
|
|
222
|
-
_context2.next = 8;
|
|
223
|
-
break;
|
|
224
|
-
|
|
225
|
-
case 6:
|
|
226
|
-
_context2.prev = 6;
|
|
227
|
-
_context2.t0 = _context2["catch"](1);
|
|
228
|
-
|
|
229
|
-
case 8:
|
|
230
|
-
this.layers0Path = (0, _path.join)(tilesetPath, 'SceneServer', 'layers', '0');
|
|
231
|
-
|
|
232
|
-
this._formLayers0(tilesetName);
|
|
233
|
-
|
|
234
|
-
this.materialDefinitions = [];
|
|
235
|
-
this.materialMap = new Map();
|
|
236
|
-
sourceRootTile = this.sourceTileset.root;
|
|
237
|
-
boundingVolumes = (0, _coordinateConverter.createBoundingVolumes)(sourceRootTile, this.geoidHeightModel);
|
|
238
|
-
parentId = this.nodePages.push({
|
|
239
|
-
lodThreshold: 0,
|
|
240
|
-
obb: boundingVolumes.obb,
|
|
241
|
-
children: []
|
|
242
|
-
});
|
|
243
|
-
isCreateSlpk = this.options.slpk;
|
|
244
|
-
root0 = this._formRootNodeIndexDocument(boundingVolumes);
|
|
245
|
-
_context2.next = 19;
|
|
246
|
-
return this._convertNodesTree(root0, sourceRootTile, parentId, boundingVolumes);
|
|
247
|
-
|
|
248
|
-
case 19:
|
|
249
|
-
this.layers0.materialDefinitions = this.materialDefinitions;
|
|
250
|
-
_context2.next = 22;
|
|
251
|
-
return this._writeLayers0();
|
|
252
|
-
|
|
253
|
-
case 22:
|
|
254
|
-
(0, _createSceneServerPath.createSceneServerPath)(tilesetName, this.layers0, tilesetPath);
|
|
255
|
-
_context2.next = 25;
|
|
256
|
-
return this._writeNodeIndexDocument(root0, 'root', (0, _path.join)(this.layers0Path, 'nodes', 'root'));
|
|
257
|
-
|
|
258
|
-
case 25:
|
|
259
|
-
_context2.next = 27;
|
|
260
|
-
return this.nodePages.save(this.layers0Path, this.fileMap, isCreateSlpk);
|
|
261
|
-
|
|
262
|
-
case 27:
|
|
263
|
-
_context2.next = 29;
|
|
264
|
-
return this._createSlpk(tilesetPath);
|
|
265
|
-
|
|
266
|
-
case 29:
|
|
267
|
-
case "end":
|
|
268
|
-
return _context2.stop();
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}, _callee2, this, [[1, 6]]);
|
|
272
|
-
}));
|
|
103
|
+
async convert(options) {
|
|
104
|
+
this.conversionStartTime = _process.default.hrtime();
|
|
105
|
+
const {
|
|
106
|
+
tilesetName,
|
|
107
|
+
slpk,
|
|
108
|
+
egmFilePath,
|
|
109
|
+
inputUrl,
|
|
110
|
+
validate,
|
|
111
|
+
outputPath,
|
|
112
|
+
draco,
|
|
113
|
+
sevenZipExe,
|
|
114
|
+
maxDepth,
|
|
115
|
+
token
|
|
116
|
+
} = options;
|
|
117
|
+
this.options = {
|
|
118
|
+
maxDepth,
|
|
119
|
+
slpk,
|
|
120
|
+
sevenZipExe,
|
|
121
|
+
egmFilePath,
|
|
122
|
+
draco,
|
|
123
|
+
token,
|
|
124
|
+
inputUrl
|
|
125
|
+
};
|
|
126
|
+
this.validate = validate;
|
|
127
|
+
this.Loader = inputUrl.indexOf(CESIUM_DATASET_PREFIX) !== -1 ? _dTiles.CesiumIonLoader : _dTiles.Tiles3DLoader;
|
|
128
|
+
console.log('Loading egm file...');
|
|
129
|
+
this.geoidHeightModel = await (0, _core.load)(egmFilePath, _pgmLoader.PGMLoader);
|
|
130
|
+
console.log('Loading egm file completed!');
|
|
131
|
+
|
|
132
|
+
if (slpk) {
|
|
133
|
+
this.nodePages.useWriteFunction(_fileUtils.writeFileForSlpk);
|
|
134
|
+
}
|
|
273
135
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
}
|
|
136
|
+
const preloadOptions = await this._fetchPreloadOptions();
|
|
137
|
+
const tilesetOptions = {
|
|
138
|
+
loadOptions: {}
|
|
139
|
+
};
|
|
277
140
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
key: "_formLayers0",
|
|
282
|
-
value: function _formLayers0(tilesetName) {
|
|
283
|
-
var extent = (0, _coordinateConverter.convertCommonToI3SExtentCoordinate)(this.sourceTileset);
|
|
284
|
-
var layers0data = {
|
|
285
|
-
version: "{".concat((0, _uuid.v4)().toUpperCase(), "}"),
|
|
286
|
-
id: 0,
|
|
287
|
-
name: tilesetName,
|
|
288
|
-
href: './layers/0',
|
|
289
|
-
store: {
|
|
290
|
-
id: "{".concat((0, _uuid.v4)().toUpperCase(), "}"),
|
|
291
|
-
extent: extent
|
|
292
|
-
},
|
|
293
|
-
nodePages: {
|
|
294
|
-
nodesPerPage: HARDCODED_NODES_PER_PAGE
|
|
295
|
-
},
|
|
296
|
-
compressGeometry: this.options.draco
|
|
141
|
+
if (preloadOptions.headers) {
|
|
142
|
+
tilesetOptions.loadOptions.fetch = {
|
|
143
|
+
headers: preloadOptions.headers
|
|
297
144
|
};
|
|
298
|
-
this.layers0 = (0, _jsonMapTransform.default)(layers0data, _layers.LAYERS);
|
|
299
|
-
}
|
|
300
|
-
}, {
|
|
301
|
-
key: "_formRootNodeIndexDocument",
|
|
302
|
-
value: function _formRootNodeIndexDocument(boundingVolumes) {
|
|
303
|
-
var root0data = _objectSpread(_objectSpread({
|
|
304
|
-
version: "{".concat((0, _uuid.v4)().toUpperCase(), "}"),
|
|
305
|
-
id: 'root',
|
|
306
|
-
level: 0,
|
|
307
|
-
lodSelection: [{
|
|
308
|
-
metricType: 'maxScreenThresholdSQ',
|
|
309
|
-
maxError: 0
|
|
310
|
-
}, {
|
|
311
|
-
metricType: 'maxScreenThreshold',
|
|
312
|
-
maxError: 0
|
|
313
|
-
}]
|
|
314
|
-
}, boundingVolumes), {}, {
|
|
315
|
-
children: []
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
return (0, _jsonMapTransform.default)(root0data, _node.NODE);
|
|
319
145
|
}
|
|
320
|
-
}, {
|
|
321
|
-
key: "_convertNodesTree",
|
|
322
|
-
value: function () {
|
|
323
|
-
var _convertNodesTree2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(root0, sourceRootTile, parentId, boundingVolumes) {
|
|
324
|
-
var _yield$this$_createNo, _yield$this$_createNo2, child, childPath;
|
|
325
|
-
|
|
326
|
-
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
327
|
-
while (1) {
|
|
328
|
-
switch (_context3.prev = _context3.next) {
|
|
329
|
-
case 0:
|
|
330
|
-
_context3.next = 2;
|
|
331
|
-
return this.sourceTileset._loadTile(sourceRootTile);
|
|
332
|
-
|
|
333
|
-
case 2:
|
|
334
|
-
if (!(sourceRootTile.content && sourceRootTile.content.type === 'b3dm')) {
|
|
335
|
-
_context3.next = 20;
|
|
336
|
-
break;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
root0.children.push(_objectSpread({
|
|
340
|
-
id: '1',
|
|
341
|
-
href: './1'
|
|
342
|
-
}, boundingVolumes));
|
|
343
|
-
_context3.next = 6;
|
|
344
|
-
return this._createNode(root0, sourceRootTile, parentId, 0);
|
|
345
|
-
|
|
346
|
-
case 6:
|
|
347
|
-
_yield$this$_createNo = _context3.sent;
|
|
348
|
-
_yield$this$_createNo2 = (0, _slicedToArray2.default)(_yield$this$_createNo, 1);
|
|
349
|
-
child = _yield$this$_createNo2[0];
|
|
350
|
-
childPath = (0, _path.join)(this.layers0Path, 'nodes', child.path);
|
|
351
|
-
|
|
352
|
-
if (!this.options.slpk) {
|
|
353
|
-
_context3.next = 16;
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
_context3.next = 13;
|
|
358
|
-
return (0, _fileUtils.writeFileForSlpk)(childPath, JSON.stringify(child), '3dNodeIndexDocument.json');
|
|
359
|
-
|
|
360
|
-
case 13:
|
|
361
|
-
this.fileMap['nodes/1/3dNodeIndexDocument.json.gz'] = _context3.sent;
|
|
362
|
-
_context3.next = 18;
|
|
363
|
-
break;
|
|
364
|
-
|
|
365
|
-
case 16:
|
|
366
|
-
_context3.next = 18;
|
|
367
|
-
return (0, _fileUtils.writeFile)(childPath, JSON.stringify(child));
|
|
368
|
-
|
|
369
|
-
case 18:
|
|
370
|
-
_context3.next = 22;
|
|
371
|
-
break;
|
|
372
|
-
|
|
373
|
-
case 20:
|
|
374
|
-
_context3.next = 22;
|
|
375
|
-
return this._addChildrenWithNeighborsAndWriteFile({
|
|
376
|
-
parentNode: root0,
|
|
377
|
-
sourceTiles: sourceRootTile.children,
|
|
378
|
-
parentId: parentId,
|
|
379
|
-
level: 1
|
|
380
|
-
});
|
|
381
|
-
|
|
382
|
-
case 22:
|
|
383
|
-
_context3.next = 24;
|
|
384
|
-
return sourceRootTile.unloadContent();
|
|
385
|
-
|
|
386
|
-
case 24:
|
|
387
|
-
case "end":
|
|
388
|
-
return _context3.stop();
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}, _callee3, this);
|
|
392
|
-
}));
|
|
393
|
-
|
|
394
|
-
function _convertNodesTree(_x4, _x5, _x6, _x7) {
|
|
395
|
-
return _convertNodesTree2.apply(this, arguments);
|
|
396
|
-
}
|
|
397
146
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
_context4.next = 6;
|
|
410
|
-
break;
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
_context4.next = 3;
|
|
414
|
-
return (0, _fileUtils.writeFileForSlpk)(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json');
|
|
415
|
-
|
|
416
|
-
case 3:
|
|
417
|
-
this.fileMap['3dSceneLayer.json.gz'] = _context4.sent;
|
|
418
|
-
_context4.next = 8;
|
|
419
|
-
break;
|
|
420
|
-
|
|
421
|
-
case 6:
|
|
422
|
-
_context4.next = 8;
|
|
423
|
-
return (0, _fileUtils.writeFile)(this.layers0Path, JSON.stringify(this.layers0));
|
|
424
|
-
|
|
425
|
-
case 8:
|
|
426
|
-
case "end":
|
|
427
|
-
return _context4.stop();
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
}, _callee4, this);
|
|
431
|
-
}));
|
|
147
|
+
Object.assign(tilesetOptions, preloadOptions);
|
|
148
|
+
const sourceTilesetJson = await (0, _core.load)(inputUrl, this.Loader, tilesetOptions.loadOptions);
|
|
149
|
+
this.sourceTileset = new _tiles.Tileset3D(sourceTilesetJson, tilesetOptions);
|
|
150
|
+
await this._createAndSaveTileset(outputPath, tilesetName);
|
|
151
|
+
await this._finishConversion({
|
|
152
|
+
slpk,
|
|
153
|
+
outputPath,
|
|
154
|
+
tilesetName
|
|
155
|
+
});
|
|
156
|
+
return sourceTilesetJson;
|
|
157
|
+
}
|
|
432
158
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
159
|
+
async _createAndSaveTileset(outputPath, tilesetName) {
|
|
160
|
+
const tilesetPath = (0, _path.join)("".concat(outputPath), "".concat(tilesetName));
|
|
436
161
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
key: "_writeNodeIndexDocument",
|
|
441
|
-
value: function () {
|
|
442
|
-
var _writeNodeIndexDocument2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee5(root0, nodePath, rootPath) {
|
|
443
|
-
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
444
|
-
while (1) {
|
|
445
|
-
switch (_context5.prev = _context5.next) {
|
|
446
|
-
case 0:
|
|
447
|
-
if (!this.options.slpk) {
|
|
448
|
-
_context5.next = 6;
|
|
449
|
-
break;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
_context5.next = 3;
|
|
453
|
-
return (0, _fileUtils.writeFileForSlpk)(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json');
|
|
454
|
-
|
|
455
|
-
case 3:
|
|
456
|
-
this.fileMap["nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz")] = _context5.sent;
|
|
457
|
-
_context5.next = 8;
|
|
458
|
-
break;
|
|
459
|
-
|
|
460
|
-
case 6:
|
|
461
|
-
_context5.next = 8;
|
|
462
|
-
return (0, _fileUtils.writeFile)(rootPath, JSON.stringify(root0));
|
|
463
|
-
|
|
464
|
-
case 8:
|
|
465
|
-
case "end":
|
|
466
|
-
return _context5.stop();
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
}, _callee5, this);
|
|
470
|
-
}));
|
|
162
|
+
try {
|
|
163
|
+
await (0, _fileUtils.removeDir)(tilesetPath);
|
|
164
|
+
} catch (e) {}
|
|
471
165
|
|
|
472
|
-
|
|
473
|
-
return _writeNodeIndexDocument2.apply(this, arguments);
|
|
474
|
-
}
|
|
166
|
+
this.layers0Path = (0, _path.join)(tilesetPath, 'SceneServer', 'layers', '0');
|
|
475
167
|
|
|
476
|
-
|
|
477
|
-
}()
|
|
478
|
-
}, {
|
|
479
|
-
key: "_createSlpk",
|
|
480
|
-
value: function () {
|
|
481
|
-
var _createSlpk2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee6(tilesetPath) {
|
|
482
|
-
var slpkTilesetPath, slpkFileName;
|
|
483
|
-
return _regenerator.default.wrap(function _callee6$(_context6) {
|
|
484
|
-
while (1) {
|
|
485
|
-
switch (_context6.prev = _context6.next) {
|
|
486
|
-
case 0:
|
|
487
|
-
if (!this.options.slpk) {
|
|
488
|
-
_context6.next = 12;
|
|
489
|
-
break;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
slpkTilesetPath = (0, _path.join)(tilesetPath, 'SceneServer', 'layers', '0');
|
|
493
|
-
slpkFileName = "".concat(tilesetPath, ".slpk");
|
|
494
|
-
_context6.next = 5;
|
|
495
|
-
return (0, _compressUtil.compressWithChildProcess)(slpkTilesetPath, slpkFileName, 0, '.', this.options.sevenZipExe);
|
|
496
|
-
|
|
497
|
-
case 5:
|
|
498
|
-
_context6.prev = 5;
|
|
499
|
-
_context6.next = 8;
|
|
500
|
-
return (0, _fileUtils.removeDir)(tilesetPath);
|
|
501
|
-
|
|
502
|
-
case 8:
|
|
503
|
-
_context6.next = 12;
|
|
504
|
-
break;
|
|
505
|
-
|
|
506
|
-
case 10:
|
|
507
|
-
_context6.prev = 10;
|
|
508
|
-
_context6.t0 = _context6["catch"](5);
|
|
509
|
-
|
|
510
|
-
case 12:
|
|
511
|
-
case "end":
|
|
512
|
-
return _context6.stop();
|
|
513
|
-
}
|
|
514
|
-
}
|
|
515
|
-
}, _callee6, this, [[5, 10]]);
|
|
516
|
-
}));
|
|
168
|
+
this._formLayers0(tilesetName);
|
|
517
169
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
170
|
+
this.materialDefinitions = [];
|
|
171
|
+
this.materialMap = new Map();
|
|
172
|
+
const sourceRootTile = this.sourceTileset.root;
|
|
173
|
+
const boundingVolumes = (0, _coordinateConverter.createBoundingVolumes)(sourceRootTile, this.geoidHeightModel);
|
|
174
|
+
const parentId = this.nodePages.push({
|
|
175
|
+
lodThreshold: 0,
|
|
176
|
+
obb: boundingVolumes.obb,
|
|
177
|
+
children: []
|
|
178
|
+
});
|
|
179
|
+
const isCreateSlpk = this.options.slpk;
|
|
180
|
+
|
|
181
|
+
const root0 = this._formRootNodeIndexDocument(boundingVolumes);
|
|
182
|
+
|
|
183
|
+
await this._convertNodesTree(root0, sourceRootTile, parentId, boundingVolumes);
|
|
184
|
+
this.layers0.materialDefinitions = this.materialDefinitions;
|
|
185
|
+
await this._writeLayers0();
|
|
186
|
+
(0, _createSceneServerPath.createSceneServerPath)(tilesetName, this.layers0, tilesetPath);
|
|
187
|
+
await this._writeNodeIndexDocument(root0, 'root', (0, _path.join)(this.layers0Path, 'nodes', 'root'));
|
|
188
|
+
await this.nodePages.save(this.layers0Path, this.fileMap, isCreateSlpk);
|
|
189
|
+
await this._createSlpk(tilesetPath);
|
|
190
|
+
}
|
|
521
191
|
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
_context7.next = 5;
|
|
541
|
-
return this._addNeighborsAndWriteFile(data.parentNode, childNodes);
|
|
542
|
-
|
|
543
|
-
case 5:
|
|
544
|
-
case "end":
|
|
545
|
-
return _context7.stop();
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
}, _callee7, this);
|
|
549
|
-
}));
|
|
192
|
+
_formLayers0(tilesetName) {
|
|
193
|
+
const extent = (0, _coordinateConverter.convertCommonToI3SExtentCoordinate)(this.sourceTileset);
|
|
194
|
+
const layers0data = {
|
|
195
|
+
version: "{".concat((0, _uuid.v4)().toUpperCase(), "}"),
|
|
196
|
+
id: 0,
|
|
197
|
+
name: tilesetName,
|
|
198
|
+
href: './layers/0',
|
|
199
|
+
store: {
|
|
200
|
+
id: "{".concat((0, _uuid.v4)().toUpperCase(), "}"),
|
|
201
|
+
extent
|
|
202
|
+
},
|
|
203
|
+
nodePages: {
|
|
204
|
+
nodesPerPage: HARDCODED_NODES_PER_PAGE
|
|
205
|
+
},
|
|
206
|
+
compressGeometry: this.options.draco
|
|
207
|
+
};
|
|
208
|
+
this.layers0 = (0, _jsonMapTransform.default)(layers0data, _layers.LAYERS);
|
|
209
|
+
}
|
|
550
210
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
}
|
|
211
|
+
_formRootNodeIndexDocument(boundingVolumes) {
|
|
212
|
+
const root0data = {
|
|
213
|
+
version: "{".concat((0, _uuid.v4)().toUpperCase(), "}"),
|
|
214
|
+
id: 'root',
|
|
215
|
+
level: 0,
|
|
216
|
+
lodSelection: [{
|
|
217
|
+
metricType: 'maxScreenThresholdSQ',
|
|
218
|
+
maxError: 0
|
|
219
|
+
}, {
|
|
220
|
+
metricType: 'maxScreenThreshold',
|
|
221
|
+
maxError: 0
|
|
222
|
+
}],
|
|
223
|
+
...boundingVolumes,
|
|
224
|
+
children: []
|
|
225
|
+
};
|
|
226
|
+
return (0, _jsonMapTransform.default)(root0data, _node.NODE);
|
|
227
|
+
}
|
|
554
228
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
}, {
|
|
558
|
-
key: "_addChildren",
|
|
559
|
-
value: function () {
|
|
560
|
-
var _addChildren2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee8(data) {
|
|
561
|
-
var childNodes, sourceTiles, parentNode, parentId, level, _iterator, _step, sourceTile, boundingVolumes, children, _iterator2, _step2, child;
|
|
562
|
-
|
|
563
|
-
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
564
|
-
while (1) {
|
|
565
|
-
switch (_context8.prev = _context8.next) {
|
|
566
|
-
case 0:
|
|
567
|
-
childNodes = data.childNodes, sourceTiles = data.sourceTiles, parentNode = data.parentNode, parentId = data.parentId, level = data.level;
|
|
568
|
-
|
|
569
|
-
if (!(this.options.maxDepth && level > this.options.maxDepth)) {
|
|
570
|
-
_context8.next = 3;
|
|
571
|
-
break;
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
return _context8.abrupt("return");
|
|
575
|
-
|
|
576
|
-
case 3:
|
|
577
|
-
_iterator = _createForOfIteratorHelper(sourceTiles);
|
|
578
|
-
_context8.prev = 4;
|
|
579
|
-
|
|
580
|
-
_iterator.s();
|
|
581
|
-
|
|
582
|
-
case 6:
|
|
583
|
-
if ((_step = _iterator.n()).done) {
|
|
584
|
-
_context8.next = 26;
|
|
585
|
-
break;
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
sourceTile = _step.value;
|
|
589
|
-
|
|
590
|
-
if (!(sourceTile.type === 'json')) {
|
|
591
|
-
_context8.next = 17;
|
|
592
|
-
break;
|
|
593
|
-
}
|
|
594
|
-
|
|
595
|
-
_context8.next = 11;
|
|
596
|
-
return this.sourceTileset._loadTile(sourceTile);
|
|
597
|
-
|
|
598
|
-
case 11:
|
|
599
|
-
_context8.next = 13;
|
|
600
|
-
return this._addChildren({
|
|
601
|
-
parentNode: parentNode,
|
|
602
|
-
sourceTiles: sourceTile.children,
|
|
603
|
-
childNodes: childNodes,
|
|
604
|
-
parentId: parentId,
|
|
605
|
-
level: level + 1
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
case 13:
|
|
609
|
-
_context8.next = 15;
|
|
610
|
-
return sourceTile.unloadContent();
|
|
611
|
-
|
|
612
|
-
case 15:
|
|
613
|
-
_context8.next = 23;
|
|
614
|
-
break;
|
|
615
|
-
|
|
616
|
-
case 17:
|
|
617
|
-
boundingVolumes = (0, _coordinateConverter.createBoundingVolumes)(sourceTile, this.geoidHeightModel);
|
|
618
|
-
_context8.next = 20;
|
|
619
|
-
return this._createNode(parentNode, sourceTile, parentId, level);
|
|
620
|
-
|
|
621
|
-
case 20:
|
|
622
|
-
children = _context8.sent;
|
|
623
|
-
_iterator2 = _createForOfIteratorHelper(children);
|
|
624
|
-
|
|
625
|
-
try {
|
|
626
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
627
|
-
child = _step2.value;
|
|
628
|
-
parentNode.children.push(_objectSpread({
|
|
629
|
-
id: child.id,
|
|
630
|
-
href: "../".concat(child.path)
|
|
631
|
-
}, boundingVolumes));
|
|
632
|
-
childNodes.push(child);
|
|
633
|
-
}
|
|
634
|
-
} catch (err) {
|
|
635
|
-
_iterator2.e(err);
|
|
636
|
-
} finally {
|
|
637
|
-
_iterator2.f();
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
case 23:
|
|
641
|
-
if (sourceTile.id) {
|
|
642
|
-
console.log(sourceTile.id);
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
case 24:
|
|
646
|
-
_context8.next = 6;
|
|
647
|
-
break;
|
|
648
|
-
|
|
649
|
-
case 26:
|
|
650
|
-
_context8.next = 31;
|
|
651
|
-
break;
|
|
652
|
-
|
|
653
|
-
case 28:
|
|
654
|
-
_context8.prev = 28;
|
|
655
|
-
_context8.t0 = _context8["catch"](4);
|
|
656
|
-
|
|
657
|
-
_iterator.e(_context8.t0);
|
|
658
|
-
|
|
659
|
-
case 31:
|
|
660
|
-
_context8.prev = 31;
|
|
661
|
-
|
|
662
|
-
_iterator.f();
|
|
663
|
-
|
|
664
|
-
return _context8.finish(31);
|
|
665
|
-
|
|
666
|
-
case 34:
|
|
667
|
-
case "end":
|
|
668
|
-
return _context8.stop();
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
}, _callee8, this, [[4, 28, 31, 34]]);
|
|
672
|
-
}));
|
|
229
|
+
async _convertNodesTree(root0, sourceRootTile, parentId, boundingVolumes) {
|
|
230
|
+
await this.sourceTileset._loadTile(sourceRootTile);
|
|
673
231
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
232
|
+
if (sourceRootTile.content && sourceRootTile.content.type === 'b3dm') {
|
|
233
|
+
root0.children.push({
|
|
234
|
+
id: '1',
|
|
235
|
+
href: './1',
|
|
236
|
+
...boundingVolumes
|
|
237
|
+
});
|
|
238
|
+
const [child] = await this._createNode(root0, sourceRootTile, parentId, 0);
|
|
239
|
+
const childPath = (0, _path.join)(this.layers0Path, 'nodes', child.path);
|
|
240
|
+
|
|
241
|
+
if (this.options.slpk) {
|
|
242
|
+
this.fileMap['nodes/1/3dNodeIndexDocument.json.gz'] = await (0, _fileUtils.writeFileForSlpk)(childPath, JSON.stringify(child), '3dNodeIndexDocument.json');
|
|
243
|
+
} else {
|
|
244
|
+
await (0, _fileUtils.writeFile)(childPath, JSON.stringify(child));
|
|
245
|
+
}
|
|
246
|
+
} else {
|
|
247
|
+
await this._addChildrenWithNeighborsAndWriteFile({
|
|
248
|
+
parentNode: root0,
|
|
249
|
+
sourceTiles: sourceRootTile.children,
|
|
250
|
+
parentId,
|
|
251
|
+
level: 1
|
|
252
|
+
});
|
|
253
|
+
}
|
|
677
254
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
}, {
|
|
681
|
-
key: "_addNeighborsAndWriteFile",
|
|
682
|
-
value: function () {
|
|
683
|
-
var _addNeighborsAndWriteFile2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee9(parentNode, childNodes) {
|
|
684
|
-
var _iterator3, _step3, node, childPath, nodePath, _iterator4, _step4, neighbor;
|
|
255
|
+
await sourceRootTile.unloadContent();
|
|
256
|
+
}
|
|
685
257
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
258
|
+
async _writeLayers0() {
|
|
259
|
+
if (this.options.slpk) {
|
|
260
|
+
this.fileMap['3dSceneLayer.json.gz'] = await (0, _fileUtils.writeFileForSlpk)(this.layers0Path, JSON.stringify(this.layers0), '3dSceneLayer.json');
|
|
261
|
+
} else {
|
|
262
|
+
await (0, _fileUtils.writeFile)(this.layers0Path, JSON.stringify(this.layers0));
|
|
263
|
+
}
|
|
264
|
+
}
|
|
692
265
|
|
|
693
|
-
|
|
266
|
+
async _writeNodeIndexDocument(root0, nodePath, rootPath) {
|
|
267
|
+
if (this.options.slpk) {
|
|
268
|
+
this.fileMap["nodes/".concat(nodePath, "/3dNodeIndexDocument.json.gz")] = await (0, _fileUtils.writeFileForSlpk)(rootPath, JSON.stringify(root0), '3dNodeIndexDocument.json');
|
|
269
|
+
} else {
|
|
270
|
+
await (0, _fileUtils.writeFile)(rootPath, JSON.stringify(root0));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
694
273
|
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
274
|
+
async _createSlpk(tilesetPath) {
|
|
275
|
+
if (this.options.slpk) {
|
|
276
|
+
const slpkTilesetPath = (0, _path.join)(tilesetPath, 'SceneServer', 'layers', '0');
|
|
277
|
+
const slpkFileName = "".concat(tilesetPath, ".slpk");
|
|
278
|
+
await (0, _compressUtil.compressWithChildProcess)(slpkTilesetPath, slpkFileName, 0, '.', this.options.sevenZipExe);
|
|
700
279
|
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
280
|
+
try {
|
|
281
|
+
await (0, _fileUtils.removeDir)(tilesetPath);
|
|
282
|
+
} catch (e) {}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
705
285
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
286
|
+
async _addChildrenWithNeighborsAndWriteFile(data) {
|
|
287
|
+
const childNodes = [];
|
|
288
|
+
await this._addChildren({ ...data,
|
|
289
|
+
childNodes
|
|
290
|
+
});
|
|
291
|
+
await this._addNeighborsAndWriteFile(data.parentNode, childNodes);
|
|
292
|
+
}
|
|
710
293
|
|
|
711
|
-
|
|
712
|
-
|
|
294
|
+
async _addChildren(data) {
|
|
295
|
+
const {
|
|
296
|
+
childNodes,
|
|
297
|
+
sourceTiles,
|
|
298
|
+
parentNode,
|
|
299
|
+
parentId,
|
|
300
|
+
level
|
|
301
|
+
} = data;
|
|
302
|
+
|
|
303
|
+
if (this.options.maxDepth && level > this.options.maxDepth) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
713
306
|
|
|
714
|
-
|
|
307
|
+
for (const sourceTile of sourceTiles) {
|
|
308
|
+
if (sourceTile.type === 'json') {
|
|
309
|
+
await this.sourceTileset._loadTile(sourceTile);
|
|
310
|
+
await this._addChildren({
|
|
311
|
+
parentNode,
|
|
312
|
+
sourceTiles: sourceTile.children,
|
|
313
|
+
childNodes,
|
|
314
|
+
parentId,
|
|
315
|
+
level: level + 1
|
|
316
|
+
});
|
|
317
|
+
await sourceTile.unloadContent();
|
|
318
|
+
} else {
|
|
319
|
+
const boundingVolumes = (0, _coordinateConverter.createBoundingVolumes)(sourceTile, this.geoidHeightModel);
|
|
320
|
+
const children = await this._createNode(parentNode, sourceTile, parentId, level);
|
|
321
|
+
|
|
322
|
+
for (const child of children) {
|
|
323
|
+
parentNode.children.push({
|
|
324
|
+
id: child.id,
|
|
325
|
+
href: "../".concat(child.path),
|
|
326
|
+
...boundingVolumes
|
|
327
|
+
});
|
|
328
|
+
childNodes.push(child);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
715
331
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
332
|
+
if (sourceTile.id) {
|
|
333
|
+
console.log(sourceTile.id);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
721
337
|
|
|
722
|
-
|
|
338
|
+
async _addNeighborsAndWriteFile(parentNode, childNodes) {
|
|
339
|
+
for (const node of childNodes) {
|
|
340
|
+
const childPath = (0, _path.join)(this.layers0Path, 'nodes', node.path);
|
|
341
|
+
const nodePath = node.path;
|
|
342
|
+
delete node.path;
|
|
723
343
|
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
344
|
+
if (parentNode.children.length < 1000) {
|
|
345
|
+
for (const neighbor of parentNode.children) {
|
|
346
|
+
if (node.id === neighbor.id) {
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
728
349
|
|
|
729
|
-
|
|
350
|
+
node.neighbors.push({ ...neighbor
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
} else {
|
|
354
|
+
console.warn("Node ".concat(node.id, ": neighbors attribute is omited because of large number of neigbors"));
|
|
355
|
+
delete node.neighbors;
|
|
356
|
+
}
|
|
730
357
|
|
|
731
|
-
|
|
732
|
-
|
|
358
|
+
await this._writeNodeIndexDocument(node, nodePath, childPath);
|
|
359
|
+
node.neighbors = [];
|
|
360
|
+
}
|
|
361
|
+
}
|
|
733
362
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
break;
|
|
363
|
+
async _createNode(parentTile, sourceTile, parentId, level) {
|
|
364
|
+
var _sourceTile$content;
|
|
737
365
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
366
|
+
if (this.validate) {
|
|
367
|
+
this._checkAddRefinementTypeForTile(sourceTile);
|
|
368
|
+
}
|
|
741
369
|
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
370
|
+
await this._updateTilesetOptions();
|
|
371
|
+
await this.sourceTileset._loadTile(sourceTile);
|
|
372
|
+
const boundingVolumes = (0, _coordinateConverter.createBoundingVolumes)(sourceTile, this.geoidHeightModel);
|
|
373
|
+
const lodSelection = (0, _lodConversionUtils.convertGeometricErrorToScreenThreshold)(sourceTile, boundingVolumes);
|
|
374
|
+
const maxScreenThresholdSQ = lodSelection.find(val => val.metricType === 'maxScreenThresholdSQ') || {
|
|
375
|
+
maxError: 0
|
|
376
|
+
};
|
|
377
|
+
const batchTable = sourceTile === null || sourceTile === void 0 ? void 0 : (_sourceTile$content = sourceTile.content) === null || _sourceTile$content === void 0 ? void 0 : _sourceTile$content.batchTableJson;
|
|
745
378
|
|
|
746
|
-
|
|
379
|
+
if (batchTable) {
|
|
380
|
+
this._convertAttributeStorageInfo(sourceTile.content);
|
|
381
|
+
}
|
|
747
382
|
|
|
748
|
-
|
|
749
|
-
|
|
383
|
+
const resourcesData = await this._convertResources(sourceTile);
|
|
384
|
+
const nodes = [];
|
|
385
|
+
const emptyResources = {
|
|
386
|
+
geometry: null,
|
|
387
|
+
compressedGeometry: null,
|
|
388
|
+
texture: null,
|
|
389
|
+
sharedResources: null,
|
|
390
|
+
meshMaterial: null,
|
|
391
|
+
vertexCount: null,
|
|
392
|
+
attributes: null,
|
|
393
|
+
featureCount: null
|
|
394
|
+
};
|
|
750
395
|
|
|
751
|
-
|
|
396
|
+
for (const resources of resourcesData || [emptyResources]) {
|
|
397
|
+
const nodeInPage = this._createNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources);
|
|
752
398
|
|
|
753
|
-
|
|
399
|
+
const node = this._createNodeIndexDocument(parentTile, boundingVolumes, lodSelection, nodeInPage, resources);
|
|
754
400
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
401
|
+
if (nodeInPage.mesh) {
|
|
402
|
+
await this._writeResources(resources, node.path);
|
|
403
|
+
}
|
|
758
404
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
delete node.neighbors;
|
|
405
|
+
if (this.validate) {
|
|
406
|
+
this.boundingVolumeWarnings = (0, _nodeDebug.validateNodeBoundingVolumes)(node);
|
|
762
407
|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
408
|
+
if (this.boundingVolumeWarnings && this.boundingVolumeWarnings.length) {
|
|
409
|
+
console.warn('Bounding Volume Warnings: ', ...this.boundingVolumeWarnings);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
766
412
|
|
|
767
|
-
|
|
768
|
-
|
|
413
|
+
nodes.push(node);
|
|
414
|
+
}
|
|
769
415
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
416
|
+
sourceTile.unloadContent();
|
|
417
|
+
const firstNode = nodes[0];
|
|
418
|
+
await this._addChildrenWithNeighborsAndWriteFile({
|
|
419
|
+
parentNode: firstNode,
|
|
420
|
+
sourceTiles: sourceTile.children,
|
|
421
|
+
parentId: firstNode.id,
|
|
422
|
+
level: level + 1
|
|
423
|
+
});
|
|
424
|
+
return nodes;
|
|
425
|
+
}
|
|
773
426
|
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
break;
|
|
427
|
+
_convertAttributeStorageInfo(sourceTileContent) {
|
|
428
|
+
const batchTable = sourceTileContent && sourceTileContent.batchTableJson;
|
|
777
429
|
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
430
|
+
if (batchTable && !this.layers0.attributeStorageInfo.length) {
|
|
431
|
+
this._convertBatchTableInfoToNodeAttributes(batchTable);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
781
434
|
|
|
782
|
-
|
|
435
|
+
async _convertResources(sourceTile) {
|
|
436
|
+
if (!sourceTile.content || sourceTile.content.type !== 'b3dm') {
|
|
437
|
+
return null;
|
|
438
|
+
}
|
|
783
439
|
|
|
784
|
-
|
|
785
|
-
|
|
440
|
+
const resourcesData = await (0, _geometryConverter.default)(sourceTile.content, Number(this.nodePages.nodesCounter), this.featuresHashArray, this.layers0.attributeStorageInfo, this.options.draco);
|
|
441
|
+
return resourcesData;
|
|
442
|
+
}
|
|
786
443
|
|
|
787
|
-
|
|
444
|
+
_createNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources) {
|
|
445
|
+
const {
|
|
446
|
+
meshMaterial,
|
|
447
|
+
texture,
|
|
448
|
+
vertexCount,
|
|
449
|
+
featureCount,
|
|
450
|
+
geometry
|
|
451
|
+
} = resources;
|
|
452
|
+
const nodeInPage = {
|
|
453
|
+
lodThreshold: maxScreenThresholdSQ.maxError,
|
|
454
|
+
obb: boundingVolumes.obb,
|
|
455
|
+
children: [],
|
|
456
|
+
mesh: null
|
|
457
|
+
};
|
|
788
458
|
|
|
789
|
-
|
|
459
|
+
if (geometry && sourceTile.content && sourceTile.content.type === 'b3dm') {
|
|
460
|
+
nodeInPage.mesh = {
|
|
461
|
+
geometry: {
|
|
462
|
+
definition: texture ? 0 : 1
|
|
463
|
+
},
|
|
464
|
+
attribute: {}
|
|
465
|
+
};
|
|
466
|
+
}
|
|
790
467
|
|
|
791
|
-
|
|
792
|
-
case "end":
|
|
793
|
-
return _context9.stop();
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
}, _callee9, this, [[1, 38, 41, 44], [10, 21, 24, 27]]);
|
|
797
|
-
}));
|
|
468
|
+
const nodeId = this.nodePages.push(nodeInPage, parentId);
|
|
798
469
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
470
|
+
if (meshMaterial) {
|
|
471
|
+
this.nodePages.updateMaterialByNodeId(nodeId, this._findOrCreateMaterial(meshMaterial));
|
|
472
|
+
}
|
|
802
473
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
value: function () {
|
|
808
|
-
var _createNode2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee10(parentTile, sourceTile, parentId, level) {
|
|
809
|
-
var _sourceTile$content;
|
|
810
|
-
|
|
811
|
-
var boundingVolumes, lodSelection, maxScreenThresholdSQ, batchTable, resourcesData, nodes, emptyResources, _iterator5, _step5, resources, nodeInPage, node, _console, firstNode;
|
|
812
|
-
|
|
813
|
-
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
814
|
-
while (1) {
|
|
815
|
-
switch (_context10.prev = _context10.next) {
|
|
816
|
-
case 0:
|
|
817
|
-
if (this.validate) {
|
|
818
|
-
this._checkAddRefinementTypeForTile(sourceTile);
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
_context10.next = 3;
|
|
822
|
-
return this._updateTilesetOptions();
|
|
823
|
-
|
|
824
|
-
case 3:
|
|
825
|
-
_context10.next = 5;
|
|
826
|
-
return this.sourceTileset._loadTile(sourceTile);
|
|
827
|
-
|
|
828
|
-
case 5:
|
|
829
|
-
boundingVolumes = (0, _coordinateConverter.createBoundingVolumes)(sourceTile, this.geoidHeightModel);
|
|
830
|
-
lodSelection = (0, _lodConversionUtils.convertGeometricErrorToScreenThreshold)(sourceTile, boundingVolumes);
|
|
831
|
-
maxScreenThresholdSQ = lodSelection.find(function (val) {
|
|
832
|
-
return val.metricType === 'maxScreenThresholdSQ';
|
|
833
|
-
}) || {
|
|
834
|
-
maxError: 0
|
|
835
|
-
};
|
|
836
|
-
batchTable = sourceTile === null || sourceTile === void 0 ? void 0 : (_sourceTile$content = sourceTile.content) === null || _sourceTile$content === void 0 ? void 0 : _sourceTile$content.batchTableJson;
|
|
837
|
-
|
|
838
|
-
if (batchTable) {
|
|
839
|
-
this._convertAttributeStorageInfo(sourceTile.content);
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
_context10.next = 12;
|
|
843
|
-
return this._convertResources(sourceTile);
|
|
844
|
-
|
|
845
|
-
case 12:
|
|
846
|
-
resourcesData = _context10.sent;
|
|
847
|
-
nodes = [];
|
|
848
|
-
emptyResources = {
|
|
849
|
-
geometry: null,
|
|
850
|
-
compressedGeometry: null,
|
|
851
|
-
texture: null,
|
|
852
|
-
sharedResources: null,
|
|
853
|
-
meshMaterial: null,
|
|
854
|
-
vertexCount: null,
|
|
855
|
-
attributes: null,
|
|
856
|
-
featureCount: null
|
|
857
|
-
};
|
|
858
|
-
_iterator5 = _createForOfIteratorHelper(resourcesData || [emptyResources]);
|
|
859
|
-
_context10.prev = 16;
|
|
860
|
-
|
|
861
|
-
_iterator5.s();
|
|
862
|
-
|
|
863
|
-
case 18:
|
|
864
|
-
if ((_step5 = _iterator5.n()).done) {
|
|
865
|
-
_context10.next = 29;
|
|
866
|
-
break;
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
resources = _step5.value;
|
|
870
|
-
nodeInPage = this._createNodeInNodePages(maxScreenThresholdSQ, boundingVolumes, sourceTile, parentId, resources);
|
|
871
|
-
node = this._createNodeIndexDocument(parentTile, boundingVolumes, lodSelection, nodeInPage, resources);
|
|
872
|
-
|
|
873
|
-
if (!nodeInPage.mesh) {
|
|
874
|
-
_context10.next = 25;
|
|
875
|
-
break;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
_context10.next = 25;
|
|
879
|
-
return this._writeResources(resources, node.path);
|
|
880
|
-
|
|
881
|
-
case 25:
|
|
882
|
-
if (this.validate) {
|
|
883
|
-
this.boundingVolumeWarnings = (0, _nodeDebug.validateNodeBoundingVolumes)(node);
|
|
884
|
-
|
|
885
|
-
if (this.boundingVolumeWarnings && this.boundingVolumeWarnings.length) {
|
|
886
|
-
(_console = console).warn.apply(_console, ['Bounding Volume Warnings: '].concat((0, _toConsumableArray2.default)(this.boundingVolumeWarnings)));
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
nodes.push(node);
|
|
891
|
-
|
|
892
|
-
case 27:
|
|
893
|
-
_context10.next = 18;
|
|
894
|
-
break;
|
|
895
|
-
|
|
896
|
-
case 29:
|
|
897
|
-
_context10.next = 34;
|
|
898
|
-
break;
|
|
899
|
-
|
|
900
|
-
case 31:
|
|
901
|
-
_context10.prev = 31;
|
|
902
|
-
_context10.t0 = _context10["catch"](16);
|
|
903
|
-
|
|
904
|
-
_iterator5.e(_context10.t0);
|
|
905
|
-
|
|
906
|
-
case 34:
|
|
907
|
-
_context10.prev = 34;
|
|
908
|
-
|
|
909
|
-
_iterator5.f();
|
|
910
|
-
|
|
911
|
-
return _context10.finish(34);
|
|
912
|
-
|
|
913
|
-
case 37:
|
|
914
|
-
sourceTile.unloadContent();
|
|
915
|
-
firstNode = nodes[0];
|
|
916
|
-
_context10.next = 41;
|
|
917
|
-
return this._addChildrenWithNeighborsAndWriteFile({
|
|
918
|
-
parentNode: firstNode,
|
|
919
|
-
sourceTiles: sourceTile.children,
|
|
920
|
-
parentId: firstNode.id,
|
|
921
|
-
level: level + 1
|
|
922
|
-
});
|
|
923
|
-
|
|
924
|
-
case 41:
|
|
925
|
-
return _context10.abrupt("return", nodes);
|
|
926
|
-
|
|
927
|
-
case 42:
|
|
928
|
-
case "end":
|
|
929
|
-
return _context10.stop();
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
}, _callee10, this, [[16, 31, 34, 37]]);
|
|
933
|
-
}));
|
|
474
|
+
if (texture) {
|
|
475
|
+
const texelCountHint = texture.image.height * texture.image.width;
|
|
476
|
+
this.nodePages.updateTexelCountHintByNodeId(nodeId, texelCountHint);
|
|
477
|
+
}
|
|
934
478
|
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
479
|
+
if (vertexCount) {
|
|
480
|
+
this.vertexCounter += vertexCount;
|
|
481
|
+
this.nodePages.updateVertexCountByNodeId(nodeId, vertexCount);
|
|
482
|
+
}
|
|
938
483
|
|
|
939
|
-
|
|
940
|
-
}()
|
|
941
|
-
}, {
|
|
942
|
-
key: "_convertAttributeStorageInfo",
|
|
943
|
-
value: function _convertAttributeStorageInfo(sourceTileContent) {
|
|
944
|
-
var batchTable = sourceTileContent && sourceTileContent.batchTableJson;
|
|
484
|
+
this.nodePages.updateNodeAttributeByNodeId(nodeId);
|
|
945
485
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
}
|
|
486
|
+
if (featureCount) {
|
|
487
|
+
this.nodePages.updateFeatureCountByNodeId(nodeId, featureCount);
|
|
949
488
|
}
|
|
950
|
-
}, {
|
|
951
|
-
key: "_convertResources",
|
|
952
|
-
value: function () {
|
|
953
|
-
var _convertResources2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee11(sourceTile) {
|
|
954
|
-
var resourcesData;
|
|
955
|
-
return _regenerator.default.wrap(function _callee11$(_context11) {
|
|
956
|
-
while (1) {
|
|
957
|
-
switch (_context11.prev = _context11.next) {
|
|
958
|
-
case 0:
|
|
959
|
-
if (!(!sourceTile.content || sourceTile.content.type !== 'b3dm')) {
|
|
960
|
-
_context11.next = 2;
|
|
961
|
-
break;
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
return _context11.abrupt("return", null);
|
|
965
|
-
|
|
966
|
-
case 2:
|
|
967
|
-
_context11.next = 4;
|
|
968
|
-
return (0, _geometryConverter.default)(sourceTile.content, Number(this.nodePages.nodesCounter), this.featuresHashArray, this.layers0.attributeStorageInfo, this.options.draco);
|
|
969
|
-
|
|
970
|
-
case 4:
|
|
971
|
-
resourcesData = _context11.sent;
|
|
972
|
-
return _context11.abrupt("return", resourcesData);
|
|
973
|
-
|
|
974
|
-
case 6:
|
|
975
|
-
case "end":
|
|
976
|
-
return _context11.stop();
|
|
977
|
-
}
|
|
978
|
-
}
|
|
979
|
-
}, _callee11, this);
|
|
980
|
-
}));
|
|
981
489
|
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
}
|
|
490
|
+
return nodeInPage;
|
|
491
|
+
}
|
|
985
492
|
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
493
|
+
_createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources) {
|
|
494
|
+
const {
|
|
495
|
+
texture,
|
|
496
|
+
attributes
|
|
497
|
+
} = resources;
|
|
498
|
+
const nodeId = nodeInPage.index;
|
|
499
|
+
const nodeData = {
|
|
500
|
+
version: parentNode.version,
|
|
501
|
+
id: nodeId.toString(),
|
|
502
|
+
path: nodeId.toString(),
|
|
503
|
+
level: parentNode.level + 1,
|
|
504
|
+
...boundingVolumes,
|
|
505
|
+
lodSelection,
|
|
506
|
+
parentNode: {
|
|
507
|
+
id: parentNode.id,
|
|
508
|
+
href: "../".concat(parentNode.id),
|
|
509
|
+
mbs: parentNode.mbs,
|
|
510
|
+
obb: parentNode.obb
|
|
511
|
+
},
|
|
512
|
+
children: [],
|
|
513
|
+
neighbors: []
|
|
514
|
+
};
|
|
515
|
+
const node = (0, _jsonMapTransform.default)(nodeData, _node.NODE);
|
|
516
|
+
|
|
517
|
+
if (nodeInPage.mesh) {
|
|
518
|
+
node.geometryData = [{
|
|
519
|
+
href: './geometries/0'
|
|
520
|
+
}];
|
|
521
|
+
node.sharedResource = {
|
|
522
|
+
href: './shared'
|
|
1000
523
|
};
|
|
1001
524
|
|
|
1002
|
-
if (sourceTile.content && sourceTile.content.type === 'b3dm') {
|
|
1003
|
-
nodeInPage.mesh = {
|
|
1004
|
-
geometry: {
|
|
1005
|
-
definition: texture ? 0 : 1
|
|
1006
|
-
},
|
|
1007
|
-
attribute: {}
|
|
1008
|
-
};
|
|
1009
|
-
}
|
|
1010
|
-
|
|
1011
|
-
var nodeId = this.nodePages.push(nodeInPage, parentId);
|
|
1012
|
-
|
|
1013
|
-
if (meshMaterial) {
|
|
1014
|
-
this.nodePages.updateMaterialByNodeId(nodeId, this._findOrCreateMaterial(meshMaterial));
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
525
|
if (texture) {
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
this.vertexCounter += vertexCount;
|
|
1024
|
-
this.nodePages.updateVertexCountByNodeId(nodeId, vertexCount);
|
|
526
|
+
node.textureData = [{
|
|
527
|
+
href: './textures/0'
|
|
528
|
+
}, {
|
|
529
|
+
href: './textures/1'
|
|
530
|
+
}];
|
|
1025
531
|
}
|
|
1026
532
|
|
|
1027
|
-
this.
|
|
533
|
+
if (attributes && attributes.length && this.layers0.attributeStorageInfo && this.layers0.attributeStorageInfo.length) {
|
|
534
|
+
node.attributeData = [];
|
|
1028
535
|
|
|
1029
|
-
|
|
1030
|
-
|
|
536
|
+
for (let index = 0; index < attributes.length; index++) {
|
|
537
|
+
const folderName = this.layers0.attributeStorageInfo[index].key;
|
|
538
|
+
node.attributeData.push({
|
|
539
|
+
href: "./attributes/".concat(folderName, "/0")
|
|
540
|
+
});
|
|
541
|
+
}
|
|
1031
542
|
}
|
|
1032
|
-
|
|
1033
|
-
return nodeInPage;
|
|
1034
543
|
}
|
|
1035
|
-
}, {
|
|
1036
|
-
key: "_createNodeIndexDocument",
|
|
1037
|
-
value: function _createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources) {
|
|
1038
|
-
var texture = resources.texture,
|
|
1039
|
-
attributes = resources.attributes;
|
|
1040
|
-
var nodeId = nodeInPage.index;
|
|
1041
|
-
|
|
1042
|
-
var nodeData = _objectSpread(_objectSpread({
|
|
1043
|
-
version: parentNode.version,
|
|
1044
|
-
id: nodeId.toString(),
|
|
1045
|
-
path: nodeId.toString(),
|
|
1046
|
-
level: parentNode.level + 1
|
|
1047
|
-
}, boundingVolumes), {}, {
|
|
1048
|
-
lodSelection: lodSelection,
|
|
1049
|
-
parentNode: {
|
|
1050
|
-
id: parentNode.id,
|
|
1051
|
-
href: "../".concat(parentNode.id),
|
|
1052
|
-
mbs: parentNode.mbs,
|
|
1053
|
-
obb: parentNode.obb
|
|
1054
|
-
},
|
|
1055
|
-
children: [],
|
|
1056
|
-
neighbors: []
|
|
1057
|
-
});
|
|
1058
|
-
|
|
1059
|
-
var node = (0, _jsonMapTransform.default)(nodeData, _node.NODE);
|
|
1060
|
-
|
|
1061
|
-
if (nodeInPage.mesh) {
|
|
1062
|
-
node.geometryData = [{
|
|
1063
|
-
href: './geometries/0'
|
|
1064
|
-
}];
|
|
1065
|
-
node.sharedResource = {
|
|
1066
|
-
href: './shared'
|
|
1067
|
-
};
|
|
1068
|
-
|
|
1069
|
-
if (texture) {
|
|
1070
|
-
node.textureData = [{
|
|
1071
|
-
href: './textures/0'
|
|
1072
|
-
}];
|
|
1073
|
-
}
|
|
1074
544
|
|
|
1075
|
-
|
|
1076
|
-
|
|
545
|
+
return node;
|
|
546
|
+
}
|
|
1077
547
|
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
548
|
+
async _writeResources(resources, nodePath) {
|
|
549
|
+
const {
|
|
550
|
+
geometry: geometryBuffer,
|
|
551
|
+
compressedGeometry,
|
|
552
|
+
texture,
|
|
553
|
+
sharedResources,
|
|
554
|
+
attributes
|
|
555
|
+
} = resources;
|
|
556
|
+
const childPath = (0, _path.join)(this.layers0Path, 'nodes', nodePath);
|
|
557
|
+
const slpkChildPath = (0, _path.join)('nodes', nodePath);
|
|
558
|
+
await this._writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath);
|
|
559
|
+
await this._writeShared(sharedResources, childPath, slpkChildPath, nodePath);
|
|
560
|
+
await this._writeTexture(texture, childPath, slpkChildPath);
|
|
561
|
+
await this._writeAttributes(attributes, childPath, slpkChildPath);
|
|
562
|
+
}
|
|
1086
563
|
|
|
1087
|
-
|
|
564
|
+
async _writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath) {
|
|
565
|
+
if (this.options.slpk) {
|
|
566
|
+
const slpkGeometryPath = (0, _path.join)(childPath, 'geometries');
|
|
567
|
+
this.fileMap["".concat(slpkChildPath, "/geometries/0.bin.gz")] = await (0, _fileUtils.writeFileForSlpk)(slpkGeometryPath, geometryBuffer, '0.bin');
|
|
568
|
+
} else {
|
|
569
|
+
const geometryPath = (0, _path.join)(childPath, 'geometries/0/');
|
|
570
|
+
await (0, _fileUtils.writeFile)(geometryPath, geometryBuffer, 'index.bin');
|
|
1088
571
|
}
|
|
1089
|
-
}, {
|
|
1090
|
-
key: "_writeResources",
|
|
1091
|
-
value: function () {
|
|
1092
|
-
var _writeResources2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee12(resources, nodePath) {
|
|
1093
|
-
var geometryBuffer, compressedGeometry, texture, sharedResources, attributes, childPath, slpkChildPath;
|
|
1094
|
-
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
1095
|
-
while (1) {
|
|
1096
|
-
switch (_context12.prev = _context12.next) {
|
|
1097
|
-
case 0:
|
|
1098
|
-
geometryBuffer = resources.geometry, compressedGeometry = resources.compressedGeometry, texture = resources.texture, sharedResources = resources.sharedResources, attributes = resources.attributes;
|
|
1099
|
-
childPath = (0, _path.join)(this.layers0Path, 'nodes', nodePath);
|
|
1100
|
-
slpkChildPath = (0, _path.join)('nodes', nodePath);
|
|
1101
|
-
_context12.next = 5;
|
|
1102
|
-
return this._writeGeometries(geometryBuffer, compressedGeometry, childPath, slpkChildPath);
|
|
1103
|
-
|
|
1104
|
-
case 5:
|
|
1105
|
-
_context12.next = 7;
|
|
1106
|
-
return this._writeShared(sharedResources, childPath, slpkChildPath, nodePath);
|
|
1107
|
-
|
|
1108
|
-
case 7:
|
|
1109
|
-
_context12.next = 9;
|
|
1110
|
-
return this._writeTexture(texture, childPath, slpkChildPath);
|
|
1111
|
-
|
|
1112
|
-
case 9:
|
|
1113
|
-
_context12.next = 11;
|
|
1114
|
-
return this._writeAttributes(attributes, childPath, slpkChildPath);
|
|
1115
|
-
|
|
1116
|
-
case 11:
|
|
1117
|
-
case "end":
|
|
1118
|
-
return _context12.stop();
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
}, _callee12, this);
|
|
1122
|
-
}));
|
|
1123
572
|
|
|
1124
|
-
|
|
1125
|
-
|
|
573
|
+
if (this.options.draco) {
|
|
574
|
+
if (this.options.slpk) {
|
|
575
|
+
const slpkCompressedGeometryPath = (0, _path.join)(childPath, 'geometries');
|
|
576
|
+
this.fileMap["".concat(slpkChildPath, "/geometries/1.bin.gz")] = await (0, _fileUtils.writeFileForSlpk)(slpkCompressedGeometryPath, compressedGeometry, '1.bin');
|
|
577
|
+
} else {
|
|
578
|
+
const compressedGeometryPath = (0, _path.join)(childPath, 'geometries/1/');
|
|
579
|
+
await (0, _fileUtils.writeFile)(compressedGeometryPath, compressedGeometry, 'index.bin');
|
|
1126
580
|
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
1127
583
|
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
break;
|
|
1142
|
-
}
|
|
1143
|
-
|
|
1144
|
-
slpkGeometryPath = (0, _path.join)(childPath, 'geometries');
|
|
1145
|
-
_context13.next = 4;
|
|
1146
|
-
return (0, _fileUtils.writeFileForSlpk)(slpkGeometryPath, geometryBuffer, '0.bin');
|
|
1147
|
-
|
|
1148
|
-
case 4:
|
|
1149
|
-
this.fileMap["".concat(slpkChildPath, "/geometries/0.bin.gz")] = _context13.sent;
|
|
1150
|
-
_context13.next = 10;
|
|
1151
|
-
break;
|
|
1152
|
-
|
|
1153
|
-
case 7:
|
|
1154
|
-
geometryPath = (0, _path.join)(childPath, 'geometries/0/');
|
|
1155
|
-
_context13.next = 10;
|
|
1156
|
-
return (0, _fileUtils.writeFile)(geometryPath, geometryBuffer, 'index.bin');
|
|
1157
|
-
|
|
1158
|
-
case 10:
|
|
1159
|
-
if (!this.options.draco) {
|
|
1160
|
-
_context13.next = 21;
|
|
1161
|
-
break;
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
if (!this.options.slpk) {
|
|
1165
|
-
_context13.next = 18;
|
|
1166
|
-
break;
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
slpkCompressedGeometryPath = (0, _path.join)(childPath, 'geometries');
|
|
1170
|
-
_context13.next = 15;
|
|
1171
|
-
return (0, _fileUtils.writeFileForSlpk)(slpkCompressedGeometryPath, compressedGeometry, '1.bin');
|
|
1172
|
-
|
|
1173
|
-
case 15:
|
|
1174
|
-
this.fileMap["".concat(slpkChildPath, "/geometries/1.bin.gz")] = _context13.sent;
|
|
1175
|
-
_context13.next = 21;
|
|
1176
|
-
break;
|
|
1177
|
-
|
|
1178
|
-
case 18:
|
|
1179
|
-
compressedGeometryPath = (0, _path.join)(childPath, 'geometries/1/');
|
|
1180
|
-
_context13.next = 21;
|
|
1181
|
-
return (0, _fileUtils.writeFile)(compressedGeometryPath, compressedGeometry, 'index.bin');
|
|
1182
|
-
|
|
1183
|
-
case 21:
|
|
1184
|
-
case "end":
|
|
1185
|
-
return _context13.stop();
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
}, _callee13, this);
|
|
1189
|
-
}));
|
|
584
|
+
async _writeShared(sharedResources, childPath, slpkChildPath, nodePath) {
|
|
585
|
+
sharedResources.nodePath = nodePath;
|
|
586
|
+
const sharedData = (0, _jsonMapTransform.default)(sharedResources, _sharedResources.SHARED_RESOURCES_TEMPLATE);
|
|
587
|
+
const sharedDataStr = JSON.stringify(sharedData);
|
|
588
|
+
|
|
589
|
+
if (this.options.slpk) {
|
|
590
|
+
const slpkSharedPath = (0, _path.join)(childPath, 'shared');
|
|
591
|
+
this.fileMap["".concat(slpkChildPath, "/shared/sharedResource.json.gz")] = await (0, _fileUtils.writeFileForSlpk)(slpkSharedPath, sharedDataStr, 'sharedResource.json');
|
|
592
|
+
} else {
|
|
593
|
+
const sharedPath = (0, _path.join)(childPath, 'shared/');
|
|
594
|
+
await (0, _fileUtils.writeFile)(sharedPath, sharedDataStr);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
1190
597
|
|
|
1191
|
-
|
|
1192
|
-
|
|
598
|
+
async _writeTexture(texture, childPath, slpkChildPath) {
|
|
599
|
+
if (texture) {
|
|
600
|
+
const format = this._getFormatByMimeType(texture.mimeType);
|
|
601
|
+
|
|
602
|
+
if (!this.layers0.textureSetDefinitions.length) {
|
|
603
|
+
this.layers0.textureSetDefinitions.push({
|
|
604
|
+
formats: [{
|
|
605
|
+
name: '0',
|
|
606
|
+
format
|
|
607
|
+
}, {
|
|
608
|
+
name: '1',
|
|
609
|
+
format: 'ktx2'
|
|
610
|
+
}]
|
|
611
|
+
});
|
|
1193
612
|
}
|
|
1194
613
|
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
}, {
|
|
1198
|
-
key: "_writeShared",
|
|
1199
|
-
value: function () {
|
|
1200
|
-
var _writeShared2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee14(sharedResources, childPath, slpkChildPath, nodePath) {
|
|
1201
|
-
var sharedData, sharedDataStr, slpkSharedPath, sharedPath;
|
|
1202
|
-
return _regenerator.default.wrap(function _callee14$(_context14) {
|
|
1203
|
-
while (1) {
|
|
1204
|
-
switch (_context14.prev = _context14.next) {
|
|
1205
|
-
case 0:
|
|
1206
|
-
sharedResources.nodePath = nodePath;
|
|
1207
|
-
sharedData = (0, _jsonMapTransform.default)(sharedResources, _sharedResources.SHARED_RESOURCES_TEMPLATE);
|
|
1208
|
-
sharedDataStr = JSON.stringify(sharedData);
|
|
1209
|
-
|
|
1210
|
-
if (!this.options.slpk) {
|
|
1211
|
-
_context14.next = 10;
|
|
1212
|
-
break;
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
slpkSharedPath = (0, _path.join)(childPath, 'shared');
|
|
1216
|
-
_context14.next = 7;
|
|
1217
|
-
return (0, _fileUtils.writeFileForSlpk)(slpkSharedPath, sharedDataStr, 'sharedResource.json');
|
|
1218
|
-
|
|
1219
|
-
case 7:
|
|
1220
|
-
this.fileMap["".concat(slpkChildPath, "/shared/sharedResource.json.gz")] = _context14.sent;
|
|
1221
|
-
_context14.next = 13;
|
|
1222
|
-
break;
|
|
1223
|
-
|
|
1224
|
-
case 10:
|
|
1225
|
-
sharedPath = (0, _path.join)(childPath, 'shared/');
|
|
1226
|
-
_context14.next = 13;
|
|
1227
|
-
return (0, _fileUtils.writeFile)(sharedPath, sharedDataStr);
|
|
1228
|
-
|
|
1229
|
-
case 13:
|
|
1230
|
-
case "end":
|
|
1231
|
-
return _context14.stop();
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
}, _callee14, this);
|
|
1235
|
-
}));
|
|
614
|
+
const textureData = texture.bufferView.data;
|
|
615
|
+
const ktx2TextureData = await (0, _core.encode)(texture.image, _textures.KTX2BasisUniversalTextureWriter);
|
|
1236
616
|
|
|
1237
|
-
|
|
1238
|
-
|
|
617
|
+
if (this.options.slpk) {
|
|
618
|
+
const slpkTexturePath = (0, _path.join)(childPath, 'textures');
|
|
619
|
+
const compress = false;
|
|
620
|
+
this.fileMap["".concat(slpkChildPath, "/textures/0.").concat(format)] = await (0, _fileUtils.writeFileForSlpk)(slpkTexturePath, textureData, "0.".concat(format), compress);
|
|
621
|
+
this.fileMap["".concat(slpkChildPath, "/textures/1.ktx2")] = await (0, _fileUtils.writeFileForSlpk)(slpkTexturePath, ktx2TextureData, "1.ktx2", compress);
|
|
622
|
+
} else {
|
|
623
|
+
const texturePath = (0, _path.join)(childPath, 'textures/0/');
|
|
624
|
+
await (0, _fileUtils.writeFile)(texturePath, textureData, "index.".concat(format));
|
|
625
|
+
const ktx2TexturePath = (0, _path.join)(childPath, 'textures/1/');
|
|
626
|
+
await (0, _fileUtils.writeFile)(ktx2TexturePath, ktx2TextureData, "index.ktx2");
|
|
1239
627
|
}
|
|
628
|
+
}
|
|
629
|
+
}
|
|
1240
630
|
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
break;
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
format = this._getFormatByMimeType(texture.mimeType);
|
|
1258
|
-
|
|
1259
|
-
if (!this.layers0.textureSetDefinitions.length) {
|
|
1260
|
-
this.layers0.textureSetDefinitions.push({
|
|
1261
|
-
formats: [{
|
|
1262
|
-
name: '0',
|
|
1263
|
-
format: format
|
|
1264
|
-
}]
|
|
1265
|
-
});
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
textureData = texture.bufferView.data;
|
|
1269
|
-
|
|
1270
|
-
if (!this.options.slpk) {
|
|
1271
|
-
_context15.next = 12;
|
|
1272
|
-
break;
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
slpkTexturePath = (0, _path.join)(childPath, 'textures');
|
|
1276
|
-
compress = false;
|
|
1277
|
-
_context15.next = 9;
|
|
1278
|
-
return (0, _fileUtils.writeFileForSlpk)(slpkTexturePath, textureData, "0.".concat(format), compress);
|
|
1279
|
-
|
|
1280
|
-
case 9:
|
|
1281
|
-
this.fileMap["".concat(slpkChildPath, "/textures/0.").concat(format)] = _context15.sent;
|
|
1282
|
-
_context15.next = 15;
|
|
1283
|
-
break;
|
|
1284
|
-
|
|
1285
|
-
case 12:
|
|
1286
|
-
texturePath = (0, _path.join)(childPath, 'textures/0/');
|
|
1287
|
-
_context15.next = 15;
|
|
1288
|
-
return (0, _fileUtils.writeFile)(texturePath, textureData, "index.".concat(format));
|
|
1289
|
-
|
|
1290
|
-
case 15:
|
|
1291
|
-
case "end":
|
|
1292
|
-
return _context15.stop();
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
}, _callee15, this);
|
|
1296
|
-
}));
|
|
1297
|
-
|
|
1298
|
-
function _writeTexture(_x31, _x32, _x33) {
|
|
1299
|
-
return _writeTexture2.apply(this, arguments);
|
|
631
|
+
async _writeAttributes(attributes, childPath, slpkChildPath) {
|
|
632
|
+
if (attributes.length && this.layers0.attributeStorageInfo && this.layers0.attributeStorageInfo.length) {
|
|
633
|
+
for (let index = 0; index < attributes.length; index++) {
|
|
634
|
+
const folderName = this.layers0.attributeStorageInfo[index].key;
|
|
635
|
+
const fileBuffer = new Uint8Array(attributes[index]);
|
|
636
|
+
|
|
637
|
+
if (this.options.slpk) {
|
|
638
|
+
const slpkAttributesPath = (0, _path.join)(childPath, 'attributes', folderName);
|
|
639
|
+
this.fileMap["".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz")] = await (0, _fileUtils.writeFileForSlpk)(slpkAttributesPath, fileBuffer, '0.bin');
|
|
640
|
+
} else {
|
|
641
|
+
const attributesPath = (0, _path.join)(childPath, "attributes/".concat(folderName, "/0"));
|
|
642
|
+
await (0, _fileUtils.writeFile)(attributesPath, fileBuffer, 'index.bin');
|
|
643
|
+
}
|
|
1300
644
|
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
1301
647
|
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
value: function () {
|
|
1307
|
-
var _writeAttributes2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee16(attributes, childPath, slpkChildPath) {
|
|
1308
|
-
var index, folderName, fileBuffer, slpkAttributesPath, attributesPath;
|
|
1309
|
-
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
1310
|
-
while (1) {
|
|
1311
|
-
switch (_context16.prev = _context16.next) {
|
|
1312
|
-
case 0:
|
|
1313
|
-
if (!(attributes.length && this.layers0.attributeStorageInfo && this.layers0.attributeStorageInfo.length)) {
|
|
1314
|
-
_context16.next = 18;
|
|
1315
|
-
break;
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
index = 0;
|
|
1319
|
-
|
|
1320
|
-
case 2:
|
|
1321
|
-
if (!(index < attributes.length)) {
|
|
1322
|
-
_context16.next = 18;
|
|
1323
|
-
break;
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
|
-
folderName = this.layers0.attributeStorageInfo[index].key;
|
|
1327
|
-
fileBuffer = new Uint8Array(attributes[index]);
|
|
1328
|
-
|
|
1329
|
-
if (!this.options.slpk) {
|
|
1330
|
-
_context16.next = 12;
|
|
1331
|
-
break;
|
|
1332
|
-
}
|
|
1333
|
-
|
|
1334
|
-
slpkAttributesPath = (0, _path.join)(childPath, 'attributes', folderName);
|
|
1335
|
-
_context16.next = 9;
|
|
1336
|
-
return (0, _fileUtils.writeFileForSlpk)(slpkAttributesPath, fileBuffer, '0.bin');
|
|
1337
|
-
|
|
1338
|
-
case 9:
|
|
1339
|
-
this.fileMap["".concat(slpkChildPath, "/attributes/").concat(folderName, ".bin.gz")] = _context16.sent;
|
|
1340
|
-
_context16.next = 15;
|
|
1341
|
-
break;
|
|
1342
|
-
|
|
1343
|
-
case 12:
|
|
1344
|
-
attributesPath = (0, _path.join)(childPath, "attributes/".concat(folderName, "/0"));
|
|
1345
|
-
_context16.next = 15;
|
|
1346
|
-
return (0, _fileUtils.writeFile)(attributesPath, fileBuffer, 'index.bin');
|
|
1347
|
-
|
|
1348
|
-
case 15:
|
|
1349
|
-
index++;
|
|
1350
|
-
_context16.next = 2;
|
|
1351
|
-
break;
|
|
1352
|
-
|
|
1353
|
-
case 18:
|
|
1354
|
-
case "end":
|
|
1355
|
-
return _context16.stop();
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
}, _callee16, this);
|
|
1359
|
-
}));
|
|
648
|
+
_getFormatByMimeType(mimeType) {
|
|
649
|
+
switch (mimeType) {
|
|
650
|
+
case 'image/jpeg':
|
|
651
|
+
return 'jpg';
|
|
1360
652
|
|
|
1361
|
-
|
|
1362
|
-
return
|
|
1363
|
-
}
|
|
653
|
+
case 'image/png':
|
|
654
|
+
return 'png';
|
|
1364
655
|
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
value: function _getFormatByMimeType(mimeType) {
|
|
1370
|
-
switch (mimeType) {
|
|
1371
|
-
case 'image/jpeg':
|
|
1372
|
-
return 'jpg';
|
|
656
|
+
default:
|
|
657
|
+
return 'jpg';
|
|
658
|
+
}
|
|
659
|
+
}
|
|
1373
660
|
|
|
1374
|
-
|
|
1375
|
-
|
|
661
|
+
_findOrCreateMaterial(material) {
|
|
662
|
+
const hash = (0, _md.default)(JSON.stringify(material));
|
|
1376
663
|
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
}
|
|
664
|
+
if (this.materialMap.has(hash)) {
|
|
665
|
+
return this.materialMap.get(hash);
|
|
1380
666
|
}
|
|
1381
|
-
}, {
|
|
1382
|
-
key: "_findOrCreateMaterial",
|
|
1383
|
-
value: function _findOrCreateMaterial(material) {
|
|
1384
|
-
var hash = (0, _md.default)(JSON.stringify(material));
|
|
1385
667
|
|
|
1386
|
-
|
|
1387
|
-
|
|
668
|
+
const newMaterialId = this.materialDefinitions.push(material) - 1;
|
|
669
|
+
this.materialMap.set(hash, newMaterialId);
|
|
670
|
+
return newMaterialId;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
_createdStorageAttribute(attributeIndex, key, attributeType) {
|
|
674
|
+
const storageAttribute = {
|
|
675
|
+
key: "f_".concat(attributeIndex),
|
|
676
|
+
name: key,
|
|
677
|
+
ordering: ['attributeValues'],
|
|
678
|
+
header: [{
|
|
679
|
+
property: 'count',
|
|
680
|
+
valueType: 'UInt32'
|
|
681
|
+
}],
|
|
682
|
+
attributeValues: {
|
|
683
|
+
valueType: 'Int32',
|
|
684
|
+
valuesPerElement: 1
|
|
1388
685
|
}
|
|
686
|
+
};
|
|
1389
687
|
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
}
|
|
1394
|
-
}, {
|
|
1395
|
-
key: "_createdStorageAttribute",
|
|
1396
|
-
value: function _createdStorageAttribute(attributeIndex, key, attributeType) {
|
|
1397
|
-
var storageAttribute = {
|
|
1398
|
-
key: "f_".concat(attributeIndex),
|
|
1399
|
-
name: key,
|
|
1400
|
-
ordering: ['attributeValues'],
|
|
1401
|
-
header: [{
|
|
1402
|
-
property: 'count',
|
|
1403
|
-
valueType: 'UInt32'
|
|
1404
|
-
}],
|
|
1405
|
-
attributeValues: {
|
|
1406
|
-
valueType: 'Int32',
|
|
1407
|
-
valuesPerElement: 1
|
|
1408
|
-
}
|
|
1409
|
-
};
|
|
688
|
+
switch (attributeType) {
|
|
689
|
+
case OBJECT_ID_TYPE:
|
|
690
|
+
this._setupIdAttribute(storageAttribute);
|
|
1410
691
|
|
|
1411
|
-
|
|
1412
|
-
case OBJECT_ID_TYPE:
|
|
1413
|
-
this._setupIdAttribute(storageAttribute);
|
|
692
|
+
break;
|
|
1414
693
|
|
|
1415
|
-
|
|
694
|
+
case STRING_TYPE:
|
|
695
|
+
this._setupStringAttribute(storageAttribute);
|
|
1416
696
|
|
|
1417
|
-
|
|
1418
|
-
this._setupStringAttribute(storageAttribute);
|
|
697
|
+
break;
|
|
1419
698
|
|
|
1420
|
-
|
|
699
|
+
case DOUBLE_TYPE:
|
|
700
|
+
this._setupDoubleAttribute(storageAttribute);
|
|
1421
701
|
|
|
1422
|
-
|
|
1423
|
-
this._setupDoubleAttribute(storageAttribute);
|
|
702
|
+
break;
|
|
1424
703
|
|
|
1425
|
-
|
|
704
|
+
case SHORT_INT_TYPE:
|
|
705
|
+
break;
|
|
1426
706
|
|
|
1427
|
-
|
|
1428
|
-
|
|
707
|
+
default:
|
|
708
|
+
this._setupStringAttribute(storageAttribute);
|
|
1429
709
|
|
|
1430
|
-
|
|
1431
|
-
this._setupStringAttribute(storageAttribute);
|
|
710
|
+
}
|
|
1432
711
|
|
|
1433
|
-
|
|
712
|
+
return storageAttribute;
|
|
713
|
+
}
|
|
1434
714
|
|
|
1435
|
-
|
|
715
|
+
getAttributeType(key, attribute) {
|
|
716
|
+
if (key === OBJECT_ID_TYPE) {
|
|
717
|
+
return OBJECT_ID_TYPE;
|
|
1436
718
|
}
|
|
1437
|
-
}, {
|
|
1438
|
-
key: "getAttributeType",
|
|
1439
|
-
value: function getAttributeType(key, attribute) {
|
|
1440
|
-
if (key === OBJECT_ID_TYPE) {
|
|
1441
|
-
return OBJECT_ID_TYPE;
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
if ((0, _typeof2.default)(attribute) === STRING_TYPE) {
|
|
1445
|
-
return STRING_TYPE;
|
|
1446
|
-
} else if (typeof attribute === 'number') {
|
|
1447
|
-
return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;
|
|
1448
|
-
}
|
|
1449
719
|
|
|
720
|
+
if (typeof attribute === STRING_TYPE) {
|
|
1450
721
|
return STRING_TYPE;
|
|
722
|
+
} else if (typeof attribute === 'number') {
|
|
723
|
+
return Number.isInteger(attribute) ? SHORT_INT_TYPE : DOUBLE_TYPE;
|
|
1451
724
|
}
|
|
1452
|
-
}, {
|
|
1453
|
-
key: "_setupStringAttribute",
|
|
1454
|
-
value: function _setupStringAttribute(storageAttribute) {
|
|
1455
|
-
storageAttribute.ordering.unshift('attributeByteCounts');
|
|
1456
|
-
storageAttribute.header.push({
|
|
1457
|
-
property: 'attributeValuesByteCount',
|
|
1458
|
-
valueType: 'UInt32'
|
|
1459
|
-
});
|
|
1460
|
-
storageAttribute.attributeValues = {
|
|
1461
|
-
valueType: 'String',
|
|
1462
|
-
encoding: 'UTF-8',
|
|
1463
|
-
valuesPerElement: 1
|
|
1464
|
-
};
|
|
1465
|
-
storageAttribute.attributeByteCounts = {
|
|
1466
|
-
valueType: 'UInt32',
|
|
1467
|
-
valuesPerElement: 1
|
|
1468
|
-
};
|
|
1469
|
-
}
|
|
1470
|
-
}, {
|
|
1471
|
-
key: "_setupIdAttribute",
|
|
1472
|
-
value: function _setupIdAttribute(storageAttribute) {
|
|
1473
|
-
storageAttribute.attributeValues = {
|
|
1474
|
-
valueType: 'Oid32',
|
|
1475
|
-
valuesPerElement: 1
|
|
1476
|
-
};
|
|
1477
|
-
}
|
|
1478
|
-
}, {
|
|
1479
|
-
key: "_setupDoubleAttribute",
|
|
1480
|
-
value: function _setupDoubleAttribute(storageAttribute) {
|
|
1481
|
-
storageAttribute.attributeValues = {
|
|
1482
|
-
valueType: 'Float64',
|
|
1483
|
-
valuesPerElement: 1
|
|
1484
|
-
};
|
|
1485
|
-
}
|
|
1486
|
-
}, {
|
|
1487
|
-
key: "_createFieldAttribute",
|
|
1488
|
-
value: function _createFieldAttribute(key, fieldAttributeType) {
|
|
1489
|
-
return {
|
|
1490
|
-
name: key,
|
|
1491
|
-
type: fieldAttributeType,
|
|
1492
|
-
alias: key
|
|
1493
|
-
};
|
|
1494
|
-
}
|
|
1495
|
-
}, {
|
|
1496
|
-
key: "_convertBatchTableInfoToNodeAttributes",
|
|
1497
|
-
value: function _convertBatchTableInfoToNodeAttributes(batchTable) {
|
|
1498
|
-
var attributeIndex = 0;
|
|
1499
725
|
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
726
|
+
return STRING_TYPE;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
_setupStringAttribute(storageAttribute) {
|
|
730
|
+
storageAttribute.ordering.unshift('attributeByteCounts');
|
|
731
|
+
storageAttribute.header.push({
|
|
732
|
+
property: 'attributeValuesByteCount',
|
|
733
|
+
valueType: 'UInt32'
|
|
734
|
+
});
|
|
735
|
+
storageAttribute.attributeValues = {
|
|
736
|
+
valueType: 'String',
|
|
737
|
+
encoding: 'UTF-8',
|
|
738
|
+
valuesPerElement: 1
|
|
739
|
+
};
|
|
740
|
+
storageAttribute.attributeByteCounts = {
|
|
741
|
+
valueType: 'UInt32',
|
|
742
|
+
valuesPerElement: 1
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
_setupIdAttribute(storageAttribute) {
|
|
747
|
+
storageAttribute.attributeValues = {
|
|
748
|
+
valueType: 'Oid32',
|
|
749
|
+
valuesPerElement: 1
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
_setupDoubleAttribute(storageAttribute) {
|
|
754
|
+
storageAttribute.attributeValues = {
|
|
755
|
+
valueType: 'Float64',
|
|
756
|
+
valuesPerElement: 1
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
_createFieldAttribute(key, fieldAttributeType) {
|
|
761
|
+
return {
|
|
762
|
+
name: key,
|
|
763
|
+
type: fieldAttributeType,
|
|
764
|
+
alias: key
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
_convertBatchTableInfoToNodeAttributes(batchTable) {
|
|
769
|
+
let attributeIndex = 0;
|
|
770
|
+
const batchTableWithObjectId = {
|
|
771
|
+
OBJECTID: [0],
|
|
772
|
+
...batchTable
|
|
773
|
+
};
|
|
1503
774
|
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
775
|
+
for (const key in batchTableWithObjectId) {
|
|
776
|
+
const firstAttribute = batchTableWithObjectId[key][0];
|
|
777
|
+
const attributeType = this.getAttributeType(key, firstAttribute);
|
|
1507
778
|
|
|
1508
|
-
|
|
779
|
+
const storageAttribute = this._createdStorageAttribute(attributeIndex, key, attributeType);
|
|
1509
780
|
|
|
1510
|
-
|
|
781
|
+
const fieldAttributeType = this._getFieldAttributeType(attributeType);
|
|
1511
782
|
|
|
1512
|
-
|
|
783
|
+
const fieldAttribute = this._createFieldAttribute(key, fieldAttributeType);
|
|
1513
784
|
|
|
1514
|
-
|
|
785
|
+
const popupInfo = this._createPopupInfo(batchTableWithObjectId);
|
|
1515
786
|
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
}
|
|
787
|
+
this.layers0.attributeStorageInfo.push(storageAttribute);
|
|
788
|
+
this.layers0.fields.push(fieldAttribute);
|
|
789
|
+
this.layers0.popupInfo = popupInfo;
|
|
790
|
+
this.layers0.layerType = _3D_OBJECT_LAYER_TYPE;
|
|
791
|
+
attributeIndex += 1;
|
|
1522
792
|
}
|
|
1523
|
-
}
|
|
1524
|
-
key: "_getFieldAttributeType",
|
|
1525
|
-
value: function _getFieldAttributeType(attributeType) {
|
|
1526
|
-
switch (attributeType) {
|
|
1527
|
-
case OBJECT_ID_TYPE:
|
|
1528
|
-
return 'esriFieldTypeOID';
|
|
793
|
+
}
|
|
1529
794
|
|
|
1530
|
-
|
|
1531
|
-
|
|
795
|
+
_getFieldAttributeType(attributeType) {
|
|
796
|
+
switch (attributeType) {
|
|
797
|
+
case OBJECT_ID_TYPE:
|
|
798
|
+
return 'esriFieldTypeOID';
|
|
1532
799
|
|
|
1533
|
-
|
|
1534
|
-
|
|
800
|
+
case STRING_TYPE:
|
|
801
|
+
return 'esriFieldTypeString';
|
|
1535
802
|
|
|
1536
|
-
|
|
1537
|
-
|
|
803
|
+
case SHORT_INT_TYPE:
|
|
804
|
+
return 'esriFieldTypeInteger';
|
|
1538
805
|
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
806
|
+
case DOUBLE_TYPE:
|
|
807
|
+
return 'esriFieldTypeDouble';
|
|
808
|
+
|
|
809
|
+
default:
|
|
810
|
+
return 'esriFieldTypeString';
|
|
1542
811
|
}
|
|
1543
|
-
}
|
|
1544
|
-
key: "_createPopupInfo",
|
|
1545
|
-
value: function _createPopupInfo(batchTable) {
|
|
1546
|
-
var title = '{OBJECTID}';
|
|
1547
|
-
var mediaInfos = [];
|
|
1548
|
-
var fieldInfos = [];
|
|
1549
|
-
var popupElements = [];
|
|
1550
|
-
var expressionInfos = [];
|
|
1551
|
-
|
|
1552
|
-
for (var _key2 in batchTable) {
|
|
1553
|
-
fieldInfos.push({
|
|
1554
|
-
fieldName: _key2,
|
|
1555
|
-
visible: true,
|
|
1556
|
-
isEditable: false,
|
|
1557
|
-
label: _key2
|
|
1558
|
-
});
|
|
1559
|
-
}
|
|
812
|
+
}
|
|
1560
813
|
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
814
|
+
_createPopupInfo(batchTable) {
|
|
815
|
+
const title = '{OBJECTID}';
|
|
816
|
+
const mediaInfos = [];
|
|
817
|
+
const fieldInfos = [];
|
|
818
|
+
const popupElements = [];
|
|
819
|
+
const expressionInfos = [];
|
|
820
|
+
|
|
821
|
+
for (const key in batchTable) {
|
|
822
|
+
fieldInfos.push({
|
|
823
|
+
fieldName: key,
|
|
824
|
+
visible: true,
|
|
825
|
+
isEditable: false,
|
|
826
|
+
label: key
|
|
1564
827
|
});
|
|
1565
|
-
return {
|
|
1566
|
-
title: title,
|
|
1567
|
-
mediaInfos: mediaInfos,
|
|
1568
|
-
popupElements: popupElements,
|
|
1569
|
-
fieldInfos: fieldInfos,
|
|
1570
|
-
expressionInfos: expressionInfos
|
|
1571
|
-
};
|
|
1572
828
|
}
|
|
1573
|
-
}, {
|
|
1574
|
-
key: "_finishConversion",
|
|
1575
|
-
value: function () {
|
|
1576
|
-
var _finishConversion2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee17(params) {
|
|
1577
|
-
var _this$refinementCount, tilesCount, tilesWithAddRefineCount, addRefinementPercentage, filesSize, diff, conversionTime;
|
|
1578
|
-
|
|
1579
|
-
return _regenerator.default.wrap(function _callee17$(_context17) {
|
|
1580
|
-
while (1) {
|
|
1581
|
-
switch (_context17.prev = _context17.next) {
|
|
1582
|
-
case 0:
|
|
1583
|
-
_this$refinementCount = this.refinementCounter, tilesCount = _this$refinementCount.tilesCount, tilesWithAddRefineCount = _this$refinementCount.tilesWithAddRefineCount;
|
|
1584
|
-
addRefinementPercentage = tilesWithAddRefineCount ? tilesWithAddRefineCount / tilesCount * 100 : 0;
|
|
1585
|
-
_context17.next = 4;
|
|
1586
|
-
return (0, _statisticUtills.calculateFilesSize)(params);
|
|
1587
|
-
|
|
1588
|
-
case 4:
|
|
1589
|
-
filesSize = _context17.sent;
|
|
1590
|
-
diff = _process.default.hrtime(this.conversionStartTime);
|
|
1591
|
-
conversionTime = (0, _statisticUtills.timeConverter)(diff);
|
|
1592
|
-
console.log("------------------------------------------------");
|
|
1593
|
-
console.log("Finishing conversion of ".concat(_3D_TILES));
|
|
1594
|
-
console.log("Total conversion time: ".concat(conversionTime));
|
|
1595
|
-
console.log("Vertex count: ", this.vertexCounter);
|
|
1596
|
-
console.log("File(s) size: ", filesSize, ' bytes');
|
|
1597
|
-
console.log("Percentage of tiles with \"ADD\" refinement type:", addRefinementPercentage, '%');
|
|
1598
|
-
console.log("------------------------------------------------");
|
|
1599
|
-
|
|
1600
|
-
case 14:
|
|
1601
|
-
case "end":
|
|
1602
|
-
return _context17.stop();
|
|
1603
|
-
}
|
|
1604
|
-
}
|
|
1605
|
-
}, _callee17, this);
|
|
1606
|
-
}));
|
|
1607
829
|
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
830
|
+
popupElements.push({
|
|
831
|
+
fieldInfos,
|
|
832
|
+
type: 'fields'
|
|
833
|
+
});
|
|
834
|
+
return {
|
|
835
|
+
title,
|
|
836
|
+
mediaInfos,
|
|
837
|
+
popupElements,
|
|
838
|
+
fieldInfos,
|
|
839
|
+
expressionInfos
|
|
840
|
+
};
|
|
841
|
+
}
|
|
1611
842
|
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
case 3:
|
|
1632
|
-
preloadOptions = _context18.sent;
|
|
1633
|
-
this.refreshTokenTime = _process.default.hrtime();
|
|
1634
|
-
return _context18.abrupt("return", _objectSpread(_objectSpread({}, options), preloadOptions));
|
|
1635
|
-
|
|
1636
|
-
case 6:
|
|
1637
|
-
case "end":
|
|
1638
|
-
return _context18.stop();
|
|
1639
|
-
}
|
|
1640
|
-
}
|
|
1641
|
-
}, _callee18, this);
|
|
1642
|
-
}));
|
|
843
|
+
async _finishConversion(params) {
|
|
844
|
+
const {
|
|
845
|
+
tilesCount,
|
|
846
|
+
tilesWithAddRefineCount
|
|
847
|
+
} = this.refinementCounter;
|
|
848
|
+
const addRefinementPercentage = tilesWithAddRefineCount ? tilesWithAddRefineCount / tilesCount * 100 : 0;
|
|
849
|
+
const filesSize = await (0, _statisticUtills.calculateFilesSize)(params);
|
|
850
|
+
|
|
851
|
+
const diff = _process.default.hrtime(this.conversionStartTime);
|
|
852
|
+
|
|
853
|
+
const conversionTime = (0, _statisticUtills.timeConverter)(diff);
|
|
854
|
+
console.log("------------------------------------------------");
|
|
855
|
+
console.log("Finishing conversion of ".concat(_3D_TILES));
|
|
856
|
+
console.log("Total conversion time: ".concat(conversionTime));
|
|
857
|
+
console.log("Vertex count: ", this.vertexCounter);
|
|
858
|
+
console.log("File(s) size: ", filesSize, ' bytes');
|
|
859
|
+
console.log("Percentage of tiles with \"ADD\" refinement type:", addRefinementPercentage, '%');
|
|
860
|
+
console.log("------------------------------------------------");
|
|
861
|
+
}
|
|
1643
862
|
|
|
1644
|
-
|
|
1645
|
-
|
|
863
|
+
async _fetchPreloadOptions() {
|
|
864
|
+
if (!this.Loader.preload) {
|
|
865
|
+
return {};
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
const options = {
|
|
869
|
+
'cesium-ion': {
|
|
870
|
+
accessToken: this.options.token || ION_DEFAULT_TOKEN
|
|
1646
871
|
}
|
|
872
|
+
};
|
|
873
|
+
const preloadOptions = await this.Loader.preload(this.options.inputUrl, options);
|
|
874
|
+
this.refreshTokenTime = _process.default.hrtime();
|
|
875
|
+
return { ...options,
|
|
876
|
+
...preloadOptions
|
|
877
|
+
};
|
|
878
|
+
}
|
|
1647
879
|
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
}, {
|
|
1651
|
-
key: "_updateTilesetOptions",
|
|
1652
|
-
value: function () {
|
|
1653
|
-
var _updateTilesetOptions2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee19() {
|
|
1654
|
-
var diff, preloadOptions;
|
|
1655
|
-
return _regenerator.default.wrap(function _callee19$(_context19) {
|
|
1656
|
-
while (1) {
|
|
1657
|
-
switch (_context19.prev = _context19.next) {
|
|
1658
|
-
case 0:
|
|
1659
|
-
diff = _process.default.hrtime(this.refreshTokenTime);
|
|
1660
|
-
|
|
1661
|
-
if (!(diff[0] < REFRESH_TOKEN_TIMEOUT)) {
|
|
1662
|
-
_context19.next = 3;
|
|
1663
|
-
break;
|
|
1664
|
-
}
|
|
1665
|
-
|
|
1666
|
-
return _context19.abrupt("return");
|
|
1667
|
-
|
|
1668
|
-
case 3:
|
|
1669
|
-
this.refreshTokenTime = _process.default.hrtime();
|
|
1670
|
-
_context19.next = 6;
|
|
1671
|
-
return this._fetchPreloadOptions();
|
|
1672
|
-
|
|
1673
|
-
case 6:
|
|
1674
|
-
preloadOptions = _context19.sent;
|
|
1675
|
-
this.sourceTileset.options = _objectSpread(_objectSpread({}, this.sourceTileset.options), preloadOptions);
|
|
1676
|
-
|
|
1677
|
-
if (preloadOptions.headers) {
|
|
1678
|
-
this.sourceTileset.loadOptions.fetch = _objectSpread(_objectSpread({}, this.sourceTileset.loadOptions.fetch), {}, {
|
|
1679
|
-
headers: preloadOptions.headers
|
|
1680
|
-
});
|
|
1681
|
-
console.log('Authorization Bearer token has been updated');
|
|
1682
|
-
}
|
|
1683
|
-
|
|
1684
|
-
case 9:
|
|
1685
|
-
case "end":
|
|
1686
|
-
return _context19.stop();
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
}, _callee19, this);
|
|
1690
|
-
}));
|
|
880
|
+
async _updateTilesetOptions() {
|
|
881
|
+
const diff = _process.default.hrtime(this.refreshTokenTime);
|
|
1691
882
|
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
883
|
+
if (diff[0] < REFRESH_TOKEN_TIMEOUT) {
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
1695
886
|
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
var ADD_TILE_REFINEMENT = 1;
|
|
887
|
+
this.refreshTokenTime = _process.default.hrtime();
|
|
888
|
+
const preloadOptions = await this._fetchPreloadOptions();
|
|
889
|
+
this.sourceTileset.options = { ...this.sourceTileset.options,
|
|
890
|
+
...preloadOptions
|
|
891
|
+
};
|
|
1702
892
|
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
}
|
|
893
|
+
if (preloadOptions.headers) {
|
|
894
|
+
this.sourceTileset.loadOptions.fetch = { ...this.sourceTileset.loadOptions.fetch,
|
|
895
|
+
headers: preloadOptions.headers
|
|
896
|
+
};
|
|
897
|
+
console.log('Authorization Bearer token has been updated');
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
_checkAddRefinementTypeForTile(tile) {
|
|
902
|
+
const ADD_TILE_REFINEMENT = 1;
|
|
1707
903
|
|
|
1708
|
-
|
|
904
|
+
if (tile.refine === ADD_TILE_REFINEMENT) {
|
|
905
|
+
this.refinementCounter.tilesWithAddRefineCount += 1;
|
|
906
|
+
console.warn('This tile uses "ADD" type of refinement');
|
|
1709
907
|
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
}
|
|
908
|
+
|
|
909
|
+
this.refinementCounter.tilesCount += 1;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
}
|
|
1713
913
|
|
|
1714
914
|
exports.default = I3SConverter;
|
|
1715
915
|
//# sourceMappingURL=i3s-converter.js.map
|