@loaders.gl/gltf 4.3.2 → 4.4.0-alpha.2
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.
- package/dist/dist.dev.js +112 -110
- package/dist/dist.min.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +2 -2
- package/dist/lib/utils/version.js +1 -1
- package/package.json +8 -8
package/dist/dist.dev.js
CHANGED
|
@@ -116,8 +116,10 @@ var __exports__ = (() => {
|
|
|
116
116
|
return module || null;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
// ../worker-utils/src/lib/npm-tag.ts
|
|
120
|
+
var NPM_TAG = "beta";
|
|
121
|
+
|
|
119
122
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
120
|
-
var NPM_TAG = "latest";
|
|
121
123
|
function getVersion() {
|
|
122
124
|
if (!globalThis._loadersgl_?.version) {
|
|
123
125
|
globalThis._loadersgl_ = globalThis._loadersgl_ || {};
|
|
@@ -3416,35 +3418,88 @@ var __exports__ = (() => {
|
|
|
3416
3418
|
preprocess: () => preprocess3
|
|
3417
3419
|
});
|
|
3418
3420
|
|
|
3421
|
+
// ../draco/src/lib/draco-module-loader.ts
|
|
3422
|
+
var DRACO_DECODER_VERSION = "1.5.6";
|
|
3423
|
+
var DRACO_ENCODER_VERSION = "1.4.1";
|
|
3424
|
+
var STATIC_DECODER_URL = `https://www.gstatic.com/draco/versioned/decoders/${DRACO_DECODER_VERSION}`;
|
|
3425
|
+
var DRACO_EXTERNAL_LIBRARIES = {
|
|
3426
|
+
/** The primary Draco3D encoder, javascript wrapper part */
|
|
3427
|
+
DECODER: "draco_wasm_wrapper.js",
|
|
3428
|
+
/** The primary draco decoder, compiled web assembly part */
|
|
3429
|
+
DECODER_WASM: "draco_decoder.wasm",
|
|
3430
|
+
/** Fallback decoder for non-webassebly environments. Very big bundle, lower performance */
|
|
3431
|
+
FALLBACK_DECODER: "draco_decoder.js",
|
|
3432
|
+
/** Draco encoder */
|
|
3433
|
+
ENCODER: "draco_encoder.js"
|
|
3434
|
+
};
|
|
3435
|
+
var DRACO_EXTERNAL_LIBRARY_URLS = {
|
|
3436
|
+
[DRACO_EXTERNAL_LIBRARIES.DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER}`,
|
|
3437
|
+
[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.DECODER_WASM}`,
|
|
3438
|
+
[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER]: `${STATIC_DECODER_URL}/${DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER}`,
|
|
3439
|
+
[DRACO_EXTERNAL_LIBRARIES.ENCODER]: `https://raw.githubusercontent.com/google/draco/${DRACO_ENCODER_VERSION}/javascript/${DRACO_EXTERNAL_LIBRARIES.ENCODER}`
|
|
3440
|
+
};
|
|
3441
|
+
var loadDecoderPromise;
|
|
3442
|
+
async function loadDracoDecoderModule(options) {
|
|
3443
|
+
const modules = options.modules || {};
|
|
3444
|
+
if (modules.draco3d) {
|
|
3445
|
+
loadDecoderPromise ||= modules.draco3d.createDecoderModule({}).then((draco) => {
|
|
3446
|
+
return { draco };
|
|
3447
|
+
});
|
|
3448
|
+
} else {
|
|
3449
|
+
loadDecoderPromise ||= loadDracoDecoder(options);
|
|
3450
|
+
}
|
|
3451
|
+
return await loadDecoderPromise;
|
|
3452
|
+
}
|
|
3453
|
+
async function loadDracoDecoder(options) {
|
|
3454
|
+
let DracoDecoderModule;
|
|
3455
|
+
let wasmBinary;
|
|
3456
|
+
switch (options.draco && options.draco.decoderType) {
|
|
3457
|
+
case "js":
|
|
3458
|
+
DracoDecoderModule = await loadLibrary(
|
|
3459
|
+
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER],
|
|
3460
|
+
"draco",
|
|
3461
|
+
options,
|
|
3462
|
+
DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER
|
|
3463
|
+
);
|
|
3464
|
+
break;
|
|
3465
|
+
case "wasm":
|
|
3466
|
+
default:
|
|
3467
|
+
[DracoDecoderModule, wasmBinary] = await Promise.all([
|
|
3468
|
+
await loadLibrary(
|
|
3469
|
+
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],
|
|
3470
|
+
"draco",
|
|
3471
|
+
options,
|
|
3472
|
+
DRACO_EXTERNAL_LIBRARIES.DECODER
|
|
3473
|
+
),
|
|
3474
|
+
await loadLibrary(
|
|
3475
|
+
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
|
|
3476
|
+
"draco",
|
|
3477
|
+
options,
|
|
3478
|
+
DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
|
|
3479
|
+
)
|
|
3480
|
+
]);
|
|
3481
|
+
}
|
|
3482
|
+
DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
|
|
3483
|
+
return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);
|
|
3484
|
+
}
|
|
3485
|
+
function initializeDracoDecoder(DracoDecoderModule, wasmBinary) {
|
|
3486
|
+
const options = {};
|
|
3487
|
+
if (wasmBinary) {
|
|
3488
|
+
options.wasmBinary = wasmBinary;
|
|
3489
|
+
}
|
|
3490
|
+
return new Promise((resolve) => {
|
|
3491
|
+
DracoDecoderModule({
|
|
3492
|
+
...options,
|
|
3493
|
+
onModuleLoaded: (draco) => resolve({ draco })
|
|
3494
|
+
// Module is Promise-like. Wrap in object to avoid loop.
|
|
3495
|
+
});
|
|
3496
|
+
});
|
|
3497
|
+
}
|
|
3498
|
+
|
|
3419
3499
|
// ../draco/src/lib/utils/version.ts
|
|
3420
3500
|
var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
3421
3501
|
|
|
3422
|
-
// ../
|
|
3423
|
-
var DracoLoader = {
|
|
3424
|
-
dataType: null,
|
|
3425
|
-
batchType: null,
|
|
3426
|
-
name: "Draco",
|
|
3427
|
-
id: "draco",
|
|
3428
|
-
module: "draco",
|
|
3429
|
-
// shapes: ['mesh'],
|
|
3430
|
-
version: VERSION5,
|
|
3431
|
-
worker: true,
|
|
3432
|
-
extensions: ["drc"],
|
|
3433
|
-
mimeTypes: ["application/octet-stream"],
|
|
3434
|
-
binary: true,
|
|
3435
|
-
tests: ["DRACO"],
|
|
3436
|
-
options: {
|
|
3437
|
-
draco: {
|
|
3438
|
-
decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
|
|
3439
|
-
// 'js' for IE11
|
|
3440
|
-
libraryPath: "libs/",
|
|
3441
|
-
extraAttributes: {},
|
|
3442
|
-
attributeNameEntry: void 0
|
|
3443
|
-
}
|
|
3444
|
-
}
|
|
3445
|
-
};
|
|
3446
|
-
|
|
3447
|
-
// ../schema/src/lib/table/simple-table/data-type.ts
|
|
3502
|
+
// ../schema-utils/src/lib/schema/data-type.ts
|
|
3448
3503
|
function getDataTypeFromTypedArray(array) {
|
|
3449
3504
|
switch (array.constructor) {
|
|
3450
3505
|
case Int8Array:
|
|
@@ -3469,7 +3524,7 @@ var __exports__ = (() => {
|
|
|
3469
3524
|
}
|
|
3470
3525
|
}
|
|
3471
3526
|
|
|
3472
|
-
// ../schema/src/lib/mesh/mesh-utils.ts
|
|
3527
|
+
// ../schema-utils/src/lib/mesh/mesh-utils.ts
|
|
3473
3528
|
function getMeshBoundingBox(attributes) {
|
|
3474
3529
|
let minX = Infinity;
|
|
3475
3530
|
let minY = Infinity;
|
|
@@ -3496,7 +3551,7 @@ var __exports__ = (() => {
|
|
|
3496
3551
|
];
|
|
3497
3552
|
}
|
|
3498
3553
|
|
|
3499
|
-
// ../schema/src/lib/mesh/deduce-mesh-schema.ts
|
|
3554
|
+
// ../schema-utils/src/lib/mesh/deduce-mesh-schema.ts
|
|
3500
3555
|
function deduceMeshField(name12, attribute, optionalMetadata) {
|
|
3501
3556
|
const type = getDataTypeFromTypedArray(attribute.value);
|
|
3502
3557
|
const metadata = optionalMetadata ? optionalMetadata : makeMeshAttributeMetadata(attribute);
|
|
@@ -3720,6 +3775,7 @@ var __exports__ = (() => {
|
|
|
3720
3775
|
case "triangle-strip":
|
|
3721
3776
|
return {
|
|
3722
3777
|
topology: "triangle-strip",
|
|
3778
|
+
// TODO - mode is wrong?
|
|
3723
3779
|
mode: 4,
|
|
3724
3780
|
// GL.TRIANGLES
|
|
3725
3781
|
attributes,
|
|
@@ -3732,6 +3788,7 @@ var __exports__ = (() => {
|
|
|
3732
3788
|
default:
|
|
3733
3789
|
return {
|
|
3734
3790
|
topology: "triangle-list",
|
|
3791
|
+
// TODO - mode is wrong?
|
|
3735
3792
|
mode: 5,
|
|
3736
3793
|
// GL.TRIANGLE_STRIP
|
|
3737
3794
|
attributes,
|
|
@@ -4016,87 +4073,32 @@ var __exports__ = (() => {
|
|
|
4016
4073
|
return intArray;
|
|
4017
4074
|
}
|
|
4018
4075
|
|
|
4019
|
-
// ../draco/src/
|
|
4020
|
-
var
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
|
|
4032
|
-
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
|
|
4036
|
-
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
const modules = options.modules || {};
|
|
4042
|
-
if (modules.draco3d) {
|
|
4043
|
-
loadDecoderPromise ||= modules.draco3d.createDecoderModule({}).then((draco) => {
|
|
4044
|
-
return { draco };
|
|
4045
|
-
});
|
|
4046
|
-
} else {
|
|
4047
|
-
loadDecoderPromise ||= loadDracoDecoder(options);
|
|
4048
|
-
}
|
|
4049
|
-
return await loadDecoderPromise;
|
|
4050
|
-
}
|
|
4051
|
-
async function loadDracoDecoder(options) {
|
|
4052
|
-
let DracoDecoderModule;
|
|
4053
|
-
let wasmBinary;
|
|
4054
|
-
switch (options.draco && options.draco.decoderType) {
|
|
4055
|
-
case "js":
|
|
4056
|
-
DracoDecoderModule = await loadLibrary(
|
|
4057
|
-
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER],
|
|
4058
|
-
"draco",
|
|
4059
|
-
options,
|
|
4060
|
-
DRACO_EXTERNAL_LIBRARIES.FALLBACK_DECODER
|
|
4061
|
-
);
|
|
4062
|
-
break;
|
|
4063
|
-
case "wasm":
|
|
4064
|
-
default:
|
|
4065
|
-
[DracoDecoderModule, wasmBinary] = await Promise.all([
|
|
4066
|
-
await loadLibrary(
|
|
4067
|
-
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER],
|
|
4068
|
-
"draco",
|
|
4069
|
-
options,
|
|
4070
|
-
DRACO_EXTERNAL_LIBRARIES.DECODER
|
|
4071
|
-
),
|
|
4072
|
-
await loadLibrary(
|
|
4073
|
-
DRACO_EXTERNAL_LIBRARY_URLS[DRACO_EXTERNAL_LIBRARIES.DECODER_WASM],
|
|
4074
|
-
"draco",
|
|
4075
|
-
options,
|
|
4076
|
-
DRACO_EXTERNAL_LIBRARIES.DECODER_WASM
|
|
4077
|
-
)
|
|
4078
|
-
]);
|
|
4079
|
-
}
|
|
4080
|
-
DracoDecoderModule = DracoDecoderModule || globalThis.DracoDecoderModule;
|
|
4081
|
-
return await initializeDracoDecoder(DracoDecoderModule, wasmBinary);
|
|
4082
|
-
}
|
|
4083
|
-
function initializeDracoDecoder(DracoDecoderModule, wasmBinary) {
|
|
4084
|
-
const options = {};
|
|
4085
|
-
if (wasmBinary) {
|
|
4086
|
-
options.wasmBinary = wasmBinary;
|
|
4076
|
+
// ../draco/src/draco-loader.ts
|
|
4077
|
+
var DracoWorkerLoader = {
|
|
4078
|
+
dataType: null,
|
|
4079
|
+
batchType: null,
|
|
4080
|
+
name: "Draco",
|
|
4081
|
+
id: "draco",
|
|
4082
|
+
module: "draco",
|
|
4083
|
+
// shapes: ['mesh'],
|
|
4084
|
+
version: VERSION5,
|
|
4085
|
+
worker: true,
|
|
4086
|
+
extensions: ["drc"],
|
|
4087
|
+
mimeTypes: ["application/octet-stream"],
|
|
4088
|
+
binary: true,
|
|
4089
|
+
tests: ["DRACO"],
|
|
4090
|
+
options: {
|
|
4091
|
+
draco: {
|
|
4092
|
+
decoderType: typeof WebAssembly === "object" ? "wasm" : "js",
|
|
4093
|
+
// 'js' for IE11
|
|
4094
|
+
libraryPath: "libs/",
|
|
4095
|
+
extraAttributes: {},
|
|
4096
|
+
attributeNameEntry: void 0
|
|
4097
|
+
}
|
|
4087
4098
|
}
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
onModuleLoaded: (draco) => resolve({ draco })
|
|
4092
|
-
// Module is Promise-like. Wrap in object to avoid loop.
|
|
4093
|
-
});
|
|
4094
|
-
});
|
|
4095
|
-
}
|
|
4096
|
-
|
|
4097
|
-
// ../draco/src/index.ts
|
|
4098
|
-
var DracoLoader2 = {
|
|
4099
|
-
...DracoLoader,
|
|
4099
|
+
};
|
|
4100
|
+
var DracoLoader = {
|
|
4101
|
+
...DracoWorkerLoader,
|
|
4100
4102
|
parse
|
|
4101
4103
|
};
|
|
4102
4104
|
async function parse(arrayBuffer, options) {
|
|
@@ -4211,7 +4213,7 @@ var __exports__ = (() => {
|
|
|
4211
4213
|
const bufferCopy = sliceArrayBuffer(buffer.buffer, buffer.byteOffset);
|
|
4212
4214
|
const dracoOptions = { ...options };
|
|
4213
4215
|
delete dracoOptions["3d-tiles"];
|
|
4214
|
-
const decodedData = await parseFromContext(bufferCopy,
|
|
4216
|
+
const decodedData = await parseFromContext(bufferCopy, DracoLoader, dracoOptions, context);
|
|
4215
4217
|
const decodedAttributes = getGLTFAccessors(decodedData.attributes);
|
|
4216
4218
|
for (const [attributeName, decodedAttribute] of Object.entries(decodedAttributes)) {
|
|
4217
4219
|
if (attributeName in primitive.attributes) {
|