@loaders.gl/textures 4.2.0-alpha.3 → 4.2.0-alpha.5
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/basis-loader.js +27 -19
- package/dist/basis-worker-node.js +2 -2
- package/dist/basis-worker.js +2 -2
- package/dist/compressed-texture-loader.js +51 -31
- package/dist/compressed-texture-worker.js +2 -2
- package/dist/compressed-texture-writer.js +32 -19
- package/dist/crunch-loader.js +19 -13
- package/dist/crunch-worker.js +2 -2
- package/dist/dist.dev.js +326 -212
- package/dist/dist.min.js +10 -0
- package/dist/index.cjs +41 -60
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +16 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -13
- package/dist/ktx2-basis-writer-worker-node.js +2 -2
- package/dist/ktx2-basis-writer-worker.js +2 -2
- package/dist/ktx2-basis-writer.js +21 -15
- package/dist/lib/encoders/encode-ktx.js +6 -3
- package/dist/lib/encoders/encode-ktx2-basis-texture.js +38 -33
- package/dist/lib/encoders/encode-texture.d.ts +1 -1
- package/dist/lib/encoders/encode-texture.d.ts.map +1 -1
- package/dist/lib/encoders/encode-texture.js +23 -9
- package/dist/lib/gl-extensions.js +70 -59
- package/dist/lib/parsers/basis-module-loader.js +97 -61
- package/dist/lib/parsers/crunch-module-loader.js +29 -13
- package/dist/lib/parsers/parse-basis.js +217 -205
- package/dist/lib/parsers/parse-compressed-texture.js +20 -11
- package/dist/lib/parsers/parse-crunch.js +89 -59
- package/dist/lib/parsers/parse-dds.js +82 -53
- package/dist/lib/parsers/parse-ktx.js +37 -18
- package/dist/lib/parsers/parse-npy.js +70 -53
- package/dist/lib/parsers/parse-pvr.js +203 -112
- package/dist/lib/texture-api/async-deep-map.js +33 -28
- package/dist/lib/texture-api/deep-load.js +7 -5
- package/dist/lib/texture-api/generate-url.d.ts +1 -1
- package/dist/lib/texture-api/generate-url.d.ts.map +1 -1
- package/dist/lib/texture-api/generate-url.js +12 -10
- package/dist/lib/texture-api/load-image-array.d.ts +1 -1
- package/dist/lib/texture-api/load-image-array.d.ts.map +1 -1
- package/dist/lib/texture-api/load-image-array.js +13 -15
- package/dist/lib/texture-api/load-image-cube.d.ts +1 -1
- package/dist/lib/texture-api/load-image-cube.d.ts.map +1 -1
- package/dist/lib/texture-api/load-image-cube.js +32 -51
- package/dist/lib/texture-api/load-image.d.ts +1 -1
- package/dist/lib/texture-api/load-image.d.ts.map +1 -1
- package/dist/lib/texture-api/load-image.js +30 -36
- package/dist/lib/texture-api/texture-api-types.js +3 -1
- package/dist/lib/utils/extract-mipmap-images.js +43 -29
- package/dist/lib/utils/ktx-format-helper.js +119 -68
- package/dist/lib/utils/texture-formats.js +40 -26
- package/dist/lib/utils/version.js +7 -2
- package/dist/npy-loader.d.ts +1 -1
- package/dist/npy-loader.d.ts.map +1 -1
- package/dist/npy-loader.js +24 -15
- package/dist/npy-worker.js +1 -1
- package/dist/workers/basis-worker-node.js +4 -1
- package/dist/workers/basis-worker.js +3 -1
- package/dist/workers/compressed-texture-worker.js +4 -1
- package/dist/workers/crunch-worker.d.ts +1 -1
- package/dist/workers/crunch-worker.d.ts.map +1 -1
- package/dist/workers/crunch-worker.js +8 -3
- package/dist/workers/ktx2-basis-writer-worker-node.js +23 -26
- package/dist/workers/ktx2-basis-writer-worker.js +22 -26
- package/dist/workers/npy-worker.js +3 -1
- package/package.json +13 -9
- package/dist/basis-loader.js.map +0 -1
- package/dist/compressed-texture-loader.js.map +0 -1
- package/dist/compressed-texture-writer.js.map +0 -1
- package/dist/crunch-loader.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/ktx2-basis-writer.js.map +0 -1
- package/dist/lib/encoders/encode-ktx.js.map +0 -1
- package/dist/lib/encoders/encode-ktx2-basis-texture.js.map +0 -1
- package/dist/lib/encoders/encode-texture.js.map +0 -1
- package/dist/lib/gl-extensions.js.map +0 -1
- package/dist/lib/parsers/basis-module-loader.js.map +0 -1
- package/dist/lib/parsers/crunch-module-loader.js.map +0 -1
- package/dist/lib/parsers/parse-basis.js.map +0 -1
- package/dist/lib/parsers/parse-compressed-texture.js.map +0 -1
- package/dist/lib/parsers/parse-crunch.js.map +0 -1
- package/dist/lib/parsers/parse-dds.js.map +0 -1
- package/dist/lib/parsers/parse-ktx.js.map +0 -1
- package/dist/lib/parsers/parse-npy.js.map +0 -1
- package/dist/lib/parsers/parse-pvr.js.map +0 -1
- package/dist/lib/texture-api/async-deep-map.js.map +0 -1
- package/dist/lib/texture-api/deep-load.js.map +0 -1
- package/dist/lib/texture-api/generate-url.js.map +0 -1
- package/dist/lib/texture-api/load-image-array.js.map +0 -1
- package/dist/lib/texture-api/load-image-cube.js.map +0 -1
- package/dist/lib/texture-api/load-image.js.map +0 -1
- package/dist/lib/texture-api/texture-api-types.js.map +0 -1
- package/dist/lib/utils/extract-mipmap-images.js.map +0 -1
- package/dist/lib/utils/ktx-format-helper.js.map +0 -1
- package/dist/lib/utils/texture-formats.js.map +0 -1
- package/dist/lib/utils/version.js.map +0 -1
- package/dist/libs/libs/README.md +0 -9
- package/dist/libs/libs/basis_encoder.js +0 -21
- package/dist/libs/libs/basis_encoder.wasm +0 -0
- package/dist/libs/libs/basis_transcoder.js +0 -22
- package/dist/libs/libs/basis_transcoder.wasm +0 -0
- package/dist/libs/libs/crunch.js +0 -136
- package/dist/npy-loader.js.map +0 -1
- package/dist/workers/basis-worker-node.js.map +0 -1
- package/dist/workers/basis-worker.js.map +0 -1
- package/dist/workers/compressed-texture-worker.js.map +0 -1
- package/dist/workers/crunch-worker.js.map +0 -1
- package/dist/workers/ktx2-basis-writer-worker-node.js.map +0 -1
- package/dist/workers/ktx2-basis-writer-worker.js.map +0 -1
- package/dist/workers/npy-worker.js.map +0 -1
|
@@ -1,61 +1,72 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
/* eslint-disable camelcase */
|
|
1
5
|
export const GL_EXTENSIONS_CONSTANTS = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
6
|
+
// WEBGL_compressed_texture_s3tc
|
|
7
|
+
COMPRESSED_RGB_S3TC_DXT1_EXT: 0x83f0,
|
|
8
|
+
COMPRESSED_RGBA_S3TC_DXT1_EXT: 0x83f1,
|
|
9
|
+
COMPRESSED_RGBA_S3TC_DXT3_EXT: 0x83f2,
|
|
10
|
+
COMPRESSED_RGBA_S3TC_DXT5_EXT: 0x83f3,
|
|
11
|
+
// WEBGL_compressed_texture_es3
|
|
12
|
+
COMPRESSED_R11_EAC: 0x9270,
|
|
13
|
+
COMPRESSED_SIGNED_R11_EAC: 0x9271,
|
|
14
|
+
COMPRESSED_RG11_EAC: 0x9272,
|
|
15
|
+
COMPRESSED_SIGNED_RG11_EAC: 0x9273,
|
|
16
|
+
COMPRESSED_RGB8_ETC2: 0x9274,
|
|
17
|
+
COMPRESSED_RGBA8_ETC2_EAC: 0x9275,
|
|
18
|
+
COMPRESSED_SRGB8_ETC2: 0x9276,
|
|
19
|
+
COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: 0x9277,
|
|
20
|
+
COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2: 0x9278,
|
|
21
|
+
COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2: 0x9279,
|
|
22
|
+
// WEBGL_compressed_texture_pvrtc
|
|
23
|
+
COMPRESSED_RGB_PVRTC_4BPPV1_IMG: 0x8c00,
|
|
24
|
+
COMPRESSED_RGBA_PVRTC_4BPPV1_IMG: 0x8c02,
|
|
25
|
+
COMPRESSED_RGB_PVRTC_2BPPV1_IMG: 0x8c01,
|
|
26
|
+
COMPRESSED_RGBA_PVRTC_2BPPV1_IMG: 0x8c03,
|
|
27
|
+
// WEBGL_compressed_texture_etc1
|
|
28
|
+
COMPRESSED_RGB_ETC1_WEBGL: 0x8d64,
|
|
29
|
+
// WEBGL_compressed_texture_atc
|
|
30
|
+
COMPRESSED_RGB_ATC_WEBGL: 0x8c92,
|
|
31
|
+
COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL: 0x8c93,
|
|
32
|
+
COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL: 0x87ee,
|
|
33
|
+
// WEBGL_compressed_texture_astc
|
|
34
|
+
COMPRESSED_RGBA_ASTC_4X4_KHR: 0x93b0,
|
|
35
|
+
COMPRESSED_RGBA_ASTC_5X4_KHR: 0x93b1,
|
|
36
|
+
COMPRESSED_RGBA_ASTC_5X5_KHR: 0x93b2,
|
|
37
|
+
COMPRESSED_RGBA_ASTC_6X5_KHR: 0x93b3,
|
|
38
|
+
COMPRESSED_RGBA_ASTC_6X6_KHR: 0x93b4,
|
|
39
|
+
COMPRESSED_RGBA_ASTC_8X5_KHR: 0x93b5,
|
|
40
|
+
COMPRESSED_RGBA_ASTC_8X6_KHR: 0x93b6,
|
|
41
|
+
COMPRESSED_RGBA_ASTC_8X8_KHR: 0x93b7,
|
|
42
|
+
COMPRESSED_RGBA_ASTC_10X5_KHR: 0x93b8,
|
|
43
|
+
COMPRESSED_RGBA_ASTC_10X6_KHR: 0x93b9,
|
|
44
|
+
COMPRESSED_RGBA_ASTC_10X8_KHR: 0x93ba,
|
|
45
|
+
COMPRESSED_RGBA_ASTC_10X10_KHR: 0x93bb,
|
|
46
|
+
COMPRESSED_RGBA_ASTC_12X10_KHR: 0x93bc,
|
|
47
|
+
COMPRESSED_RGBA_ASTC_12X12_KHR: 0x93bd,
|
|
48
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR: 0x93d0,
|
|
49
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR: 0x93d1,
|
|
50
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR: 0x93d2,
|
|
51
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR: 0x93d3,
|
|
52
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR: 0x93d4,
|
|
53
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR: 0x93d5,
|
|
54
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR: 0x93d6,
|
|
55
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR: 0x93d7,
|
|
56
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR: 0x93d8,
|
|
57
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR: 0x93d9,
|
|
58
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR: 0x93da,
|
|
59
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR: 0x93db,
|
|
60
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR: 0x93dc,
|
|
61
|
+
COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR: 0x93dd,
|
|
62
|
+
// EXT_texture_compression_rgtc
|
|
63
|
+
COMPRESSED_RED_RGTC1_EXT: 0x8dbb,
|
|
64
|
+
COMPRESSED_SIGNED_RED_RGTC1_EXT: 0x8dbc,
|
|
65
|
+
COMPRESSED_RED_GREEN_RGTC2_EXT: 0x8dbd,
|
|
66
|
+
COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT: 0x8dbe,
|
|
67
|
+
// WEBGL_compressed_texture_s3tc_srgb
|
|
68
|
+
COMPRESSED_SRGB_S3TC_DXT1_EXT: 0x8c4c,
|
|
69
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: 0x8c4d,
|
|
70
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT: 0x8c4e,
|
|
71
|
+
COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT: 0x8c4f
|
|
60
72
|
};
|
|
61
|
-
//# sourceMappingURL=gl-extensions.js.map
|
|
@@ -1,80 +1,116 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
1
4
|
import { loadLibrary } from '@loaders.gl/worker-utils';
|
|
2
5
|
export const BASIS_EXTERNAL_LIBRARIES = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
/** Basis transcoder, javascript wrapper part */
|
|
7
|
+
TRANSCODER: 'basis_transcoder.js',
|
|
8
|
+
/** Basis transcoder, compiled web assembly part */
|
|
9
|
+
TRANSCODER_WASM: 'basis_transcoder.wasm',
|
|
10
|
+
/** Basis encoder, javascript wrapper part */
|
|
11
|
+
ENCODER: 'basis_encoder.js',
|
|
12
|
+
/** Basis encoder, compiled web assembly part */
|
|
13
|
+
ENCODER_WASM: 'basis_encoder.wasm'
|
|
7
14
|
};
|
|
8
15
|
let loadBasisTranscoderPromise;
|
|
16
|
+
/**
|
|
17
|
+
* Loads wasm transcoder module
|
|
18
|
+
* @param options
|
|
19
|
+
* @returns {BasisFile} promise
|
|
20
|
+
*/
|
|
9
21
|
export async function loadBasisTranscoderModule(options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
const modules = options.modules || {};
|
|
23
|
+
if (modules.basis) {
|
|
24
|
+
return modules.basis;
|
|
25
|
+
}
|
|
26
|
+
loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
|
|
27
|
+
return await loadBasisTranscoderPromise;
|
|
16
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Loads wasm transcoder module
|
|
31
|
+
* @param options
|
|
32
|
+
* @returns {BasisFile} promise
|
|
33
|
+
*/
|
|
17
34
|
async function loadBasisTranscoder(options) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
let BASIS = null;
|
|
36
|
+
let wasmBinary = null;
|
|
37
|
+
[BASIS, wasmBinary] = await Promise.all([
|
|
38
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, 'textures', options),
|
|
39
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, 'textures', options)
|
|
40
|
+
]);
|
|
41
|
+
// Depends on how import happened...
|
|
42
|
+
// @ts-ignore TS2339: Property does not exist on type
|
|
43
|
+
BASIS = BASIS || globalThis.BASIS;
|
|
44
|
+
return await initializeBasisTranscoderModule(BASIS, wasmBinary);
|
|
23
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Initialize wasm transcoder module
|
|
48
|
+
* @param BasisModule - js part of the module
|
|
49
|
+
* @param wasmBinary - wasm part of the module
|
|
50
|
+
* @returns {BasisFile} promise
|
|
51
|
+
*/
|
|
24
52
|
function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
resolve({
|
|
37
|
-
BasisFile
|
|
38
|
-
});
|
|
53
|
+
const options = {};
|
|
54
|
+
if (wasmBinary) {
|
|
55
|
+
options.wasmBinary = wasmBinary;
|
|
56
|
+
}
|
|
57
|
+
return new Promise((resolve) => {
|
|
58
|
+
// if you try to return BasisModule the browser crashes!
|
|
59
|
+
BasisModule(options).then((module) => {
|
|
60
|
+
const { BasisFile, initializeBasis } = module;
|
|
61
|
+
initializeBasis();
|
|
62
|
+
resolve({ BasisFile });
|
|
63
|
+
});
|
|
39
64
|
});
|
|
40
|
-
});
|
|
41
65
|
}
|
|
42
66
|
let loadBasisEncoderPromise;
|
|
67
|
+
/**
|
|
68
|
+
* Loads wasm encoder module
|
|
69
|
+
* @param options
|
|
70
|
+
* @returns {BasisFile, KTX2File} promise
|
|
71
|
+
*/
|
|
43
72
|
export async function loadBasisEncoderModule(options) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
73
|
+
const modules = options.modules || {};
|
|
74
|
+
if (modules.basisEncoder) {
|
|
75
|
+
return modules.basisEncoder;
|
|
76
|
+
}
|
|
77
|
+
loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
|
|
78
|
+
return await loadBasisEncoderPromise;
|
|
50
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Loads wasm encoder module
|
|
82
|
+
* @param options
|
|
83
|
+
* @returns {BasisFile, KTX2File} promise
|
|
84
|
+
*/
|
|
51
85
|
async function loadBasisEncoder(options) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
86
|
+
let BASIS_ENCODER = null;
|
|
87
|
+
let wasmBinary = null;
|
|
88
|
+
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
89
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, 'textures', options),
|
|
90
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, 'textures', options)
|
|
91
|
+
]);
|
|
92
|
+
// Depends on how import happened...
|
|
93
|
+
// @ts-ignore TS2339: Property does not exist on type
|
|
94
|
+
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
95
|
+
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
57
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Initialize wasm transcoder module
|
|
99
|
+
* @param BasisEncoderModule - js part of the module
|
|
100
|
+
* @param wasmBinary - wasm part of the module
|
|
101
|
+
* @returns {BasisFile, KTX2File} promise
|
|
102
|
+
*/
|
|
58
103
|
function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
} = module;
|
|
71
|
-
initializeBasis();
|
|
72
|
-
resolve({
|
|
73
|
-
BasisFile,
|
|
74
|
-
KTX2File,
|
|
75
|
-
BasisEncoder
|
|
76
|
-
});
|
|
104
|
+
const options = {};
|
|
105
|
+
if (wasmBinary) {
|
|
106
|
+
options.wasmBinary = wasmBinary;
|
|
107
|
+
}
|
|
108
|
+
return new Promise((resolve) => {
|
|
109
|
+
// if you try to return BasisModule the browser crashes!
|
|
110
|
+
BasisEncoderModule(options).then((module) => {
|
|
111
|
+
const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
|
|
112
|
+
initializeBasis();
|
|
113
|
+
resolve({ BasisFile, KTX2File, BasisEncoder });
|
|
114
|
+
});
|
|
77
115
|
});
|
|
78
|
-
});
|
|
79
116
|
}
|
|
80
|
-
//# sourceMappingURL=basis-module-loader.js.map
|
|
@@ -1,22 +1,38 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
// @ts-nocheck
|
|
1
5
|
import { loadLibrary } from '@loaders.gl/worker-utils';
|
|
2
6
|
export const CRUNCH_EXTERNAL_LIBRARIES = {
|
|
3
|
-
|
|
7
|
+
/** Crunch decoder library. It is used as dynamically imported script */
|
|
8
|
+
DECODER: 'crunch.js'
|
|
4
9
|
};
|
|
10
|
+
/**
|
|
11
|
+
* Load crunch decoder module
|
|
12
|
+
* @param options - loader options
|
|
13
|
+
* @returns Promise of module object
|
|
14
|
+
*/
|
|
5
15
|
export async function loadCrunchModule(options) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
const modules = options.modules || {};
|
|
17
|
+
if (modules.crunch) {
|
|
18
|
+
return modules.crunch;
|
|
19
|
+
}
|
|
20
|
+
return loadCrunch(options);
|
|
11
21
|
}
|
|
12
22
|
let crunchModule;
|
|
23
|
+
/**
|
|
24
|
+
* Load crunch decoder module
|
|
25
|
+
* @param {any} options - Loader options
|
|
26
|
+
* @returns {Promise<any>} Promise of Module object
|
|
27
|
+
*/
|
|
13
28
|
async function loadCrunch(options) {
|
|
14
|
-
|
|
29
|
+
if (crunchModule) {
|
|
30
|
+
return crunchModule;
|
|
31
|
+
}
|
|
32
|
+
let loadCrunchDecoder = await loadLibrary(CRUNCH_EXTERNAL_LIBRARIES.DECODER, 'textures', options);
|
|
33
|
+
// Depends on how import happened...
|
|
34
|
+
// @ts-ignore TS2339: Property does not exist on type
|
|
35
|
+
loadCrunchDecoder = loadCrunchDecoder || globalThis.LoadCrunchDecoder;
|
|
36
|
+
crunchModule = loadCrunchDecoder();
|
|
15
37
|
return crunchModule;
|
|
16
|
-
}
|
|
17
|
-
let loadCrunchDecoder = await loadLibrary(CRUNCH_EXTERNAL_LIBRARIES.DECODER, 'textures', options);
|
|
18
|
-
loadCrunchDecoder = loadCrunchDecoder || globalThis.LoadCrunchDecoder;
|
|
19
|
-
crunchModule = loadCrunchDecoder();
|
|
20
|
-
return crunchModule;
|
|
21
38
|
}
|
|
22
|
-
//# sourceMappingURL=crunch-module-loader.js.map
|