twgl.js 6.1.1 → 6.2.0
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/6.x/twgl-full.js +465 -44
- package/dist/6.x/twgl-full.module.js +234 -44
- package/dist/6.x/twgl.js +465 -44
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @license twgl.js 6.
|
|
1
|
+
/* @license twgl.js 6.2.0 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
|
|
2
2
|
Available via the MIT license.
|
|
3
3
|
see: http://github.com/greggman/twgl.js for details */
|
|
4
4
|
/*
|
|
@@ -5200,6 +5200,74 @@ const RED_INTEGER = 0x8D94;
|
|
|
5200
5200
|
const RGB_INTEGER = 0x8D98;
|
|
5201
5201
|
const RGBA_INTEGER = 0x8D99;
|
|
5202
5202
|
|
|
5203
|
+
/* Compressed Texture Formats */
|
|
5204
|
+
// s3tc
|
|
5205
|
+
const COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
|
|
5206
|
+
const COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
|
|
5207
|
+
const COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2;
|
|
5208
|
+
const COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
|
|
5209
|
+
// s3tc_srgb
|
|
5210
|
+
const COMPRESSED_SRGB_S3TC_DXT1_EXT = 0x8C4C;
|
|
5211
|
+
const COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 0x8C4D;
|
|
5212
|
+
const COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 0x8C4E;
|
|
5213
|
+
const COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 0x8C4F;
|
|
5214
|
+
// etc
|
|
5215
|
+
const COMPRESSED_RGB_ETC1_WEBGL = 0x8D64;
|
|
5216
|
+
const COMPRESSED_R11_EAC = 0x9270;
|
|
5217
|
+
const COMPRESSED_SIGNED_R11_EAC = 0x9271;
|
|
5218
|
+
const COMPRESSED_RG11_EAC = 0x9272;
|
|
5219
|
+
const COMPRESSED_SIGNED_RG11_EAC = 0x9273;
|
|
5220
|
+
const COMPRESSED_RGB8_ETC2 = 0x9274;
|
|
5221
|
+
const COMPRESSED_SRGB8_ETC2 = 0x9275;
|
|
5222
|
+
const COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276;
|
|
5223
|
+
const COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277;
|
|
5224
|
+
const COMPRESSED_RGBA8_ETC2_EAC = 0x9278;
|
|
5225
|
+
const COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279;
|
|
5226
|
+
// pvrtc
|
|
5227
|
+
const COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00;
|
|
5228
|
+
const COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01;
|
|
5229
|
+
const COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02;
|
|
5230
|
+
const COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03;
|
|
5231
|
+
// astc
|
|
5232
|
+
const COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0;
|
|
5233
|
+
const COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93B1;
|
|
5234
|
+
const COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93B2;
|
|
5235
|
+
const COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93B3;
|
|
5236
|
+
const COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93B4;
|
|
5237
|
+
const COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93B5;
|
|
5238
|
+
const COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93B6;
|
|
5239
|
+
const COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93B7;
|
|
5240
|
+
const COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93B8;
|
|
5241
|
+
const COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93B9;
|
|
5242
|
+
const COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93BA;
|
|
5243
|
+
const COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93BB;
|
|
5244
|
+
const COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93BC;
|
|
5245
|
+
const COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93BD;
|
|
5246
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93D0;
|
|
5247
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93D1;
|
|
5248
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93D2;
|
|
5249
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93D3;
|
|
5250
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93D4;
|
|
5251
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93D5;
|
|
5252
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93D6;
|
|
5253
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93D7;
|
|
5254
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93D8;
|
|
5255
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93D9;
|
|
5256
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93DA;
|
|
5257
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93DB;
|
|
5258
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93DC;
|
|
5259
|
+
const COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD;
|
|
5260
|
+
// bptc
|
|
5261
|
+
const COMPRESSED_RGBA_BPTC_UNORM_EXT = 0x8E8C;
|
|
5262
|
+
const COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = 0x8E8D;
|
|
5263
|
+
const COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT = 0x8E8E;
|
|
5264
|
+
const COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT = 0x8E8F;
|
|
5265
|
+
// rgtc
|
|
5266
|
+
const COMPRESSED_RED_RGTC1_EXT = 0x8DBB;
|
|
5267
|
+
const COMPRESSED_SIGNED_RED_RGTC1_EXT = 0x8DBC;
|
|
5268
|
+
const COMPRESSED_RED_GREEN_RGTC2_EXT = 0x8DBD;
|
|
5269
|
+
const COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT = 0x8DBE;
|
|
5270
|
+
|
|
5203
5271
|
const formatInfo = {};
|
|
5204
5272
|
{
|
|
5205
5273
|
// NOTE: this is named `numColorComponents` vs `numComponents` so we can let Uglify mangle
|
|
@@ -5228,7 +5296,8 @@ const formatInfo = {};
|
|
|
5228
5296
|
* @property {boolean} colorRenderable true if you can render to this format of texture.
|
|
5229
5297
|
* @property {boolean} textureFilterable true if you can filter the texture, false if you can ony use `NEAREST`.
|
|
5230
5298
|
* @property {number[]} type Array of possible types you can pass to texImage2D and similar function
|
|
5231
|
-
* @property {Object.<number,number>} bytesPerElementMap A map of types to bytes per element
|
|
5299
|
+
* @property {Object.<number,number>} [bytesPerElementMap] A map of types to bytes per element
|
|
5300
|
+
* @property {boolean} [compressed] true if it's a compressed texture format
|
|
5232
5301
|
* @private
|
|
5233
5302
|
*/
|
|
5234
5303
|
|
|
@@ -5310,6 +5379,85 @@ function getTextureInternalFormatInfo(internalFormat) {
|
|
|
5310
5379
|
info.bytesPerElementMap[type] = bytesPerElement;
|
|
5311
5380
|
});
|
|
5312
5381
|
});
|
|
5382
|
+
|
|
5383
|
+
const getCompressedFormatInfo = () => {
|
|
5384
|
+
const t = {};
|
|
5385
|
+
// compressed texture formats
|
|
5386
|
+
// s3tc:https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc.txt
|
|
5387
|
+
t[COMPRESSED_RGB_S3TC_DXT1_EXT] = { textureFormat: COMPRESSED_RGB_S3TC_DXT1_EXT, colorRenderable: false, textureFilterable: true };
|
|
5388
|
+
t[COMPRESSED_RGBA_S3TC_DXT1_EXT] = { textureFormat: COMPRESSED_RGBA_S3TC_DXT1_EXT, colorRenderable: false, textureFilterable: true };
|
|
5389
|
+
t[COMPRESSED_RGBA_S3TC_DXT3_EXT] = { textureFormat: COMPRESSED_RGBA_S3TC_DXT3_EXT, colorRenderable: false, textureFilterable: true };
|
|
5390
|
+
t[COMPRESSED_RGBA_S3TC_DXT5_EXT] = { textureFormat: COMPRESSED_RGBA_S3TC_DXT5_EXT, colorRenderable: false, textureFilterable: true };
|
|
5391
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc_srgb.txt
|
|
5392
|
+
t[COMPRESSED_SRGB_S3TC_DXT1_EXT] = { textureFormat: COMPRESSED_SRGB_S3TC_DXT1_EXT, colorRenderable: false, textureFilterable: true };
|
|
5393
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = { textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, colorRenderable: false, textureFilterable: true };
|
|
5394
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = { textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, colorRenderable: false, textureFilterable: true };
|
|
5395
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = { textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, colorRenderable: false, textureFilterable: true };
|
|
5396
|
+
// https://registry.khronos.org/OpenGL/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt
|
|
5397
|
+
t[COMPRESSED_RGB_ETC1_WEBGL] = { textureFormat: COMPRESSED_RGB_ETC1_WEBGL, colorRenderable: false, textureFilterable: true };
|
|
5398
|
+
t[COMPRESSED_R11_EAC] = { textureFormat: COMPRESSED_R11_EAC, colorRenderable: false, textureFilterable: true };
|
|
5399
|
+
t[COMPRESSED_SIGNED_R11_EAC] = { textureFormat: COMPRESSED_SIGNED_R11_EAC, colorRenderable: false, textureFilterable: true };
|
|
5400
|
+
t[COMPRESSED_RG11_EAC] = { textureFormat: COMPRESSED_RG11_EAC, colorRenderable: false, textureFilterable: true };
|
|
5401
|
+
t[COMPRESSED_SIGNED_RG11_EAC] = { textureFormat: COMPRESSED_SIGNED_RG11_EAC, colorRenderable: false, textureFilterable: true };
|
|
5402
|
+
t[COMPRESSED_RGB8_ETC2] = { textureFormat: COMPRESSED_RGB8_ETC2, colorRenderable: false, textureFilterable: true };
|
|
5403
|
+
t[COMPRESSED_SRGB8_ETC2] = { textureFormat: COMPRESSED_SRGB8_ETC2, colorRenderable: false, textureFilterable: true };
|
|
5404
|
+
t[COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = { textureFormat: COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, colorRenderable: false, textureFilterable: true };
|
|
5405
|
+
t[COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = { textureFormat: COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, colorRenderable: false, textureFilterable: true };
|
|
5406
|
+
t[COMPRESSED_RGBA8_ETC2_EAC] = { textureFormat: COMPRESSED_RGBA8_ETC2_EAC, colorRenderable: false, textureFilterable: true };
|
|
5407
|
+
t[COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, colorRenderable: false, textureFilterable: true };
|
|
5408
|
+
// https://registry.khronos.org/OpenGL/extensions/IMG/IMG_texture_compression_pvrtc.txt
|
|
5409
|
+
t[COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = { textureFormat: COMPRESSED_RGB_PVRTC_4BPPV1_IMG, colorRenderable: false, textureFilterable: true };
|
|
5410
|
+
t[COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = { textureFormat: COMPRESSED_RGB_PVRTC_2BPPV1_IMG, colorRenderable: false, textureFilterable: true };
|
|
5411
|
+
t[COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = { textureFormat: COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, colorRenderable: false, textureFilterable: true };
|
|
5412
|
+
t[COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = { textureFormat: COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, colorRenderable: false, textureFilterable: true };
|
|
5413
|
+
// https://registry.khronos.org/OpenGL/extensions/KHR/KHR_texture_compression_astc_hdr.txt
|
|
5414
|
+
t[COMPRESSED_RGBA_ASTC_4x4_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_4x4_KHR, colorRenderable: false, textureFilterable: true };
|
|
5415
|
+
t[COMPRESSED_RGBA_ASTC_5x4_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_5x4_KHR, colorRenderable: false, textureFilterable: true };
|
|
5416
|
+
t[COMPRESSED_RGBA_ASTC_5x5_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_5x5_KHR, colorRenderable: false, textureFilterable: true };
|
|
5417
|
+
t[COMPRESSED_RGBA_ASTC_6x5_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_6x5_KHR, colorRenderable: false, textureFilterable: true };
|
|
5418
|
+
t[COMPRESSED_RGBA_ASTC_6x6_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_6x6_KHR, colorRenderable: false, textureFilterable: true };
|
|
5419
|
+
t[COMPRESSED_RGBA_ASTC_8x5_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_8x5_KHR, colorRenderable: false, textureFilterable: true };
|
|
5420
|
+
t[COMPRESSED_RGBA_ASTC_8x6_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_8x6_KHR, colorRenderable: false, textureFilterable: true };
|
|
5421
|
+
t[COMPRESSED_RGBA_ASTC_8x8_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_8x8_KHR, colorRenderable: false, textureFilterable: true };
|
|
5422
|
+
t[COMPRESSED_RGBA_ASTC_10x5_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_10x5_KHR, colorRenderable: false, textureFilterable: true };
|
|
5423
|
+
t[COMPRESSED_RGBA_ASTC_10x6_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_10x6_KHR, colorRenderable: false, textureFilterable: true };
|
|
5424
|
+
t[COMPRESSED_RGBA_ASTC_10x8_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_10x8_KHR, colorRenderable: false, textureFilterable: true };
|
|
5425
|
+
t[COMPRESSED_RGBA_ASTC_10x10_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_10x10_KHR, colorRenderable: false, textureFilterable: true };
|
|
5426
|
+
t[COMPRESSED_RGBA_ASTC_12x10_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_12x10_KHR, colorRenderable: false, textureFilterable: true };
|
|
5427
|
+
t[COMPRESSED_RGBA_ASTC_12x12_KHR] = { textureFormat: COMPRESSED_RGBA_ASTC_12x12_KHR, colorRenderable: false, textureFilterable: true };
|
|
5428
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, colorRenderable: false, textureFilterable: true };
|
|
5429
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, colorRenderable: false, textureFilterable: true };
|
|
5430
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, colorRenderable: false, textureFilterable: true };
|
|
5431
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, colorRenderable: false, textureFilterable: true };
|
|
5432
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, colorRenderable: false, textureFilterable: true };
|
|
5433
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, colorRenderable: false, textureFilterable: true };
|
|
5434
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, colorRenderable: false, textureFilterable: true };
|
|
5435
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, colorRenderable: false, textureFilterable: true };
|
|
5436
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, colorRenderable: false, textureFilterable: true };
|
|
5437
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, colorRenderable: false, textureFilterable: true };
|
|
5438
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, colorRenderable: false, textureFilterable: true };
|
|
5439
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, colorRenderable: false, textureFilterable: true };
|
|
5440
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, colorRenderable: false, textureFilterable: true };
|
|
5441
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR] = { textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, colorRenderable: false, textureFilterable: true };
|
|
5442
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_bptc.txt
|
|
5443
|
+
t[COMPRESSED_RGBA_BPTC_UNORM_EXT] = { textureFormat: COMPRESSED_RGBA_BPTC_UNORM_EXT, colorRenderable: false, textureFilterable: true };
|
|
5444
|
+
t[COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT] = { textureFormat: COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, colorRenderable: false, textureFilterable: true };
|
|
5445
|
+
t[COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT] = { textureFormat: COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, colorRenderable: false, textureFilterable: true };
|
|
5446
|
+
t[COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT] = { textureFormat: COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, colorRenderable: false, textureFilterable: true };
|
|
5447
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_rgtc.txt
|
|
5448
|
+
t[COMPRESSED_RED_RGTC1_EXT] = { textureFormat: COMPRESSED_RED_RGTC1_EXT, colorRenderable: false, textureFilterable: true };
|
|
5449
|
+
t[COMPRESSED_SIGNED_RED_RGTC1_EXT] = { textureFormat: COMPRESSED_SIGNED_RED_RGTC1_EXT, colorRenderable: false, textureFilterable: true };
|
|
5450
|
+
t[COMPRESSED_RED_GREEN_RGTC2_EXT] = { textureFormat: COMPRESSED_RED_GREEN_RGTC2_EXT, colorRenderable: false, textureFilterable: true };
|
|
5451
|
+
t[COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT] = { textureFormat: COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, colorRenderable: false, textureFilterable: true };
|
|
5452
|
+
|
|
5453
|
+
for (const info of Object.values(t)) {
|
|
5454
|
+
info.compressed = true;
|
|
5455
|
+
}
|
|
5456
|
+
|
|
5457
|
+
return t;
|
|
5458
|
+
};
|
|
5459
|
+
Object.assign(t, getCompressedFormatInfo());
|
|
5460
|
+
|
|
5313
5461
|
s_textureInternalFormatInfo = t;
|
|
5314
5462
|
}
|
|
5315
5463
|
return s_textureInternalFormatInfo[internalFormat];
|
|
@@ -5358,10 +5506,23 @@ function getFormatAndTypeForInternalFormat(internalFormat) {
|
|
|
5358
5506
|
}
|
|
5359
5507
|
return {
|
|
5360
5508
|
format: info.textureFormat,
|
|
5361
|
-
type: info.type[0],
|
|
5509
|
+
type: info.type?.[0] ?? UNSIGNED_BYTE$1,
|
|
5362
5510
|
};
|
|
5363
5511
|
}
|
|
5364
5512
|
|
|
5513
|
+
/**
|
|
5514
|
+
* @param {number} internalFormat The internal format
|
|
5515
|
+
* @returns if the internalFormat is a compressed format
|
|
5516
|
+
* @private
|
|
5517
|
+
*/
|
|
5518
|
+
function isCompressedInternalFormat(internalFormat) {
|
|
5519
|
+
const info = getTextureInternalFormatInfo(internalFormat);
|
|
5520
|
+
if (!info) {
|
|
5521
|
+
throw "unknown internal format";
|
|
5522
|
+
}
|
|
5523
|
+
return !!info.compressed;
|
|
5524
|
+
}
|
|
5525
|
+
|
|
5365
5526
|
/**
|
|
5366
5527
|
* Returns true if value is power of 2
|
|
5367
5528
|
* @param {number} value number to check.
|
|
@@ -6498,9 +6659,6 @@ function setTextureFromArray(gl, tex, src, options) {
|
|
|
6498
6659
|
options = options || defaults$1.textureOptions;
|
|
6499
6660
|
const target = options.target || TEXTURE_2D$2;
|
|
6500
6661
|
gl.bindTexture(target, tex);
|
|
6501
|
-
let width = options.width;
|
|
6502
|
-
let height = options.height;
|
|
6503
|
-
let depth = options.depth;
|
|
6504
6662
|
const level = options.level || 0;
|
|
6505
6663
|
const internalFormat = options.internalFormat || options.format || RGBA$1;
|
|
6506
6664
|
const formatType = getFormatAndTypeForInternalFormat(internalFormat);
|
|
@@ -6513,55 +6671,31 @@ function setTextureFromArray(gl, tex, src, options) {
|
|
|
6513
6671
|
src = new Uint8Array(src.buffer);
|
|
6514
6672
|
}
|
|
6515
6673
|
|
|
6516
|
-
const
|
|
6517
|
-
const
|
|
6518
|
-
|
|
6519
|
-
throw "length wrong size for format: " + glEnumToString(gl, format);
|
|
6520
|
-
}
|
|
6521
|
-
let dimensions;
|
|
6522
|
-
if (target === TEXTURE_3D$1 || target === TEXTURE_2D_ARRAY$1) {
|
|
6523
|
-
if (!width && !height && !depth) {
|
|
6524
|
-
const size = Math.cbrt(numElements);
|
|
6525
|
-
if (size % 1 !== 0) {
|
|
6526
|
-
throw "can't guess cube size of array of numElements: " + numElements;
|
|
6527
|
-
}
|
|
6528
|
-
width = size;
|
|
6529
|
-
height = size;
|
|
6530
|
-
depth = size;
|
|
6531
|
-
} else if (width && (!height || !depth)) {
|
|
6532
|
-
dimensions = guessDimensions(gl, target, height, depth, numElements / width);
|
|
6533
|
-
height = dimensions.width;
|
|
6534
|
-
depth = dimensions.height;
|
|
6535
|
-
} else if (height && (!width || !depth)) {
|
|
6536
|
-
dimensions = guessDimensions(gl, target, width, depth, numElements / height);
|
|
6537
|
-
width = dimensions.width;
|
|
6538
|
-
depth = dimensions.height;
|
|
6539
|
-
} else {
|
|
6540
|
-
dimensions = guessDimensions(gl, target, width, height, numElements / depth);
|
|
6541
|
-
width = dimensions.width;
|
|
6542
|
-
height = dimensions.height;
|
|
6543
|
-
}
|
|
6544
|
-
} else {
|
|
6545
|
-
dimensions = guessDimensions(gl, target, width, height, numElements);
|
|
6546
|
-
width = dimensions.width;
|
|
6547
|
-
height = dimensions.height;
|
|
6548
|
-
}
|
|
6674
|
+
const { width, height, depth } = getTextureSize(gl, target, src, options, internalFormat, format, type);
|
|
6675
|
+
const compressed = isCompressedInternalFormat(internalFormat);
|
|
6676
|
+
|
|
6549
6677
|
setSkipStateToDefault(gl);
|
|
6550
6678
|
gl.pixelStorei(UNPACK_ALIGNMENT, options.unpackAlignment || 1);
|
|
6551
6679
|
scopedSetPackState(gl, options, () => {
|
|
6552
6680
|
if (target === TEXTURE_CUBE_MAP$1) {
|
|
6553
|
-
const
|
|
6554
|
-
const faceSize = numElements / 6 * elementsPerElement;
|
|
6555
|
-
|
|
6681
|
+
const faceSize = src.length / 6;
|
|
6556
6682
|
getCubeFacesWithNdx(gl, options).forEach(f => {
|
|
6557
6683
|
const offset = faceSize * f.ndx;
|
|
6558
6684
|
const data = src.subarray(offset, offset + faceSize);
|
|
6559
|
-
|
|
6685
|
+
if (compressed) {
|
|
6686
|
+
gl.compressedTexImage2D(f.face, level, internalFormat, width, height, 0, data);
|
|
6687
|
+
} else {
|
|
6688
|
+
gl.texImage2D(f.face, level, internalFormat, width, height, 0, format, type, data);
|
|
6689
|
+
}
|
|
6560
6690
|
});
|
|
6561
6691
|
} else if (target === TEXTURE_3D$1 || target === TEXTURE_2D_ARRAY$1) {
|
|
6562
6692
|
gl.texImage3D(target, level, internalFormat, width, height, depth, 0, format, type, src);
|
|
6563
6693
|
} else {
|
|
6564
|
-
|
|
6694
|
+
if (compressed) {
|
|
6695
|
+
gl.compressedTexImage2D(target, level, internalFormat, width, height, 0, src);
|
|
6696
|
+
} else {
|
|
6697
|
+
gl.texImage2D(target, level, internalFormat, width, height, 0, format, type, src);
|
|
6698
|
+
}
|
|
6565
6699
|
}
|
|
6566
6700
|
});
|
|
6567
6701
|
return {
|
|
@@ -6572,6 +6706,59 @@ function setTextureFromArray(gl, tex, src, options) {
|
|
|
6572
6706
|
};
|
|
6573
6707
|
}
|
|
6574
6708
|
|
|
6709
|
+
function getTextureSize(gl, target, src, options, internalFormat, format, type) {
|
|
6710
|
+
let width = options.width;
|
|
6711
|
+
let height = options.height;
|
|
6712
|
+
let depth = options.depth;
|
|
6713
|
+
|
|
6714
|
+
const compressed = isCompressedInternalFormat(internalFormat);
|
|
6715
|
+
if (compressed) {
|
|
6716
|
+
if (!width || !height) {
|
|
6717
|
+
throw "compressed texture needs to set width and height!";
|
|
6718
|
+
}
|
|
6719
|
+
} else {
|
|
6720
|
+
const bytesPerElement = getBytesPerElementForInternalFormat(internalFormat, type);
|
|
6721
|
+
const numElements = src.byteLength / bytesPerElement; // TODO: check UNPACK_ALIGNMENT?
|
|
6722
|
+
if (numElements % 1) {
|
|
6723
|
+
throw "length wrong size for format: " + glEnumToString(gl, format);
|
|
6724
|
+
}
|
|
6725
|
+
let dimensions;
|
|
6726
|
+
if (target === TEXTURE_3D$1 || target === TEXTURE_2D_ARRAY$1) {
|
|
6727
|
+
if (!width && !height && !depth) {
|
|
6728
|
+
const size = Math.cbrt(numElements);
|
|
6729
|
+
if (size % 1 !== 0) {
|
|
6730
|
+
throw "can't guess cube size of array of numElements: " + numElements;
|
|
6731
|
+
}
|
|
6732
|
+
width = size;
|
|
6733
|
+
height = size;
|
|
6734
|
+
depth = size;
|
|
6735
|
+
} else if (width && (!height || !depth)) {
|
|
6736
|
+
dimensions = guessDimensions(gl, target, height, depth, numElements / width);
|
|
6737
|
+
height = dimensions.width;
|
|
6738
|
+
depth = dimensions.height;
|
|
6739
|
+
} else if (height && (!width || !depth)) {
|
|
6740
|
+
dimensions = guessDimensions(gl, target, width, depth, numElements / height);
|
|
6741
|
+
width = dimensions.width;
|
|
6742
|
+
depth = dimensions.height;
|
|
6743
|
+
} else {
|
|
6744
|
+
dimensions = guessDimensions(gl, target, width, height, numElements / depth);
|
|
6745
|
+
width = dimensions.width;
|
|
6746
|
+
height = dimensions.height;
|
|
6747
|
+
}
|
|
6748
|
+
} else {
|
|
6749
|
+
dimensions = guessDimensions(gl, target, width, height, numElements);
|
|
6750
|
+
width = dimensions.width;
|
|
6751
|
+
height = dimensions.height;
|
|
6752
|
+
}
|
|
6753
|
+
}
|
|
6754
|
+
|
|
6755
|
+
return {
|
|
6756
|
+
width,
|
|
6757
|
+
height,
|
|
6758
|
+
depth,
|
|
6759
|
+
};
|
|
6760
|
+
}
|
|
6761
|
+
|
|
6575
6762
|
/**
|
|
6576
6763
|
* Sets a texture with no contents of a certain size. In other words calls `gl.texImage2D` with `null`.
|
|
6577
6764
|
* You must set `options.width` and `options.height`.
|
|
@@ -10075,6 +10262,8 @@ const supportedExtensions = [
|
|
|
10075
10262
|
'EXT_frag_depth',
|
|
10076
10263
|
'EXT_sRGB',
|
|
10077
10264
|
'EXT_shader_texture_lod',
|
|
10265
|
+
'EXT_texture_compression_bptc',
|
|
10266
|
+
'EXT_texture_compression_rgtc',
|
|
10078
10267
|
'EXT_texture_filter_anisotropic',
|
|
10079
10268
|
'OES_element_index_uint',
|
|
10080
10269
|
'OES_standard_derivatives',
|
|
@@ -10086,6 +10275,7 @@ const supportedExtensions = [
|
|
|
10086
10275
|
'WEBGL_color_buffer_float',
|
|
10087
10276
|
'WEBGL_compressed_texture_atc',
|
|
10088
10277
|
'WEBGL_compressed_texture_etc1',
|
|
10278
|
+
'WEBGL_compressed_texture_etc',
|
|
10089
10279
|
'WEBGL_compressed_texture_pvrtc',
|
|
10090
10280
|
'WEBGL_compressed_texture_s3tc',
|
|
10091
10281
|
'WEBGL_compressed_texture_s3tc_srgb',
|