@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
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.convertAttributes = convertAttributes;
9
8
  exports.default = convertB3dmToI3sGeometry;
10
9
  exports.getPropertyTable = getPropertyTable;
11
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
14
10
  var _math = require("@loaders.gl/math");
15
11
  var _core = require("@math.gl/core");
16
12
  var _geospatial = require("@math.gl/geospatial");
@@ -24,323 +20,194 @@ var _coordinateConverter = require("./coordinate-converter");
24
20
  var _gltfAttributes = require("./gltf-attributes");
25
21
  var _batchIdsExtensions = require("./batch-ids-extensions");
26
22
  var _featureAttributes = require("./feature-attributes");
27
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
28
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
- 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; }
30
- 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; }
31
- 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; } } }; }
32
- 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); }
33
- 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; }
34
- var DEFAULT_ROUGHNESS_FACTOR = 1;
35
- var DEFAULT_METALLIC_FACTOR = 1;
36
- var VALUES_PER_VERTEX = 3;
37
- var VALUES_PER_TEX_COORD = 2;
38
- var VALUES_PER_COLOR_ELEMENT = 4;
39
- var STRING_TYPE = 'string';
40
- var SHORT_INT_TYPE = 'Int32';
41
- var DOUBLE_TYPE = 'Float64';
42
- var OBJECT_ID_TYPE = 'Oid32';
43
- var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
44
- var EXT_FEATURE_METADATA = 'EXT_feature_metadata';
45
- var EXT_MESH_FEATURES = 'EXT_mesh_features';
46
- var scratchVector = new _core.Vector3();
47
- function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8, _x9, _x10) {
48
- return _convertB3dmToI3sGeometry.apply(this, arguments);
49
- }
50
- function _convertB3dmToI3sGeometry() {
51
- _convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, workerSource) {
52
- var _tileContent$gltf4;
53
- var useCartesianPositions, materialAndTextureList, dataForAttributesConversion, convertedAttributesMap, result, _iterator6, _step6, materialAndTexture, originarMaterialId, convertedAttributes, material, texture, nodeId;
54
- return _regenerator.default.wrap(function _callee$(_context) {
55
- while (1) switch (_context.prev = _context.next) {
56
- case 0:
57
- useCartesianPositions = generateBoundingVolumes;
58
- _context.next = 3;
59
- return convertMaterials((_tileContent$gltf4 = tileContent.gltf) === null || _tileContent$gltf4 === void 0 ? void 0 : _tileContent$gltf4.materials, shouldMergeMaterials);
60
- case 3:
61
- materialAndTextureList = _context.sent;
62
- dataForAttributesConversion = (0, _gltfAttributes.prepareDataForAttributesConversion)(tileContent);
63
- _context.next = 7;
64
- return convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions);
65
- case 7:
66
- convertedAttributesMap = _context.sent;
67
- if (generateBoundingVolumes) {
68
- _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
69
- }
70
- result = [];
71
- _iterator6 = _createForOfIteratorHelper(materialAndTextureList);
72
- _context.prev = 11;
73
- _iterator6.s();
74
- case 13:
75
- if ((_step6 = _iterator6.n()).done) {
76
- _context.next = 32;
77
- break;
78
- }
79
- materialAndTexture = _step6.value;
80
- originarMaterialId = materialAndTexture.mergedMaterials[0].originalMaterialId;
81
- if (convertedAttributesMap.has(originarMaterialId)) {
82
- _context.next = 18;
83
- break;
84
- }
85
- return _context.abrupt("continue", 30);
86
- case 18:
87
- convertedAttributes = convertedAttributesMap.get(originarMaterialId);
88
- if (convertedAttributes) {
89
- _context.next = 21;
90
- break;
91
- }
92
- return _context.abrupt("continue", 30);
93
- case 21:
94
- material = materialAndTexture.material, texture = materialAndTexture.texture;
95
- _context.next = 24;
96
- return addNodeToNodePage();
97
- case 24:
98
- nodeId = _context.sent;
99
- _context.t0 = result;
100
- _context.next = 28;
101
- return _makeNodeResources({
102
- convertedAttributes: convertedAttributes,
103
- material: material,
104
- texture: texture,
105
- tileContent: tileContent,
106
- nodeId: nodeId,
107
- featuresHashArray: featuresHashArray,
108
- propertyTable: propertyTable,
109
- attributeStorageInfo: attributeStorageInfo,
110
- draco: draco,
111
- workerSource: workerSource
112
- });
113
- case 28:
114
- _context.t1 = _context.sent;
115
- _context.t0.push.call(_context.t0, _context.t1);
116
- case 30:
117
- _context.next = 13;
118
- break;
119
- case 32:
120
- _context.next = 37;
121
- break;
122
- case 34:
123
- _context.prev = 34;
124
- _context.t2 = _context["catch"](11);
125
- _iterator6.e(_context.t2);
126
- case 37:
127
- _context.prev = 37;
128
- _iterator6.f();
129
- return _context.finish(37);
130
- case 40:
131
- if (result.length) {
132
- _context.next = 42;
133
- break;
134
- }
135
- return _context.abrupt("return", null);
136
- case 42:
137
- return _context.abrupt("return", result);
138
- case 43:
139
- case "end":
140
- return _context.stop();
141
- }
142
- }, _callee, null, [[11, 34, 37, 40]]);
143
- }));
144
- return _convertB3dmToI3sGeometry.apply(this, arguments);
23
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
24
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
+ const DEFAULT_ROUGHNESS_FACTOR = 1;
26
+ const DEFAULT_METALLIC_FACTOR = 1;
27
+ const VALUES_PER_VERTEX = 3;
28
+ const VALUES_PER_TEX_COORD = 2;
29
+ const VALUES_PER_COLOR_ELEMENT = 4;
30
+ const STRING_TYPE = 'string';
31
+ const SHORT_INT_TYPE = 'Int32';
32
+ const DOUBLE_TYPE = 'Float64';
33
+ const OBJECT_ID_TYPE = 'Oid32';
34
+ const BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
35
+ const EXT_FEATURE_METADATA = 'EXT_feature_metadata';
36
+ const EXT_MESH_FEATURES = 'EXT_mesh_features';
37
+ let scratchVector = new _core.Vector3();
38
+ async function convertB3dmToI3sGeometry(tileContent, addNodeToNodePage, propertyTable, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, shouldMergeMaterials, geoidHeightModel, workerSource) {
39
+ var _tileContent$gltf;
40
+ const useCartesianPositions = generateBoundingVolumes;
41
+ const materialAndTextureList = await convertMaterials((_tileContent$gltf = tileContent.gltf) === null || _tileContent$gltf === void 0 ? void 0 : _tileContent$gltf.materials, shouldMergeMaterials);
42
+ const dataForAttributesConversion = (0, _gltfAttributes.prepareDataForAttributesConversion)(tileContent);
43
+ const convertedAttributesMap = await convertAttributes(dataForAttributesConversion, materialAndTextureList, useCartesianPositions);
44
+ if (generateBoundingVolumes) {
45
+ _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
46
+ }
47
+ const result = [];
48
+ for (const materialAndTexture of materialAndTextureList) {
49
+ const originarMaterialId = materialAndTexture.mergedMaterials[0].originalMaterialId;
50
+ if (!convertedAttributesMap.has(originarMaterialId)) {
51
+ continue;
52
+ }
53
+ const convertedAttributes = convertedAttributesMap.get(originarMaterialId);
54
+ if (!convertedAttributes) {
55
+ continue;
56
+ }
57
+ const {
58
+ material,
59
+ texture
60
+ } = materialAndTexture;
61
+ const nodeId = await addNodeToNodePage();
62
+ result.push(await _makeNodeResources({
63
+ convertedAttributes,
64
+ material,
65
+ texture,
66
+ tileContent,
67
+ nodeId,
68
+ featuresHashArray,
69
+ propertyTable,
70
+ attributeStorageInfo,
71
+ draco,
72
+ workerSource
73
+ }));
74
+ }
75
+ if (!result.length) {
76
+ return null;
77
+ }
78
+ return result;
145
79
  }
146
80
  function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel) {
147
- var _iterator = _createForOfIteratorHelper(convertedAttributesMap.values()),
148
- _step;
149
- try {
150
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
151
- var attributes = _step.value;
152
- var boundingVolumes = (0, _coordinateConverter.createBoundingVolumesFromGeometry)(attributes.positions, geoidHeightModel);
153
- attributes.boundingVolumes = boundingVolumes;
154
- var cartographicOrigin = boundingVolumes.obb.center;
155
- for (var index = 0; index < attributes.positions.length; index += VALUES_PER_VERTEX) {
156
- var vertex = attributes.positions.subarray(index, index + VALUES_PER_VERTEX);
157
- _geospatial.Ellipsoid.WGS84.cartesianToCartographic(Array.from(vertex), scratchVector);
158
- scratchVector[2] = scratchVector[2] - geoidHeightModel.getHeight(scratchVector[1], scratchVector[0]);
159
- scratchVector = scratchVector.subtract(cartographicOrigin);
160
- attributes.positions.set(scratchVector, index);
161
- }
81
+ for (const attributes of convertedAttributesMap.values()) {
82
+ const boundingVolumes = (0, _coordinateConverter.createBoundingVolumesFromGeometry)(attributes.positions, geoidHeightModel);
83
+ attributes.boundingVolumes = boundingVolumes;
84
+ const cartographicOrigin = boundingVolumes.obb.center;
85
+ for (let index = 0; index < attributes.positions.length; index += VALUES_PER_VERTEX) {
86
+ const vertex = attributes.positions.subarray(index, index + VALUES_PER_VERTEX);
87
+ _geospatial.Ellipsoid.WGS84.cartesianToCartographic(Array.from(vertex), scratchVector);
88
+ scratchVector[2] = scratchVector[2] - geoidHeightModel.getHeight(scratchVector[1], scratchVector[0]);
89
+ scratchVector = scratchVector.subtract(cartographicOrigin);
90
+ attributes.positions.set(scratchVector, index);
162
91
  }
163
- } catch (err) {
164
- _iterator.e(err);
165
- } finally {
166
- _iterator.f();
167
92
  }
168
93
  }
169
- function _makeNodeResources(_x11) {
170
- return _makeNodeResources2.apply(this, arguments);
171
- }
172
- function _makeNodeResources2() {
173
- _makeNodeResources2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref) {
174
- var _tileContent$gltf5;
175
- var convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, propertyTable, attributeStorageInfo, draco, workerSource, boundingVolumes, vertexCount, _generateAttributes, faceRange, featureIds, positions, normals, colors, uvRegions, texCoords, featureCount, header, typedFeatureIds, fileBuffer, compressedGeometry, attributes;
176
- return _regenerator.default.wrap(function _callee2$(_context2) {
177
- while (1) switch (_context2.prev = _context2.next) {
178
- case 0:
179
- convertedAttributes = _ref.convertedAttributes, material = _ref.material, texture = _ref.texture, tileContent = _ref.tileContent, nodeId = _ref.nodeId, featuresHashArray = _ref.featuresHashArray, propertyTable = _ref.propertyTable, attributeStorageInfo = _ref.attributeStorageInfo, draco = _ref.draco, workerSource = _ref.workerSource;
180
- boundingVolumes = convertedAttributes.boundingVolumes;
181
- vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
182
- _generateAttributes = (0, _geometryAttributes.generateAttributes)(convertedAttributes), faceRange = _generateAttributes.faceRange, featureIds = _generateAttributes.featureIds, positions = _generateAttributes.positions, normals = _generateAttributes.normals, colors = _generateAttributes.colors, uvRegions = _generateAttributes.uvRegions, texCoords = _generateAttributes.texCoords, featureCount = _generateAttributes.featureCount;
183
- if (tileContent.batchTableJson) {
184
- makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, tileContent.batchTableJson);
185
- }
186
- header = new Uint32Array(2);
187
- typedFeatureIds = generateBigUint64Array(featureIds);
188
- header.set([vertexCount, featureCount], 0);
189
- fileBuffer = new Uint8Array((0, _loaderUtils.concatenateArrayBuffers)(header.buffer, positions.buffer, normals.buffer, texture ? texCoords.buffer : new ArrayBuffer(0), colors.buffer, uvRegions, typedFeatureIds.buffer, faceRange.buffer));
190
- compressedGeometry = draco ? generateCompressedGeometry(vertexCount, convertedAttributes, {
191
- positions: positions,
192
- normals: normals,
193
- texCoords: texture ? texCoords : new Float32Array(0),
194
- colors: colors,
195
- uvRegions: uvRegions,
196
- featureIds: featureIds,
197
- faceRange: faceRange
198
- }, workerSource.draco) : null;
199
- attributes = [];
200
- if (attributeStorageInfo && propertyTable) {
201
- attributes = convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo);
202
- }
203
- return _context2.abrupt("return", {
204
- nodeId: nodeId,
205
- geometry: fileBuffer,
206
- compressedGeometry: compressedGeometry,
207
- texture: texture,
208
- hasUvRegions: Boolean(uvRegions.length),
209
- sharedResources: getSharedResources(((_tileContent$gltf5 = tileContent.gltf) === null || _tileContent$gltf5 === void 0 ? void 0 : _tileContent$gltf5.materials) || [], nodeId),
210
- meshMaterial: material,
211
- vertexCount: vertexCount,
212
- attributes: attributes,
213
- featureCount: featureCount,
214
- boundingVolumes: boundingVolumes
215
- });
216
- case 13:
217
- case "end":
218
- return _context2.stop();
219
- }
220
- }, _callee2);
221
- }));
222
- return _makeNodeResources2.apply(this, arguments);
223
- }
224
- function convertAttributes(_x12, _x13, _x14) {
225
- return _convertAttributes.apply(this, arguments);
94
+ async function _makeNodeResources(_ref) {
95
+ var _tileContent$gltf2;
96
+ let {
97
+ convertedAttributes,
98
+ material,
99
+ texture,
100
+ tileContent,
101
+ nodeId,
102
+ featuresHashArray,
103
+ propertyTable,
104
+ attributeStorageInfo,
105
+ draco,
106
+ workerSource
107
+ } = _ref;
108
+ const boundingVolumes = convertedAttributes.boundingVolumes;
109
+ const vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
110
+ const {
111
+ faceRange,
112
+ featureIds,
113
+ positions,
114
+ normals,
115
+ colors,
116
+ uvRegions,
117
+ texCoords,
118
+ featureCount
119
+ } = (0, _geometryAttributes.generateAttributes)(convertedAttributes);
120
+ if (tileContent.batchTableJson) {
121
+ makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, tileContent.batchTableJson);
122
+ }
123
+ const header = new Uint32Array(2);
124
+ const typedFeatureIds = generateBigUint64Array(featureIds);
125
+ header.set([vertexCount, featureCount], 0);
126
+ const fileBuffer = new Uint8Array((0, _loaderUtils.concatenateArrayBuffers)(header.buffer, positions.buffer, normals.buffer, texture ? texCoords.buffer : new ArrayBuffer(0), colors.buffer, uvRegions, typedFeatureIds.buffer, faceRange.buffer));
127
+ const compressedGeometry = draco ? generateCompressedGeometry(vertexCount, convertedAttributes, {
128
+ positions,
129
+ normals,
130
+ texCoords: texture ? texCoords : new Float32Array(0),
131
+ colors,
132
+ uvRegions,
133
+ featureIds,
134
+ faceRange
135
+ }, workerSource.draco) : null;
136
+ let attributes = [];
137
+ if (attributeStorageInfo && propertyTable) {
138
+ attributes = convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo);
139
+ }
140
+ return {
141
+ nodeId,
142
+ geometry: fileBuffer,
143
+ compressedGeometry,
144
+ texture,
145
+ hasUvRegions: Boolean(uvRegions.length),
146
+ sharedResources: getSharedResources(((_tileContent$gltf2 = tileContent.gltf) === null || _tileContent$gltf2 === void 0 ? void 0 : _tileContent$gltf2.materials) || [], nodeId),
147
+ meshMaterial: material,
148
+ vertexCount,
149
+ attributes,
150
+ featureCount,
151
+ boundingVolumes
152
+ };
226
153
  }
227
- function _convertAttributes() {
228
- _convertAttributes = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(attributesData, materialAndTextureList, useCartesianPositions) {
229
- var nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, _iterator7, _step7, materialAndTexture, attributes, _iterator9, _step9, mergedMaterial, _iterator8, _step8, attrKey, _attributes;
230
- return _regenerator.default.wrap(function _callee3$(_context3) {
231
- while (1) switch (_context3.prev = _context3.next) {
232
- case 0:
233
- nodes = attributesData.nodes, images = attributesData.images, cartographicOrigin = attributesData.cartographicOrigin, cartesianModelMatrix = attributesData.cartesianModelMatrix;
234
- attributesMap = new Map();
235
- _iterator7 = _createForOfIteratorHelper(materialAndTextureList);
236
- try {
237
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
238
- materialAndTexture = _step7.value;
239
- attributes = {
240
- positions: new Float32Array(0),
241
- normals: new Float32Array(0),
242
- texCoords: new Float32Array(0),
243
- colors: new Uint8Array(0),
244
- uvRegions: new Uint16Array(0),
245
- featureIndicesGroups: [],
246
- featureIndices: [],
247
- boundingVolumes: null,
248
- mergedMaterials: materialAndTexture.mergedMaterials
249
- };
250
- _iterator9 = _createForOfIteratorHelper(materialAndTexture.mergedMaterials);
251
- try {
252
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
253
- mergedMaterial = _step9.value;
254
- attributesMap.set(mergedMaterial.originalMaterialId, attributes);
255
- }
256
- } catch (err) {
257
- _iterator9.e(err);
258
- } finally {
259
- _iterator9.f();
260
- }
261
- }
262
- } catch (err) {
263
- _iterator7.e(err);
264
- } finally {
265
- _iterator7.f();
266
- }
267
- convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
268
- _iterator8 = _createForOfIteratorHelper(attributesMap.keys());
269
- _context3.prev = 6;
270
- _iterator8.s();
271
- case 8:
272
- if ((_step8 = _iterator8.n()).done) {
273
- _context3.next = 19;
274
- break;
275
- }
276
- attrKey = _step8.value;
277
- _attributes = attributesMap.get(attrKey);
278
- if (_attributes) {
279
- _context3.next = 13;
280
- break;
281
- }
282
- return _context3.abrupt("continue", 17);
283
- case 13:
284
- if (!(_attributes.positions.length === 0)) {
285
- _context3.next = 16;
286
- break;
287
- }
288
- attributesMap.delete(attrKey);
289
- return _context3.abrupt("continue", 17);
290
- case 16:
291
- if (_attributes.featureIndicesGroups) {
292
- _attributes.featureIndices = _attributes.featureIndicesGroups.reduce(function (acc, value) {
293
- return acc.concat(value);
294
- });
295
- delete _attributes.featureIndicesGroups;
296
- }
297
- case 17:
298
- _context3.next = 8;
299
- break;
300
- case 19:
301
- _context3.next = 24;
302
- break;
303
- case 21:
304
- _context3.prev = 21;
305
- _context3.t0 = _context3["catch"](6);
306
- _iterator8.e(_context3.t0);
307
- case 24:
308
- _context3.prev = 24;
309
- _iterator8.f();
310
- return _context3.finish(24);
311
- case 27:
312
- return _context3.abrupt("return", attributesMap);
313
- case 28:
314
- case "end":
315
- return _context3.stop();
316
- }
317
- }, _callee3, null, [[6, 21, 24, 27]]);
318
- }));
319
- return _convertAttributes.apply(this, arguments);
154
+ async function convertAttributes(attributesData, materialAndTextureList, useCartesianPositions) {
155
+ const {
156
+ nodes,
157
+ images,
158
+ cartographicOrigin,
159
+ cartesianModelMatrix
160
+ } = attributesData;
161
+ const attributesMap = new Map();
162
+ for (const materialAndTexture of materialAndTextureList) {
163
+ const attributes = {
164
+ positions: new Float32Array(0),
165
+ normals: new Float32Array(0),
166
+ texCoords: new Float32Array(0),
167
+ colors: new Uint8Array(0),
168
+ uvRegions: new Uint16Array(0),
169
+ featureIndicesGroups: [],
170
+ featureIndices: [],
171
+ boundingVolumes: null,
172
+ mergedMaterials: materialAndTexture.mergedMaterials
173
+ };
174
+ for (const mergedMaterial of materialAndTexture.mergedMaterials) {
175
+ attributesMap.set(mergedMaterial.originalMaterialId, attributes);
176
+ }
177
+ }
178
+ convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
179
+ for (const attrKey of attributesMap.keys()) {
180
+ const attributes = attributesMap.get(attrKey);
181
+ if (!attributes) {
182
+ continue;
183
+ }
184
+ if (attributes.positions.length === 0) {
185
+ attributesMap.delete(attrKey);
186
+ continue;
187
+ }
188
+ if (attributes.featureIndicesGroups) {
189
+ attributes.featureIndices = attributes.featureIndicesGroups.reduce((acc, value) => acc.concat(value));
190
+ delete attributes.featureIndicesGroups;
191
+ }
192
+ }
193
+ return attributesMap;
320
194
  }
321
195
  function convertNodes(nodes, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
322
- var matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
196
+ let matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
323
197
  if (nodes) {
324
- var _iterator2 = _createForOfIteratorHelper(nodes),
325
- _step2;
326
- try {
327
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
328
- var node = _step2.value;
329
- convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix);
330
- }
331
- } catch (err) {
332
- _iterator2.e(err);
333
- } finally {
334
- _iterator2.f();
198
+ for (const node of nodes) {
199
+ convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix);
335
200
  }
336
201
  }
337
202
  }
338
203
  function getCompositeTransformationMatrix(node, matrix) {
339
- var transformationMatrix = matrix;
340
- var nodeMatrix = node.matrix,
341
- rotation = node.rotation,
342
- scale = node.scale,
343
- translation = node.translation;
204
+ let transformationMatrix = matrix;
205
+ const {
206
+ matrix: nodeMatrix,
207
+ rotation,
208
+ scale,
209
+ translation
210
+ } = node;
344
211
  if (nodeMatrix) {
345
212
  transformationMatrix = matrix.multiplyRight(nodeMatrix);
346
213
  }
@@ -356,87 +223,76 @@ function getCompositeTransformationMatrix(node, matrix) {
356
223
  return transformationMatrix;
357
224
  }
358
225
  function convertNode(node, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
359
- var matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
360
- var transformationMatrix = getCompositeTransformationMatrix(node, matrix);
361
- var mesh = node.mesh;
226
+ let matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
227
+ const transformationMatrix = getCompositeTransformationMatrix(node, matrix);
228
+ const mesh = node.mesh;
362
229
  if (mesh) {
363
230
  convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
364
231
  }
365
232
  convertNodes(node.children || [], images, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
366
233
  }
367
234
  function convertMesh(mesh, images, cartographicOrigin, cartesianModelMatrix, attributesMap) {
368
- var useCartesianPositions = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
369
- var matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
370
- var _iterator3 = _createForOfIteratorHelper(mesh.primitives),
371
- _step3;
372
- try {
373
- var _loop = function _loop() {
374
- var primitive = _step3.value;
375
- var outputAttributes = null;
376
- var materialUvRegion;
377
- if (primitive.material) {
378
- var _outputAttributes, _outputAttributes$mer;
379
- outputAttributes = attributesMap.get(primitive.material.uniqueId);
380
- materialUvRegion = (_outputAttributes = outputAttributes) === null || _outputAttributes === void 0 ? void 0 : (_outputAttributes$mer = _outputAttributes.mergedMaterials.find(function (_ref2) {
381
- var _primitive$material;
382
- var originalMaterialId = _ref2.originalMaterialId;
383
- return originalMaterialId === ((_primitive$material = primitive.material) === null || _primitive$material === void 0 ? void 0 : _primitive$material.uniqueId);
384
- })) === null || _outputAttributes$mer === void 0 ? void 0 : _outputAttributes$mer.uvRegion;
385
- } else if (attributesMap.has('default')) {
386
- outputAttributes = attributesMap.get('default');
387
- }
388
- (0, _core2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
389
- var attributes = primitive.attributes;
390
- if (!outputAttributes) {
391
- return "continue";
392
- }
393
- var indices = getIndices(primitive);
394
- outputAttributes.positions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
395
- vertices: attributes.POSITION.value,
396
- cartographicOrigin: cartographicOrigin,
397
- cartesianModelMatrix: cartesianModelMatrix,
398
- nodeMatrix: matrix,
399
- indices: indices,
400
- attributeSpecificTransformation: transformVertexPositions,
401
- useCartesianPositions: useCartesianPositions
402
- }));
403
- outputAttributes.normals = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.normals, transformVertexArray({
404
- vertices: attributes.NORMAL && attributes.NORMAL.value,
405
- cartographicOrigin: cartographicOrigin,
406
- cartesianModelMatrix: cartesianModelMatrix,
407
- nodeMatrix: matrix,
408
- indices: indices,
409
- attributeSpecificTransformation: transformVertexNormals,
410
- useCartesianPositions: false
411
- }));
412
- outputAttributes.texCoords = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, indices));
413
- outputAttributes.colors = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0, indices));
414
- if (materialUvRegion) {
415
- outputAttributes.uvRegions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.uvRegions, createUvRegion(materialUvRegion, indices));
416
- }
417
- outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
418
- outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images), indices));
419
- };
420
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
421
- var _ret = _loop();
422
- if (_ret === "continue") continue;
235
+ let useCartesianPositions = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
236
+ let matrix = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
237
+ for (const primitive of mesh.primitives) {
238
+ let outputAttributes = null;
239
+ let materialUvRegion;
240
+ if (primitive.material) {
241
+ var _outputAttributes, _outputAttributes$mer;
242
+ outputAttributes = attributesMap.get(primitive.material.uniqueId);
243
+ materialUvRegion = (_outputAttributes = outputAttributes) === null || _outputAttributes === void 0 ? void 0 : (_outputAttributes$mer = _outputAttributes.mergedMaterials.find(_ref2 => {
244
+ var _primitive$material;
245
+ let {
246
+ originalMaterialId
247
+ } = _ref2;
248
+ return originalMaterialId === ((_primitive$material = primitive.material) === null || _primitive$material === void 0 ? void 0 : _primitive$material.uniqueId);
249
+ })) === null || _outputAttributes$mer === void 0 ? void 0 : _outputAttributes$mer.uvRegion;
250
+ } else if (attributesMap.has('default')) {
251
+ outputAttributes = attributesMap.get('default');
252
+ }
253
+ (0, _core2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
254
+ const attributes = primitive.attributes;
255
+ if (!outputAttributes) {
256
+ continue;
257
+ }
258
+ const indices = getIndices(primitive);
259
+ outputAttributes.positions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
260
+ vertices: attributes.POSITION.value,
261
+ cartographicOrigin,
262
+ cartesianModelMatrix,
263
+ nodeMatrix: matrix,
264
+ indices,
265
+ attributeSpecificTransformation: transformVertexPositions,
266
+ useCartesianPositions
267
+ }));
268
+ outputAttributes.normals = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.normals, transformVertexArray({
269
+ vertices: attributes.NORMAL && attributes.NORMAL.value,
270
+ cartographicOrigin,
271
+ cartesianModelMatrix,
272
+ nodeMatrix: matrix,
273
+ indices,
274
+ attributeSpecificTransformation: transformVertexNormals,
275
+ useCartesianPositions: false
276
+ }));
277
+ outputAttributes.texCoords = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, indices));
278
+ outputAttributes.colors = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0, indices));
279
+ if (materialUvRegion) {
280
+ outputAttributes.uvRegions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.uvRegions, createUvRegion(materialUvRegion, indices));
423
281
  }
424
- } catch (err) {
425
- _iterator3.e(err);
426
- } finally {
427
- _iterator3.f();
282
+ outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
283
+ outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIds(attributes, primitive, images), indices));
428
284
  }
429
285
  }
430
286
  function getIndices(primitive) {
431
287
  var _primitive$indices;
432
- var indices = (_primitive$indices = primitive.indices) === null || _primitive$indices === void 0 ? void 0 : _primitive$indices.value;
288
+ let indices = (_primitive$indices = primitive.indices) === null || _primitive$indices === void 0 ? void 0 : _primitive$indices.value;
433
289
  if (indices && primitive.mode === _math.GL.TRIANGLE_STRIP) {
434
- var TypedArrayConstructor = indices.constructor;
435
- var newIndices = new TypedArrayConstructor((indices.length - 2) * 3);
436
- var triangleIndex = 0;
437
- var currentTriangle = indices.slice(0, 3);
290
+ const TypedArrayConstructor = indices.constructor;
291
+ const newIndices = new TypedArrayConstructor((indices.length - 2) * 3);
292
+ let triangleIndex = 0;
293
+ let currentTriangle = indices.slice(0, 3);
438
294
  newIndices.set(currentTriangle, 0);
439
- for (var i = 1; i + 2 < indices.length; i++) {
295
+ for (let i = 1; i + 2 < indices.length; i++) {
440
296
  triangleIndex += 3;
441
297
  currentTriangle = indices.slice(i, i + 3);
442
298
  if (i % 2 === 0) {
@@ -450,17 +306,19 @@ function getIndices(primitive) {
450
306
  return indices;
451
307
  }
452
308
  function transformVertexArray(args) {
453
- var vertices = args.vertices,
454
- indices = args.indices,
455
- attributeSpecificTransformation = args.attributeSpecificTransformation;
456
- var newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);
309
+ const {
310
+ vertices,
311
+ indices,
312
+ attributeSpecificTransformation
313
+ } = args;
314
+ const newVertices = new Float32Array(indices.length * VALUES_PER_VERTEX);
457
315
  if (!vertices) {
458
316
  return newVertices;
459
317
  }
460
- for (var i = 0; i < indices.length; i++) {
461
- var coordIndex = indices[i] * VALUES_PER_VERTEX;
462
- var vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX);
463
- var vertexVector = new _core.Vector3(Array.from(vertex));
318
+ for (let i = 0; i < indices.length; i++) {
319
+ const coordIndex = indices[i] * VALUES_PER_VERTEX;
320
+ const vertex = vertices.subarray(coordIndex, coordIndex + VALUES_PER_VERTEX);
321
+ let vertexVector = new _core.Vector3(Array.from(vertex));
464
322
  vertexVector = attributeSpecificTransformation(vertexVector, args);
465
323
  newVertices[i * VALUES_PER_VERTEX] = vertexVector.x;
466
324
  newVertices[i * VALUES_PER_VERTEX + 1] = vertexVector.y;
@@ -469,10 +327,12 @@ function transformVertexArray(args) {
469
327
  return newVertices;
470
328
  }
471
329
  function transformVertexPositions(vertexVector, calleeArgs) {
472
- var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
473
- cartographicOrigin = calleeArgs.cartographicOrigin,
474
- nodeMatrix = calleeArgs.nodeMatrix,
475
- useCartesianPositions = calleeArgs.useCartesianPositions;
330
+ const {
331
+ cartesianModelMatrix,
332
+ cartographicOrigin,
333
+ nodeMatrix,
334
+ useCartesianPositions
335
+ } = calleeArgs;
476
336
  if (nodeMatrix) {
477
337
  vertexVector = vertexVector.transform(nodeMatrix);
478
338
  }
@@ -485,8 +345,10 @@ function transformVertexPositions(vertexVector, calleeArgs) {
485
345
  return vertexVector;
486
346
  }
487
347
  function transformVertexNormals(vertexVector, calleeArgs) {
488
- var cartesianModelMatrix = calleeArgs.cartesianModelMatrix,
489
- nodeMatrix = calleeArgs.nodeMatrix;
348
+ const {
349
+ cartesianModelMatrix,
350
+ nodeMatrix
351
+ } = calleeArgs;
490
352
  if (nodeMatrix) {
491
353
  vertexVector = vertexVector.transformAsVector(nodeMatrix);
492
354
  }
@@ -494,32 +356,32 @@ function transformVertexNormals(vertexVector, calleeArgs) {
494
356
  return vertexVector;
495
357
  }
496
358
  function flattenTexCoords(texCoords, indices) {
497
- var newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
359
+ const newTexCoords = new Float32Array(indices.length * VALUES_PER_TEX_COORD);
498
360
  if (!texCoords) {
499
361
  newTexCoords.fill(1);
500
362
  return newTexCoords;
501
363
  }
502
- for (var i = 0; i < indices.length; i++) {
503
- var coordIndex = indices[i] * VALUES_PER_TEX_COORD;
504
- var texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);
364
+ for (let i = 0; i < indices.length; i++) {
365
+ const coordIndex = indices[i] * VALUES_PER_TEX_COORD;
366
+ const texCoord = texCoords.subarray(coordIndex, coordIndex + VALUES_PER_TEX_COORD);
505
367
  newTexCoords[i * VALUES_PER_TEX_COORD] = texCoord[0];
506
368
  newTexCoords[i * VALUES_PER_TEX_COORD + 1] = texCoord[1];
507
369
  }
508
370
  return newTexCoords;
509
371
  }
510
372
  function flattenColors(colorsAttribute, indices) {
511
- var components = (colorsAttribute === null || colorsAttribute === void 0 ? void 0 : colorsAttribute.components) || VALUES_PER_COLOR_ELEMENT;
512
- var newColors = new Uint8Array(indices.length * components);
373
+ const components = (colorsAttribute === null || colorsAttribute === void 0 ? void 0 : colorsAttribute.components) || VALUES_PER_COLOR_ELEMENT;
374
+ const newColors = new Uint8Array(indices.length * components);
513
375
  if (!colorsAttribute) {
514
376
  newColors.fill(255);
515
377
  return newColors;
516
378
  }
517
- var colors = colorsAttribute.value;
518
- for (var i = 0; i < indices.length; i++) {
519
- var colorIndex = indices[i] * components;
520
- var color = colors.subarray(colorIndex, colorIndex + components);
521
- var colorUint8 = new Uint8Array(components);
522
- for (var j = 0; j < color.length; j++) {
379
+ const colors = colorsAttribute.value;
380
+ for (let i = 0; i < indices.length; i++) {
381
+ const colorIndex = indices[i] * components;
382
+ const color = colors.subarray(colorIndex, colorIndex + components);
383
+ const colorUint8 = new Uint8Array(components);
384
+ for (let j = 0; j < color.length; j++) {
523
385
  colorUint8[j] = color[j] * 255;
524
386
  }
525
387
  newColors.set(colorUint8, i * components);
@@ -527,8 +389,8 @@ function flattenColors(colorsAttribute, indices) {
527
389
  return newColors;
528
390
  }
529
391
  function createUvRegion(materialUvRegion, indices) {
530
- var result = new Uint16Array(indices.length * 4);
531
- for (var i = 0; i < result.length; i += 4) {
392
+ const result = new Uint16Array(indices.length * 4);
393
+ for (let i = 0; i < result.length; i += 4) {
532
394
  result.set(materialUvRegion, i);
533
395
  }
534
396
  return result;
@@ -537,239 +399,124 @@ function flattenBatchIds(batchedIds, indices) {
537
399
  if (!batchedIds.length || !indices.length) {
538
400
  return [];
539
401
  }
540
- var newBatchIds = [];
541
- for (var i = 0; i < indices.length; i++) {
542
- var coordIndex = indices[i];
402
+ const newBatchIds = [];
403
+ for (let i = 0; i < indices.length; i++) {
404
+ const coordIndex = indices[i];
543
405
  newBatchIds.push(batchedIds[coordIndex]);
544
406
  }
545
407
  return newBatchIds;
546
408
  }
547
409
  function getBatchIds(attributes, primitive, images) {
548
- var batchIds = (0, _batchIdsExtensions.handleBatchIdsExtensions)(attributes, primitive, images);
410
+ const batchIds = (0, _batchIdsExtensions.handleBatchIdsExtensions)(attributes, primitive, images);
549
411
  if (batchIds.length) {
550
412
  return batchIds;
551
413
  }
552
- for (var index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {
553
- var possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];
414
+ for (let index = 0; index < BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES.length; index++) {
415
+ const possibleBatchIdAttributeName = BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES[index];
554
416
  if (attributes[possibleBatchIdAttributeName] && attributes[possibleBatchIdAttributeName].value) {
555
417
  return attributes[possibleBatchIdAttributeName].value;
556
418
  }
557
419
  }
558
420
  return [];
559
421
  }
560
- function convertMaterials() {
561
- return _convertMaterials.apply(this, arguments);
562
- }
563
- function _convertMaterials() {
564
- _convertMaterials = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4() {
565
- var sourceMaterials,
566
- shouldMergeMaterials,
567
- materials,
568
- _iterator10,
569
- _step10,
570
- sourceMaterial,
571
- _args4 = arguments;
572
- return _regenerator.default.wrap(function _callee4$(_context4) {
573
- while (1) switch (_context4.prev = _context4.next) {
574
- case 0:
575
- sourceMaterials = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : [];
576
- shouldMergeMaterials = _args4.length > 1 ? _args4[1] : undefined;
577
- materials = [];
578
- _iterator10 = _createForOfIteratorHelper(sourceMaterials);
579
- try {
580
- for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
581
- sourceMaterial = _step10.value;
582
- materials.push(convertMaterial(sourceMaterial));
583
- }
584
- } catch (err) {
585
- _iterator10.e(err);
586
- } finally {
587
- _iterator10.f();
588
- }
589
- if (!shouldMergeMaterials) {
590
- _context4.next = 9;
591
- break;
592
- }
593
- _context4.next = 8;
594
- return mergeAllMaterials(materials);
595
- case 8:
596
- materials = _context4.sent;
597
- case 9:
598
- return _context4.abrupt("return", materials);
599
- case 10:
600
- case "end":
601
- return _context4.stop();
422
+ async function convertMaterials() {
423
+ let sourceMaterials = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
424
+ let shouldMergeMaterials = arguments.length > 1 ? arguments[1] : undefined;
425
+ let materials = [];
426
+ for (const sourceMaterial of sourceMaterials) {
427
+ materials.push(convertMaterial(sourceMaterial));
428
+ }
429
+ if (shouldMergeMaterials) {
430
+ materials = await mergeAllMaterials(materials);
431
+ }
432
+ return materials;
433
+ }
434
+ async function mergeAllMaterials(materials) {
435
+ const result = [];
436
+ while (materials.length > 0) {
437
+ let newMaterial = materials.splice(0, 1)[0];
438
+ const mergedIndices = [];
439
+ for (let i = 0; i < materials.length; i++) {
440
+ const material = materials[i];
441
+ if (newMaterial.texture && material.texture || !newMaterial.texture && !material.texture) {
442
+ newMaterial = await mergeMaterials(newMaterial, material);
443
+ mergedIndices.push(i);
602
444
  }
603
- }, _callee4);
604
- }));
605
- return _convertMaterials.apply(this, arguments);
606
- }
607
- function mergeAllMaterials(_x15) {
608
- return _mergeAllMaterials.apply(this, arguments);
609
- }
610
- function _mergeAllMaterials() {
611
- _mergeAllMaterials = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee5(materials) {
612
- var result, newMaterial, mergedIndices, i, material, _newMaterial$mergedMa, _newMaterial$mergedMa2, newWidth, newHeight, currentX, _iterator11, _step11, aTextureMetadata, newX, _iterator12, _step12, index;
613
- return _regenerator.default.wrap(function _callee5$(_context5) {
614
- while (1) switch (_context5.prev = _context5.next) {
615
- case 0:
616
- result = [];
617
- case 1:
618
- if (!(materials.length > 0)) {
619
- _context5.next = 21;
620
- break;
621
- }
622
- newMaterial = materials.splice(0, 1)[0];
623
- mergedIndices = [];
624
- i = 0;
625
- case 5:
626
- if (!(i < materials.length)) {
627
- _context5.next = 15;
628
- break;
629
- }
630
- material = materials[i];
631
- if (!(newMaterial.texture && material.texture || !newMaterial.texture && !material.texture)) {
632
- _context5.next = 12;
633
- break;
634
- }
635
- _context5.next = 10;
636
- return mergeMaterials(newMaterial, material);
637
- case 10:
638
- newMaterial = _context5.sent;
639
- mergedIndices.push(i);
640
- case 12:
641
- i++;
642
- _context5.next = 5;
643
- break;
644
- case 15:
645
- if (newMaterial.texture && mergedIndices.length) {
646
- newWidth = (_newMaterial$mergedMa = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa === void 0 ? void 0 : _newMaterial$mergedMa.reduce(function (accum, _ref4) {
647
- var textureSize = _ref4.textureSize;
648
- return accum + ((textureSize === null || textureSize === void 0 ? void 0 : textureSize.width) || 0);
649
- }, 0);
650
- newHeight = (_newMaterial$mergedMa2 = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa2 === void 0 ? void 0 : _newMaterial$mergedMa2.reduce(function (accum, _ref5) {
651
- var textureSize = _ref5.textureSize;
652
- return Math.max(accum, (textureSize === null || textureSize === void 0 ? void 0 : textureSize.height) || 0);
653
- }, 0);
654
- currentX = -1;
655
- _iterator11 = _createForOfIteratorHelper(newMaterial.mergedMaterials);
656
- try {
657
- for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
658
- aTextureMetadata = _step11.value;
659
- if (aTextureMetadata.textureSize) {
660
- newX = currentX + 1 + aTextureMetadata.textureSize.width / newWidth * Math.pow(2, Uint16Array.BYTES_PER_ELEMENT * 8) - 1;
661
- aTextureMetadata.uvRegion = new Uint16Array([currentX + 1, 0, newX, aTextureMetadata.textureSize.height / newHeight * Math.pow(2, Uint16Array.BYTES_PER_ELEMENT * 8) - 1]);
662
- currentX = newX;
663
- }
664
- }
665
- } catch (err) {
666
- _iterator11.e(err);
667
- } finally {
668
- _iterator11.f();
669
- }
670
- newMaterial.texture.image.width = newWidth;
671
- newMaterial.texture.image.height = newHeight;
672
- }
673
- _iterator12 = _createForOfIteratorHelper(mergedIndices.reverse());
674
- try {
675
- for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
676
- index = _step12.value;
677
- materials.splice(index, 1);
678
- }
679
- } catch (err) {
680
- _iterator12.e(err);
681
- } finally {
682
- _iterator12.f();
683
- }
684
- result.push(newMaterial);
685
- _context5.next = 1;
686
- break;
687
- case 21:
688
- if (!result.length) {
689
- result.push({
690
- material: getDefaultMaterial(),
691
- mergedMaterials: [{
692
- originalMaterialId: 'default'
693
- }]
694
- });
695
- }
696
- return _context5.abrupt("return", result);
697
- case 23:
698
- case "end":
699
- return _context5.stop();
445
+ }
446
+ if (newMaterial.texture && mergedIndices.length) {
447
+ var _newMaterial$mergedMa, _newMaterial$mergedMa2;
448
+ const newWidth = (_newMaterial$mergedMa = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa === void 0 ? void 0 : _newMaterial$mergedMa.reduce((accum, _ref3) => {
449
+ let {
450
+ textureSize
451
+ } = _ref3;
452
+ return accum + ((textureSize === null || textureSize === void 0 ? void 0 : textureSize.width) || 0);
453
+ }, 0);
454
+ const newHeight = (_newMaterial$mergedMa2 = newMaterial.mergedMaterials) === null || _newMaterial$mergedMa2 === void 0 ? void 0 : _newMaterial$mergedMa2.reduce((accum, _ref4) => {
455
+ let {
456
+ textureSize
457
+ } = _ref4;
458
+ return Math.max(accum, (textureSize === null || textureSize === void 0 ? void 0 : textureSize.height) || 0);
459
+ }, 0);
460
+ let currentX = -1;
461
+ for (const aTextureMetadata of newMaterial.mergedMaterials) {
462
+ if (aTextureMetadata.textureSize) {
463
+ const newX = currentX + 1 + aTextureMetadata.textureSize.width / newWidth * 2 ** (Uint16Array.BYTES_PER_ELEMENT * 8) - 1;
464
+ aTextureMetadata.uvRegion = new Uint16Array([currentX + 1, 0, newX, aTextureMetadata.textureSize.height / newHeight * 2 ** (Uint16Array.BYTES_PER_ELEMENT * 8) - 1]);
465
+ currentX = newX;
466
+ }
700
467
  }
701
- }, _callee5);
702
- }));
703
- return _mergeAllMaterials.apply(this, arguments);
704
- }
705
- function mergeMaterials(_x16, _x17) {
706
- return _mergeMaterials.apply(this, arguments);
468
+ newMaterial.texture.image.width = newWidth;
469
+ newMaterial.texture.image.height = newHeight;
470
+ }
471
+ for (const index of mergedIndices.reverse()) {
472
+ materials.splice(index, 1);
473
+ }
474
+ result.push(newMaterial);
475
+ }
476
+ if (!result.length) {
477
+ result.push({
478
+ material: getDefaultMaterial(),
479
+ mergedMaterials: [{
480
+ originalMaterialId: 'default'
481
+ }]
482
+ });
483
+ }
484
+ return result;
707
485
  }
708
- function _mergeMaterials() {
709
- _mergeMaterials = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee6(material1, material2) {
710
- var _material1$texture, _material2$texture;
711
- var buffer1, buffer2, _yield$import, joinImages, sharpData;
712
- return _regenerator.default.wrap(function _callee6$(_context6) {
713
- while (1) switch (_context6.prev = _context6.next) {
714
- case 0:
715
- if (!((_material1$texture = material1.texture) !== null && _material1$texture !== void 0 && _material1$texture.bufferView && (_material2$texture = material2.texture) !== null && _material2$texture !== void 0 && _material2$texture.bufferView && material1.mergedMaterials && material2.mergedMaterials)) {
716
- _context6.next = 21;
717
- break;
718
- }
719
- buffer1 = Buffer.from(material1.texture.bufferView.data);
720
- buffer2 = Buffer.from(material2.texture.bufferView.data);
721
- _context6.prev = 3;
722
- _context6.next = 6;
723
- return Promise.resolve().then(function () {
724
- return _interopRequireWildcard(require('join-images'));
725
- });
726
- case 6:
727
- _yield$import = _context6.sent;
728
- joinImages = _yield$import.joinImages;
729
- _context6.next = 10;
730
- return joinImages([buffer1, buffer2], {
731
- direction: 'horizontal'
732
- });
733
- case 10:
734
- sharpData = _context6.sent;
735
- _context6.next = 13;
736
- return sharpData.toFormat(material1.texture.mimeType === 'image/png' ? 'png' : 'jpeg').toBuffer();
737
- case 13:
738
- material1.texture.bufferView.data = _context6.sent;
739
- _context6.next = 20;
740
- break;
741
- case 16:
742
- _context6.prev = 16;
743
- _context6.t0 = _context6["catch"](3);
744
- console.log('Join images into a texture atlas has failed. Consider usage `--split-nodes` option. (See documentation https://loaders.gl/modules/tile-converter/docs/cli-reference/tile-converter)');
745
- throw _context6.t0;
746
- case 20:
747
- material1.material.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId = 1;
748
- case 21:
749
- material1.mergedMaterials = material1.mergedMaterials.concat(material2.mergedMaterials);
750
- return _context6.abrupt("return", material1);
751
- case 23:
752
- case "end":
753
- return _context6.stop();
754
- }
755
- }, _callee6, null, [[3, 16]]);
756
- }));
757
- return _mergeMaterials.apply(this, arguments);
486
+ async function mergeMaterials(material1, material2) {
487
+ var _material1$texture, _material2$texture;
488
+ if ((_material1$texture = material1.texture) !== null && _material1$texture !== void 0 && _material1$texture.bufferView && (_material2$texture = material2.texture) !== null && _material2$texture !== void 0 && _material2$texture.bufferView && material1.mergedMaterials && material2.mergedMaterials) {
489
+ const buffer1 = Buffer.from(material1.texture.bufferView.data);
490
+ const buffer2 = Buffer.from(material2.texture.bufferView.data);
491
+ try {
492
+ const {
493
+ joinImages
494
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require('join-images')));
495
+ const sharpData = await joinImages([buffer1, buffer2], {
496
+ direction: 'horizontal'
497
+ });
498
+ material1.texture.bufferView.data = await sharpData.toFormat(material1.texture.mimeType === 'image/png' ? 'png' : 'jpeg').toBuffer();
499
+ } catch (error) {
500
+ console.log('Join images into a texture atlas has failed. Consider usage `--split-nodes` option. (See documentation https://loaders.gl/modules/tile-converter/docs/cli-reference/tile-converter)');
501
+ throw error;
502
+ }
503
+ material1.material.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId = 1;
504
+ }
505
+ material1.mergedMaterials = material1.mergedMaterials.concat(material2.mergedMaterials);
506
+ return material1;
758
507
  }
759
508
  function convertMaterial(sourceMaterial) {
760
509
  var _sourceMaterial$emiss, _sourceMaterial$pbrMe, _sourceMaterial$pbrMe2, _sourceMaterial$pbrMe3;
761
- var material = {
510
+ const material = {
762
511
  doubleSided: sourceMaterial.doubleSided,
763
- emissiveFactor: (_sourceMaterial$emiss = sourceMaterial.emissiveFactor) === null || _sourceMaterial$emiss === void 0 ? void 0 : _sourceMaterial$emiss.map(function (c) {
764
- return Math.round(c * 255);
765
- }),
512
+ emissiveFactor: (_sourceMaterial$emiss = sourceMaterial.emissiveFactor) === null || _sourceMaterial$emiss === void 0 ? void 0 : _sourceMaterial$emiss.map(c => Math.round(c * 255)),
766
513
  alphaMode: convertAlphaMode(sourceMaterial.alphaMode),
767
514
  pbrMetallicRoughness: {
768
515
  roughnessFactor: (sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe === void 0 ? void 0 : _sourceMaterial$pbrMe.roughnessFactor) || DEFAULT_ROUGHNESS_FACTOR,
769
516
  metallicFactor: (sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe2 = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe2 === void 0 ? void 0 : _sourceMaterial$pbrMe2.metallicFactor) || DEFAULT_METALLIC_FACTOR
770
517
  }
771
518
  };
772
- var texture;
519
+ let texture;
773
520
  if (sourceMaterial !== null && sourceMaterial !== void 0 && (_sourceMaterial$pbrMe3 = sourceMaterial.pbrMetallicRoughness) !== null && _sourceMaterial$pbrMe3 !== void 0 && _sourceMaterial$pbrMe3.baseColorTexture) {
774
521
  texture = sourceMaterial.pbrMetallicRoughness.baseColorTexture.texture.source;
775
522
  material.pbrMetallicRoughness.baseColorTexture = {
@@ -781,17 +528,15 @@ function convertMaterial(sourceMaterial) {
781
528
  textureSetDefinitionId: 0
782
529
  };
783
530
  }
784
- var uniqueId = (0, _uuid.v4)();
531
+ const uniqueId = (0, _uuid.v4)();
785
532
  sourceMaterial.uniqueId = uniqueId;
786
- var mergedMaterials = [{
533
+ let mergedMaterials = [{
787
534
  originalMaterialId: uniqueId
788
535
  }];
789
536
  if (!texture) {
790
537
  var _sourceMaterial$pbrMe4;
791
- var baseColorFactor = sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe4 = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe4 === void 0 ? void 0 : _sourceMaterial$pbrMe4.baseColorFactor;
792
- material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map(function (c) {
793
- return Math.round(c * 255);
794
- }) || undefined;
538
+ const baseColorFactor = sourceMaterial === null || sourceMaterial === void 0 ? void 0 : (_sourceMaterial$pbrMe4 = sourceMaterial.pbrMetallicRoughness) === null || _sourceMaterial$pbrMe4 === void 0 ? void 0 : _sourceMaterial$pbrMe4.baseColorFactor;
539
+ material.pbrMetallicRoughness.baseColorFactor = baseColorFactor && baseColorFactor.map(c => Math.round(c * 255)) || undefined;
795
540
  } else {
796
541
  mergedMaterials[0].textureSize = {
797
542
  width: texture.image.width,
@@ -799,9 +544,9 @@ function convertMaterial(sourceMaterial) {
799
544
  };
800
545
  }
801
546
  return {
802
- material: material,
803
- texture: texture,
804
- mergedMaterials: mergedMaterials
547
+ material,
548
+ texture,
549
+ mergedMaterials
805
550
  };
806
551
  }
807
552
  function convertAlphaMode(gltfAlphaMode) {
@@ -826,63 +571,56 @@ function getDefaultMaterial() {
826
571
  };
827
572
  }
828
573
  function getSharedResources(gltfMaterials, nodeId) {
829
- var i3sResources = {};
574
+ const i3sResources = {};
830
575
  if (!gltfMaterials || !gltfMaterials.length) {
831
576
  return i3sResources;
832
577
  }
833
578
  i3sResources.materialDefinitionInfos = [];
834
- var _iterator4 = _createForOfIteratorHelper(gltfMaterials),
835
- _step4;
836
- try {
837
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
838
- var gltfMaterial = _step4.value;
839
- var _convertGLTFMaterialT = convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId),
840
- materialDefinitionInfo = _convertGLTFMaterialT.materialDefinitionInfo,
841
- textureDefinitionInfo = _convertGLTFMaterialT.textureDefinitionInfo;
842
- i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);
843
- if (textureDefinitionInfo) {
844
- i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];
845
- i3sResources.textureDefinitionInfos.push(textureDefinitionInfo);
846
- }
579
+ for (const gltfMaterial of gltfMaterials) {
580
+ const {
581
+ materialDefinitionInfo,
582
+ textureDefinitionInfo
583
+ } = convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId);
584
+ i3sResources.materialDefinitionInfos.push(materialDefinitionInfo);
585
+ if (textureDefinitionInfo) {
586
+ i3sResources.textureDefinitionInfos = i3sResources.textureDefinitionInfos || [];
587
+ i3sResources.textureDefinitionInfos.push(textureDefinitionInfo);
847
588
  }
848
- } catch (err) {
849
- _iterator4.e(err);
850
- } finally {
851
- _iterator4.f();
852
589
  }
853
590
  return i3sResources;
854
591
  }
855
592
  function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
856
593
  var _gltfMaterial$pbrMeta;
857
- var texture = (gltfMaterial === null || gltfMaterial === void 0 ? void 0 : (_gltfMaterial$pbrMeta = gltfMaterial.pbrMetallicRoughness) === null || _gltfMaterial$pbrMeta === void 0 ? void 0 : _gltfMaterial$pbrMeta.baseColorTexture) || gltfMaterial.emissiveTexture;
858
- var textureDefinitionInfo = null;
594
+ const texture = (gltfMaterial === null || gltfMaterial === void 0 ? void 0 : (_gltfMaterial$pbrMeta = gltfMaterial.pbrMetallicRoughness) === null || _gltfMaterial$pbrMeta === void 0 ? void 0 : _gltfMaterial$pbrMeta.baseColorTexture) || gltfMaterial.emissiveTexture;
595
+ let textureDefinitionInfo = null;
859
596
  if (texture) {
860
597
  textureDefinitionInfo = extractSharedResourcesTextureInfo(texture.texture, nodeId);
861
598
  }
862
- var _ref3 = (gltfMaterial === null || gltfMaterial === void 0 ? void 0 : gltfMaterial.pbrMetallicRoughness) || {},
863
- baseColorFactor = _ref3.baseColorFactor,
864
- metallicFactor = _ref3.metallicFactor;
865
- var colorFactor = baseColorFactor;
599
+ const {
600
+ baseColorFactor,
601
+ metallicFactor
602
+ } = (gltfMaterial === null || gltfMaterial === void 0 ? void 0 : gltfMaterial.pbrMetallicRoughness) || {};
603
+ let colorFactor = baseColorFactor;
866
604
  if ((!baseColorFactor || baseColorFactor[3] === 0) && gltfMaterial.emissiveFactor) {
867
605
  colorFactor = gltfMaterial.emissiveFactor;
868
606
  colorFactor[3] = colorFactor[3] || 1;
869
607
  }
870
608
  return {
871
609
  materialDefinitionInfo: extractSharedResourcesMaterialInfo(colorFactor || [1, 1, 1, 1], metallicFactor),
872
- textureDefinitionInfo: textureDefinitionInfo
610
+ textureDefinitionInfo
873
611
  };
874
612
  }
875
613
  function extractSharedResourcesMaterialInfo(baseColorFactor) {
876
- var metallicFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
877
- var matDielectricColorComponent = 0.04 / 255;
878
- var black = new _core.Vector4(0, 0, 0, 1);
879
- var unitVector = new _core.Vector4(1, 1, 1, 1);
880
- var dielectricSpecular = new _core.Vector4(matDielectricColorComponent, matDielectricColorComponent, matDielectricColorComponent, 0);
881
- var baseColorVector = new _core.Vector4(baseColorFactor);
882
- var firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);
883
- var diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);
614
+ let metallicFactor = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
615
+ const matDielectricColorComponent = 0.04 / 255;
616
+ const black = new _core.Vector4(0, 0, 0, 1);
617
+ const unitVector = new _core.Vector4(1, 1, 1, 1);
618
+ const dielectricSpecular = new _core.Vector4(matDielectricColorComponent, matDielectricColorComponent, matDielectricColorComponent, 0);
619
+ const baseColorVector = new _core.Vector4(baseColorFactor);
620
+ const firstOperand = unitVector.subtract(dielectricSpecular).multiply(baseColorVector);
621
+ const diffuse = firstOperand.lerp(firstOperand, black, metallicFactor);
884
622
  dielectricSpecular[3] = 1;
885
- var specular = dielectricSpecular.lerp(dielectricSpecular, baseColorVector, metallicFactor);
623
+ const specular = dielectricSpecular.lerp(dielectricSpecular, baseColorVector, metallicFactor);
886
624
  return {
887
625
  params: {
888
626
  diffuse: diffuse.toArray(),
@@ -904,73 +642,75 @@ function extractSharedResourcesTextureInfo(texture, nodeId) {
904
642
  }
905
643
  function generateImageId(texture, nodeId) {
906
644
  var _texture$source4;
907
- var _texture$source$image = (_texture$source4 = texture.source) === null || _texture$source4 === void 0 ? void 0 : _texture$source4.image,
908
- width = _texture$source$image.width,
909
- height = _texture$source$image.height;
910
- var levelCountOfTexture = 1;
911
- var indexOfLevel = 0;
912
- var indexOfTextureInStore = nodeId + 1;
913
- var zerosCount = 32 - indexOfTextureInStore.toString(2).length;
914
- var rightHalf = '0'.repeat(zerosCount).concat(indexOfTextureInStore.toString(2));
915
- var shiftedLevelCountOfTexture = levelCountOfTexture << 28;
916
- var shiftedIndexOfLevel = indexOfLevel << 24;
917
- var shiftedWidth = width - 1 << 12;
918
- var shiftedHeight = height - 1 << 0;
919
- var leftHalf = shiftedLevelCountOfTexture + shiftedIndexOfLevel + shiftedWidth + shiftedHeight;
920
- var imageId = BigInt("0b".concat(leftHalf.toString(2)).concat(rightHalf));
645
+ const {
646
+ width,
647
+ height
648
+ } = (_texture$source4 = texture.source) === null || _texture$source4 === void 0 ? void 0 : _texture$source4.image;
649
+ const levelCountOfTexture = 1;
650
+ const indexOfLevel = 0;
651
+ const indexOfTextureInStore = nodeId + 1;
652
+ const zerosCount = 32 - indexOfTextureInStore.toString(2).length;
653
+ const rightHalf = '0'.repeat(zerosCount).concat(indexOfTextureInStore.toString(2));
654
+ const shiftedLevelCountOfTexture = levelCountOfTexture << 28;
655
+ const shiftedIndexOfLevel = indexOfLevel << 24;
656
+ const shiftedWidth = width - 1 << 12;
657
+ const shiftedHeight = height - 1 << 0;
658
+ const leftHalf = shiftedLevelCountOfTexture + shiftedIndexOfLevel + shiftedWidth + shiftedHeight;
659
+ const imageId = BigInt("0b".concat(leftHalf.toString(2)).concat(rightHalf));
921
660
  return imageId.toString();
922
661
  }
923
662
  function makeFeatureIdsUnique(featureIds, featureIndices, featuresHashArray, batchTable) {
924
- var replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
663
+ const replaceMap = getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray);
925
664
  replaceIndicesByUnique(featureIndices, replaceMap);
926
665
  replaceIndicesByUnique(featureIds, replaceMap);
927
666
  }
928
667
  function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
929
- var featureMap = {};
930
- for (var index = 0; index < featureIds.length; index++) {
931
- var oldFeatureId = featureIds[index];
932
- var uniqueFeatureId = getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray);
668
+ const featureMap = {};
669
+ for (let index = 0; index < featureIds.length; index++) {
670
+ const oldFeatureId = featureIds[index];
671
+ const uniqueFeatureId = getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray);
933
672
  featureMap[oldFeatureId.toString()] = uniqueFeatureId;
934
673
  }
935
674
  return featureMap;
936
675
  }
937
676
  function generateStringFromBatchTableByIndex(batchTable, index) {
938
- var str = '';
939
- for (var _key in batchTable) {
940
- str += batchTable[_key][index];
677
+ let str = '';
678
+ for (const key in batchTable) {
679
+ str += batchTable[key][index];
941
680
  }
942
681
  return str;
943
682
  }
944
683
  function getOrCreateUniqueFeatureId(index, batchTable, featuresHashArray) {
945
- var batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);
946
- var hash = (0, _md.default)(batchTableStr);
684
+ const batchTableStr = generateStringFromBatchTableByIndex(batchTable, index);
685
+ const hash = (0, _md.default)(batchTableStr);
947
686
  if (featuresHashArray.includes(hash)) {
948
687
  return featuresHashArray.indexOf(hash);
949
688
  }
950
689
  return featuresHashArray.push(hash) - 1;
951
690
  }
952
691
  function replaceIndicesByUnique(indicesArray, featureMap) {
953
- for (var index = 0; index < indicesArray.length; index++) {
692
+ for (let index = 0; index < indicesArray.length; index++) {
954
693
  indicesArray[index] = featureMap[indicesArray[index]];
955
694
  }
956
695
  }
957
696
  function convertPropertyTableToAttributeBuffers(featureIds, propertyTable, attributeStorageInfo) {
958
- var attributeBuffers = [];
959
- var needFlattenPropertyTable = (0, _featureAttributes.checkPropertiesLength)(featureIds, propertyTable);
960
- var properties = needFlattenPropertyTable ? (0, _featureAttributes.flattenPropertyTableByFeatureIds)(featureIds, propertyTable) : propertyTable;
961
- var propertyTableWithObjectIds = _objectSpread({
962
- OBJECTID: featureIds
963
- }, properties);
964
- for (var propertyName in propertyTableWithObjectIds) {
965
- var type = getAttributeType(propertyName, attributeStorageInfo);
966
- var value = propertyTableWithObjectIds[propertyName];
967
- var attributeBuffer = generateAttributeBuffer(type, value);
697
+ const attributeBuffers = [];
698
+ const needFlattenPropertyTable = (0, _featureAttributes.checkPropertiesLength)(featureIds, propertyTable);
699
+ const properties = needFlattenPropertyTable ? (0, _featureAttributes.flattenPropertyTableByFeatureIds)(featureIds, propertyTable) : propertyTable;
700
+ const propertyTableWithObjectIds = {
701
+ OBJECTID: featureIds,
702
+ ...properties
703
+ };
704
+ for (const propertyName in propertyTableWithObjectIds) {
705
+ const type = getAttributeType(propertyName, attributeStorageInfo);
706
+ const value = propertyTableWithObjectIds[propertyName];
707
+ const attributeBuffer = generateAttributeBuffer(type, value);
968
708
  attributeBuffers.push(attributeBuffer);
969
709
  }
970
710
  return attributeBuffers;
971
711
  }
972
712
  function generateAttributeBuffer(type, value) {
973
- var attributeBuffer;
713
+ let attributeBuffer;
974
714
  switch (type) {
975
715
  case OBJECT_ID_TYPE:
976
716
  case SHORT_INT_TYPE:
@@ -988,108 +728,100 @@ function generateAttributeBuffer(type, value) {
988
728
  return attributeBuffer;
989
729
  }
990
730
  function getAttributeType(key, attributeStorageInfo) {
991
- var attribute = attributeStorageInfo.find(function (attr) {
992
- return attr.name === key;
993
- });
731
+ const attribute = attributeStorageInfo.find(attr => attr.name === key);
994
732
  return attribute.attributeValues.valueType;
995
733
  }
996
734
  function generateShortIntegerAttributeBuffer(featureIds) {
997
- var count = new Uint32Array([featureIds.length]);
998
- var valuesArray = new Uint32Array(featureIds);
735
+ const count = new Uint32Array([featureIds.length]);
736
+ const valuesArray = new Uint32Array(featureIds);
999
737
  return (0, _loaderUtils.concatenateArrayBuffers)(count.buffer, valuesArray.buffer);
1000
738
  }
1001
739
  function generateDoubleAttributeBuffer(featureIds) {
1002
- var count = new Uint32Array([featureIds.length]);
1003
- var padding = new Uint8Array(4);
1004
- var valuesArray = new Float64Array(featureIds);
740
+ const count = new Uint32Array([featureIds.length]);
741
+ const padding = new Uint8Array(4);
742
+ const valuesArray = new Float64Array(featureIds);
1005
743
  return (0, _loaderUtils.concatenateArrayBuffers)(count.buffer, padding.buffer, valuesArray.buffer);
1006
744
  }
1007
745
  function generateStringAttributeBuffer(batchAttributes) {
1008
- var stringCountArray = new Uint32Array([batchAttributes.length]);
1009
- var totalNumberOfBytes = 0;
1010
- var stringSizesArray = new Uint32Array(batchAttributes.length);
1011
- var stringBufferArray = [];
1012
- for (var index = 0; index < batchAttributes.length; index++) {
1013
- var currentString = "".concat(String(batchAttributes[index]), "\0");
1014
- var currentStringBuffer = Buffer.from(currentString);
1015
- var currentStringSize = currentStringBuffer.length;
746
+ const stringCountArray = new Uint32Array([batchAttributes.length]);
747
+ let totalNumberOfBytes = 0;
748
+ const stringSizesArray = new Uint32Array(batchAttributes.length);
749
+ const stringBufferArray = [];
750
+ for (let index = 0; index < batchAttributes.length; index++) {
751
+ const currentString = "".concat(String(batchAttributes[index]), "\0");
752
+ const currentStringBuffer = Buffer.from(currentString);
753
+ const currentStringSize = currentStringBuffer.length;
1016
754
  totalNumberOfBytes += currentStringSize;
1017
755
  stringSizesArray[index] = currentStringSize;
1018
756
  stringBufferArray.push(currentStringBuffer);
1019
757
  }
1020
- var totalBytes = new Uint32Array([totalNumberOfBytes]);
1021
- return _loaderUtils.concatenateArrayBuffers.apply(void 0, [stringCountArray.buffer, totalBytes.buffer, stringSizesArray.buffer].concat(stringBufferArray));
758
+ const totalBytes = new Uint32Array([totalNumberOfBytes]);
759
+ return (0, _loaderUtils.concatenateArrayBuffers)(stringCountArray.buffer, totalBytes.buffer, stringSizesArray.buffer, ...stringBufferArray);
1022
760
  }
1023
761
  function generateBigUint64Array(featureIds) {
1024
- var typedFeatureIds = new BigUint64Array(featureIds.length);
1025
- for (var index = 0; index < featureIds.length; index++) {
762
+ const typedFeatureIds = new BigUint64Array(featureIds.length);
763
+ for (let index = 0; index < featureIds.length; index++) {
1026
764
  typedFeatureIds[index] = BigInt(featureIds[index]);
1027
765
  }
1028
766
  return typedFeatureIds;
1029
767
  }
1030
- function generateCompressedGeometry(_x18, _x19, _x20, _x21) {
1031
- return _generateCompressedGeometry.apply(this, arguments);
1032
- }
1033
- function _generateCompressedGeometry() {
1034
- _generateCompressedGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee7(vertexCount, convertedAttributes, attributes, dracoWorkerSoure) {
1035
- var positions, normals, texCoords, colors, uvRegions, featureIds, faceRange, indices, index, featureIndices, featureIndex, compressedAttributes, attributesMetadata;
1036
- return _regenerator.default.wrap(function _callee7$(_context7) {
1037
- while (1) switch (_context7.prev = _context7.next) {
1038
- case 0:
1039
- positions = attributes.positions, normals = attributes.normals, texCoords = attributes.texCoords, colors = attributes.colors, uvRegions = attributes.uvRegions, featureIds = attributes.featureIds, faceRange = attributes.faceRange;
1040
- indices = new Uint32Array(vertexCount);
1041
- for (index = 0; index < indices.length; index++) {
1042
- indices.set([index], index);
1043
- }
1044
- featureIndices = new Uint32Array(convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount);
1045
- featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
1046
- compressedAttributes = {
1047
- positions: positions,
1048
- normals: normals,
1049
- colors: colors,
1050
- 'feature-index': featureIndex
1051
- };
1052
- if (texCoords.length) {
1053
- compressedAttributes.texCoords = texCoords;
1054
- }
1055
- attributesMetadata = {
1056
- 'feature-index': {
1057
- 'i3s-attribute-type': 'feature-index',
1058
- 'i3s-feature-ids': new Int32Array(featureIds)
1059
- }
1060
- };
1061
- if (uvRegions.length) {
1062
- compressedAttributes['uv-region'] = uvRegions;
1063
- attributesMetadata['uv-region'] = {
1064
- 'i3s-attribute-type': 'uv-region'
1065
- };
1066
- }
1067
- return _context7.abrupt("return", (0, _core2.encode)({
1068
- attributes: compressedAttributes,
1069
- indices: indices
1070
- }, _draco.DracoWriterWorker, _objectSpread(_objectSpread({}, _draco.DracoWriterWorker.options), {}, {
1071
- source: dracoWorkerSoure,
1072
- reuseWorkers: true,
1073
- _nodeWorkers: true,
1074
- draco: {
1075
- method: 'MESH_SEQUENTIAL_ENCODING',
1076
- attributesMetadata: attributesMetadata
1077
- }
1078
- })));
1079
- case 10:
1080
- case "end":
1081
- return _context7.stop();
1082
- }
1083
- }, _callee7);
1084
- }));
1085
- return _generateCompressedGeometry.apply(this, arguments);
768
+ async function generateCompressedGeometry(vertexCount, convertedAttributes, attributes, dracoWorkerSoure) {
769
+ const {
770
+ positions,
771
+ normals,
772
+ texCoords,
773
+ colors,
774
+ uvRegions,
775
+ featureIds,
776
+ faceRange
777
+ } = attributes;
778
+ const indices = new Uint32Array(vertexCount);
779
+ for (let index = 0; index < indices.length; index++) {
780
+ indices.set([index], index);
781
+ }
782
+ const featureIndices = new Uint32Array(convertedAttributes.featureIndices.length ? convertedAttributes.featureIndices : vertexCount);
783
+ const featureIndex = generateFeatureIndexAttribute(featureIndices, faceRange);
784
+ const compressedAttributes = {
785
+ positions,
786
+ normals,
787
+ colors,
788
+ 'feature-index': featureIndex
789
+ };
790
+ if (texCoords.length) {
791
+ compressedAttributes.texCoords = texCoords;
792
+ }
793
+ const attributesMetadata = {
794
+ 'feature-index': {
795
+ 'i3s-attribute-type': 'feature-index',
796
+ 'i3s-feature-ids': new Int32Array(featureIds)
797
+ }
798
+ };
799
+ if (uvRegions.length) {
800
+ compressedAttributes['uv-region'] = uvRegions;
801
+ attributesMetadata['uv-region'] = {
802
+ 'i3s-attribute-type': 'uv-region'
803
+ };
804
+ }
805
+ return (0, _core2.encode)({
806
+ attributes: compressedAttributes,
807
+ indices
808
+ }, _draco.DracoWriterWorker, {
809
+ ..._draco.DracoWriterWorker.options,
810
+ source: dracoWorkerSoure,
811
+ reuseWorkers: true,
812
+ _nodeWorkers: true,
813
+ draco: {
814
+ method: 'MESH_SEQUENTIAL_ENCODING',
815
+ attributesMetadata
816
+ }
817
+ });
1086
818
  }
1087
819
  function generateFeatureIndexAttribute(featureIndex, faceRange) {
1088
- var orderedFeatureIndices = new Uint32Array(featureIndex.length);
1089
- var fillIndex = 0;
1090
- var startIndex = 0;
1091
- for (var index = 1; index < faceRange.length; index += 2) {
1092
- var endIndex = (faceRange[index] + 1) * VALUES_PER_VERTEX;
820
+ const orderedFeatureIndices = new Uint32Array(featureIndex.length);
821
+ let fillIndex = 0;
822
+ let startIndex = 0;
823
+ for (let index = 1; index < faceRange.length; index += 2) {
824
+ const endIndex = (faceRange[index] + 1) * VALUES_PER_VERTEX;
1093
825
  orderedFeatureIndices.fill(fillIndex, startIndex, endIndex);
1094
826
  fillIndex++;
1095
827
  startIndex = endIndex + 1;
@@ -1097,13 +829,14 @@ function generateFeatureIndexAttribute(featureIndex, faceRange) {
1097
829
  return orderedFeatureIndices;
1098
830
  }
1099
831
  function getPropertyTable(tileContent) {
1100
- var batchTableJson = tileContent === null || tileContent === void 0 ? void 0 : tileContent.batchTableJson;
832
+ const batchTableJson = tileContent === null || tileContent === void 0 ? void 0 : tileContent.batchTableJson;
1101
833
  if (batchTableJson) {
1102
834
  return batchTableJson;
1103
835
  }
1104
- var _getPropertyTableExte = getPropertyTableExtension(tileContent),
1105
- extensionName = _getPropertyTableExte.extensionName,
1106
- extension = _getPropertyTableExte.extension;
836
+ const {
837
+ extensionName,
838
+ extension
839
+ } = getPropertyTableExtension(tileContent);
1107
840
  switch (extensionName) {
1108
841
  case EXT_MESH_FEATURES:
1109
842
  {
@@ -1119,35 +852,27 @@ function getPropertyTable(tileContent) {
1119
852
  }
1120
853
  }
1121
854
  function getPropertyTableExtension(tileContent) {
1122
- var _tileContent$gltf, _tileContent$gltf2, _tileContent$gltf2$ex, _tileContent$gltf3;
1123
- var extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_MESH_FEATURES];
1124
- var extensionsUsed = tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf = tileContent.gltf) === null || _tileContent$gltf === void 0 ? void 0 : _tileContent$gltf.extensionsUsed;
855
+ var _tileContent$gltf3, _tileContent$gltf5, _tileContent$gltf5$ex;
856
+ const extensionsWithPropertyTables = [EXT_FEATURE_METADATA, EXT_MESH_FEATURES];
857
+ const extensionsUsed = tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf3 = tileContent.gltf) === null || _tileContent$gltf3 === void 0 ? void 0 : _tileContent$gltf3.extensionsUsed;
1125
858
  if (!extensionsUsed) {
1126
859
  return {
1127
860
  extensionName: null,
1128
861
  extension: null
1129
862
  };
1130
863
  }
1131
- var extensionName = '';
1132
- var _iterator5 = _createForOfIteratorHelper((tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf3 = tileContent.gltf) === null || _tileContent$gltf3 === void 0 ? void 0 : _tileContent$gltf3.extensionsUsed) || []),
1133
- _step5;
1134
- try {
1135
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1136
- var extensionItem = _step5.value;
1137
- if (extensionsWithPropertyTables.includes(extensionItem)) {
1138
- extensionName = extensionItem;
1139
- break;
1140
- }
864
+ let extensionName = '';
865
+ for (const extensionItem of (tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf4 = tileContent.gltf) === null || _tileContent$gltf4 === void 0 ? void 0 : _tileContent$gltf4.extensionsUsed) || []) {
866
+ var _tileContent$gltf4;
867
+ if (extensionsWithPropertyTables.includes(extensionItem)) {
868
+ extensionName = extensionItem;
869
+ break;
1141
870
  }
1142
- } catch (err) {
1143
- _iterator5.e(err);
1144
- } finally {
1145
- _iterator5.f();
1146
871
  }
1147
- var extension = tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf2 = tileContent.gltf) === null || _tileContent$gltf2 === void 0 ? void 0 : (_tileContent$gltf2$ex = _tileContent$gltf2.extensions) === null || _tileContent$gltf2$ex === void 0 ? void 0 : _tileContent$gltf2$ex[extensionName];
872
+ const extension = tileContent === null || tileContent === void 0 ? void 0 : (_tileContent$gltf5 = tileContent.gltf) === null || _tileContent$gltf5 === void 0 ? void 0 : (_tileContent$gltf5$ex = _tileContent$gltf5.extensions) === null || _tileContent$gltf5$ex === void 0 ? void 0 : _tileContent$gltf5$ex[extensionName];
1148
873
  return {
1149
- extensionName: extensionName,
1150
- extension: extension
874
+ extensionName,
875
+ extension
1151
876
  };
1152
877
  }
1153
878
  function getPropertyTableFromExtFeatureMetadata(extension) {
@@ -1157,11 +882,11 @@ function getPropertyTableFromExtFeatureMetadata(extension) {
1157
882
  }
1158
883
  if (extension !== null && extension !== void 0 && extension.featureTables) {
1159
884
  var _Object$keys;
1160
- var firstFeatureTableName = (_Object$keys = Object.keys(extension.featureTables)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
885
+ const firstFeatureTableName = (_Object$keys = Object.keys(extension.featureTables)) === null || _Object$keys === void 0 ? void 0 : _Object$keys[0];
1161
886
  if (firstFeatureTableName) {
1162
- var featureTable = extension === null || extension === void 0 ? void 0 : extension.featureTables[firstFeatureTableName];
1163
- var propertyTable = {};
1164
- for (var propertyName in featureTable.properties) {
887
+ const featureTable = extension === null || extension === void 0 ? void 0 : extension.featureTables[firstFeatureTableName];
888
+ const propertyTable = {};
889
+ for (const propertyName in featureTable.properties) {
1165
890
  propertyTable[propertyName] = featureTable.properties[propertyName].data;
1166
891
  }
1167
892
  return propertyTable;