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