@loaders.gl/textures 3.1.0-alpha.4 → 3.1.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/basis-loader.d.ts +50 -0
- package/dist/basis-loader.d.ts.map +1 -0
- package/dist/basis-loader.js +40 -0
- package/dist/basis-worker.js +675 -2
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +2107 -0
- package/dist/compressed-texture-loader.d.ts +63 -0
- package/dist/compressed-texture-loader.d.ts.map +1 -0
- package/dist/compressed-texture-loader.js +64 -0
- package/dist/compressed-texture-worker.js +1179 -2
- package/dist/compressed-texture-writer.d.ts +25 -0
- package/dist/compressed-texture-writer.d.ts.map +1 -0
- package/dist/compressed-texture-writer.js +28 -0
- package/dist/crunch-loader.d.ts +21 -0
- package/dist/crunch-loader.d.ts.map +1 -0
- package/dist/crunch-loader.js +25 -0
- package/dist/crunch-worker.js +486 -2
- package/dist/es5/basis-loader.js +5 -13
- package/dist/es5/basis-loader.js.map +1 -1
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/compressed-texture-loader.js +20 -59
- package/dist/es5/compressed-texture-loader.js.map +1 -1
- package/dist/es5/compressed-texture-writer.js +2 -2
- package/dist/es5/compressed-texture-writer.js.map +1 -1
- package/dist/es5/crunch-loader.js +2 -2
- package/dist/es5/crunch-loader.js.map +1 -1
- package/dist/es5/index.js +26 -18
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/ktx2-basis-universal-texture-writer.js +29 -0
- package/dist/es5/ktx2-basis-universal-texture-writer.js.map +1 -0
- package/dist/es5/lib/encoders/encode-ktx.js +1 -1
- package/dist/es5/lib/encoders/encode-ktx.js.map +1 -1
- package/dist/es5/lib/encoders/encode-ktx2-basis-texture.js +43 -0
- package/dist/es5/lib/encoders/encode-ktx2-basis-texture.js.map +1 -0
- package/dist/es5/lib/encoders/encode-texture.js +13 -41
- package/dist/es5/lib/encoders/encode-texture.js.map +1 -1
- package/dist/es5/lib/{gl-constants.js → gl-extensions.js} +4 -4
- package/dist/es5/lib/gl-extensions.js.map +1 -0
- package/dist/es5/lib/parsers/basis-module-loader.js +51 -190
- package/dist/es5/lib/parsers/basis-module-loader.js.map +1 -1
- package/dist/es5/lib/parsers/crunch-module-loader.js +15 -71
- package/dist/es5/lib/parsers/crunch-module-loader.js.map +1 -1
- package/dist/es5/lib/parsers/parse-basis.js +86 -138
- package/dist/es5/lib/parsers/parse-basis.js.map +1 -1
- package/dist/es5/lib/parsers/parse-crunch.js +59 -80
- package/dist/es5/lib/parsers/parse-crunch.js.map +1 -1
- package/dist/es5/lib/parsers/parse-dds.js +39 -39
- package/dist/es5/lib/parsers/parse-dds.js.map +1 -1
- package/dist/es5/lib/parsers/parse-ktx.js +14 -16
- package/dist/es5/lib/parsers/parse-ktx.js.map +1 -1
- package/dist/es5/lib/parsers/parse-npy.js +27 -28
- package/dist/es5/lib/parsers/parse-npy.js.map +1 -1
- package/dist/es5/lib/parsers/parse-pvr.js +49 -49
- package/dist/es5/lib/parsers/parse-pvr.js.map +1 -1
- package/dist/es5/lib/texture-api/async-deep-map.js +27 -156
- package/dist/es5/lib/texture-api/async-deep-map.js.map +1 -1
- package/dist/es5/lib/texture-api/deep-load.js +6 -67
- package/dist/es5/lib/texture-api/deep-load.js.map +1 -1
- package/dist/es5/lib/texture-api/generate-url.js +4 -16
- package/dist/es5/lib/texture-api/generate-url.js.map +1 -1
- package/dist/es5/lib/texture-api/load-image-array.js +12 -76
- package/dist/es5/lib/texture-api/load-image-array.js.map +1 -1
- package/dist/es5/lib/texture-api/load-image-cube.js +27 -96
- package/dist/es5/lib/texture-api/load-image-cube.js.map +1 -1
- package/dist/es5/lib/texture-api/load-image.js +37 -146
- package/dist/es5/lib/texture-api/load-image.js.map +1 -1
- package/dist/es5/lib/texture-api/texture-api-types.js +2 -0
- package/dist/es5/lib/texture-api/texture-api-types.js.map +1 -0
- package/dist/es5/lib/utils/extract-mipmap-images.js +9 -9
- package/dist/es5/lib/utils/extract-mipmap-images.js.map +1 -1
- package/dist/es5/lib/utils/ktx-format-helper.js +68 -68
- package/dist/es5/lib/utils/ktx-format-helper.js.map +1 -1
- package/dist/es5/lib/utils/texture-formats.js +9 -27
- package/dist/es5/lib/utils/texture-formats.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/lib/utils/version.js.map +1 -1
- package/dist/es5/libs/README.md +2 -2
- package/dist/es5/libs/basis_encoder.js +1 -1
- package/dist/es5/libs/basis_transcoder.js +1 -1
- package/dist/es5/libs/crunch.js +1 -0
- package/dist/es5/npy-loader.js +7 -42
- package/dist/es5/npy-loader.js.map +1 -1
- package/dist/es5/workers/crunch-worker.js +2 -11
- package/dist/es5/workers/crunch-worker.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/ktx2-basis-universal-texture-writer.js +18 -0
- package/dist/esm/ktx2-basis-universal-texture-writer.js.map +1 -0
- package/dist/esm/lib/encoders/encode-ktx2-basis-texture.js +35 -0
- package/dist/esm/lib/encoders/encode-ktx2-basis-texture.js.map +1 -0
- package/dist/esm/lib/encoders/encode-texture.js +1 -1
- package/dist/esm/lib/encoders/encode-texture.js.map +1 -1
- package/dist/esm/lib/{gl-constants.js → gl-extensions.js} +2 -2
- package/dist/esm/lib/gl-extensions.js.map +1 -0
- package/dist/esm/lib/parsers/basis-module-loader.js +8 -3
- package/dist/esm/lib/parsers/basis-module-loader.js.map +1 -1
- package/dist/esm/lib/parsers/crunch-module-loader.js.map +1 -1
- package/dist/esm/lib/parsers/parse-basis.js +8 -8
- package/dist/esm/lib/parsers/parse-basis.js.map +1 -1
- package/dist/esm/lib/parsers/parse-crunch.js +4 -4
- package/dist/esm/lib/parsers/parse-crunch.js.map +1 -1
- package/dist/esm/lib/parsers/parse-dds.js +24 -24
- package/dist/esm/lib/parsers/parse-dds.js.map +1 -1
- package/dist/esm/lib/parsers/parse-ktx.js +2 -2
- package/dist/esm/lib/parsers/parse-ktx.js.map +1 -1
- package/dist/esm/lib/parsers/parse-npy.js +4 -2
- package/dist/esm/lib/parsers/parse-npy.js.map +1 -1
- package/dist/esm/lib/parsers/parse-pvr.js +28 -28
- package/dist/esm/lib/parsers/parse-pvr.js.map +1 -1
- package/dist/esm/lib/texture-api/async-deep-map.js.map +1 -1
- package/dist/esm/lib/texture-api/deep-load.js.map +1 -1
- package/dist/esm/lib/texture-api/generate-url.js +6 -14
- package/dist/esm/lib/texture-api/generate-url.js.map +1 -1
- package/dist/esm/lib/texture-api/load-image-array.js.map +1 -1
- package/dist/esm/lib/texture-api/load-image-cube.js.map +1 -1
- package/dist/esm/lib/texture-api/load-image.js +2 -5
- package/dist/esm/lib/texture-api/load-image.js.map +1 -1
- package/dist/esm/lib/texture-api/texture-api-types.js +2 -0
- package/dist/esm/lib/texture-api/texture-api-types.js.map +1 -0
- package/dist/esm/lib/utils/extract-mipmap-images.js.map +1 -1
- package/dist/esm/lib/utils/ktx-format-helper.js +67 -67
- package/dist/esm/lib/utils/ktx-format-helper.js.map +1 -1
- package/dist/esm/lib/utils/texture-formats.js +1 -1
- package/dist/esm/lib/utils/texture-formats.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/esm/lib/utils/version.js.map +1 -1
- package/dist/esm/libs/README.md +2 -2
- package/dist/esm/libs/basis_encoder.js +1 -1
- package/dist/esm/libs/basis_transcoder.js +1 -1
- package/dist/esm/libs/crunch.js +1 -0
- package/dist/esm/npy-loader.js.map +1 -1
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/ktx2-basis-universal-texture-writer.d.ts +22 -0
- package/dist/ktx2-basis-universal-texture-writer.d.ts.map +1 -0
- package/dist/ktx2-basis-universal-texture-writer.js +25 -0
- package/dist/lib/encoders/encode-ktx.d.ts +2 -0
- package/dist/lib/encoders/encode-ktx.d.ts.map +1 -0
- package/dist/lib/encoders/encode-ktx.js +10 -0
- package/dist/lib/encoders/encode-ktx2-basis-texture.d.ts +10 -0
- package/dist/lib/encoders/encode-ktx2-basis-texture.d.ts.map +1 -0
- package/dist/lib/encoders/encode-ktx2-basis-texture.js +41 -0
- package/dist/lib/encoders/encode-texture.d.ts +2 -0
- package/dist/lib/encoders/encode-texture.d.ts.map +1 -0
- package/dist/lib/encoders/encode-texture.js +30 -0
- package/dist/lib/gl-extensions.d.ts +61 -0
- package/dist/lib/gl-extensions.d.ts.map +1 -0
- package/dist/lib/gl-extensions.js +72 -0
- package/dist/lib/parsers/basis-module-loader.d.ts +13 -0
- package/dist/lib/parsers/basis-module-loader.d.ts.map +1 -0
- package/dist/lib/parsers/basis-module-loader.js +114 -0
- package/dist/lib/parsers/crunch-module-loader.d.ts +7 -0
- package/dist/lib/parsers/crunch-module-loader.d.ts.map +1 -0
- package/dist/lib/parsers/crunch-module-loader.js +35 -0
- package/dist/lib/parsers/parse-basis.d.ts +30 -0
- package/dist/lib/parsers/parse-basis.d.ts.map +1 -0
- package/dist/lib/parsers/parse-basis.js +245 -0
- package/dist/lib/parsers/parse-compressed-texture.d.ts +8 -0
- package/dist/lib/parsers/parse-compressed-texture.d.ts.map +1 -0
- package/dist/lib/parsers/parse-compressed-texture.js +26 -0
- package/dist/lib/parsers/parse-crunch.d.ts +9 -0
- package/dist/lib/parsers/parse-crunch.d.ts.map +1 -0
- package/dist/lib/parsers/parse-crunch.js +105 -0
- package/dist/lib/parsers/parse-dds.d.ts +28 -0
- package/dist/lib/parsers/parse-dds.d.ts.map +1 -0
- package/dist/lib/parsers/parse-dds.js +108 -0
- package/dist/lib/parsers/parse-ktx.d.ts +3 -0
- package/dist/lib/parsers/parse-ktx.d.ts.map +1 -0
- package/dist/lib/parsers/parse-ktx.js +46 -0
- package/dist/lib/parsers/parse-npy.d.ts +10 -0
- package/dist/lib/parsers/parse-npy.d.ts.map +1 -0
- package/dist/lib/parsers/parse-npy.js +85 -0
- package/dist/lib/parsers/parse-pvr.d.ts +15 -0
- package/dist/lib/parsers/parse-pvr.d.ts.map +1 -0
- package/dist/lib/parsers/parse-pvr.js +250 -0
- package/dist/lib/texture-api/async-deep-map.d.ts +5 -0
- package/dist/lib/texture-api/async-deep-map.d.ts.map +1 -0
- package/dist/lib/texture-api/async-deep-map.js +41 -0
- package/dist/lib/texture-api/deep-load.d.ts +5 -0
- package/dist/lib/texture-api/deep-load.d.ts.map +1 -0
- package/dist/lib/texture-api/deep-load.js +16 -0
- package/dist/lib/texture-api/generate-url.d.ts +3 -0
- package/dist/lib/texture-api/generate-url.d.ts.map +1 -0
- package/dist/lib/texture-api/generate-url.js +17 -0
- package/dist/lib/texture-api/load-image-array.d.ts +4 -0
- package/dist/lib/texture-api/load-image-array.d.ts.map +1 -0
- package/dist/lib/texture-api/load-image-array.js +21 -0
- package/dist/lib/texture-api/load-image-cube.d.ts +12 -0
- package/dist/lib/texture-api/load-image-cube.d.ts.map +1 -0
- package/dist/lib/texture-api/load-image-cube.js +47 -0
- package/dist/lib/texture-api/load-image.d.ts +8 -0
- package/dist/lib/texture-api/load-image.d.ts.map +1 -0
- package/dist/lib/texture-api/load-image.js +43 -0
- package/dist/lib/texture-api/texture-api-types.d.ts +10 -0
- package/dist/lib/texture-api/texture-api-types.d.ts.map +1 -0
- package/dist/lib/texture-api/texture-api-types.js +3 -0
- package/dist/lib/utils/extract-mipmap-images.d.ts +13 -0
- package/dist/lib/utils/extract-mipmap-images.d.ts.map +1 -0
- package/dist/lib/utils/extract-mipmap-images.js +50 -0
- package/dist/lib/utils/ktx-format-helper.d.ts +9 -0
- package/dist/lib/utils/ktx-format-helper.d.ts.map +1 -0
- package/dist/lib/utils/ktx-format-helper.js +125 -0
- package/dist/lib/utils/texture-formats.d.ts +8 -0
- package/dist/lib/utils/texture-formats.d.ts.map +1 -0
- package/dist/lib/utils/texture-formats.js +51 -0
- package/dist/lib/utils/version.d.ts +2 -0
- package/dist/lib/utils/version.d.ts.map +1 -0
- package/dist/lib/utils/version.js +8 -0
- package/dist/libs/README.md +2 -2
- package/dist/libs/basis_encoder.js +1 -1
- package/dist/libs/basis_transcoder.js +1 -1
- package/dist/libs/crunch.js +1 -0
- package/dist/npy-loader.d.ts +45 -0
- package/dist/npy-loader.d.ts.map +1 -0
- package/dist/npy-loader.js +34 -0
- package/dist/npy-worker.js +240 -2
- package/dist/types.d.ts +21 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/workers/basis-worker.d.ts +2 -0
- package/dist/workers/basis-worker.d.ts.map +1 -0
- package/dist/workers/basis-worker.js +5 -0
- package/dist/workers/compressed-texture-worker.d.ts +2 -0
- package/dist/workers/compressed-texture-worker.d.ts.map +1 -0
- package/dist/workers/compressed-texture-worker.js +5 -0
- package/dist/workers/crunch-worker.d.ts +21 -0
- package/dist/workers/crunch-worker.d.ts.map +1 -0
- package/dist/workers/crunch-worker.js +14 -0
- package/dist/workers/npy-worker.d.ts +2 -0
- package/dist/workers/npy-worker.d.ts.map +1 -0
- package/dist/workers/npy-worker.js +5 -0
- package/package.json +11 -11
- package/src/index.ts +2 -1
- package/src/ktx2-basis-universal-texture-writer.ts +27 -0
- package/src/lib/encoders/encode-ktx2-basis-texture.ts +44 -0
- package/src/lib/{gl-constants.ts → gl-extensions.ts} +1 -1
- package/src/lib/parsers/basis-module-loader.ts +12 -4
- package/src/lib/parsers/crunch-module-loader.ts +1 -0
- package/src/lib/parsers/parse-basis.js +32 -8
- package/src/lib/parsers/parse-crunch.ts +4 -4
- package/src/lib/parsers/parse-dds.ts +29 -26
- package/src/lib/parsers/parse-ktx.js +3 -6
- package/src/lib/parsers/parse-ktx.ts +47 -0
- package/src/lib/parsers/parse-npy.js +3 -17
- package/src/lib/parsers/parse-npy.ts +98 -0
- package/src/lib/parsers/parse-pvr.ts +90 -48
- package/src/lib/texture-api/async-deep-map.ts +15 -8
- package/src/lib/texture-api/deep-load.ts +7 -3
- package/src/lib/texture-api/generate-url.ts +10 -8
- package/src/lib/texture-api/load-image-array.ts +8 -2
- package/src/lib/texture-api/load-image-cube.ts +18 -4
- package/src/lib/texture-api/load-image.ts +15 -5
- package/src/lib/texture-api/texture-api-types.ts +12 -0
- package/src/lib/utils/extract-mipmap-images.ts +16 -3
- package/src/lib/utils/ktx-format-helper.ts +71 -71
- package/src/libs/README.md +2 -2
- package/src/libs/basis_encoder.js +1 -1
- package/src/libs/basis_transcoder.js +1 -1
- package/src/libs/crunch.js +1 -0
- package/src/npy-loader.ts +2 -2
- package/dist/basis-worker.js.map +0 -1
- package/dist/compressed-texture-worker.js.map +0 -1
- package/dist/crunch-worker.js.map +0 -1
- package/dist/dist.min.js +0 -2
- package/dist/dist.min.js.map +0 -1
- package/dist/es5/lib/gl-constants.js.map +0 -1
- package/dist/esm/lib/gl-constants.js.map +0 -1
- package/dist/npy-worker.js.map +0 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GL_EXTENSIONS_CONSTANTS = void 0;
|
|
4
|
+
/* eslint-disable camelcase */
|
|
5
|
+
exports.GL_EXTENSIONS_CONSTANTS = {
|
|
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
|
|
72
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads wasm transcoder module
|
|
3
|
+
* @param options
|
|
4
|
+
* @returns {BasisFile} promise
|
|
5
|
+
*/
|
|
6
|
+
export declare function loadBasisTrascoderModule(options: any): Promise<any>;
|
|
7
|
+
/**
|
|
8
|
+
* Loads wasm encoder module
|
|
9
|
+
* @param options
|
|
10
|
+
* @returns {BasisFile, KTX2File} promise
|
|
11
|
+
*/
|
|
12
|
+
export declare function loadBasisEncoderModule(options: any): Promise<any>;
|
|
13
|
+
//# sourceMappingURL=basis-module-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basis-module-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/basis-module-loader.ts"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,KAAA,gBAQrD;AA+CD;;;;GAIG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,KAAA,gBAQnD"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadBasisEncoderModule = exports.loadBasisTrascoderModule = void 0;
|
|
4
|
+
// __VERSION__ is injected by babel-plugin-version-inline
|
|
5
|
+
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
6
|
+
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
|
|
7
|
+
// @ts-nocheck
|
|
8
|
+
const worker_utils_1 = require("@loaders.gl/worker-utils");
|
|
9
|
+
const BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION}/dist/libs/basis_encoder.wasm`;
|
|
10
|
+
const BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION}/dist/libs/basis_encoder.js`;
|
|
11
|
+
let loadBasisTranscoderPromise;
|
|
12
|
+
/**
|
|
13
|
+
* Loads wasm transcoder module
|
|
14
|
+
* @param options
|
|
15
|
+
* @returns {BasisFile} promise
|
|
16
|
+
*/
|
|
17
|
+
async function loadBasisTrascoderModule(options) {
|
|
18
|
+
const modules = options.modules || {};
|
|
19
|
+
if (modules.basis) {
|
|
20
|
+
return modules.basis;
|
|
21
|
+
}
|
|
22
|
+
loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTrascoder(options);
|
|
23
|
+
return await loadBasisTranscoderPromise;
|
|
24
|
+
}
|
|
25
|
+
exports.loadBasisTrascoderModule = loadBasisTrascoderModule;
|
|
26
|
+
/**
|
|
27
|
+
* Loads wasm transcoder module
|
|
28
|
+
* @param options
|
|
29
|
+
* @returns {BasisFile} promise
|
|
30
|
+
*/
|
|
31
|
+
async function loadBasisTrascoder(options) {
|
|
32
|
+
let BASIS = null;
|
|
33
|
+
let wasmBinary = null;
|
|
34
|
+
[BASIS, wasmBinary] = await Promise.all([
|
|
35
|
+
await (0, worker_utils_1.loadLibrary)('basis_transcoder.js', 'textures', options),
|
|
36
|
+
await (0, worker_utils_1.loadLibrary)('basis_transcoder.wasm', 'textures', options)
|
|
37
|
+
]);
|
|
38
|
+
// Depends on how import happened...
|
|
39
|
+
// @ts-ignore TS2339: Property does not exist on type
|
|
40
|
+
BASIS = BASIS || globalThis.BASIS;
|
|
41
|
+
return await initializeBasisTrascoderModule(BASIS, wasmBinary);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Initialize wasm transcoder module
|
|
45
|
+
* @param BasisModule - js part of the module
|
|
46
|
+
* @param wasmBinary - wasm part of the module
|
|
47
|
+
* @returns {BasisFile} promise
|
|
48
|
+
*/
|
|
49
|
+
function initializeBasisTrascoderModule(BasisModule, wasmBinary) {
|
|
50
|
+
const options = {};
|
|
51
|
+
if (wasmBinary) {
|
|
52
|
+
options.wasmBinary = wasmBinary;
|
|
53
|
+
}
|
|
54
|
+
return new Promise((resolve) => {
|
|
55
|
+
// if you try to return BasisModule the browser crashes!
|
|
56
|
+
BasisModule(options).then((module) => {
|
|
57
|
+
const { BasisFile, initializeBasis } = module;
|
|
58
|
+
initializeBasis();
|
|
59
|
+
resolve({ BasisFile });
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
let loadBasisEncoderPromise;
|
|
64
|
+
/**
|
|
65
|
+
* Loads wasm encoder module
|
|
66
|
+
* @param options
|
|
67
|
+
* @returns {BasisFile, KTX2File} promise
|
|
68
|
+
*/
|
|
69
|
+
async function loadBasisEncoderModule(options) {
|
|
70
|
+
const modules = options.modules || {};
|
|
71
|
+
if (modules.basisEncoder) {
|
|
72
|
+
return modules.basisEncoder;
|
|
73
|
+
}
|
|
74
|
+
loadBasisEncoderPromise = loadBasisEncoderPromise || loadBasisEncoder(options);
|
|
75
|
+
return await loadBasisEncoderPromise;
|
|
76
|
+
}
|
|
77
|
+
exports.loadBasisEncoderModule = loadBasisEncoderModule;
|
|
78
|
+
/**
|
|
79
|
+
* Loads wasm encoder module
|
|
80
|
+
* @param options
|
|
81
|
+
* @returns {BasisFile, KTX2File} promise
|
|
82
|
+
*/
|
|
83
|
+
async function loadBasisEncoder(options) {
|
|
84
|
+
let BASIS_ENCODER = null;
|
|
85
|
+
let wasmBinary = null;
|
|
86
|
+
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
87
|
+
await (0, worker_utils_1.loadLibrary)(BASIS_CDN_ENCODER_JS, 'textures', options),
|
|
88
|
+
await (0, worker_utils_1.loadLibrary)(BASIS_CDN_ENCODER_WASM, 'textures', options)
|
|
89
|
+
]);
|
|
90
|
+
// Depends on how import happened...
|
|
91
|
+
// @ts-ignore TS2339: Property does not exist on type
|
|
92
|
+
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
93
|
+
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Initialize wasm transcoder module
|
|
97
|
+
* @param BasisEncoderModule - js part of the module
|
|
98
|
+
* @param wasmBinary - wasm part of the module
|
|
99
|
+
* @returns {BasisFile, KTX2File} promise
|
|
100
|
+
*/
|
|
101
|
+
function initializeBasisEncoderModule(BasisEncoderModule, wasmBinary) {
|
|
102
|
+
const options = {};
|
|
103
|
+
if (wasmBinary) {
|
|
104
|
+
options.wasmBinary = wasmBinary;
|
|
105
|
+
}
|
|
106
|
+
return new Promise((resolve) => {
|
|
107
|
+
// if you try to return BasisModule the browser crashes!
|
|
108
|
+
BasisEncoderModule(options).then((module) => {
|
|
109
|
+
const { BasisFile, KTX2File, initializeBasis, BasisEncoder } = module;
|
|
110
|
+
initializeBasis();
|
|
111
|
+
resolve({ BasisFile, KTX2File, BasisEncoder });
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crunch-module-loader.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/crunch-module-loader.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,KAAA,GAAG,OAAO,CAAC,GAAG,CAAC,CAO5D"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadCrunchModule = void 0;
|
|
4
|
+
// @ts-nocheck
|
|
5
|
+
const worker_utils_1 = require("@loaders.gl/worker-utils");
|
|
6
|
+
/**
|
|
7
|
+
* Load crunch decoder module
|
|
8
|
+
* @param options - loader options
|
|
9
|
+
* @returns Promise of module object
|
|
10
|
+
*/
|
|
11
|
+
async function loadCrunchModule(options) {
|
|
12
|
+
const modules = options.modules || {};
|
|
13
|
+
if (modules.crunch) {
|
|
14
|
+
return modules.crunch;
|
|
15
|
+
}
|
|
16
|
+
return loadCrunch(options);
|
|
17
|
+
}
|
|
18
|
+
exports.loadCrunchModule = loadCrunchModule;
|
|
19
|
+
let crunchModule;
|
|
20
|
+
/**
|
|
21
|
+
* Load crunch decoder module
|
|
22
|
+
* @param {any} options - Loader options
|
|
23
|
+
* @returns {Promise<any>} Promise of Module object
|
|
24
|
+
*/
|
|
25
|
+
async function loadCrunch(options) {
|
|
26
|
+
if (crunchModule) {
|
|
27
|
+
return crunchModule;
|
|
28
|
+
}
|
|
29
|
+
let loadCrunchDecoder = await (0, worker_utils_1.loadLibrary)('crunch.js', 'textures', options);
|
|
30
|
+
// Depends on how import happened...
|
|
31
|
+
// @ts-ignore TS2339: Property does not exist on type
|
|
32
|
+
loadCrunchDecoder = loadCrunchDecoder || globalThis.loadCrunchDecoder;
|
|
33
|
+
crunchModule = loadCrunchDecoder();
|
|
34
|
+
return crunchModule;
|
|
35
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* parse data with a Binomial Basis_Universal module
|
|
3
|
+
* @param {ArrayBuffer} data
|
|
4
|
+
* @param {*} options
|
|
5
|
+
* @returns compressed texture data
|
|
6
|
+
*/
|
|
7
|
+
export default function parseBasis(data: ArrayBuffer, options: any): Promise<({
|
|
8
|
+
width: any;
|
|
9
|
+
height: any;
|
|
10
|
+
data: Uint8Array;
|
|
11
|
+
compressed: any;
|
|
12
|
+
alphaFlag: any;
|
|
13
|
+
format: any;
|
|
14
|
+
} | null)[] | ({
|
|
15
|
+
width: any;
|
|
16
|
+
height: any;
|
|
17
|
+
data: Uint8Array;
|
|
18
|
+
compressed: any;
|
|
19
|
+
hasAlpha: any;
|
|
20
|
+
format: any;
|
|
21
|
+
} | null)[][] | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Select transcode format from the list of supported formats
|
|
24
|
+
* @returns key for OutputFormat map
|
|
25
|
+
*/
|
|
26
|
+
export function selectSupportedBasisFormat(): "etc1" | "etc2" | "astc-4x4" | "rgb565" | {
|
|
27
|
+
alpha: string;
|
|
28
|
+
noAlpha: string;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=parse-basis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-basis.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-basis.js"],"names":[],"mappings":"AAiDA;;;;;GAKG;AACH,yCAJW,WAAW;;;;;;;;;;;;;;sBA4BrB;AA8KD;;;GAGG;AACH;;;EAoBC"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.selectSupportedBasisFormat = void 0;
|
|
4
|
+
const basis_module_loader_1 = require("./basis-module-loader");
|
|
5
|
+
const gl_extensions_1 = require("../gl-extensions");
|
|
6
|
+
const texture_formats_1 = require("../utils/texture-formats");
|
|
7
|
+
const parse_ktx_1 = require("./parse-ktx");
|
|
8
|
+
const OutputFormat = {
|
|
9
|
+
etc1: {
|
|
10
|
+
basisFormat: 0,
|
|
11
|
+
compressed: true,
|
|
12
|
+
format: gl_extensions_1.GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_ETC1_WEBGL
|
|
13
|
+
},
|
|
14
|
+
etc2: { basisFormat: 1, compressed: true },
|
|
15
|
+
bc1: {
|
|
16
|
+
basisFormat: 2,
|
|
17
|
+
compressed: true,
|
|
18
|
+
format: gl_extensions_1.GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT
|
|
19
|
+
},
|
|
20
|
+
bc3: {
|
|
21
|
+
basisFormat: 3,
|
|
22
|
+
compressed: true,
|
|
23
|
+
format: gl_extensions_1.GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT
|
|
24
|
+
},
|
|
25
|
+
bc4: { basisFormat: 4, compressed: true },
|
|
26
|
+
bc5: { basisFormat: 5, compressed: true },
|
|
27
|
+
'bc7-m6-opaque-only': { basisFormat: 6, compressed: true },
|
|
28
|
+
'bc7-m5': { basisFormat: 7, compressed: true },
|
|
29
|
+
'pvrtc1-4-rgb': {
|
|
30
|
+
basisFormat: 8,
|
|
31
|
+
compressed: true,
|
|
32
|
+
format: gl_extensions_1.GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
|
33
|
+
},
|
|
34
|
+
'pvrtc1-4-rgba': {
|
|
35
|
+
basisFormat: 9,
|
|
36
|
+
compressed: true,
|
|
37
|
+
format: gl_extensions_1.GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
|
38
|
+
},
|
|
39
|
+
'astc-4x4': {
|
|
40
|
+
basisFormat: 10,
|
|
41
|
+
compressed: true,
|
|
42
|
+
format: gl_extensions_1.GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_ASTC_4X4_KHR
|
|
43
|
+
},
|
|
44
|
+
'atc-rgb': { basisFormat: 11, compressed: true },
|
|
45
|
+
'atc-rgba-interpolated-alpha': { basisFormat: 12, compressed: true },
|
|
46
|
+
rgba32: { basisFormat: 13, compressed: false },
|
|
47
|
+
rgb565: { basisFormat: 14, compressed: false },
|
|
48
|
+
bgr565: { basisFormat: 15, compressed: false },
|
|
49
|
+
rgba4444: { basisFormat: 16, compressed: false }
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* parse data with a Binomial Basis_Universal module
|
|
53
|
+
* @param {ArrayBuffer} data
|
|
54
|
+
* @param {*} options
|
|
55
|
+
* @returns compressed texture data
|
|
56
|
+
*/
|
|
57
|
+
async function parseBasis(data, options) {
|
|
58
|
+
if (options.basis.containerFormat === 'auto') {
|
|
59
|
+
if ((0, parse_ktx_1.isKTX)(data)) {
|
|
60
|
+
const fileConstructors = await (0, basis_module_loader_1.loadBasisEncoderModule)(options);
|
|
61
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
62
|
+
}
|
|
63
|
+
const { BasisFile } = await (0, basis_module_loader_1.loadBasisTrascoderModule)(options);
|
|
64
|
+
return parseBasisFile(BasisFile, data, options);
|
|
65
|
+
}
|
|
66
|
+
switch (options.basis.module) {
|
|
67
|
+
case 'encoder':
|
|
68
|
+
const fileConstructors = await (0, basis_module_loader_1.loadBasisEncoderModule)(options);
|
|
69
|
+
switch (options.basis.containerFormat) {
|
|
70
|
+
case 'ktx2':
|
|
71
|
+
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
72
|
+
case 'basis':
|
|
73
|
+
default:
|
|
74
|
+
return parseBasisFile(fileConstructors.BasisFile, data, options);
|
|
75
|
+
}
|
|
76
|
+
case 'transcoder':
|
|
77
|
+
default:
|
|
78
|
+
const { BasisFile } = await (0, basis_module_loader_1.loadBasisTrascoderModule)(options);
|
|
79
|
+
return parseBasisFile(BasisFile, data, options);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.default = parseBasis;
|
|
83
|
+
/**
|
|
84
|
+
* Parse *.basis file data
|
|
85
|
+
* @param {*} BasisFile - initialized transcoder module
|
|
86
|
+
* @param {*} data
|
|
87
|
+
* @param {*} options
|
|
88
|
+
* @returns compressed texture data
|
|
89
|
+
*/
|
|
90
|
+
function parseBasisFile(BasisFile, data, options) {
|
|
91
|
+
const basisFile = new BasisFile(new Uint8Array(data));
|
|
92
|
+
try {
|
|
93
|
+
if (!basisFile.startTranscoding()) {
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
const imageCount = basisFile.getNumImages();
|
|
97
|
+
const images = [];
|
|
98
|
+
for (let imageIndex = 0; imageIndex < imageCount; imageIndex++) {
|
|
99
|
+
const levelsCount = basisFile.getNumLevels(imageIndex);
|
|
100
|
+
const levels = [];
|
|
101
|
+
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
102
|
+
levels.push(transcodeImage(basisFile, imageIndex, levelIndex, options));
|
|
103
|
+
}
|
|
104
|
+
images.push(levels);
|
|
105
|
+
}
|
|
106
|
+
return images;
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
basisFile.close();
|
|
110
|
+
basisFile.delete();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Parse the particular level image of a basis file
|
|
115
|
+
* @param {*} basisFile
|
|
116
|
+
* @param {*} imageIndex
|
|
117
|
+
* @param {*} levelIndex
|
|
118
|
+
* @param {*} options
|
|
119
|
+
* @returns compressed texture data
|
|
120
|
+
*/
|
|
121
|
+
function transcodeImage(basisFile, imageIndex, levelIndex, options) {
|
|
122
|
+
const width = basisFile.getImageWidth(imageIndex, levelIndex);
|
|
123
|
+
const height = basisFile.getImageHeight(imageIndex, levelIndex);
|
|
124
|
+
// See https://github.com/BinomialLLC/basis_universal/pull/83
|
|
125
|
+
const hasAlpha = basisFile.getHasAlpha( /* imageIndex, levelIndex */);
|
|
126
|
+
// Check options for output format etc
|
|
127
|
+
const { compressed, format, basisFormat } = getBasisOptions(options, hasAlpha);
|
|
128
|
+
const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
|
|
129
|
+
const decodedData = new Uint8Array(decodedSize);
|
|
130
|
+
if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
// standard loaders.gl image category payload
|
|
135
|
+
width,
|
|
136
|
+
height,
|
|
137
|
+
data: decodedData,
|
|
138
|
+
compressed,
|
|
139
|
+
// Additional fields
|
|
140
|
+
// Add levelSize field.
|
|
141
|
+
hasAlpha,
|
|
142
|
+
format
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Parse *.ktx2 file data
|
|
147
|
+
* @param {*} KTX2File
|
|
148
|
+
* @param {*} data
|
|
149
|
+
* @param {*} options
|
|
150
|
+
* @returns compressed texture data
|
|
151
|
+
*/
|
|
152
|
+
function parseKTX2File(KTX2File, data, options) {
|
|
153
|
+
const ktx2File = new KTX2File(new Uint8Array(data));
|
|
154
|
+
try {
|
|
155
|
+
if (!ktx2File.startTranscoding()) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
const levelsCount = ktx2File.getLevels();
|
|
159
|
+
const levels = [];
|
|
160
|
+
for (let levelIndex = 0; levelIndex < levelsCount; levelIndex++) {
|
|
161
|
+
levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
|
|
162
|
+
break; // texture app can only show one level for some reason
|
|
163
|
+
}
|
|
164
|
+
return levels;
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
ktx2File.close();
|
|
168
|
+
ktx2File.delete();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Parse the particular level image of a ktx2 file
|
|
173
|
+
* @param {*} ktx2File
|
|
174
|
+
* @param {*} levelIndex
|
|
175
|
+
* @param {*} options
|
|
176
|
+
* @returns
|
|
177
|
+
*/
|
|
178
|
+
function transcodeKTX2Image(ktx2File, levelIndex, options) {
|
|
179
|
+
const { alphaFlag, height, width } = ktx2File.getImageLevelInfo(levelIndex, 0, 0);
|
|
180
|
+
// Check options for output format etc
|
|
181
|
+
const { compressed, format, basisFormat } = getBasisOptions(options, alphaFlag);
|
|
182
|
+
const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0 /* layerIndex */, 0 /* faceIndex */, basisFormat);
|
|
183
|
+
const decodedData = new Uint8Array(decodedSize);
|
|
184
|
+
if (!ktx2File.transcodeImage(decodedData, levelIndex, 0 /* layerIndex */, 0 /* faceIndex */, basisFormat, 0, -1 /* channel0 */, -1 /* channel1 */)) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return {
|
|
188
|
+
// standard loaders.gl image category payload
|
|
189
|
+
width,
|
|
190
|
+
height,
|
|
191
|
+
data: decodedData,
|
|
192
|
+
compressed,
|
|
193
|
+
// Additional fields
|
|
194
|
+
// Add levelSize field.
|
|
195
|
+
alphaFlag,
|
|
196
|
+
format
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Get BasisFormat by loader format option
|
|
201
|
+
* @param {*} options
|
|
202
|
+
* @param {*} hasAlpha
|
|
203
|
+
* @returns BasisFormat data
|
|
204
|
+
*/
|
|
205
|
+
function getBasisOptions(options, hasAlpha) {
|
|
206
|
+
let format = options && options.basis && options.basis.format;
|
|
207
|
+
if (format === 'auto') {
|
|
208
|
+
format = selectSupportedBasisFormat();
|
|
209
|
+
}
|
|
210
|
+
if (typeof format === 'object') {
|
|
211
|
+
format = hasAlpha ? format.alpha : format.noAlpha;
|
|
212
|
+
}
|
|
213
|
+
format = format.toLowerCase();
|
|
214
|
+
return OutputFormat[format];
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Select transcode format from the list of supported formats
|
|
218
|
+
* @returns key for OutputFormat map
|
|
219
|
+
*/
|
|
220
|
+
function selectSupportedBasisFormat() {
|
|
221
|
+
const supportedFormats = (0, texture_formats_1.getSupportedGPUTextureFormats)();
|
|
222
|
+
if (supportedFormats.has('astc')) {
|
|
223
|
+
return 'astc-4x4';
|
|
224
|
+
}
|
|
225
|
+
else if (supportedFormats.has('dxt')) {
|
|
226
|
+
return {
|
|
227
|
+
alpha: 'bc3',
|
|
228
|
+
noAlpha: 'bc1'
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
else if (supportedFormats.has('pvrtc')) {
|
|
232
|
+
return {
|
|
233
|
+
alpha: 'pvrtc1-4-rgba',
|
|
234
|
+
noAlpha: 'pvrtc1-4-rgb'
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
else if (supportedFormats.has('etc1')) {
|
|
238
|
+
return 'etc1';
|
|
239
|
+
}
|
|
240
|
+
else if (supportedFormats.has('etc2')) {
|
|
241
|
+
return 'etc2';
|
|
242
|
+
}
|
|
243
|
+
return 'rgb565';
|
|
244
|
+
}
|
|
245
|
+
exports.selectSupportedBasisFormat = selectSupportedBasisFormat;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TextureLevel } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Deduces format and parses compressed texture loaded in ArrayBuffer
|
|
4
|
+
* @param data - binary data of compressed texture
|
|
5
|
+
* @returns Array of the texture levels
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseCompressedTexture(data: ArrayBuffer): TextureLevel[];
|
|
8
|
+
//# sourceMappingURL=parse-compressed-texture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-compressed-texture.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-compressed-texture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAK9C;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,EAAE,CAaxE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCompressedTexture = void 0;
|
|
4
|
+
const parse_ktx_1 = require("./parse-ktx");
|
|
5
|
+
const parse_dds_1 = require("./parse-dds");
|
|
6
|
+
const parse_pvr_1 = require("./parse-pvr");
|
|
7
|
+
/**
|
|
8
|
+
* Deduces format and parses compressed texture loaded in ArrayBuffer
|
|
9
|
+
* @param data - binary data of compressed texture
|
|
10
|
+
* @returns Array of the texture levels
|
|
11
|
+
*/
|
|
12
|
+
function parseCompressedTexture(data) {
|
|
13
|
+
if ((0, parse_ktx_1.isKTX)(data)) {
|
|
14
|
+
// TODO: remove @ts-ignore when `parseKTX` output is normalized to loaders.gl texture format
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
return (0, parse_ktx_1.parseKTX)(data);
|
|
17
|
+
}
|
|
18
|
+
if ((0, parse_dds_1.isDDS)(data)) {
|
|
19
|
+
return (0, parse_dds_1.parseDDS)(data);
|
|
20
|
+
}
|
|
21
|
+
if ((0, parse_pvr_1.isPVR)(data)) {
|
|
22
|
+
return (0, parse_pvr_1.parsePVR)(data);
|
|
23
|
+
}
|
|
24
|
+
throw new Error('Texture container format not recognized');
|
|
25
|
+
}
|
|
26
|
+
exports.parseCompressedTexture = parseCompressedTexture;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TextureLevel } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Parse texture data as "CRN" format.
|
|
4
|
+
* Function is "async" as emscriptified decoder module is loaded asyncronously
|
|
5
|
+
* @param data - binary data of compressed texture
|
|
6
|
+
* @returns Promise of Array of the texture levels
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseCrunch(data: any, options: any): Promise<TextureLevel[]>;
|
|
9
|
+
//# sourceMappingURL=parse-crunch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-crunch.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-crunch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAqC9C;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,IAAI,KAAA,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAmD7E"}
|