@loaders.gl/i3s 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 (36) hide show
  1. package/dist/dist.es5.min.js +1 -1
  2. package/dist/dist.es5.min.js.map +1 -1
  3. package/dist/dist.min.js +1 -1
  4. package/dist/dist.min.js.map +1 -1
  5. package/dist/es5/bundle.js +2 -2
  6. package/dist/es5/bundle.js.map +1 -1
  7. package/dist/es5/i3s-attribute-loader.js +132 -53
  8. package/dist/es5/i3s-attribute-loader.js.map +1 -1
  9. package/dist/es5/i3s-content-loader.js +36 -10
  10. package/dist/es5/i3s-content-loader.js.map +1 -1
  11. package/dist/es5/i3s-loader.js +175 -51
  12. package/dist/es5/i3s-loader.js.map +1 -1
  13. package/dist/es5/i3s-node-page-loader.js +51 -8
  14. package/dist/es5/i3s-node-page-loader.js.map +1 -1
  15. package/dist/es5/index.js +4 -4
  16. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js +313 -163
  17. package/dist/es5/lib/helpers/i3s-nodepages-tiles.js.map +1 -1
  18. package/dist/es5/lib/parsers/constants.js +9 -9
  19. package/dist/es5/lib/parsers/constants.js.map +1 -1
  20. package/dist/es5/lib/parsers/parse-i3s-attribute.js +68 -26
  21. package/dist/es5/lib/parsers/parse-i3s-attribute.js.map +1 -1
  22. package/dist/es5/lib/parsers/parse-i3s-tile-content.js +405 -276
  23. package/dist/es5/lib/parsers/parse-i3s-tile-content.js.map +1 -1
  24. package/dist/es5/lib/parsers/parse-i3s.js +70 -31
  25. package/dist/es5/lib/parsers/parse-i3s.js.map +1 -1
  26. package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js +8 -4
  27. package/dist/es5/lib/utils/convert-i3s-obb-to-mbs.js.map +1 -1
  28. package/dist/es5/lib/utils/url-utils.js +14 -17
  29. package/dist/es5/lib/utils/url-utils.js.map +1 -1
  30. package/dist/esm/i3s-attribute-loader.js +1 -1
  31. package/dist/esm/i3s-content-loader.js +1 -1
  32. package/dist/esm/i3s-loader.js +1 -1
  33. package/dist/esm/i3s-node-page-loader.js +1 -1
  34. package/dist/i3s-content-worker.js +1 -1
  35. package/dist/i3s-content-worker.js.map +1 -1
  36. package/package.json +9 -9
@@ -1,10 +1,20 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.parseI3STileContent = parseI3STileContent;
7
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
+
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
16
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
17
+
8
18
  var _core = require("@loaders.gl/core");
9
19
 
10
20
  var _core2 = require("@math.gl/core");
@@ -21,157 +31,270 @@ var _urlUtils = require("../utils/url-utils");
21
31
 
22
32
  var _constants = require("./constants");
23
33
 
24
- const scratchVector = new _core2.Vector3([0, 0, 0]);
25
- const FORMAT_LOADER_MAP = {
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
+ 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; }
41
+
42
+ 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; }
43
+
44
+ var scratchVector = new _core2.Vector3([0, 0, 0]);
45
+ var FORMAT_LOADER_MAP = {
26
46
  jpeg: _images.ImageLoader,
27
47
  png: _images.ImageLoader,
28
48
  'ktx-etc2': _textures.CompressedTextureLoader,
29
49
  dds: _textures.CompressedTextureLoader
30
50
  };
31
- const I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';
32
-
33
- async function parseI3STileContent(arrayBuffer, tile, tileset, options, context) {
34
- tile.content = tile.content || {};
35
- tile.content.featureIds = tile.content.featureIds || null;
36
- tile.content.featureData = constructFeatureDataStruct(tile, tileset);
37
- tile.content.attributes = {};
38
-
39
- if (tile.textureUrl) {
40
- var _options$i3s;
41
-
42
- const url = (0, _urlUtils.getUrlWithToken)(tile.textureUrl, options === null || options === void 0 ? void 0 : (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
43
- const loader = FORMAT_LOADER_MAP[tile.textureFormat] || _images.ImageLoader;
44
- const response = await fetch(url);
45
- const arrayBuffer = await response.arrayBuffer();
46
-
47
- if (loader === _images.ImageLoader) {
48
- const options = {
49
- image: {
50
- type: 'data'
51
- }
52
- };
53
- tile.content.texture = await context.parse(arrayBuffer, options);
54
- } else if (loader === _textures.CompressedTextureLoader) {
55
- const texture = await (0, _core.load)(arrayBuffer, _textures.CompressedTextureLoader);
56
- tile.content.texture = {
57
- compressed: true,
58
- mipmaps: false,
59
- width: texture[0].width,
60
- height: texture[0].height,
61
- data: texture
62
- };
63
- }
64
- }
51
+ var I3S_ATTRIBUTE_TYPE = 'i3s-attribute-type';
65
52
 
66
- tile.content.material = makePbrMaterial(tile.materialDefinition, tile.content.texture);
67
-
68
- if (tile.content.material) {
69
- tile.content.texture = null;
70
- }
71
-
72
- return await parseI3SNodeGeometry(arrayBuffer, tile, context);
53
+ function parseI3STileContent(_x, _x2, _x3, _x4, _x5) {
54
+ return _parseI3STileContent.apply(this, arguments);
73
55
  }
74
56
 
75
- async function parseI3SNodeGeometry(arrayBuffer, tile = {}, context) {
76
- if (!tile.content) {
77
- return tile;
78
- }
79
-
80
- const content = tile.content;
81
- let attributes;
82
- let vertexCount;
83
- let byteOffset = 0;
84
- let featureCount = 0;
85
-
86
- if (tile.isDracoGeometry) {
87
- const decompressedGeometry = await (0, _core.parse)(arrayBuffer, _draco.DracoLoader, {
88
- draco: {
89
- attributeNameEntry: I3S_ATTRIBUTE_TYPE
57
+ function _parseI3STileContent() {
58
+ _parseI3STileContent = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer, tile, tileset, options, context) {
59
+ var _options$i3s, url, loader, response, _arrayBuffer, _options, texture;
60
+
61
+ return _regenerator.default.wrap(function _callee$(_context) {
62
+ while (1) {
63
+ switch (_context.prev = _context.next) {
64
+ case 0:
65
+ tile.content = tile.content || {};
66
+ tile.content.featureIds = tile.content.featureIds || null;
67
+ tile.content.featureData = constructFeatureDataStruct(tile, tileset);
68
+ tile.content.attributes = {};
69
+
70
+ if (!tile.textureUrl) {
71
+ _context.next = 25;
72
+ break;
73
+ }
74
+
75
+ url = (0, _urlUtils.getUrlWithToken)(tile.textureUrl, options === null || options === void 0 ? void 0 : (_options$i3s = options.i3s) === null || _options$i3s === void 0 ? void 0 : _options$i3s.token);
76
+ loader = FORMAT_LOADER_MAP[tile.textureFormat] || _images.ImageLoader;
77
+ _context.next = 9;
78
+ return fetch(url);
79
+
80
+ case 9:
81
+ response = _context.sent;
82
+ _context.next = 12;
83
+ return response.arrayBuffer();
84
+
85
+ case 12:
86
+ _arrayBuffer = _context.sent;
87
+
88
+ if (!(loader === _images.ImageLoader)) {
89
+ _context.next = 20;
90
+ break;
91
+ }
92
+
93
+ _options = {
94
+ image: {
95
+ type: 'data'
96
+ }
97
+ };
98
+ _context.next = 17;
99
+ return context.parse(_arrayBuffer, _options);
100
+
101
+ case 17:
102
+ tile.content.texture = _context.sent;
103
+ _context.next = 25;
104
+ break;
105
+
106
+ case 20:
107
+ if (!(loader === _textures.CompressedTextureLoader)) {
108
+ _context.next = 25;
109
+ break;
110
+ }
111
+
112
+ _context.next = 23;
113
+ return (0, _core.load)(_arrayBuffer, _textures.CompressedTextureLoader);
114
+
115
+ case 23:
116
+ texture = _context.sent;
117
+ tile.content.texture = {
118
+ compressed: true,
119
+ mipmaps: false,
120
+ width: texture[0].width,
121
+ height: texture[0].height,
122
+ data: texture
123
+ };
124
+
125
+ case 25:
126
+ tile.content.material = makePbrMaterial(tile.materialDefinition, tile.content.texture);
127
+
128
+ if (tile.content.material) {
129
+ tile.content.texture = null;
130
+ }
131
+
132
+ _context.next = 29;
133
+ return parseI3SNodeGeometry(arrayBuffer, tile, context);
134
+
135
+ case 29:
136
+ return _context.abrupt("return", _context.sent);
137
+
138
+ case 30:
139
+ case "end":
140
+ return _context.stop();
141
+ }
90
142
  }
91
- });
92
- vertexCount = decompressedGeometry.header.vertexCount;
93
- const indices = decompressedGeometry.indices.value;
94
- const {
95
- POSITION,
96
- NORMAL,
97
- COLOR_0,
98
- TEXCOORD_0,
99
- ['feature-index']: featureIndex,
100
- ['uv-region']: uvRegion
101
- } = decompressedGeometry.attributes;
102
- attributes = {
103
- position: POSITION,
104
- normal: NORMAL,
105
- color: COLOR_0,
106
- uv0: TEXCOORD_0,
107
- uvRegion,
108
- id: featureIndex,
109
- indices
110
- };
111
- updateAttributesMetadata(attributes, decompressedGeometry);
112
- const featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);
113
-
114
- if (featureIds) {
115
- flattenFeatureIdsByFeatureIndices(attributes, featureIds);
116
- }
117
- } else {
118
- const {
119
- vertexAttributes,
120
- attributesOrder,
121
- featureAttributes,
122
- featureAttributeOrder
123
- } = content.featureData;
124
- const headers = parseHeaders(content, arrayBuffer);
125
- byteOffset = headers.byteOffset;
126
- vertexCount = headers.vertexCount;
127
- featureCount = headers.featureCount;
128
- const {
129
- attributes: normalizedVertexAttributes,
130
- byteOffset: offset
131
- } = normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, vertexCount, attributesOrder);
132
- const {
133
- attributes: normalizedFeatureAttributes
134
- } = normalizeAttributes(arrayBuffer, offset, featureAttributes, featureCount, featureAttributeOrder);
135
- flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);
136
- attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);
137
- }
138
-
139
- const {
140
- enuMatrix,
141
- cartographicOrigin,
142
- cartesianOrigin
143
- } = parsePositions(attributes.position, tile);
144
- const matrix = new _core2.Matrix4().multiplyRight(enuMatrix);
145
- content.attributes = {
146
- positions: attributes.position,
147
- normals: attributes.normal,
148
- colors: normalizeAttribute(attributes.color),
149
- texCoords: attributes.uv0,
150
- uvRegions: normalizeAttribute(attributes.uvRegion)
151
- };
152
- content.indices = attributes.indices || null;
153
-
154
- if (attributes.id && attributes.id.value) {
155
- tile.content.featureIds = attributes.id.value;
156
- }
143
+ }, _callee);
144
+ }));
145
+ return _parseI3STileContent.apply(this, arguments);
146
+ }
157
147
 
158
- for (const attributeIndex in content.attributes) {
159
- if (!content.attributes[attributeIndex]) {
160
- delete content.attributes[attributeIndex];
161
- }
162
- }
148
+ function parseI3SNodeGeometry(_x6) {
149
+ return _parseI3SNodeGeometry.apply(this, arguments);
150
+ }
163
151
 
164
- content.vertexCount = vertexCount;
165
- content.cartographicCenter = cartographicOrigin;
166
- content.cartesianOrigin = cartesianOrigin;
167
- content.modelMatrix = matrix.invert();
168
- content.byteLength = arrayBuffer.byteLength;
169
- return tile;
152
+ function _parseI3SNodeGeometry() {
153
+ _parseI3SNodeGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(arrayBuffer) {
154
+ var tile,
155
+ context,
156
+ content,
157
+ attributes,
158
+ vertexCount,
159
+ byteOffset,
160
+ featureCount,
161
+ decompressedGeometry,
162
+ indices,
163
+ _decompressedGeometry,
164
+ POSITION,
165
+ NORMAL,
166
+ COLOR_0,
167
+ TEXCOORD_0,
168
+ featureIndex,
169
+ uvRegion,
170
+ featureIds,
171
+ _content$featureData,
172
+ vertexAttributes,
173
+ attributesOrder,
174
+ featureAttributes,
175
+ featureAttributeOrder,
176
+ headers,
177
+ _normalizeAttributes,
178
+ normalizedVertexAttributes,
179
+ offset,
180
+ _normalizeAttributes2,
181
+ normalizedFeatureAttributes,
182
+ _parsePositions,
183
+ enuMatrix,
184
+ cartographicOrigin,
185
+ cartesianOrigin,
186
+ matrix,
187
+ attributeIndex,
188
+ _args2 = arguments;
189
+
190
+ return _regenerator.default.wrap(function _callee2$(_context2) {
191
+ while (1) {
192
+ switch (_context2.prev = _context2.next) {
193
+ case 0:
194
+ tile = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {};
195
+ context = _args2.length > 2 ? _args2[2] : undefined;
196
+
197
+ if (tile.content) {
198
+ _context2.next = 4;
199
+ break;
200
+ }
201
+
202
+ return _context2.abrupt("return", tile);
203
+
204
+ case 4:
205
+ content = tile.content;
206
+ byteOffset = 0;
207
+ featureCount = 0;
208
+
209
+ if (!tile.isDracoGeometry) {
210
+ _context2.next = 20;
211
+ break;
212
+ }
213
+
214
+ _context2.next = 10;
215
+ return (0, _core.parse)(arrayBuffer, _draco.DracoLoader, {
216
+ draco: {
217
+ attributeNameEntry: I3S_ATTRIBUTE_TYPE
218
+ }
219
+ });
220
+
221
+ case 10:
222
+ decompressedGeometry = _context2.sent;
223
+ vertexCount = decompressedGeometry.header.vertexCount;
224
+ indices = decompressedGeometry.indices.value;
225
+ _decompressedGeometry = decompressedGeometry.attributes, POSITION = _decompressedGeometry.POSITION, NORMAL = _decompressedGeometry.NORMAL, COLOR_0 = _decompressedGeometry.COLOR_0, TEXCOORD_0 = _decompressedGeometry.TEXCOORD_0, featureIndex = _decompressedGeometry['feature-index'], uvRegion = _decompressedGeometry['uv-region'];
226
+ attributes = {
227
+ position: POSITION,
228
+ normal: NORMAL,
229
+ color: COLOR_0,
230
+ uv0: TEXCOORD_0,
231
+ uvRegion: uvRegion,
232
+ id: featureIndex,
233
+ indices: indices
234
+ };
235
+ updateAttributesMetadata(attributes, decompressedGeometry);
236
+ featureIds = getFeatureIdsFromFeatureIndexMetadata(featureIndex);
237
+
238
+ if (featureIds) {
239
+ flattenFeatureIdsByFeatureIndices(attributes, featureIds);
240
+ }
241
+
242
+ _context2.next = 29;
243
+ break;
244
+
245
+ case 20:
246
+ _content$featureData = content.featureData, vertexAttributes = _content$featureData.vertexAttributes, attributesOrder = _content$featureData.attributesOrder, featureAttributes = _content$featureData.featureAttributes, featureAttributeOrder = _content$featureData.featureAttributeOrder;
247
+ headers = parseHeaders(content, arrayBuffer);
248
+ byteOffset = headers.byteOffset;
249
+ vertexCount = headers.vertexCount;
250
+ featureCount = headers.featureCount;
251
+ _normalizeAttributes = normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, vertexCount, attributesOrder), normalizedVertexAttributes = _normalizeAttributes.attributes, offset = _normalizeAttributes.byteOffset;
252
+ _normalizeAttributes2 = normalizeAttributes(arrayBuffer, offset, featureAttributes, featureCount, featureAttributeOrder), normalizedFeatureAttributes = _normalizeAttributes2.attributes;
253
+ flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes);
254
+ attributes = concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes);
255
+
256
+ case 29:
257
+ _parsePositions = parsePositions(attributes.position, tile), enuMatrix = _parsePositions.enuMatrix, cartographicOrigin = _parsePositions.cartographicOrigin, cartesianOrigin = _parsePositions.cartesianOrigin;
258
+ matrix = new _core2.Matrix4().multiplyRight(enuMatrix);
259
+ content.attributes = {
260
+ positions: attributes.position,
261
+ normals: attributes.normal,
262
+ colors: normalizeAttribute(attributes.color),
263
+ texCoords: attributes.uv0,
264
+ uvRegions: normalizeAttribute(attributes.uvRegion)
265
+ };
266
+ content.indices = attributes.indices || null;
267
+
268
+ if (attributes.id && attributes.id.value) {
269
+ tile.content.featureIds = attributes.id.value;
270
+ }
271
+
272
+ for (attributeIndex in content.attributes) {
273
+ if (!content.attributes[attributeIndex]) {
274
+ delete content.attributes[attributeIndex];
275
+ }
276
+ }
277
+
278
+ content.vertexCount = vertexCount;
279
+ content.cartographicCenter = cartographicOrigin;
280
+ content.cartesianOrigin = cartesianOrigin;
281
+ content.modelMatrix = matrix.invert();
282
+ content.byteLength = arrayBuffer.byteLength;
283
+ return _context2.abrupt("return", tile);
284
+
285
+ case 41:
286
+ case "end":
287
+ return _context2.stop();
288
+ }
289
+ }
290
+ }, _callee2);
291
+ }));
292
+ return _parseI3SNodeGeometry.apply(this, arguments);
170
293
  }
171
294
 
172
295
  function updateAttributesMetadata(attributes, decompressedGeometry) {
173
- for (const key in decompressedGeometry.loaderData.attributes) {
174
- const dracoAttribute = decompressedGeometry.loaderData.attributes[key];
296
+ for (var key in decompressedGeometry.loaderData.attributes) {
297
+ var dracoAttribute = decompressedGeometry.loaderData.attributes[key];
175
298
 
176
299
  switch (dracoAttribute.name) {
177
300
  case 'POSITION':
@@ -189,9 +312,7 @@ function updateAttributesMetadata(attributes, decompressedGeometry) {
189
312
  }
190
313
 
191
314
  function concatAttributes(normalizedVertexAttributes, normalizedFeatureAttributes) {
192
- return { ...normalizedVertexAttributes,
193
- ...normalizedFeatureAttributes
194
- };
315
+ return _objectSpread(_objectSpread({}, normalizedVertexAttributes), normalizedFeatureAttributes);
195
316
  }
196
317
 
197
318
  function normalizeAttribute(attribute) {
@@ -204,25 +325,25 @@ function normalizeAttribute(attribute) {
204
325
  }
205
326
 
206
327
  function constructFeatureDataStruct(tile, tileset) {
207
- const defaultGeometrySchema = tileset.store.defaultGeometrySchema;
208
- const featureData = defaultGeometrySchema;
328
+ var defaultGeometrySchema = tileset.store.defaultGeometrySchema;
329
+ var featureData = defaultGeometrySchema;
209
330
 
210
- for (const geometryAttribute in _constants.I3S_NAMED_GEOMETRY_ATTRIBUTES) {
211
- for (const namedAttribute in _constants.I3S_NAMED_VERTEX_ATTRIBUTES) {
212
- const attribute = defaultGeometrySchema[geometryAttribute][namedAttribute];
331
+ for (var geometryAttribute in _constants.I3S_NAMED_GEOMETRY_ATTRIBUTES) {
332
+ for (var namedAttribute in _constants.I3S_NAMED_VERTEX_ATTRIBUTES) {
333
+ var attribute = defaultGeometrySchema[geometryAttribute][namedAttribute];
213
334
 
214
335
  if (attribute) {
215
- const {
216
- byteOffset = 0,
217
- count = 0,
218
- valueType,
219
- valuesPerElement
220
- } = attribute;
336
+ var _attribute$byteOffset = attribute.byteOffset,
337
+ byteOffset = _attribute$byteOffset === void 0 ? 0 : _attribute$byteOffset,
338
+ _attribute$count = attribute.count,
339
+ count = _attribute$count === void 0 ? 0 : _attribute$count,
340
+ valueType = attribute.valueType,
341
+ valuesPerElement = attribute.valuesPerElement;
221
342
  featureData[geometryAttribute][namedAttribute] = {
222
- valueType,
223
- valuesPerElement,
224
- byteOffset,
225
- count
343
+ valueType: valueType,
344
+ valuesPerElement: valuesPerElement,
345
+ byteOffset: byteOffset,
346
+ count: count
226
347
  };
227
348
  }
228
349
  }
@@ -233,17 +354,16 @@ function constructFeatureDataStruct(tile, tileset) {
233
354
  }
234
355
 
235
356
  function parseHeaders(content, buffer) {
236
- let byteOffset = 0;
237
- let vertexCount = 0;
238
- let featureCount = 0;
239
- const headers = content.featureData[_constants.I3S_NAMED_HEADER_ATTRIBUTES.header];
240
-
241
- for (const header in headers) {
242
- const {
243
- property,
244
- type
245
- } = headers[header];
246
- const TypedArrayTypeHeader = _constants.TYPE_ARRAY_MAP[type];
357
+ var byteOffset = 0;
358
+ var vertexCount = 0;
359
+ var featureCount = 0;
360
+ var headers = content.featureData[_constants.I3S_NAMED_HEADER_ATTRIBUTES.header];
361
+
362
+ for (var header in headers) {
363
+ var _headers$header = headers[header],
364
+ property = _headers$header.property,
365
+ type = _headers$header.type;
366
+ var TypedArrayTypeHeader = _constants.TYPE_ARRAY_MAP[type];
247
367
 
248
368
  if (property === _constants.I3S_NAMED_HEADER_ATTRIBUTES.vertexCount) {
249
369
  vertexCount = new TypedArrayTypeHeader(buffer, 0, 4)[0];
@@ -257,73 +377,83 @@ function parseHeaders(content, buffer) {
257
377
  }
258
378
 
259
379
  return {
260
- vertexCount,
261
- featureCount,
262
- byteOffset
380
+ vertexCount: vertexCount,
381
+ featureCount: featureCount,
382
+ byteOffset: byteOffset
263
383
  };
264
384
  }
265
385
 
266
386
  function normalizeAttributes(arrayBuffer, byteOffset, vertexAttributes, vertexCount, attributesOrder) {
267
- const attributes = {};
387
+ var attributes = {};
268
388
 
269
- for (const attribute of attributesOrder) {
270
- if (vertexAttributes[attribute]) {
271
- const {
272
- valueType,
273
- valuesPerElement
274
- } = vertexAttributes[attribute];
275
- const count = vertexCount;
389
+ var _iterator = _createForOfIteratorHelper(attributesOrder),
390
+ _step;
276
391
 
277
- if (byteOffset + count * valuesPerElement > arrayBuffer.byteLength) {
278
- break;
279
- }
392
+ try {
393
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
394
+ var attribute = _step.value;
280
395
 
281
- const buffer = arrayBuffer.slice(byteOffset);
282
- let value = [];
396
+ if (vertexAttributes[attribute]) {
397
+ var _vertexAttributes$att = vertexAttributes[attribute],
398
+ valueType = _vertexAttributes$att.valueType,
399
+ valuesPerElement = _vertexAttributes$att.valuesPerElement;
400
+ var count = vertexCount;
283
401
 
284
- if (valueType === 'UInt64') {
285
- value = parseUint64Values(buffer, count * valuesPerElement, _constants.SIZEOF[valueType]);
286
- } else {
287
- const TypedArrayType = _constants.TYPE_ARRAY_MAP[valueType];
288
- value = new TypedArrayType(buffer, 0, count * valuesPerElement);
289
- }
402
+ if (byteOffset + count * valuesPerElement > arrayBuffer.byteLength) {
403
+ break;
404
+ }
290
405
 
291
- attributes[attribute] = {
292
- value,
293
- type: _constants.GL_TYPE_MAP[valueType],
294
- size: valuesPerElement
295
- };
406
+ var buffer = arrayBuffer.slice(byteOffset);
407
+ var value = [];
296
408
 
297
- switch (attribute) {
298
- case 'color':
299
- attributes.color.normalized = true;
300
- break;
409
+ if (valueType === 'UInt64') {
410
+ value = parseUint64Values(buffer, count * valuesPerElement, _constants.SIZEOF[valueType]);
411
+ } else {
412
+ var TypedArrayType = _constants.TYPE_ARRAY_MAP[valueType];
413
+ value = new TypedArrayType(buffer, 0, count * valuesPerElement);
414
+ }
301
415
 
302
- case 'position':
303
- case 'region':
304
- case 'normal':
305
- default:
306
- }
416
+ attributes[attribute] = {
417
+ value: value,
418
+ type: _constants.GL_TYPE_MAP[valueType],
419
+ size: valuesPerElement
420
+ };
307
421
 
308
- byteOffset = byteOffset + count * valuesPerElement * _constants.SIZEOF[valueType];
422
+ switch (attribute) {
423
+ case 'color':
424
+ attributes.color.normalized = true;
425
+ break;
426
+
427
+ case 'position':
428
+ case 'region':
429
+ case 'normal':
430
+ default:
431
+ }
432
+
433
+ byteOffset = byteOffset + count * valuesPerElement * _constants.SIZEOF[valueType];
434
+ }
309
435
  }
436
+ } catch (err) {
437
+ _iterator.e(err);
438
+ } finally {
439
+ _iterator.f();
310
440
  }
311
441
 
312
442
  return {
313
- attributes,
314
- byteOffset
443
+ attributes: attributes,
444
+ byteOffset: byteOffset
315
445
  };
316
446
  }
317
447
 
318
448
  function parseUint64Values(buffer, elementsCount, attributeSize) {
319
- const values = [];
320
- const dataView = new DataView(buffer);
321
- let offset = 0;
322
-
323
- for (let index = 0; index < elementsCount; index++) {
324
- const left = dataView.getUint32(offset, true);
325
- const right = dataView.getUint32(offset + 4, true);
326
- const value = left + 2 ** 32 * right;
449
+ var values = [];
450
+ var dataView = new DataView(buffer);
451
+ var offset = 0;
452
+
453
+ for (var index = 0; index < elementsCount; index++) {
454
+ var left = dataView.getUint32(offset, true);
455
+ var right = dataView.getUint32(offset + 4, true);
456
+ var value = left + Math.pow(2, 32) * right;
327
457
  values.push(value);
328
458
  offset += attributeSize;
329
459
  }
@@ -332,12 +462,12 @@ function parseUint64Values(buffer, elementsCount, attributeSize) {
332
462
  }
333
463
 
334
464
  function parsePositions(attribute, tile) {
335
- const mbs = tile.mbs;
336
- const value = attribute.value;
337
- const metadata = attribute.metadata;
338
- const enuMatrix = new _core2.Matrix4();
339
- const cartographicOrigin = new _core2.Vector3(mbs[0], mbs[1], mbs[2]);
340
- const cartesianOrigin = new _core2.Vector3();
465
+ var mbs = tile.mbs;
466
+ var value = attribute.value;
467
+ var metadata = attribute.metadata;
468
+ var enuMatrix = new _core2.Matrix4();
469
+ var cartographicOrigin = new _core2.Vector3(mbs[0], mbs[1], mbs[2]);
470
+ var cartesianOrigin = new _core2.Vector3();
341
471
 
342
472
  _geospatial.Ellipsoid.WGS84.cartographicToCartesian(cartographicOrigin, cartesianOrigin);
343
473
 
@@ -345,45 +475,46 @@ function parsePositions(attribute, tile) {
345
475
 
346
476
  attribute.value = offsetsToCartesians(value, metadata, cartographicOrigin);
347
477
  return {
348
- enuMatrix,
478
+ enuMatrix: enuMatrix,
349
479
  fixedFrameToENUMatrix: enuMatrix.invert(),
350
- cartographicOrigin,
351
- cartesianOrigin
480
+ cartographicOrigin: cartographicOrigin,
481
+ cartesianOrigin: cartesianOrigin
352
482
  };
353
483
  }
354
484
 
355
- function offsetsToCartesians(vertices, metadata = {}, cartographicOrigin) {
356
- const positions = new Float64Array(vertices.length);
357
- const scaleX = metadata['i3s-scale_x'] && metadata['i3s-scale_x'].double || 1;
358
- const scaleY = metadata['i3s-scale_y'] && metadata['i3s-scale_y'].double || 1;
485
+ function offsetsToCartesians(vertices) {
486
+ var metadata = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
487
+ var cartographicOrigin = arguments.length > 2 ? arguments[2] : undefined;
488
+ var positions = new Float64Array(vertices.length);
489
+ var scaleX = metadata['i3s-scale_x'] && metadata['i3s-scale_x'].double || 1;
490
+ var scaleY = metadata['i3s-scale_y'] && metadata['i3s-scale_y'].double || 1;
359
491
 
360
- for (let i = 0; i < positions.length; i += 3) {
492
+ for (var i = 0; i < positions.length; i += 3) {
361
493
  positions[i] = vertices[i] * scaleX + cartographicOrigin.x;
362
494
  positions[i + 1] = vertices[i + 1] * scaleY + cartographicOrigin.y;
363
495
  positions[i + 2] = vertices[i + 2] + cartographicOrigin.z;
364
496
  }
365
497
 
366
- for (let i = 0; i < positions.length; i += 3) {
367
- _geospatial.Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(i, i + 3), scratchVector);
498
+ for (var _i = 0; _i < positions.length; _i += 3) {
499
+ _geospatial.Ellipsoid.WGS84.cartographicToCartesian(positions.subarray(_i, _i + 3), scratchVector);
368
500
 
369
- positions[i] = scratchVector.x;
370
- positions[i + 1] = scratchVector.y;
371
- positions[i + 2] = scratchVector.z;
501
+ positions[_i] = scratchVector.x;
502
+ positions[_i + 1] = scratchVector.y;
503
+ positions[_i + 2] = scratchVector.z;
372
504
  }
373
505
 
374
506
  return positions;
375
507
  }
376
508
 
377
509
  function makePbrMaterial(materialDefinition, texture) {
378
- let pbrMaterial;
510
+ var pbrMaterial;
379
511
 
380
512
  if (materialDefinition) {
381
- pbrMaterial = { ...materialDefinition,
382
- pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness ? { ...materialDefinition.pbrMetallicRoughness
383
- } : {
513
+ pbrMaterial = _objectSpread(_objectSpread({}, materialDefinition), {}, {
514
+ pbrMetallicRoughness: materialDefinition.pbrMetallicRoughness ? _objectSpread({}, materialDefinition.pbrMetallicRoughness) : {
384
515
  baseColorFactor: [255, 255, 255, 255]
385
516
  }
386
- };
517
+ });
387
518
  } else {
388
519
  pbrMaterial = {
389
520
  pbrMetallicRoughness: {}
@@ -417,9 +548,9 @@ function makePbrMaterial(materialDefinition, texture) {
417
548
  }
418
549
 
419
550
  function convertColorFormat(colorFactor) {
420
- const normalizedColor = [...colorFactor];
551
+ var normalizedColor = (0, _toConsumableArray2.default)(colorFactor);
421
552
 
422
- for (let index = 0; index < colorFactor.length; index++) {
553
+ for (var index = 0; index < colorFactor.length; index++) {
423
554
  normalizedColor[index] = colorFactor[index] / 255;
424
555
  }
425
556
 
@@ -427,58 +558,56 @@ function convertColorFormat(colorFactor) {
427
558
  }
428
559
 
429
560
  function setMaterialTexture(material, image) {
430
- const texture = {
561
+ var texture = {
431
562
  source: {
432
- image
563
+ image: image
433
564
  }
434
565
  };
435
566
 
436
567
  if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.baseColorTexture) {
437
- material.pbrMetallicRoughness.baseColorTexture = { ...material.pbrMetallicRoughness.baseColorTexture,
438
- texture
439
- };
568
+ material.pbrMetallicRoughness.baseColorTexture = _objectSpread(_objectSpread({}, material.pbrMetallicRoughness.baseColorTexture), {}, {
569
+ texture: texture
570
+ });
440
571
  } else if (material.emissiveTexture) {
441
- material.emissiveTexture = { ...material.emissiveTexture,
442
- texture
443
- };
572
+ material.emissiveTexture = _objectSpread(_objectSpread({}, material.emissiveTexture), {}, {
573
+ texture: texture
574
+ });
444
575
  } else if (material.pbrMetallicRoughness && material.pbrMetallicRoughness.metallicRoughnessTexture) {
445
- material.pbrMetallicRoughness.metallicRoughnessTexture = { ...material.pbrMetallicRoughness.metallicRoughnessTexture,
446
- texture
447
- };
576
+ material.pbrMetallicRoughness.metallicRoughnessTexture = _objectSpread(_objectSpread({}, material.pbrMetallicRoughness.metallicRoughnessTexture), {}, {
577
+ texture: texture
578
+ });
448
579
  } else if (material.normalTexture) {
449
- material.normalTexture = { ...material.normalTexture,
450
- texture
451
- };
580
+ material.normalTexture = _objectSpread(_objectSpread({}, material.normalTexture), {}, {
581
+ texture: texture
582
+ });
452
583
  } else if (material.occlusionTexture) {
453
- material.occlusionTexture = { ...material.occlusionTexture,
454
- texture
455
- };
584
+ material.occlusionTexture = _objectSpread(_objectSpread({}, material.occlusionTexture), {}, {
585
+ texture: texture
586
+ });
456
587
  }
457
588
  }
458
589
 
459
590
  function flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes) {
460
- const {
461
- id,
462
- faceRange
463
- } = normalizedFeatureAttributes;
591
+ var id = normalizedFeatureAttributes.id,
592
+ faceRange = normalizedFeatureAttributes.faceRange;
464
593
 
465
594
  if (!id || !faceRange) {
466
595
  return;
467
596
  }
468
597
 
469
- const featureIds = id.value;
470
- const range = faceRange.value;
471
- const featureIdsLength = range[range.length - 1] + 1;
472
- const orderedFeatureIndices = new Uint32Array(featureIdsLength * 3);
473
- let featureIndex = 0;
474
- let startIndex = 0;
475
-
476
- for (let index = 1; index < range.length; index += 2) {
477
- const fillId = Number(featureIds[featureIndex]);
478
- const endValue = range[index];
479
- const prevValue = range[index - 1];
480
- const trianglesCount = endValue - prevValue + 1;
481
- const endIndex = startIndex + trianglesCount * 3;
598
+ var featureIds = id.value;
599
+ var range = faceRange.value;
600
+ var featureIdsLength = range[range.length - 1] + 1;
601
+ var orderedFeatureIndices = new Uint32Array(featureIdsLength * 3);
602
+ var featureIndex = 0;
603
+ var startIndex = 0;
604
+
605
+ for (var index = 1; index < range.length; index += 2) {
606
+ var fillId = Number(featureIds[featureIndex]);
607
+ var endValue = range[index];
608
+ var prevValue = range[index - 1];
609
+ var trianglesCount = endValue - prevValue + 1;
610
+ var endIndex = startIndex + trianglesCount * 3;
482
611
  orderedFeatureIndices.fill(fillId, startIndex, endIndex);
483
612
  featureIndex++;
484
613
  startIndex = endIndex;
@@ -488,10 +617,10 @@ function flattenFeatureIdsByFaceRanges(normalizedFeatureAttributes) {
488
617
  }
489
618
 
490
619
  function flattenFeatureIdsByFeatureIndices(attributes, featureIds) {
491
- const featureIndices = attributes.id.value;
492
- const result = new Float32Array(featureIndices.length);
620
+ var featureIndices = attributes.id.value;
621
+ var result = new Float32Array(featureIndices.length);
493
622
 
494
- for (let index = 0; index < featureIndices.length; index++) {
623
+ for (var index = 0; index < featureIndices.length; index++) {
495
624
  result[index] = featureIds[featureIndices[index]];
496
625
  }
497
626