@loaders.gl/textures 4.4.0-alpha.16 → 4.4.0-alpha.18
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/README.md +44 -0
- package/dist/basis-loader.d.ts +15 -10
- package/dist/basis-loader.d.ts.map +1 -1
- package/dist/basis-loader.js +0 -1
- package/dist/basis-loader.js.map +1 -1
- package/dist/basis-worker-node.js +333 -193
- package/dist/basis-worker.js +267 -128
- package/dist/compressed-texture-loader.d.ts +0 -4
- package/dist/compressed-texture-loader.d.ts.map +1 -1
- package/dist/compressed-texture-loader.js +0 -1
- package/dist/compressed-texture-loader.js.map +1 -1
- package/dist/compressed-texture-worker.js +1050 -331
- package/dist/crunch-loader.d.ts +1 -5
- package/dist/crunch-loader.d.ts.map +1 -1
- package/dist/crunch-loader.js +1 -3
- package/dist/crunch-loader.js.map +1 -1
- package/dist/crunch-worker.js +153 -86
- package/dist/dist.dev.js +1281 -388
- package/dist/dist.min.js +1 -2
- package/dist/index.cjs +671 -330
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/ktx2-basis-writer-worker-node.js +14 -3
- package/dist/ktx2-basis-writer-worker.js +13 -3
- package/dist/lib/encoders/encode-ktx2-basis-texture.d.ts.map +1 -1
- package/dist/lib/encoders/encode-ktx2-basis-texture.js +2 -1
- package/dist/lib/encoders/encode-ktx2-basis-texture.js.map +1 -1
- package/dist/lib/gl-extensions.d.ts +164 -58
- package/dist/lib/gl-extensions.d.ts.map +1 -1
- package/dist/lib/gl-extensions.js +175 -66
- package/dist/lib/gl-extensions.js.map +1 -1
- package/dist/lib/parsers/crunch-module-loader.d.ts +2 -2
- package/dist/lib/parsers/crunch-module-loader.d.ts.map +1 -1
- package/dist/lib/parsers/crunch-module-loader.js.map +1 -1
- package/dist/lib/parsers/parse-basis.d.ts +16 -2
- package/dist/lib/parsers/parse-basis.d.ts.map +1 -1
- package/dist/lib/parsers/parse-basis.js +222 -47
- package/dist/lib/parsers/parse-basis.js.map +1 -1
- package/dist/lib/parsers/parse-crunch.d.ts.map +1 -1
- package/dist/lib/parsers/parse-crunch.js +6 -5
- package/dist/lib/parsers/parse-crunch.js.map +1 -1
- package/dist/lib/parsers/parse-dds.d.ts.map +1 -1
- package/dist/lib/parsers/parse-dds.js +7 -7
- package/dist/lib/parsers/parse-dds.js.map +1 -1
- package/dist/lib/parsers/parse-ktx.d.ts.map +1 -1
- package/dist/lib/parsers/parse-ktx.js +7 -0
- package/dist/lib/parsers/parse-ktx.js.map +1 -1
- package/dist/lib/parsers/parse-pvr.d.ts.map +1 -1
- package/dist/lib/parsers/parse-pvr.js +28 -70
- package/dist/lib/parsers/parse-pvr.js.map +1 -1
- package/dist/lib/utils/detect-supported-texture-formats.d.ts +14 -0
- package/dist/lib/utils/detect-supported-texture-formats.d.ts.map +1 -0
- package/dist/lib/utils/detect-supported-texture-formats.js +197 -0
- package/dist/lib/utils/detect-supported-texture-formats.js.map +1 -0
- package/dist/lib/utils/extract-mipmap-images.d.ts +2 -2
- package/dist/lib/utils/extract-mipmap-images.d.ts.map +1 -1
- package/dist/lib/utils/extract-mipmap-images.js +12 -2
- package/dist/lib/utils/extract-mipmap-images.js.map +1 -1
- package/dist/lib/utils/ktx-format-helper.d.ts +2 -1
- package/dist/lib/utils/ktx-format-helper.d.ts.map +1 -1
- package/dist/lib/utils/ktx-format-helper.js +67 -109
- package/dist/lib/utils/ktx-format-helper.js.map +1 -1
- package/dist/lib/utils/texture-format-map.d.ts +3 -0
- package/dist/lib/utils/texture-format-map.d.ts.map +1 -0
- package/dist/lib/utils/texture-format-map.js +71 -0
- package/dist/lib/utils/texture-format-map.js.map +1 -0
- package/dist/lib/utils/version.js +1 -1
- package/dist/npy-worker.js +1 -1
- package/dist/workers/crunch-worker.d.ts +1 -3
- package/dist/workers/crunch-worker.d.ts.map +1 -1
- package/package.json +6 -6
- package/src/basis-loader.ts +19 -9
- package/src/compressed-texture-loader.ts +0 -3
- package/src/crunch-loader.ts +1 -5
- package/src/index.ts +2 -4
- package/src/lib/encoders/encode-ktx2-basis-texture.ts +2 -1
- package/src/lib/gl-extensions.ts +186 -81
- package/src/lib/parsers/crunch-module-loader.ts +4 -4
- package/src/lib/parsers/parse-basis.ts +281 -45
- package/src/lib/parsers/parse-crunch.ts +15 -7
- package/src/lib/parsers/parse-dds.ts +16 -9
- package/src/lib/parsers/parse-ktx.ts +12 -2
- package/src/lib/parsers/parse-pvr.ts +72 -72
- package/src/lib/utils/detect-supported-texture-formats.ts +210 -0
- package/src/lib/utils/extract-mipmap-images.ts +15 -4
- package/src/lib/utils/ktx-format-helper.ts +124 -111
- package/src/lib/utils/texture-format-map.ts +135 -0
- package/dist/lib/utils/texture-formats.d.ts +0 -8
- package/dist/lib/utils/texture-formats.d.ts.map +0 -1
- package/dist/lib/utils/texture-formats.js +0 -51
- package/dist/lib/utils/texture-formats.js.map +0 -1
- package/src/lib/utils/texture-formats.ts +0 -59
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// loaders.gl
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Copyright (c) vis.gl contributors
|
|
4
|
+
|
|
5
|
+
/* eslint-disable camelcase */
|
|
6
|
+
import type {TextureFormat} from '@loaders.gl/schema';
|
|
7
|
+
import {
|
|
8
|
+
GL_COMPRESSED_R11_EAC,
|
|
9
|
+
GL_COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
10
|
+
GL_COMPRESSED_RED_RGTC1_EXT,
|
|
11
|
+
GL_COMPRESSED_RG11_EAC,
|
|
12
|
+
GL_COMPRESSED_RGB8_ETC2,
|
|
13
|
+
GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
14
|
+
GL_COMPRESSED_RGB_ATC_WEBGL,
|
|
15
|
+
GL_COMPRESSED_RGB_ETC1_WEBGL,
|
|
16
|
+
GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
|
|
17
|
+
GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
18
|
+
GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
19
|
+
GL_COMPRESSED_RGBA8_ETC2_EAC,
|
|
20
|
+
GL_COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
21
|
+
GL_COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
22
|
+
GL_COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
23
|
+
GL_COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
24
|
+
GL_COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
25
|
+
GL_COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
26
|
+
GL_COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
27
|
+
GL_COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
28
|
+
GL_COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
29
|
+
GL_COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
30
|
+
GL_COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
31
|
+
GL_COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
32
|
+
GL_COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
33
|
+
GL_COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
34
|
+
GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,
|
|
35
|
+
GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL,
|
|
36
|
+
GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
37
|
+
GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
38
|
+
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
39
|
+
GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
40
|
+
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
41
|
+
GL_COMPRESSED_SIGNED_R11_EAC,
|
|
42
|
+
GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
|
|
43
|
+
GL_COMPRESSED_SIGNED_RED_RGTC1_EXT,
|
|
44
|
+
GL_COMPRESSED_SIGNED_RG11_EAC,
|
|
45
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
46
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
47
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
48
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
49
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
50
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
51
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
52
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
53
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
54
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
55
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
56
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
57
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
58
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
59
|
+
GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
|
|
60
|
+
GL_COMPRESSED_SRGB8_ETC2,
|
|
61
|
+
GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
62
|
+
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
|
|
63
|
+
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
|
|
64
|
+
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
|
|
65
|
+
GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
|
|
66
|
+
} from '../gl-extensions';
|
|
67
|
+
|
|
68
|
+
const WEBGL_TO_TEXTURE_FORMAT: Record<number, TextureFormat> = {
|
|
69
|
+
[GL_COMPRESSED_RGB_S3TC_DXT1_EXT]: 'bc1-rgb-unorm-webgl',
|
|
70
|
+
[GL_COMPRESSED_SRGB_S3TC_DXT1_EXT]: 'bc1-rgb-unorm-srgb-webgl',
|
|
71
|
+
[GL_COMPRESSED_RGBA_S3TC_DXT1_EXT]: 'bc1-rgba-unorm',
|
|
72
|
+
[GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT]: 'bc1-rgba-unorm-srgb',
|
|
73
|
+
[GL_COMPRESSED_RGBA_S3TC_DXT3_EXT]: 'bc2-rgba-unorm',
|
|
74
|
+
[GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT]: 'bc2-rgba-unorm-srgb',
|
|
75
|
+
[GL_COMPRESSED_RGBA_S3TC_DXT5_EXT]: 'bc3-rgba-unorm',
|
|
76
|
+
[GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT]: 'bc3-rgba-unorm-srgb',
|
|
77
|
+
[GL_COMPRESSED_RED_RGTC1_EXT]: 'bc4-r-unorm',
|
|
78
|
+
[GL_COMPRESSED_SIGNED_RED_RGTC1_EXT]: 'bc4-r-snorm',
|
|
79
|
+
[GL_COMPRESSED_RED_GREEN_RGTC2_EXT]: 'bc5-rg-unorm',
|
|
80
|
+
[GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT]: 'bc5-rg-snorm',
|
|
81
|
+
[GL_COMPRESSED_RGB8_ETC2]: 'etc2-rgb8unorm',
|
|
82
|
+
[GL_COMPRESSED_SRGB8_ETC2]: 'etc2-rgb8unorm-srgb',
|
|
83
|
+
[GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2]: 'etc2-rgb8a1unorm',
|
|
84
|
+
[GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2]: 'etc2-rgb8a1unorm-srgb',
|
|
85
|
+
[GL_COMPRESSED_RGBA8_ETC2_EAC]: 'etc2-rgba8unorm',
|
|
86
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC]: 'etc2-rgba8unorm-srgb',
|
|
87
|
+
[GL_COMPRESSED_R11_EAC]: 'eac-r11unorm',
|
|
88
|
+
[GL_COMPRESSED_SIGNED_R11_EAC]: 'eac-r11snorm',
|
|
89
|
+
[GL_COMPRESSED_RG11_EAC]: 'eac-rg11unorm',
|
|
90
|
+
[GL_COMPRESSED_SIGNED_RG11_EAC]: 'eac-rg11snorm',
|
|
91
|
+
[GL_COMPRESSED_RGBA_ASTC_4x4_KHR]: 'astc-4x4-unorm',
|
|
92
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR]: 'astc-4x4-unorm-srgb',
|
|
93
|
+
[GL_COMPRESSED_RGBA_ASTC_5x4_KHR]: 'astc-5x4-unorm',
|
|
94
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR]: 'astc-5x4-unorm-srgb',
|
|
95
|
+
[GL_COMPRESSED_RGBA_ASTC_5x5_KHR]: 'astc-5x5-unorm',
|
|
96
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR]: 'astc-5x5-unorm-srgb',
|
|
97
|
+
[GL_COMPRESSED_RGBA_ASTC_6x5_KHR]: 'astc-6x5-unorm',
|
|
98
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR]: 'astc-6x5-unorm-srgb',
|
|
99
|
+
[GL_COMPRESSED_RGBA_ASTC_6x6_KHR]: 'astc-6x6-unorm',
|
|
100
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR]: 'astc-6x6-unorm-srgb',
|
|
101
|
+
[GL_COMPRESSED_RGBA_ASTC_8x5_KHR]: 'astc-8x5-unorm',
|
|
102
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR]: 'astc-8x5-unorm-srgb',
|
|
103
|
+
[GL_COMPRESSED_RGBA_ASTC_8x6_KHR]: 'astc-8x6-unorm',
|
|
104
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR]: 'astc-8x6-unorm-srgb',
|
|
105
|
+
[GL_COMPRESSED_RGBA_ASTC_8x8_KHR]: 'astc-8x8-unorm',
|
|
106
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR]: 'astc-8x8-unorm-srgb',
|
|
107
|
+
[GL_COMPRESSED_RGBA_ASTC_10x5_KHR]: 'astc-10x5-unorm',
|
|
108
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR]: 'astc-10x5-unorm-srgb',
|
|
109
|
+
[GL_COMPRESSED_RGBA_ASTC_10x6_KHR]: 'astc-10x6-unorm',
|
|
110
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR]: 'astc-10x6-unorm-srgb',
|
|
111
|
+
[GL_COMPRESSED_RGBA_ASTC_10x8_KHR]: 'astc-10x8-unorm',
|
|
112
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR]: 'astc-10x8-unorm-srgb',
|
|
113
|
+
[GL_COMPRESSED_RGBA_ASTC_10x10_KHR]: 'astc-10x10-unorm',
|
|
114
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR]: 'astc-10x10-unorm-srgb',
|
|
115
|
+
[GL_COMPRESSED_RGBA_ASTC_12x10_KHR]: 'astc-12x10-unorm',
|
|
116
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR]: 'astc-12x10-unorm-srgb',
|
|
117
|
+
[GL_COMPRESSED_RGBA_ASTC_12x12_KHR]: 'astc-12x12-unorm',
|
|
118
|
+
[GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR]: 'astc-12x12-unorm-srgb',
|
|
119
|
+
[GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG]: 'pvrtc-rgb4unorm-webgl',
|
|
120
|
+
[GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG]: 'pvrtc-rgba4unorm-webgl',
|
|
121
|
+
[GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG]: 'pvrtc-rbg2unorm-webgl',
|
|
122
|
+
[GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG]: 'pvrtc-rgba2unorm-webgl',
|
|
123
|
+
[GL_COMPRESSED_RGB_ETC1_WEBGL]: 'etc1-rbg-unorm-webgl',
|
|
124
|
+
[GL_COMPRESSED_RGB_ATC_WEBGL]: 'atc-rgb-unorm-webgl',
|
|
125
|
+
[GL_COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL]: 'atc-rgba-unorm-webgl',
|
|
126
|
+
[GL_COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL]: 'atc-rgbai-unorm-webgl'
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export function getTextureFormatFromWebGLFormat(format?: number): TextureFormat | undefined {
|
|
130
|
+
if (format === undefined) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return WEBGL_TO_TEXTURE_FORMAT[format];
|
|
135
|
+
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a list of formats.
|
|
3
|
-
* Creates a temporary WebGLRenderingContext if none is provided.
|
|
4
|
-
*
|
|
5
|
-
* @param gl - Optional context.
|
|
6
|
-
*/
|
|
7
|
-
export declare function getSupportedGPUTextureFormats(gl?: WebGLRenderingContext): Set<string>;
|
|
8
|
-
//# sourceMappingURL=texture-formats.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"texture-formats.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/texture-formats.ts"],"names":[],"mappings":"AAuBA;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,EAAE,CAAC,EAAE,qBAAqB,GAAG,GAAG,CAAC,MAAM,CAAC,CAiBrF"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
const BROWSER_PREFIXES = ['', 'WEBKIT_', 'MOZ_'];
|
|
5
|
-
const WEBGL_EXTENSIONS = {
|
|
6
|
-
/* eslint-disable camelcase */
|
|
7
|
-
WEBGL_compressed_texture_s3tc: 'dxt',
|
|
8
|
-
WEBGL_compressed_texture_s3tc_srgb: 'dxt-srgb',
|
|
9
|
-
WEBGL_compressed_texture_etc1: 'etc1',
|
|
10
|
-
WEBGL_compressed_texture_etc: 'etc2',
|
|
11
|
-
WEBGL_compressed_texture_pvrtc: 'pvrtc',
|
|
12
|
-
WEBGL_compressed_texture_atc: 'atc',
|
|
13
|
-
WEBGL_compressed_texture_astc: 'astc',
|
|
14
|
-
EXT_texture_compression_rgtc: 'rgtc'
|
|
15
|
-
/* eslint-enable camelcase */
|
|
16
|
-
};
|
|
17
|
-
let formats = null;
|
|
18
|
-
/**
|
|
19
|
-
* Returns a list of formats.
|
|
20
|
-
* Creates a temporary WebGLRenderingContext if none is provided.
|
|
21
|
-
*
|
|
22
|
-
* @param gl - Optional context.
|
|
23
|
-
*/
|
|
24
|
-
export function getSupportedGPUTextureFormats(gl) {
|
|
25
|
-
if (!formats) {
|
|
26
|
-
gl = gl || getWebGLContext() || undefined;
|
|
27
|
-
formats = new Set();
|
|
28
|
-
for (const prefix of BROWSER_PREFIXES) {
|
|
29
|
-
for (const extension in WEBGL_EXTENSIONS) {
|
|
30
|
-
if (gl && gl.getExtension(`${prefix}${extension}`)) {
|
|
31
|
-
const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
|
|
32
|
-
formats.add(gpuTextureFormat);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return formats;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* @returns {WebGLRenderingContext?}
|
|
41
|
-
*/
|
|
42
|
-
function getWebGLContext() {
|
|
43
|
-
try {
|
|
44
|
-
const canvas = document.createElement('canvas');
|
|
45
|
-
return canvas.getContext('webgl');
|
|
46
|
-
}
|
|
47
|
-
catch (error) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
//# sourceMappingURL=texture-formats.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"texture-formats.js","sourceRoot":"","sources":["../../../src/lib/utils/texture-formats.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAIpC,MAAM,gBAAgB,GAAG,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAEjD,MAAM,gBAAgB,GAAsC;IAC1D,8BAA8B;IAC9B,6BAA6B,EAAE,KAAK;IACpC,kCAAkC,EAAE,UAAU;IAC9C,6BAA6B,EAAE,MAAM;IACrC,4BAA4B,EAAE,MAAM;IACpC,8BAA8B,EAAE,OAAO;IACvC,4BAA4B,EAAE,KAAK;IACnC,6BAA6B,EAAE,MAAM;IACrC,4BAA4B,EAAE,MAAM;IACpC,6BAA6B;CAC9B,CAAC;AAEF,IAAI,OAAO,GAAiC,IAAI,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAC,EAA0B;IACtE,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,EAAE,GAAG,EAAE,IAAI,eAAe,EAAE,IAAI,SAAS,CAAC;QAE1C,OAAO,GAAG,IAAI,GAAG,EAAoB,CAAC;QAEtC,KAAK,MAAM,MAAM,IAAI,gBAAgB,EAAE,CAAC;YACtC,KAAK,MAAM,SAAS,IAAI,gBAAgB,EAAE,CAAC;gBACzC,IAAI,EAAE,IAAI,EAAE,CAAC,YAAY,CAAC,GAAG,MAAM,GAAG,SAAS,EAAE,CAAC,EAAE,CAAC;oBACnD,MAAM,gBAAgB,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;oBACrD,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;gBAChC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,SAAS,eAAe;IACtB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,OAAO,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
// loaders.gl
|
|
2
|
-
// SPDX-License-Identifier: MIT
|
|
3
|
-
// Copyright (c) vis.gl contributors
|
|
4
|
-
|
|
5
|
-
import type {GPUTextureFormat} from '@loaders.gl/schema';
|
|
6
|
-
|
|
7
|
-
const BROWSER_PREFIXES = ['', 'WEBKIT_', 'MOZ_'];
|
|
8
|
-
|
|
9
|
-
const WEBGL_EXTENSIONS: {[key: string]: GPUTextureFormat} = {
|
|
10
|
-
/* eslint-disable camelcase */
|
|
11
|
-
WEBGL_compressed_texture_s3tc: 'dxt',
|
|
12
|
-
WEBGL_compressed_texture_s3tc_srgb: 'dxt-srgb',
|
|
13
|
-
WEBGL_compressed_texture_etc1: 'etc1',
|
|
14
|
-
WEBGL_compressed_texture_etc: 'etc2',
|
|
15
|
-
WEBGL_compressed_texture_pvrtc: 'pvrtc',
|
|
16
|
-
WEBGL_compressed_texture_atc: 'atc',
|
|
17
|
-
WEBGL_compressed_texture_astc: 'astc',
|
|
18
|
-
EXT_texture_compression_rgtc: 'rgtc'
|
|
19
|
-
/* eslint-enable camelcase */
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
let formats: Set<GPUTextureFormat> | null = null;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Returns a list of formats.
|
|
26
|
-
* Creates a temporary WebGLRenderingContext if none is provided.
|
|
27
|
-
*
|
|
28
|
-
* @param gl - Optional context.
|
|
29
|
-
*/
|
|
30
|
-
export function getSupportedGPUTextureFormats(gl?: WebGLRenderingContext): Set<string> {
|
|
31
|
-
if (!formats) {
|
|
32
|
-
gl = gl || getWebGLContext() || undefined;
|
|
33
|
-
|
|
34
|
-
formats = new Set<GPUTextureFormat>();
|
|
35
|
-
|
|
36
|
-
for (const prefix of BROWSER_PREFIXES) {
|
|
37
|
-
for (const extension in WEBGL_EXTENSIONS) {
|
|
38
|
-
if (gl && gl.getExtension(`${prefix}${extension}`)) {
|
|
39
|
-
const gpuTextureFormat = WEBGL_EXTENSIONS[extension];
|
|
40
|
-
formats.add(gpuTextureFormat);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return formats;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @returns {WebGLRenderingContext?}
|
|
51
|
-
*/
|
|
52
|
-
function getWebGLContext() {
|
|
53
|
-
try {
|
|
54
|
-
const canvas = document.createElement('canvas');
|
|
55
|
-
return canvas.getContext('webgl');
|
|
56
|
-
} catch (error) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
}
|