@loaders.gl/tile-converter 3.4.14 → 3.4.15

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.
Files changed (91) hide show
  1. package/dist/3d-tiles-attributes-worker.js +1 -1
  2. package/dist/converter.min.js +78 -77
  3. package/dist/dist.min.js +2081 -1557
  4. package/dist/es5/3d-tiles-attributes-worker.js +3 -3
  5. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -1
  6. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +203 -417
  7. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  8. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +197 -266
  9. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  10. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +4 -6
  11. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
  12. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js +12 -12
  13. package/dist/es5/3d-tiles-converter/helpers/texture-atlas.js.map +1 -1
  14. package/dist/es5/3d-tiles-converter/json-templates/tileset.js +35 -51
  15. package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -1
  16. package/dist/es5/bundle.js +1 -1
  17. package/dist/es5/bundle.js.map +1 -1
  18. package/dist/es5/constants.js +1 -1
  19. package/dist/es5/constants.js.map +1 -1
  20. package/dist/es5/converter-cli.js +78 -133
  21. package/dist/es5/converter-cli.js.map +1 -1
  22. package/dist/es5/deps-installer/deps-installer.js +38 -110
  23. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  24. package/dist/es5/i3s-attributes-worker.js +3 -3
  25. package/dist/es5/i3s-attributes-worker.js.map +1 -1
  26. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js +31 -36
  27. package/dist/es5/i3s-converter/helpers/batch-ids-extensions.js.map +1 -1
  28. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +23 -23
  29. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  30. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +9 -27
  31. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
  32. package/dist/es5/i3s-converter/helpers/feature-attributes.js +27 -42
  33. package/dist/es5/i3s-converter/helpers/feature-attributes.js.map +1 -1
  34. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +97 -114
  35. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  36. package/dist/es5/i3s-converter/helpers/geometry-converter.js +523 -798
  37. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  38. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +24 -25
  39. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -1
  40. package/dist/es5/i3s-converter/helpers/node-debug.js +27 -25
  41. package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -1
  42. package/dist/es5/i3s-converter/helpers/node-index-document.js +165 -461
  43. package/dist/es5/i3s-converter/helpers/node-index-document.js.map +1 -1
  44. package/dist/es5/i3s-converter/helpers/node-pages.js +169 -474
  45. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  46. package/dist/es5/i3s-converter/i3s-converter.js +663 -1401
  47. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  48. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js +82 -92
  49. package/dist/es5/i3s-converter/json-templates/geometry-definitions.js.map +1 -1
  50. package/dist/es5/i3s-converter/json-templates/layers.js +130 -152
  51. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
  52. package/dist/es5/i3s-converter/json-templates/metadata.js +21 -23
  53. package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -1
  54. package/dist/es5/i3s-converter/json-templates/node.js +78 -89
  55. package/dist/es5/i3s-converter/json-templates/node.js.map +1 -1
  56. package/dist/es5/i3s-converter/json-templates/scene-server.js +27 -31
  57. package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -1
  58. package/dist/es5/i3s-converter/json-templates/shared-resources.js +110 -152
  59. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
  60. package/dist/es5/i3s-converter/json-templates/store.js +2 -4
  61. package/dist/es5/i3s-converter/json-templates/store.js.map +1 -1
  62. package/dist/es5/i3s-server/app.js +6 -6
  63. package/dist/es5/i3s-server/app.js.map +1 -1
  64. package/dist/es5/i3s-server/controllers/index-controller.js +20 -49
  65. package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
  66. package/dist/es5/i3s-server/routes/index.js +14 -33
  67. package/dist/es5/i3s-server/routes/index.js.map +1 -1
  68. package/dist/es5/index.js +2 -2
  69. package/dist/es5/lib/utils/compress-util.js +127 -295
  70. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  71. package/dist/es5/lib/utils/file-utils.js +65 -174
  72. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  73. package/dist/es5/lib/utils/lod-conversion-utils.js +9 -9
  74. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  75. package/dist/es5/lib/utils/queue.js +13 -38
  76. package/dist/es5/lib/utils/queue.js.map +1 -1
  77. package/dist/es5/lib/utils/statistic-utills.js +39 -117
  78. package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
  79. package/dist/es5/lib/utils/write-queue.js +74 -195
  80. package/dist/es5/lib/utils/write-queue.js.map +1 -1
  81. package/dist/es5/pgm-loader.js +3 -22
  82. package/dist/es5/pgm-loader.js.map +1 -1
  83. package/dist/es5/workers/3d-tiles-attributes-worker.js +5 -22
  84. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -1
  85. package/dist/es5/workers/i3s-attributes-worker.js +4 -25
  86. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -1
  87. package/dist/esm/3d-tiles-attributes-worker.js +1 -1
  88. package/dist/esm/deps-installer/deps-installer.js +1 -1
  89. package/dist/esm/i3s-attributes-worker.js +1 -1
  90. package/dist/esm/pgm-loader.js +1 -1
  91. package/package.json +15 -15
@@ -5,24 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.NodeIndexDocument = void 0;
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
9
  var _path = require("path");
14
10
  var _jsonMapTransform = _interopRequireDefault(require("json-map-transform"));
15
11
  var _uuid = require("uuid");
16
12
  var _fileUtils = require("../../lib/utils/file-utils");
17
13
  var _node = require("../json-templates/node");
18
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
20
- 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; } } }; }
21
- 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); }
22
- 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; }
23
- var NodeIndexDocument = function () {
24
- function NodeIndexDocument(id, converter) {
25
- (0, _classCallCheck2.default)(this, NodeIndexDocument);
14
+ class NodeIndexDocument {
15
+ constructor(id, converter) {
26
16
  (0, _defineProperty2.default)(this, "id", void 0);
27
17
  (0, _defineProperty2.default)(this, "inPageId", void 0);
28
18
  (0, _defineProperty2.default)(this, "data", null);
@@ -32,461 +22,175 @@ var NodeIndexDocument = function () {
32
22
  this.id = id === 0 ? 'root' : id.toString();
33
23
  this.converter = converter;
34
24
  }
35
- (0, _createClass2.default)(NodeIndexDocument, [{
36
- key: "addData",
37
- value: function () {
38
- var _addData = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(data) {
39
- return _regenerator.default.wrap(function _callee$(_context) {
40
- while (1) switch (_context.prev = _context.next) {
41
- case 0:
42
- if (!this.converter.options.instantNodeWriting) {
43
- _context.next = 5;
44
- break;
45
- }
46
- _context.next = 3;
47
- return this.write(data);
48
- case 3:
49
- _context.next = 6;
50
- break;
51
- case 5:
52
- this.data = data;
53
- case 6:
54
- return _context.abrupt("return", this);
55
- case 7:
56
- case "end":
57
- return _context.stop();
58
- }
59
- }, _callee, this);
60
- }));
61
- function addData(_x) {
62
- return _addData.apply(this, arguments);
63
- }
64
- return addData;
65
- }()
66
- }, {
67
- key: "addChildren",
68
- value: function () {
69
- var _addChildren = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(childNodes) {
70
- var newChildren, _iterator, _step, node, nodeData, data, _data$children;
71
- return _regenerator.default.wrap(function _callee2$(_context2) {
72
- while (1) switch (_context2.prev = _context2.next) {
73
- case 0:
74
- newChildren = [];
75
- _iterator = _createForOfIteratorHelper(childNodes);
76
- _context2.prev = 2;
77
- _iterator.s();
78
- case 4:
79
- if ((_step = _iterator.n()).done) {
80
- _context2.next = 12;
81
- break;
82
- }
83
- node = _step.value;
84
- _context2.next = 8;
85
- return node.load();
86
- case 8:
87
- nodeData = _context2.sent;
88
- newChildren.push({
89
- id: node.id,
90
- href: "../".concat(node.id),
91
- obb: nodeData.obb,
92
- mbs: nodeData.mbs
93
- });
94
- case 10:
95
- _context2.next = 4;
96
- break;
97
- case 12:
98
- _context2.next = 17;
99
- break;
100
- case 14:
101
- _context2.prev = 14;
102
- _context2.t0 = _context2["catch"](2);
103
- _iterator.e(_context2.t0);
104
- case 17:
105
- _context2.prev = 17;
106
- _iterator.f();
107
- return _context2.finish(17);
108
- case 20:
109
- this.children = this.children.concat(childNodes);
110
- data = this.data;
111
- if (!this.converter.options.instantNodeWriting) {
112
- _context2.next = 26;
113
- break;
114
- }
115
- _context2.next = 25;
116
- return this.load();
117
- case 25:
118
- data = _context2.sent;
119
- case 26:
120
- if (data) {
121
- data.children = (_data$children = data.children) !== null && _data$children !== void 0 ? _data$children : [];
122
- data.children = data.children.concat(newChildren);
123
- }
124
- if (!(this.converter.options.instantNodeWriting && data)) {
125
- _context2.next = 30;
126
- break;
127
- }
128
- _context2.next = 30;
129
- return this.write(data);
130
- case 30:
131
- case "end":
132
- return _context2.stop();
133
- }
134
- }, _callee2, this, [[2, 14, 17, 20]]);
135
- }));
136
- function addChildren(_x2) {
137
- return _addChildren.apply(this, arguments);
138
- }
139
- return addChildren;
140
- }()
141
- }, {
142
- key: "addNeighbors",
143
- value: function () {
144
- var _addNeighbors = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3() {
145
- var nodeData, _iterator2, _step2, _childNodeData$neighb, _nodeData$children, childNode, childNodeData, _iterator3, _step3, neighbor;
146
- return _regenerator.default.wrap(function _callee3$(_context3) {
147
- while (1) switch (_context3.prev = _context3.next) {
148
- case 0:
149
- _context3.next = 2;
150
- return this.load();
151
- case 2:
152
- nodeData = _context3.sent;
153
- _iterator2 = _createForOfIteratorHelper(this.children);
154
- _context3.prev = 4;
155
- _iterator2.s();
156
- case 6:
157
- if ((_step2 = _iterator2.n()).done) {
158
- _context3.next = 43;
159
- break;
160
- }
161
- childNode = _step2.value;
162
- _context3.next = 10;
163
- return childNode.load();
164
- case 10:
165
- childNodeData = _context3.sent;
166
- childNodeData.neighbors = (_childNodeData$neighb = childNodeData.neighbors) !== null && _childNodeData$neighb !== void 0 ? _childNodeData$neighb : [];
167
- if (!(Number(nodeData === null || nodeData === void 0 ? void 0 : (_nodeData$children = nodeData.children) === null || _nodeData$children === void 0 ? void 0 : _nodeData$children.length) < 1000)) {
168
- _context3.next = 33;
169
- break;
170
- }
171
- _iterator3 = _createForOfIteratorHelper(nodeData.children || []);
172
- _context3.prev = 14;
173
- _iterator3.s();
174
- case 16:
175
- if ((_step3 = _iterator3.n()).done) {
176
- _context3.next = 23;
177
- break;
178
- }
179
- neighbor = _step3.value;
180
- if (!(childNode.id === neighbor.id)) {
181
- _context3.next = 20;
182
- break;
183
- }
184
- return _context3.abrupt("continue", 21);
185
- case 20:
186
- childNodeData.neighbors.push(_objectSpread({}, neighbor));
187
- case 21:
188
- _context3.next = 16;
189
- break;
190
- case 23:
191
- _context3.next = 28;
192
- break;
193
- case 25:
194
- _context3.prev = 25;
195
- _context3.t0 = _context3["catch"](14);
196
- _iterator3.e(_context3.t0);
197
- case 28:
198
- _context3.prev = 28;
199
- _iterator3.f();
200
- return _context3.finish(28);
201
- case 31:
202
- _context3.next = 35;
203
- break;
204
- case 33:
205
- console.warn("Node ".concat(childNode.id, ": neighbors attribute is omited because of large number of neigbors"));
206
- delete childNodeData.neighbors;
207
- case 35:
208
- if (!(this.converter.options.instantNodeWriting && childNodeData)) {
209
- _context3.next = 38;
210
- break;
211
- }
212
- _context3.next = 38;
213
- return childNode.write(childNodeData);
214
- case 38:
215
- _context3.next = 40;
216
- return childNode.save();
217
- case 40:
218
- childNode.flush();
219
- case 41:
220
- _context3.next = 6;
221
- break;
222
- case 43:
223
- _context3.next = 48;
224
- break;
225
- case 45:
226
- _context3.prev = 45;
227
- _context3.t1 = _context3["catch"](4);
228
- _iterator2.e(_context3.t1);
229
- case 48:
230
- _context3.prev = 48;
231
- _iterator2.f();
232
- return _context3.finish(48);
233
- case 51:
234
- case "end":
235
- return _context3.stop();
236
- }
237
- }, _callee3, this, [[4, 45, 48, 51], [14, 25, 28, 31]]);
238
- }));
239
- function addNeighbors() {
240
- return _addNeighbors.apply(this, arguments);
241
- }
242
- return addNeighbors;
243
- }()
244
- }, {
245
- key: "save",
246
- value: function () {
247
- var _save = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4() {
248
- return _regenerator.default.wrap(function _callee4$(_context4) {
249
- while (1) switch (_context4.prev = _context4.next) {
250
- case 0:
251
- if (!this.data) {
252
- _context4.next = 3;
253
- break;
254
- }
255
- _context4.next = 3;
256
- return this.write(this.data);
257
- case 3:
258
- case "end":
259
- return _context4.stop();
260
- }
261
- }, _callee4, this);
262
- }));
263
- function save() {
264
- return _save.apply(this, arguments);
265
- }
266
- return save;
267
- }()
268
- }, {
269
- key: "write",
270
- value: function () {
271
- var _write = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee5(node) {
272
- var _this = this;
273
- var path;
274
- return _regenerator.default.wrap(function _callee5$(_context5) {
275
- while (1) switch (_context5.prev = _context5.next) {
276
- case 0:
277
- path = (0, _path.join)(this.converter.layers0Path, 'nodes', this.id);
278
- if (!this.converter.options.slpk) {
279
- _context5.next = 6;
280
- break;
281
- }
282
- _context5.next = 4;
283
- return this.converter.writeQueue.enqueue({
284
- archiveKey: "nodes/".concat(this.id, "/3dNodeIndexDocument.json.gz"),
285
- writePromise: function writePromise() {
286
- return (0, _fileUtils.writeFileForSlpk)(path, JSON.stringify(node), '3dNodeIndexDocument.json', true, _this.converter.compressList);
287
- }
288
- }, true);
289
- case 4:
290
- _context5.next = 8;
291
- break;
292
- case 6:
293
- _context5.next = 8;
294
- return this.converter.writeQueue.enqueue({
295
- writePromise: function writePromise() {
296
- return (0, _fileUtils.writeFile)(path, JSON.stringify(node));
297
- }
298
- }, true);
299
- case 8:
300
- case "end":
301
- return _context5.stop();
25
+ async addData(data) {
26
+ if (this.converter.options.instantNodeWriting) {
27
+ await this.write(data);
28
+ } else {
29
+ this.data = data;
30
+ }
31
+ return this;
32
+ }
33
+ async addChildren(childNodes) {
34
+ const newChildren = [];
35
+ for (const node of childNodes) {
36
+ const nodeData = await node.load();
37
+ newChildren.push({
38
+ id: node.id,
39
+ href: "../".concat(node.id),
40
+ obb: nodeData.obb,
41
+ mbs: nodeData.mbs
42
+ });
43
+ }
44
+ this.children = this.children.concat(childNodes);
45
+ let data = this.data;
46
+ if (this.converter.options.instantNodeWriting) {
47
+ data = await this.load();
48
+ }
49
+ if (data) {
50
+ var _data$children;
51
+ data.children = (_data$children = data.children) !== null && _data$children !== void 0 ? _data$children : [];
52
+ data.children = data.children.concat(newChildren);
53
+ }
54
+ if (this.converter.options.instantNodeWriting && data) {
55
+ await this.write(data);
56
+ }
57
+ }
58
+ async addNeighbors() {
59
+ const nodeData = await this.load();
60
+ for (const childNode of this.children) {
61
+ var _childNodeData$neighb, _nodeData$children;
62
+ const childNodeData = await childNode.load();
63
+ childNodeData.neighbors = (_childNodeData$neighb = childNodeData.neighbors) !== null && _childNodeData$neighb !== void 0 ? _childNodeData$neighb : [];
64
+ if (Number(nodeData === null || nodeData === void 0 ? void 0 : (_nodeData$children = nodeData.children) === null || _nodeData$children === void 0 ? void 0 : _nodeData$children.length) < 1000) {
65
+ for (const neighbor of nodeData.children || []) {
66
+ if (childNode.id === neighbor.id) {
67
+ continue;
302
68
  }
303
- }, _callee5, this);
304
- }));
305
- function write(_x3) {
306
- return _write.apply(this, arguments);
69
+ childNodeData.neighbors.push({
70
+ ...neighbor
71
+ });
72
+ }
73
+ } else {
74
+ console.warn("Node ".concat(childNode.id, ": neighbors attribute is omited because of large number of neigbors"));
75
+ delete childNodeData.neighbors;
307
76
  }
308
- return write;
309
- }()
310
- }, {
311
- key: "load",
312
- value: function () {
313
- var _load = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee6() {
314
- var path, parentNodePath, parentNodeFileName;
315
- return _regenerator.default.wrap(function _callee6$(_context6) {
316
- while (1) switch (_context6.prev = _context6.next) {
317
- case 0:
318
- if (!this.data) {
319
- _context6.next = 2;
320
- break;
321
- }
322
- return _context6.abrupt("return", this.data);
323
- case 2:
324
- path = this.id;
325
- parentNodePath = (0, _path.join)(this.converter.layers0Path, 'nodes', path);
326
- parentNodeFileName = 'index.json';
327
- if (this.converter.options.slpk) {
328
- parentNodeFileName = '3dNodeIndexDocument.json';
329
- }
330
- _context6.next = 8;
331
- return (0, _fileUtils.openJson)(parentNodePath, parentNodeFileName);
332
- case 8:
333
- return _context6.abrupt("return", _context6.sent);
334
- case 9:
335
- case "end":
336
- return _context6.stop();
337
- }
338
- }, _callee6, this);
339
- }));
340
- function load() {
341
- return _load.apply(this, arguments);
77
+ if (this.converter.options.instantNodeWriting && childNodeData) {
78
+ await childNode.write(childNodeData);
342
79
  }
343
- return load;
344
- }()
345
- }, {
346
- key: "flush",
347
- value: function flush() {
348
- this.data = null;
80
+ await childNode.save();
81
+ childNode.flush();
349
82
  }
350
- }], [{
351
- key: "createRootNode",
352
- value: function () {
353
- var _createRootNode = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(boundingVolumes, converter) {
354
- var rootData, rootNode;
355
- return _regenerator.default.wrap(function _callee7$(_context7) {
356
- while (1) switch (_context7.prev = _context7.next) {
357
- case 0:
358
- rootData = NodeIndexDocument.createRootNodeIndexDocument(boundingVolumes);
359
- _context7.next = 3;
360
- return new NodeIndexDocument(0, converter).addData(rootData);
361
- case 3:
362
- rootNode = _context7.sent;
363
- return _context7.abrupt("return", rootNode);
364
- case 5:
365
- case "end":
366
- return _context7.stop();
367
- }
368
- }, _callee7);
369
- }));
370
- function createRootNode(_x4, _x5) {
371
- return _createRootNode.apply(this, arguments);
83
+ }
84
+ async save() {
85
+ if (this.data) {
86
+ await this.write(this.data);
87
+ }
88
+ }
89
+ async write(node) {
90
+ const path = (0, _path.join)(this.converter.layers0Path, 'nodes', this.id);
91
+ if (this.converter.options.slpk) {
92
+ await this.converter.writeQueue.enqueue({
93
+ archiveKey: "nodes/".concat(this.id, "/3dNodeIndexDocument.json.gz"),
94
+ writePromise: () => (0, _fileUtils.writeFileForSlpk)(path, JSON.stringify(node), '3dNodeIndexDocument.json', true, this.converter.compressList)
95
+ }, true);
96
+ } else {
97
+ await this.converter.writeQueue.enqueue({
98
+ writePromise: () => (0, _fileUtils.writeFile)(path, JSON.stringify(node))
99
+ }, true);
100
+ }
101
+ }
102
+ async load() {
103
+ if (this.data) {
104
+ return this.data;
105
+ }
106
+ const path = this.id;
107
+ const parentNodePath = (0, _path.join)(this.converter.layers0Path, 'nodes', path);
108
+ let parentNodeFileName = 'index.json';
109
+ if (this.converter.options.slpk) {
110
+ parentNodeFileName = '3dNodeIndexDocument.json';
111
+ }
112
+ return await (0, _fileUtils.openJson)(parentNodePath, parentNodeFileName);
113
+ }
114
+ flush() {
115
+ this.data = null;
116
+ }
117
+ static async createRootNode(boundingVolumes, converter) {
118
+ const rootData = NodeIndexDocument.createRootNodeIndexDocument(boundingVolumes);
119
+ const rootNode = await new NodeIndexDocument(0, converter).addData(rootData);
120
+ return rootNode;
121
+ }
122
+ static async createNode(parentNode, boundingVolumes, lodSelection, nodeInPage, resources, converter) {
123
+ const data = await NodeIndexDocument.createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources);
124
+ const node = await new NodeIndexDocument(nodeInPage.index, converter).addData(data);
125
+ return node;
126
+ }
127
+ static createRootNodeIndexDocument(boundingVolumes) {
128
+ const root0data = {
129
+ version: "{".concat((0, _uuid.v4)().toUpperCase(), "}"),
130
+ id: 'root',
131
+ level: 0,
132
+ lodSelection: [{
133
+ metricType: 'maxScreenThresholdSQ',
134
+ maxError: 0
135
+ }, {
136
+ metricType: 'maxScreenThreshold',
137
+ maxError: 0
138
+ }],
139
+ ...boundingVolumes,
140
+ children: []
141
+ };
142
+ return (0, _jsonMapTransform.default)(root0data, (0, _node.NODE)());
143
+ }
144
+ static async createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources) {
145
+ const {
146
+ texture,
147
+ attributes
148
+ } = resources;
149
+ const nodeId = nodeInPage.index;
150
+ const parentNodeData = await parentNode.load();
151
+ const nodeData = {
152
+ version: parentNodeData.version,
153
+ id: nodeId.toString(),
154
+ level: parentNodeData.level + 1,
155
+ ...boundingVolumes,
156
+ lodSelection,
157
+ parentNode: {
158
+ id: parentNode.id,
159
+ href: "../".concat(parentNode.id),
160
+ mbs: parentNodeData.mbs,
161
+ obb: parentNodeData.obb
162
+ },
163
+ children: [],
164
+ neighbors: []
165
+ };
166
+ const node = (0, _jsonMapTransform.default)(nodeData, (0, _node.NODE)());
167
+ if (nodeInPage.mesh) {
168
+ var _parentNode$converter, _parentNode$converter2;
169
+ node.geometryData = [{
170
+ href: './geometries/0'
171
+ }];
172
+ node.sharedResource = {
173
+ href: './shared'
174
+ };
175
+ if (texture) {
176
+ node.textureData = [{
177
+ href: './textures/0'
178
+ }, {
179
+ href: './textures/1'
180
+ }];
372
181
  }
373
- return createRootNode;
374
- }()
375
- }, {
376
- key: "createNode",
377
- value: function () {
378
- var _createNode = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee8(parentNode, boundingVolumes, lodSelection, nodeInPage, resources, converter) {
379
- var data, node;
380
- return _regenerator.default.wrap(function _callee8$(_context8) {
381
- while (1) switch (_context8.prev = _context8.next) {
382
- case 0:
383
- _context8.next = 2;
384
- return NodeIndexDocument.createNodeIndexDocument(parentNode, boundingVolumes, lodSelection, nodeInPage, resources);
385
- case 2:
386
- data = _context8.sent;
387
- _context8.next = 5;
388
- return new NodeIndexDocument(nodeInPage.index, converter).addData(data);
389
- case 5:
390
- node = _context8.sent;
391
- return _context8.abrupt("return", node);
392
- case 7:
393
- case "end":
394
- return _context8.stop();
395
- }
396
- }, _callee8);
397
- }));
398
- function createNode(_x6, _x7, _x8, _x9, _x10, _x11) {
399
- return _createNode.apply(this, arguments);
182
+ if (attributes && attributes.length && (_parentNode$converter = parentNode.converter.layers0) !== null && _parentNode$converter !== void 0 && (_parentNode$converter2 = _parentNode$converter.attributeStorageInfo) !== null && _parentNode$converter2 !== void 0 && _parentNode$converter2.length) {
183
+ node.attributeData = [];
184
+ for (let index = 0; index < attributes.length; index++) {
185
+ const folderName = parentNode.converter.layers0.attributeStorageInfo[index].key;
186
+ node.attributeData.push({
187
+ href: "./attributes/".concat(folderName, "/0")
188
+ });
189
+ }
400
190
  }
401
- return createNode;
402
- }()
403
- }, {
404
- key: "createRootNodeIndexDocument",
405
- value: function createRootNodeIndexDocument(boundingVolumes) {
406
- var root0data = _objectSpread(_objectSpread({
407
- version: "{".concat((0, _uuid.v4)().toUpperCase(), "}"),
408
- id: 'root',
409
- level: 0,
410
- lodSelection: [{
411
- metricType: 'maxScreenThresholdSQ',
412
- maxError: 0
413
- }, {
414
- metricType: 'maxScreenThreshold',
415
- maxError: 0
416
- }]
417
- }, boundingVolumes), {}, {
418
- children: []
419
- });
420
- return (0, _jsonMapTransform.default)(root0data, (0, _node.NODE)());
421
191
  }
422
- }, {
423
- key: "createNodeIndexDocument",
424
- value: function () {
425
- var _createNodeIndexDocument = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee9(parentNode, boundingVolumes, lodSelection, nodeInPage, resources) {
426
- var texture, attributes, nodeId, parentNodeData, nodeData, node, _parentNode$converter, _parentNode$converter2, index, folderName;
427
- return _regenerator.default.wrap(function _callee9$(_context9) {
428
- while (1) switch (_context9.prev = _context9.next) {
429
- case 0:
430
- texture = resources.texture, attributes = resources.attributes;
431
- nodeId = nodeInPage.index;
432
- _context9.next = 4;
433
- return parentNode.load();
434
- case 4:
435
- parentNodeData = _context9.sent;
436
- nodeData = _objectSpread(_objectSpread({
437
- version: parentNodeData.version,
438
- id: nodeId.toString(),
439
- level: parentNodeData.level + 1
440
- }, boundingVolumes), {}, {
441
- lodSelection: lodSelection,
442
- parentNode: {
443
- id: parentNode.id,
444
- href: "../".concat(parentNode.id),
445
- mbs: parentNodeData.mbs,
446
- obb: parentNodeData.obb
447
- },
448
- children: [],
449
- neighbors: []
450
- });
451
- node = (0, _jsonMapTransform.default)(nodeData, (0, _node.NODE)());
452
- if (nodeInPage.mesh) {
453
- node.geometryData = [{
454
- href: './geometries/0'
455
- }];
456
- node.sharedResource = {
457
- href: './shared'
458
- };
459
- if (texture) {
460
- node.textureData = [{
461
- href: './textures/0'
462
- }, {
463
- href: './textures/1'
464
- }];
465
- }
466
- if (attributes && attributes.length && (_parentNode$converter = parentNode.converter.layers0) !== null && _parentNode$converter !== void 0 && (_parentNode$converter2 = _parentNode$converter.attributeStorageInfo) !== null && _parentNode$converter2 !== void 0 && _parentNode$converter2.length) {
467
- node.attributeData = [];
468
- for (index = 0; index < attributes.length; index++) {
469
- folderName = parentNode.converter.layers0.attributeStorageInfo[index].key;
470
- node.attributeData.push({
471
- href: "./attributes/".concat(folderName, "/0")
472
- });
473
- }
474
- }
475
- }
476
- return _context9.abrupt("return", node);
477
- case 9:
478
- case "end":
479
- return _context9.stop();
480
- }
481
- }, _callee9);
482
- }));
483
- function createNodeIndexDocument(_x12, _x13, _x14, _x15, _x16) {
484
- return _createNodeIndexDocument.apply(this, arguments);
485
- }
486
- return createNodeIndexDocument;
487
- }()
488
- }]);
489
- return NodeIndexDocument;
490
- }();
192
+ return node;
193
+ }
194
+ }
491
195
  exports.NodeIndexDocument = NodeIndexDocument;
492
196
  //# sourceMappingURL=node-index-document.js.map