@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.
Files changed (69) hide show
  1. package/dist/dist.es5.min.js +3 -3
  2. package/dist/dist.es5.min.js.map +1 -1
  3. package/dist/dist.min.js +11 -11
  4. package/dist/dist.min.js.map +1 -1
  5. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +422 -184
  6. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  7. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +299 -202
  8. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  9. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js +8 -4
  10. package/dist/es5/3d-tiles-converter/helpers/i3s-obb-to-3d-tiles-obb.js.map +1 -1
  11. package/dist/es5/3d-tiles-converter/json-templates/tileset.js +17 -7
  12. package/dist/es5/3d-tiles-converter/json-templates/tileset.js.map +1 -1
  13. package/dist/es5/bundle.js +2 -2
  14. package/dist/es5/bundle.js.map +1 -1
  15. package/dist/es5/deps-installer/deps-installer.js +65 -17
  16. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  17. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +16 -16
  18. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  19. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js +33 -9
  20. package/dist/es5/i3s-converter/helpers/create-scene-server-path.js.map +1 -1
  21. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +103 -93
  22. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  23. package/dist/es5/i3s-converter/helpers/geometry-converter.js +505 -344
  24. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  25. package/dist/es5/i3s-converter/helpers/node-debug.js +26 -30
  26. package/dist/es5/i3s-converter/helpers/node-debug.js.map +1 -1
  27. package/dist/es5/i3s-converter/helpers/node-pages.js +203 -102
  28. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  29. package/dist/es5/i3s-converter/i3s-converter.js +1510 -680
  30. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  31. package/dist/es5/i3s-converter/json-templates/layers.js +25 -15
  32. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
  33. package/dist/es5/i3s-converter/json-templates/metadata.js +1 -1
  34. package/dist/es5/i3s-converter/json-templates/metadata.js.map +1 -1
  35. package/dist/es5/i3s-converter/json-templates/node.js +21 -12
  36. package/dist/es5/i3s-converter/json-templates/node.js.map +1 -1
  37. package/dist/es5/i3s-converter/json-templates/scene-server.js +4 -2
  38. package/dist/es5/i3s-converter/json-templates/scene-server.js.map +1 -1
  39. package/dist/es5/i3s-converter/json-templates/shared-resources.js +55 -15
  40. package/dist/es5/i3s-converter/json-templates/shared-resources.js.map +1 -1
  41. package/dist/es5/i3s-converter/json-templates/store.js +4 -2
  42. package/dist/es5/i3s-converter/json-templates/store.js.map +1 -1
  43. package/dist/es5/i3s-server/app.js +6 -6
  44. package/dist/es5/i3s-server/app.js.map +1 -1
  45. package/dist/es5/i3s-server/controllers/index-controller.js +60 -20
  46. package/dist/es5/i3s-server/controllers/index-controller.js.map +1 -1
  47. package/dist/es5/i3s-server/routes/index.js +41 -14
  48. package/dist/es5/i3s-server/routes/index.js.map +1 -1
  49. package/dist/es5/index.js +4 -4
  50. package/dist/es5/lib/geoid-height-model.js +114 -100
  51. package/dist/es5/lib/geoid-height-model.js.map +1 -1
  52. package/dist/es5/lib/pgm-parser.js +122 -68
  53. package/dist/es5/lib/pgm-parser.js.map +1 -1
  54. package/dist/es5/lib/utils/compress-util.js +345 -123
  55. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  56. package/dist/es5/lib/utils/file-utils.js +98 -20
  57. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  58. package/dist/es5/lib/utils/lod-conversion-utils.js +9 -9
  59. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  60. package/dist/es5/lib/utils/statistic-utills.js +152 -41
  61. package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
  62. package/dist/es5/pgm-loader.js +5 -3
  63. package/dist/es5/pgm-loader.js.map +1 -1
  64. package/dist/esm/i3s-converter/i3s-converter.js +11 -3
  65. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  66. package/dist/esm/pgm-loader.js +1 -1
  67. package/dist/scripts/converter.js +134 -71
  68. package/package.json +14 -14
  69. package/src/i3s-converter/i3s-converter.ts +10 -3
@@ -7,6 +7,12 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = convertB3dmToI3sGeometry;
9
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
+
10
16
  var _core = require("@math.gl/core");
11
17
 
12
18
  var _geospatial = require("@math.gl/geospatial");
@@ -21,174 +27,280 @@ var _md = _interopRequireDefault(require("md5"));
21
27
 
22
28
  var _geometryAttributes = require("./geometry-attributes");
23
29
 
24
- const VALUES_PER_VERTEX = 3;
25
- const VALUES_PER_TEX_COORD = 2;
26
- const VALUES_PER_COLOR_ELEMENT = 4;
27
- const STRING_TYPE = 'string';
28
- const SHORT_INT_TYPE = 'Int32';
29
- const DOUBLE_TYPE = 'Float64';
30
- const OBJECT_ID_TYPE = 'Oid32';
31
- const BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
32
-
33
- async function convertB3dmToI3sGeometry(tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco) {
34
- const materialAndTextureList = convertMaterials(tileContent);
35
- const convertedAttributesMap = convertAttributes(tileContent);
36
-
37
- if (convertedAttributesMap.has('default')) {
38
- materialAndTextureList.push({
39
- material: getDefaultMaterial()
40
- });
41
- }
42
-
43
- const result = [];
44
- let nodesCounter = nodeId;
45
-
46
- for (let i = 0; i < (tileContent.gltf.materials.length || 1); i++) {
47
- const sourceMaterial = tileContent.gltf.materials[i] || {
48
- id: 'default'
49
- };
50
-
51
- if (!convertedAttributesMap.has(sourceMaterial.id)) {
52
- continue;
53
- }
54
-
55
- const convertedAttributes = convertedAttributesMap.get(sourceMaterial.id);
56
- const {
57
- material,
58
- texture
59
- } = materialAndTextureList[i];
60
- result.push(await _makeNodeResources({
61
- convertedAttributes,
62
- material,
63
- texture,
64
- tileContent,
65
- nodeId: nodesCounter,
66
- featuresHashArray,
67
- attributeStorageInfo,
68
- draco
69
- }));
70
- nodesCounter++;
71
- }
72
-
73
- return result;
74
- }
75
-
76
- async function _makeNodeResources({
77
- convertedAttributes,
78
- material,
79
- texture,
80
- tileContent,
81
- nodeId,
82
- featuresHashArray,
83
- attributeStorageInfo,
84
- draco
85
- }) {
86
- const vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
87
- const triangleCount = vertexCount / 3;
88
- const {
89
- faceRange,
90
- featureIds,
91
- positions,
92
- normals,
93
- colors,
94
- texCoords,
95
- featureCount
96
- } = (0, _geometryAttributes.generateAttributes)({
97
- triangleCount,
98
- ...convertedAttributes
99
- });
100
-
101
- if (tileContent.batchTableJson) {
102
- makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, tileContent.batchTableJson);
103
- }
104
-
105
- const header = new Uint32Array(2);
106
- const typedFeatureIds = generateBigUint64Array(featureIds);
107
- header.set([vertexCount, featureCount], 0);
108
- const fileBuffer = new Uint8Array((0, _loaderUtils.concatenateArrayBuffers)(header.buffer, positions.buffer, normals.buffer, texture ? texCoords.buffer : new ArrayBuffer(0), colors.buffer, typedFeatureIds.buffer, faceRange.buffer));
109
- const compressedGeometry = draco ? await generateCompressedGeometry(vertexCount, convertedAttributes, {
110
- positions,
111
- normals,
112
- texCoords: texture ? texCoords : new Float32Array(0),
113
- colors,
114
- featureIds,
115
- faceRange
116
- }) : null;
117
- const attributes = convertBatchTableToAttributeBuffers(tileContent.batchTableJson, featureIds, attributeStorageInfo);
118
- return {
119
- geometry: fileBuffer,
120
- compressedGeometry,
121
- texture,
122
- sharedResources: getSharedResources(tileContent, nodeId),
123
- meshMaterial: material,
124
- vertexCount,
125
- attributes,
126
- featureCount
127
- };
30
+ 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; }
31
+
32
+ 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; }
33
+
34
+ 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; } } }; }
35
+
36
+ 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); }
37
+
38
+ 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; }
39
+
40
+ var VALUES_PER_VERTEX = 3;
41
+ var VALUES_PER_TEX_COORD = 2;
42
+ var VALUES_PER_COLOR_ELEMENT = 4;
43
+ var STRING_TYPE = 'string';
44
+ var SHORT_INT_TYPE = 'Int32';
45
+ var DOUBLE_TYPE = 'Float64';
46
+ var OBJECT_ID_TYPE = 'Oid32';
47
+ var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
48
+
49
+ function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5) {
50
+ return _convertB3dmToI3sGeometry.apply(this, arguments);
51
+ }
52
+
53
+ function _convertB3dmToI3sGeometry() {
54
+ _convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco) {
55
+ var materialAndTextureList, convertedAttributesMap, result, nodesCounter, i, sourceMaterial, convertedAttributes, _materialAndTextureLi, material, texture;
56
+
57
+ return _regenerator.default.wrap(function _callee$(_context) {
58
+ while (1) {
59
+ switch (_context.prev = _context.next) {
60
+ case 0:
61
+ materialAndTextureList = convertMaterials(tileContent);
62
+ convertedAttributesMap = convertAttributes(tileContent);
63
+
64
+ if (convertedAttributesMap.has('default')) {
65
+ materialAndTextureList.push({
66
+ material: getDefaultMaterial()
67
+ });
68
+ }
69
+
70
+ result = [];
71
+ nodesCounter = nodeId;
72
+ i = 0;
73
+
74
+ case 6:
75
+ if (!(i < (tileContent.gltf.materials.length || 1))) {
76
+ _context.next = 21;
77
+ break;
78
+ }
79
+
80
+ sourceMaterial = tileContent.gltf.materials[i] || {
81
+ id: 'default'
82
+ };
83
+
84
+ if (convertedAttributesMap.has(sourceMaterial.id)) {
85
+ _context.next = 10;
86
+ break;
87
+ }
88
+
89
+ return _context.abrupt("continue", 18);
90
+
91
+ case 10:
92
+ convertedAttributes = convertedAttributesMap.get(sourceMaterial.id);
93
+ _materialAndTextureLi = materialAndTextureList[i], material = _materialAndTextureLi.material, texture = _materialAndTextureLi.texture;
94
+ _context.t0 = result;
95
+ _context.next = 15;
96
+ return _makeNodeResources({
97
+ convertedAttributes: convertedAttributes,
98
+ material: material,
99
+ texture: texture,
100
+ tileContent: tileContent,
101
+ nodeId: nodesCounter,
102
+ featuresHashArray: featuresHashArray,
103
+ attributeStorageInfo: attributeStorageInfo,
104
+ draco: draco
105
+ });
106
+
107
+ case 15:
108
+ _context.t1 = _context.sent;
109
+
110
+ _context.t0.push.call(_context.t0, _context.t1);
111
+
112
+ nodesCounter++;
113
+
114
+ case 18:
115
+ i++;
116
+ _context.next = 6;
117
+ break;
118
+
119
+ case 21:
120
+ return _context.abrupt("return", result);
121
+
122
+ case 22:
123
+ case "end":
124
+ return _context.stop();
125
+ }
126
+ }
127
+ }, _callee);
128
+ }));
129
+ return _convertB3dmToI3sGeometry.apply(this, arguments);
130
+ }
131
+
132
+ function _makeNodeResources(_x6) {
133
+ return _makeNodeResources2.apply(this, arguments);
134
+ }
135
+
136
+ function _makeNodeResources2() {
137
+ _makeNodeResources2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref) {
138
+ var convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco, vertexCount, triangleCount, _generateAttributes, faceRange, featureIds, positions, normals, colors, texCoords, featureCount, header, typedFeatureIds, fileBuffer, compressedGeometry, attributes;
139
+
140
+ return _regenerator.default.wrap(function _callee2$(_context2) {
141
+ while (1) {
142
+ switch (_context2.prev = _context2.next) {
143
+ case 0:
144
+ convertedAttributes = _ref.convertedAttributes, material = _ref.material, texture = _ref.texture, tileContent = _ref.tileContent, nodeId = _ref.nodeId, featuresHashArray = _ref.featuresHashArray, attributeStorageInfo = _ref.attributeStorageInfo, draco = _ref.draco;
145
+ vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
146
+ triangleCount = vertexCount / 3;
147
+ _generateAttributes = (0, _geometryAttributes.generateAttributes)(_objectSpread({
148
+ triangleCount: triangleCount
149
+ }, convertedAttributes)), faceRange = _generateAttributes.faceRange, featureIds = _generateAttributes.featureIds, positions = _generateAttributes.positions, normals = _generateAttributes.normals, colors = _generateAttributes.colors, texCoords = _generateAttributes.texCoords, featureCount = _generateAttributes.featureCount;
150
+
151
+ if (tileContent.batchTableJson) {
152
+ makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, tileContent.batchTableJson);
153
+ }
154
+
155
+ header = new Uint32Array(2);
156
+ typedFeatureIds = generateBigUint64Array(featureIds);
157
+ header.set([vertexCount, featureCount], 0);
158
+ fileBuffer = new Uint8Array((0, _loaderUtils.concatenateArrayBuffers)(header.buffer, positions.buffer, normals.buffer, texture ? texCoords.buffer : new ArrayBuffer(0), colors.buffer, typedFeatureIds.buffer, faceRange.buffer));
159
+
160
+ if (!draco) {
161
+ _context2.next = 15;
162
+ break;
163
+ }
164
+
165
+ _context2.next = 12;
166
+ return generateCompressedGeometry(vertexCount, convertedAttributes, {
167
+ positions: positions,
168
+ normals: normals,
169
+ texCoords: texture ? texCoords : new Float32Array(0),
170
+ colors: colors,
171
+ featureIds: featureIds,
172
+ faceRange: faceRange
173
+ });
174
+
175
+ case 12:
176
+ _context2.t0 = _context2.sent;
177
+ _context2.next = 16;
178
+ break;
179
+
180
+ case 15:
181
+ _context2.t0 = null;
182
+
183
+ case 16:
184
+ compressedGeometry = _context2.t0;
185
+ attributes = convertBatchTableToAttributeBuffers(tileContent.batchTableJson, featureIds, attributeStorageInfo);
186
+ return _context2.abrupt("return", {
187
+ geometry: fileBuffer,
188
+ compressedGeometry: compressedGeometry,
189
+ texture: texture,
190
+ sharedResources: getSharedResources(tileContent, nodeId),
191
+ meshMaterial: material,
192
+ vertexCount: vertexCount,
193
+ attributes: attributes,
194
+ featureCount: featureCount
195
+ });
196
+
197
+ case 19:
198
+ case "end":
199
+ return _context2.stop();
200
+ }
201
+ }
202
+ }, _callee2);
203
+ }));
204
+ return _makeNodeResources2.apply(this, arguments);
128
205
  }
129
206
 
130
207
  function convertAttributes(tileContent) {
131
- const attributesMap = new Map();
208
+ var attributesMap = new Map();
132
209
 
133
- for (const material of tileContent.gltf.materials || [{
210
+ var _iterator = _createForOfIteratorHelper(tileContent.gltf.materials || [{
134
211
  id: 'default'
135
- }]) {
136
- attributesMap.set(material.id, {
137
- positions: new Float32Array(0),
138
- normals: new Float32Array(0),
139
- texCoords: new Float32Array(0),
140
- colors: new Uint8Array(0),
141
- featureIndices: []
142
- });
212
+ }]),
213
+ _step;
214
+
215
+ try {
216
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
217
+ var material = _step.value;
218
+ attributesMap.set(material.id, {
219
+ positions: new Float32Array(0),
220
+ normals: new Float32Array(0),
221
+ texCoords: new Float32Array(0),
222
+ colors: new Uint8Array(0),
223
+ featureIndices: []
224
+ });
225
+ }
226
+ } catch (err) {
227
+ _iterator.e(err);
228
+ } finally {
229
+ _iterator.f();
143
230
  }
144
231
 
145
- const nodes = tileContent.gltf.scene.nodes;
232
+ var nodes = tileContent.gltf.scene.nodes;
146
233
  convertNodes(nodes, tileContent, attributesMap);
147
234
 
148
- for (const attrKey of attributesMap.keys()) {
149
- const attributes = attributesMap.get(attrKey);
235
+ var _iterator2 = _createForOfIteratorHelper(attributesMap.keys()),
236
+ _step2;
150
237
 
151
- if (attributes.positions.length === 0) {
152
- attributesMap.delete(attrKey);
153
- continue;
154
- }
238
+ try {
239
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
240
+ var attrKey = _step2.value;
241
+ var attributes = attributesMap.get(attrKey);
155
242
 
156
- const vertexCount = attributes.positions.length / VALUES_PER_VERTEX;
243
+ if (attributes.positions.length === 0) {
244
+ attributesMap.delete(attrKey);
245
+ continue;
246
+ }
247
+
248
+ var vertexCount = attributes.positions.length / VALUES_PER_VERTEX;
157
249
 
158
- if (!attributes.colors.length) {
159
- attributes.colors = new Uint8Array(vertexCount * VALUES_PER_COLOR_ELEMENT);
250
+ if (!attributes.colors.length) {
251
+ attributes.colors = new Uint8Array(vertexCount * VALUES_PER_COLOR_ELEMENT);
160
252
 
161
- for (let index = 0; index < attributes.colors.length; index += 4) {
162
- attributes.colors.set([255, 255, 255, 255], index);
253
+ for (var index = 0; index < attributes.colors.length; index += 4) {
254
+ attributes.colors.set([255, 255, 255, 255], index);
255
+ }
163
256
  }
164
- }
165
257
 
166
- if (!attributes.texCoords.length) {
167
- attributes.texCoords = new Float32Array(vertexCount * VALUES_PER_TEX_COORD);
258
+ if (!attributes.texCoords.length) {
259
+ attributes.texCoords = new Float32Array(vertexCount * VALUES_PER_TEX_COORD);
168
260
 
169
- for (let index = 0; index < attributes.texCoords.length; index += 2) {
170
- attributes.texCoords.set([1, 1], index);
261
+ for (var _index = 0; _index < attributes.texCoords.length; _index += 2) {
262
+ attributes.texCoords.set([1, 1], _index);
263
+ }
171
264
  }
172
- }
173
265
 
174
- attributes.featureIndices = attributes.featureIndices.reduce((acc, value) => acc.concat(value));
266
+ attributes.featureIndices = attributes.featureIndices.reduce(function (acc, value) {
267
+ return acc.concat(value);
268
+ });
269
+ }
270
+ } catch (err) {
271
+ _iterator2.e(err);
272
+ } finally {
273
+ _iterator2.f();
175
274
  }
176
275
 
177
276
  return attributesMap;
178
277
  }
179
278
 
180
- function convertNodes(nodes, tileContent, attributesMap, matrix = new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
279
+ function convertNodes(nodes, tileContent, attributesMap) {
280
+ var matrix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
281
+
181
282
  if (nodes) {
182
- for (const node of nodes) {
183
- convertNode(node, tileContent, attributesMap, matrix);
283
+ var _iterator3 = _createForOfIteratorHelper(nodes),
284
+ _step3;
285
+
286
+ try {
287
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
288
+ var node = _step3.value;
289
+ convertNode(node, tileContent, attributesMap, matrix);
290
+ }
291
+ } catch (err) {
292
+ _iterator3.e(err);
293
+ } finally {
294
+ _iterator3.f();
184
295
  }
185
296
  }
186
297
  }
187
298
 
188
- function convertNode(node, tileContent, attributesMap, matrix = new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
189
- const nodeMatrix = node.matrix;
190
- const compositeMatrix = nodeMatrix ? matrix.multiplyRight(nodeMatrix) : matrix;
191
- const mesh = node.mesh;
299
+ function convertNode(node, tileContent, attributesMap) {
300
+ var matrix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
301
+ var nodeMatrix = node.matrix;
302
+ var compositeMatrix = nodeMatrix ? matrix.multiplyRight(nodeMatrix) : matrix;
303
+ var mesh = node.mesh;
192
304
 
193
305
  if (mesh) {
194
306
  convertMesh(mesh, tileContent, attributesMap, compositeMatrix);
@@ -197,56 +309,66 @@ function convertNode(node, tileContent, attributesMap, matrix = new _core.Matrix
197
309
  convertNodes(node.children, tileContent, attributesMap, compositeMatrix);
198
310
  }
199
311
 
200
- function convertMesh(mesh, content, attributesMap, matrix = new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1])) {
201
- for (const primitive of mesh.primitives) {
202
- let outputAttributes = null;
312
+ function convertMesh(mesh, content, attributesMap) {
313
+ var matrix = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
203
314
 
204
- if (primitive.material) {
205
- outputAttributes = attributesMap.get(primitive.material.id);
206
- } else if (attributesMap.has('default')) {
207
- outputAttributes = attributesMap.get('default');
208
- }
315
+ var _iterator4 = _createForOfIteratorHelper(mesh.primitives),
316
+ _step4;
209
317
 
210
- (0, _core2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
211
- const attributes = primitive.attributes;
212
- outputAttributes.positions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
213
- vertices: attributes.POSITION.value,
214
- cartographicOrigin: content.cartographicOrigin,
215
- cartesianModelMatrix: content.cartesianModelMatrix,
216
- nodeMatrix: matrix,
217
- indices: primitive.indices.value,
218
- attributeSpecificTransformation: transformVertexPositions
219
- }));
220
- outputAttributes.normals = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.normals, transformVertexArray({
221
- vertices: attributes.NORMAL && attributes.NORMAL.value,
222
- cartographicOrigin: content.cartographicOrigin,
223
- cartesianModelMatrix: content.cartesianModelMatrix,
224
- nodeMatrix: matrix,
225
- indices: primitive.indices.value,
226
- attributeSpecificTransformation: transformVertexNormals
227
- }));
228
- outputAttributes.texCoords = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, primitive.indices.value));
229
- outputAttributes.colors = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0, primitive.indices.value));
230
- outputAttributes.featureIndices.push(flattenBatchIds(getBatchIdsByAttributeName(attributes), primitive.indices.value));
318
+ try {
319
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
320
+ var primitive = _step4.value;
321
+ var outputAttributes = null;
322
+
323
+ if (primitive.material) {
324
+ outputAttributes = attributesMap.get(primitive.material.id);
325
+ } else if (attributesMap.has('default')) {
326
+ outputAttributes = attributesMap.get('default');
327
+ }
328
+
329
+ (0, _core2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
330
+ var attributes = primitive.attributes;
331
+ outputAttributes.positions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
332
+ vertices: attributes.POSITION.value,
333
+ cartographicOrigin: content.cartographicOrigin,
334
+ cartesianModelMatrix: content.cartesianModelMatrix,
335
+ nodeMatrix: matrix,
336
+ indices: primitive.indices.value,
337
+ attributeSpecificTransformation: transformVertexPositions
338
+ }));
339
+ outputAttributes.normals = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.normals, transformVertexArray({
340
+ vertices: attributes.NORMAL && attributes.NORMAL.value,
341
+ cartographicOrigin: content.cartographicOrigin,
342
+ cartesianModelMatrix: content.cartesianModelMatrix,
343
+ nodeMatrix: matrix,
344
+ indices: primitive.indices.value,
345
+ attributeSpecificTransformation: transformVertexNormals
346
+ }));
347
+ outputAttributes.texCoords = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, primitive.indices.value));
348
+ outputAttributes.colors = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0, primitive.indices.value));
349
+ outputAttributes.featureIndices.push(flattenBatchIds(getBatchIdsByAttributeName(attributes), primitive.indices.value));
350
+ }
351
+ } catch (err) {
352
+ _iterator4.e(err);
353
+ } finally {
354
+ _iterator4.f();
231
355
  }
232
356
  }
233
357
 
234
358
  function transformVertexArray(args) {
235
- const {
236
- vertices,
237
- indices,
238
- attributeSpecificTransformation
239
- } = args;
240
- const newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);
359
+ var vertices = args.vertices,
360
+ indices = args.indices,
361
+ attributeSpecificTransformation = args.attributeSpecificTransformation;
362
+ var newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);
241
363
 
242
364
  if (!vertices) {
243
365
  return newVertices;
244
366
  }
245
367
 
246
- for (let i = 0; i < indices.length; i++) {
247
- const coordIndex = indices[i] * VALUES_PER_VERTEX;
248
- const vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX);
249
- let vertexVector = new _core.Vector3(Array.from(vertex));
368
+ for (var i = 0; i < indices.length; i++) {
369
+ var coordIndex = indices[i] * VALUES_PER_VERTEX;
370
+ var vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX);
371
+ var vertexVector = new _core.Vector3(Array.from(vertex));
250
372
  vertexVector = attributeSpecificTransformation(vertexVector, args);
251
373
  newVertices[i * VALUES_PER_VERTEX] = vertexVector.x;
252
374
  newVertices[i * VALUES_PER_VERTEX + 1] = vertexVector.y;
@@ -257,11 +379,9 @@ function transformVertexArray(args) {
257
379
  }
258
380
 
259
381
  function transformVertexPositions(vertexVector, calleeArgs) {
260
- const {
261
- cartesianModelMatrix,
262
- cartographicOrigin,
263
- nodeMatrix
264
- } = calleeArgs;
382
+ var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
383
+ cartographicOrigin = calleeArgs.cartographicOrigin,
384
+ nodeMatrix = calleeArgs.nodeMatrix;
265
385
 
266
386
  if (nodeMatrix) {
267
387
  vertexVector = vertexVector.transform(nodeMatrix);
@@ -276,10 +396,8 @@ function transformVertexPositions(vertexVector, calleeArgs) {
276
396
  }
277
397
 
278
398
  function transformVertexNormals(vertexVector, calleeArgs) {
279
- const {
280
- cartesianModelMatrix,
281
- nodeMatrix
282
- } = calleeArgs;
399
+ var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
400
+ nodeMatrix = calleeArgs.nodeMatrix;
283
401
 
284
402
  if (nodeMatrix) {
285
403
  vertexVector = vertexVector.transformAsVector(nodeMatrix);
@@ -294,11 +412,11 @@ function flattenTexCoords(texCoords, indices) {
294
412
  return new Float32Array(0);
295
413
  }
296
414
 
297
- const newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
415
+ var newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
298
416
 
299
- for (let i = 0; i < indices.length; i++) {
300
- const coordIndex = indices[i] * VALUES_PER_TEX_COORD;
301
- const texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);
417
+ for (var i = 0; i < indices.length; i++) {
418
+ var coordIndex = indices[i] * VALUES_PER_TEX_COORD;
419
+ var texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);
302
420
  newTexCoords[i * VALUES_PER_TEX_COORD] = texCoord[0];
303
421
  newTexCoords[i * VALUES_PER_TEX_COORD + 1] = texCoord[1];
304
422
  }
@@ -311,16 +429,16 @@ function flattenColors(colorsAttribute, indices) {
311
429
  return new Uint8Array(0);
312
430
  }
313
431
 
314
- const components = colorsAttribute.components;
315
- const colors = colorsAttribute.value;
316
- const newColors = new Uint8Array(indices.length * components);
432
+ var components = colorsAttribute.components;
433
+ var colors = colorsAttribute.value;
434
+ var newColors = new Uint8Array(indices.length * components);
317
435
 
318
- for (let i = 0; i < indices.length; i++) {
319
- const colorIndex = indices[i] * components;
320
- const color = colors.subarray(colorIndex, colorIndex + components);
321
- const colorUint8 = new Uint8Array(components);
436
+ for (var i = 0; i < indices.length; i++) {
437
+ var colorIndex = indices[i] * components;
438
+ var color = colors.subarray(colorIndex, colorIndex + components);
439
+ var colorUint8 = new Uint8Array(components);
322
440
 
323
- for (let j = 0; j < color.length; j++) {
441
+ for (var j = 0; j < color.length; j++) {
324
442
  colorUint8[j] = color[j] * 255;
325
443
  }
326
444
 
@@ -335,10 +453,10 @@ function flattenBatchIds(batchedIds, indices) {
335
453
  return [];
336
454
  }
337
455
 
338
- const newBatchIds = [];
456
+ var newBatchIds = [];
339
457
 
340
- for (let i = 0; i < indices.length; i++) {
341
- const coordIndex = indices[i];
458
+ for (var i = 0; i < indices.length; i++) {
459
+ var coordIndex = indices[i];
342
460
  newBatchIds.push(batchedIds[coordIndex]);
343
461
  }
344
462
 
@@ -346,10 +464,10 @@ function flattenBatchIds(batchedIds, indices) {
346
464
  }
347
465
 
348
466
  function getBatchIdsByAttributeName(attributes) {
349
- let batchIds = [];
467
+ var batchIds = [];
350
468
 
351
- for (let index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {
352
- const possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];
469
+ for (var index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {
470
+ var possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];
353
471
 
354
472
  if (attributes[possibleBatchIdAttributeName] && attributes[possibleBatchIdAttributeName].value) {
355
473
  batchIds = attributes[possibleBatchIdAttributeName].value;
@@ -361,27 +479,39 @@ function getBatchIdsByAttributeName(attributes) {
361
479
  }
362
480
 
363
481
  function convertMaterials(tileContent) {
364
- const result = [];
365
- const sourceMaterials = tileContent.gltf.materials;
482
+ var result = [];
483
+ var sourceMaterials = tileContent.gltf.materials;
366
484
 
367
- for (const sourceMaterial of sourceMaterials) {
368
- result.push(convertMaterial(sourceMaterial));
485
+ var _iterator5 = _createForOfIteratorHelper(sourceMaterials),
486
+ _step5;
487
+
488
+ try {
489
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
490
+ var sourceMaterial = _step5.value;
491
+ result.push(convertMaterial(sourceMaterial));
492
+ }
493
+ } catch (err) {
494
+ _iterator5.e(err);
495
+ } finally {
496
+ _iterator5.f();
369
497
  }
370
498
 
371
499
  return result;
372
500
  }
373
501
 
374
502
  function convertMaterial(sourceMaterial) {
375
- const material = {
503
+ var material = {
376
504
  doubleSided: sourceMaterial.doubleSided,
377
- emissiveFactor: sourceMaterial.emissiveFactor.map(c => Math.round(c * 255)),
505
+ emissiveFactor: sourceMaterial.emissiveFactor.map(function (c) {
506
+ return Math.round(c * 255);
507
+ }),
378
508
  alphaMode: (sourceMaterial.alphaMode || 'OPAQUE').toLowerCase(),
379
509
  pbrMetallicRoughness: {
380
510
  roughnessFactor: sourceMaterial.pbrMetallicRoughness.roughnessFactor,
381
511
  metallicFactor: sourceMaterial.pbrMetallicRoughness.metallicFactor
382
512
  }
383
513
  };
384
- let texture;
514
+ var texture;
385
515
 
386
516
  if (sourceMaterial.pbrMetallicRoughness.baseColorTexture) {
387
517
  texture = sourceMaterial.pbrMetallicRoughness.baseColorTexture.texture.source;
@@ -396,13 +526,15 @@ function convertMaterial(sourceMaterial) {
396
526
  }
397
527
 
398
528
  if (!texture) {
399
- const baseColorFactor = sourceMaterial.pbrMetallicRoughness.baseColorFactor;
400
- material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map(c => Math.round(c * 255)) || undefined;
529
+ var baseColorFactor = sourceMaterial.pbrMetallicRoughness.baseColorFactor;
530
+ material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map(function (c) {
531
+ return Math.round(c * 255);
532
+ }) || undefined;
401
533
  }
402
534
 
403
535
  return {
404
- material,
405
- texture
536
+ material: material,
537
+ texture: texture
406
538
  };
407
539
  }
408
540
 
@@ -414,8 +546,8 @@ function getDefaultMaterial() {
414
546
  }
415
547
 
416
548
  function getSharedResources(tileContent, nodeId) {
417
- const gltfMaterials = tileContent.gltf.materials;
418
- const i3sResources = {};
549
+ var gltfMaterials = tileContent.gltf.materials;
550
+ var i3sResources = {};
419
551
 
420
552
  if (!gltfMaterials || !gltfMaterials.length) {
421
553
  return i3sResources;
@@ -423,35 +555,45 @@ function getSharedResources(tileContent, nodeId) {
423
555
 
424
556
  i3sResources.materialDefinitionInfos = [];
425
557
 
426
- for (const gltfMaterial of gltfMaterials) {
427
- const {
428
- materialDefinitionInfo,
429
- textureDefinitionInfo
430
- } = convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId);
431
- i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);
558
+ var _iterator6 = _createForOfIteratorHelper(gltfMaterials),
559
+ _step6;
560
+
561
+ try {
562
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
563
+ var gltfMaterial = _step6.value;
564
+
565
+ var _convertGLTFMaterialT = convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId),
566
+ materialDefinitionInfo = _convertGLTFMaterialT.materialDefinitionInfo,
567
+ textureDefinitionInfo = _convertGLTFMaterialT.textureDefinitionInfo;
568
+
569
+ i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);
432
570
 
433
- if (textureDefinitionInfo) {
434
- i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];
435
- i3sResources.textureDefinitionInfos.push(textureDefinitionInfo);
571
+ if (textureDefinitionInfo) {
572
+ i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];
573
+ i3sResources.textureDefinitionInfos.push(textureDefinitionInfo);
574
+ }
436
575
  }
576
+ } catch (err) {
577
+ _iterator6.e(err);
578
+ } finally {
579
+ _iterator6.f();
437
580
  }
438
581
 
439
582
  return i3sResources;
440
583
  }
441
584
 
442
585
  function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
443
- const texture = gltfMaterial.pbrMetallicRoughness.baseColorTexture || gltfMaterial.emissiveTexture;
444
- let textureDefinitionInfo = null;
586
+ var texture = gltfMaterial.pbrMetallicRoughness.baseColorTexture || gltfMaterial.emissiveTexture;
587
+ var textureDefinitionInfo = null;
445
588
 
446
589
  if (texture) {
447
590
  textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);
448
591
  }
449
592
 
450
- const {
451
- baseColorFactor,
452
- metallicFactor
453
- } = gltfMaterial.pbrMetallicRoughness;
454
- let colorFactor = baseColorFactor;
593
+ var _gltfMaterial$pbrMeta = gltfMaterial.pbrMetallicRoughness,
594
+ baseColorFactor = _gltfMaterial$pbrMeta.baseColorFactor,
595
+ metallicFactor = _gltfMaterial$pbrMeta.metallicFactor;
596
+ var colorFactor = baseColorFactor;
455
597
 
456
598
  if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {
457
599
  colorFactor = gltfMaterial.emissiveFactor;
@@ -460,20 +602,21 @@ function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
460
602
 
461
603
  return {
462
604
  materialDefinitionInfo: extractSharedResourcesMaterialInfo(colorFactor, metallicFactor),
463
- textureDefinitionInfo
605
+ textureDefinitionInfo: textureDefinitionInfo
464
606
  };
465
607
  }
466
608
 
467
- function extractSharedResourcesMaterialInfo(baseColorFactor, metallicFactor = 0) {
468
- const matDielectricColorComponent = 0.04 / 255;
469
- const black = new _core.Vector4(0, 0, 0, 1);
470
- const unitVector = new _core.Vector4(1, 1, 1, 1);
471
- const dielectricSpecular = new _core.Vector4(matDielectricColorComponent, matDielectricColorComponent, matDielectricColorComponent, 0);
472
- const baseColorVector = new _core.Vector4(baseColorFactor);
473
- const firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);
474
- const diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);
609
+ function extractSharedResourcesMaterialInfo(baseColorFactor) {
610
+ var metallicFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
611
+ var matDielectricColorComponent = 0.04 / 255;
612
+ var black = new _core.Vector4(0, 0, 0, 1);
613
+ var unitVector = new _core.Vector4(1, 1, 1, 1);
614
+ var dielectricSpecular = new _core.Vector4(matDielectricColorComponent, matDielectricColorComponent, matDielectricColorComponent, 0);
615
+ var baseColorVector = new _core.Vector4(baseColorFactor);
616
+ var firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);
617
+ var diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);
475
618
  dielectricSpecular[3] = 1;
476
- const specular = dielectricSpecular.lerp(dielectricSpecular, baseColorVector, metallicFactor);
619
+ var specular = dielectricSpecular.lerp(dielectricSpecular, baseColorVector, metallicFactor);
477
620
  return {
478
621
  diffuse: diffuse.toArray(),
479
622
  specular: specular.toArray()
@@ -492,36 +635,35 @@ function extractSharedResourcesTextureInfo(texture, nodeId) {
492
635
  }
493
636
 
494
637
  function generateImageId(texture, nodeId) {
495
- const {
496
- width,
497
- height
498
- } = texture.source.image;
499
- const levelCountOfTexture = 1;
500
- const indexOfLevel = 0;
501
- const indexOfTextureInStore = nodeId + 1;
502
- const zerosCount = 32 - indexOfTextureInStore.toString(2).length;
503
- const rightHalf = '0'.repeat(zerosCount).concat(indexOfTextureInStore.toString(2));
504
- const shiftedLevelCountOfTexture = levelCountOfTexture << 28;
505
- const shiftedIndexOfLevel = indexOfLevel << 24;
506
- const shiftedWidth = width - 1 << 12;
507
- const shiftedHeight = height - 1 << 0;
508
- const leftHalf = shiftedLevelCountOfTexture + shiftedIndexOfLevel + shiftedWidth + shiftedHeight;
509
- const imageId = BigInt("0b".concat(leftHalf.toString(2)).concat(rightHalf));
638
+ var _texture$source$image = texture.source.image,
639
+ width = _texture$source$image.width,
640
+ height = _texture$source$image.height;
641
+ var levelCountOfTexture = 1;
642
+ var indexOfLevel = 0;
643
+ var indexOfTextureInStore = nodeId + 1;
644
+ var zerosCount = 32 - indexOfTextureInStore.toString(2).length;
645
+ var rightHalf = '0'.repeat(zerosCount).concat(indexOfTextureInStore.toString(2));
646
+ var shiftedLevelCountOfTexture = levelCountOfTexture << 28;
647
+ var shiftedIndexOfLevel = indexOfLevel << 24;
648
+ var shiftedWidth = width - 1 << 12;
649
+ var shiftedHeight = height - 1 << 0;
650
+ var leftHalf = shiftedLevelCountOfTexture + shiftedIndexOfLevel + shiftedWidth + shiftedHeight;
651
+ var imageId = BigInt("0b".concat(leftHalf.toString(2)).concat(rightHalf));
510
652
  return imageId.toString();
511
653
  }
512
654
 
513
655
  function makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, batchTable) {
514
- const replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
656
+ var replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
515
657
  replaceIndicesByUnique(featureIndices, replaceMap);
516
658
  replaceIndicesByUnique(featureIds, replaceMap);
517
659
  }
518
660
 
519
661
  function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
520
- const featureMap = {};
662
+ var featureMap = {};
521
663
 
522
- for (let index = 0; index < featureIds.length; index++) {
523
- const oldFeatureId = featureIds[index];
524
- const uniqueFeatureId = getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray);
664
+ for (var index = 0; index < featureIds.length; index++) {
665
+ var oldFeatureId = featureIds[index];
666
+ var uniqueFeatureId = getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray);
525
667
  featureMap[oldFeatureId.toString()] = uniqueFeatureId;
526
668
  }
527
669
 
@@ -529,9 +671,9 @@ function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
529
671
  }
530
672
 
531
673
  function generateStringFromBatchTableByIndex(batchTable, index) {
532
- let str = '';
674
+ var str = '';
533
675
 
534
- for (const key in batchTable) {
676
+ for (var key in batchTable) {
535
677
  str += batchTable[key][index];
536
678
  }
537
679
 
@@ -539,8 +681,8 @@ function generateStringFromBatchTableByIndex(batchTable, index) {
539
681
  }
540
682
 
541
683
  function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
542
- const batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);
543
- const hash = (0, _md.default)(batchTableStr);
684
+ var batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);
685
+ var hash = (0, _md.default)(batchTableStr);
544
686
 
545
687
  if (featuresHashArray.includes(hash)) {
546
688
  return featuresHashArray.indexOf(hash);
@@ -550,23 +692,22 @@ function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
550
692
  }
551
693
 
552
694
  function replaceIndicesByUnique(indicesArray, featureMap) {
553
- for (let index = 0; index < indicesArray.length; index++) {
695
+ for (var index = 0; index < indicesArray.length; index++) {
554
696
  indicesArray[index] = featureMap[indicesArray[index]];
555
697
  }
556
698
  }
557
699
 
558
700
  function convertBatchTableToAttributeBuffers(batchTable, featureIds, attributeStorageInfo) {
559
- const attributeBuffers = [];
701
+ var attributeBuffers = [];
560
702
 
561
703
  if (batchTable) {
562
- const batchTableWithFeatureIds = {
563
- OBJECTID: featureIds,
564
- ...batchTable
565
- };
704
+ var batchTableWithFeatureIds = _objectSpread({
705
+ OBJECTID: featureIds
706
+ }, batchTable);
566
707
 
567
- for (const key in batchTableWithFeatureIds) {
568
- const type = getAttributeType(key, attributeStorageInfo);
569
- let attributeBuffer = null;
708
+ for (var key in batchTableWithFeatureIds) {
709
+ var type = getAttributeType(key, attributeStorageInfo);
710
+ var attributeBuffer = null;
570
711
 
571
712
  switch (type) {
572
713
  case OBJECT_ID_TYPE:
@@ -594,104 +735,124 @@ function convertBatchTableToAttributeBuffers(batchTable, featureIds, attributeSt
594
735
  }
595
736
 
596
737
  function getAttributeType(key, attributeStorageInfo) {
597
- const attribute = attributeStorageInfo.find(attr => attr.name === key);
738
+ var attribute = attributeStorageInfo.find(function (attr) {
739
+ return attr.name === key;
740
+ });
598
741
  return attribute.attributeValues.valueType;
599
742
  }
600
743
 
601
744
  function generateShortIntegerAttributeBuffer(featureIds) {
602
- const count = new Uint32Array([featureIds.length]);
603
- const valuesArray = new Uint32Array(featureIds);
745
+ var count = new Uint32Array([featureIds.length]);
746
+ var valuesArray = new Uint32Array(featureIds);
604
747
  return (0, _loaderUtils.concatenateArrayBuffers)(count.buffer, valuesArray.buffer);
605
748
  }
606
749
 
607
750
  function generateDoubleAttributeBuffer(featureIds) {
608
- const count = new Uint32Array([featureIds.length]);
609
- const padding = new Uint8Array(4);
610
- const valuesArray = new Float64Array(featureIds);
751
+ var count = new Uint32Array([featureIds.length]);
752
+ var padding = new Uint8Array(4);
753
+ var valuesArray = new Float64Array(featureIds);
611
754
  return (0, _loaderUtils.concatenateArrayBuffers)(count.buffer, padding.buffer, valuesArray.buffer);
612
755
  }
613
756
 
614
757
  function generateStringAttributeBuffer(batchAttributes) {
615
- const stringCountArray = new Uint32Array([batchAttributes.length]);
616
- let totalNumberOfBytes = 0;
617
- const stringSizesArray = new Uint32Array(batchAttributes.length);
618
- const stringBufferArray = [];
619
-
620
- for (let index = 0; index < batchAttributes.length; index++) {
621
- const currentString = "".concat(String(batchAttributes[index]), "\0");
622
- const currentStringBuffer = Buffer.from(currentString);
623
- const currentStringSize = currentStringBuffer.length;
758
+ var stringCountArray = new Uint32Array([batchAttributes.length]);
759
+ var totalNumberOfBytes = 0;
760
+ var stringSizesArray = new Uint32Array(batchAttributes.length);
761
+ var stringBufferArray = [];
762
+
763
+ for (var index = 0; index < batchAttributes.length; index++) {
764
+ var currentString = "".concat(String(batchAttributes[index]), "\0");
765
+ var currentStringBuffer = Buffer.from(currentString);
766
+ var currentStringSize = currentStringBuffer.length;
624
767
  totalNumberOfBytes += currentStringSize;
625
768
  stringSizesArray[index] = currentStringSize;
626
769
  stringBufferArray.push(currentStringBuffer);
627
770
  }
628
771
 
629
- const totalBytes = new Uint32Array([totalNumberOfBytes]);
630
- return (0, _loaderUtils.concatenateArrayBuffers)(stringCountArray.buffer, totalBytes.buffer, stringSizesArray.buffer, ...stringBufferArray);
772
+ var totalBytes = new Uint32Array([totalNumberOfBytes]);
773
+ return _loaderUtils.concatenateArrayBuffers.apply(void 0, [stringCountArray.buffer, totalBytes.buffer, stringSizesArray.buffer].concat(stringBufferArray));
631
774
  }
632
775
 
633
776
  function generateBigUint64Array(featureIds) {
634
- const typedFeatureIds = new BigUint64Array(featureIds.length);
777
+ var typedFeatureIds = new BigUint64Array(featureIds.length);
635
778
 
636
- for (let index = 0; index < featureIds.length; index++) {
779
+ for (var index = 0; index < featureIds.length; index++) {
637
780
  typedFeatureIds[index] = BigInt(featureIds[index]);
638
781
  }
639
782
 
640
783
  return typedFeatureIds;
641
784
  }
642
785
 
643
- async function generateCompressedGeometry(vertexCount, convertedAttributes, attributes) {
644
- const {
645
- positions,
646
- normals,
647
- texCoords,
648
- colors,
649
- featureIds,
650
- faceRange
651
- } = attributes;
652
- const indices = new Uint32Array(vertexCount);
653
-
654
- for (let index = 0; index < indices.length; index++) {
655
- indices.set([index], index);
656
- }
657
-
658
- const featureIndices = new Uint32Array(convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount);
659
- const featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
660
- const compressedAttributes = {
661
- positions,
662
- normals,
663
- colors,
664
- 'feature-index': featureIndex
665
- };
666
-
667
- if (texCoords.length) {
668
- compressedAttributes.texCoords = texCoords;
669
- }
670
-
671
- const attributesMetadata = {
672
- 'feature-index': {
673
- 'i3s-attribute-type': 'feature-index',
674
- 'i3s-feature-ids': new Int32Array(featureIds)
675
- }
676
- };
677
- return new Uint8Array(await (0, _core2.encode)({
678
- attributes: compressedAttributes,
679
- indices
680
- }, _draco.DracoWriter, {
681
- draco: {
682
- method: 'MESH_SEQUENTIAL_ENCODING',
683
- attributesMetadata
684
- }
786
+ function generateCompressedGeometry(_x7, _x8, _x9) {
787
+ return _generateCompressedGeometry.apply(this, arguments);
788
+ }
789
+
790
+ function _generateCompressedGeometry() {
791
+ _generateCompressedGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(vertexCount, convertedAttributes, attributes) {
792
+ var positions, normals, texCoords, colors, featureIds, faceRange, indices, index, featureIndices, featureIndex, compressedAttributes, attributesMetadata;
793
+ return _regenerator.default.wrap(function _callee3$(_context3) {
794
+ while (1) {
795
+ switch (_context3.prev = _context3.next) {
796
+ case 0:
797
+ positions = attributes.positions, normals = attributes.normals, texCoords = attributes.texCoords, colors = attributes.colors, featureIds = attributes.featureIds, faceRange = attributes.faceRange;
798
+ indices = new Uint32Array(vertexCount);
799
+
800
+ for (index = 0; index < indices.length; index++) {
801
+ indices.set([index], index);
802
+ }
803
+
804
+ featureIndices = new Uint32Array(convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount);
805
+ featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
806
+ compressedAttributes = {
807
+ positions: positions,
808
+ normals: normals,
809
+ colors: colors,
810
+ 'feature-index': featureIndex
811
+ };
812
+
813
+ if (texCoords.length) {
814
+ compressedAttributes.texCoords = texCoords;
815
+ }
816
+
817
+ attributesMetadata = {
818
+ 'feature-index': {
819
+ 'i3s-attribute-type': 'feature-index',
820
+ 'i3s-feature-ids': new Int32Array(featureIds)
821
+ }
822
+ };
823
+ _context3.t0 = Uint8Array;
824
+ _context3.next = 11;
825
+ return (0, _core2.encode)({
826
+ attributes: compressedAttributes,
827
+ indices: indices
828
+ }, _draco.DracoWriter, {
829
+ draco: {
830
+ method: 'MESH_SEQUENTIAL_ENCODING',
831
+ attributesMetadata: attributesMetadata
832
+ }
833
+ });
834
+
835
+ case 11:
836
+ _context3.t1 = _context3.sent;
837
+ return _context3.abrupt("return", new _context3.t0(_context3.t1));
838
+
839
+ case 13:
840
+ case "end":
841
+ return _context3.stop();
842
+ }
843
+ }
844
+ }, _callee3);
685
845
  }));
846
+ return _generateCompressedGeometry.apply(this, arguments);
686
847
  }
687
848
 
688
849
  function generateFeatureIndexAttribute(featureIndex, faceRange) {
689
- const orderedFeatureIndices = new Uint32Array(featureIndex.length);
690
- let fillIndex = 0;
691
- let startIndex = 0;
850
+ var orderedFeatureIndices = new Uint32Array(featureIndex.length);
851
+ var fillIndex = 0;
852
+ var startIndex = 0;
692
853
 
693
- for (let index = 1; index < faceRange.length; index += 2) {
694
- const endIndex = (faceRange[index] + 1) * VALUES_PER_VERTEX;
854
+ for (var index = 1; index < faceRange.length; index += 2) {
855
+ var endIndex = (faceRange[index] + 1) * VALUES_PER_VERTEX;
695
856
  orderedFeatureIndices.fill(fillIndex, startIndex, endIndex);
696
857
  fillIndex++;
697
858
  startIndex = endIndex + 1;