twgl.js 6.2.0 → 7.0.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/README.md +1 -1
- package/dist/{6.x → 7.x}/twgl-full.d.ts +15 -6
- package/dist/{6.x → 7.x}/twgl-full.js +679 -376
- package/dist/{6.x → 7.x}/twgl-full.module.js +243 -148
- package/dist/{6.x → 7.x}/twgl.d.ts +15 -6
- package/dist/{6.x → 7.x}/twgl.js +679 -376
- package/package.json +9 -9
package/dist/{6.x → 7.x}/twgl.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @license twgl.js
|
|
2
|
+
* @license twgl.js 7.0.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
|
*/
|
|
@@ -4177,6 +4177,7 @@ var CLAMP_TO_EDGE = 0x812f;
|
|
|
4177
4177
|
/* TextureMagFilter */
|
|
4178
4178
|
var NEAREST = 0x2600;
|
|
4179
4179
|
var LINEAR = 0x2601;
|
|
4180
|
+
var NEAREST_MIPMAP_LINEAR = 0x2702;
|
|
4180
4181
|
|
|
4181
4182
|
/* TextureMinFilter */
|
|
4182
4183
|
// const NEAREST_MIPMAP_NEAREST = 0x2700;
|
|
@@ -4420,6 +4421,14 @@ var formatInfo = {};
|
|
|
4420
4421
|
};
|
|
4421
4422
|
}
|
|
4422
4423
|
|
|
4424
|
+
/**
|
|
4425
|
+
* @typedef {Object} BlockInfo
|
|
4426
|
+
* @property {number} bytes number of bytes in the block
|
|
4427
|
+
* @property {number} width width of the block
|
|
4428
|
+
* @property {number} height height of the block
|
|
4429
|
+
* @private
|
|
4430
|
+
*/
|
|
4431
|
+
|
|
4423
4432
|
/**
|
|
4424
4433
|
* @typedef {Object} TextureFormatDetails
|
|
4425
4434
|
* @property {number} textureFormat format to pass texImage2D and similar functions.
|
|
@@ -4427,7 +4436,7 @@ var formatInfo = {};
|
|
|
4427
4436
|
* @property {boolean} textureFilterable true if you can filter the texture, false if you can ony use `NEAREST`.
|
|
4428
4437
|
* @property {number[]} type Array of possible types you can pass to texImage2D and similar function
|
|
4429
4438
|
* @property {Object.<number,number>} [bytesPerElementMap] A map of types to bytes per element
|
|
4430
|
-
* @property {
|
|
4439
|
+
* @property {BlockInfo} [block] block size, only for compressed textures
|
|
4431
4440
|
* @private
|
|
4432
4441
|
*/
|
|
4433
4442
|
|
|
@@ -4868,321 +4877,514 @@ function getTextureInternalFormatInfo(internalFormat) {
|
|
|
4868
4877
|
info.bytesPerElementMap[type] = bytesPerElement;
|
|
4869
4878
|
});
|
|
4870
4879
|
});
|
|
4871
|
-
var
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
|
|
4937
|
-
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
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;
|
|
4880
|
+
var block8_4_4 = {
|
|
4881
|
+
bytes: 8,
|
|
4882
|
+
width: 4,
|
|
4883
|
+
height: 4
|
|
4884
|
+
};
|
|
4885
|
+
var block16_4_4 = {
|
|
4886
|
+
bytes: 16,
|
|
4887
|
+
width: 4,
|
|
4888
|
+
height: 4
|
|
4889
|
+
};
|
|
4890
|
+
|
|
4891
|
+
// compressed texture formats
|
|
4892
|
+
// s3tc:https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc.txt
|
|
4893
|
+
t[COMPRESSED_RGB_S3TC_DXT1_EXT] = {
|
|
4894
|
+
textureFormat: COMPRESSED_RGB_S3TC_DXT1_EXT,
|
|
4895
|
+
colorRenderable: false,
|
|
4896
|
+
textureFilterable: true,
|
|
4897
|
+
block: block8_4_4
|
|
4898
|
+
};
|
|
4899
|
+
t[COMPRESSED_RGBA_S3TC_DXT1_EXT] = {
|
|
4900
|
+
textureFormat: COMPRESSED_RGBA_S3TC_DXT1_EXT,
|
|
4901
|
+
colorRenderable: false,
|
|
4902
|
+
textureFilterable: true,
|
|
4903
|
+
block: block8_4_4
|
|
4904
|
+
};
|
|
4905
|
+
t[COMPRESSED_RGBA_S3TC_DXT3_EXT] = {
|
|
4906
|
+
textureFormat: COMPRESSED_RGBA_S3TC_DXT3_EXT,
|
|
4907
|
+
colorRenderable: false,
|
|
4908
|
+
textureFilterable: true,
|
|
4909
|
+
block: block16_4_4
|
|
4910
|
+
};
|
|
4911
|
+
t[COMPRESSED_RGBA_S3TC_DXT5_EXT] = {
|
|
4912
|
+
textureFormat: COMPRESSED_RGBA_S3TC_DXT5_EXT,
|
|
4913
|
+
colorRenderable: false,
|
|
4914
|
+
textureFilterable: true,
|
|
4915
|
+
block: block16_4_4
|
|
4916
|
+
};
|
|
4917
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_s3tc_srgb.txt
|
|
4918
|
+
t[COMPRESSED_SRGB_S3TC_DXT1_EXT] = {
|
|
4919
|
+
textureFormat: COMPRESSED_SRGB_S3TC_DXT1_EXT,
|
|
4920
|
+
colorRenderable: false,
|
|
4921
|
+
textureFilterable: true,
|
|
4922
|
+
block: block8_4_4
|
|
4923
|
+
};
|
|
4924
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT] = {
|
|
4925
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
|
|
4926
|
+
colorRenderable: false,
|
|
4927
|
+
textureFilterable: true,
|
|
4928
|
+
block: block8_4_4
|
|
4929
|
+
};
|
|
4930
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT] = {
|
|
4931
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
|
|
4932
|
+
colorRenderable: false,
|
|
4933
|
+
textureFilterable: true,
|
|
4934
|
+
block: block16_4_4
|
|
4935
|
+
};
|
|
4936
|
+
t[COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT] = {
|
|
4937
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
|
|
4938
|
+
colorRenderable: false,
|
|
4939
|
+
textureFilterable: true,
|
|
4940
|
+
block: block16_4_4
|
|
4941
|
+
};
|
|
4942
|
+
// https://registry.khronos.org/OpenGL/extensions/OES/OES_compressed_ETC1_RGB8_texture.txt
|
|
4943
|
+
t[COMPRESSED_RGB_ETC1_WEBGL] = {
|
|
4944
|
+
textureFormat: COMPRESSED_RGB_ETC1_WEBGL,
|
|
4945
|
+
colorRenderable: false,
|
|
4946
|
+
textureFilterable: true,
|
|
4947
|
+
block: block8_4_4
|
|
4948
|
+
};
|
|
4949
|
+
t[COMPRESSED_R11_EAC] = {
|
|
4950
|
+
textureFormat: COMPRESSED_R11_EAC,
|
|
4951
|
+
colorRenderable: false,
|
|
4952
|
+
textureFilterable: true,
|
|
4953
|
+
block: block8_4_4
|
|
4954
|
+
};
|
|
4955
|
+
t[COMPRESSED_SIGNED_R11_EAC] = {
|
|
4956
|
+
textureFormat: COMPRESSED_SIGNED_R11_EAC,
|
|
4957
|
+
colorRenderable: false,
|
|
4958
|
+
textureFilterable: true,
|
|
4959
|
+
block: block8_4_4
|
|
4960
|
+
};
|
|
4961
|
+
t[COMPRESSED_RG11_EAC] = {
|
|
4962
|
+
textureFormat: COMPRESSED_RG11_EAC,
|
|
4963
|
+
colorRenderable: false,
|
|
4964
|
+
textureFilterable: true,
|
|
4965
|
+
block: block16_4_4
|
|
4966
|
+
};
|
|
4967
|
+
t[COMPRESSED_SIGNED_RG11_EAC] = {
|
|
4968
|
+
textureFormat: COMPRESSED_SIGNED_RG11_EAC,
|
|
4969
|
+
colorRenderable: false,
|
|
4970
|
+
textureFilterable: true,
|
|
4971
|
+
block: block16_4_4
|
|
4972
|
+
};
|
|
4973
|
+
t[COMPRESSED_RGB8_ETC2] = {
|
|
4974
|
+
textureFormat: COMPRESSED_RGB8_ETC2,
|
|
4975
|
+
colorRenderable: false,
|
|
4976
|
+
textureFilterable: true,
|
|
4977
|
+
block: block8_4_4
|
|
4978
|
+
};
|
|
4979
|
+
t[COMPRESSED_SRGB8_ETC2] = {
|
|
4980
|
+
textureFormat: COMPRESSED_SRGB8_ETC2,
|
|
4981
|
+
colorRenderable: false,
|
|
4982
|
+
textureFilterable: true,
|
|
4983
|
+
block: block8_4_4
|
|
4984
|
+
};
|
|
4985
|
+
t[COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = {
|
|
4986
|
+
textureFormat: COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
4987
|
+
colorRenderable: false,
|
|
4988
|
+
textureFilterable: true,
|
|
4989
|
+
block: block8_4_4
|
|
4990
|
+
};
|
|
4991
|
+
t[COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = {
|
|
4992
|
+
textureFormat: COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,
|
|
4993
|
+
colorRenderable: false,
|
|
4994
|
+
textureFilterable: true,
|
|
4995
|
+
block: block8_4_4
|
|
4996
|
+
};
|
|
4997
|
+
t[COMPRESSED_RGBA8_ETC2_EAC] = {
|
|
4998
|
+
textureFormat: COMPRESSED_RGBA8_ETC2_EAC,
|
|
4999
|
+
colorRenderable: false,
|
|
5000
|
+
textureFilterable: true,
|
|
5001
|
+
block: block16_4_4
|
|
5002
|
+
};
|
|
5003
|
+
t[COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = {
|
|
5004
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,
|
|
5005
|
+
colorRenderable: false,
|
|
5006
|
+
textureFilterable: true,
|
|
5007
|
+
block: block16_4_4
|
|
5008
|
+
};
|
|
5009
|
+
// https://registry.khronos.org/OpenGL/extensions/IMG/IMG_texture_compression_pvrtc.txt
|
|
5010
|
+
t[COMPRESSED_RGB_PVRTC_4BPPV1_IMG] = {
|
|
5011
|
+
textureFormat: COMPRESSED_RGB_PVRTC_4BPPV1_IMG,
|
|
5012
|
+
colorRenderable: false,
|
|
5013
|
+
textureFilterable: true,
|
|
5014
|
+
block: {
|
|
5015
|
+
bytes: 32,
|
|
5016
|
+
width: 8,
|
|
5017
|
+
height: 8
|
|
5179
5018
|
}
|
|
5180
|
-
return t;
|
|
5181
5019
|
};
|
|
5182
|
-
|
|
5020
|
+
t[COMPRESSED_RGB_PVRTC_2BPPV1_IMG] = {
|
|
5021
|
+
textureFormat: COMPRESSED_RGB_PVRTC_2BPPV1_IMG,
|
|
5022
|
+
colorRenderable: false,
|
|
5023
|
+
textureFilterable: true,
|
|
5024
|
+
block: {
|
|
5025
|
+
bytes: 32,
|
|
5026
|
+
width: 16,
|
|
5027
|
+
height: 8
|
|
5028
|
+
}
|
|
5029
|
+
};
|
|
5030
|
+
t[COMPRESSED_RGBA_PVRTC_4BPPV1_IMG] = {
|
|
5031
|
+
textureFormat: COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,
|
|
5032
|
+
colorRenderable: false,
|
|
5033
|
+
textureFilterable: true,
|
|
5034
|
+
block: {
|
|
5035
|
+
bytes: 32,
|
|
5036
|
+
width: 8,
|
|
5037
|
+
height: 8
|
|
5038
|
+
}
|
|
5039
|
+
};
|
|
5040
|
+
t[COMPRESSED_RGBA_PVRTC_2BPPV1_IMG] = {
|
|
5041
|
+
textureFormat: COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,
|
|
5042
|
+
colorRenderable: false,
|
|
5043
|
+
textureFilterable: true,
|
|
5044
|
+
block: {
|
|
5045
|
+
bytes: 32,
|
|
5046
|
+
width: 16,
|
|
5047
|
+
height: 8
|
|
5048
|
+
}
|
|
5049
|
+
};
|
|
5050
|
+
// https://registry.khronos.org/OpenGL/extensions/KHR/KHR_texture_compression_astc_hdr.txt
|
|
5051
|
+
t[COMPRESSED_RGBA_ASTC_4x4_KHR] = {
|
|
5052
|
+
textureFormat: COMPRESSED_RGBA_ASTC_4x4_KHR,
|
|
5053
|
+
colorRenderable: false,
|
|
5054
|
+
textureFilterable: true,
|
|
5055
|
+
block: {
|
|
5056
|
+
bytes: 16,
|
|
5057
|
+
width: 4,
|
|
5058
|
+
height: 4
|
|
5059
|
+
}
|
|
5060
|
+
};
|
|
5061
|
+
t[COMPRESSED_RGBA_ASTC_5x4_KHR] = {
|
|
5062
|
+
textureFormat: COMPRESSED_RGBA_ASTC_5x4_KHR,
|
|
5063
|
+
colorRenderable: false,
|
|
5064
|
+
textureFilterable: true,
|
|
5065
|
+
block: {
|
|
5066
|
+
bytes: 16,
|
|
5067
|
+
width: 5,
|
|
5068
|
+
height: 4
|
|
5069
|
+
}
|
|
5070
|
+
};
|
|
5071
|
+
t[COMPRESSED_RGBA_ASTC_5x5_KHR] = {
|
|
5072
|
+
textureFormat: COMPRESSED_RGBA_ASTC_5x5_KHR,
|
|
5073
|
+
colorRenderable: false,
|
|
5074
|
+
textureFilterable: true,
|
|
5075
|
+
block: {
|
|
5076
|
+
bytes: 16,
|
|
5077
|
+
width: 5,
|
|
5078
|
+
height: 5
|
|
5079
|
+
}
|
|
5080
|
+
};
|
|
5081
|
+
t[COMPRESSED_RGBA_ASTC_6x5_KHR] = {
|
|
5082
|
+
textureFormat: COMPRESSED_RGBA_ASTC_6x5_KHR,
|
|
5083
|
+
colorRenderable: false,
|
|
5084
|
+
textureFilterable: true,
|
|
5085
|
+
block: {
|
|
5086
|
+
bytes: 16,
|
|
5087
|
+
width: 6,
|
|
5088
|
+
height: 5
|
|
5089
|
+
}
|
|
5090
|
+
};
|
|
5091
|
+
t[COMPRESSED_RGBA_ASTC_6x6_KHR] = {
|
|
5092
|
+
textureFormat: COMPRESSED_RGBA_ASTC_6x6_KHR,
|
|
5093
|
+
colorRenderable: false,
|
|
5094
|
+
textureFilterable: true,
|
|
5095
|
+
block: {
|
|
5096
|
+
bytes: 16,
|
|
5097
|
+
width: 6,
|
|
5098
|
+
height: 6
|
|
5099
|
+
}
|
|
5100
|
+
};
|
|
5101
|
+
t[COMPRESSED_RGBA_ASTC_8x5_KHR] = {
|
|
5102
|
+
textureFormat: COMPRESSED_RGBA_ASTC_8x5_KHR,
|
|
5103
|
+
colorRenderable: false,
|
|
5104
|
+
textureFilterable: true,
|
|
5105
|
+
block: {
|
|
5106
|
+
bytes: 16,
|
|
5107
|
+
width: 8,
|
|
5108
|
+
height: 5
|
|
5109
|
+
}
|
|
5110
|
+
};
|
|
5111
|
+
t[COMPRESSED_RGBA_ASTC_8x6_KHR] = {
|
|
5112
|
+
textureFormat: COMPRESSED_RGBA_ASTC_8x6_KHR,
|
|
5113
|
+
colorRenderable: false,
|
|
5114
|
+
textureFilterable: true,
|
|
5115
|
+
block: {
|
|
5116
|
+
bytes: 16,
|
|
5117
|
+
width: 8,
|
|
5118
|
+
height: 6
|
|
5119
|
+
}
|
|
5120
|
+
};
|
|
5121
|
+
t[COMPRESSED_RGBA_ASTC_8x8_KHR] = {
|
|
5122
|
+
textureFormat: COMPRESSED_RGBA_ASTC_8x8_KHR,
|
|
5123
|
+
colorRenderable: false,
|
|
5124
|
+
textureFilterable: true,
|
|
5125
|
+
block: {
|
|
5126
|
+
bytes: 16,
|
|
5127
|
+
width: 8,
|
|
5128
|
+
height: 8
|
|
5129
|
+
}
|
|
5130
|
+
};
|
|
5131
|
+
t[COMPRESSED_RGBA_ASTC_10x5_KHR] = {
|
|
5132
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x5_KHR,
|
|
5133
|
+
colorRenderable: false,
|
|
5134
|
+
textureFilterable: true,
|
|
5135
|
+
block: {
|
|
5136
|
+
bytes: 16,
|
|
5137
|
+
width: 10,
|
|
5138
|
+
height: 5
|
|
5139
|
+
}
|
|
5140
|
+
};
|
|
5141
|
+
t[COMPRESSED_RGBA_ASTC_10x6_KHR] = {
|
|
5142
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x6_KHR,
|
|
5143
|
+
colorRenderable: false,
|
|
5144
|
+
textureFilterable: true,
|
|
5145
|
+
block: {
|
|
5146
|
+
bytes: 16,
|
|
5147
|
+
width: 10,
|
|
5148
|
+
height: 6
|
|
5149
|
+
}
|
|
5150
|
+
};
|
|
5151
|
+
t[COMPRESSED_RGBA_ASTC_10x8_KHR] = {
|
|
5152
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x8_KHR,
|
|
5153
|
+
colorRenderable: false,
|
|
5154
|
+
textureFilterable: true,
|
|
5155
|
+
block: {
|
|
5156
|
+
bytes: 16,
|
|
5157
|
+
width: 10,
|
|
5158
|
+
height: 8
|
|
5159
|
+
}
|
|
5160
|
+
};
|
|
5161
|
+
t[COMPRESSED_RGBA_ASTC_10x10_KHR] = {
|
|
5162
|
+
textureFormat: COMPRESSED_RGBA_ASTC_10x10_KHR,
|
|
5163
|
+
colorRenderable: false,
|
|
5164
|
+
textureFilterable: true,
|
|
5165
|
+
block: {
|
|
5166
|
+
bytes: 16,
|
|
5167
|
+
width: 10,
|
|
5168
|
+
height: 10
|
|
5169
|
+
}
|
|
5170
|
+
};
|
|
5171
|
+
t[COMPRESSED_RGBA_ASTC_12x10_KHR] = {
|
|
5172
|
+
textureFormat: COMPRESSED_RGBA_ASTC_12x10_KHR,
|
|
5173
|
+
colorRenderable: false,
|
|
5174
|
+
textureFilterable: true,
|
|
5175
|
+
block: {
|
|
5176
|
+
bytes: 16,
|
|
5177
|
+
width: 12,
|
|
5178
|
+
height: 10
|
|
5179
|
+
}
|
|
5180
|
+
};
|
|
5181
|
+
t[COMPRESSED_RGBA_ASTC_12x12_KHR] = {
|
|
5182
|
+
textureFormat: COMPRESSED_RGBA_ASTC_12x12_KHR,
|
|
5183
|
+
colorRenderable: false,
|
|
5184
|
+
textureFilterable: true,
|
|
5185
|
+
block: {
|
|
5186
|
+
bytes: 16,
|
|
5187
|
+
width: 12,
|
|
5188
|
+
height: 12
|
|
5189
|
+
}
|
|
5190
|
+
};
|
|
5191
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR] = {
|
|
5192
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,
|
|
5193
|
+
colorRenderable: false,
|
|
5194
|
+
textureFilterable: true,
|
|
5195
|
+
block: {
|
|
5196
|
+
bytes: 16,
|
|
5197
|
+
width: 4,
|
|
5198
|
+
height: 4
|
|
5199
|
+
}
|
|
5200
|
+
};
|
|
5201
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR] = {
|
|
5202
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,
|
|
5203
|
+
colorRenderable: false,
|
|
5204
|
+
textureFilterable: true,
|
|
5205
|
+
block: {
|
|
5206
|
+
bytes: 16,
|
|
5207
|
+
width: 5,
|
|
5208
|
+
height: 4
|
|
5209
|
+
}
|
|
5210
|
+
};
|
|
5211
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR] = {
|
|
5212
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,
|
|
5213
|
+
colorRenderable: false,
|
|
5214
|
+
textureFilterable: true,
|
|
5215
|
+
block: {
|
|
5216
|
+
bytes: 16,
|
|
5217
|
+
width: 5,
|
|
5218
|
+
height: 5
|
|
5219
|
+
}
|
|
5220
|
+
};
|
|
5221
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR] = {
|
|
5222
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,
|
|
5223
|
+
colorRenderable: false,
|
|
5224
|
+
textureFilterable: true,
|
|
5225
|
+
block: {
|
|
5226
|
+
bytes: 16,
|
|
5227
|
+
width: 6,
|
|
5228
|
+
height: 5
|
|
5229
|
+
}
|
|
5230
|
+
};
|
|
5231
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR] = {
|
|
5232
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,
|
|
5233
|
+
colorRenderable: false,
|
|
5234
|
+
textureFilterable: true,
|
|
5235
|
+
block: {
|
|
5236
|
+
bytes: 16,
|
|
5237
|
+
width: 6,
|
|
5238
|
+
height: 6
|
|
5239
|
+
}
|
|
5240
|
+
};
|
|
5241
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR] = {
|
|
5242
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,
|
|
5243
|
+
colorRenderable: false,
|
|
5244
|
+
textureFilterable: true,
|
|
5245
|
+
block: {
|
|
5246
|
+
bytes: 16,
|
|
5247
|
+
width: 8,
|
|
5248
|
+
height: 5
|
|
5249
|
+
}
|
|
5250
|
+
};
|
|
5251
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR] = {
|
|
5252
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,
|
|
5253
|
+
colorRenderable: false,
|
|
5254
|
+
textureFilterable: true,
|
|
5255
|
+
block: {
|
|
5256
|
+
bytes: 16,
|
|
5257
|
+
width: 8,
|
|
5258
|
+
height: 6
|
|
5259
|
+
}
|
|
5260
|
+
};
|
|
5261
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR] = {
|
|
5262
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,
|
|
5263
|
+
colorRenderable: false,
|
|
5264
|
+
textureFilterable: true,
|
|
5265
|
+
block: {
|
|
5266
|
+
bytes: 16,
|
|
5267
|
+
width: 8,
|
|
5268
|
+
height: 8
|
|
5269
|
+
}
|
|
5270
|
+
};
|
|
5271
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR] = {
|
|
5272
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,
|
|
5273
|
+
colorRenderable: false,
|
|
5274
|
+
textureFilterable: true,
|
|
5275
|
+
block: {
|
|
5276
|
+
bytes: 16,
|
|
5277
|
+
width: 10,
|
|
5278
|
+
height: 5
|
|
5279
|
+
}
|
|
5280
|
+
};
|
|
5281
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR] = {
|
|
5282
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,
|
|
5283
|
+
colorRenderable: false,
|
|
5284
|
+
textureFilterable: true,
|
|
5285
|
+
block: {
|
|
5286
|
+
bytes: 16,
|
|
5287
|
+
width: 10,
|
|
5288
|
+
height: 6
|
|
5289
|
+
}
|
|
5290
|
+
};
|
|
5291
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR] = {
|
|
5292
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,
|
|
5293
|
+
colorRenderable: false,
|
|
5294
|
+
textureFilterable: true,
|
|
5295
|
+
block: {
|
|
5296
|
+
bytes: 16,
|
|
5297
|
+
width: 10,
|
|
5298
|
+
height: 8
|
|
5299
|
+
}
|
|
5300
|
+
};
|
|
5301
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR] = {
|
|
5302
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,
|
|
5303
|
+
colorRenderable: false,
|
|
5304
|
+
textureFilterable: true,
|
|
5305
|
+
block: {
|
|
5306
|
+
bytes: 16,
|
|
5307
|
+
width: 10,
|
|
5308
|
+
height: 10
|
|
5309
|
+
}
|
|
5310
|
+
};
|
|
5311
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR] = {
|
|
5312
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,
|
|
5313
|
+
colorRenderable: false,
|
|
5314
|
+
textureFilterable: true,
|
|
5315
|
+
block: {
|
|
5316
|
+
bytes: 16,
|
|
5317
|
+
width: 12,
|
|
5318
|
+
height: 10
|
|
5319
|
+
}
|
|
5320
|
+
};
|
|
5321
|
+
t[COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR] = {
|
|
5322
|
+
textureFormat: COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,
|
|
5323
|
+
colorRenderable: false,
|
|
5324
|
+
textureFilterable: true,
|
|
5325
|
+
block: {
|
|
5326
|
+
bytes: 16,
|
|
5327
|
+
width: 12,
|
|
5328
|
+
height: 12
|
|
5329
|
+
}
|
|
5330
|
+
};
|
|
5331
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_bptc.txt
|
|
5332
|
+
t[COMPRESSED_RGBA_BPTC_UNORM_EXT] = {
|
|
5333
|
+
textureFormat: COMPRESSED_RGBA_BPTC_UNORM_EXT,
|
|
5334
|
+
colorRenderable: false,
|
|
5335
|
+
textureFilterable: true,
|
|
5336
|
+
block: block16_4_4
|
|
5337
|
+
};
|
|
5338
|
+
t[COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT] = {
|
|
5339
|
+
textureFormat: COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
|
|
5340
|
+
colorRenderable: false,
|
|
5341
|
+
textureFilterable: true,
|
|
5342
|
+
block: block16_4_4
|
|
5343
|
+
};
|
|
5344
|
+
t[COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT] = {
|
|
5345
|
+
textureFormat: COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
|
|
5346
|
+
colorRenderable: false,
|
|
5347
|
+
textureFilterable: true,
|
|
5348
|
+
block: block16_4_4
|
|
5349
|
+
};
|
|
5350
|
+
t[COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT] = {
|
|
5351
|
+
textureFormat: COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
|
|
5352
|
+
colorRenderable: false,
|
|
5353
|
+
textureFilterable: true,
|
|
5354
|
+
block: block16_4_4
|
|
5355
|
+
};
|
|
5356
|
+
// https://registry.khronos.org/OpenGL/extensions/EXT/EXT_texture_compression_rgtc.txt
|
|
5357
|
+
t[COMPRESSED_RED_RGTC1_EXT] = {
|
|
5358
|
+
textureFormat: COMPRESSED_RED_RGTC1_EXT,
|
|
5359
|
+
colorRenderable: false,
|
|
5360
|
+
textureFilterable: true,
|
|
5361
|
+
block: block8_4_4
|
|
5362
|
+
};
|
|
5363
|
+
t[COMPRESSED_SIGNED_RED_RGTC1_EXT] = {
|
|
5364
|
+
textureFormat: COMPRESSED_SIGNED_RED_RGTC1_EXT,
|
|
5365
|
+
colorRenderable: false,
|
|
5366
|
+
textureFilterable: true,
|
|
5367
|
+
block: block8_4_4
|
|
5368
|
+
};
|
|
5369
|
+
t[COMPRESSED_RED_GREEN_RGTC2_EXT] = {
|
|
5370
|
+
textureFormat: COMPRESSED_RED_GREEN_RGTC2_EXT,
|
|
5371
|
+
colorRenderable: false,
|
|
5372
|
+
textureFilterable: true,
|
|
5373
|
+
block: block8_4_4
|
|
5374
|
+
};
|
|
5375
|
+
t[COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT] = {
|
|
5376
|
+
textureFormat: COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,
|
|
5377
|
+
colorRenderable: false,
|
|
5378
|
+
textureFilterable: true,
|
|
5379
|
+
block: block8_4_4
|
|
5380
|
+
};
|
|
5183
5381
|
s_textureInternalFormatInfo = t;
|
|
5184
5382
|
}
|
|
5185
|
-
|
|
5383
|
+
var info = s_textureInternalFormatInfo[internalFormat];
|
|
5384
|
+
if (!info) {
|
|
5385
|
+
throw new Error("unknown internal format");
|
|
5386
|
+
}
|
|
5387
|
+
return info;
|
|
5186
5388
|
}
|
|
5187
5389
|
|
|
5188
5390
|
/**
|
|
@@ -5194,12 +5396,9 @@ function getTextureInternalFormatInfo(internalFormat) {
|
|
|
5194
5396
|
*/
|
|
5195
5397
|
function getBytesPerElementForInternalFormat(internalFormat, type) {
|
|
5196
5398
|
var info = getTextureInternalFormatInfo(internalFormat);
|
|
5197
|
-
if (!info) {
|
|
5198
|
-
throw "unknown internal format";
|
|
5199
|
-
}
|
|
5200
5399
|
var bytesPerElement = info.bytesPerElementMap[type];
|
|
5201
5400
|
if (bytesPerElement === undefined) {
|
|
5202
|
-
throw "
|
|
5401
|
+
throw new Error("type not supported for internal format");
|
|
5203
5402
|
}
|
|
5204
5403
|
return bytesPerElement;
|
|
5205
5404
|
}
|
|
@@ -5225,7 +5424,7 @@ function getFormatAndTypeForInternalFormat(internalFormat) {
|
|
|
5225
5424
|
var _info$type$, _info$type;
|
|
5226
5425
|
var info = getTextureInternalFormatInfo(internalFormat);
|
|
5227
5426
|
if (!info) {
|
|
5228
|
-
throw "unknown internal format";
|
|
5427
|
+
throw new Error("unknown internal format");
|
|
5229
5428
|
}
|
|
5230
5429
|
return {
|
|
5231
5430
|
format: info.textureFormat,
|
|
@@ -5240,10 +5439,30 @@ function getFormatAndTypeForInternalFormat(internalFormat) {
|
|
|
5240
5439
|
*/
|
|
5241
5440
|
function isCompressedInternalFormat(internalFormat) {
|
|
5242
5441
|
var info = getTextureInternalFormatInfo(internalFormat);
|
|
5243
|
-
|
|
5244
|
-
|
|
5442
|
+
return !!info.block;
|
|
5443
|
+
}
|
|
5444
|
+
|
|
5445
|
+
/**
|
|
5446
|
+
* Gets the width, height, and bytes per block for the given internal format
|
|
5447
|
+
* @param {number} internalFormat
|
|
5448
|
+
* @param {number} type
|
|
5449
|
+
* @private
|
|
5450
|
+
*/
|
|
5451
|
+
function getBlockInfoForInternalFormat(internalFormat, type) {
|
|
5452
|
+
var info = getTextureInternalFormatInfo(internalFormat);
|
|
5453
|
+
if (info.block) {
|
|
5454
|
+
return {
|
|
5455
|
+
blockWidth: info.block.width,
|
|
5456
|
+
blockHeight: info.block.height,
|
|
5457
|
+
bytesPerBlock: info.block.bytes
|
|
5458
|
+
};
|
|
5245
5459
|
}
|
|
5246
|
-
|
|
5460
|
+
var bytesPerBlock = getBytesPerElementForInternalFormat(internalFormat, type);
|
|
5461
|
+
return {
|
|
5462
|
+
blockWidth: 1,
|
|
5463
|
+
blockHeight: 1,
|
|
5464
|
+
bytesPerBlock: bytesPerBlock
|
|
5465
|
+
};
|
|
5247
5466
|
}
|
|
5248
5467
|
|
|
5249
5468
|
/**
|
|
@@ -5272,9 +5491,6 @@ function canGenerateMipmap(gl, width, height, internalFormat) {
|
|
|
5272
5491
|
return isPowerOf2(width) && isPowerOf2(height);
|
|
5273
5492
|
}
|
|
5274
5493
|
var info = getTextureInternalFormatInfo(internalFormat);
|
|
5275
|
-
if (!info) {
|
|
5276
|
-
throw "unknown internal format";
|
|
5277
|
-
}
|
|
5278
5494
|
return info.colorRenderable && info.textureFilterable;
|
|
5279
5495
|
}
|
|
5280
5496
|
|
|
@@ -5286,9 +5502,6 @@ function canGenerateMipmap(gl, width, height, internalFormat) {
|
|
|
5286
5502
|
*/
|
|
5287
5503
|
function canFilter(internalFormat) {
|
|
5288
5504
|
var info = getTextureInternalFormatInfo(internalFormat);
|
|
5289
|
-
if (!info) {
|
|
5290
|
-
throw "unknown internal format";
|
|
5291
|
-
}
|
|
5292
5505
|
return info.textureFilterable;
|
|
5293
5506
|
}
|
|
5294
5507
|
|
|
@@ -5300,9 +5513,6 @@ function canFilter(internalFormat) {
|
|
|
5300
5513
|
*/
|
|
5301
5514
|
function getNumComponentsForFormat(format) {
|
|
5302
5515
|
var info = formatInfo[format];
|
|
5303
|
-
if (!info) {
|
|
5304
|
-
throw "unknown format: " + format;
|
|
5305
|
-
}
|
|
5306
5516
|
return info.numColorComponents;
|
|
5307
5517
|
}
|
|
5308
5518
|
|
|
@@ -5320,7 +5530,7 @@ function getTextureTypeForArrayType(gl, src, defaultType) {
|
|
|
5320
5530
|
}
|
|
5321
5531
|
function guessDimensions(gl, target, width, height, numElements) {
|
|
5322
5532
|
if (numElements % 1 !== 0) {
|
|
5323
|
-
throw "can't guess dimensions";
|
|
5533
|
+
throw new Error("can't guess dimensions");
|
|
5324
5534
|
}
|
|
5325
5535
|
if (!width && !height) {
|
|
5326
5536
|
var size = Math.sqrt(numElements / (target === TEXTURE_CUBE_MAP ? 6 : 1));
|
|
@@ -5334,12 +5544,12 @@ function guessDimensions(gl, target, width, height, numElements) {
|
|
|
5334
5544
|
} else if (!height) {
|
|
5335
5545
|
height = numElements / width;
|
|
5336
5546
|
if (height % 1) {
|
|
5337
|
-
throw "can't guess dimensions";
|
|
5547
|
+
throw new Error("can't guess dimensions");
|
|
5338
5548
|
}
|
|
5339
5549
|
} else if (!width) {
|
|
5340
5550
|
width = numElements / height;
|
|
5341
5551
|
if (width % 1) {
|
|
5342
|
-
throw "can't guess dimensions";
|
|
5552
|
+
throw new Error("can't guess dimensions");
|
|
5343
5553
|
}
|
|
5344
5554
|
}
|
|
5345
5555
|
return {
|
|
@@ -5392,7 +5602,7 @@ function setDefaults(newDefaults) {
|
|
|
5392
5602
|
* @property {number} [level] the mip level to affect. Defaults to 0. Note, if set auto will be considered false unless explicitly set to true.
|
|
5393
5603
|
* @property {number} [width] the width of the texture. Only used if src is an array or typed array or null.
|
|
5394
5604
|
* @property {number} [height] the height of a texture. Only used if src is an array or typed array or null.
|
|
5395
|
-
* @property {number} [depth] the depth of a texture. Only used if src is an array or
|
|
5605
|
+
* @property {number} [depth] the depth of a texture. Only used if src is an array or typed array or null and target is `TEXTURE_3D` .
|
|
5396
5606
|
* @property {number} [min] the min filter setting (eg. `gl.LINEAR`). Defaults to `gl.NEAREST_MIPMAP_LINEAR`
|
|
5397
5607
|
* or if texture is not a power of 2 on both dimensions then defaults to `gl.LINEAR`.
|
|
5398
5608
|
* @property {number} [mag] the mag filter setting (eg. `gl.LINEAR`). Defaults to `gl.LINEAR`
|
|
@@ -5451,15 +5661,24 @@ function setDefaults(newDefaults) {
|
|
|
5451
5661
|
* If `TexImageSource` then it wil be used immediately to create the contents of the texture. Examples `HTMLImageElement`,
|
|
5452
5662
|
* `HTMLCanvasElement`, `HTMLVideoElement`.
|
|
5453
5663
|
*
|
|
5454
|
-
* If `number[]` or `ArrayBufferView` it's assumed to be data for a texture.
|
|
5455
|
-
* not specified it is guessed as follows. First the number of elements is computed by `src.length / numComponents`
|
|
5456
|
-
* where `numComponents` is derived from `format`. If `target` is `gl.TEXTURE_CUBE_MAP` then `numElements` is divided
|
|
5457
|
-
* by 6. Then
|
|
5664
|
+
* If `number[]` or `ArrayBufferView` it's assumed to be data for a texture.
|
|
5458
5665
|
*
|
|
5459
|
-
* *
|
|
5460
|
-
* are set to `sqrt(numElements)`. Otherwise `width = numElements` and `height = 1`.
|
|
5666
|
+
* * If `width` or `height` is not specified it is guessed as follows.
|
|
5461
5667
|
*
|
|
5462
|
-
*
|
|
5668
|
+
* First the number of elements is computed by `src.length / numComponents`
|
|
5669
|
+
* where `numComponents` is derived from `format`. If `target` is `gl.TEXTURE_CUBE_MAP` then `numElements` is divided
|
|
5670
|
+
* by 6. Then
|
|
5671
|
+
*
|
|
5672
|
+
* * If neither `width` nor `height` are specified and `sqrt(numElements)` is an integer then width and height
|
|
5673
|
+
* are set to `sqrt(numElements)`. Otherwise `width = numElements` and `height = 1`.
|
|
5674
|
+
*
|
|
5675
|
+
* * If only one of `width` or `height` is specified then the other equals `numElements / specifiedDimension`.
|
|
5676
|
+
*
|
|
5677
|
+
* * If both `width` and `height` is specified, then, the size of mip levels from `level` will be computed
|
|
5678
|
+
* and data for consecutive mip levels will be uploaded until the data runs out.
|
|
5679
|
+
*
|
|
5680
|
+
* In other words: `{ format: g.RGBA, width: 4, height: 4, src: Uint8Array((4 * 4 + 2 * 2 + 1) * 4) }`
|
|
5681
|
+
* uploads 3 mip levels (4x4, 2x2, 1x1) because src is more than the data for the first mip level.
|
|
5463
5682
|
*
|
|
5464
5683
|
* If `number[]` will be converted to `type`.
|
|
5465
5684
|
*
|
|
@@ -5710,27 +5929,48 @@ function make1Pixel(color) {
|
|
|
5710
5929
|
return new Uint8Array([color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255]);
|
|
5711
5930
|
}
|
|
5712
5931
|
|
|
5932
|
+
/**
|
|
5933
|
+
* @typedef {Object} SetTextureFilteringInternalOptions
|
|
5934
|
+
* @property {module:twgl.TextureOptions} [options] A TextureOptions object with whatever parameters you want set.
|
|
5935
|
+
* This is often the same options you passed in when you created the texture.
|
|
5936
|
+
* @property {number} [width] width of texture
|
|
5937
|
+
* @property {number} [height] height of texture
|
|
5938
|
+
* @property {number} [internalFormat] The internalFormat parameter from texImage2D etc..
|
|
5939
|
+
* @property {number} [lastMipLevelUploaded] The last mip level manually uploaded
|
|
5940
|
+
* @private
|
|
5941
|
+
*/
|
|
5942
|
+
|
|
5713
5943
|
/**
|
|
5714
5944
|
* Sets filtering or generates mips for texture based on width or height
|
|
5715
5945
|
* If width or height is not passed in uses `options.width` and//or `options.height`
|
|
5716
5946
|
*
|
|
5717
5947
|
* @param {WebGLRenderingContext} gl the WebGLRenderingContext
|
|
5718
5948
|
* @param {WebGLTexture} tex the WebGLTexture to set parameters for
|
|
5719
|
-
* @param {
|
|
5720
|
-
*
|
|
5721
|
-
* @param {number} [width] width of texture
|
|
5722
|
-
* @param {number} [height] height of texture
|
|
5723
|
-
* @param {number} [internalFormat] The internalFormat parameter from texImage2D etc..
|
|
5724
|
-
* @memberOf module:twgl/textures
|
|
5949
|
+
* @param {SetTextureFilteringInternalOptions} p
|
|
5950
|
+
* @private
|
|
5725
5951
|
*/
|
|
5726
|
-
function
|
|
5952
|
+
function setTextureFilteringForSizeInternal(gl, tex, _ref2) {
|
|
5953
|
+
var options = _ref2.options,
|
|
5954
|
+
width = _ref2.width,
|
|
5955
|
+
height = _ref2.height,
|
|
5956
|
+
internalFormat = _ref2.internalFormat,
|
|
5957
|
+
lastMipLevelUploaded = _ref2.lastMipLevelUploaded;
|
|
5727
5958
|
options = options || defaults.textureOptions;
|
|
5728
5959
|
internalFormat = internalFormat || RGBA;
|
|
5729
5960
|
var target = options.target || TEXTURE_2D;
|
|
5730
5961
|
width = width || options.width;
|
|
5731
5962
|
height = height || options.height;
|
|
5732
5963
|
gl.bindTexture(target, tex);
|
|
5733
|
-
if (
|
|
5964
|
+
if (lastMipLevelUploaded > 1) {
|
|
5965
|
+
var lastLevelWidth = Math.max(1, width >> lastMipLevelUploaded);
|
|
5966
|
+
var lastLevelHeight = Math.max(1, height >> lastMipLevelUploaded);
|
|
5967
|
+
// Note: This is a guess. The user can set maxLod etc...
|
|
5968
|
+
var canUseMips = lastLevelWidth === 1 && lastLevelHeight === 1;
|
|
5969
|
+
var magFiltering = canFilter(internalFormat) ? LINEAR : NEAREST;
|
|
5970
|
+
var minFiltering = canFilter(internalFormat) ? canUseMips ? NEAREST_MIPMAP_LINEAR : LINEAR : NEAREST;
|
|
5971
|
+
gl.texParameteri(target, TEXTURE_MAG_FILTER, magFiltering);
|
|
5972
|
+
gl.texParameteri(target, TEXTURE_MIN_FILTER, minFiltering);
|
|
5973
|
+
} else if (canGenerateMipmap(gl, width, height, internalFormat)) {
|
|
5734
5974
|
gl.generateMipmap(target);
|
|
5735
5975
|
} else {
|
|
5736
5976
|
var filtering = canFilter(internalFormat) ? LINEAR : NEAREST;
|
|
@@ -5740,6 +5980,28 @@ function setTextureFilteringForSize(gl, tex, options, width, height, internalFor
|
|
|
5740
5980
|
gl.texParameteri(target, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
|
|
5741
5981
|
}
|
|
5742
5982
|
}
|
|
5983
|
+
|
|
5984
|
+
/**
|
|
5985
|
+
* Sets filtering or generates mips for texture based on width or height
|
|
5986
|
+
* If width or height is not passed in uses `options.width` and//or `options.height`
|
|
5987
|
+
*
|
|
5988
|
+
* @param {WebGLRenderingContext} gl the WebGLRenderingContext
|
|
5989
|
+
* @param {WebGLTexture} tex the WebGLTexture to set parameters for
|
|
5990
|
+
* @param {module:twgl.TextureOptions} [options] A TextureOptions object with whatever parameters you want set.
|
|
5991
|
+
* This is often the same options you passed in when you created the texture.
|
|
5992
|
+
* @param {number} [width] width of texture
|
|
5993
|
+
* @param {number} [height] height of texture
|
|
5994
|
+
* @param {number} [internalFormat] The internalFormat parameter from texImage2D etc..
|
|
5995
|
+
* @memberOf module:twgl/textures
|
|
5996
|
+
*/
|
|
5997
|
+
function setTextureFilteringForSize(gl, tex, options, width, height, internalFormat) {
|
|
5998
|
+
setTextureFilteringForSizeInternal(gl, tex, {
|
|
5999
|
+
options: options,
|
|
6000
|
+
width: width,
|
|
6001
|
+
height: height,
|
|
6002
|
+
internalFormat: internalFormat
|
|
6003
|
+
});
|
|
6004
|
+
}
|
|
5743
6005
|
function shouldAutomaticallySetTextureFilteringForSize(options) {
|
|
5744
6006
|
return options.auto === true || options.auto === undefined && options.level === undefined;
|
|
5745
6007
|
}
|
|
@@ -5839,7 +6101,7 @@ function setTextureFromElement(gl, tex, element, options) {
|
|
|
5839
6101
|
size = imgWidth / 2;
|
|
5840
6102
|
slices = [0, 0, 1, 0, 0, 1, 1, 1, 0, 2, 1, 2];
|
|
5841
6103
|
} else {
|
|
5842
|
-
throw "can't figure out cube map from element: "
|
|
6104
|
+
throw new Error("can't figure out cube map from element: ".concat(element.src ? element.src : element.nodeName));
|
|
5843
6105
|
}
|
|
5844
6106
|
var ctx = getShared2DContext();
|
|
5845
6107
|
if (ctx) {
|
|
@@ -5892,7 +6154,7 @@ function setTextureFromElement(gl, tex, element, options) {
|
|
|
5892
6154
|
var largest = Math.max(element.width, element.height);
|
|
5893
6155
|
var depth = largest / smallest;
|
|
5894
6156
|
if (depth % 1 !== 0) {
|
|
5895
|
-
throw "can not compute 3D dimensions of element";
|
|
6157
|
+
throw new Error("can not compute 3D dimensions of element");
|
|
5896
6158
|
}
|
|
5897
6159
|
var xMult = element.width === largest ? 1 : 0;
|
|
5898
6160
|
var yMult = element.height === largest ? 1 : 0;
|
|
@@ -6174,7 +6436,7 @@ function loadCubemapFromUrls(gl, tex, options, callback) {
|
|
|
6174
6436
|
callback = callback || noop;
|
|
6175
6437
|
var urls = options.src;
|
|
6176
6438
|
if (urls.length !== 6) {
|
|
6177
|
-
throw "there must be 6 urls for a cubemap";
|
|
6439
|
+
throw new Error("there must be 6 urls for a cubemap");
|
|
6178
6440
|
}
|
|
6179
6441
|
var level = options.level || 0;
|
|
6180
6442
|
var internalFormat = options.internalFormat || options.format || RGBA;
|
|
@@ -6183,7 +6445,7 @@ function loadCubemapFromUrls(gl, tex, options, callback) {
|
|
|
6183
6445
|
var type = options.type || UNSIGNED_BYTE;
|
|
6184
6446
|
var target = options.target || TEXTURE_2D;
|
|
6185
6447
|
if (target !== TEXTURE_CUBE_MAP) {
|
|
6186
|
-
throw "target must be TEXTURE_CUBE_MAP";
|
|
6448
|
+
throw new Error("target must be TEXTURE_CUBE_MAP");
|
|
6187
6449
|
}
|
|
6188
6450
|
setTextureTo1PixelColor(gl, tex, options);
|
|
6189
6451
|
// Because it's async we need to copy the options.
|
|
@@ -6261,7 +6523,7 @@ function loadSlicesFromUrls(gl, tex, options, callback) {
|
|
|
6261
6523
|
var type = options.type || UNSIGNED_BYTE;
|
|
6262
6524
|
var target = options.target || TEXTURE_2D_ARRAY;
|
|
6263
6525
|
if (target !== TEXTURE_3D && target !== TEXTURE_2D_ARRAY) {
|
|
6264
|
-
throw "target must be TEXTURE_3D or TEXTURE_2D_ARRAY";
|
|
6526
|
+
throw new Error("target must be TEXTURE_3D or TEXTURE_2D_ARRAY");
|
|
6265
6527
|
}
|
|
6266
6528
|
setTextureTo1PixelColor(gl, tex, options);
|
|
6267
6529
|
// Because it's async we need to copy the options.
|
|
@@ -6351,63 +6613,96 @@ function setTextureFromArray(gl, tex, src, options) {
|
|
|
6351
6613
|
} else if (src instanceof Uint8ClampedArray) {
|
|
6352
6614
|
src = new Uint8Array(src.buffer);
|
|
6353
6615
|
}
|
|
6354
|
-
var _getTextureSize = getTextureSize(
|
|
6616
|
+
var _getTextureSize = getTextureSize(target, src, options, internalFormat, format, type),
|
|
6355
6617
|
width = _getTextureSize.width,
|
|
6356
6618
|
height = _getTextureSize.height,
|
|
6357
6619
|
depth = _getTextureSize.depth;
|
|
6358
6620
|
var compressed = isCompressedInternalFormat(internalFormat);
|
|
6359
6621
|
setSkipStateToDefault(gl);
|
|
6360
6622
|
gl.pixelStorei(UNPACK_ALIGNMENT, options.unpackAlignment || 1);
|
|
6623
|
+
var mipLevelOffset = 0; // this is in addition to level
|
|
6361
6624
|
scopedSetPackState(gl, options, function () {
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6625
|
+
var mipLevelByteOffset = 0;
|
|
6626
|
+
var _getBlockInfoForInter = getBlockInfoForInternalFormat(internalFormat, type),
|
|
6627
|
+
blockWidth = _getBlockInfoForInter.blockWidth,
|
|
6628
|
+
blockHeight = _getBlockInfoForInter.blockHeight,
|
|
6629
|
+
bytesPerBlock = _getBlockInfoForInter.bytesPerBlock;
|
|
6630
|
+
var _loop = function _loop() {
|
|
6631
|
+
var mipWidth = Math.max(1, width >> mipLevelOffset);
|
|
6632
|
+
var mipHeight = Math.max(1, height >> mipLevelOffset);
|
|
6633
|
+
var mipDepth = target === TEXTURE_2D ? Math.max(1, depth >> mipLevelOffset) : depth;
|
|
6634
|
+
var blocksAcross = Math.ceil(mipWidth / blockWidth);
|
|
6635
|
+
var blocksDown = Math.ceil(mipHeight / blockHeight);
|
|
6636
|
+
var numFaces = target === TEXTURE_CUBE_MAP ? 6 : 1;
|
|
6637
|
+
var bytesPerMipLevel = blocksAcross * blocksDown * bytesPerBlock * mipDepth * numFaces;
|
|
6638
|
+
if (mipLevelByteOffset + bytesPerMipLevel > src.byteLength) {
|
|
6639
|
+
throw new Error('src size does not match number of mip levels');
|
|
6640
|
+
}
|
|
6641
|
+
var mipSource = src.subarray(mipLevelByteOffset / src.BYTES_PER_ELEMENT, (mipLevelByteOffset + bytesPerMipLevel) / src.BYTES_PER_ELEMENT);
|
|
6642
|
+
var mipLevel = level + mipLevelOffset;
|
|
6643
|
+
if (target === TEXTURE_CUBE_MAP) {
|
|
6644
|
+
var faceSize = mipSource.length / 6;
|
|
6645
|
+
getCubeFacesWithNdx(gl, options).forEach(function (f) {
|
|
6646
|
+
var offset = faceSize * f.ndx;
|
|
6647
|
+
var data = mipSource.subarray(offset, offset + faceSize);
|
|
6648
|
+
if (compressed) {
|
|
6649
|
+
gl.compressedTexImage2D(f.face, mipLevel, internalFormat, mipWidth, mipHeight, 0, data);
|
|
6650
|
+
} else {
|
|
6651
|
+
gl.texImage2D(f.face, mipLevel, internalFormat, mipWidth, mipHeight, 0, format, type, data);
|
|
6652
|
+
}
|
|
6653
|
+
});
|
|
6654
|
+
} else if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
|
|
6655
|
+
gl.texImage3D(target, mipLevel, internalFormat, mipWidth, mipHeight, mipDepth, 0, format, type, mipSource);
|
|
6656
|
+
} else {
|
|
6367
6657
|
if (compressed) {
|
|
6368
|
-
gl.compressedTexImage2D(
|
|
6658
|
+
gl.compressedTexImage2D(target, mipLevel, internalFormat, mipWidth, mipHeight, 0, mipSource);
|
|
6369
6659
|
} else {
|
|
6370
|
-
gl.texImage2D(
|
|
6660
|
+
gl.texImage2D(target, mipLevel, internalFormat, mipWidth, mipHeight, 0, format, type, mipSource);
|
|
6371
6661
|
}
|
|
6372
|
-
});
|
|
6373
|
-
} else if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
|
|
6374
|
-
gl.texImage3D(target, level, internalFormat, width, height, depth, 0, format, type, src);
|
|
6375
|
-
} else {
|
|
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
6662
|
}
|
|
6663
|
+
++mipLevelOffset;
|
|
6664
|
+
mipLevelByteOffset += bytesPerMipLevel;
|
|
6665
|
+
if (mipWidth === 1 && mipHeight === 1 && mipDepth === 1 && mipLevelByteOffset !== src.byteLength) {
|
|
6666
|
+
throw new Error('src size has more data than can fit in mip levels');
|
|
6667
|
+
}
|
|
6668
|
+
};
|
|
6669
|
+
while (mipLevelByteOffset < src.byteLength) {
|
|
6670
|
+
_loop();
|
|
6381
6671
|
}
|
|
6382
6672
|
});
|
|
6383
6673
|
return {
|
|
6384
6674
|
width: width,
|
|
6385
6675
|
height: height,
|
|
6386
6676
|
depth: depth,
|
|
6387
|
-
type: type
|
|
6677
|
+
type: type,
|
|
6678
|
+
lastMipLevelUploaded: level + mipLevelOffset - 1
|
|
6388
6679
|
};
|
|
6389
6680
|
}
|
|
6390
|
-
function getTextureSize(
|
|
6681
|
+
function getTextureSize(target, src, options, internalFormat, format, type) {
|
|
6391
6682
|
var width = options.width;
|
|
6392
6683
|
var height = options.height;
|
|
6393
6684
|
var depth = options.depth;
|
|
6394
6685
|
var compressed = isCompressedInternalFormat(internalFormat);
|
|
6395
6686
|
if (compressed) {
|
|
6396
6687
|
if (!width || !height) {
|
|
6397
|
-
throw "compressed texture needs to set width and height!";
|
|
6688
|
+
throw new Error("compressed texture needs to set width and height!");
|
|
6398
6689
|
}
|
|
6690
|
+
depth = depth || 1;
|
|
6399
6691
|
} else {
|
|
6400
6692
|
var bytesPerElement = getBytesPerElementForInternalFormat(internalFormat, type);
|
|
6401
6693
|
var numElements = src.byteLength / bytesPerElement; // TODO: check UNPACK_ALIGNMENT?
|
|
6402
6694
|
if (numElements % 1) {
|
|
6403
|
-
throw "length wrong size for format: "
|
|
6695
|
+
throw new Error("length wrong size for format: ".concat(utils.glEnumToString(gl, format)));
|
|
6696
|
+
}
|
|
6697
|
+
if (compressed && (!width || !height)) {
|
|
6698
|
+
throw new Error("compressed texture needs to set width and height!");
|
|
6404
6699
|
}
|
|
6405
6700
|
var dimensions;
|
|
6406
6701
|
if (target === TEXTURE_3D || target === TEXTURE_2D_ARRAY) {
|
|
6407
6702
|
if (!width && !height && !depth) {
|
|
6408
6703
|
var size = Math.cbrt(numElements);
|
|
6409
6704
|
if (size % 1 !== 0) {
|
|
6410
|
-
throw "can't guess cube size of array of numElements: "
|
|
6705
|
+
throw new Error("can't guess cube size of array of numElements: ".concat(numElements));
|
|
6411
6706
|
}
|
|
6412
6707
|
width = size;
|
|
6413
6708
|
height = size;
|
|
@@ -6507,6 +6802,7 @@ function createTexture(gl, options, callback) {
|
|
|
6507
6802
|
var target = options.target || TEXTURE_2D;
|
|
6508
6803
|
var width = options.width || 1;
|
|
6509
6804
|
var height = options.height || 1;
|
|
6805
|
+
var lastMipLevelUploaded = 0;
|
|
6510
6806
|
var internalFormat = options.internalFormat || RGBA;
|
|
6511
6807
|
gl.bindTexture(target, tex);
|
|
6512
6808
|
if (target === TEXTURE_CUBE_MAP) {
|
|
@@ -6525,6 +6821,7 @@ function createTexture(gl, options, callback) {
|
|
|
6525
6821
|
var dimensions = setTextureFromArray(gl, tex, src, options);
|
|
6526
6822
|
width = dimensions.width;
|
|
6527
6823
|
height = dimensions.height;
|
|
6824
|
+
lastMipLevelUploaded = dimensions.lastMipLevelUploaded;
|
|
6528
6825
|
} else if (Array.isArray(src) && (typeof src[0] === 'string' || isTexImageSource(src[0]))) {
|
|
6529
6826
|
if (target === TEXTURE_CUBE_MAP) {
|
|
6530
6827
|
loadCubemapFromUrls(gl, tex, options, callback);
|
|
@@ -6541,7 +6838,13 @@ function createTexture(gl, options, callback) {
|
|
|
6541
6838
|
setEmptyTexture(gl, tex, options);
|
|
6542
6839
|
}
|
|
6543
6840
|
if (shouldAutomaticallySetTextureFilteringForSize(options)) {
|
|
6544
|
-
|
|
6841
|
+
setTextureFilteringForSizeInternal(gl, tex, {
|
|
6842
|
+
options: options,
|
|
6843
|
+
width: width,
|
|
6844
|
+
height: height,
|
|
6845
|
+
internalFormat: internalFormat,
|
|
6846
|
+
lastMipLevelUploaded: lastMipLevelUploaded
|
|
6847
|
+
});
|
|
6545
6848
|
}
|
|
6546
6849
|
setTextureParameters(gl, tex, options);
|
|
6547
6850
|
return tex;
|