@itwin/rpcinterface-full-stack-tests 5.2.0-dev.7 → 5.3.0-dev.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.
@@ -0,0 +1,1760 @@
1
+ "use strict";
2
+ (self["webpackChunk_itwin_rpcinterface_full_stack_tests"] = self["webpackChunk_itwin_rpcinterface_full_stack_tests"] || []).push([["vendors-common_temp_node_modules_pnpm_loaders_gl_draco_4_3_4__loaders_gl_core_4_3_4_node_modu-4c1fc9"],{
3
+
4
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/draco-loader.js":
5
+ /*!***********************************************************************************************************************************************!*\
6
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/draco-loader.js ***!
7
+ \***********************************************************************************************************************************************/
8
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
9
+
10
+ __webpack_require__.r(__webpack_exports__);
11
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12
+ /* harmony export */ DracoLoader: () => (/* binding */ DracoLoader)
13
+ /* harmony export */ });
14
+ /* harmony import */ var _lib_utils_version_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/utils/version.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/utils/version.js");
15
+ // loaders.gl
16
+ // SPDX-License-Identifier: MIT
17
+ // Copyright (c) vis.gl contributors
18
+
19
+ /**
20
+ * Worker loader for Draco3D compressed geometries
21
+ */
22
+ const DracoLoader = {
23
+ dataType: null,
24
+ batchType: null,
25
+ name: 'Draco',
26
+ id: 'draco',
27
+ module: 'draco',
28
+ // shapes: ['mesh'],
29
+ version: _lib_utils_version_js__WEBPACK_IMPORTED_MODULE_0__.VERSION,
30
+ worker: true,
31
+ extensions: ['drc'],
32
+ mimeTypes: ['application/octet-stream'],
33
+ binary: true,
34
+ tests: ['DRACO'],
35
+ options: {
36
+ draco: {
37
+ decoderType: typeof WebAssembly === 'object' ? 'wasm' : 'js', // 'js' for IE11
38
+ libraryPath: 'libs/',
39
+ extraAttributes: {},
40
+ attributeNameEntry: undefined
41
+ }
42
+ }
43
+ };
44
+
45
+
46
+ /***/ }),
47
+
48
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/draco-writer.js":
49
+ /*!***********************************************************************************************************************************************!*\
50
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/draco-writer.js ***!
51
+ \***********************************************************************************************************************************************/
52
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
53
+
54
+ __webpack_require__.r(__webpack_exports__);
55
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
56
+ /* harmony export */ DracoWriter: () => (/* binding */ DracoWriter)
57
+ /* harmony export */ });
58
+ /* harmony import */ var _lib_draco_builder_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/draco-builder.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/draco-builder.js");
59
+ /* harmony import */ var _lib_draco_module_loader_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lib/draco-module-loader.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/draco-module-loader.js");
60
+ /* harmony import */ var _lib_utils_version_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/utils/version.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/utils/version.js");
61
+
62
+
63
+
64
+ const DEFAULT_DRACO_WRITER_OPTIONS = {
65
+ pointcloud: false, // Set to true if pointcloud (mode: 0, no indices)
66
+ attributeNameEntry: 'name'
67
+ // Draco Compression Parameters
68
+ // method: 'MESH_EDGEBREAKER_ENCODING', // Use draco defaults
69
+ // speed: [5, 5], // Use draco defaults
70
+ // quantization: { // Use draco defaults
71
+ // POSITION: 10
72
+ // }
73
+ };
74
+ /**
75
+ * Exporter for Draco3D compressed geometries
76
+ */
77
+ const DracoWriter = {
78
+ name: 'DRACO',
79
+ id: 'draco',
80
+ module: 'draco',
81
+ version: _lib_utils_version_js__WEBPACK_IMPORTED_MODULE_0__.VERSION,
82
+ extensions: ['drc'],
83
+ options: {
84
+ draco: DEFAULT_DRACO_WRITER_OPTIONS
85
+ },
86
+ encode
87
+ };
88
+ async function encode(data, options = {}) {
89
+ // Dynamically load draco
90
+ const { draco } = await (0,_lib_draco_module_loader_js__WEBPACK_IMPORTED_MODULE_1__.loadDracoEncoderModule)(options);
91
+ const dracoBuilder = new _lib_draco_builder_js__WEBPACK_IMPORTED_MODULE_2__["default"](draco);
92
+ try {
93
+ return dracoBuilder.encodeSync(data, options.draco);
94
+ }
95
+ finally {
96
+ dracoBuilder.destroy();
97
+ }
98
+ }
99
+
100
+
101
+ /***/ }),
102
+
103
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/index.js":
104
+ /*!****************************************************************************************************************************************!*\
105
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/index.js ***!
106
+ \****************************************************************************************************************************************/
107
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
108
+
109
+ __webpack_require__.r(__webpack_exports__);
110
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
111
+ /* harmony export */ DRACO_EXTERNAL_LIBRARIES: () => (/* reexport safe */ _lib_draco_module_loader_js__WEBPACK_IMPORTED_MODULE_0__.DRACO_EXTERNAL_LIBRARIES),
112
+ /* harmony export */ DRACO_EXTERNAL_LIBRARY_URLS: () => (/* reexport safe */ _lib_draco_module_loader_js__WEBPACK_IMPORTED_MODULE_0__.DRACO_EXTERNAL_LIBRARY_URLS),
113
+ /* harmony export */ DracoLoader: () => (/* binding */ DracoLoader),
114
+ /* harmony export */ DracoWorkerLoader: () => (/* reexport safe */ _draco_loader_js__WEBPACK_IMPORTED_MODULE_3__.DracoLoader),
115
+ /* harmony export */ DracoWriter: () => (/* reexport safe */ _draco_writer_js__WEBPACK_IMPORTED_MODULE_1__.DracoWriter),
116
+ /* harmony export */ DracoWriterWorker: () => (/* binding */ DracoWriterWorker)
117
+ /* harmony export */ });
118
+ /* harmony import */ var _draco_loader_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./draco-loader.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/draco-loader.js");
119
+ /* harmony import */ var _lib_draco_parser_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./lib/draco-parser.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/draco-parser.js");
120
+ /* harmony import */ var _lib_draco_module_loader_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lib/draco-module-loader.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/draco-module-loader.js");
121
+ /* harmony import */ var _lib_utils_version_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lib/utils/version.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/utils/version.js");
122
+ /* harmony import */ var _draco_writer_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./draco-writer.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/draco-writer.js");
123
+
124
+
125
+
126
+
127
+ // Module constants
128
+
129
+
130
+ /**
131
+ * Browser worker doesn't work because of issue during "draco_encoder.js" loading.
132
+ * Refused to execute script from 'https://raw.githubusercontent.com/google/draco/1.4.1/javascript/draco_encoder.js' because its MIME type ('') is not executable.
133
+ */
134
+ const DracoWriterWorker = {
135
+ id: 'draco-writer',
136
+ name: 'Draco compressed geometry writer',
137
+ module: 'draco',
138
+ version: _lib_utils_version_js__WEBPACK_IMPORTED_MODULE_2__.VERSION,
139
+ worker: true,
140
+ options: {
141
+ draco: {},
142
+ source: null
143
+ }
144
+ };
145
+
146
+ /**
147
+ * Loader for Draco3D compressed geometries
148
+ */
149
+ const DracoLoader = {
150
+ ..._draco_loader_js__WEBPACK_IMPORTED_MODULE_3__.DracoLoader,
151
+ parse
152
+ };
153
+ async function parse(arrayBuffer, options) {
154
+ const { draco } = await (0,_lib_draco_module_loader_js__WEBPACK_IMPORTED_MODULE_0__.loadDracoDecoderModule)(options);
155
+ const dracoParser = new _lib_draco_parser_js__WEBPACK_IMPORTED_MODULE_4__["default"](draco);
156
+ try {
157
+ return dracoParser.parseSync(arrayBuffer, options?.draco);
158
+ }
159
+ finally {
160
+ dracoParser.destroy();
161
+ }
162
+ }
163
+
164
+
165
+ /***/ }),
166
+
167
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/draco-builder.js":
168
+ /*!****************************************************************************************************************************************************!*\
169
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/draco-builder.js ***!
170
+ \****************************************************************************************************************************************************/
171
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
172
+
173
+ __webpack_require__.r(__webpack_exports__);
174
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
175
+ /* harmony export */ "default": () => (/* binding */ DracoBuilder)
176
+ /* harmony export */ });
177
+ // Native Draco attribute names to GLTF attribute names.
178
+ const GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP = {
179
+ POSITION: 'POSITION',
180
+ NORMAL: 'NORMAL',
181
+ COLOR_0: 'COLOR',
182
+ TEXCOORD_0: 'TEX_COORD'
183
+ };
184
+ const noop = () => { };
185
+ class DracoBuilder {
186
+ draco;
187
+ dracoEncoder;
188
+ dracoMeshBuilder;
189
+ dracoMetadataBuilder;
190
+ log;
191
+ // draco - the draco decoder, either import `draco3d` or load dynamically
192
+ constructor(draco) {
193
+ this.draco = draco;
194
+ this.dracoEncoder = new this.draco.Encoder();
195
+ this.dracoMeshBuilder = new this.draco.MeshBuilder();
196
+ this.dracoMetadataBuilder = new this.draco.MetadataBuilder();
197
+ }
198
+ destroy() {
199
+ this.destroyEncodedObject(this.dracoMeshBuilder);
200
+ this.destroyEncodedObject(this.dracoEncoder);
201
+ this.destroyEncodedObject(this.dracoMetadataBuilder);
202
+ // @ts-ignore
203
+ this.dracoMeshBuilder = null;
204
+ // @ts-ignore
205
+ this.dracoEncoder = null;
206
+ // @ts-ignore
207
+ this.draco = null;
208
+ }
209
+ // TBD - when does this need to be called?
210
+ destroyEncodedObject(object) {
211
+ if (object) {
212
+ this.draco.destroy(object);
213
+ }
214
+ }
215
+ /**
216
+ * Encode mesh or point cloud
217
+ * @param mesh =({})
218
+ * @param options
219
+ */
220
+ encodeSync(mesh, options = {}) {
221
+ this.log = noop; // TODO
222
+ this._setOptions(options);
223
+ return options.pointcloud
224
+ ? this._encodePointCloud(mesh, options)
225
+ : this._encodeMesh(mesh, options);
226
+ }
227
+ // PRIVATE
228
+ _getAttributesFromMesh(mesh) {
229
+ // TODO - Change the encodePointCloud interface instead?
230
+ const attributes = { ...mesh, ...mesh.attributes };
231
+ // Fold indices into the attributes
232
+ if (mesh.indices) {
233
+ attributes.indices = mesh.indices;
234
+ }
235
+ return attributes;
236
+ }
237
+ _encodePointCloud(pointcloud, options) {
238
+ const dracoPointCloud = new this.draco.PointCloud();
239
+ if (options.metadata) {
240
+ this._addGeometryMetadata(dracoPointCloud, options.metadata);
241
+ }
242
+ const attributes = this._getAttributesFromMesh(pointcloud);
243
+ // Build a `DracoPointCloud` from the input data
244
+ this._createDracoPointCloud(dracoPointCloud, attributes, options);
245
+ const dracoData = new this.draco.DracoInt8Array();
246
+ try {
247
+ const encodedLen = this.dracoEncoder.EncodePointCloudToDracoBuffer(dracoPointCloud, false, dracoData);
248
+ if (!(encodedLen > 0)) {
249
+ throw new Error('Draco encoding failed.');
250
+ }
251
+ this.log(`DRACO encoded ${dracoPointCloud.num_points()} points
252
+ with ${dracoPointCloud.num_attributes()} attributes into ${encodedLen} bytes`);
253
+ return dracoInt8ArrayToArrayBuffer(dracoData);
254
+ }
255
+ finally {
256
+ this.destroyEncodedObject(dracoData);
257
+ this.destroyEncodedObject(dracoPointCloud);
258
+ }
259
+ }
260
+ _encodeMesh(mesh, options) {
261
+ const dracoMesh = new this.draco.Mesh();
262
+ if (options.metadata) {
263
+ this._addGeometryMetadata(dracoMesh, options.metadata);
264
+ }
265
+ const attributes = this._getAttributesFromMesh(mesh);
266
+ // Build a `DracoMesh` from the input data
267
+ this._createDracoMesh(dracoMesh, attributes, options);
268
+ const dracoData = new this.draco.DracoInt8Array();
269
+ try {
270
+ const encodedLen = this.dracoEncoder.EncodeMeshToDracoBuffer(dracoMesh, dracoData);
271
+ if (encodedLen <= 0) {
272
+ throw new Error('Draco encoding failed.');
273
+ }
274
+ this.log(`DRACO encoded ${dracoMesh.num_points()} points
275
+ with ${dracoMesh.num_attributes()} attributes into ${encodedLen} bytes`);
276
+ return dracoInt8ArrayToArrayBuffer(dracoData);
277
+ }
278
+ finally {
279
+ this.destroyEncodedObject(dracoData);
280
+ this.destroyEncodedObject(dracoMesh);
281
+ }
282
+ }
283
+ /**
284
+ * Set encoding options.
285
+ * @param {{speed?: any; method?: any; quantization?: any;}} options
286
+ */
287
+ _setOptions(options) {
288
+ if ('speed' in options) {
289
+ // @ts-ignore
290
+ this.dracoEncoder.SetSpeedOptions(...options.speed);
291
+ }
292
+ if ('method' in options) {
293
+ const dracoMethod = this.draco[options.method || 'MESH_SEQUENTIAL_ENCODING'];
294
+ // assert(dracoMethod)
295
+ this.dracoEncoder.SetEncodingMethod(dracoMethod);
296
+ }
297
+ if ('quantization' in options) {
298
+ for (const attribute in options.quantization) {
299
+ const bits = options.quantization[attribute];
300
+ const dracoPosition = this.draco[attribute];
301
+ this.dracoEncoder.SetAttributeQuantization(dracoPosition, bits);
302
+ }
303
+ }
304
+ }
305
+ /**
306
+ * @param {Mesh} dracoMesh
307
+ * @param {object} attributes
308
+ * @returns {Mesh}
309
+ */
310
+ _createDracoMesh(dracoMesh, attributes, options) {
311
+ const optionalMetadata = options.attributesMetadata || {};
312
+ try {
313
+ const positions = this._getPositionAttribute(attributes);
314
+ if (!positions) {
315
+ throw new Error('positions');
316
+ }
317
+ const vertexCount = positions.length / 3;
318
+ for (let attributeName in attributes) {
319
+ const attribute = attributes[attributeName];
320
+ attributeName = GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP[attributeName] || attributeName;
321
+ const uniqueId = this._addAttributeToMesh(dracoMesh, attributeName, attribute, vertexCount);
322
+ if (uniqueId !== -1) {
323
+ this._addAttributeMetadata(dracoMesh, uniqueId, {
324
+ name: attributeName,
325
+ ...(optionalMetadata[attributeName] || {})
326
+ });
327
+ }
328
+ }
329
+ }
330
+ catch (error) {
331
+ this.destroyEncodedObject(dracoMesh);
332
+ throw error;
333
+ }
334
+ return dracoMesh;
335
+ }
336
+ /**
337
+ * @param {} dracoPointCloud
338
+ * @param {object} attributes
339
+ */
340
+ _createDracoPointCloud(dracoPointCloud, attributes, options) {
341
+ const optionalMetadata = options.attributesMetadata || {};
342
+ try {
343
+ const positions = this._getPositionAttribute(attributes);
344
+ if (!positions) {
345
+ throw new Error('positions');
346
+ }
347
+ const vertexCount = positions.length / 3;
348
+ for (let attributeName in attributes) {
349
+ const attribute = attributes[attributeName];
350
+ attributeName = GLTF_TO_DRACO_ATTRIBUTE_NAME_MAP[attributeName] || attributeName;
351
+ const uniqueId = this._addAttributeToMesh(dracoPointCloud, attributeName, attribute, vertexCount);
352
+ if (uniqueId !== -1) {
353
+ this._addAttributeMetadata(dracoPointCloud, uniqueId, {
354
+ name: attributeName,
355
+ ...(optionalMetadata[attributeName] || {})
356
+ });
357
+ }
358
+ }
359
+ }
360
+ catch (error) {
361
+ this.destroyEncodedObject(dracoPointCloud);
362
+ throw error;
363
+ }
364
+ return dracoPointCloud;
365
+ }
366
+ /**
367
+ * @param mesh
368
+ * @param attributeName
369
+ * @param attribute
370
+ * @param vertexCount
371
+ */
372
+ _addAttributeToMesh(mesh, attributeName, attribute, vertexCount) {
373
+ if (!ArrayBuffer.isView(attribute)) {
374
+ return -1;
375
+ }
376
+ const type = this._getDracoAttributeType(attributeName);
377
+ // @ts-ignore TODO/fix types
378
+ const size = attribute.length / vertexCount;
379
+ if (type === 'indices') {
380
+ // @ts-ignore TODO/fix types
381
+ const numFaces = attribute.length / 3;
382
+ this.log(`Adding attribute ${attributeName}, size ${numFaces}`);
383
+ // @ts-ignore assumes mesh is a Mesh, not a point cloud
384
+ this.dracoMeshBuilder.AddFacesToMesh(mesh, numFaces, attribute);
385
+ return -1;
386
+ }
387
+ this.log(`Adding attribute ${attributeName}, size ${size}`);
388
+ const builder = this.dracoMeshBuilder;
389
+ const { buffer } = attribute;
390
+ switch (attribute.constructor) {
391
+ case Int8Array:
392
+ return builder.AddInt8Attribute(mesh, type, vertexCount, size, new Int8Array(buffer));
393
+ case Int16Array:
394
+ return builder.AddInt16Attribute(mesh, type, vertexCount, size, new Int16Array(buffer));
395
+ case Int32Array:
396
+ return builder.AddInt32Attribute(mesh, type, vertexCount, size, new Int32Array(buffer));
397
+ case Uint8Array:
398
+ case Uint8ClampedArray:
399
+ return builder.AddUInt8Attribute(mesh, type, vertexCount, size, new Uint8Array(buffer));
400
+ case Uint16Array:
401
+ return builder.AddUInt16Attribute(mesh, type, vertexCount, size, new Uint16Array(buffer));
402
+ case Uint32Array:
403
+ return builder.AddUInt32Attribute(mesh, type, vertexCount, size, new Uint32Array(buffer));
404
+ case Float32Array:
405
+ return builder.AddFloatAttribute(mesh, type, vertexCount, size, new Float32Array(buffer));
406
+ default:
407
+ // eslint-disable-next-line no-console
408
+ console.warn('Unsupported attribute type', attribute);
409
+ return -1;
410
+ }
411
+ // case Float64Array:
412
+ // Add attribute does not seem to be exposed
413
+ // return builder.AddAttribute(mesh, type, vertexCount, size, new Float32Array(buffer));
414
+ }
415
+ /**
416
+ * DRACO can compress attributes of know type better
417
+ * TODO - expose an attribute type map?
418
+ * @param attributeName
419
+ */
420
+ _getDracoAttributeType(attributeName) {
421
+ switch (attributeName.toLowerCase()) {
422
+ case 'indices':
423
+ return 'indices';
424
+ case 'position':
425
+ case 'positions':
426
+ case 'vertices':
427
+ return this.draco.POSITION;
428
+ case 'normal':
429
+ case 'normals':
430
+ return this.draco.NORMAL;
431
+ case 'color':
432
+ case 'colors':
433
+ return this.draco.COLOR;
434
+ case 'texcoord':
435
+ case 'texcoords':
436
+ return this.draco.TEX_COORD;
437
+ default:
438
+ return this.draco.GENERIC;
439
+ }
440
+ }
441
+ _getPositionAttribute(attributes) {
442
+ for (const attributeName in attributes) {
443
+ const attribute = attributes[attributeName];
444
+ const dracoType = this._getDracoAttributeType(attributeName);
445
+ if (dracoType === this.draco.POSITION) {
446
+ return attribute;
447
+ }
448
+ }
449
+ return null;
450
+ }
451
+ /**
452
+ * Add metadata for the geometry.
453
+ * @param dracoGeometry - WASM Draco Object
454
+ * @param metadata
455
+ */
456
+ _addGeometryMetadata(dracoGeometry, metadata) {
457
+ const dracoMetadata = new this.draco.Metadata();
458
+ this._populateDracoMetadata(dracoMetadata, metadata);
459
+ this.dracoMeshBuilder.AddMetadata(dracoGeometry, dracoMetadata);
460
+ }
461
+ /**
462
+ * Add metadata for an attribute to geometry.
463
+ * @param dracoGeometry - WASM Draco Object
464
+ * @param uniqueAttributeId
465
+ * @param metadata
466
+ */
467
+ _addAttributeMetadata(dracoGeometry, uniqueAttributeId, metadata) {
468
+ // Note: Draco JS IDL doesn't seem to expose draco.AttributeMetadata, however it seems to
469
+ // create such objects automatically from draco.Metadata object.
470
+ const dracoAttributeMetadata = new this.draco.Metadata();
471
+ this._populateDracoMetadata(dracoAttributeMetadata, metadata);
472
+ // Draco3d doc note: Directly add attribute metadata to geometry.
473
+ // You can do this without explicitly adding |GeometryMetadata| to mesh.
474
+ this.dracoMeshBuilder.SetMetadataForAttribute(dracoGeometry, uniqueAttributeId, dracoAttributeMetadata);
475
+ }
476
+ /**
477
+ * Add contents of object or map to a WASM Draco Metadata Object
478
+ * @param dracoMetadata - WASM Draco Object
479
+ * @param metadata
480
+ */
481
+ _populateDracoMetadata(dracoMetadata, metadata) {
482
+ for (const [key, value] of getEntries(metadata)) {
483
+ switch (typeof value) {
484
+ case 'number':
485
+ if (Math.trunc(value) === value) {
486
+ this.dracoMetadataBuilder.AddIntEntry(dracoMetadata, key, value);
487
+ }
488
+ else {
489
+ this.dracoMetadataBuilder.AddDoubleEntry(dracoMetadata, key, value);
490
+ }
491
+ break;
492
+ case 'object':
493
+ if (value instanceof Int32Array) {
494
+ this.dracoMetadataBuilder.AddIntEntryArray(dracoMetadata, key, value, value.length);
495
+ }
496
+ break;
497
+ case 'string':
498
+ default:
499
+ this.dracoMetadataBuilder.AddStringEntry(dracoMetadata, key, value);
500
+ }
501
+ }
502
+ }
503
+ }
504
+ // HELPER FUNCTIONS
505
+ /**
506
+ * Copy encoded data to buffer
507
+ * @param dracoData
508
+ */
509
+ function dracoInt8ArrayToArrayBuffer(dracoData) {
510
+ const byteLength = dracoData.size();
511
+ const outputBuffer = new ArrayBuffer(byteLength);
512
+ const outputData = new Int8Array(outputBuffer);
513
+ for (let i = 0; i < byteLength; ++i) {
514
+ outputData[i] = dracoData.GetValue(i);
515
+ }
516
+ return outputBuffer;
517
+ }
518
+ /** Enable iteration over either an object or a map */
519
+ function getEntries(container) {
520
+ const hasEntriesFunc = container.entries && !container.hasOwnProperty('entries');
521
+ return hasEntriesFunc ? container.entries() : Object.entries(container);
522
+ }
523
+
524
+
525
+ /***/ }),
526
+
527
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/draco-module-loader.js":
528
+ /*!**********************************************************************************************************************************************************!*\
529
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/draco-module-loader.js ***!
530
+ \**********************************************************************************************************************************************************/
531
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
532
+
533
+ __webpack_require__.r(__webpack_exports__);
534
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
535
+ /* harmony export */ DRACO_EXTERNAL_LIBRARIES: () => (/* binding */ DRACO_EXTERNAL_LIBRARIES),
536
+ /* harmony export */ DRACO_EXTERNAL_LIBRARY_URLS: () => (/* binding */ DRACO_EXTERNAL_LIBRARY_URLS),
537
+ /* harmony export */ loadDracoDecoderModule: () => (/* binding */ loadDracoDecoderModule),
538
+ /* harmony export */ loadDracoEncoderModule: () => (/* binding */ loadDracoEncoderModule)
539
+ /* harmony export */ });
540
+ /* harmony import */ var _loaders_gl_worker_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @loaders.gl/worker-utils */ "../../common/temp/node_modules/.pnpm/@loaders.gl+worker-utils@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/worker-utils/dist/lib/library-utils/library-utils.js");
541
+ // Dynamic DRACO module loading inspired by THREE.DRACOLoader
542
+ // https://github.com/mrdoob/three.js/blob/398c4f39ebdb8b23eefd4a7a5ec49ec0c96c7462/examples/jsm/loaders/DRACOLoader.js
543
+ // by Don McCurdy / https://www.donmccurdy.com / MIT license
544
+
545
+ const DRACO_DECODER_VERSION = '1.5.6';
546
+ const DRACO_ENCODER_VERSION = '1.4.1';
547
+ const STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;
548
+ const DRACO_EXTERNAL_LIBRARIES = {
549
+ /** The primary Draco3D encoder, javascript wrapper part */
550
+ DECODER: 'draco_wasm_wrapper.js',
551
+ /** The primary draco decoder, compiled web assembly part */
552
+ DECODER_WASM: 'draco_decoder.wasm',
553
+ /** Fallback decoder for non-webassebly environments. Very big bundle, lower performance */
554
+ FALLBACK_DECODER: 'draco_decoder.js',
555
+ /** Draco encoder */
556
+ ENCODER: 'draco_encoder.js'
557
+ };
558
+ const DRACO_EXTERNAL_LIBRARY_URLS = {
559
+ [DRACO_EXTERNAL_LIBRARIES.DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER}`,
560
+ [DRACO_EXTERNAL_LIBRARIES.DECODER_WASM]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER_WASM}`,
561
+ [DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER}`,
562
+ [DRACO_EXTERNAL_LIBRARIES.ENCODER]: `https://raw.githubusercontent.com/google/draco/${DRACO_ENCODER_VERSION}/javascript/${DRACO_EXTERNAL_LIBRARIES.ENCODER}`
563
+ };
564
+ let loadDecoderPromise;
565
+ let loadEncoderPromise;
566
+ async function loadDracoDecoderModule(options) {
567
+ const modules = options.modules || {};
568
+ // Check if a bundled draco3d library has been supplied by application
569
+ if (modules.draco3d) {
570
+ loadDecoderPromise ||= modules.draco3d.createDecoderModule({}).then((draco) => {
571
+ return { draco };
572
+ });
573
+ }
574
+ else {
575
+ // If not, dynamically load the WASM script from our CDN
576
+ loadDecoderPromise ||= loadDracoDecoder(options);
577
+ }
578
+ return await loadDecoderPromise;
579
+ }
580
+ async function loadDracoEncoderModule(options) {
581
+ const modules = options.modules || {};
582
+ // Check if a bundled draco3d library has been supplied by application
583
+ if (modules.draco3d) {
584
+ loadEncoderPromise ||= modules.draco3d.createEncoderModule({}).then((draco) => {
585
+ return { draco };
586
+ });
587
+ }
588
+ else {
589
+ // If not, dynamically load the WASM script from our CDN
590
+ loadEncoderPromise ||= loadDracoEncoder(options);
591
+ }
592
+ return await loadEncoderPromise;
593
+ }
594
+ // DRACO DECODER LOADING
595
+ async function loadDracoDecoder(options) {
596
+ let DracoDecoderModule;
597
+ let wasmBinary;
598
+ switch (options.draco && options.draco.decoderType) {
599
+ case 'js':
600
+ DracoDecoderModule = await (0,_loaders_gl_worker_utils__WEBPACK_IMPORTED_MODULE_0__.loadLibrary)(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER], 'draco', options, DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER);
601
+ break;
602
+ case 'wasm':
603
+ default:
604
+ [DracoDecoderModule, wasmBinary] = await Promise.all([
605
+ await (0,_loaders_gl_worker_utils__WEBPACK_IMPORTED_MODULE_0__.loadLibrary)(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER], 'draco', options, DRACO_EXTERNAL_LIBRARIES.DECODER),
606
+ await (0,_loaders_gl_worker_utils__WEBPACK_IMPORTED_MODULE_0__.loadLibrary)(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM], 'draco', options, DRACO_EXTERNAL_LIBRARIES.DECODER_WASM)
607
+ ]);
608
+ }
609
+ // Depends on how import happened...
610
+ // @ts-ignore
611
+ DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
612
+ return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);
613
+ }
614
+ function initializeDracoDecoder(DracoDecoderModule, wasmBinary) {
615
+ const options = {};
616
+ if (wasmBinary) {
617
+ options.wasmBinary = wasmBinary;
618
+ }
619
+ return new Promise((resolve) => {
620
+ DracoDecoderModule({
621
+ ...options,
622
+ onModuleLoaded: (draco) => resolve({ draco }) // Module is Promise-like. Wrap in object to avoid loop.
623
+ });
624
+ });
625
+ }
626
+ // ENCODER
627
+ async function loadDracoEncoder(options) {
628
+ let DracoEncoderModule = await (0,_loaders_gl_worker_utils__WEBPACK_IMPORTED_MODULE_0__.loadLibrary)(DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.ENCODER], 'draco', options, DRACO_EXTERNAL_LIBRARIES.ENCODER);
629
+ // @ts-ignore
630
+ DracoEncoderModule = DracoEncoderModule || globalThis.DracoEncoderModule;
631
+ return new Promise((resolve) => {
632
+ DracoEncoderModule({
633
+ onModuleLoaded: (draco) => resolve({ draco }) // Module is Promise-like. Wrap in object to avoid loop.
634
+ });
635
+ });
636
+ }
637
+
638
+
639
+ /***/ }),
640
+
641
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/draco-parser.js":
642
+ /*!***************************************************************************************************************************************************!*\
643
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/draco-parser.js ***!
644
+ \***************************************************************************************************************************************************/
645
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
646
+
647
+ __webpack_require__.r(__webpack_exports__);
648
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
649
+ /* harmony export */ "default": () => (/* binding */ DracoParser)
650
+ /* harmony export */ });
651
+ /* harmony import */ var _loaders_gl_schema__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @loaders.gl/schema */ "../../common/temp/node_modules/.pnpm/@loaders.gl+schema@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/schema/dist/lib/mesh/mesh-utils.js");
652
+ /* harmony import */ var _utils_get_draco_schema_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils/get-draco-schema.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/utils/get-draco-schema.js");
653
+ /* eslint-disable camelcase */
654
+
655
+
656
+ // @ts-ignore
657
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
658
+ const GEOMETRY_TYPE = {
659
+ TRIANGULAR_MESH: 0,
660
+ POINT_CLOUD: 1
661
+ };
662
+ // Native Draco attribute names to GLTF attribute names.
663
+ const DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP = {
664
+ POSITION: 'POSITION',
665
+ NORMAL: 'NORMAL',
666
+ COLOR: 'COLOR_0',
667
+ TEX_COORD: 'TEXCOORD_0'
668
+ };
669
+ const DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP = {
670
+ 1: Int8Array,
671
+ 2: Uint8Array,
672
+ 3: Int16Array,
673
+ 4: Uint16Array,
674
+ 5: Int32Array,
675
+ 6: Uint32Array,
676
+ // 7: BigInt64Array,
677
+ // 8: BigUint64Array,
678
+ 9: Float32Array
679
+ // 10: Float64Array
680
+ // 11: BOOL - What array type do we use for this?
681
+ };
682
+ const INDEX_ITEM_SIZE = 4;
683
+ class DracoParser {
684
+ draco;
685
+ decoder;
686
+ metadataQuerier;
687
+ // draco - the draco decoder, either import `draco3d` or load dynamically
688
+ constructor(draco) {
689
+ this.draco = draco;
690
+ this.decoder = new this.draco.Decoder();
691
+ this.metadataQuerier = new this.draco.MetadataQuerier();
692
+ }
693
+ /**
694
+ * Destroy draco resources
695
+ */
696
+ destroy() {
697
+ this.draco.destroy(this.decoder);
698
+ this.draco.destroy(this.metadataQuerier);
699
+ }
700
+ /**
701
+ * NOTE: caller must call `destroyGeometry` on the return value after using it
702
+ * @param arrayBuffer
703
+ * @param options
704
+ */
705
+ parseSync(arrayBuffer, options = {}) {
706
+ const buffer = new this.draco.DecoderBuffer();
707
+ buffer.Init(new Int8Array(arrayBuffer), arrayBuffer.byteLength);
708
+ this._disableAttributeTransforms(options);
709
+ const geometry_type = this.decoder.GetEncodedGeometryType(buffer);
710
+ const dracoGeometry = geometry_type === this.draco.TRIANGULAR_MESH
711
+ ? new this.draco.Mesh()
712
+ : new this.draco.PointCloud();
713
+ try {
714
+ let dracoStatus;
715
+ switch (geometry_type) {
716
+ case this.draco.TRIANGULAR_MESH:
717
+ dracoStatus = this.decoder.DecodeBufferToMesh(buffer, dracoGeometry);
718
+ break;
719
+ case this.draco.POINT_CLOUD:
720
+ dracoStatus = this.decoder.DecodeBufferToPointCloud(buffer, dracoGeometry);
721
+ break;
722
+ default:
723
+ throw new Error('DRACO: Unknown geometry type.');
724
+ }
725
+ if (!dracoStatus.ok() || !dracoGeometry.ptr) {
726
+ const message = `DRACO decompression failed: ${dracoStatus.error_msg()}`;
727
+ // console.error(message);
728
+ throw new Error(message);
729
+ }
730
+ const loaderData = this._getDracoLoaderData(dracoGeometry, geometry_type, options);
731
+ const geometry = this._getMeshData(dracoGeometry, loaderData, options);
732
+ const boundingBox = (0,_loaders_gl_schema__WEBPACK_IMPORTED_MODULE_0__.getMeshBoundingBox)(geometry.attributes);
733
+ const schema = (0,_utils_get_draco_schema_js__WEBPACK_IMPORTED_MODULE_1__.getDracoSchema)(geometry.attributes, loaderData, geometry.indices);
734
+ const data = {
735
+ loader: 'draco',
736
+ loaderData,
737
+ header: {
738
+ vertexCount: dracoGeometry.num_points(),
739
+ boundingBox
740
+ },
741
+ ...geometry,
742
+ schema
743
+ };
744
+ return data;
745
+ }
746
+ finally {
747
+ this.draco.destroy(buffer);
748
+ if (dracoGeometry) {
749
+ this.draco.destroy(dracoGeometry);
750
+ }
751
+ }
752
+ }
753
+ // Draco specific "loader data"
754
+ /**
755
+ * Extract
756
+ * @param dracoGeometry
757
+ * @param geometry_type
758
+ * @param options
759
+ * @returns
760
+ */
761
+ _getDracoLoaderData(dracoGeometry, geometry_type, options) {
762
+ const metadata = this._getTopLevelMetadata(dracoGeometry);
763
+ const attributes = this._getDracoAttributes(dracoGeometry, options);
764
+ return {
765
+ geometry_type,
766
+ num_attributes: dracoGeometry.num_attributes(),
767
+ num_points: dracoGeometry.num_points(),
768
+ num_faces: dracoGeometry instanceof this.draco.Mesh ? dracoGeometry.num_faces() : 0,
769
+ metadata,
770
+ attributes
771
+ };
772
+ }
773
+ /**
774
+ * Extract all draco provided information and metadata for each attribute
775
+ * @param dracoGeometry
776
+ * @param options
777
+ * @returns
778
+ */
779
+ _getDracoAttributes(dracoGeometry, options) {
780
+ const dracoAttributes = {};
781
+ for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
782
+ // Note: Draco docs do not seem clear on `GetAttribute` ids just being a zero-based index,
783
+ // but it does seems to work this way
784
+ const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId);
785
+ const metadata = this._getAttributeMetadata(dracoGeometry, attributeId);
786
+ dracoAttributes[dracoAttribute.unique_id()] = {
787
+ unique_id: dracoAttribute.unique_id(),
788
+ attribute_type: dracoAttribute.attribute_type(),
789
+ data_type: dracoAttribute.data_type(),
790
+ num_components: dracoAttribute.num_components(),
791
+ byte_offset: dracoAttribute.byte_offset(),
792
+ byte_stride: dracoAttribute.byte_stride(),
793
+ normalized: dracoAttribute.normalized(),
794
+ attribute_index: attributeId,
795
+ metadata
796
+ };
797
+ // Add transformation parameters for any attributes app wants untransformed
798
+ const quantization = this._getQuantizationTransform(dracoAttribute, options);
799
+ if (quantization) {
800
+ dracoAttributes[dracoAttribute.unique_id()].quantization_transform = quantization;
801
+ }
802
+ const octahedron = this._getOctahedronTransform(dracoAttribute, options);
803
+ if (octahedron) {
804
+ dracoAttributes[dracoAttribute.unique_id()].octahedron_transform = octahedron;
805
+ }
806
+ }
807
+ return dracoAttributes;
808
+ }
809
+ /**
810
+ * Get standard loaders.gl mesh category data
811
+ * Extracts the geometry from draco
812
+ * @param dracoGeometry
813
+ * @param options
814
+ */
815
+ _getMeshData(dracoGeometry, loaderData, options) {
816
+ const attributes = this._getMeshAttributes(loaderData, dracoGeometry, options);
817
+ const positionAttribute = attributes.POSITION;
818
+ if (!positionAttribute) {
819
+ throw new Error('DRACO: No position attribute found.');
820
+ }
821
+ // For meshes, we need indices to define the faces.
822
+ if (dracoGeometry instanceof this.draco.Mesh) {
823
+ switch (options.topology) {
824
+ case 'triangle-strip':
825
+ return {
826
+ topology: 'triangle-strip',
827
+ mode: 4, // GL.TRIANGLES
828
+ attributes,
829
+ indices: {
830
+ value: this._getTriangleStripIndices(dracoGeometry),
831
+ size: 1
832
+ }
833
+ };
834
+ case 'triangle-list':
835
+ default:
836
+ return {
837
+ topology: 'triangle-list',
838
+ mode: 5, // GL.TRIANGLE_STRIP
839
+ attributes,
840
+ indices: {
841
+ value: this._getTriangleListIndices(dracoGeometry),
842
+ size: 1
843
+ }
844
+ };
845
+ }
846
+ }
847
+ // PointCloud - must come last as Mesh inherits from PointCloud
848
+ return {
849
+ topology: 'point-list',
850
+ mode: 0, // GL.POINTS
851
+ attributes
852
+ };
853
+ }
854
+ _getMeshAttributes(loaderData, dracoGeometry, options) {
855
+ const attributes = {};
856
+ for (const loaderAttribute of Object.values(loaderData.attributes)) {
857
+ const attributeName = this._deduceAttributeName(loaderAttribute, options);
858
+ loaderAttribute.name = attributeName;
859
+ const values = this._getAttributeValues(dracoGeometry, loaderAttribute);
860
+ if (values) {
861
+ const { value, size } = values;
862
+ attributes[attributeName] = {
863
+ value,
864
+ size,
865
+ byteOffset: loaderAttribute.byte_offset,
866
+ byteStride: loaderAttribute.byte_stride,
867
+ normalized: loaderAttribute.normalized
868
+ };
869
+ }
870
+ }
871
+ return attributes;
872
+ }
873
+ // MESH INDICES EXTRACTION
874
+ /**
875
+ * For meshes, we need indices to define the faces.
876
+ * @param dracoGeometry
877
+ */
878
+ _getTriangleListIndices(dracoGeometry) {
879
+ // Example on how to retrieve mesh and attributes.
880
+ const numFaces = dracoGeometry.num_faces();
881
+ const numIndices = numFaces * 3;
882
+ const byteLength = numIndices * INDEX_ITEM_SIZE;
883
+ const ptr = this.draco._malloc(byteLength);
884
+ try {
885
+ this.decoder.GetTrianglesUInt32Array(dracoGeometry, byteLength, ptr);
886
+ return new Uint32Array(this.draco.HEAPF32.buffer, ptr, numIndices).slice();
887
+ }
888
+ finally {
889
+ this.draco._free(ptr);
890
+ }
891
+ }
892
+ /**
893
+ * For meshes, we need indices to define the faces.
894
+ * @param dracoGeometry
895
+ */
896
+ _getTriangleStripIndices(dracoGeometry) {
897
+ const dracoArray = new this.draco.DracoInt32Array();
898
+ try {
899
+ /* const numStrips = */ this.decoder.GetTriangleStripsFromMesh(dracoGeometry, dracoArray);
900
+ return getUint32Array(dracoArray);
901
+ }
902
+ finally {
903
+ this.draco.destroy(dracoArray);
904
+ }
905
+ }
906
+ /**
907
+ *
908
+ * @param dracoGeometry
909
+ * @param dracoAttribute
910
+ * @param attributeName
911
+ */
912
+ _getAttributeValues(dracoGeometry, attribute) {
913
+ const TypedArrayCtor = DRACO_DATA_TYPE_TO_TYPED_ARRAY_MAP[attribute.data_type];
914
+ if (!TypedArrayCtor) {
915
+ // eslint-disable-next-line no-console
916
+ console.warn(`DRACO: Unsupported attribute type ${attribute.data_type}`);
917
+ return null;
918
+ }
919
+ const numComponents = attribute.num_components;
920
+ const numPoints = dracoGeometry.num_points();
921
+ const numValues = numPoints * numComponents;
922
+ const byteLength = numValues * TypedArrayCtor.BYTES_PER_ELEMENT;
923
+ const dataType = getDracoDataType(this.draco, TypedArrayCtor);
924
+ let value;
925
+ const ptr = this.draco._malloc(byteLength);
926
+ try {
927
+ const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attribute.attribute_index);
928
+ this.decoder.GetAttributeDataArrayForAllPoints(dracoGeometry, dracoAttribute, dataType, byteLength, ptr);
929
+ value = new TypedArrayCtor(this.draco.HEAPF32.buffer, ptr, numValues).slice();
930
+ }
931
+ finally {
932
+ this.draco._free(ptr);
933
+ }
934
+ return { value, size: numComponents };
935
+ }
936
+ // Attribute names
937
+ /**
938
+ * DRACO does not store attribute names - We need to deduce an attribute name
939
+ * for each attribute
940
+ _getAttributeNames(
941
+ dracoGeometry: Mesh | PointCloud,
942
+ options: DracoParseOptions
943
+ ): {[unique_id: number]: string} {
944
+ const attributeNames: {[unique_id: number]: string} = {};
945
+ for (let attributeId = 0; attributeId < dracoGeometry.num_attributes(); attributeId++) {
946
+ const dracoAttribute = this.decoder.GetAttribute(dracoGeometry, attributeId);
947
+ const attributeName = this._deduceAttributeName(dracoAttribute, options);
948
+ attributeNames[attributeName] = attributeName;
949
+ }
950
+ return attributeNames;
951
+ }
952
+ */
953
+ /**
954
+ * Deduce an attribute name.
955
+ * @note DRACO does not save attribute names, just general type (POSITION, COLOR)
956
+ * to help optimize compression. We generate GLTF compatible names for the Draco-recognized
957
+ * types
958
+ * @param attributeData
959
+ */
960
+ _deduceAttributeName(attribute, options) {
961
+ // Deduce name based on application provided map
962
+ const uniqueId = attribute.unique_id;
963
+ for (const [attributeName, attributeUniqueId] of Object.entries(options.extraAttributes || {})) {
964
+ if (attributeUniqueId === uniqueId) {
965
+ return attributeName;
966
+ }
967
+ }
968
+ // Deduce name based on attribute type
969
+ const thisAttributeType = attribute.attribute_type;
970
+ for (const dracoAttributeConstant in DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP) {
971
+ const attributeType = this.draco[dracoAttributeConstant];
972
+ if (attributeType === thisAttributeType) {
973
+ // TODO - Return unique names if there multiple attributes per type
974
+ // (e.g. multiple TEX_COORDS or COLORS)
975
+ return DRACO_TO_GLTF_ATTRIBUTE_NAME_MAP[dracoAttributeConstant];
976
+ }
977
+ }
978
+ // Look up in metadata
979
+ // TODO - shouldn't this have priority?
980
+ const entryName = options.attributeNameEntry || 'name';
981
+ if (attribute.metadata[entryName]) {
982
+ return attribute.metadata[entryName].string;
983
+ }
984
+ // Attribute of "GENERIC" type, we need to assign some name
985
+ return `CUSTOM_ATTRIBUTE_${uniqueId}`;
986
+ }
987
+ // METADATA EXTRACTION
988
+ /** Get top level metadata */
989
+ _getTopLevelMetadata(dracoGeometry) {
990
+ const dracoMetadata = this.decoder.GetMetadata(dracoGeometry);
991
+ return this._getDracoMetadata(dracoMetadata);
992
+ }
993
+ /** Get per attribute metadata */
994
+ _getAttributeMetadata(dracoGeometry, attributeId) {
995
+ const dracoMetadata = this.decoder.GetAttributeMetadata(dracoGeometry, attributeId);
996
+ return this._getDracoMetadata(dracoMetadata);
997
+ }
998
+ /**
999
+ * Extract metadata field values
1000
+ * @param dracoMetadata
1001
+ * @returns
1002
+ */
1003
+ _getDracoMetadata(dracoMetadata) {
1004
+ // The not so wonderful world of undocumented Draco APIs :(
1005
+ if (!dracoMetadata || !dracoMetadata.ptr) {
1006
+ return {};
1007
+ }
1008
+ const result = {};
1009
+ const numEntries = this.metadataQuerier.NumEntries(dracoMetadata);
1010
+ for (let entryIndex = 0; entryIndex < numEntries; entryIndex++) {
1011
+ const entryName = this.metadataQuerier.GetEntryName(dracoMetadata, entryIndex);
1012
+ result[entryName] = this._getDracoMetadataField(dracoMetadata, entryName);
1013
+ }
1014
+ return result;
1015
+ }
1016
+ /**
1017
+ * Extracts possible values for one metadata entry by name
1018
+ * @param dracoMetadata
1019
+ * @param entryName
1020
+ */
1021
+ _getDracoMetadataField(dracoMetadata, entryName) {
1022
+ const dracoArray = new this.draco.DracoInt32Array();
1023
+ try {
1024
+ // Draco metadata fields can hold int32 arrays
1025
+ this.metadataQuerier.GetIntEntryArray(dracoMetadata, entryName, dracoArray);
1026
+ const intArray = getInt32Array(dracoArray);
1027
+ return {
1028
+ int: this.metadataQuerier.GetIntEntry(dracoMetadata, entryName),
1029
+ string: this.metadataQuerier.GetStringEntry(dracoMetadata, entryName),
1030
+ double: this.metadataQuerier.GetDoubleEntry(dracoMetadata, entryName),
1031
+ intArray
1032
+ };
1033
+ }
1034
+ finally {
1035
+ this.draco.destroy(dracoArray);
1036
+ }
1037
+ }
1038
+ // QUANTIZED ATTRIBUTE SUPPORT (NO DECOMPRESSION)
1039
+ /** Skip transforms for specific attribute types */
1040
+ _disableAttributeTransforms(options) {
1041
+ const { quantizedAttributes = [], octahedronAttributes = [] } = options;
1042
+ const skipAttributes = [...quantizedAttributes, ...octahedronAttributes];
1043
+ for (const dracoAttributeName of skipAttributes) {
1044
+ this.decoder.SkipAttributeTransform(this.draco[dracoAttributeName]);
1045
+ }
1046
+ }
1047
+ /**
1048
+ * Extract (and apply?) Position Transform
1049
+ * @todo not used
1050
+ */
1051
+ _getQuantizationTransform(dracoAttribute, options) {
1052
+ const { quantizedAttributes = [] } = options;
1053
+ const attribute_type = dracoAttribute.attribute_type();
1054
+ const skip = quantizedAttributes.map((type) => this.decoder[type]).includes(attribute_type);
1055
+ if (skip) {
1056
+ const transform = new this.draco.AttributeQuantizationTransform();
1057
+ try {
1058
+ if (transform.InitFromAttribute(dracoAttribute)) {
1059
+ return {
1060
+ quantization_bits: transform.quantization_bits(),
1061
+ range: transform.range(),
1062
+ min_values: new Float32Array([1, 2, 3]).map((i) => transform.min_value(i))
1063
+ };
1064
+ }
1065
+ }
1066
+ finally {
1067
+ this.draco.destroy(transform);
1068
+ }
1069
+ }
1070
+ return null;
1071
+ }
1072
+ _getOctahedronTransform(dracoAttribute, options) {
1073
+ const { octahedronAttributes = [] } = options;
1074
+ const attribute_type = dracoAttribute.attribute_type();
1075
+ const octahedron = octahedronAttributes
1076
+ .map((type) => this.decoder[type])
1077
+ .includes(attribute_type);
1078
+ if (octahedron) {
1079
+ const transform = new this.draco.AttributeQuantizationTransform();
1080
+ try {
1081
+ if (transform.InitFromAttribute(dracoAttribute)) {
1082
+ return {
1083
+ quantization_bits: transform.quantization_bits()
1084
+ };
1085
+ }
1086
+ }
1087
+ finally {
1088
+ this.draco.destroy(transform);
1089
+ }
1090
+ }
1091
+ return null;
1092
+ }
1093
+ }
1094
+ /**
1095
+ * Get draco specific data type by TypedArray constructor type
1096
+ * @param attributeType
1097
+ * @returns draco specific data type
1098
+ */
1099
+ function getDracoDataType(draco, attributeType) {
1100
+ switch (attributeType) {
1101
+ case Float32Array:
1102
+ return draco.DT_FLOAT32;
1103
+ case Int8Array:
1104
+ return draco.DT_INT8;
1105
+ case Int16Array:
1106
+ return draco.DT_INT16;
1107
+ case Int32Array:
1108
+ return draco.DT_INT32;
1109
+ case Uint8Array:
1110
+ return draco.DT_UINT8;
1111
+ case Uint16Array:
1112
+ return draco.DT_UINT16;
1113
+ case Uint32Array:
1114
+ return draco.DT_UINT32;
1115
+ default:
1116
+ return draco.DT_INVALID;
1117
+ }
1118
+ }
1119
+ /**
1120
+ * Copy a Draco int32 array into a JS typed array
1121
+ */
1122
+ function getInt32Array(dracoArray) {
1123
+ const numValues = dracoArray.size();
1124
+ const intArray = new Int32Array(numValues);
1125
+ for (let i = 0; i < numValues; i++) {
1126
+ intArray[i] = dracoArray.GetValue(i);
1127
+ }
1128
+ return intArray;
1129
+ }
1130
+ /**
1131
+ * Copy a Draco int32 array into a JS typed array
1132
+ */
1133
+ function getUint32Array(dracoArray) {
1134
+ const numValues = dracoArray.size();
1135
+ const intArray = new Int32Array(numValues);
1136
+ for (let i = 0; i < numValues; i++) {
1137
+ intArray[i] = dracoArray.GetValue(i);
1138
+ }
1139
+ return intArray;
1140
+ }
1141
+
1142
+
1143
+ /***/ }),
1144
+
1145
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/utils/get-draco-schema.js":
1146
+ /*!*************************************************************************************************************************************************************!*\
1147
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/utils/get-draco-schema.js ***!
1148
+ \*************************************************************************************************************************************************************/
1149
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1150
+
1151
+ __webpack_require__.r(__webpack_exports__);
1152
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1153
+ /* harmony export */ getDracoSchema: () => (/* binding */ getDracoSchema)
1154
+ /* harmony export */ });
1155
+ /* harmony import */ var _loaders_gl_schema__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @loaders.gl/schema */ "../../common/temp/node_modules/.pnpm/@loaders.gl+schema@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/schema/dist/lib/mesh/deduce-mesh-schema.js");
1156
+
1157
+ /** Extract an arrow-like schema from a Draco mesh */
1158
+ function getDracoSchema(attributes, loaderData, indices) {
1159
+ const metadata = makeMetadata(loaderData.metadata);
1160
+ const fields = [];
1161
+ const namedLoaderDataAttributes = transformAttributesLoaderData(loaderData.attributes);
1162
+ for (const attributeName in attributes) {
1163
+ const attribute = attributes[attributeName];
1164
+ const field = getArrowFieldFromAttribute(attributeName, attribute, namedLoaderDataAttributes[attributeName]);
1165
+ fields.push(field);
1166
+ }
1167
+ if (indices) {
1168
+ const indicesField = getArrowFieldFromAttribute('indices', indices);
1169
+ fields.push(indicesField);
1170
+ }
1171
+ return { fields, metadata };
1172
+ }
1173
+ function transformAttributesLoaderData(loaderData) {
1174
+ const result = {};
1175
+ for (const key in loaderData) {
1176
+ const dracoAttribute = loaderData[key];
1177
+ result[dracoAttribute.name || 'undefined'] = dracoAttribute;
1178
+ }
1179
+ return result;
1180
+ }
1181
+ function getArrowFieldFromAttribute(attributeName, attribute, loaderData) {
1182
+ const metadataMap = loaderData ? makeMetadata(loaderData.metadata) : undefined;
1183
+ const field = (0,_loaders_gl_schema__WEBPACK_IMPORTED_MODULE_0__.deduceMeshField)(attributeName, attribute, metadataMap);
1184
+ return field;
1185
+ }
1186
+ function makeMetadata(metadata) {
1187
+ Object.entries(metadata);
1188
+ const serializedMetadata = {};
1189
+ for (const key in metadata) {
1190
+ serializedMetadata[`${key}.string`] = JSON.stringify(metadata[key]);
1191
+ }
1192
+ return serializedMetadata;
1193
+ }
1194
+
1195
+
1196
+ /***/ }),
1197
+
1198
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/utils/version.js":
1199
+ /*!****************************************************************************************************************************************************!*\
1200
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+draco@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/draco/dist/lib/utils/version.js ***!
1201
+ \****************************************************************************************************************************************************/
1202
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1203
+
1204
+ __webpack_require__.r(__webpack_exports__);
1205
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1206
+ /* harmony export */ VERSION: () => (/* binding */ VERSION)
1207
+ /* harmony export */ });
1208
+ // Version constant cannot be imported, it needs to correspond to the build version of **this** module.
1209
+ // __VERSION__ is injected by babel-plugin-version-inline
1210
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
1211
+ const VERSION = true ? "4.3.3" : 0;
1212
+
1213
+
1214
+ /***/ }),
1215
+
1216
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+schema@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/schema/dist/lib/mesh/deduce-mesh-schema.js":
1217
+ /*!****************************************************************************************************************************************************************!*\
1218
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+schema@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/schema/dist/lib/mesh/deduce-mesh-schema.js ***!
1219
+ \****************************************************************************************************************************************************************/
1220
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1221
+
1222
+ __webpack_require__.r(__webpack_exports__);
1223
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1224
+ /* harmony export */ deduceMeshField: () => (/* binding */ deduceMeshField),
1225
+ /* harmony export */ deduceMeshSchema: () => (/* binding */ deduceMeshSchema),
1226
+ /* harmony export */ makeMeshAttributeMetadata: () => (/* binding */ makeMeshAttributeMetadata)
1227
+ /* harmony export */ });
1228
+ /* harmony import */ var _table_simple_table_data_type_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../table/simple-table/data-type.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+schema@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/schema/dist/lib/table/simple-table/data-type.js");
1229
+ // loaders.gl
1230
+ // SPDX-License-Identifier: MIT
1231
+ // Copyright (c) vis.gl contributors
1232
+
1233
+ /**
1234
+ * Create a schema for mesh attributes data
1235
+ * @param attributes
1236
+ * @param metadata
1237
+ * @returns
1238
+ */
1239
+ function deduceMeshSchema(attributes, metadata = {}) {
1240
+ const fields = deduceMeshFields(attributes);
1241
+ return { fields, metadata };
1242
+ }
1243
+ /**
1244
+ * Create arrow-like schema field for mesh attribute
1245
+ * @param attributeName
1246
+ * @param attribute
1247
+ * @param optionalMetadata
1248
+ * @returns
1249
+ */
1250
+ function deduceMeshField(name, attribute, optionalMetadata) {
1251
+ const type = (0,_table_simple_table_data_type_js__WEBPACK_IMPORTED_MODULE_0__.getDataTypeFromTypedArray)(attribute.value);
1252
+ const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
1253
+ return {
1254
+ name,
1255
+ type: { type: 'fixed-size-list', listSize: attribute.size, children: [{ name: 'value', type }] },
1256
+ nullable: false,
1257
+ metadata
1258
+ };
1259
+ }
1260
+ /**
1261
+ * Create fields array for mesh attributes
1262
+ * @param attributes
1263
+ * @returns
1264
+ */
1265
+ function deduceMeshFields(attributes) {
1266
+ const fields = [];
1267
+ for (const attributeName in attributes) {
1268
+ const attribute = attributes[attributeName];
1269
+ fields.push(deduceMeshField(attributeName, attribute));
1270
+ }
1271
+ return fields;
1272
+ }
1273
+ /**
1274
+ * Make metadata by mesh attribute properties
1275
+ * @param attribute
1276
+ * @returns
1277
+ */
1278
+ function makeMeshAttributeMetadata(attribute) {
1279
+ const result = {};
1280
+ if ('byteOffset' in attribute) {
1281
+ result.byteOffset = attribute.byteOffset.toString(10);
1282
+ }
1283
+ if ('byteStride' in attribute) {
1284
+ result.byteStride = attribute.byteStride.toString(10);
1285
+ }
1286
+ if ('normalized' in attribute) {
1287
+ result.normalized = attribute.normalized.toString();
1288
+ }
1289
+ return result;
1290
+ }
1291
+
1292
+
1293
+ /***/ }),
1294
+
1295
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+schema@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/schema/dist/lib/mesh/mesh-utils.js":
1296
+ /*!********************************************************************************************************************************************************!*\
1297
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+schema@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/schema/dist/lib/mesh/mesh-utils.js ***!
1298
+ \********************************************************************************************************************************************************/
1299
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1300
+
1301
+ __webpack_require__.r(__webpack_exports__);
1302
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1303
+ /* harmony export */ getMeshBoundingBox: () => (/* binding */ getMeshBoundingBox),
1304
+ /* harmony export */ getMeshSize: () => (/* binding */ getMeshSize)
1305
+ /* harmony export */ });
1306
+ /**
1307
+ * Get number of vertices in mesh
1308
+ * @param attributes
1309
+ */
1310
+ function getMeshSize(attributes) {
1311
+ let size = 0;
1312
+ for (const attributeName in attributes) {
1313
+ const attribute = attributes[attributeName];
1314
+ if (ArrayBuffer.isView(attribute)) {
1315
+ // @ts-ignore DataView doesn't have BYTES_PER_ELEMENT
1316
+ size += attribute.byteLength * attribute.BYTES_PER_ELEMENT;
1317
+ }
1318
+ }
1319
+ return size;
1320
+ }
1321
+ /**
1322
+ * Get the (axis aligned) bounding box of a mesh
1323
+ * @param attributes
1324
+ * @returns array of two vectors representing the axis aligned bounding box
1325
+ */
1326
+ // eslint-disable-next-line complexity
1327
+ function getMeshBoundingBox(attributes) {
1328
+ let minX = Infinity;
1329
+ let minY = Infinity;
1330
+ let minZ = Infinity;
1331
+ let maxX = -Infinity;
1332
+ let maxY = -Infinity;
1333
+ let maxZ = -Infinity;
1334
+ const positions = attributes.POSITION ? attributes.POSITION.value : [];
1335
+ const len = positions && positions.length;
1336
+ for (let i = 0; i < len; i += 3) {
1337
+ const x = positions[i];
1338
+ const y = positions[i + 1];
1339
+ const z = positions[i + 2];
1340
+ minX = x < minX ? x : minX;
1341
+ minY = y < minY ? y : minY;
1342
+ minZ = z < minZ ? z : minZ;
1343
+ maxX = x > maxX ? x : maxX;
1344
+ maxY = y > maxY ? y : maxY;
1345
+ maxZ = z > maxZ ? z : maxZ;
1346
+ }
1347
+ return [
1348
+ [minX, minY, minZ],
1349
+ [maxX, maxY, maxZ]
1350
+ ];
1351
+ }
1352
+
1353
+
1354
+ /***/ }),
1355
+
1356
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+schema@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/schema/dist/lib/table/simple-table/data-type.js":
1357
+ /*!*********************************************************************************************************************************************************************!*\
1358
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+schema@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/schema/dist/lib/table/simple-table/data-type.js ***!
1359
+ \*********************************************************************************************************************************************************************/
1360
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1361
+
1362
+ __webpack_require__.r(__webpack_exports__);
1363
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1364
+ /* harmony export */ getArrayTypeFromDataType: () => (/* binding */ getArrayTypeFromDataType),
1365
+ /* harmony export */ getDataTypeFromArray: () => (/* binding */ getDataTypeFromArray),
1366
+ /* harmony export */ getDataTypeFromTypedArray: () => (/* binding */ getDataTypeFromTypedArray),
1367
+ /* harmony export */ getDataTypeFromValue: () => (/* binding */ getDataTypeFromValue)
1368
+ /* harmony export */ });
1369
+ // loaders.gl
1370
+ // SPDX-License-Identifier: MIT
1371
+ // Copyright (c) vis.gl contributors
1372
+ /** Deduce column types from values */
1373
+ function getDataTypeFromValue(value, defaultNumberType = 'float32') {
1374
+ if (value instanceof Date) {
1375
+ return 'date-millisecond';
1376
+ }
1377
+ if (value instanceof Number) {
1378
+ return defaultNumberType;
1379
+ }
1380
+ if (typeof value === 'string') {
1381
+ return 'utf8';
1382
+ }
1383
+ if (value === null || value === 'undefined') {
1384
+ return 'null';
1385
+ }
1386
+ return 'null';
1387
+ }
1388
+ /**
1389
+ * Deduces a simple data type "descriptor from a typed array instance
1390
+ */
1391
+ function getDataTypeFromArray(array) {
1392
+ let type = getDataTypeFromTypedArray(array);
1393
+ if (type !== 'null') {
1394
+ return { type, nullable: false };
1395
+ }
1396
+ if (array.length > 0) {
1397
+ type = getDataTypeFromValue(array[0]);
1398
+ return { type, nullable: true };
1399
+ }
1400
+ return { type: 'null', nullable: true };
1401
+ }
1402
+ /**
1403
+ * Deduces a simple data type "descriptor from a typed array instance
1404
+ */
1405
+ function getDataTypeFromTypedArray(array) {
1406
+ switch (array.constructor) {
1407
+ case Int8Array:
1408
+ return 'int8';
1409
+ case Uint8Array:
1410
+ case Uint8ClampedArray:
1411
+ return 'uint8';
1412
+ case Int16Array:
1413
+ return 'int16';
1414
+ case Uint16Array:
1415
+ return 'uint16';
1416
+ case Int32Array:
1417
+ return 'int32';
1418
+ case Uint32Array:
1419
+ return 'uint32';
1420
+ case Float32Array:
1421
+ return 'float32';
1422
+ case Float64Array:
1423
+ return 'float64';
1424
+ default:
1425
+ return 'null';
1426
+ }
1427
+ }
1428
+ function getArrayTypeFromDataType(type, nullable) {
1429
+ if (!nullable) {
1430
+ switch (type) {
1431
+ case 'int8':
1432
+ return Int8Array;
1433
+ case 'uint8':
1434
+ return Uint8Array;
1435
+ case 'int16':
1436
+ return Int16Array;
1437
+ case 'uint16':
1438
+ return Uint16Array;
1439
+ case 'int32':
1440
+ return Int32Array;
1441
+ case 'uint32':
1442
+ return Uint32Array;
1443
+ case 'float32':
1444
+ return Float32Array;
1445
+ case 'float64':
1446
+ return Float64Array;
1447
+ default:
1448
+ break;
1449
+ }
1450
+ }
1451
+ // if (typeof BigInt64Array !== 'undefined') {
1452
+ // TYPED_ARRAY_TO_TYPE.BigInt64Array = new Int64();
1453
+ // TYPED_ARRAY_TO_TYPE.BigUint64Array = new Uint64();
1454
+ // }
1455
+ return Array;
1456
+ }
1457
+
1458
+
1459
+ /***/ }),
1460
+
1461
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+worker-utils@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/assert.js":
1462
+ /*!*********************************************************************************************************************************************************************!*\
1463
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+worker-utils@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/assert.js ***!
1464
+ \*********************************************************************************************************************************************************************/
1465
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1466
+
1467
+ __webpack_require__.r(__webpack_exports__);
1468
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1469
+ /* harmony export */ assert: () => (/* binding */ assert)
1470
+ /* harmony export */ });
1471
+ // loaders.gl
1472
+ // SPDX-License-Identifier: MIT
1473
+ // Copyright (c) vis.gl contributors
1474
+ // Replacement for the external assert method to reduce bundle size
1475
+ // Note: We don't use the second "message" argument in calling code,
1476
+ // so no need to support it here
1477
+ /** Throws an `Error` with the optional `message` if `condition` is falsy */
1478
+ function assert(condition, message) {
1479
+ if (!condition) {
1480
+ throw new Error(message || 'loaders.gl assertion failed.');
1481
+ }
1482
+ }
1483
+
1484
+
1485
+ /***/ }),
1486
+
1487
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+worker-utils@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/globals.js":
1488
+ /*!**********************************************************************************************************************************************************************!*\
1489
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+worker-utils@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/globals.js ***!
1490
+ \**********************************************************************************************************************************************************************/
1491
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1492
+
1493
+ __webpack_require__.r(__webpack_exports__);
1494
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1495
+ /* harmony export */ document: () => (/* binding */ document_),
1496
+ /* harmony export */ global: () => (/* binding */ global_),
1497
+ /* harmony export */ isBrowser: () => (/* binding */ isBrowser),
1498
+ /* harmony export */ isMobile: () => (/* binding */ isMobile),
1499
+ /* harmony export */ isWorker: () => (/* binding */ isWorker),
1500
+ /* harmony export */ nodeVersion: () => (/* binding */ nodeVersion),
1501
+ /* harmony export */ self: () => (/* binding */ self_),
1502
+ /* harmony export */ window: () => (/* binding */ window_)
1503
+ /* harmony export */ });
1504
+ // loaders.gl
1505
+ // SPDX-License-Identifier: MIT
1506
+ // Copyright (c) vis.gl contributors
1507
+ // Purpose: include this in your module to avoids adding dependencies on
1508
+ // micro modules like 'global' and 'is-browser';
1509
+ /* eslint-disable no-restricted-globals */
1510
+ const globals = {
1511
+ self: typeof self !== 'undefined' && self,
1512
+ window: typeof window !== 'undefined' && window,
1513
+ global: typeof global !== 'undefined' && global,
1514
+ document: typeof document !== 'undefined' && document
1515
+ };
1516
+ const self_ = globals.self || globals.window || globals.global || {};
1517
+ const window_ = globals.window || globals.self || globals.global || {};
1518
+ const global_ = globals.global || globals.self || globals.window || {};
1519
+ const document_ = globals.document || {};
1520
+
1521
+ /** true if running in the browser, false if running in Node.js */
1522
+ const isBrowser =
1523
+ // @ts-ignore process.browser
1524
+ typeof process !== 'object' || String(process) !== '[object process]' || process.browser;
1525
+ /** true if running on a worker thread */
1526
+ const isWorker = typeof importScripts === 'function';
1527
+ /** true if running on a mobile device */
1528
+ const isMobile = typeof window !== 'undefined' && typeof window.orientation !== 'undefined';
1529
+ // Extract node major version
1530
+ const matches = typeof process !== 'undefined' && process.version && /v([0-9]*)/.exec(process.version);
1531
+ /** Version of Node.js if running under Node, otherwise 0 */
1532
+ const nodeVersion = (matches && parseFloat(matches[1])) || 0;
1533
+
1534
+
1535
+ /***/ }),
1536
+
1537
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+worker-utils@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/version.js":
1538
+ /*!**********************************************************************************************************************************************************************!*\
1539
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+worker-utils@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/version.js ***!
1540
+ \**********************************************************************************************************************************************************************/
1541
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1542
+
1543
+ __webpack_require__.r(__webpack_exports__);
1544
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1545
+ /* harmony export */ NPM_TAG: () => (/* binding */ NPM_TAG),
1546
+ /* harmony export */ VERSION: () => (/* binding */ VERSION)
1547
+ /* harmony export */ });
1548
+ // loaders.gl
1549
+ // SPDX-License-Identifier: MIT
1550
+ // Copyright (c) vis.gl contributors
1551
+ // Version constant cannot be imported, it needs to correspond to the build version of **this** module.
1552
+ /**
1553
+ * TODO - unpkg.com doesn't seem to have a `latest` specifier for alpha releases...
1554
+ * 'beta' on beta branch, 'latest' on prod branch
1555
+ */
1556
+ const NPM_TAG = 'latest';
1557
+ function getVersion() {
1558
+ if (!globalThis._loadersgl_?.version) {
1559
+ globalThis._loadersgl_ = globalThis._loadersgl_ || {};
1560
+ // __VERSION__ is injected by babel-plugin-version-inline
1561
+ if (false) {}
1562
+ else {
1563
+ globalThis._loadersgl_.version = "4.3.3";
1564
+ }
1565
+ }
1566
+ return globalThis._loadersgl_.version;
1567
+ }
1568
+ const VERSION = getVersion();
1569
+
1570
+
1571
+ /***/ }),
1572
+
1573
+ /***/ "../../common/temp/node_modules/.pnpm/@loaders.gl+worker-utils@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/worker-utils/dist/lib/library-utils/library-utils.js":
1574
+ /*!********************************************************************************************************************************************************************************!*\
1575
+ !*** ../../common/temp/node_modules/.pnpm/@loaders.gl+worker-utils@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/worker-utils/dist/lib/library-utils/library-utils.js ***!
1576
+ \********************************************************************************************************************************************************************************/
1577
+ /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1578
+
1579
+ __webpack_require__.r(__webpack_exports__);
1580
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1581
+ /* harmony export */ getLibraryUrl: () => (/* binding */ getLibraryUrl),
1582
+ /* harmony export */ loadLibrary: () => (/* binding */ loadLibrary)
1583
+ /* harmony export */ });
1584
+ /* harmony import */ var _env_utils_globals_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../env-utils/globals.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+worker-utils@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/globals.js");
1585
+ /* harmony import */ var _env_utils_assert_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../env-utils/assert.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+worker-utils@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/assert.js");
1586
+ /* harmony import */ var _env_utils_version_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../env-utils/version.js */ "../../common/temp/node_modules/.pnpm/@loaders.gl+worker-utils@4.3.4_@loaders.gl+core@4.3.4/node_modules/@loaders.gl/worker-utils/dist/lib/env-utils/version.js");
1587
+ // loaders.gl
1588
+ // SPDX-License-Identifier: MIT
1589
+ // Copyright (c) vis.gl contributors
1590
+ /* global importScripts */
1591
+
1592
+
1593
+
1594
+ const loadLibraryPromises = {}; // promises
1595
+ /**
1596
+ * Dynamically loads a library ("module")
1597
+ *
1598
+ * - wasm library: Array buffer is returned
1599
+ * - js library: Parse JS is returned
1600
+ *
1601
+ * Method depends on environment
1602
+ * - browser - script element is created and installed on document
1603
+ * - worker - eval is called on global context
1604
+ * - node - file is required
1605
+ *
1606
+ * @param libraryUrl
1607
+ * @param moduleName
1608
+ * @param options
1609
+ */
1610
+ async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
1611
+ if (moduleName) {
1612
+ libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
1613
+ }
1614
+ // Ensure libraries are only loaded once
1615
+ loadLibraryPromises[libraryUrl] =
1616
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
1617
+ loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
1618
+ return await loadLibraryPromises[libraryUrl];
1619
+ }
1620
+ // TODO - sort out how to resolve paths for main/worker and dev/prod
1621
+ function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
1622
+ // Check if already a URL
1623
+ if (!options.useLocalLibraries && library.startsWith('http')) {
1624
+ return library;
1625
+ }
1626
+ libraryName = libraryName || library;
1627
+ // Allow application to import and supply libraries through `options.modules`
1628
+ // TODO - See js-module-utils in loader-utils
1629
+ const modules = options.modules || {};
1630
+ if (modules[libraryName]) {
1631
+ return modules[libraryName];
1632
+ }
1633
+ // Load from local files, not from CDN scripts in Node.js
1634
+ // TODO - needs to locate the modules directory when installed!
1635
+ if (!_env_utils_globals_js__WEBPACK_IMPORTED_MODULE_0__.isBrowser) {
1636
+ return `modules/${moduleName}/dist/libs/${libraryName}`;
1637
+ }
1638
+ // In browser, load from external scripts
1639
+ if (options.CDN) {
1640
+ (0,_env_utils_assert_js__WEBPACK_IMPORTED_MODULE_1__.assert)(options.CDN.startsWith('http'));
1641
+ return `${options.CDN}/${moduleName}@${_env_utils_version_js__WEBPACK_IMPORTED_MODULE_2__.VERSION}/dist/libs/${libraryName}`;
1642
+ }
1643
+ // TODO - loading inside workers requires paths relative to worker script location...
1644
+ if (_env_utils_globals_js__WEBPACK_IMPORTED_MODULE_0__.isWorker) {
1645
+ return `../src/libs/${libraryName}`;
1646
+ }
1647
+ return `modules/${moduleName}/src/libs/${libraryName}`;
1648
+ }
1649
+ async function loadLibraryFromFile(libraryUrl) {
1650
+ if (libraryUrl.endsWith('wasm')) {
1651
+ return await loadAsArrayBuffer(libraryUrl);
1652
+ }
1653
+ if (!_env_utils_globals_js__WEBPACK_IMPORTED_MODULE_0__.isBrowser) {
1654
+ // TODO - Node doesn't yet support dynamic import from https URLs
1655
+ // try {
1656
+ // return await import(libraryUrl);
1657
+ // } catch (error) {
1658
+ // console.error(error);
1659
+ // }
1660
+ try {
1661
+ const { requireFromFile } = globalThis.loaders || {};
1662
+ return await requireFromFile?.(libraryUrl);
1663
+ }
1664
+ catch (error) {
1665
+ console.error(error); // eslint-disable-line no-console
1666
+ return null;
1667
+ }
1668
+ }
1669
+ if (_env_utils_globals_js__WEBPACK_IMPORTED_MODULE_0__.isWorker) {
1670
+ return importScripts(libraryUrl);
1671
+ }
1672
+ // TODO - fix - should be more secure than string parsing since observes CORS
1673
+ // if (isBrowser) {
1674
+ // return await loadScriptFromFile(libraryUrl);
1675
+ // }
1676
+ const scriptSource = await loadAsText(libraryUrl);
1677
+ return loadLibraryFromString(scriptSource, libraryUrl);
1678
+ }
1679
+ /*
1680
+ async function loadScriptFromFile(libraryUrl) {
1681
+ const script = document.createElement('script');
1682
+ script.src = libraryUrl;
1683
+ return await new Promise((resolve, reject) => {
1684
+ script.onload = data => {
1685
+ resolve(data);
1686
+ };
1687
+ script.onerror = reject;
1688
+ });
1689
+ }
1690
+ */
1691
+ // TODO - Needs security audit...
1692
+ // - Raw eval call
1693
+ // - Potentially bypasses CORS
1694
+ // Upside is that this separates fetching and parsing
1695
+ // we could create a`LibraryLoader` or`ModuleLoader`
1696
+ function loadLibraryFromString(scriptSource, id) {
1697
+ if (!_env_utils_globals_js__WEBPACK_IMPORTED_MODULE_0__.isBrowser) {
1698
+ const { requireFromString } = globalThis.loaders || {};
1699
+ return requireFromString?.(scriptSource, id);
1700
+ }
1701
+ if (_env_utils_globals_js__WEBPACK_IMPORTED_MODULE_0__.isWorker) {
1702
+ // Use lvalue trick to make eval run in global scope
1703
+ eval.call(globalThis, scriptSource); // eslint-disable-line no-eval
1704
+ // https://stackoverflow.com/questions/9107240/1-evalthis-vs-evalthis-in-javascript
1705
+ // http://perfectionkills.com/global-eval-what-are-the-options/
1706
+ return null;
1707
+ }
1708
+ const script = document.createElement('script');
1709
+ script.id = id;
1710
+ // most browsers like a separate text node but some throw an error. The second method covers those.
1711
+ try {
1712
+ script.appendChild(document.createTextNode(scriptSource));
1713
+ }
1714
+ catch (e) {
1715
+ script.text = scriptSource;
1716
+ }
1717
+ document.body.appendChild(script);
1718
+ return null;
1719
+ }
1720
+ // TODO - technique for module injection into worker, from THREE.DracoLoader...
1721
+ /*
1722
+ function combineWorkerWithLibrary(worker, jsContent) {
1723
+ var fn = wWorker.toString();
1724
+ var body = [
1725
+ '// injected',
1726
+ jsContent,
1727
+ '',
1728
+ '// worker',
1729
+ fn.substring(fn.indexOf('{') + 1, fn.lastIndexOf('}'))
1730
+ ].join('\n');
1731
+ this.workerSourceURL = URL.createObjectURL(new Blob([body]));
1732
+ }
1733
+ */
1734
+ async function loadAsArrayBuffer(url) {
1735
+ const { readFileAsArrayBuffer } = globalThis.loaders || {};
1736
+ if (_env_utils_globals_js__WEBPACK_IMPORTED_MODULE_0__.isBrowser || !readFileAsArrayBuffer || url.startsWith('http')) {
1737
+ const response = await fetch(url);
1738
+ return await response.arrayBuffer();
1739
+ }
1740
+ return await readFileAsArrayBuffer(url);
1741
+ }
1742
+ /**
1743
+ * Load a file from local file system
1744
+ * @param filename
1745
+ * @returns
1746
+ */
1747
+ async function loadAsText(url) {
1748
+ const { readFileAsText } = globalThis.loaders || {};
1749
+ if (_env_utils_globals_js__WEBPACK_IMPORTED_MODULE_0__.isBrowser || !readFileAsText || url.startsWith('http')) {
1750
+ const response = await fetch(url);
1751
+ return await response.text();
1752
+ }
1753
+ return await readFileAsText(url);
1754
+ }
1755
+
1756
+
1757
+ /***/ })
1758
+
1759
+ }]);
1760
+ //# sourceMappingURL=vendors-common_temp_node_modules_pnpm_loaders_gl_draco_4_3_4__loaders_gl_core_4_3_4_node_modu-4c1fc9.bundled-tests.js.map