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.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
|
*/
|
|
@@ -4300,6 +4300,74 @@ var RED = 0x1903;
|
|
|
4300
4300
|
var RED_INTEGER = 0x8D94;
|
|
4301
4301
|
var RGB_INTEGER = 0x8D98;
|
|
4302
4302
|
var RGBA_INTEGER = 0x8D99;
|
|
4303
|
+
|
|
4304
|
+
/* Compressed Texture Formats */
|
|
4305
|
+
// s3tc
|
|
4306
|
+
var COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83F0;
|
|
4307
|
+
var COMPRESSED_RGBA_S3TC_DXT1_EXT = 0x83F1;
|
|
4308
|
+
var COMPRESSED_RGBA_S3TC_DXT3_EXT = 0x83F2;
|
|
4309
|
+
var COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83F3;
|
|
4310
|
+
// s3tc_srgb
|
|
4311
|
+
var COMPRESSED_SRGB_S3TC_DXT1_EXT = 0x8C4C;
|
|
4312
|
+
var COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT = 0x8C4D;
|
|
4313
|
+
var COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT = 0x8C4E;
|
|
4314
|
+
var COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT = 0x8C4F;
|
|
4315
|
+
// etc
|
|
4316
|
+
var COMPRESSED_RGB_ETC1_WEBGL = 0x8D64;
|
|
4317
|
+
var COMPRESSED_R11_EAC = 0x9270;
|
|
4318
|
+
var COMPRESSED_SIGNED_R11_EAC = 0x9271;
|
|
4319
|
+
var COMPRESSED_RG11_EAC = 0x9272;
|
|
4320
|
+
var COMPRESSED_SIGNED_RG11_EAC = 0x9273;
|
|
4321
|
+
var COMPRESSED_RGB8_ETC2 = 0x9274;
|
|
4322
|
+
var COMPRESSED_SRGB8_ETC2 = 0x9275;
|
|
4323
|
+
var COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9276;
|
|
4324
|
+
var COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 = 0x9277;
|
|
4325
|
+
var COMPRESSED_RGBA8_ETC2_EAC = 0x9278;
|
|
4326
|
+
var COMPRESSED_SRGB8_ALPHA8_ETC2_EAC = 0x9279;
|
|
4327
|
+
// pvrtc
|
|
4328
|
+
var COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8C00;
|
|
4329
|
+
var COMPRESSED_RGB_PVRTC_2BPPV1_IMG = 0x8C01;
|
|
4330
|
+
var COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8C02;
|
|
4331
|
+
var COMPRESSED_RGBA_PVRTC_2BPPV1_IMG = 0x8C03;
|
|
4332
|
+
// astc
|
|
4333
|
+
var COMPRESSED_RGBA_ASTC_4x4_KHR = 0x93B0;
|
|
4334
|
+
var COMPRESSED_RGBA_ASTC_5x4_KHR = 0x93B1;
|
|
4335
|
+
var COMPRESSED_RGBA_ASTC_5x5_KHR = 0x93B2;
|
|
4336
|
+
var COMPRESSED_RGBA_ASTC_6x5_KHR = 0x93B3;
|
|
4337
|
+
var COMPRESSED_RGBA_ASTC_6x6_KHR = 0x93B4;
|
|
4338
|
+
var COMPRESSED_RGBA_ASTC_8x5_KHR = 0x93B5;
|
|
4339
|
+
var COMPRESSED_RGBA_ASTC_8x6_KHR = 0x93B6;
|
|
4340
|
+
var COMPRESSED_RGBA_ASTC_8x8_KHR = 0x93B7;
|
|
4341
|
+
var COMPRESSED_RGBA_ASTC_10x5_KHR = 0x93B8;
|
|
4342
|
+
var COMPRESSED_RGBA_ASTC_10x6_KHR = 0x93B9;
|
|
4343
|
+
var COMPRESSED_RGBA_ASTC_10x8_KHR = 0x93BA;
|
|
4344
|
+
var COMPRESSED_RGBA_ASTC_10x10_KHR = 0x93BB;
|
|
4345
|
+
var COMPRESSED_RGBA_ASTC_12x10_KHR = 0x93BC;
|
|
4346
|
+
var COMPRESSED_RGBA_ASTC_12x12_KHR = 0x93BD;
|
|
4347
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR = 0x93D0;
|
|
4348
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR = 0x93D1;
|
|
4349
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR = 0x93D2;
|
|
4350
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR = 0x93D3;
|
|
4351
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR = 0x93D4;
|
|
4352
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR = 0x93D5;
|
|
4353
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR = 0x93D6;
|
|
4354
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR = 0x93D7;
|
|
4355
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR = 0x93D8;
|
|
4356
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR = 0x93D9;
|
|
4357
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR = 0x93DA;
|
|
4358
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR = 0x93DB;
|
|
4359
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR = 0x93DC;
|
|
4360
|
+
var COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR = 0x93DD;
|
|
4361
|
+
// bptc
|
|
4362
|
+
var COMPRESSED_RGBA_BPTC_UNORM_EXT = 0x8E8C;
|
|
4363
|
+
var COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = 0x8E8D;
|
|
4364
|
+
var COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT = 0x8E8E;
|
|
4365
|
+
var COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT = 0x8E8F;
|
|
4366
|
+
// rgtc
|
|
4367
|
+
var COMPRESSED_RED_RGTC1_EXT = 0x8DBB;
|
|
4368
|
+
var COMPRESSED_SIGNED_RED_RGTC1_EXT = 0x8DBC;
|
|
4369
|
+
var COMPRESSED_RED_GREEN_RGTC2_EXT = 0x8DBD;
|
|
4370
|
+
var COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT = 0x8DBE;
|
|
4303
4371
|
var formatInfo = {};
|
|
4304
4372
|
{
|
|
4305
4373
|
// NOTE: this is named `numColorComponents` vs `numComponents` so we can let Uglify mangle
|
|
@@ -4358,7 +4426,8 @@ var formatInfo = {};
|
|
|
4358
4426
|
* @property {boolean} colorRenderable true if you can render to this format of texture.
|
|
4359
4427
|
* @property {boolean} textureFilterable true if you can filter the texture, false if you can ony use `NEAREST`.
|
|
4360
4428
|
* @property {number[]} type Array of possible types you can pass to texImage2D and similar function
|
|
4361
|
-
* @property {Object.<number,number>} bytesPerElementMap A map of types to bytes per element
|
|
4429
|
+
* @property {Object.<number,number>} [bytesPerElementMap] A map of types to bytes per element
|
|
4430
|
+
* @property {boolean} [compressed] true if it's a compressed texture format
|
|
4362
4431
|
* @private
|
|
4363
4432
|
*/
|
|
4364
4433
|
|
|
@@ -4799,6 +4868,318 @@ function getTextureInternalFormatInfo(internalFormat) {
|
|
|
4799
4868
|
info.bytesPerElementMap[type] = bytesPerElement;
|
|
4800
4869
|
});
|
|
4801
4870
|
});
|
|
4871
|
+
var getCompressedFormatInfo = function getCompressedFormatInfo() {
|
|
4872
|
+
var t = {};
|
|
4873
|
+
// compressed texture formats
|
|
4874
|
+
// s3tc:https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc.txt
|
|
4875
|
+
t[COMPRESSED_RGB_S3TC_DXT1_EXT] = {
|
|
4876
|
+
textureFormat: COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
4877
|
+
colorRenderable: false,
|
|
4878
|
+
textureFilterable: true
|
|
4879
|
+
};
|
|
4880
|
+
t[COMPRESSED_RGBA_S3TC_DXT1_EXT] = {
|
|
4881
|
+
textureFormat: COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
4882
|
+
colorRenderable: false,
|
|
4883
|
+
textureFilterable: true
|
|
4884
|
+
};
|
|
4885
|
+
t[COMPRESSED_RGBA_S3TC_DXT3_EXT] = {
|
|
4886
|
+
textureFormat: COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
4887
|
+
colorRenderable: false,
|
|
4888
|
+
textureFilterable: true
|
|
4889
|
+
};
|
|
4890
|
+
t[COMPRESSED_RGBA_S3TC_DXT5_EXT] = {
|
|
4891
|
+
textureFormat: COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
4892
|
+
colorRenderable: false,
|
|
4893
|
+
textureFilterable: true
|
|
4894
|
+
};
|
|
4895
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc_srgb.txt
|
|
4896
|
+
t[COMPRESSED_SRGB_S3TC_DXT1_EXT] = {
|
|
4897
|
+
textureFormat: COMPRESSED_SRGB_S3TC_DXT1_EXT,
|
|
4898
|
+
colorRenderable: false,
|
|
4899
|
+
textureFilterable: true
|
|
4900
|
+
};
|
|
4901
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = {
|
|
4902
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
|
|
4903
|
+
colorRenderable: false,
|
|
4904
|
+
textureFilterable: true
|
|
4905
|
+
};
|
|
4906
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = {
|
|
4907
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
|
|
4908
|
+
colorRenderable: false,
|
|
4909
|
+
textureFilterable: true
|
|
4910
|
+
};
|
|
4911
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = {
|
|
4912
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
|
|
4913
|
+
colorRenderable: false,
|
|
4914
|
+
textureFilterable: true
|
|
4915
|
+
};
|
|
4916
|
+
// https://registry.khronos.org/OpenGL/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt
|
|
4917
|
+
t[COMPRESSED_RGB_ETC1_WEBGL] = {
|
|
4918
|
+
textureFormat: COMPRESSED_RGB_ETC1_WEBGL,
|
|
4919
|
+
colorRenderable: false,
|
|
4920
|
+
textureFilterable: true
|
|
4921
|
+
};
|
|
4922
|
+
t[COMPRESSED_R11_EAC] = {
|
|
4923
|
+
textureFormat: COMPRESSED_R11_EAC,
|
|
4924
|
+
colorRenderable: false,
|
|
4925
|
+
textureFilterable: true
|
|
4926
|
+
};
|
|
4927
|
+
t[COMPRESSED_SIGNED_R11_EAC] = {
|
|
4928
|
+
textureFormat: COMPRESSED_SIGNED_R11_EAC,
|
|
4929
|
+
colorRenderable: false,
|
|
4930
|
+
textureFilterable: true
|
|
4931
|
+
};
|
|
4932
|
+
t[COMPRESSED_RG11_EAC] = {
|
|
4933
|
+
textureFormat: COMPRESSED_RG11_EAC,
|
|
4934
|
+
colorRenderable: false,
|
|
4935
|
+
textureFilterable: true
|
|
4936
|
+
};
|
|
4937
|
+
t[COMPRESSED_SIGNED_RG11_EAC] = {
|
|
4938
|
+
textureFormat: COMPRESSED_SIGNED_RG11_EAC,
|
|
4939
|
+
colorRenderable: false,
|
|
4940
|
+
textureFilterable: true
|
|
4941
|
+
};
|
|
4942
|
+
t[COMPRESSED_RGB8_ETC2] = {
|
|
4943
|
+
textureFormat: COMPRESSED_RGB8_ETC2,
|
|
4944
|
+
colorRenderable: false,
|
|
4945
|
+
textureFilterable: true
|
|
4946
|
+
};
|
|
4947
|
+
t[COMPRESSED_SRGB8_ETC2] = {
|
|
4948
|
+
textureFormat: COMPRESSED_SRGB8_ETC2,
|
|
4949
|
+
colorRenderable: false,
|
|
4950
|
+
textureFilterable: true
|
|
4951
|
+
};
|
|
4952
|
+
t[COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = {
|
|
4953
|
+
textureFormat: COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
4954
|
+
colorRenderable: false,
|
|
4955
|
+
textureFilterable: true
|
|
4956
|
+
};
|
|
4957
|
+
t[COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = {
|
|
4958
|
+
textureFormat: COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
4959
|
+
colorRenderable: false,
|
|
4960
|
+
textureFilterable: true
|
|
4961
|
+
};
|
|
4962
|
+
t[COMPRESSED_RGBA8_ETC2_EAC] = {
|
|
4963
|
+
textureFormat: COMPRESSED_RGBA8_ETC2_EAC,
|
|
4964
|
+
colorRenderable: false,
|
|
4965
|
+
textureFilterable: true
|
|
4966
|
+
};
|
|
4967
|
+
t[COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = {
|
|
4968
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
|
|
4969
|
+
colorRenderable: false,
|
|
4970
|
+
textureFilterable: true
|
|
4971
|
+
};
|
|
4972
|
+
// https://registry.khronos.org/OpenGL/extensions/IMG/IMG_texture_compression_pvrtc.txt
|
|
4973
|
+
t[COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = {
|
|
4974
|
+
textureFormat: COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
4975
|
+
colorRenderable: false,
|
|
4976
|
+
textureFilterable: true
|
|
4977
|
+
};
|
|
4978
|
+
t[COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = {
|
|
4979
|
+
textureFormat: COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
|
|
4980
|
+
colorRenderable: false,
|
|
4981
|
+
textureFilterable: true
|
|
4982
|
+
};
|
|
4983
|
+
t[COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = {
|
|
4984
|
+
textureFormat: COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
4985
|
+
colorRenderable: false,
|
|
4986
|
+
textureFilterable: true
|
|
4987
|
+
};
|
|
4988
|
+
t[COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = {
|
|
4989
|
+
textureFormat: COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
4990
|
+
colorRenderable: false,
|
|
4991
|
+
textureFilterable: true
|
|
4992
|
+
};
|
|
4993
|
+
// https://registry.khronos.org/OpenGL/extensions/KHR/KHR_texture_compression_astc_hdr.txt
|
|
4994
|
+
t[COMPRESSED_RGBA_ASTC_4x4_KHR] = {
|
|
4995
|
+
textureFormat: COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
4996
|
+
colorRenderable: false,
|
|
4997
|
+
textureFilterable: true
|
|
4998
|
+
};
|
|
4999
|
+
t[COMPRESSED_RGBA_ASTC_5x4_KHR] = {
|
|
5000
|
+
textureFormat: COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
5001
|
+
colorRenderable: false,
|
|
5002
|
+
textureFilterable: true
|
|
5003
|
+
};
|
|
5004
|
+
t[COMPRESSED_RGBA_ASTC_5x5_KHR] = {
|
|
5005
|
+
textureFormat: COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
5006
|
+
colorRenderable: false,
|
|
5007
|
+
textureFilterable: true
|
|
5008
|
+
};
|
|
5009
|
+
t[COMPRESSED_RGBA_ASTC_6x5_KHR] = {
|
|
5010
|
+
textureFormat: COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
5011
|
+
colorRenderable: false,
|
|
5012
|
+
textureFilterable: true
|
|
5013
|
+
};
|
|
5014
|
+
t[COMPRESSED_RGBA_ASTC_6x6_KHR] = {
|
|
5015
|
+
textureFormat: COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
5016
|
+
colorRenderable: false,
|
|
5017
|
+
textureFilterable: true
|
|
5018
|
+
};
|
|
5019
|
+
t[COMPRESSED_RGBA_ASTC_8x5_KHR] = {
|
|
5020
|
+
textureFormat: COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
5021
|
+
colorRenderable: false,
|
|
5022
|
+
textureFilterable: true
|
|
5023
|
+
};
|
|
5024
|
+
t[COMPRESSED_RGBA_ASTC_8x6_KHR] = {
|
|
5025
|
+
textureFormat: COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
5026
|
+
colorRenderable: false,
|
|
5027
|
+
textureFilterable: true
|
|
5028
|
+
};
|
|
5029
|
+
t[COMPRESSED_RGBA_ASTC_8x8_KHR] = {
|
|
5030
|
+
textureFormat: COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
5031
|
+
colorRenderable: false,
|
|
5032
|
+
textureFilterable: true
|
|
5033
|
+
};
|
|
5034
|
+
t[COMPRESSED_RGBA_ASTC_10x5_KHR] = {
|
|
5035
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
5036
|
+
colorRenderable: false,
|
|
5037
|
+
textureFilterable: true
|
|
5038
|
+
};
|
|
5039
|
+
t[COMPRESSED_RGBA_ASTC_10x6_KHR] = {
|
|
5040
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
5041
|
+
colorRenderable: false,
|
|
5042
|
+
textureFilterable: true
|
|
5043
|
+
};
|
|
5044
|
+
t[COMPRESSED_RGBA_ASTC_10x8_KHR] = {
|
|
5045
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
5046
|
+
colorRenderable: false,
|
|
5047
|
+
textureFilterable: true
|
|
5048
|
+
};
|
|
5049
|
+
t[COMPRESSED_RGBA_ASTC_10x10_KHR] = {
|
|
5050
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
5051
|
+
colorRenderable: false,
|
|
5052
|
+
textureFilterable: true
|
|
5053
|
+
};
|
|
5054
|
+
t[COMPRESSED_RGBA_ASTC_12x10_KHR] = {
|
|
5055
|
+
textureFormat: COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
5056
|
+
colorRenderable: false,
|
|
5057
|
+
textureFilterable: true
|
|
5058
|
+
};
|
|
5059
|
+
t[COMPRESSED_RGBA_ASTC_12x12_KHR] = {
|
|
5060
|
+
textureFormat: COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
5061
|
+
colorRenderable: false,
|
|
5062
|
+
textureFilterable: true
|
|
5063
|
+
};
|
|
5064
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR] = {
|
|
5065
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
5066
|
+
colorRenderable: false,
|
|
5067
|
+
textureFilterable: true
|
|
5068
|
+
};
|
|
5069
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR] = {
|
|
5070
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
5071
|
+
colorRenderable: false,
|
|
5072
|
+
textureFilterable: true
|
|
5073
|
+
};
|
|
5074
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR] = {
|
|
5075
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
5076
|
+
colorRenderable: false,
|
|
5077
|
+
textureFilterable: true
|
|
5078
|
+
};
|
|
5079
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR] = {
|
|
5080
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
5081
|
+
colorRenderable: false,
|
|
5082
|
+
textureFilterable: true
|
|
5083
|
+
};
|
|
5084
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR] = {
|
|
5085
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
5086
|
+
colorRenderable: false,
|
|
5087
|
+
textureFilterable: true
|
|
5088
|
+
};
|
|
5089
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR] = {
|
|
5090
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
5091
|
+
colorRenderable: false,
|
|
5092
|
+
textureFilterable: true
|
|
5093
|
+
};
|
|
5094
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR] = {
|
|
5095
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
5096
|
+
colorRenderable: false,
|
|
5097
|
+
textureFilterable: true
|
|
5098
|
+
};
|
|
5099
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR] = {
|
|
5100
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
5101
|
+
colorRenderable: false,
|
|
5102
|
+
textureFilterable: true
|
|
5103
|
+
};
|
|
5104
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR] = {
|
|
5105
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
5106
|
+
colorRenderable: false,
|
|
5107
|
+
textureFilterable: true
|
|
5108
|
+
};
|
|
5109
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR] = {
|
|
5110
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
5111
|
+
colorRenderable: false,
|
|
5112
|
+
textureFilterable: true
|
|
5113
|
+
};
|
|
5114
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR] = {
|
|
5115
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
5116
|
+
colorRenderable: false,
|
|
5117
|
+
textureFilterable: true
|
|
5118
|
+
};
|
|
5119
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR] = {
|
|
5120
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
5121
|
+
colorRenderable: false,
|
|
5122
|
+
textureFilterable: true
|
|
5123
|
+
};
|
|
5124
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR] = {
|
|
5125
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
5126
|
+
colorRenderable: false,
|
|
5127
|
+
textureFilterable: true
|
|
5128
|
+
};
|
|
5129
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR] = {
|
|
5130
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
5131
|
+
colorRenderable: false,
|
|
5132
|
+
textureFilterable: true
|
|
5133
|
+
};
|
|
5134
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_bptc.txt
|
|
5135
|
+
t[COMPRESSED_RGBA_BPTC_UNORM_EXT] = {
|
|
5136
|
+
textureFormat: COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
5137
|
+
colorRenderable: false,
|
|
5138
|
+
textureFilterable: true
|
|
5139
|
+
};
|
|
5140
|
+
t[COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT] = {
|
|
5141
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
|
|
5142
|
+
colorRenderable: false,
|
|
5143
|
+
textureFilterable: true
|
|
5144
|
+
};
|
|
5145
|
+
t[COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT] = {
|
|
5146
|
+
textureFormat: COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
|
|
5147
|
+
colorRenderable: false,
|
|
5148
|
+
textureFilterable: true
|
|
5149
|
+
};
|
|
5150
|
+
t[COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT] = {
|
|
5151
|
+
textureFormat: COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
|
|
5152
|
+
colorRenderable: false,
|
|
5153
|
+
textureFilterable: true
|
|
5154
|
+
};
|
|
5155
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_rgtc.txt
|
|
5156
|
+
t[COMPRESSED_RED_RGTC1_EXT] = {
|
|
5157
|
+
textureFormat: COMPRESSED_RED_RGTC1_EXT,
|
|
5158
|
+
colorRenderable: false,
|
|
5159
|
+
textureFilterable: true
|
|
5160
|
+
};
|
|
5161
|
+
t[COMPRESSED_SIGNED_RED_RGTC1_EXT] = {
|
|
5162
|
+
textureFormat: COMPRESSED_SIGNED_RED_RGTC1_EXT,
|
|
5163
|
+
colorRenderable: false,
|
|
5164
|
+
textureFilterable: true
|
|
5165
|
+
};
|
|
5166
|
+
t[COMPRESSED_RED_GREEN_RGTC2_EXT] = {
|
|
5167
|
+
textureFormat: COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
5168
|
+
colorRenderable: false,
|
|
5169
|
+
textureFilterable: true
|
|
5170
|
+
};
|
|
5171
|
+
t[COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT] = {
|
|
5172
|
+
textureFormat: COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
|
|
5173
|
+
colorRenderable: false,
|
|
5174
|
+
textureFilterable: true
|
|
5175
|
+
};
|
|
5176
|
+
for (var _i = 0, _Object$values = Object.values(t); _i < _Object$values.length; _i++) {
|
|
5177
|
+
var info = _Object$values[_i];
|
|
5178
|
+
info.compressed = true;
|
|
5179
|
+
}
|
|
5180
|
+
return t;
|
|
5181
|
+
};
|
|
5182
|
+
Object.assign(t, getCompressedFormatInfo());
|
|
4802
5183
|
s_textureInternalFormatInfo = t;
|
|
4803
5184
|
}
|
|
4804
5185
|
return s_textureInternalFormatInfo[internalFormat];
|
|
@@ -4841,16 +5222,30 @@ function getBytesPerElementForInternalFormat(internalFormat, type) {
|
|
|
4841
5222
|
* @memberOf module:twgl/textures
|
|
4842
5223
|
*/
|
|
4843
5224
|
function getFormatAndTypeForInternalFormat(internalFormat) {
|
|
5225
|
+
var _info$type$, _info$type;
|
|
4844
5226
|
var info = getTextureInternalFormatInfo(internalFormat);
|
|
4845
5227
|
if (!info) {
|
|
4846
5228
|
throw "unknown internal format";
|
|
4847
5229
|
}
|
|
4848
5230
|
return {
|
|
4849
5231
|
format: info.textureFormat,
|
|
4850
|
-
type: info.type[0]
|
|
5232
|
+
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
|
|
4851
5233
|
};
|
|
4852
5234
|
}
|
|
4853
5235
|
|
|
5236
|
+
/**
|
|
5237
|
+
* @param {number} internalFormat The internal format
|
|
5238
|
+
* @returns if the internalFormat is a compressed format
|
|
5239
|
+
* @private
|
|
5240
|
+
*/
|
|
5241
|
+
function isCompressedInternalFormat(internalFormat) {
|
|
5242
|
+
var info = getTextureInternalFormatInfo(internalFormat);
|
|
5243
|
+
if (!info) {
|
|
5244
|
+
throw "unknown internal format";
|
|
5245
|
+
}
|
|
5246
|
+
return !!info.compressed;
|
|
5247
|
+
}
|
|
5248
|
+
|
|
4854
5249
|
/**
|
|
4855
5250
|
* Returns true if value is power of 2
|
|
4856
5251
|
* @param {number} value number to check.
|
|
@@ -5945,9 +6340,6 @@ function setTextureFromArray(gl, tex, src, options) {
|
|
|
5945
6340
|
options = options || defaults.textureOptions;
|
|
5946
6341
|
var target = options.target || TEXTURE_2D;
|
|
5947
6342
|
gl.bindTexture(target, tex);
|
|
5948
|
-
var width = options.width;
|
|
5949
|
-
var height = options.height;
|
|
5950
|
-
var depth = options.depth;
|
|
5951
6343
|
var level = options.level || 0;
|
|
5952
6344
|
var internalFormat = options.internalFormat || options.format || RGBA;
|
|
5953
6345
|
var formatType = getFormatAndTypeForInternalFormat(internalFormat);
|
|
@@ -5959,54 +6351,33 @@ function setTextureFromArray(gl, tex, src, options) {
|
|
|
5959
6351
|
} else if (src instanceof Uint8ClampedArray) {
|
|
5960
6352
|
src = new Uint8Array(src.buffer);
|
|
5961
6353
|
}
|
|
5962
|
-
var
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
var dimensions;
|
|
5968
|
-
if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
|
|
5969
|
-
if (!width && !height && !depth) {
|
|
5970
|
-
var size = Math.cbrt(numElements);
|
|
5971
|
-
if (size % 1 !== 0) {
|
|
5972
|
-
throw "can't guess cube size of array of numElements: " + numElements;
|
|
5973
|
-
}
|
|
5974
|
-
width = size;
|
|
5975
|
-
height = size;
|
|
5976
|
-
depth = size;
|
|
5977
|
-
} else if (width && (!height || !depth)) {
|
|
5978
|
-
dimensions = guessDimensions(gl, target, height, depth, numElements / width);
|
|
5979
|
-
height = dimensions.width;
|
|
5980
|
-
depth = dimensions.height;
|
|
5981
|
-
} else if (height && (!width || !depth)) {
|
|
5982
|
-
dimensions = guessDimensions(gl, target, width, depth, numElements / height);
|
|
5983
|
-
width = dimensions.width;
|
|
5984
|
-
depth = dimensions.height;
|
|
5985
|
-
} else {
|
|
5986
|
-
dimensions = guessDimensions(gl, target, width, height, numElements / depth);
|
|
5987
|
-
width = dimensions.width;
|
|
5988
|
-
height = dimensions.height;
|
|
5989
|
-
}
|
|
5990
|
-
} else {
|
|
5991
|
-
dimensions = guessDimensions(gl, target, width, height, numElements);
|
|
5992
|
-
width = dimensions.width;
|
|
5993
|
-
height = dimensions.height;
|
|
5994
|
-
}
|
|
6354
|
+
var _getTextureSize = getTextureSize(gl, target, src, options, internalFormat, format, type),
|
|
6355
|
+
width = _getTextureSize.width,
|
|
6356
|
+
height = _getTextureSize.height,
|
|
6357
|
+
depth = _getTextureSize.depth;
|
|
6358
|
+
var compressed = isCompressedInternalFormat(internalFormat);
|
|
5995
6359
|
setSkipStateToDefault(gl);
|
|
5996
6360
|
gl.pixelStorei(UNPACK_ALIGNMENT, options.unpackAlignment || 1);
|
|
5997
6361
|
scopedSetPackState(gl, options, function () {
|
|
5998
6362
|
if (target === TEXTURE_CUBE_MAP) {
|
|
5999
|
-
var
|
|
6000
|
-
var faceSize = numElements / 6 * elementsPerElement;
|
|
6363
|
+
var faceSize = src.length / 6;
|
|
6001
6364
|
getCubeFacesWithNdx(gl, options).forEach(function (f) {
|
|
6002
6365
|
var offset = faceSize * f.ndx;
|
|
6003
6366
|
var data = src.subarray(offset, offset + faceSize);
|
|
6004
|
-
|
|
6367
|
+
if (compressed) {
|
|
6368
|
+
gl.compressedTexImage2D(f.face, level, internalFormat, width, height, 0, data);
|
|
6369
|
+
} else {
|
|
6370
|
+
gl.texImage2D(f.face, level, internalFormat, width, height, 0, format, type, data);
|
|
6371
|
+
}
|
|
6005
6372
|
});
|
|
6006
6373
|
} else if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
|
|
6007
6374
|
gl.texImage3D(target, level, internalFormat, width, height, depth, 0, format, type, src);
|
|
6008
6375
|
} else {
|
|
6009
|
-
|
|
6376
|
+
if (compressed) {
|
|
6377
|
+
gl.compressedTexImage2D(target, level, internalFormat, width, height, 0, src);
|
|
6378
|
+
} else {
|
|
6379
|
+
gl.texImage2D(target, level, internalFormat, width, height, 0, format, type, src);
|
|
6380
|
+
}
|
|
6010
6381
|
}
|
|
6011
6382
|
});
|
|
6012
6383
|
return {
|
|
@@ -6016,6 +6387,56 @@ function setTextureFromArray(gl, tex, src, options) {
|
|
|
6016
6387
|
type: type
|
|
6017
6388
|
};
|
|
6018
6389
|
}
|
|
6390
|
+
function getTextureSize(gl, target, src, options, internalFormat, format, type) {
|
|
6391
|
+
var width = options.width;
|
|
6392
|
+
var height = options.height;
|
|
6393
|
+
var depth = options.depth;
|
|
6394
|
+
var compressed = isCompressedInternalFormat(internalFormat);
|
|
6395
|
+
if (compressed) {
|
|
6396
|
+
if (!width || !height) {
|
|
6397
|
+
throw "compressed texture needs to set width and height!";
|
|
6398
|
+
}
|
|
6399
|
+
} else {
|
|
6400
|
+
var bytesPerElement = getBytesPerElementForInternalFormat(internalFormat, type);
|
|
6401
|
+
var numElements = src.byteLength / bytesPerElement; // TODO: check UNPACK_ALIGNMENT?
|
|
6402
|
+
if (numElements % 1) {
|
|
6403
|
+
throw "length wrong size for format: " + utils.glEnumToString(gl, format);
|
|
6404
|
+
}
|
|
6405
|
+
var dimensions;
|
|
6406
|
+
if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
|
|
6407
|
+
if (!width && !height && !depth) {
|
|
6408
|
+
var size = Math.cbrt(numElements);
|
|
6409
|
+
if (size % 1 !== 0) {
|
|
6410
|
+
throw "can't guess cube size of array of numElements: " + numElements;
|
|
6411
|
+
}
|
|
6412
|
+
width = size;
|
|
6413
|
+
height = size;
|
|
6414
|
+
depth = size;
|
|
6415
|
+
} else if (width && (!height || !depth)) {
|
|
6416
|
+
dimensions = guessDimensions(gl, target, height, depth, numElements / width);
|
|
6417
|
+
height = dimensions.width;
|
|
6418
|
+
depth = dimensions.height;
|
|
6419
|
+
} else if (height && (!width || !depth)) {
|
|
6420
|
+
dimensions = guessDimensions(gl, target, width, depth, numElements / height);
|
|
6421
|
+
width = dimensions.width;
|
|
6422
|
+
depth = dimensions.height;
|
|
6423
|
+
} else {
|
|
6424
|
+
dimensions = guessDimensions(gl, target, width, height, numElements / depth);
|
|
6425
|
+
width = dimensions.width;
|
|
6426
|
+
height = dimensions.height;
|
|
6427
|
+
}
|
|
6428
|
+
} else {
|
|
6429
|
+
dimensions = guessDimensions(gl, target, width, height, numElements);
|
|
6430
|
+
width = dimensions.width;
|
|
6431
|
+
height = dimensions.height;
|
|
6432
|
+
}
|
|
6433
|
+
}
|
|
6434
|
+
return {
|
|
6435
|
+
width: width,
|
|
6436
|
+
height: height,
|
|
6437
|
+
depth: depth
|
|
6438
|
+
};
|
|
6439
|
+
}
|
|
6019
6440
|
|
|
6020
6441
|
/**
|
|
6021
6442
|
* Sets a texture with no contents of a certain size. In other words calls `gl.texImage2D` with `null`.
|
|
@@ -6680,7 +7101,7 @@ function addExtensionToContext(gl, extensionName) {
|
|
|
6680
7101
|
* list.
|
|
6681
7102
|
*
|
|
6682
7103
|
*/
|
|
6683
|
-
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'];
|
|
7104
|
+
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'];
|
|
6684
7105
|
|
|
6685
7106
|
/**
|
|
6686
7107
|
* Attempts to enable all of the following extensions
|