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
package/dist/6.x/twgl-full.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @license twgl.js 6.
|
|
2
|
+
* @license twgl.js 6.2.0 Copyright (c) 2015, Gregg Tavares All Rights Reserved.
|
|
3
3
|
* Available via the MIT license.
|
|
4
4
|
* see: http://github.com/greggman/twgl.js for details
|
|
5
5
|
*/
|
|
@@ -7275,6 +7275,74 @@ var RED = 0x1903;
|
|
|
7275
7275
|
var RED_INTEGER = 0x8D94;
|
|
7276
7276
|
var RGB_INTEGER = 0x8D98;
|
|
7277
7277
|
var RGBA_INTEGER = 0x8D99;
|
|
7278
|
+
|
|
7279
|
+
/* Compressed Texture Formats */
|
|
7280
|
+
// s3tc
|
|
7281
|
+
var COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
|
|
7282
|
+
var COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
|
|
7283
|
+
var COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2;
|
|
7284
|
+
var COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
|
|
7285
|
+
// s3tc_srgb
|
|
7286
|
+
var COMPRESSED_SRGB_S3TC_DXT1_EXT = 0x8C4C;
|
|
7287
|
+
var COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 0x8C4D;
|
|
7288
|
+
var COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 0x8C4E;
|
|
7289
|
+
var COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 0x8C4F;
|
|
7290
|
+
// etc
|
|
7291
|
+
var COMPRESSED_RGB_ETC1_WEBGL = 0x8D64;
|
|
7292
|
+
var COMPRESSED_R11_EAC = 0x9270;
|
|
7293
|
+
var COMPRESSED_SIGNED_R11_EAC = 0x9271;
|
|
7294
|
+
var COMPRESSED_RG11_EAC = 0x9272;
|
|
7295
|
+
var COMPRESSED_SIGNED_RG11_EAC = 0x9273;
|
|
7296
|
+
var COMPRESSED_RGB8_ETC2 = 0x9274;
|
|
7297
|
+
var COMPRESSED_SRGB8_ETC2 = 0x9275;
|
|
7298
|
+
var COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276;
|
|
7299
|
+
var COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277;
|
|
7300
|
+
var COMPRESSED_RGBA8_ETC2_EAC = 0x9278;
|
|
7301
|
+
var COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279;
|
|
7302
|
+
// pvrtc
|
|
7303
|
+
var COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00;
|
|
7304
|
+
var COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01;
|
|
7305
|
+
var COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02;
|
|
7306
|
+
var COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03;
|
|
7307
|
+
// astc
|
|
7308
|
+
var COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0;
|
|
7309
|
+
var COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93B1;
|
|
7310
|
+
var COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93B2;
|
|
7311
|
+
var COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93B3;
|
|
7312
|
+
var COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93B4;
|
|
7313
|
+
var COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93B5;
|
|
7314
|
+
var COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93B6;
|
|
7315
|
+
var COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93B7;
|
|
7316
|
+
var COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93B8;
|
|
7317
|
+
var COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93B9;
|
|
7318
|
+
var COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93BA;
|
|
7319
|
+
var COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93BB;
|
|
7320
|
+
var COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93BC;
|
|
7321
|
+
var COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93BD;
|
|
7322
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93D0;
|
|
7323
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93D1;
|
|
7324
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93D2;
|
|
7325
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93D3;
|
|
7326
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93D4;
|
|
7327
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93D5;
|
|
7328
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93D6;
|
|
7329
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93D7;
|
|
7330
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93D8;
|
|
7331
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93D9;
|
|
7332
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93DA;
|
|
7333
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93DB;
|
|
7334
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93DC;
|
|
7335
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD;
|
|
7336
|
+
// bptc
|
|
7337
|
+
var COMPRESSED_RGBA_BPTC_UNORM_EXT = 0x8E8C;
|
|
7338
|
+
var COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = 0x8E8D;
|
|
7339
|
+
var COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT = 0x8E8E;
|
|
7340
|
+
var COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT = 0x8E8F;
|
|
7341
|
+
// rgtc
|
|
7342
|
+
var COMPRESSED_RED_RGTC1_EXT = 0x8DBB;
|
|
7343
|
+
var COMPRESSED_SIGNED_RED_RGTC1_EXT = 0x8DBC;
|
|
7344
|
+
var COMPRESSED_RED_GREEN_RGTC2_EXT = 0x8DBD;
|
|
7345
|
+
var COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT = 0x8DBE;
|
|
7278
7346
|
var formatInfo = {};
|
|
7279
7347
|
{
|
|
7280
7348
|
// NOTE: this is named `numColorComponents` vs `numComponents` so we can let Uglify mangle
|
|
@@ -7333,7 +7401,8 @@ var formatInfo = {};
|
|
|
7333
7401
|
* @property {boolean} colorRenderable true if you can render to this format of texture.
|
|
7334
7402
|
* @property {boolean} textureFilterable true if you can filter the texture, false if you can ony use `NEAREST`.
|
|
7335
7403
|
* @property {number[]} type Array of possible types you can pass to texImage2D and similar function
|
|
7336
|
-
* @property {Object.<number,number>} bytesPerElementMap A map of types to bytes per element
|
|
7404
|
+
* @property {Object.<number,number>} [bytesPerElementMap] A map of types to bytes per element
|
|
7405
|
+
* @property {boolean} [compressed] true if it's a compressed texture format
|
|
7337
7406
|
* @private
|
|
7338
7407
|
*/
|
|
7339
7408
|
|
|
@@ -7774,6 +7843,318 @@ function getTextureInternalFormatInfo(internalFormat) {
|
|
|
7774
7843
|
info.bytesPerElementMap[type] = bytesPerElement;
|
|
7775
7844
|
});
|
|
7776
7845
|
});
|
|
7846
|
+
var getCompressedFormatInfo = function getCompressedFormatInfo() {
|
|
7847
|
+
var t = {};
|
|
7848
|
+
// compressed texture formats
|
|
7849
|
+
// s3tc:https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc.txt
|
|
7850
|
+
t[COMPRESSED_RGB_S3TC_DXT1_EXT] = {
|
|
7851
|
+
textureFormat: COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
7852
|
+
colorRenderable: false,
|
|
7853
|
+
textureFilterable: true
|
|
7854
|
+
};
|
|
7855
|
+
t[COMPRESSED_RGBA_S3TC_DXT1_EXT] = {
|
|
7856
|
+
textureFormat: COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
7857
|
+
colorRenderable: false,
|
|
7858
|
+
textureFilterable: true
|
|
7859
|
+
};
|
|
7860
|
+
t[COMPRESSED_RGBA_S3TC_DXT3_EXT] = {
|
|
7861
|
+
textureFormat: COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
7862
|
+
colorRenderable: false,
|
|
7863
|
+
textureFilterable: true
|
|
7864
|
+
};
|
|
7865
|
+
t[COMPRESSED_RGBA_S3TC_DXT5_EXT] = {
|
|
7866
|
+
textureFormat: COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
7867
|
+
colorRenderable: false,
|
|
7868
|
+
textureFilterable: true
|
|
7869
|
+
};
|
|
7870
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc_srgb.txt
|
|
7871
|
+
t[COMPRESSED_SRGB_S3TC_DXT1_EXT] = {
|
|
7872
|
+
textureFormat: COMPRESSED_SRGB_S3TC_DXT1_EXT,
|
|
7873
|
+
colorRenderable: false,
|
|
7874
|
+
textureFilterable: true
|
|
7875
|
+
};
|
|
7876
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = {
|
|
7877
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
|
|
7878
|
+
colorRenderable: false,
|
|
7879
|
+
textureFilterable: true
|
|
7880
|
+
};
|
|
7881
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = {
|
|
7882
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
|
|
7883
|
+
colorRenderable: false,
|
|
7884
|
+
textureFilterable: true
|
|
7885
|
+
};
|
|
7886
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = {
|
|
7887
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
|
|
7888
|
+
colorRenderable: false,
|
|
7889
|
+
textureFilterable: true
|
|
7890
|
+
};
|
|
7891
|
+
// https://registry.khronos.org/OpenGL/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt
|
|
7892
|
+
t[COMPRESSED_RGB_ETC1_WEBGL] = {
|
|
7893
|
+
textureFormat: COMPRESSED_RGB_ETC1_WEBGL,
|
|
7894
|
+
colorRenderable: false,
|
|
7895
|
+
textureFilterable: true
|
|
7896
|
+
};
|
|
7897
|
+
t[COMPRESSED_R11_EAC] = {
|
|
7898
|
+
textureFormat: COMPRESSED_R11_EAC,
|
|
7899
|
+
colorRenderable: false,
|
|
7900
|
+
textureFilterable: true
|
|
7901
|
+
};
|
|
7902
|
+
t[COMPRESSED_SIGNED_R11_EAC] = {
|
|
7903
|
+
textureFormat: COMPRESSED_SIGNED_R11_EAC,
|
|
7904
|
+
colorRenderable: false,
|
|
7905
|
+
textureFilterable: true
|
|
7906
|
+
};
|
|
7907
|
+
t[COMPRESSED_RG11_EAC] = {
|
|
7908
|
+
textureFormat: COMPRESSED_RG11_EAC,
|
|
7909
|
+
colorRenderable: false,
|
|
7910
|
+
textureFilterable: true
|
|
7911
|
+
};
|
|
7912
|
+
t[COMPRESSED_SIGNED_RG11_EAC] = {
|
|
7913
|
+
textureFormat: COMPRESSED_SIGNED_RG11_EAC,
|
|
7914
|
+
colorRenderable: false,
|
|
7915
|
+
textureFilterable: true
|
|
7916
|
+
};
|
|
7917
|
+
t[COMPRESSED_RGB8_ETC2] = {
|
|
7918
|
+
textureFormat: COMPRESSED_RGB8_ETC2,
|
|
7919
|
+
colorRenderable: false,
|
|
7920
|
+
textureFilterable: true
|
|
7921
|
+
};
|
|
7922
|
+
t[COMPRESSED_SRGB8_ETC2] = {
|
|
7923
|
+
textureFormat: COMPRESSED_SRGB8_ETC2,
|
|
7924
|
+
colorRenderable: false,
|
|
7925
|
+
textureFilterable: true
|
|
7926
|
+
};
|
|
7927
|
+
t[COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = {
|
|
7928
|
+
textureFormat: COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
7929
|
+
colorRenderable: false,
|
|
7930
|
+
textureFilterable: true
|
|
7931
|
+
};
|
|
7932
|
+
t[COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = {
|
|
7933
|
+
textureFormat: COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
7934
|
+
colorRenderable: false,
|
|
7935
|
+
textureFilterable: true
|
|
7936
|
+
};
|
|
7937
|
+
t[COMPRESSED_RGBA8_ETC2_EAC] = {
|
|
7938
|
+
textureFormat: COMPRESSED_RGBA8_ETC2_EAC,
|
|
7939
|
+
colorRenderable: false,
|
|
7940
|
+
textureFilterable: true
|
|
7941
|
+
};
|
|
7942
|
+
t[COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = {
|
|
7943
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
|
|
7944
|
+
colorRenderable: false,
|
|
7945
|
+
textureFilterable: true
|
|
7946
|
+
};
|
|
7947
|
+
// https://registry.khronos.org/OpenGL/extensions/IMG/IMG_texture_compression_pvrtc.txt
|
|
7948
|
+
t[COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = {
|
|
7949
|
+
textureFormat: COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
7950
|
+
colorRenderable: false,
|
|
7951
|
+
textureFilterable: true
|
|
7952
|
+
};
|
|
7953
|
+
t[COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = {
|
|
7954
|
+
textureFormat: COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
|
|
7955
|
+
colorRenderable: false,
|
|
7956
|
+
textureFilterable: true
|
|
7957
|
+
};
|
|
7958
|
+
t[COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = {
|
|
7959
|
+
textureFormat: COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
7960
|
+
colorRenderable: false,
|
|
7961
|
+
textureFilterable: true
|
|
7962
|
+
};
|
|
7963
|
+
t[COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = {
|
|
7964
|
+
textureFormat: COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
7965
|
+
colorRenderable: false,
|
|
7966
|
+
textureFilterable: true
|
|
7967
|
+
};
|
|
7968
|
+
// https://registry.khronos.org/OpenGL/extensions/KHR/KHR_texture_compression_astc_hdr.txt
|
|
7969
|
+
t[COMPRESSED_RGBA_ASTC_4x4_KHR] = {
|
|
7970
|
+
textureFormat: COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
7971
|
+
colorRenderable: false,
|
|
7972
|
+
textureFilterable: true
|
|
7973
|
+
};
|
|
7974
|
+
t[COMPRESSED_RGBA_ASTC_5x4_KHR] = {
|
|
7975
|
+
textureFormat: COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
7976
|
+
colorRenderable: false,
|
|
7977
|
+
textureFilterable: true
|
|
7978
|
+
};
|
|
7979
|
+
t[COMPRESSED_RGBA_ASTC_5x5_KHR] = {
|
|
7980
|
+
textureFormat: COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
7981
|
+
colorRenderable: false,
|
|
7982
|
+
textureFilterable: true
|
|
7983
|
+
};
|
|
7984
|
+
t[COMPRESSED_RGBA_ASTC_6x5_KHR] = {
|
|
7985
|
+
textureFormat: COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
7986
|
+
colorRenderable: false,
|
|
7987
|
+
textureFilterable: true
|
|
7988
|
+
};
|
|
7989
|
+
t[COMPRESSED_RGBA_ASTC_6x6_KHR] = {
|
|
7990
|
+
textureFormat: COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
7991
|
+
colorRenderable: false,
|
|
7992
|
+
textureFilterable: true
|
|
7993
|
+
};
|
|
7994
|
+
t[COMPRESSED_RGBA_ASTC_8x5_KHR] = {
|
|
7995
|
+
textureFormat: COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
7996
|
+
colorRenderable: false,
|
|
7997
|
+
textureFilterable: true
|
|
7998
|
+
};
|
|
7999
|
+
t[COMPRESSED_RGBA_ASTC_8x6_KHR] = {
|
|
8000
|
+
textureFormat: COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
8001
|
+
colorRenderable: false,
|
|
8002
|
+
textureFilterable: true
|
|
8003
|
+
};
|
|
8004
|
+
t[COMPRESSED_RGBA_ASTC_8x8_KHR] = {
|
|
8005
|
+
textureFormat: COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
8006
|
+
colorRenderable: false,
|
|
8007
|
+
textureFilterable: true
|
|
8008
|
+
};
|
|
8009
|
+
t[COMPRESSED_RGBA_ASTC_10x5_KHR] = {
|
|
8010
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
8011
|
+
colorRenderable: false,
|
|
8012
|
+
textureFilterable: true
|
|
8013
|
+
};
|
|
8014
|
+
t[COMPRESSED_RGBA_ASTC_10x6_KHR] = {
|
|
8015
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
8016
|
+
colorRenderable: false,
|
|
8017
|
+
textureFilterable: true
|
|
8018
|
+
};
|
|
8019
|
+
t[COMPRESSED_RGBA_ASTC_10x8_KHR] = {
|
|
8020
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
8021
|
+
colorRenderable: false,
|
|
8022
|
+
textureFilterable: true
|
|
8023
|
+
};
|
|
8024
|
+
t[COMPRESSED_RGBA_ASTC_10x10_KHR] = {
|
|
8025
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
8026
|
+
colorRenderable: false,
|
|
8027
|
+
textureFilterable: true
|
|
8028
|
+
};
|
|
8029
|
+
t[COMPRESSED_RGBA_ASTC_12x10_KHR] = {
|
|
8030
|
+
textureFormat: COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
8031
|
+
colorRenderable: false,
|
|
8032
|
+
textureFilterable: true
|
|
8033
|
+
};
|
|
8034
|
+
t[COMPRESSED_RGBA_ASTC_12x12_KHR] = {
|
|
8035
|
+
textureFormat: COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
8036
|
+
colorRenderable: false,
|
|
8037
|
+
textureFilterable: true
|
|
8038
|
+
};
|
|
8039
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR] = {
|
|
8040
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
8041
|
+
colorRenderable: false,
|
|
8042
|
+
textureFilterable: true
|
|
8043
|
+
};
|
|
8044
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR] = {
|
|
8045
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
8046
|
+
colorRenderable: false,
|
|
8047
|
+
textureFilterable: true
|
|
8048
|
+
};
|
|
8049
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR] = {
|
|
8050
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
8051
|
+
colorRenderable: false,
|
|
8052
|
+
textureFilterable: true
|
|
8053
|
+
};
|
|
8054
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR] = {
|
|
8055
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
8056
|
+
colorRenderable: false,
|
|
8057
|
+
textureFilterable: true
|
|
8058
|
+
};
|
|
8059
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR] = {
|
|
8060
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
8061
|
+
colorRenderable: false,
|
|
8062
|
+
textureFilterable: true
|
|
8063
|
+
};
|
|
8064
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR] = {
|
|
8065
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
8066
|
+
colorRenderable: false,
|
|
8067
|
+
textureFilterable: true
|
|
8068
|
+
};
|
|
8069
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR] = {
|
|
8070
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
8071
|
+
colorRenderable: false,
|
|
8072
|
+
textureFilterable: true
|
|
8073
|
+
};
|
|
8074
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR] = {
|
|
8075
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
8076
|
+
colorRenderable: false,
|
|
8077
|
+
textureFilterable: true
|
|
8078
|
+
};
|
|
8079
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR] = {
|
|
8080
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
8081
|
+
colorRenderable: false,
|
|
8082
|
+
textureFilterable: true
|
|
8083
|
+
};
|
|
8084
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR] = {
|
|
8085
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
8086
|
+
colorRenderable: false,
|
|
8087
|
+
textureFilterable: true
|
|
8088
|
+
};
|
|
8089
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR] = {
|
|
8090
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
8091
|
+
colorRenderable: false,
|
|
8092
|
+
textureFilterable: true
|
|
8093
|
+
};
|
|
8094
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR] = {
|
|
8095
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
8096
|
+
colorRenderable: false,
|
|
8097
|
+
textureFilterable: true
|
|
8098
|
+
};
|
|
8099
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR] = {
|
|
8100
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
8101
|
+
colorRenderable: false,
|
|
8102
|
+
textureFilterable: true
|
|
8103
|
+
};
|
|
8104
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR] = {
|
|
8105
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
8106
|
+
colorRenderable: false,
|
|
8107
|
+
textureFilterable: true
|
|
8108
|
+
};
|
|
8109
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_bptc.txt
|
|
8110
|
+
t[COMPRESSED_RGBA_BPTC_UNORM_EXT] = {
|
|
8111
|
+
textureFormat: COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
8112
|
+
colorRenderable: false,
|
|
8113
|
+
textureFilterable: true
|
|
8114
|
+
};
|
|
8115
|
+
t[COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT] = {
|
|
8116
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
|
|
8117
|
+
colorRenderable: false,
|
|
8118
|
+
textureFilterable: true
|
|
8119
|
+
};
|
|
8120
|
+
t[COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT] = {
|
|
8121
|
+
textureFormat: COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
|
|
8122
|
+
colorRenderable: false,
|
|
8123
|
+
textureFilterable: true
|
|
8124
|
+
};
|
|
8125
|
+
t[COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT] = {
|
|
8126
|
+
textureFormat: COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
|
|
8127
|
+
colorRenderable: false,
|
|
8128
|
+
textureFilterable: true
|
|
8129
|
+
};
|
|
8130
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_rgtc.txt
|
|
8131
|
+
t[COMPRESSED_RED_RGTC1_EXT] = {
|
|
8132
|
+
textureFormat: COMPRESSED_RED_RGTC1_EXT,
|
|
8133
|
+
colorRenderable: false,
|
|
8134
|
+
textureFilterable: true
|
|
8135
|
+
};
|
|
8136
|
+
t[COMPRESSED_SIGNED_RED_RGTC1_EXT] = {
|
|
8137
|
+
textureFormat: COMPRESSED_SIGNED_RED_RGTC1_EXT,
|
|
8138
|
+
colorRenderable: false,
|
|
8139
|
+
textureFilterable: true
|
|
8140
|
+
};
|
|
8141
|
+
t[COMPRESSED_RED_GREEN_RGTC2_EXT] = {
|
|
8142
|
+
textureFormat: COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
8143
|
+
colorRenderable: false,
|
|
8144
|
+
textureFilterable: true
|
|
8145
|
+
};
|
|
8146
|
+
t[COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT] = {
|
|
8147
|
+
textureFormat: COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
|
|
8148
|
+
colorRenderable: false,
|
|
8149
|
+
textureFilterable: true
|
|
8150
|
+
};
|
|
8151
|
+
for (var _i = 0, _Object$values = Object.values(t); _i < _Object$values.length; _i++) {
|
|
8152
|
+
var info = _Object$values[_i];
|
|
8153
|
+
info.compressed = true;
|
|
8154
|
+
}
|
|
8155
|
+
return t;
|
|
8156
|
+
};
|
|
8157
|
+
Object.assign(t, getCompressedFormatInfo());
|
|
7777
8158
|
s_textureInternalFormatInfo = t;
|
|
7778
8159
|
}
|
|
7779
8160
|
return s_textureInternalFormatInfo[internalFormat];
|
|
@@ -7816,16 +8197,30 @@ function getBytesPerElementForInternalFormat(internalFormat, type) {
|
|
|
7816
8197
|
* @memberOf module:twgl/textures
|
|
7817
8198
|
*/
|
|
7818
8199
|
function getFormatAndTypeForInternalFormat(internalFormat) {
|
|
8200
|
+
var _info$type$, _info$type;
|
|
7819
8201
|
var info = getTextureInternalFormatInfo(internalFormat);
|
|
7820
8202
|
if (!info) {
|
|
7821
8203
|
throw "unknown internal format";
|
|
7822
8204
|
}
|
|
7823
8205
|
return {
|
|
7824
8206
|
format: info.textureFormat,
|
|
7825
|
-
type: info.type[0]
|
|
8207
|
+
type: (_info$type$ = (_info$type = info.type) === null || _info$type === void 0 ? void 0 : _info$type[0]) !== null && _info$type$ !== void 0 ? _info$type$ : UNSIGNED_BYTE
|
|
7826
8208
|
};
|
|
7827
8209
|
}
|
|
7828
8210
|
|
|
8211
|
+
/**
|
|
8212
|
+
* @param {number} internalFormat The internal format
|
|
8213
|
+
* @returns if the internalFormat is a compressed format
|
|
8214
|
+
* @private
|
|
8215
|
+
*/
|
|
8216
|
+
function isCompressedInternalFormat(internalFormat) {
|
|
8217
|
+
var info = getTextureInternalFormatInfo(internalFormat);
|
|
8218
|
+
if (!info) {
|
|
8219
|
+
throw "unknown internal format";
|
|
8220
|
+
}
|
|
8221
|
+
return !!info.compressed;
|
|
8222
|
+
}
|
|
8223
|
+
|
|
7829
8224
|
/**
|
|
7830
8225
|
* Returns true if value is power of 2
|
|
7831
8226
|
* @param {number} value number to check.
|
|
@@ -8920,9 +9315,6 @@ function setTextureFromArray(gl, tex, src, options) {
|
|
|
8920
9315
|
options = options || defaults.textureOptions;
|
|
8921
9316
|
var target = options.target || TEXTURE_2D;
|
|
8922
9317
|
gl.bindTexture(target, tex);
|
|
8923
|
-
var width = options.width;
|
|
8924
|
-
var height = options.height;
|
|
8925
|
-
var depth = options.depth;
|
|
8926
9318
|
var level = options.level || 0;
|
|
8927
9319
|
var internalFormat = options.internalFormat || options.format || RGBA;
|
|
8928
9320
|
var formatType = getFormatAndTypeForInternalFormat(internalFormat);
|
|
@@ -8934,54 +9326,33 @@ function setTextureFromArray(gl, tex, src, options) {
|
|
|
8934
9326
|
} else if (src instanceof Uint8ClampedArray) {
|
|
8935
9327
|
src = new Uint8Array(src.buffer);
|
|
8936
9328
|
}
|
|
8937
|
-
var
|
|
8938
|
-
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
var dimensions;
|
|
8943
|
-
if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
|
|
8944
|
-
if (!width && !height && !depth) {
|
|
8945
|
-
var size = Math.cbrt(numElements);
|
|
8946
|
-
if (size % 1 !== 0) {
|
|
8947
|
-
throw "can't guess cube size of array of numElements: " + numElements;
|
|
8948
|
-
}
|
|
8949
|
-
width = size;
|
|
8950
|
-
height = size;
|
|
8951
|
-
depth = size;
|
|
8952
|
-
} else if (width && (!height || !depth)) {
|
|
8953
|
-
dimensions = guessDimensions(gl, target, height, depth, numElements / width);
|
|
8954
|
-
height = dimensions.width;
|
|
8955
|
-
depth = dimensions.height;
|
|
8956
|
-
} else if (height && (!width || !depth)) {
|
|
8957
|
-
dimensions = guessDimensions(gl, target, width, depth, numElements / height);
|
|
8958
|
-
width = dimensions.width;
|
|
8959
|
-
depth = dimensions.height;
|
|
8960
|
-
} else {
|
|
8961
|
-
dimensions = guessDimensions(gl, target, width, height, numElements / depth);
|
|
8962
|
-
width = dimensions.width;
|
|
8963
|
-
height = dimensions.height;
|
|
8964
|
-
}
|
|
8965
|
-
} else {
|
|
8966
|
-
dimensions = guessDimensions(gl, target, width, height, numElements);
|
|
8967
|
-
width = dimensions.width;
|
|
8968
|
-
height = dimensions.height;
|
|
8969
|
-
}
|
|
9329
|
+
var _getTextureSize = getTextureSize(gl, target, src, options, internalFormat, format, type),
|
|
9330
|
+
width = _getTextureSize.width,
|
|
9331
|
+
height = _getTextureSize.height,
|
|
9332
|
+
depth = _getTextureSize.depth;
|
|
9333
|
+
var compressed = isCompressedInternalFormat(internalFormat);
|
|
8970
9334
|
setSkipStateToDefault(gl);
|
|
8971
9335
|
gl.pixelStorei(UNPACK_ALIGNMENT, options.unpackAlignment || 1);
|
|
8972
9336
|
scopedSetPackState(gl, options, function () {
|
|
8973
9337
|
if (target === TEXTURE_CUBE_MAP) {
|
|
8974
|
-
var
|
|
8975
|
-
var faceSize = numElements / 6 * elementsPerElement;
|
|
9338
|
+
var faceSize = src.length / 6;
|
|
8976
9339
|
getCubeFacesWithNdx(gl, options).forEach(function (f) {
|
|
8977
9340
|
var offset = faceSize * f.ndx;
|
|
8978
9341
|
var data = src.subarray(offset, offset + faceSize);
|
|
8979
|
-
|
|
9342
|
+
if (compressed) {
|
|
9343
|
+
gl.compressedTexImage2D(f.face, level, internalFormat, width, height, 0, data);
|
|
9344
|
+
} else {
|
|
9345
|
+
gl.texImage2D(f.face, level, internalFormat, width, height, 0, format, type, data);
|
|
9346
|
+
}
|
|
8980
9347
|
});
|
|
8981
9348
|
} else if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
|
|
8982
9349
|
gl.texImage3D(target, level, internalFormat, width, height, depth, 0, format, type, src);
|
|
8983
9350
|
} else {
|
|
8984
|
-
|
|
9351
|
+
if (compressed) {
|
|
9352
|
+
gl.compressedTexImage2D(target, level, internalFormat, width, height, 0, src);
|
|
9353
|
+
} else {
|
|
9354
|
+
gl.texImage2D(target, level, internalFormat, width, height, 0, format, type, src);
|
|
9355
|
+
}
|
|
8985
9356
|
}
|
|
8986
9357
|
});
|
|
8987
9358
|
return {
|
|
@@ -8991,6 +9362,56 @@ function setTextureFromArray(gl, tex, src, options) {
|
|
|
8991
9362
|
type: type
|
|
8992
9363
|
};
|
|
8993
9364
|
}
|
|
9365
|
+
function getTextureSize(gl, target, src, options, internalFormat, format, type) {
|
|
9366
|
+
var width = options.width;
|
|
9367
|
+
var height = options.height;
|
|
9368
|
+
var depth = options.depth;
|
|
9369
|
+
var compressed = isCompressedInternalFormat(internalFormat);
|
|
9370
|
+
if (compressed) {
|
|
9371
|
+
if (!width || !height) {
|
|
9372
|
+
throw "compressed texture needs to set width and height!";
|
|
9373
|
+
}
|
|
9374
|
+
} else {
|
|
9375
|
+
var bytesPerElement = getBytesPerElementForInternalFormat(internalFormat, type);
|
|
9376
|
+
var numElements = src.byteLength / bytesPerElement; // TODO: check UNPACK_ALIGNMENT?
|
|
9377
|
+
if (numElements % 1) {
|
|
9378
|
+
throw "length wrong size for format: " + utils.glEnumToString(gl, format);
|
|
9379
|
+
}
|
|
9380
|
+
var dimensions;
|
|
9381
|
+
if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
|
|
9382
|
+
if (!width && !height && !depth) {
|
|
9383
|
+
var size = Math.cbrt(numElements);
|
|
9384
|
+
if (size % 1 !== 0) {
|
|
9385
|
+
throw "can't guess cube size of array of numElements: " + numElements;
|
|
9386
|
+
}
|
|
9387
|
+
width = size;
|
|
9388
|
+
height = size;
|
|
9389
|
+
depth = size;
|
|
9390
|
+
} else if (width && (!height || !depth)) {
|
|
9391
|
+
dimensions = guessDimensions(gl, target, height, depth, numElements / width);
|
|
9392
|
+
height = dimensions.width;
|
|
9393
|
+
depth = dimensions.height;
|
|
9394
|
+
} else if (height && (!width || !depth)) {
|
|
9395
|
+
dimensions = guessDimensions(gl, target, width, depth, numElements / height);
|
|
9396
|
+
width = dimensions.width;
|
|
9397
|
+
depth = dimensions.height;
|
|
9398
|
+
} else {
|
|
9399
|
+
dimensions = guessDimensions(gl, target, width, height, numElements / depth);
|
|
9400
|
+
width = dimensions.width;
|
|
9401
|
+
height = dimensions.height;
|
|
9402
|
+
}
|
|
9403
|
+
} else {
|
|
9404
|
+
dimensions = guessDimensions(gl, target, width, height, numElements);
|
|
9405
|
+
width = dimensions.width;
|
|
9406
|
+
height = dimensions.height;
|
|
9407
|
+
}
|
|
9408
|
+
}
|
|
9409
|
+
return {
|
|
9410
|
+
width: width,
|
|
9411
|
+
height: height,
|
|
9412
|
+
depth: depth
|
|
9413
|
+
};
|
|
9414
|
+
}
|
|
8994
9415
|
|
|
8995
9416
|
/**
|
|
8996
9417
|
* Sets a texture with no contents of a certain size. In other words calls `gl.texImage2D` with `null`.
|
|
@@ -9671,7 +10092,7 @@ function addExtensionToContext(gl, extensionName) {
|
|
|
9671
10092
|
* list.
|
|
9672
10093
|
*
|
|
9673
10094
|
*/
|
|
9674
|
-
var supportedExtensions = ['ANGLE_instanced_arrays', 'EXT_blend_minmax', 'EXT_color_buffer_float', 'EXT_color_buffer_half_float', 'EXT_disjoint_timer_query', 'EXT_disjoint_timer_query_webgl2', 'EXT_frag_depth', 'EXT_sRGB', 'EXT_shader_texture_lod', 'EXT_texture_filter_anisotropic', 'OES_element_index_uint', 'OES_standard_derivatives', 'OES_texture_float', 'OES_texture_float_linear', 'OES_texture_half_float', 'OES_texture_half_float_linear', 'OES_vertex_array_object', 'WEBGL_color_buffer_float', 'WEBGL_compressed_texture_atc', 'WEBGL_compressed_texture_etc1', 'WEBGL_compressed_texture_pvrtc', 'WEBGL_compressed_texture_s3tc', 'WEBGL_compressed_texture_s3tc_srgb', 'WEBGL_depth_texture', 'WEBGL_draw_buffers'];
|
|
10095
|
+
var supportedExtensions = ['ANGLE_instanced_arrays', 'EXT_blend_minmax', 'EXT_color_buffer_float', 'EXT_color_buffer_half_float', 'EXT_disjoint_timer_query', 'EXT_disjoint_timer_query_webgl2', 'EXT_frag_depth', 'EXT_sRGB', 'EXT_shader_texture_lod', 'EXT_texture_compression_bptc', 'EXT_texture_compression_rgtc', 'EXT_texture_filter_anisotropic', 'OES_element_index_uint', 'OES_standard_derivatives', 'OES_texture_float', 'OES_texture_float_linear', 'OES_texture_half_float', 'OES_texture_half_float_linear', 'OES_vertex_array_object', 'WEBGL_color_buffer_float', 'WEBGL_compressed_texture_atc', 'WEBGL_compressed_texture_etc1', 'WEBGL_compressed_texture_etc', 'WEBGL_compressed_texture_pvrtc', 'WEBGL_compressed_texture_s3tc', 'WEBGL_compressed_texture_s3tc_srgb', 'WEBGL_depth_texture', 'WEBGL_draw_buffers'];
|
|
9675
10096
|
|
|
9676
10097
|
/**
|
|
9677
10098
|
* Attempts to enable all of the following extensions
|