@loaders.gl/tile-converter 3.1.0-alpha.4 → 3.1.0-beta.5

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