@loaders.gl/draco 4.0.0-alpha.9 → 4.0.0-beta.1

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 (63) hide show
  1. package/dist/dist.min.js +3 -3
  2. package/dist/dist.min.js.map +2 -2
  3. package/dist/draco-loader.d.ts +0 -1
  4. package/dist/draco-loader.d.ts.map +1 -1
  5. package/dist/draco-worker-node.js +51 -51
  6. package/dist/draco-worker-node.js.map +3 -3
  7. package/dist/draco-worker.js +1 -1
  8. package/dist/draco-worker.js.map +2 -2
  9. package/dist/draco-writer-worker-node.js +46 -46
  10. package/dist/draco-writer-worker-node.js.map +3 -3
  11. package/dist/draco-writer-worker.js +3 -3
  12. package/dist/draco-writer-worker.js.map +2 -2
  13. package/dist/es5/draco-loader.js +1 -3
  14. package/dist/es5/draco-loader.js.map +1 -1
  15. package/dist/es5/index.js +13 -3
  16. package/dist/es5/index.js.map +1 -1
  17. package/dist/es5/lib/draco-module-loader.js +17 -10
  18. package/dist/es5/lib/draco-module-loader.js.map +1 -1
  19. package/dist/es5/lib/utils/version.js +1 -1
  20. package/dist/es5/lib/utils/version.js.map +1 -1
  21. package/dist/es5/libs/draco_decoder.wasm +0 -0
  22. package/dist/es5/libs/draco_encoder.js +52 -0
  23. package/dist/es5/libs/draco_wasm_wrapper.js +117 -0
  24. package/dist/esm/draco-loader.js +0 -1
  25. package/dist/esm/draco-loader.js.map +1 -1
  26. package/dist/esm/index.js +1 -1
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/esm/lib/draco-module-loader.js +16 -8
  29. package/dist/esm/lib/draco-module-loader.js.map +1 -1
  30. package/dist/esm/lib/utils/version.js +1 -1
  31. package/dist/esm/lib/utils/version.js.map +1 -1
  32. package/dist/esm/libs/draco_decoder.wasm +0 -0
  33. package/dist/esm/libs/draco_encoder.js +52 -0
  34. package/dist/esm/libs/draco_wasm_wrapper.js +117 -0
  35. package/dist/index.d.ts +1 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/lib/draco-module-loader.d.ts +13 -0
  38. package/dist/lib/draco-module-loader.d.ts.map +1 -1
  39. package/dist/libs/draco_decoder.wasm +0 -0
  40. package/dist/libs/draco_encoder.js +52 -0
  41. package/dist/libs/draco_wasm_wrapper.js +117 -0
  42. package/package.json +8 -7
  43. package/src/draco-loader.ts +0 -2
  44. package/src/index.ts +3 -3
  45. package/src/lib/draco-module-loader.ts +42 -10
  46. package/src/libs/draco_decoder.wasm +0 -0
  47. package/src/libs/draco_encoder.js +52 -0
  48. package/src/libs/draco_wasm_wrapper.js +117 -0
  49. package/dist/bundle.js +0 -5
  50. package/dist/draco-loader.js +0 -29
  51. package/dist/draco-writer.js +0 -44
  52. package/dist/draco3d/draco3d-types.js +0 -51
  53. package/dist/index.js +0 -47
  54. package/dist/lib/draco-builder.js +0 -338
  55. package/dist/lib/draco-module-loader.js +0 -93
  56. package/dist/lib/draco-parser.js +0 -476
  57. package/dist/lib/draco-types.js +0 -3
  58. package/dist/lib/utils/get-draco-schema.js +0 -42
  59. package/dist/lib/utils/version.js +0 -7
  60. package/dist/workers/draco-worker-node.js +0 -7
  61. package/dist/workers/draco-worker.js +0 -5
  62. package/dist/workers/draco-writer-worker-node.js +0 -28
  63. package/dist/workers/draco-writer-worker.js +0 -26
@@ -1,476 +0,0 @@
1
- "use strict";
2
- /* eslint-disable camelcase */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const schema_1 = require("@loaders.gl/schema");
5
- const get_draco_schema_1 = require("./utils/get-draco-schema");
6
- // @ts-ignore
7
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
- const GEOMETRY_TYPE = {
9
- TRIANGULAR_MESH: 0,
10
- POINT_CLOUD: 1
11
- };
12
- // Native Draco attribute names to GLTF attribute names.
13
- const DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP = {
14
- POSITION: 'POSITION',
15
- NORMAL: 'NORMAL',
16
- COLOR: 'COLOR_0',
17
- TEX_COORD: 'TEXCOORD_0'
18
- };
19
- const DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP = {
20
- 1: Int8Array,
21
- 2: Uint8Array,
22
- 3: Int16Array,
23
- 4: Uint16Array,
24
- 5: Int32Array,
25
- 6: Uint32Array,
26
- 9: Float32Array
27
- };
28
- const INDEX_ITEM_SIZE = 4;
29
- class DracoParser {
30
- // draco - the draco decoder, either import `draco3d` or load dynamically
31
- constructor(draco) {
32
- this.draco = draco;
33
- this.decoder = new this.draco.Decoder();
34
- this.metadataQuerier = new this.draco.MetadataQuerier();
35
- }
36
- /**
37
- * Destroy draco resources
38
- */
39
- destroy() {
40
- this.draco.destroy(this.decoder);
41
- this.draco.destroy(this.metadataQuerier);
42
- }
43
- /**
44
- * NOTE: caller must call `destroyGeometry` on the return value after using it
45
- * @param arrayBuffer
46
- * @param options
47
- */
48
- parseSync(arrayBuffer, options = {}) {
49
- const buffer = new this.draco.DecoderBuffer();
50
- buffer.Init(new Int8Array(arrayBuffer), arrayBuffer.byteLength);
51
- this._disableAttributeTransforms(options);
52
- const geometry_type = this.decoder.GetEncodedGeometryType(buffer);
53
- const dracoGeometry = geometry_type === this.draco.TRIANGULAR_MESH
54
- ? new this.draco.Mesh()
55
- : new this.draco.PointCloud();
56
- try {
57
- let dracoStatus;
58
- switch (geometry_type) {
59
- case this.draco.TRIANGULAR_MESH:
60
- dracoStatus = this.decoder.DecodeBufferToMesh(buffer, dracoGeometry);
61
- break;
62
- case this.draco.POINT_CLOUD:
63
- dracoStatus = this.decoder.DecodeBufferToPointCloud(buffer, dracoGeometry);
64
- break;
65
- default:
66
- throw new Error('DRACO: Unknown geometry type.');
67
- }
68
- if (!dracoStatus.ok() || !dracoGeometry.ptr) {
69
- const message = `DRACO decompression failed: ${dracoStatus.error_msg()}`;
70
- // console.error(message);
71
- throw new Error(message);
72
- }
73
- const loaderData = this._getDracoLoaderData(dracoGeometry, geometry_type, options);
74
- const geometry = this._getMeshData(dracoGeometry, loaderData, options);
75
- const boundingBox = (0, schema_1.getMeshBoundingBox)(geometry.attributes);
76
- const schema = (0, get_draco_schema_1.getDracoSchema)(geometry.attributes, loaderData, geometry.indices);
77
- const data = {
78
- loader: 'draco',
79
- loaderData,
80
- header: {
81
- vertexCount: dracoGeometry.num_points(),
82
- boundingBox
83
- },
84
- ...geometry,
85
- schema
86
- };
87
- return data;
88
- }
89
- finally {
90
- this.draco.destroy(buffer);
91
- if (dracoGeometry) {
92
- this.draco.destroy(dracoGeometry);
93
- }
94
- }
95
- }
96
- // Draco specific "loader data"
97
- /**
98
- * Extract
99
- * @param dracoGeometry
100
- * @param geometry_type
101
- * @param options
102
- * @returns
103
- */
104
- _getDracoLoaderData(dracoGeometry, geometry_type, options) {
105
- const metadata = this._getTopLevelMetadata(dracoGeometry);
106
- const attributes = this._getDracoAttributes(dracoGeometry, options);
107
- return {
108
- geometry_type,
109
- num_attributes: dracoGeometry.num_attributes(),
110
- num_points: dracoGeometry.num_points(),
111
- num_faces: dracoGeometry instanceof this.draco.Mesh ? dracoGeometry.num_faces() : 0,
112
- metadata,
113
- attributes
114
- };
115
- }
116
- /**
117
- * Extract all draco provided information and metadata for each attribute
118
- * @param dracoGeometry
119
- * @param options
120
- * @returns
121
- */
122
- _getDracoAttributes(dracoGeometry, options) {
123
- const dracoAttributes = {};
124
- for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
125
- // Note: Draco docs do not seem clear on `GetAttribute` ids just being a zero-based index,
126
- // but it does seems to work this way
127
- const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId);
128
- const metadata = this._getAttributeMetadata(dracoGeometry, attributeId);
129
- dracoAttributes[dracoAttribute.unique_id()] = {
130
- unique_id: dracoAttribute.unique_id(),
131
- attribute_type: dracoAttribute.attribute_type(),
132
- data_type: dracoAttribute.data_type(),
133
- num_components: dracoAttribute.num_components(),
134
- byte_offset: dracoAttribute.byte_offset(),
135
- byte_stride: dracoAttribute.byte_stride(),
136
- normalized: dracoAttribute.normalized(),
137
- attribute_index: attributeId,
138
- metadata
139
- };
140
- // Add transformation parameters for any attributes app wants untransformed
141
- const quantization = this._getQuantizationTransform(dracoAttribute, options);
142
- if (quantization) {
143
- dracoAttributes[dracoAttribute.unique_id()].quantization_transform = quantization;
144
- }
145
- const octahedron = this._getOctahedronTransform(dracoAttribute, options);
146
- if (octahedron) {
147
- dracoAttributes[dracoAttribute.unique_id()].octahedron_transform = octahedron;
148
- }
149
- }
150
- return dracoAttributes;
151
- }
152
- /**
153
- * Get standard loaders.gl mesh category data
154
- * Extracts the geometry from draco
155
- * @param dracoGeometry
156
- * @param options
157
- */
158
- _getMeshData(dracoGeometry, loaderData, options) {
159
- const attributes = this._getMeshAttributes(loaderData, dracoGeometry, options);
160
- const positionAttribute = attributes.POSITION;
161
- if (!positionAttribute) {
162
- throw new Error('DRACO: No position attribute found.');
163
- }
164
- // For meshes, we need indices to define the faces.
165
- if (dracoGeometry instanceof this.draco.Mesh) {
166
- switch (options.topology) {
167
- case 'triangle-strip':
168
- return {
169
- topology: 'triangle-strip',
170
- mode: 4,
171
- attributes,
172
- indices: {
173
- value: this._getTriangleStripIndices(dracoGeometry),
174
- size: 1
175
- }
176
- };
177
- case 'triangle-list':
178
- default:
179
- return {
180
- topology: 'triangle-list',
181
- mode: 5,
182
- attributes,
183
- indices: {
184
- value: this._getTriangleListIndices(dracoGeometry),
185
- size: 1
186
- }
187
- };
188
- }
189
- }
190
- // PointCloud - must come last as Mesh inherits from PointCloud
191
- return {
192
- topology: 'point-list',
193
- mode: 0,
194
- attributes
195
- };
196
- }
197
- _getMeshAttributes(loaderData, dracoGeometry, options) {
198
- const attributes = {};
199
- for (const loaderAttribute of Object.values(loaderData.attributes)) {
200
- const attributeName = this._deduceAttributeName(loaderAttribute, options);
201
- loaderAttribute.name = attributeName;
202
- const { value, size } = this._getAttributeValues(dracoGeometry, loaderAttribute);
203
- attributes[attributeName] = {
204
- value,
205
- size,
206
- byteOffset: loaderAttribute.byte_offset,
207
- byteStride: loaderAttribute.byte_stride,
208
- normalized: loaderAttribute.normalized
209
- };
210
- }
211
- return attributes;
212
- }
213
- // MESH INDICES EXTRACTION
214
- /**
215
- * For meshes, we need indices to define the faces.
216
- * @param dracoGeometry
217
- */
218
- _getTriangleListIndices(dracoGeometry) {
219
- // Example on how to retrieve mesh and attributes.
220
- const numFaces = dracoGeometry.num_faces();
221
- const numIndices = numFaces * 3;
222
- const byteLength = numIndices * INDEX_ITEM_SIZE;
223
- const ptr = this.draco._malloc(byteLength);
224
- try {
225
- this.decoder.GetTrianglesUInt32Array(dracoGeometry, byteLength, ptr);
226
- return new Uint32Array(this.draco.HEAPF32.buffer, ptr, numIndices).slice();
227
- }
228
- finally {
229
- this.draco._free(ptr);
230
- }
231
- }
232
- /**
233
- * For meshes, we need indices to define the faces.
234
- * @param dracoGeometry
235
- */
236
- _getTriangleStripIndices(dracoGeometry) {
237
- const dracoArray = new this.draco.DracoInt32Array();
238
- try {
239
- /* const numStrips = */ this.decoder.GetTriangleStripsFromMesh(dracoGeometry, dracoArray);
240
- return getUint32Array(dracoArray);
241
- }
242
- finally {
243
- this.draco.destroy(dracoArray);
244
- }
245
- }
246
- /**
247
- *
248
- * @param dracoGeometry
249
- * @param dracoAttribute
250
- * @param attributeName
251
- */
252
- _getAttributeValues(dracoGeometry, attribute) {
253
- const TypedArrayCtor = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type];
254
- const numComponents = attribute.num_components;
255
- const numPoints = dracoGeometry.num_points();
256
- const numValues = numPoints * numComponents;
257
- const byteLength = numValues * TypedArrayCtor.BYTES_PER_ELEMENT;
258
- const dataType = getDracoDataType(this.draco, TypedArrayCtor);
259
- let value;
260
- const ptr = this.draco._malloc(byteLength);
261
- try {
262
- const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attribute.attribute_index);
263
- this.decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, dracoAttribute, dataType, byteLength, ptr);
264
- value = new TypedArrayCtor(this.draco.HEAPF32.buffer, ptr, numValues).slice();
265
- }
266
- finally {
267
- this.draco._free(ptr);
268
- }
269
- return { value, size: numComponents };
270
- }
271
- // Attribute names
272
- /**
273
- * DRACO does not store attribute names - We need to deduce an attribute name
274
- * for each attribute
275
- _getAttributeNames(
276
- dracoGeometry: Mesh | PointCloud,
277
- options: DracoParseOptions
278
- ): {[unique_id: number]: string} {
279
- const attributeNames: {[unique_id: number]: string} = {};
280
- for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
281
- const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId);
282
- const attributeName = this._deduceAttributeName(dracoAttribute, options);
283
- attributeNames[attributeName] = attributeName;
284
- }
285
- return attributeNames;
286
- }
287
- */
288
- /**
289
- * Deduce an attribute name.
290
- * @note DRACO does not save attribute names, just general type (POSITION, COLOR)
291
- * to help optimize compression. We generate GLTF compatible names for the Draco-recognized
292
- * types
293
- * @param attributeData
294
- */
295
- _deduceAttributeName(attribute, options) {
296
- // Deduce name based on application provided map
297
- const uniqueId = attribute.unique_id;
298
- for (const [attributeName, attributeUniqueId] of Object.entries(options.extraAttributes || {})) {
299
- if (attributeUniqueId === uniqueId) {
300
- return attributeName;
301
- }
302
- }
303
- // Deduce name based on attribute type
304
- const thisAttributeType = attribute.attribute_type;
305
- for (const dracoAttributeConstant in DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP) {
306
- const attributeType = this.draco[dracoAttributeConstant];
307
- if (attributeType === thisAttributeType) {
308
- // TODO - Return unique names if there multiple attributes per type
309
- // (e.g. multiple TEX_COORDS or COLORS)
310
- return DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP[dracoAttributeConstant];
311
- }
312
- }
313
- // Look up in metadata
314
- // TODO - shouldn't this have priority?
315
- const entryName = options.attributeNameEntry || 'name';
316
- if (attribute.metadata[entryName]) {
317
- return attribute.metadata[entryName].string;
318
- }
319
- // Attribute of "GENERIC" type, we need to assign some name
320
- return `CUSTOM_ATTRIBUTE_${uniqueId}`;
321
- }
322
- // METADATA EXTRACTION
323
- /** Get top level metadata */
324
- _getTopLevelMetadata(dracoGeometry) {
325
- const dracoMetadata = this.decoder.GetMetadata(dracoGeometry);
326
- return this._getDracoMetadata(dracoMetadata);
327
- }
328
- /** Get per attribute metadata */
329
- _getAttributeMetadata(dracoGeometry, attributeId) {
330
- const dracoMetadata = this.decoder.GetAttributeMetadata(dracoGeometry, attributeId);
331
- return this._getDracoMetadata(dracoMetadata);
332
- }
333
- /**
334
- * Extract metadata field values
335
- * @param dracoMetadata
336
- * @returns
337
- */
338
- _getDracoMetadata(dracoMetadata) {
339
- // The not so wonderful world of undocumented Draco APIs :(
340
- if (!dracoMetadata || !dracoMetadata.ptr) {
341
- return {};
342
- }
343
- const result = {};
344
- const numEntries = this.metadataQuerier.NumEntries(dracoMetadata);
345
- for (let entryIndex = 0; entryIndex < numEntries; entryIndex++) {
346
- const entryName = this.metadataQuerier.GetEntryName(dracoMetadata, entryIndex);
347
- result[entryName] = this._getDracoMetadataField(dracoMetadata, entryName);
348
- }
349
- return result;
350
- }
351
- /**
352
- * Extracts possible values for one metadata entry by name
353
- * @param dracoMetadata
354
- * @param entryName
355
- */
356
- _getDracoMetadataField(dracoMetadata, entryName) {
357
- const dracoArray = new this.draco.DracoInt32Array();
358
- try {
359
- // Draco metadata fields can hold int32 arrays
360
- this.metadataQuerier.GetIntEntryArray(dracoMetadata, entryName, dracoArray);
361
- const intArray = getInt32Array(dracoArray);
362
- return {
363
- int: this.metadataQuerier.GetIntEntry(dracoMetadata, entryName),
364
- string: this.metadataQuerier.GetStringEntry(dracoMetadata, entryName),
365
- double: this.metadataQuerier.GetDoubleEntry(dracoMetadata, entryName),
366
- intArray
367
- };
368
- }
369
- finally {
370
- this.draco.destroy(dracoArray);
371
- }
372
- }
373
- // QUANTIZED ATTRIBUTE SUPPORT (NO DECOMPRESSION)
374
- /** Skip transforms for specific attribute types */
375
- _disableAttributeTransforms(options) {
376
- const { quantizedAttributes = [], octahedronAttributes = [] } = options;
377
- const skipAttributes = [...quantizedAttributes, ...octahedronAttributes];
378
- for (const dracoAttributeName of skipAttributes) {
379
- this.decoder.SkipAttributeTransform(this.draco[dracoAttributeName]);
380
- }
381
- }
382
- /**
383
- * Extract (and apply?) Position Transform
384
- * @todo not used
385
- */
386
- _getQuantizationTransform(dracoAttribute, options) {
387
- const { quantizedAttributes = [] } = options;
388
- const attribute_type = dracoAttribute.attribute_type();
389
- const skip = quantizedAttributes.map((type) => this.decoder[type]).includes(attribute_type);
390
- if (skip) {
391
- const transform = new this.draco.AttributeQuantizationTransform();
392
- try {
393
- if (transform.InitFromAttribute(dracoAttribute)) {
394
- return {
395
- quantization_bits: transform.quantization_bits(),
396
- range: transform.range(),
397
- min_values: new Float32Array([1, 2, 3]).map((i) => transform.min_value(i))
398
- };
399
- }
400
- }
401
- finally {
402
- this.draco.destroy(transform);
403
- }
404
- }
405
- return null;
406
- }
407
- _getOctahedronTransform(dracoAttribute, options) {
408
- const { octahedronAttributes = [] } = options;
409
- const attribute_type = dracoAttribute.attribute_type();
410
- const octahedron = octahedronAttributes
411
- .map((type) => this.decoder[type])
412
- .includes(attribute_type);
413
- if (octahedron) {
414
- const transform = new this.draco.AttributeQuantizationTransform();
415
- try {
416
- if (transform.InitFromAttribute(dracoAttribute)) {
417
- return {
418
- quantization_bits: transform.quantization_bits()
419
- };
420
- }
421
- }
422
- finally {
423
- this.draco.destroy(transform);
424
- }
425
- }
426
- return null;
427
- }
428
- }
429
- exports.default = DracoParser;
430
- /**
431
- * Get draco specific data type by TypedArray constructor type
432
- * @param attributeType
433
- * @returns draco specific data type
434
- */
435
- function getDracoDataType(draco, attributeType) {
436
- switch (attributeType) {
437
- case Float32Array:
438
- return draco.DT_FLOAT32;
439
- case Int8Array:
440
- return draco.DT_INT8;
441
- case Int16Array:
442
- return draco.DT_INT16;
443
- case Int32Array:
444
- return draco.DT_INT32;
445
- case Uint8Array:
446
- return draco.DT_UINT8;
447
- case Uint16Array:
448
- return draco.DT_UINT16;
449
- case Uint32Array:
450
- return draco.DT_UINT32;
451
- default:
452
- return draco.DT_INVALID;
453
- }
454
- }
455
- /**
456
- * Copy a Draco int32 array into a JS typed array
457
- */
458
- function getInt32Array(dracoArray) {
459
- const numValues = dracoArray.size();
460
- const intArray = new Int32Array(numValues);
461
- for (let i = 0; i < numValues; i++) {
462
- intArray[i] = dracoArray.GetValue(i);
463
- }
464
- return intArray;
465
- }
466
- /**
467
- * Copy a Draco int32 array into a JS typed array
468
- */
469
- function getUint32Array(dracoArray) {
470
- const numValues = dracoArray.size();
471
- const intArray = new Int32Array(numValues);
472
- for (let i = 0; i < numValues; i++) {
473
- intArray[i] = dracoArray.GetValue(i);
474
- }
475
- return intArray;
476
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- /* eslint-disable camelcase */
3
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDracoSchema = void 0;
4
- const schema_1 = require("@loaders.gl/schema");
5
- /** Extract an arrow-like schema from a Draco mesh */
6
- function getDracoSchema(attributes, loaderData, indices) {
7
- const metadata = makeMetadata(loaderData.metadata);
8
- const fields = [];
9
- const namedLoaderDataAttributes = transformAttributesLoaderData(loaderData.attributes);
10
- for (const attributeName in attributes) {
11
- const attribute = attributes[attributeName];
12
- const field = getArrowFieldFromAttribute(attributeName, attribute, namedLoaderDataAttributes[attributeName]);
13
- fields.push(field);
14
- }
15
- if (indices) {
16
- const indicesField = getArrowFieldFromAttribute('indices', indices);
17
- fields.push(indicesField);
18
- }
19
- return { fields, metadata };
20
- }
21
- exports.getDracoSchema = getDracoSchema;
22
- function transformAttributesLoaderData(loaderData) {
23
- const result = {};
24
- for (const key in loaderData) {
25
- const dracoAttribute = loaderData[key];
26
- result[dracoAttribute.name || 'undefined'] = dracoAttribute;
27
- }
28
- return result;
29
- }
30
- function getArrowFieldFromAttribute(attributeName, attribute, loaderData) {
31
- const metadataMap = loaderData ? makeMetadata(loaderData.metadata) : undefined;
32
- const field = (0, schema_1.deduceMeshField)(attributeName, attribute, metadataMap);
33
- return field;
34
- }
35
- function makeMetadata(metadata) {
36
- Object.entries(metadata);
37
- const serializedMetadata = {};
38
- for (const key in metadata) {
39
- serializedMetadata[`${key}.string`] = JSON.stringify(metadata[key]);
40
- }
41
- return serializedMetadata;
42
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VERSION = void 0;
4
- // Version constant cannot be imported, it needs to correspond to the build version of **this** module.
5
- // __VERSION__ is injected by babel-plugin-version-inline
6
- // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- exports.VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // Polyfills increases the bundle size significantly. Use it for NodeJS worker only
4
- require("@loaders.gl/polyfills");
5
- const loader_utils_1 = require("@loaders.gl/loader-utils");
6
- const index_1 = require("../index");
7
- (0, loader_utils_1.createLoaderWorker)(index_1.DracoLoader);
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const loader_utils_1 = require("@loaders.gl/loader-utils");
4
- const index_1 = require("../index");
5
- (0, loader_utils_1.createLoaderWorker)(index_1.DracoLoader);
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- // Polyfills increases the bundle size significantly. Use it for NodeJS worker only
4
- require("@loaders.gl/polyfills");
5
- const worker_utils_1 = require("@loaders.gl/worker-utils");
6
- const draco_writer_1 = require("../draco-writer");
7
- (() => {
8
- // Check that we are actually in a worker thread
9
- if (!worker_utils_1.WorkerBody.inWorkerThread()) {
10
- return;
11
- }
12
- worker_utils_1.WorkerBody.onmessage = async (type, payload) => {
13
- switch (type) {
14
- case 'process':
15
- try {
16
- const { input, options } = payload;
17
- const result = await draco_writer_1.DracoWriter.encode(input, options);
18
- worker_utils_1.WorkerBody.postMessage('done', { result });
19
- }
20
- catch (error) {
21
- const message = error instanceof Error ? error.message : '';
22
- worker_utils_1.WorkerBody.postMessage('error', { error: message });
23
- }
24
- break;
25
- default:
26
- }
27
- };
28
- })();
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const worker_utils_1 = require("@loaders.gl/worker-utils");
4
- const draco_writer_1 = require("../draco-writer");
5
- (() => {
6
- // Check that we are actually in a worker thread
7
- if (!worker_utils_1.WorkerBody.inWorkerThread()) {
8
- return;
9
- }
10
- worker_utils_1.WorkerBody.onmessage = async (type, payload) => {
11
- switch (type) {
12
- case 'process':
13
- try {
14
- const { input, options } = payload;
15
- const result = await draco_writer_1.DracoWriter.encode(input, options);
16
- worker_utils_1.WorkerBody.postMessage('done', { result });
17
- }
18
- catch (error) {
19
- const message = error instanceof Error ? error.message : '';
20
- worker_utils_1.WorkerBody.postMessage('error', { error: message });
21
- }
22
- break;
23
- default:
24
- }
25
- };
26
- })();