@loaders.gl/draco 3.1.0-beta.7 → 3.1.3

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.
@@ -7,19 +7,40 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = void 0;
9
9
 
10
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
+
16
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
17
+
18
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
19
+
10
20
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
21
 
12
- const GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP = {
22
+ 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; } } }; }
23
+
24
+ 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); }
25
+
26
+ 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; }
27
+
28
+ 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; }
29
+
30
+ 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; }
31
+
32
+ var GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP = {
13
33
  POSITION: 'POSITION',
14
34
  NORMAL: 'NORMAL',
15
35
  COLOR_0: 'COLOR',
16
36
  TEXCOORD_0: 'TEX_COORD'
17
37
  };
18
38
 
19
- const noop = () => {};
39
+ var noop = function noop() {};
20
40
 
21
- class DracoBuilder {
22
- constructor(draco) {
41
+ var DracoBuilder = function () {
42
+ function DracoBuilder(draco) {
43
+ (0, _classCallCheck2.default)(this, DracoBuilder);
23
44
  (0, _defineProperty2.default)(this, "draco", void 0);
24
45
  (0, _defineProperty2.default)(this, "dracoEncoder", void 0);
25
46
  (0, _defineProperty2.default)(this, "dracoMeshBuilder", void 0);
@@ -31,323 +52,350 @@ class DracoBuilder {
31
52
  this.dracoMetadataBuilder = new this.draco.MetadataBuilder();
32
53
  }
33
54
 
34
- destroy() {
35
- this.destroyEncodedObject(this.dracoMeshBuilder);
36
- this.destroyEncodedObject(this.dracoEncoder);
37
- this.destroyEncodedObject(this.dracoMetadataBuilder);
38
- this.dracoMeshBuilder = null;
39
- this.dracoEncoder = null;
40
- this.draco = null;
41
- }
42
-
43
- destroyEncodedObject(object) {
44
- if (object) {
45
- this.draco.destroy(object);
55
+ (0, _createClass2.default)(DracoBuilder, [{
56
+ key: "destroy",
57
+ value: function destroy() {
58
+ this.destroyEncodedObject(this.dracoMeshBuilder);
59
+ this.destroyEncodedObject(this.dracoEncoder);
60
+ this.destroyEncodedObject(this.dracoMetadataBuilder);
61
+ this.dracoMeshBuilder = null;
62
+ this.dracoEncoder = null;
63
+ this.draco = null;
46
64
  }
47
- }
48
-
49
- encodeSync(mesh, options = {}) {
50
- this.log = noop;
65
+ }, {
66
+ key: "destroyEncodedObject",
67
+ value: function destroyEncodedObject(object) {
68
+ if (object) {
69
+ this.draco.destroy(object);
70
+ }
71
+ }
72
+ }, {
73
+ key: "encodeSync",
74
+ value: function encodeSync(mesh) {
75
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
76
+ this.log = noop;
51
77
 
52
- this._setOptions(options);
78
+ this._setOptions(options);
53
79
 
54
- return options.pointcloud ? this._encodePointCloud(mesh, options) : this._encodeMesh(mesh, options);
55
- }
80
+ return options.pointcloud ? this._encodePointCloud(mesh, options) : this._encodeMesh(mesh, options);
81
+ }
82
+ }, {
83
+ key: "_getAttributesFromMesh",
84
+ value: function _getAttributesFromMesh(mesh) {
85
+ var attributes = _objectSpread(_objectSpread({}, mesh), mesh.attributes);
56
86
 
57
- _getAttributesFromMesh(mesh) {
58
- const attributes = { ...mesh,
59
- ...mesh.attributes
60
- };
87
+ if (mesh.indices) {
88
+ attributes.indices = mesh.indices;
89
+ }
61
90
 
62
- if (mesh.indices) {
63
- attributes.indices = mesh.indices;
91
+ return attributes;
64
92
  }
93
+ }, {
94
+ key: "_encodePointCloud",
95
+ value: function _encodePointCloud(pointcloud, options) {
96
+ var dracoPointCloud = new this.draco.PointCloud();
65
97
 
66
- return attributes;
67
- }
68
-
69
- _encodePointCloud(pointcloud, options) {
70
- const dracoPointCloud = new this.draco.PointCloud();
98
+ if (options.metadata) {
99
+ this._addGeometryMetadata(dracoPointCloud, options.metadata);
100
+ }
71
101
 
72
- if (options.metadata) {
73
- this._addGeometryMetadata(dracoPointCloud, options.metadata);
74
- }
102
+ var attributes = this._getAttributesFromMesh(pointcloud);
75
103
 
76
- const attributes = this._getAttributesFromMesh(pointcloud);
104
+ this._createDracoPointCloud(dracoPointCloud, attributes, options);
77
105
 
78
- this._createDracoPointCloud(dracoPointCloud, attributes, options);
106
+ var dracoData = new this.draco.DracoInt8Array();
79
107
 
80
- const dracoData = new this.draco.DracoInt8Array();
108
+ try {
109
+ var encodedLen = this.dracoEncoder.EncodePointCloudToDracoBuffer(dracoPointCloud, false, dracoData);
81
110
 
82
- try {
83
- const encodedLen = this.dracoEncoder.EncodePointCloudToDracoBuffer(dracoPointCloud, false, dracoData);
111
+ if (!(encodedLen > 0)) {
112
+ throw new Error('Draco encoding failed.');
113
+ }
84
114
 
85
- if (!(encodedLen > 0)) {
86
- throw new Error('Draco encoding failed.');
115
+ this.log("DRACO encoded ".concat(dracoPointCloud.num_points(), " points\n with ").concat(dracoPointCloud.num_attributes(), " attributes into ").concat(encodedLen, " bytes"));
116
+ return dracoInt8ArrayToArrayBuffer(dracoData);
117
+ } finally {
118
+ this.destroyEncodedObject(dracoData);
119
+ this.destroyEncodedObject(dracoPointCloud);
87
120
  }
88
-
89
- this.log("DRACO encoded ".concat(dracoPointCloud.num_points(), " points\n with ").concat(dracoPointCloud.num_attributes(), " attributes into ").concat(encodedLen, " bytes"));
90
- return dracoInt8ArrayToArrayBuffer(dracoData);
91
- } finally {
92
- this.destroyEncodedObject(dracoData);
93
- this.destroyEncodedObject(dracoPointCloud);
94
121
  }
95
- }
122
+ }, {
123
+ key: "_encodeMesh",
124
+ value: function _encodeMesh(mesh, options) {
125
+ var dracoMesh = new this.draco.Mesh();
96
126
 
97
- _encodeMesh(mesh, options) {
98
- const dracoMesh = new this.draco.Mesh();
127
+ if (options.metadata) {
128
+ this._addGeometryMetadata(dracoMesh, options.metadata);
129
+ }
99
130
 
100
- if (options.metadata) {
101
- this._addGeometryMetadata(dracoMesh, options.metadata);
102
- }
131
+ var attributes = this._getAttributesFromMesh(mesh);
103
132
 
104
- const attributes = this._getAttributesFromMesh(mesh);
133
+ this._createDracoMesh(dracoMesh, attributes, options);
105
134
 
106
- this._createDracoMesh(dracoMesh, attributes, options);
135
+ var dracoData = new this.draco.DracoInt8Array();
107
136
 
108
- const dracoData = new this.draco.DracoInt8Array();
137
+ try {
138
+ var encodedLen = this.dracoEncoder.EncodeMeshToDracoBuffer(dracoMesh, dracoData);
109
139
 
110
- try {
111
- const encodedLen = this.dracoEncoder.EncodeMeshToDracoBuffer(dracoMesh, dracoData);
140
+ if (encodedLen <= 0) {
141
+ throw new Error('Draco encoding failed.');
142
+ }
112
143
 
113
- if (encodedLen <= 0) {
114
- throw new Error('Draco encoding failed.');
144
+ this.log("DRACO encoded ".concat(dracoMesh.num_points(), " points\n with ").concat(dracoMesh.num_attributes(), " attributes into ").concat(encodedLen, " bytes"));
145
+ return dracoInt8ArrayToArrayBuffer(dracoData);
146
+ } finally {
147
+ this.destroyEncodedObject(dracoData);
148
+ this.destroyEncodedObject(dracoMesh);
115
149
  }
116
-
117
- this.log("DRACO encoded ".concat(dracoMesh.num_points(), " points\n with ").concat(dracoMesh.num_attributes(), " attributes into ").concat(encodedLen, " bytes"));
118
- return dracoInt8ArrayToArrayBuffer(dracoData);
119
- } finally {
120
- this.destroyEncodedObject(dracoData);
121
- this.destroyEncodedObject(dracoMesh);
122
- }
123
- }
124
-
125
- _setOptions(options) {
126
- if ('speed' in options) {
127
- this.dracoEncoder.SetSpeedOptions(...options.speed);
128
150
  }
151
+ }, {
152
+ key: "_setOptions",
153
+ value: function _setOptions(options) {
154
+ if ('speed' in options) {
155
+ var _this$dracoEncoder;
129
156
 
130
- if ('method' in options) {
131
- const dracoMethod = this.draco[options.method || 'MESH_SEQUENTIAL_ENCODING'];
132
- this.dracoEncoder.SetEncodingMethod(dracoMethod);
133
- }
134
-
135
- if ('quantization' in options) {
136
- for (const attribute in options.quantization) {
137
- const bits = options.quantization[attribute];
138
- const dracoPosition = this.draco[attribute];
139
- this.dracoEncoder.SetAttributeQuantization(dracoPosition, bits);
157
+ (_this$dracoEncoder = this.dracoEncoder).SetSpeedOptions.apply(_this$dracoEncoder, (0, _toConsumableArray2.default)(options.speed));
140
158
  }
141
- }
142
- }
143
-
144
- _createDracoMesh(dracoMesh, attributes, options) {
145
- const optionalMetadata = options.attributesMetadata || {};
146
-
147
- try {
148
- const positions = this._getPositionAttribute(attributes);
149
159
 
150
- if (!positions) {
151
- throw new Error('positions');
160
+ if ('method' in options) {
161
+ var dracoMethod = this.draco[options.method || 'MESH_SEQUENTIAL_ENCODING'];
162
+ this.dracoEncoder.SetEncodingMethod(dracoMethod);
152
163
  }
153
164
 
154
- const vertexCount = positions.length / 3;
155
-
156
- for (let attributeName in attributes) {
157
- const attribute = attributes[attributeName];
158
- attributeName = GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP[attributeName] || attributeName;
159
-
160
- const uniqueId = this._addAttributeToMesh(dracoMesh, attributeName, attribute, vertexCount);
161
-
162
- if (uniqueId !== -1) {
163
- this._addAttributeMetadata(dracoMesh, uniqueId, {
164
- name: attributeName,
165
- ...(optionalMetadata[attributeName] || {})
166
- });
165
+ if ('quantization' in options) {
166
+ for (var attribute in options.quantization) {
167
+ var bits = options.quantization[attribute];
168
+ var dracoPosition = this.draco[attribute];
169
+ this.dracoEncoder.SetAttributeQuantization(dracoPosition, bits);
167
170
  }
168
171
  }
169
- } catch (error) {
170
- this.destroyEncodedObject(dracoMesh);
171
- throw error;
172
172
  }
173
+ }, {
174
+ key: "_createDracoMesh",
175
+ value: function _createDracoMesh(dracoMesh, attributes, options) {
176
+ var optionalMetadata = options.attributesMetadata || {};
173
177
 
174
- return dracoMesh;
175
- }
176
-
177
- _createDracoPointCloud(dracoPointCloud, attributes, options) {
178
- const optionalMetadata = options.attributesMetadata || {};
178
+ try {
179
+ var positions = this._getPositionAttribute(attributes);
179
180
 
180
- try {
181
- const positions = this._getPositionAttribute(attributes);
182
-
183
- if (!positions) {
184
- throw new Error('positions');
185
- }
181
+ if (!positions) {
182
+ throw new Error('positions');
183
+ }
186
184
 
187
- const vertexCount = positions.length / 3;
185
+ var vertexCount = positions.length / 3;
188
186
 
189
- for (let attributeName in attributes) {
190
- const attribute = attributes[attributeName];
191
- attributeName = GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP[attributeName] || attributeName;
187
+ for (var _attributeName in attributes) {
188
+ var attribute = attributes[_attributeName];
189
+ _attributeName = GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP[_attributeName] || _attributeName;
192
190
 
193
- const uniqueId = this._addAttributeToMesh(dracoPointCloud, attributeName, attribute, vertexCount);
191
+ var uniqueId = this._addAttributeToMesh(dracoMesh, _attributeName, attribute, vertexCount);
194
192
 
195
- if (uniqueId !== -1) {
196
- this._addAttributeMetadata(dracoPointCloud, uniqueId, {
197
- name: attributeName,
198
- ...(optionalMetadata[attributeName] || {})
199
- });
193
+ if (uniqueId !== -1) {
194
+ this._addAttributeMetadata(dracoMesh, uniqueId, _objectSpread({
195
+ name: _attributeName
196
+ }, optionalMetadata[_attributeName] || {}));
197
+ }
200
198
  }
199
+ } catch (error) {
200
+ this.destroyEncodedObject(dracoMesh);
201
+ throw error;
201
202
  }
202
- } catch (error) {
203
- this.destroyEncodedObject(dracoPointCloud);
204
- throw error;
205
- }
206
203
 
207
- return dracoPointCloud;
208
- }
209
-
210
- _addAttributeToMesh(mesh, attributeName, attribute, vertexCount) {
211
- if (!ArrayBuffer.isView(attribute)) {
212
- return -1;
204
+ return dracoMesh;
213
205
  }
206
+ }, {
207
+ key: "_createDracoPointCloud",
208
+ value: function _createDracoPointCloud(dracoPointCloud, attributes, options) {
209
+ var optionalMetadata = options.attributesMetadata || {};
214
210
 
215
- const type = this._getDracoAttributeType(attributeName);
216
-
217
- const size = attribute.length / vertexCount;
211
+ try {
212
+ var positions = this._getPositionAttribute(attributes);
218
213
 
219
- if (type === 'indices') {
220
- const numFaces = attribute.length / 3;
221
- this.log("Adding attribute ".concat(attributeName, ", size ").concat(numFaces));
222
- this.dracoMeshBuilder.AddFacesToMesh(mesh, numFaces, attribute);
223
- return -1;
224
- }
225
-
226
- this.log("Adding attribute ".concat(attributeName, ", size ").concat(size));
227
- const builder = this.dracoMeshBuilder;
228
- const {
229
- buffer
230
- } = attribute;
214
+ if (!positions) {
215
+ throw new Error('positions');
216
+ }
231
217
 
232
- switch (attribute.constructor) {
233
- case Int8Array:
234
- return builder.AddInt8Attribute(mesh, type, vertexCount, size, new Int8Array(buffer));
218
+ var vertexCount = positions.length / 3;
235
219
 
236
- case Int16Array:
237
- return builder.AddInt16Attribute(mesh, type, vertexCount, size, new Int16Array(buffer));
220
+ for (var _attributeName2 in attributes) {
221
+ var attribute = attributes[_attributeName2];
222
+ _attributeName2 = GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP[_attributeName2] || _attributeName2;
238
223
 
239
- case Int32Array:
240
- return builder.AddInt32Attribute(mesh, type, vertexCount, size, new Int32Array(buffer));
224
+ var uniqueId = this._addAttributeToMesh(dracoPointCloud, _attributeName2, attribute, vertexCount);
241
225
 
242
- case Uint8Array:
243
- case Uint8ClampedArray:
244
- return builder.AddUInt8Attribute(mesh, type, vertexCount, size, new Uint8Array(buffer));
226
+ if (uniqueId !== -1) {
227
+ this._addAttributeMetadata(dracoPointCloud, uniqueId, _objectSpread({
228
+ name: _attributeName2
229
+ }, optionalMetadata[_attributeName2] || {}));
230
+ }
231
+ }
232
+ } catch (error) {
233
+ this.destroyEncodedObject(dracoPointCloud);
234
+ throw error;
235
+ }
245
236
 
246
- case Uint16Array:
247
- return builder.AddUInt16Attribute(mesh, type, vertexCount, size, new Uint16Array(buffer));
237
+ return dracoPointCloud;
238
+ }
239
+ }, {
240
+ key: "_addAttributeToMesh",
241
+ value: function _addAttributeToMesh(mesh, attributeName, attribute, vertexCount) {
242
+ if (!ArrayBuffer.isView(attribute)) {
243
+ return -1;
244
+ }
248
245
 
249
- case Uint32Array:
250
- return builder.AddUInt32Attribute(mesh, type, vertexCount, size, new Uint32Array(buffer));
246
+ var type = this._getDracoAttributeType(attributeName);
251
247
 
252
- case Float32Array:
253
- default:
254
- return builder.AddFloatAttribute(mesh, type, vertexCount, size, new Float32Array(buffer));
255
- }
256
- }
248
+ var size = attribute.length / vertexCount;
257
249
 
258
- _getDracoAttributeType(attributeName) {
259
- switch (attributeName.toLowerCase()) {
260
- case 'indices':
261
- return 'indices';
250
+ if (type === 'indices') {
251
+ var numFaces = attribute.length / 3;
252
+ this.log("Adding attribute ".concat(attributeName, ", size ").concat(numFaces));
253
+ this.dracoMeshBuilder.AddFacesToMesh(mesh, numFaces, attribute);
254
+ return -1;
255
+ }
262
256
 
263
- case 'position':
264
- case 'positions':
265
- case 'vertices':
266
- return this.draco.POSITION;
257
+ this.log("Adding attribute ".concat(attributeName, ", size ").concat(size));
258
+ var builder = this.dracoMeshBuilder;
259
+ var buffer = attribute.buffer;
267
260
 
268
- case 'normal':
269
- case 'normals':
270
- return this.draco.NORMAL;
261
+ switch (attribute.constructor) {
262
+ case Int8Array:
263
+ return builder.AddInt8Attribute(mesh, type, vertexCount, size, new Int8Array(buffer));
271
264
 
272
- case 'color':
273
- case 'colors':
274
- return this.draco.COLOR;
265
+ case Int16Array:
266
+ return builder.AddInt16Attribute(mesh, type, vertexCount, size, new Int16Array(buffer));
275
267
 
276
- case 'texcoord':
277
- case 'texcoords':
278
- return this.draco.TEX_COORD;
268
+ case Int32Array:
269
+ return builder.AddInt32Attribute(mesh, type, vertexCount, size, new Int32Array(buffer));
279
270
 
280
- default:
281
- return this.draco.GENERIC;
282
- }
283
- }
271
+ case Uint8Array:
272
+ case Uint8ClampedArray:
273
+ return builder.AddUInt8Attribute(mesh, type, vertexCount, size, new Uint8Array(buffer));
284
274
 
285
- _getPositionAttribute(attributes) {
286
- for (const attributeName in attributes) {
287
- const attribute = attributes[attributeName];
275
+ case Uint16Array:
276
+ return builder.AddUInt16Attribute(mesh, type, vertexCount, size, new Uint16Array(buffer));
288
277
 
289
- const dracoType = this._getDracoAttributeType(attributeName);
278
+ case Uint32Array:
279
+ return builder.AddUInt32Attribute(mesh, type, vertexCount, size, new Uint32Array(buffer));
290
280
 
291
- if (dracoType === this.draco.POSITION) {
292
- return attribute;
281
+ case Float32Array:
282
+ default:
283
+ return builder.AddFloatAttribute(mesh, type, vertexCount, size, new Float32Array(buffer));
293
284
  }
294
285
  }
286
+ }, {
287
+ key: "_getDracoAttributeType",
288
+ value: function _getDracoAttributeType(attributeName) {
289
+ switch (attributeName.toLowerCase()) {
290
+ case 'indices':
291
+ return 'indices';
292
+
293
+ case 'position':
294
+ case 'positions':
295
+ case 'vertices':
296
+ return this.draco.POSITION;
297
+
298
+ case 'normal':
299
+ case 'normals':
300
+ return this.draco.NORMAL;
301
+
302
+ case 'color':
303
+ case 'colors':
304
+ return this.draco.COLOR;
305
+
306
+ case 'texcoord':
307
+ case 'texcoords':
308
+ return this.draco.TEX_COORD;
295
309
 
296
- return null;
297
- }
298
-
299
- _addGeometryMetadata(dracoGeometry, metadata) {
300
- const dracoMetadata = new this.draco.Metadata();
310
+ default:
311
+ return this.draco.GENERIC;
312
+ }
313
+ }
314
+ }, {
315
+ key: "_getPositionAttribute",
316
+ value: function _getPositionAttribute(attributes) {
317
+ for (var _attributeName3 in attributes) {
318
+ var attribute = attributes[_attributeName3];
301
319
 
302
- this._populateDracoMetadata(dracoMetadata, metadata);
320
+ var dracoType = this._getDracoAttributeType(_attributeName3);
303
321
 
304
- this.dracoMeshBuilder.AddMetadata(dracoGeometry, dracoMetadata);
305
- }
306
-
307
- _addAttributeMetadata(dracoGeometry, uniqueAttributeId, metadata) {
308
- const dracoAttributeMetadata = new this.draco.Metadata();
322
+ if (dracoType === this.draco.POSITION) {
323
+ return attribute;
324
+ }
325
+ }
309
326
 
310
- this._populateDracoMetadata(dracoAttributeMetadata, metadata);
327
+ return null;
328
+ }
329
+ }, {
330
+ key: "_addGeometryMetadata",
331
+ value: function _addGeometryMetadata(dracoGeometry, metadata) {
332
+ var dracoMetadata = new this.draco.Metadata();
311
333
 
312
- this.dracoMeshBuilder.SetMetadataForAttribute(dracoGeometry, uniqueAttributeId, dracoAttributeMetadata);
313
- }
334
+ this._populateDracoMetadata(dracoMetadata, metadata);
314
335
 
315
- _populateDracoMetadata(dracoMetadata, metadata) {
316
- for (const [key, value] of getEntries(metadata)) {
317
- switch (typeof value) {
318
- case 'number':
319
- if (Math.trunc(value) === value) {
320
- this.dracoMetadataBuilder.AddIntEntry(dracoMetadata, key, value);
321
- } else {
322
- this.dracoMetadataBuilder.AddDoubleEntry(dracoMetadata, key, value);
323
- }
336
+ this.dracoMeshBuilder.AddMetadata(dracoGeometry, dracoMetadata);
337
+ }
338
+ }, {
339
+ key: "_addAttributeMetadata",
340
+ value: function _addAttributeMetadata(dracoGeometry, uniqueAttributeId, metadata) {
341
+ var dracoAttributeMetadata = new this.draco.Metadata();
324
342
 
325
- break;
343
+ this._populateDracoMetadata(dracoAttributeMetadata, metadata);
326
344
 
327
- case 'object':
328
- if (value instanceof Int32Array) {
329
- this.dracoMetadataBuilder.AddIntEntryArray(dracoMetadata, key, value, value.length);
345
+ this.dracoMeshBuilder.SetMetadataForAttribute(dracoGeometry, uniqueAttributeId, dracoAttributeMetadata);
346
+ }
347
+ }, {
348
+ key: "_populateDracoMetadata",
349
+ value: function _populateDracoMetadata(dracoMetadata, metadata) {
350
+ var _iterator = _createForOfIteratorHelper(getEntries(metadata)),
351
+ _step;
352
+
353
+ try {
354
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
355
+ var _step$value = (0, _slicedToArray2.default)(_step.value, 2),
356
+ _key = _step$value[0],
357
+ value = _step$value[1];
358
+
359
+ switch ((0, _typeof2.default)(value)) {
360
+ case 'number':
361
+ if (Math.trunc(value) === value) {
362
+ this.dracoMetadataBuilder.AddIntEntry(dracoMetadata, _key, value);
363
+ } else {
364
+ this.dracoMetadataBuilder.AddDoubleEntry(dracoMetadata, _key, value);
365
+ }
366
+
367
+ break;
368
+
369
+ case 'object':
370
+ if (value instanceof Int32Array) {
371
+ this.dracoMetadataBuilder.AddIntEntryArray(dracoMetadata, _key, value, value.length);
372
+ }
373
+
374
+ break;
375
+
376
+ case 'string':
377
+ default:
378
+ this.dracoMetadataBuilder.AddStringEntry(dracoMetadata, _key, value);
330
379
  }
331
-
332
- break;
333
-
334
- case 'string':
335
- default:
336
- this.dracoMetadataBuilder.AddStringEntry(dracoMetadata, key, value);
380
+ }
381
+ } catch (err) {
382
+ _iterator.e(err);
383
+ } finally {
384
+ _iterator.f();
337
385
  }
338
386
  }
339
- }
340
-
341
- }
387
+ }]);
388
+ return DracoBuilder;
389
+ }();
342
390
 
343
391
  exports.default = DracoBuilder;
344
392
 
345
393
  function dracoInt8ArrayToArrayBuffer(dracoData) {
346
- const byteLength = dracoData.size();
347
- const outputBuffer = new ArrayBuffer(byteLength);
348
- const outputData = new Int8Array(outputBuffer);
394
+ var byteLength = dracoData.size();
395
+ var outputBuffer = new ArrayBuffer(byteLength);
396
+ var outputData = new Int8Array(outputBuffer);
349
397
 
350
- for (let i = 0; i < byteLength; ++i) {
398
+ for (var i = 0; i < byteLength; ++i) {
351
399
  outputData[i] = dracoData.GetValue(i);
352
400
  }
353
401
 
@@ -355,7 +403,7 @@ function dracoInt8ArrayToArrayBuffer(dracoData) {
355
403
  }
356
404
 
357
405
  function getEntries(container) {
358
- const hasEntriesFunc = container.entries && !container.hasOwnProperty('entries');
406
+ var hasEntriesFunc = container.entries && !container.hasOwnProperty('entries');
359
407
  return hasEntriesFunc ? container.entries() : Object.entries(container);
360
408
  }
361
409
  //# sourceMappingURL=draco-builder.js.map