@loaders.gl/tile-converter 3.2.0-alpha.1 → 3.2.0-alpha.4

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 (203) hide show
  1. package/dist/3d-tiles-attributes-worker.d.ts +28 -0
  2. package/dist/3d-tiles-attributes-worker.d.ts.map +1 -0
  3. package/dist/3d-tiles-attributes-worker.js +4 -0
  4. package/dist/3d-tiles-attributes-worker.js.map +7 -0
  5. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts +5 -1
  6. package/dist/3d-tiles-converter/3d-tiles-converter.d.ts.map +1 -1
  7. package/dist/3d-tiles-converter/3d-tiles-converter.js +34 -3
  8. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts +5 -4
  9. package/dist/3d-tiles-converter/helpers/b3dm-converter.d.ts.map +1 -1
  10. package/dist/3d-tiles-converter/helpers/b3dm-converter.js +10 -10
  11. package/dist/constants.d.ts +2 -0
  12. package/dist/constants.d.ts.map +1 -0
  13. package/dist/constants.js +4 -0
  14. package/dist/converter-cli.d.ts +2 -0
  15. package/dist/converter-cli.d.ts.map +1 -0
  16. package/dist/converter-cli.js +232 -0
  17. package/dist/converter.min.js +68 -68
  18. package/dist/deps-installer/deps-installer.d.ts +11 -1
  19. package/dist/deps-installer/deps-installer.d.ts.map +1 -1
  20. package/dist/deps-installer/deps-installer.js +10 -0
  21. package/dist/dist.min.js +910 -790
  22. package/dist/es5/3d-tiles-attributes-worker.js +29 -0
  23. package/dist/es5/3d-tiles-attributes-worker.js.map +1 -0
  24. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js +116 -46
  25. package/dist/es5/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  26. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js +21 -23
  27. package/dist/es5/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  28. package/dist/es5/constants.js +9 -0
  29. package/dist/es5/constants.js.map +1 -0
  30. package/dist/es5/converter-cli.js +306 -0
  31. package/dist/es5/converter-cli.js.map +1 -0
  32. package/dist/es5/deps-installer/deps-installer.js.map +1 -1
  33. package/dist/es5/i3s-attributes-worker.js +29 -0
  34. package/dist/es5/i3s-attributes-worker.js.map +1 -0
  35. package/dist/es5/i3s-converter/helpers/coordinate-converter.js +19 -11
  36. package/dist/es5/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  37. package/dist/es5/i3s-converter/helpers/geometry-attributes.js +2 -2
  38. package/dist/es5/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  39. package/dist/es5/i3s-converter/helpers/geometry-converter.js +271 -182
  40. package/dist/es5/i3s-converter/helpers/geometry-converter.js.map +1 -1
  41. package/dist/es5/i3s-converter/helpers/gltf-attributes.js +71 -0
  42. package/dist/es5/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  43. package/dist/es5/i3s-converter/helpers/node-pages.js +47 -99
  44. package/dist/es5/i3s-converter/helpers/node-pages.js.map +1 -1
  45. package/dist/es5/i3s-converter/i3s-converter.js +293 -223
  46. package/dist/es5/i3s-converter/i3s-converter.js.map +1 -1
  47. package/dist/es5/i3s-converter/json-templates/layers.js +29 -0
  48. package/dist/es5/i3s-converter/json-templates/layers.js.map +1 -1
  49. package/dist/es5/index.js +0 -16
  50. package/dist/es5/index.js.map +1 -1
  51. package/dist/es5/lib/utils/compress-util.js +14 -17
  52. package/dist/es5/lib/utils/compress-util.js.map +1 -1
  53. package/dist/es5/lib/utils/file-utils.js +39 -14
  54. package/dist/es5/lib/utils/file-utils.js.map +1 -1
  55. package/dist/es5/lib/utils/lod-conversion-utils.js.map +1 -1
  56. package/dist/es5/lib/utils/queue.js +61 -0
  57. package/dist/es5/lib/utils/queue.js.map +1 -0
  58. package/dist/es5/lib/utils/statistic-utills.js.map +1 -1
  59. package/dist/es5/lib/utils/write-queue.js +225 -0
  60. package/dist/es5/lib/utils/write-queue.js.map +1 -0
  61. package/dist/es5/pgm-loader.js +1 -1
  62. package/dist/es5/workers/3d-tiles-attributes-worker.js +37 -0
  63. package/dist/es5/workers/3d-tiles-attributes-worker.js.map +1 -0
  64. package/dist/es5/workers/i3s-attributes-worker.js +40 -0
  65. package/dist/es5/workers/i3s-attributes-worker.js.map +1 -0
  66. package/dist/esm/3d-tiles-attributes-worker.js +16 -0
  67. package/dist/esm/3d-tiles-attributes-worker.js.map +1 -0
  68. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js +36 -4
  69. package/dist/esm/3d-tiles-converter/3d-tiles-converter.js.map +1 -1
  70. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js +16 -18
  71. package/dist/esm/3d-tiles-converter/helpers/b3dm-converter.js.map +1 -1
  72. package/dist/esm/constants.js +2 -0
  73. package/dist/esm/constants.js.map +1 -0
  74. package/dist/esm/converter-cli.js +230 -0
  75. package/dist/esm/converter-cli.js.map +1 -0
  76. package/dist/esm/deps-installer/deps-installer.js.map +1 -1
  77. package/dist/esm/i3s-attributes-worker.js +16 -0
  78. package/dist/esm/i3s-attributes-worker.js.map +1 -0
  79. package/dist/esm/i3s-converter/helpers/coordinate-converter.js +19 -11
  80. package/dist/esm/i3s-converter/helpers/coordinate-converter.js.map +1 -1
  81. package/dist/esm/i3s-converter/helpers/geometry-attributes.js +2 -2
  82. package/dist/esm/i3s-converter/helpers/geometry-attributes.js.map +1 -1
  83. package/dist/esm/i3s-converter/helpers/geometry-converter.js +121 -62
  84. package/dist/esm/i3s-converter/helpers/geometry-converter.js.map +1 -1
  85. package/dist/esm/i3s-converter/helpers/gltf-attributes.js +54 -0
  86. package/dist/esm/i3s-converter/helpers/gltf-attributes.js.map +1 -0
  87. package/dist/esm/i3s-converter/helpers/node-pages.js +12 -4
  88. package/dist/esm/i3s-converter/helpers/node-pages.js.map +1 -1
  89. package/dist/esm/i3s-converter/i3s-converter.js +157 -52
  90. package/dist/esm/i3s-converter/i3s-converter.js.map +1 -1
  91. package/dist/esm/i3s-converter/json-templates/layers.js +25 -0
  92. package/dist/esm/i3s-converter/json-templates/layers.js.map +1 -1
  93. package/dist/esm/index.js +0 -2
  94. package/dist/esm/index.js.map +1 -1
  95. package/dist/esm/lib/utils/compress-util.js +6 -8
  96. package/dist/esm/lib/utils/compress-util.js.map +1 -1
  97. package/dist/esm/lib/utils/file-utils.js +11 -1
  98. package/dist/esm/lib/utils/file-utils.js.map +1 -1
  99. package/dist/esm/lib/utils/lod-conversion-utils.js.map +1 -1
  100. package/dist/esm/lib/utils/queue.js +19 -0
  101. package/dist/esm/lib/utils/queue.js.map +1 -0
  102. package/dist/esm/lib/utils/statistic-utills.js.map +1 -1
  103. package/dist/esm/lib/utils/write-queue.js +88 -0
  104. package/dist/esm/lib/utils/write-queue.js.map +1 -0
  105. package/dist/esm/pgm-loader.js +1 -1
  106. package/dist/esm/workers/3d-tiles-attributes-worker.js +5 -0
  107. package/dist/esm/workers/3d-tiles-attributes-worker.js.map +1 -0
  108. package/dist/esm/workers/i3s-attributes-worker.js +4 -0
  109. package/dist/esm/workers/i3s-attributes-worker.js.map +1 -0
  110. package/dist/i3s-attributes-worker.d.ts +33 -0
  111. package/dist/i3s-attributes-worker.d.ts.map +1 -0
  112. package/dist/i3s-attributes-worker.js +10 -0
  113. package/dist/i3s-attributes-worker.js.map +7 -0
  114. package/dist/i3s-converter/helpers/coordinate-converter.d.ts +7 -7
  115. package/dist/i3s-converter/helpers/coordinate-converter.d.ts.map +1 -1
  116. package/dist/i3s-converter/helpers/coordinate-converter.js +25 -21
  117. package/dist/i3s-converter/helpers/geometry-attributes.d.ts +2 -2
  118. package/dist/i3s-converter/helpers/geometry-attributes.d.ts.map +1 -1
  119. package/dist/i3s-converter/helpers/geometry-attributes.js +2 -1
  120. package/dist/i3s-converter/helpers/geometry-converter.d.ts +28 -11
  121. package/dist/i3s-converter/helpers/geometry-converter.d.ts.map +1 -1
  122. package/dist/i3s-converter/helpers/geometry-converter.js +223 -113
  123. package/dist/i3s-converter/helpers/gltf-attributes.d.ts +9 -0
  124. package/dist/i3s-converter/helpers/gltf-attributes.d.ts.map +1 -0
  125. package/dist/i3s-converter/helpers/gltf-attributes.js +56 -0
  126. package/dist/i3s-converter/helpers/node-pages.d.ts +6 -5
  127. package/dist/i3s-converter/helpers/node-pages.d.ts.map +1 -1
  128. package/dist/i3s-converter/helpers/node-pages.js +13 -8
  129. package/dist/i3s-converter/i3s-converter.d.ts +7 -5
  130. package/dist/i3s-converter/i3s-converter.d.ts.map +1 -1
  131. package/dist/i3s-converter/i3s-converter.js +126 -40
  132. package/dist/i3s-converter/json-templates/layers.d.ts +4 -0
  133. package/dist/i3s-converter/json-templates/layers.d.ts.map +1 -1
  134. package/dist/i3s-converter/json-templates/layers.js +24 -0
  135. package/dist/i3s-converter/types.d.ts +83 -8
  136. package/dist/i3s-converter/types.d.ts.map +1 -1
  137. package/dist/index.d.ts +0 -2
  138. package/dist/index.d.ts.map +1 -1
  139. package/dist/index.js +1 -5
  140. package/dist/lib/utils/compress-util.d.ts +44 -5
  141. package/dist/lib/utils/compress-util.d.ts.map +1 -1
  142. package/dist/lib/utils/compress-util.js +73 -6
  143. package/dist/lib/utils/file-utils.d.ts +34 -5
  144. package/dist/lib/utils/file-utils.d.ts.map +1 -1
  145. package/dist/lib/utils/file-utils.js +40 -1
  146. package/dist/lib/utils/lod-conversion-utils.d.ts +25 -4
  147. package/dist/lib/utils/lod-conversion-utils.d.ts.map +1 -1
  148. package/dist/lib/utils/lod-conversion-utils.js +21 -2
  149. package/dist/lib/utils/queue.d.ts +7 -0
  150. package/dist/lib/utils/queue.d.ts.map +1 -0
  151. package/dist/lib/utils/queue.js +18 -0
  152. package/dist/lib/utils/statistic-utills.d.ts +2 -2
  153. package/dist/lib/utils/statistic-utills.d.ts.map +1 -1
  154. package/dist/lib/utils/write-queue.d.ts +22 -0
  155. package/dist/lib/utils/write-queue.d.ts.map +1 -0
  156. package/dist/lib/utils/write-queue.js +62 -0
  157. package/dist/workers/3d-tiles-attributes-worker.d.ts +2 -0
  158. package/dist/workers/3d-tiles-attributes-worker.d.ts.map +1 -0
  159. package/dist/workers/3d-tiles-attributes-worker.js +9 -0
  160. package/dist/workers/i3s-attributes-worker.d.ts +2 -0
  161. package/dist/workers/i3s-attributes-worker.d.ts.map +1 -0
  162. package/dist/workers/i3s-attributes-worker.js +5 -0
  163. package/package.json +23 -18
  164. package/src/3d-tiles-attributes-worker.ts +43 -0
  165. package/src/3d-tiles-converter/3d-tiles-converter.ts +50 -5
  166. package/src/3d-tiles-converter/helpers/b3dm-converter.ts +15 -13
  167. package/src/constants.ts +2 -0
  168. package/src/converter-cli.ts +310 -0
  169. package/src/deps-installer/{deps-installer.js → deps-installer.ts} +11 -1
  170. package/src/i3s-attributes-worker.ts +46 -0
  171. package/src/i3s-converter/helpers/coordinate-converter.ts +29 -24
  172. package/src/i3s-converter/helpers/geometry-attributes.ts +4 -3
  173. package/src/i3s-converter/helpers/{geometry-converter.js → geometry-converter.ts} +425 -179
  174. package/src/i3s-converter/helpers/gltf-attributes.ts +68 -0
  175. package/src/i3s-converter/helpers/node-pages.ts +25 -17
  176. package/src/i3s-converter/i3s-converter.ts +150 -90
  177. package/src/i3s-converter/json-templates/layers.ts +25 -0
  178. package/src/i3s-converter/types.ts +90 -8
  179. package/src/index.ts +0 -4
  180. package/src/lib/utils/{compress-util.js → compress-util.ts} +105 -18
  181. package/src/lib/utils/file-utils.ts +84 -0
  182. package/src/lib/utils/{lod-conversion-utils.js → lod-conversion-utils.ts} +27 -5
  183. package/src/lib/utils/queue.ts +17 -0
  184. package/src/lib/utils/{statistic-utills.js → statistic-utills.ts} +0 -0
  185. package/src/lib/utils/write-queue.ts +75 -0
  186. package/src/workers/3d-tiles-attributes-worker.ts +6 -0
  187. package/src/workers/i3s-attributes-worker.ts +6 -0
  188. package/dist/es5/deps-installer/deps-installer.d.ts +0 -10
  189. package/dist/es5/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  190. package/dist/es5/lib/utils/compress-util.d.ts +0 -53
  191. package/dist/es5/lib/utils/file-utils.d.ts +0 -43
  192. package/dist/es5/lib/utils/lod-conversion-utils.d.ts +0 -32
  193. package/dist/esm/deps-installer/deps-installer.d.ts +0 -10
  194. package/dist/esm/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  195. package/dist/esm/lib/utils/compress-util.d.ts +0 -53
  196. package/dist/esm/lib/utils/file-utils.d.ts +0 -43
  197. package/dist/esm/lib/utils/lod-conversion-utils.d.ts +0 -32
  198. package/src/deps-installer/deps-installer.d.ts +0 -10
  199. package/src/i3s-converter/helpers/geometry-converter.d.ts +0 -44
  200. package/src/lib/utils/compress-util.d.ts +0 -53
  201. package/src/lib/utils/file-utils.d.ts +0 -43
  202. package/src/lib/utils/file-utils.js +0 -38
  203. package/src/lib/utils/lod-conversion-utils.d.ts +0 -32
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = convertB3dmToI3sGeometry;
9
+ exports.convertAttributes = convertAttributes;
9
10
 
10
11
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
12
 
@@ -29,6 +30,8 @@ var _geometryAttributes = require("./geometry-attributes");
29
30
 
30
31
  var _coordinateConverter = require("./coordinate-converter");
31
32
 
33
+ var _gltfAttributes = require("./gltf-attributes");
34
+
32
35
  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; }
33
36
 
34
37
  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; }
@@ -51,21 +54,28 @@ var OBJECT_ID_TYPE = 'Oid32';
51
54
  var BATCHED_ID_POSSIBLE_ATTRIBUTE_NAMES = ['CUSTOM_ATTRIBUTE_2', '_BATCHID', 'BATCHID'];
52
55
  var scratchVector = new _core.Vector3();
53
56
 
54
- function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5, _x6, _x7) {
57
+ function convertB3dmToI3sGeometry(_x, _x2, _x3, _x4, _x5, _x6, _x7, _x8) {
55
58
  return _convertB3dmToI3sGeometry.apply(this, arguments);
56
59
  }
57
60
 
58
61
  function _convertB3dmToI3sGeometry() {
59
- _convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, geoidHeightModel) {
60
- var useCartesianPositions, materialAndTextureList, convertedAttributesMap, result, nodesCounter, _tileContent$gltf$mat, materials, i, sourceMaterial, convertedAttributes, _materialAndTextureLi, material, texture;
62
+ _convertB3dmToI3sGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco, generateBoundingVolumes, geoidHeightModel, workerSource) {
63
+ var _tileContent$gltf;
64
+
65
+ var useCartesianPositions, materialAndTextureList, dataForAttributesConversion, convertedAttributesMap, result, nodesCounter, _ref3, _ref3$materials, materials, i, sourceMaterial, convertedAttributes, _materialAndTextureLi, material, texture;
61
66
 
62
67
  return _regenerator.default.wrap(function _callee$(_context) {
63
68
  while (1) {
64
69
  switch (_context.prev = _context.next) {
65
70
  case 0:
66
71
  useCartesianPositions = generateBoundingVolumes;
67
- materialAndTextureList = convertMaterials(tileContent);
68
- convertedAttributesMap = convertAttributes(tileContent, useCartesianPositions);
72
+ materialAndTextureList = convertMaterials((_tileContent$gltf = tileContent.gltf) === null || _tileContent$gltf === void 0 ? void 0 : _tileContent$gltf.materials);
73
+ dataForAttributesConversion = (0, _gltfAttributes.prepareDataForAttributesConversion)(tileContent);
74
+ _context.next = 5;
75
+ return convertAttributes(dataForAttributesConversion, useCartesianPositions);
76
+
77
+ case 5:
78
+ convertedAttributesMap = _context.sent;
69
79
 
70
80
  if (generateBoundingVolumes) {
71
81
  _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeightModel);
@@ -79,7 +89,9 @@ function _convertB3dmToI3sGeometry() {
79
89
 
80
90
  result = [];
81
91
  nodesCounter = nodeId;
82
- _tileContent$gltf$mat = tileContent.gltf.materials, materials = _tileContent$gltf$mat === void 0 ? [] : _tileContent$gltf$mat;
92
+ _ref3 = tileContent.gltf || {
93
+ materials: []
94
+ }, _ref3$materials = _ref3.materials, materials = _ref3$materials === void 0 ? [] : _ref3$materials;
83
95
 
84
96
  if (!(materials !== null && materials !== void 0 && materials.length)) {
85
97
  materials.push({
@@ -89,26 +101,35 @@ function _convertB3dmToI3sGeometry() {
89
101
 
90
102
  i = 0;
91
103
 
92
- case 10:
104
+ case 13:
93
105
  if (!(i < materials.length)) {
94
- _context.next = 25;
106
+ _context.next = 30;
95
107
  break;
96
108
  }
97
109
 
98
110
  sourceMaterial = materials[i];
99
111
 
100
112
  if (convertedAttributesMap.has(sourceMaterial.id)) {
101
- _context.next = 14;
113
+ _context.next = 17;
102
114
  break;
103
115
  }
104
116
 
105
- return _context.abrupt("continue", 22);
117
+ return _context.abrupt("continue", 27);
106
118
 
107
- case 14:
119
+ case 17:
108
120
  convertedAttributes = convertedAttributesMap.get(sourceMaterial.id);
121
+
122
+ if (convertedAttributes) {
123
+ _context.next = 20;
124
+ break;
125
+ }
126
+
127
+ return _context.abrupt("continue", 27);
128
+
129
+ case 20:
109
130
  _materialAndTextureLi = materialAndTextureList[i], material = _materialAndTextureLi.material, texture = _materialAndTextureLi.texture;
110
131
  _context.t0 = result;
111
- _context.next = 19;
132
+ _context.next = 24;
112
133
  return _makeNodeResources({
113
134
  convertedAttributes: convertedAttributes,
114
135
  material: material,
@@ -117,33 +138,34 @@ function _convertB3dmToI3sGeometry() {
117
138
  nodeId: nodesCounter,
118
139
  featuresHashArray: featuresHashArray,
119
140
  attributeStorageInfo: attributeStorageInfo,
120
- draco: draco
141
+ draco: draco,
142
+ workerSource: workerSource
121
143
  });
122
144
 
123
- case 19:
145
+ case 24:
124
146
  _context.t1 = _context.sent;
125
147
 
126
148
  _context.t0.push.call(_context.t0, _context.t1);
127
149
 
128
150
  nodesCounter++;
129
151
 
130
- case 22:
152
+ case 27:
131
153
  i++;
132
- _context.next = 10;
154
+ _context.next = 13;
133
155
  break;
134
156
 
135
- case 25:
157
+ case 30:
136
158
  if (result.length) {
137
- _context.next = 27;
159
+ _context.next = 32;
138
160
  break;
139
161
  }
140
162
 
141
163
  return _context.abrupt("return", null);
142
164
 
143
- case 27:
165
+ case 32:
144
166
  return _context.abrupt("return", result);
145
167
 
146
- case 28:
168
+ case 33:
147
169
  case "end":
148
170
  return _context.stop();
149
171
  }
@@ -181,25 +203,24 @@ function _generateBoundingVolumesFromGeometry(convertedAttributesMap, geoidHeigh
181
203
  }
182
204
  }
183
205
 
184
- function _makeNodeResources(_x8) {
206
+ function _makeNodeResources(_x9) {
185
207
  return _makeNodeResources2.apply(this, arguments);
186
208
  }
187
209
 
188
210
  function _makeNodeResources2() {
189
211
  _makeNodeResources2 = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(_ref) {
190
- var convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco, boundingVolumes, vertexCount, triangleCount, _generateAttributes, faceRange, featureIds, positions, normals, colors, texCoords, featureCount, header, typedFeatureIds, fileBuffer, compressedGeometry, attributes;
212
+ var _tileContent$gltf2;
213
+
214
+ var convertedAttributes, material, texture, tileContent, nodeId, featuresHashArray, attributeStorageInfo, draco, workerSource, boundingVolumes, vertexCount, _generateAttributes, faceRange, featureIds, positions, normals, colors, texCoords, featureCount, header, typedFeatureIds, fileBuffer, compressedGeometry, attributes;
191
215
 
192
216
  return _regenerator.default.wrap(function _callee2$(_context2) {
193
217
  while (1) {
194
218
  switch (_context2.prev = _context2.next) {
195
219
  case 0:
196
- convertedAttributes = _ref.convertedAttributes, material = _ref.material, texture = _ref.texture, tileContent = _ref.tileContent, nodeId = _ref.nodeId, featuresHashArray = _ref.featuresHashArray, attributeStorageInfo = _ref.attributeStorageInfo, draco = _ref.draco;
220
+ convertedAttributes = _ref.convertedAttributes, material = _ref.material, texture = _ref.texture, tileContent = _ref.tileContent, nodeId = _ref.nodeId, featuresHashArray = _ref.featuresHashArray, attributeStorageInfo = _ref.attributeStorageInfo, draco = _ref.draco, workerSource = _ref.workerSource;
197
221
  boundingVolumes = convertedAttributes.boundingVolumes;
198
222
  vertexCount = convertedAttributes.positions.length / VALUES_PER_VERTEX;
199
- triangleCount = vertexCount / 3;
200
- _generateAttributes = (0, _geometryAttributes.generateAttributes)(_objectSpread({
201
- triangleCount: triangleCount
202
- }, convertedAttributes)), faceRange = _generateAttributes.faceRange, featureIds = _generateAttributes.featureIds, positions = _generateAttributes.positions, normals = _generateAttributes.normals, colors = _generateAttributes.colors, texCoords = _generateAttributes.texCoords, featureCount = _generateAttributes.featureCount;
223
+ _generateAttributes = (0, _geometryAttributes.generateAttributes)(convertedAttributes), faceRange = _generateAttributes.faceRange, featureIds = _generateAttributes.featureIds, positions = _generateAttributes.positions, normals = _generateAttributes.normals, colors = _generateAttributes.colors, texCoords = _generateAttributes.texCoords, featureCount = _generateAttributes.featureCount;
203
224
 
204
225
  if (tileContent.batchTableJson) {
205
226
  makeFeatureIdsUnique(featureIds, convertedAttributes.featureIndices, featuresHashArray, tileContent.batchTableJson);
@@ -209,38 +230,20 @@ function _makeNodeResources2() {
209
230
  typedFeatureIds = generateBigUint64Array(featureIds);
210
231
  header.set([vertexCount, featureCount], 0);
211
232
  fileBuffer = new Uint8Array((0, _loaderUtils.concatenateArrayBuffers)(header.buffer, positions.buffer, normals.buffer, texture ? texCoords.buffer : new ArrayBuffer(0), colors.buffer, typedFeatureIds.buffer, faceRange.buffer));
212
-
213
- if (!draco) {
214
- _context2.next = 16;
215
- break;
216
- }
217
-
218
- _context2.next = 13;
219
- return generateCompressedGeometry(vertexCount, convertedAttributes, {
233
+ compressedGeometry = draco ? generateCompressedGeometry(vertexCount, convertedAttributes, {
220
234
  positions: positions,
221
235
  normals: normals,
222
236
  texCoords: texture ? texCoords : new Float32Array(0),
223
237
  colors: colors,
224
238
  featureIds: featureIds,
225
239
  faceRange: faceRange
226
- });
227
-
228
- case 13:
229
- _context2.t0 = _context2.sent;
230
- _context2.next = 17;
231
- break;
232
-
233
- case 16:
234
- _context2.t0 = null;
235
-
236
- case 17:
237
- compressedGeometry = _context2.t0;
240
+ }, workerSource.draco) : null;
238
241
  attributes = convertBatchTableToAttributeBuffers(tileContent.batchTableJson, featureIds, attributeStorageInfo);
239
242
  return _context2.abrupt("return", {
240
243
  geometry: fileBuffer,
241
244
  compressedGeometry: compressedGeometry,
242
245
  texture: texture,
243
- sharedResources: getSharedResources(tileContent, nodeId),
246
+ sharedResources: getSharedResources(((_tileContent$gltf2 = tileContent.gltf) === null || _tileContent$gltf2 === void 0 ? void 0 : _tileContent$gltf2.materials) || [], nodeId),
244
247
  meshMaterial: material,
245
248
  vertexCount: vertexCount,
246
249
  attributes: attributes,
@@ -248,7 +251,7 @@ function _makeNodeResources2() {
248
251
  boundingVolumes: boundingVolumes
249
252
  });
250
253
 
251
- case 20:
254
+ case 12:
252
255
  case "end":
253
256
  return _context2.stop();
254
257
  }
@@ -258,79 +261,132 @@ function _makeNodeResources2() {
258
261
  return _makeNodeResources2.apply(this, arguments);
259
262
  }
260
263
 
261
- function convertAttributes(tileContent, useCartesianPositions) {
262
- var _tileContent$gltf$sce;
264
+ function convertAttributes(_x10, _x11) {
265
+ return _convertAttributes.apply(this, arguments);
266
+ }
267
+
268
+ function _convertAttributes() {
269
+ _convertAttributes = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(attributesData, useCartesianPositions) {
270
+ var gltfMaterials, nodes, cartographicOrigin, cartesianModelMatrix, attributesMap, _iterator6, _step6, material, _iterator7, _step7, attrKey, attributes;
271
+
272
+ return _regenerator.default.wrap(function _callee3$(_context3) {
273
+ while (1) {
274
+ switch (_context3.prev = _context3.next) {
275
+ case 0:
276
+ gltfMaterials = attributesData.gltfMaterials, nodes = attributesData.nodes, cartographicOrigin = attributesData.cartographicOrigin, cartesianModelMatrix = attributesData.cartesianModelMatrix;
277
+ attributesMap = new Map();
278
+ _iterator6 = _createForOfIteratorHelper(gltfMaterials || [{
279
+ id: 'default'
280
+ }]);
281
+
282
+ try {
283
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
284
+ material = _step6.value;
285
+ attributesMap.set(material.id, {
286
+ positions: new Float32Array(0),
287
+ normals: new Float32Array(0),
288
+ texCoords: new Float32Array(0),
289
+ colors: new Uint8Array(0),
290
+ featureIndicesGroups: [],
291
+ featureIndices: [],
292
+ boundingVolumes: null
293
+ });
294
+ }
295
+ } catch (err) {
296
+ _iterator6.e(err);
297
+ } finally {
298
+ _iterator6.f();
299
+ }
263
300
 
264
- var attributesMap = new Map();
301
+ convertNodes(nodes, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions);
302
+ _iterator7 = _createForOfIteratorHelper(attributesMap.keys());
303
+ _context3.prev = 6;
265
304
 
266
- var _iterator2 = _createForOfIteratorHelper(tileContent.gltf.materials || [{
267
- id: 'default'
268
- }]),
269
- _step2;
305
+ _iterator7.s();
270
306
 
271
- try {
272
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
273
- var material = _step2.value;
274
- attributesMap.set(material.id, {
275
- positions: new Float32Array(0),
276
- normals: new Float32Array(0),
277
- texCoords: new Float32Array(0),
278
- colors: new Uint8Array(0),
279
- featureIndices: [],
280
- boundingVolumes: null
281
- });
282
- }
283
- } catch (err) {
284
- _iterator2.e(err);
285
- } finally {
286
- _iterator2.f();
287
- }
307
+ case 8:
308
+ if ((_step7 = _iterator7.n()).done) {
309
+ _context3.next = 19;
310
+ break;
311
+ }
288
312
 
289
- var 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;
290
- convertNodes(nodes, tileContent, attributesMap, useCartesianPositions);
313
+ attrKey = _step7.value;
314
+ attributes = attributesMap.get(attrKey);
291
315
 
292
- var _iterator3 = _createForOfIteratorHelper(attributesMap.keys()),
293
- _step3;
316
+ if (attributes) {
317
+ _context3.next = 13;
318
+ break;
319
+ }
294
320
 
295
- try {
296
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
297
- var attrKey = _step3.value;
298
- var attributes = attributesMap.get(attrKey);
321
+ return _context3.abrupt("continue", 17);
299
322
 
300
- if (attributes.positions.length === 0) {
301
- attributesMap.delete(attrKey);
302
- continue;
303
- }
323
+ case 13:
324
+ if (!(attributes.positions.length === 0)) {
325
+ _context3.next = 16;
326
+ break;
327
+ }
304
328
 
305
- attributes.featureIndices = attributes.featureIndices.reduce(function (acc, value) {
306
- return acc.concat(value);
307
- });
308
- }
309
- } catch (err) {
310
- _iterator3.e(err);
311
- } finally {
312
- _iterator3.f();
313
- }
329
+ attributesMap.delete(attrKey);
330
+ return _context3.abrupt("continue", 17);
331
+
332
+ case 16:
333
+ if (attributes.featureIndicesGroups) {
334
+ attributes.featureIndices = attributes.featureIndicesGroups.reduce(function (acc, value) {
335
+ return acc.concat(value);
336
+ });
337
+ delete attributes.featureIndicesGroups;
338
+ }
339
+
340
+ case 17:
341
+ _context3.next = 8;
342
+ break;
343
+
344
+ case 19:
345
+ _context3.next = 24;
346
+ break;
347
+
348
+ case 21:
349
+ _context3.prev = 21;
350
+ _context3.t0 = _context3["catch"](6);
314
351
 
315
- return attributesMap;
352
+ _iterator7.e(_context3.t0);
353
+
354
+ case 24:
355
+ _context3.prev = 24;
356
+
357
+ _iterator7.f();
358
+
359
+ return _context3.finish(24);
360
+
361
+ case 27:
362
+ return _context3.abrupt("return", attributesMap);
363
+
364
+ case 28:
365
+ case "end":
366
+ return _context3.stop();
367
+ }
368
+ }
369
+ }, _callee3, null, [[6, 21, 24, 27]]);
370
+ }));
371
+ return _convertAttributes.apply(this, arguments);
316
372
  }
317
373
 
318
- function convertNodes(nodes, tileContent, attributesMap, useCartesianPositions) {
319
- var matrix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
374
+ function convertNodes(nodes, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
375
+ var matrix = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
320
376
 
321
377
  if (nodes) {
322
- var _iterator4 = _createForOfIteratorHelper(nodes),
323
- _step4;
378
+ var _iterator2 = _createForOfIteratorHelper(nodes),
379
+ _step2;
324
380
 
325
381
  try {
326
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
327
- var node = _step4.value;
328
- convertNode(node, tileContent, attributesMap, useCartesianPositions, matrix);
382
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
383
+ var node = _step2.value;
384
+ convertNode(node, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, matrix);
329
385
  }
330
386
  } catch (err) {
331
- _iterator4.e(err);
387
+ _iterator2.e(err);
332
388
  } finally {
333
- _iterator4.f();
389
+ _iterator2.f();
334
390
  }
335
391
  }
336
392
  }
@@ -346,6 +402,10 @@ function getCompositeTransformationMatrix(node, matrix) {
346
402
  transformationMatrix = matrix.multiplyRight(nodeMatrix);
347
403
  }
348
404
 
405
+ if (translation) {
406
+ transformationMatrix = transformationMatrix.translate(translation);
407
+ }
408
+
349
409
  if (rotation) {
350
410
  transformationMatrix = transformationMatrix.rotateXYZ(rotation);
351
411
  }
@@ -354,35 +414,33 @@ function getCompositeTransformationMatrix(node, matrix) {
354
414
  transformationMatrix = transformationMatrix.scale(scale);
355
415
  }
356
416
 
357
- if (translation) {
358
- transformationMatrix = transformationMatrix.translate(translation);
359
- }
360
-
361
417
  return transformationMatrix;
362
418
  }
363
419
 
364
- function convertNode(node, tileContent, attributesMap, useCartesianPositions) {
365
- var matrix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
420
+ function convertNode(node, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions) {
421
+ var matrix = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
366
422
  var transformationMatrix = getCompositeTransformationMatrix(node, matrix);
367
423
  var mesh = node.mesh;
368
424
 
369
425
  if (mesh) {
370
- convertMesh(mesh, tileContent, attributesMap, useCartesianPositions, transformationMatrix);
426
+ convertMesh(mesh, cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
371
427
  }
372
428
 
373
- convertNodes(node.children, tileContent, attributesMap, useCartesianPositions, transformationMatrix);
429
+ convertNodes(node.children || [], cartographicOrigin, cartesianModelMatrix, attributesMap, useCartesianPositions, transformationMatrix);
374
430
  }
375
431
 
376
- function convertMesh(mesh, content, attributesMap) {
377
- var useCartesianPositions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
378
- var matrix = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
432
+ function convertMesh(mesh, cartographicOrigin, cartesianModelMatrix, attributesMap) {
433
+ var useCartesianPositions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
434
+ var matrix = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : new _core.Matrix4([1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
379
435
 
380
- var _iterator5 = _createForOfIteratorHelper(mesh.primitives),
381
- _step5;
436
+ var _iterator3 = _createForOfIteratorHelper(mesh.primitives),
437
+ _step3;
382
438
 
383
439
  try {
384
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
385
- var primitive = _step5.value;
440
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
441
+ var _primitive$indices, _primitive$indices2, _primitive$indices3, _primitive$indices4, _primitive$indices5;
442
+
443
+ var primitive = _step3.value;
386
444
  var outputAttributes = null;
387
445
 
388
446
  if (primitive.material) {
@@ -393,32 +451,38 @@ function convertMesh(mesh, content, attributesMap) {
393
451
 
394
452
  (0, _core2.assert)(outputAttributes !== null, 'Primitive - material mapping failed');
395
453
  var attributes = primitive.attributes;
454
+
455
+ if (!outputAttributes) {
456
+ continue;
457
+ }
458
+
396
459
  outputAttributes.positions = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.positions, transformVertexArray({
397
460
  vertices: attributes.POSITION.value,
398
- cartographicOrigin: content.cartographicOrigin,
399
- cartesianModelMatrix: content.cartesianModelMatrix,
461
+ cartographicOrigin: cartographicOrigin,
462
+ cartesianModelMatrix: cartesianModelMatrix,
400
463
  nodeMatrix: matrix,
401
- indices: primitive.indices.value,
464
+ indices: (_primitive$indices = primitive.indices) === null || _primitive$indices === void 0 ? void 0 : _primitive$indices.value,
402
465
  attributeSpecificTransformation: transformVertexPositions,
403
466
  useCartesianPositions: useCartesianPositions
404
467
  }));
405
468
  outputAttributes.normals = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.normals, transformVertexArray({
406
469
  vertices: attributes.NORMAL && attributes.NORMAL.value,
407
- cartographicOrigin: content.cartographicOrigin,
408
- cartesianModelMatrix: content.cartesianModelMatrix,
470
+ cartographicOrigin: cartographicOrigin,
471
+ cartesianModelMatrix: cartesianModelMatrix,
409
472
  nodeMatrix: matrix,
410
- indices: primitive.indices.value,
473
+ indices: (_primitive$indices2 = primitive.indices) === null || _primitive$indices2 === void 0 ? void 0 : _primitive$indices2.value,
411
474
  attributeSpecificTransformation: transformVertexNormals,
412
475
  useCartesianPositions: false
413
476
  }));
414
- outputAttributes.texCoords = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, primitive.indices.value));
415
- outputAttributes.colors = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0, primitive.indices.value));
416
- outputAttributes.featureIndices.push(flattenBatchIds(getBatchIdsByAttributeName(attributes), primitive.indices.value));
477
+ outputAttributes.texCoords = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.texCoords, flattenTexCoords(attributes.TEXCOORD_0 && attributes.TEXCOORD_0.value, (_primitive$indices3 = primitive.indices) === null || _primitive$indices3 === void 0 ? void 0 : _primitive$indices3.value));
478
+ outputAttributes.colors = (0, _loaderUtils.concatenateTypedArrays)(outputAttributes.colors, flattenColors(attributes.COLOR_0, (_primitive$indices4 = primitive.indices) === null || _primitive$indices4 === void 0 ? void 0 : _primitive$indices4.value));
479
+ outputAttributes.featureIndicesGroups = outputAttributes.featureIndicesGroups || [];
480
+ outputAttributes.featureIndicesGroups.push(flattenBatchIds(getBatchIdsByAttributeName(attributes), (_primitive$indices5 = primitive.indices) === null || _primitive$indices5 === void 0 ? void 0 : _primitive$indices5.value));
417
481
  }
418
482
  } catch (err) {
419
- _iterator5.e(err);
483
+ _iterator3.e(err);
420
484
  } finally {
421
- _iterator5.f();
485
+ _iterator3.f();
422
486
  }
423
487
  }
424
488
 
@@ -553,36 +617,36 @@ function getBatchIdsByAttributeName(attributes) {
553
617
  return batchIds;
554
618
  }
555
619
 
556
- function convertMaterials(tileContent) {
620
+ function convertMaterials() {
621
+ var sourceMaterials = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
557
622
  var result = [];
558
- var sourceMaterials = tileContent.gltf.materials || [];
559
623
 
560
- var _iterator6 = _createForOfIteratorHelper(sourceMaterials),
561
- _step6;
624
+ var _iterator4 = _createForOfIteratorHelper(sourceMaterials),
625
+ _step4;
562
626
 
563
627
  try {
564
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
565
- var sourceMaterial = _step6.value;
628
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
629
+ var sourceMaterial = _step4.value;
566
630
  result.push(convertMaterial(sourceMaterial));
567
631
  }
568
632
  } catch (err) {
569
- _iterator6.e(err);
633
+ _iterator4.e(err);
570
634
  } finally {
571
- _iterator6.f();
635
+ _iterator4.f();
572
636
  }
573
637
 
574
638
  return result;
575
639
  }
576
640
 
577
641
  function convertMaterial(sourceMaterial) {
578
- var _sourceMaterial$pbrMe, _sourceMaterial$pbrMe2, _sourceMaterial$pbrMe3;
642
+ var _sourceMaterial$emiss, _sourceMaterial$pbrMe, _sourceMaterial$pbrMe2, _sourceMaterial$pbrMe3;
579
643
 
580
644
  var material = {
581
645
  doubleSided: sourceMaterial.doubleSided,
582
- emissiveFactor: sourceMaterial.emissiveFactor.map(function (c) {
646
+ emissiveFactor: (_sourceMaterial$emiss = sourceMaterial.emissiveFactor) === null || _sourceMaterial$emiss === void 0 ? void 0 : _sourceMaterial$emiss.map(function (c) {
583
647
  return Math.round(c * 255);
584
648
  }),
585
- alphaMode: (sourceMaterial.alphaMode || 'OPAQUE').toLowerCase(),
649
+ alphaMode: convertAlphaMode(sourceMaterial.alphaMode),
586
650
  pbrMetallicRoughness: {
587
651
  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,
588
652
  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
@@ -617,15 +681,33 @@ function convertMaterial(sourceMaterial) {
617
681
  };
618
682
  }
619
683
 
684
+ function convertAlphaMode(gltfAlphaMode) {
685
+ switch (gltfAlphaMode) {
686
+ case 'OPAQUE':
687
+ return 'opaque';
688
+
689
+ case 'MASK':
690
+ return 'mask';
691
+
692
+ case 'BLEND':
693
+ return 'blend';
694
+
695
+ default:
696
+ return 'opaque';
697
+ }
698
+ }
699
+
620
700
  function getDefaultMaterial() {
621
701
  return {
622
702
  alphaMode: 'opaque',
623
- pbrMetallicRoughness: {}
703
+ pbrMetallicRoughness: {
704
+ metallicFactor: 1,
705
+ roughnessFactor: 1
706
+ }
624
707
  };
625
708
  }
626
709
 
627
- function getSharedResources(tileContent, nodeId) {
628
- var gltfMaterials = tileContent.gltf.materials;
710
+ function getSharedResources(gltfMaterials, nodeId) {
629
711
  var i3sResources = {};
630
712
 
631
713
  if (!gltfMaterials || !gltfMaterials.length) {
@@ -634,12 +716,12 @@ function getSharedResources(tileContent, nodeId) {
634
716
 
635
717
  i3sResources.materialDefinitionInfos = [];
636
718
 
637
- var _iterator7 = _createForOfIteratorHelper(gltfMaterials),
638
- _step7;
719
+ var _iterator5 = _createForOfIteratorHelper(gltfMaterials),
720
+ _step5;
639
721
 
640
722
  try {
641
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
642
- var gltfMaterial = _step7.value;
723
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
724
+ var gltfMaterial = _step5.value;
643
725
 
644
726
  var _convertGLTFMaterialT = convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId),
645
727
  materialDefinitionInfo = _convertGLTFMaterialT.materialDefinitionInfo,
@@ -653,9 +735,9 @@ function getSharedResources(tileContent, nodeId) {
653
735
  }
654
736
  }
655
737
  } catch (err) {
656
- _iterator7.e(err);
738
+ _iterator5.e(err);
657
739
  } finally {
658
- _iterator7.f();
740
+ _iterator5.f();
659
741
  }
660
742
 
661
743
  return i3sResources;
@@ -683,7 +765,7 @@ function convertGLTFMaterialToI3sSharedResources(gltfMaterial, nodeId) {
683
765
  }
684
766
 
685
767
  return {
686
- materialDefinitionInfo: extractSharedResourcesMaterialInfo(colorFactor, metallicFactor),
768
+ materialDefinitionInfo: extractSharedResourcesMaterialInfo(colorFactor || [1, 1, 1, 1], metallicFactor),
687
769
  textureDefinitionInfo: textureDefinitionInfo
688
770
  };
689
771
  }
@@ -700,26 +782,34 @@ function extractSharedResourcesMaterialInfo(baseColorFactor) {
700
782
  dielectricSpecular[3] = 1;
701
783
  var specular = dielectricSpecular.lerp(dielectricSpecular, baseColorVector, metallicFactor);
702
784
  return {
703
- diffuse: diffuse.toArray(),
704
- specular: specular.toArray()
785
+ params: {
786
+ diffuse: diffuse.toArray(),
787
+ specular: specular.toArray(),
788
+ renderMode: 'solid'
789
+ }
705
790
  };
706
791
  }
707
792
 
708
793
  function extractSharedResourcesTextureInfo(texture, nodeId) {
794
+ var _texture$source, _texture$source2, _texture$source3;
795
+
709
796
  return {
710
- encoding: [texture.source.mimeType],
797
+ encoding: texture !== null && texture !== void 0 && (_texture$source = texture.source) !== null && _texture$source !== void 0 && _texture$source.mimeType ? [texture.source.mimeType] : undefined,
711
798
  images: [{
712
799
  id: generateImageId(texture, nodeId),
713
- size: texture.source.image.width,
714
- length: [texture.source.image.data.length]
800
+ size: (_texture$source2 = texture.source) === null || _texture$source2 === void 0 ? void 0 : _texture$source2.image.width,
801
+ length: [(_texture$source3 = texture.source) === null || _texture$source3 === void 0 ? void 0 : _texture$source3.image.data.length]
715
802
  }]
716
803
  };
717
804
  }
718
805
 
719
806
  function generateImageId(texture, nodeId) {
720
- var _texture$source$image = texture.source.image,
807
+ var _texture$source4;
808
+
809
+ var _texture$source$image = (_texture$source4 = texture.source) === null || _texture$source4 === void 0 ? void 0 : _texture$source4.image,
721
810
  width = _texture$source$image.width,
722
811
  height = _texture$source$image.height;
812
+
723
813
  var levelCountOfTexture = 1;
724
814
  var indexOfLevel = 0;
725
815
  var indexOfTextureInStore = nodeId + 1;
@@ -755,8 +845,8 @@ function getFeaturesReplaceMap(featureIds, batchTable, featuresHashArray) {
755
845
  function generateStringFromBatchTableByIndex(batchTable, index) {
756
846
  var str = '';
757
847
 
758
- for (var key in batchTable) {
759
- str += batchTable[key][index];
848
+ for (var _key in batchTable) {
849
+ str += batchTable[_key][index];
760
850
  }
761
851
 
762
852
  return str;
@@ -787,29 +877,31 @@ function convertBatchTableToAttributeBuffers(batchTable, featureIds, attributeSt
787
877
  OBJECTID: featureIds
788
878
  }, batchTable);
789
879
 
790
- for (var key in batchTableWithFeatureIds) {
791
- var type = getAttributeType(key, attributeStorageInfo);
880
+ for (var _key2 in batchTableWithFeatureIds) {
881
+ var type = getAttributeType(_key2, attributeStorageInfo);
792
882
  var attributeBuffer = null;
793
883
 
794
884
  switch (type) {
795
885
  case OBJECT_ID_TYPE:
796
886
  case SHORT_INT_TYPE:
797
- attributeBuffer = generateShortIntegerAttributeBuffer(batchTableWithFeatureIds[key]);
887
+ attributeBuffer = generateShortIntegerAttributeBuffer(batchTableWithFeatureIds[_key2]);
798
888
  break;
799
889
 
800
890
  case DOUBLE_TYPE:
801
- attributeBuffer = generateDoubleAttributeBuffer(batchTableWithFeatureIds[key]);
891
+ attributeBuffer = generateDoubleAttributeBuffer(batchTableWithFeatureIds[_key2]);
802
892
  break;
803
893
 
804
894
  case STRING_TYPE:
805
- attributeBuffer = generateStringAttributeBuffer(batchTableWithFeatureIds[key]);
895
+ attributeBuffer = generateStringAttributeBuffer(batchTableWithFeatureIds[_key2]);
806
896
  break;
807
897
 
808
898
  default:
809
- attributeBuffer = generateStringAttributeBuffer(batchTableWithFeatureIds[key]);
899
+ attributeBuffer = generateStringAttributeBuffer(batchTableWithFeatureIds[_key2]);
810
900
  }
811
901
 
812
- attributeBuffers.push(attributeBuffer);
902
+ if (attributeBuffer) {
903
+ attributeBuffers.push(attributeBuffer);
904
+ }
813
905
  }
814
906
  }
815
907
 
@@ -865,16 +957,16 @@ function generateBigUint64Array(featureIds) {
865
957
  return typedFeatureIds;
866
958
  }
867
959
 
868
- function generateCompressedGeometry(_x9, _x10, _x11) {
960
+ function generateCompressedGeometry(_x12, _x13, _x14, _x15) {
869
961
  return _generateCompressedGeometry.apply(this, arguments);
870
962
  }
871
963
 
872
964
  function _generateCompressedGeometry() {
873
- _generateCompressedGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee3(vertexCount, convertedAttributes, attributes) {
965
+ _generateCompressedGeometry = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee4(vertexCount, convertedAttributes, attributes, dracoWorkerSoure) {
874
966
  var positions, normals, texCoords, colors, featureIds, faceRange, indices, index, featureIndices, featureIndex, compressedAttributes, attributesMetadata;
875
- return _regenerator.default.wrap(function _callee3$(_context3) {
967
+ return _regenerator.default.wrap(function _callee4$(_context4) {
876
968
  while (1) {
877
- switch (_context3.prev = _context3.next) {
969
+ switch (_context4.prev = _context4.next) {
878
970
  case 0:
879
971
  positions = attributes.positions, normals = attributes.normals, texCoords = attributes.texCoords, colors = attributes.colors, featureIds = attributes.featureIds, faceRange = attributes.faceRange;
880
972
  indices = new Uint32Array(vertexCount);
@@ -902,28 +994,25 @@ function _generateCompressedGeometry() {
902
994
  'i3s-feature-ids': new Int32Array(featureIds)
903
995
  }
904
996
  };
905
- _context3.t0 = Uint8Array;
906
- _context3.next = 11;
907
- return (0, _core2.encode)({
997
+ return _context4.abrupt("return", (0, _core2.encode)({
908
998
  attributes: compressedAttributes,
909
999
  indices: indices
910
- }, _draco.DracoWriter, {
1000
+ }, _draco.DracoWriterWorker, _objectSpread(_objectSpread({}, _draco.DracoWriterWorker.options), {}, {
1001
+ source: dracoWorkerSoure,
1002
+ reuseWorkers: true,
1003
+ _nodeWorkers: true,
911
1004
  draco: {
912
1005
  method: 'MESH_SEQUENTIAL_ENCODING',
913
1006
  attributesMetadata: attributesMetadata
914
1007
  }
915
- });
916
-
917
- case 11:
918
- _context3.t1 = _context3.sent;
919
- return _context3.abrupt("return", new _context3.t0(_context3.t1));
1008
+ })));
920
1009
 
921
- case 13:
1010
+ case 9:
922
1011
  case "end":
923
- return _context3.stop();
1012
+ return _context4.stop();
924
1013
  }
925
1014
  }
926
- }, _callee3);
1015
+ }, _callee4);
927
1016
  }));
928
1017
  return _generateCompressedGeometry.apply(this, arguments);
929
1018
  }