|
@@ -184,16 +184,6 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
var _gl;
|
|
|
|
|
|
- var _glExtensionTextureFloat;
|
|
|
- var _glExtensionTextureFloatLinear;
|
|
|
- var _glExtensionStandardDerivatives;
|
|
|
- var _glExtensionTextureFilterAnisotropic;
|
|
|
- var _glExtensionCompressedTextureS3TC;
|
|
|
- var _glExtensionCompressedTexturePVRTC;
|
|
|
- var _glExtensionElementIndexUint;
|
|
|
- var _glExtensionFragDepth;
|
|
|
- var _glExtensionBlendMinMax;
|
|
|
-
|
|
|
try {
|
|
|
|
|
|
var attributes = {
|
|
@@ -219,63 +209,6 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- _glExtensionTextureFloat = _gl.getExtension( 'OES_texture_float' );
|
|
|
- _glExtensionTextureFloatLinear = _gl.getExtension( 'OES_texture_float_linear' );
|
|
|
-
|
|
|
- if ( _glExtensionTextureFloat === null ) {
|
|
|
-
|
|
|
- console.log( 'THREE.WebGLRenderer: Float textures not supported.' );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- _glExtensionStandardDerivatives = _gl.getExtension( 'OES_standard_derivatives' );
|
|
|
-
|
|
|
- if ( _glExtensionStandardDerivatives === null ) {
|
|
|
-
|
|
|
- console.log( 'THREE.WebGLRenderer: Standard derivatives not supported.' );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- _glExtensionTextureFilterAnisotropic = _gl.getExtension( 'EXT_texture_filter_anisotropic' ) || _gl.getExtension( 'MOZ_EXT_texture_filter_anisotropic' ) || _gl.getExtension( 'WEBKIT_EXT_texture_filter_anisotropic' );
|
|
|
-
|
|
|
- if ( _glExtensionTextureFilterAnisotropic === null ) {
|
|
|
-
|
|
|
- console.log( 'THREE.WebGLRenderer: Anisotropic texture filtering not supported.' );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- _glExtensionCompressedTextureS3TC = _gl.getExtension( 'WEBGL_compressed_texture_s3tc' ) || _gl.getExtension( 'MOZ_WEBGL_compressed_texture_s3tc' ) || _gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_s3tc' );
|
|
|
-
|
|
|
- if ( _glExtensionCompressedTextureS3TC === null ) {
|
|
|
-
|
|
|
- console.log( 'THREE.WebGLRenderer: S3TC compressed textures not supported.' );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- _glExtensionCompressedTexturePVRTC = _gl.getExtension( 'WEBGL_compressed_texture_pvrtc' ) || _gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );
|
|
|
-
|
|
|
- if ( _glExtensionCompressedTexturePVRTC === null ) {
|
|
|
-
|
|
|
- console.log( 'THREE.WebGLRenderer: PVRTC compressed textures not supported.' );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- _glExtensionElementIndexUint = _gl.getExtension( 'OES_element_index_uint' );
|
|
|
-
|
|
|
- if ( _glExtensionElementIndexUint === null ) {
|
|
|
-
|
|
|
- console.log( 'THREE.WebGLRenderer: elementindex as unsigned integer not supported.' );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- _glExtensionBlendMinMax = _gl.getExtension( 'EXT_blend_minmax' );
|
|
|
-
|
|
|
- if ( _glExtensionBlendMinMax === null ) {
|
|
|
-
|
|
|
- console.log( 'THREE.WebGLRenderer: min max blend equations not supported.' );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
if ( _gl.getShaderPrecisionFormat === undefined ) {
|
|
|
|
|
|
_gl.getShaderPrecisionFormat = function () {
|
|
@@ -289,9 +222,11 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ var extensions = new THREE.WebGLExtensions( _gl );
|
|
|
+
|
|
|
if ( _logarithmicDepthBuffer ) {
|
|
|
|
|
|
- _glExtensionFragDepth = _gl.getExtension( 'EXT_frag_depth' );
|
|
|
+ extensions.get( 'EXT_frag_depth' );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -331,20 +266,23 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
var _maxTextureSize = _gl.getParameter( _gl.MAX_TEXTURE_SIZE );
|
|
|
var _maxCubemapSize = _gl.getParameter( _gl.MAX_CUBE_MAP_TEXTURE_SIZE );
|
|
|
|
|
|
- var _maxAnisotropy = _glExtensionTextureFilterAnisotropic ? _gl.getParameter( _glExtensionTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT ) : 0;
|
|
|
-
|
|
|
- var _supportsVertexTextures = ( _maxVertexTextures > 0 );
|
|
|
- var _supportsBoneTextures = _supportsVertexTextures && _glExtensionTextureFloat;
|
|
|
+ var _supportsVertexTextures = _maxVertexTextures > 0;
|
|
|
+ var _supportsBoneTextures = _supportsVertexTextures && extensions.get( 'OES_texture_float' );
|
|
|
|
|
|
// COMPRESSED_TEXTURE_FORMATS return IntArray
|
|
|
// but we need Array.indexOf to test formats availabilities
|
|
|
var _compressedTextureFormats = [];
|
|
|
|
|
|
- if( _glExtensionCompressedTexturePVRTC || _glExtensionCompressedTextureS3TC ) {
|
|
|
+ if ( extensions.get( 'WEBGL_compressed_texture_pvrtc' ) || extensions.get( 'WEBGL_compressed_texture_s3tc' ) ) {
|
|
|
+
|
|
|
var compressedfmts = _gl.getParameter( _gl.COMPRESSED_TEXTURE_FORMATS );
|
|
|
- for( var i = 0; i < compressedfmts.length; i++ ){
|
|
|
- _compressedTextureFormats.push( compressedfmts[i] );
|
|
|
+
|
|
|
+ for ( var i = 0; i < compressedfmts.length; i ++ ){
|
|
|
+
|
|
|
+ _compressedTextureFormats.push( compressedfmts[ i ] );
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
@@ -402,39 +340,55 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
this.supportsFloatTextures = function () {
|
|
|
|
|
|
- return _glExtensionTextureFloat;
|
|
|
+ return extensions.get( 'OES_texture_float' );
|
|
|
|
|
|
};
|
|
|
|
|
|
this.supportsStandardDerivatives = function () {
|
|
|
|
|
|
- return _glExtensionStandardDerivatives;
|
|
|
+ return extensions.get( 'OES_standard_derivatives' );
|
|
|
|
|
|
};
|
|
|
|
|
|
this.supportsCompressedTextureS3TC = function () {
|
|
|
|
|
|
- return _glExtensionCompressedTextureS3TC;
|
|
|
+ return extensions.get( 'WEBGL_compressed_texture_s3tc' );
|
|
|
|
|
|
};
|
|
|
|
|
|
this.supportsCompressedTexturePVRTC = function () {
|
|
|
|
|
|
- return _glExtensionCompressedTexturePVRTC;
|
|
|
+ return extensions.get( 'WEBGL_compressed_texture_pvrtc' );
|
|
|
|
|
|
};
|
|
|
|
|
|
this.supportsBlendMinMax = function () {
|
|
|
|
|
|
- return _glExtensionBlendMinMax;
|
|
|
+ return extensions.get( 'EXT_blend_minmax' );
|
|
|
|
|
|
};
|
|
|
|
|
|
- this.getMaxAnisotropy = function () {
|
|
|
+ this.getMaxAnisotropy = ( function () {
|
|
|
|
|
|
- return _maxAnisotropy;
|
|
|
+ var value;
|
|
|
|
|
|
- };
|
|
|
+ return function () {
|
|
|
+
|
|
|
+ if ( value !== undefined ) {
|
|
|
+
|
|
|
+ return value;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ var extension = extensions.get( 'EXT_texture_filter_anisotropic' );
|
|
|
+
|
|
|
+ value = extension !== null ? _gl.getParameter( extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT ) : 0;
|
|
|
+
|
|
|
+ return value;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ } )();
|
|
|
|
|
|
this.getPrecision = function () {
|
|
|
|
|
@@ -1099,7 +1053,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- var UintArray = _glExtensionElementIndexUint !== null && ntris > 21845 ? Uint32Array : Uint16Array; // 65535 / 3
|
|
|
+ var UintArray = extensions.get( 'OES_element_index_uint' ) !== null && ntris > 21845 ? Uint32Array : Uint16Array; // 65535 / 3
|
|
|
|
|
|
geometryGroup.__typeArray = UintArray;
|
|
|
geometryGroup.__faceArray = new UintArray( ntris * 3 );
|
|
@@ -3943,7 +3897,7 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
delete _webglObjects[ object.id ];
|
|
|
|
|
|
- geometryGroups[ geometry.id ] = makeGroups( geometry, material instanceof THREE.MeshFaceMaterial, _glExtensionElementIndexUint ? 4294967296 : 65535 );
|
|
|
+ geometryGroups[ geometry.id ] = makeGroups( geometry, material instanceof THREE.MeshFaceMaterial, extensions.get( 'OES_element_index_uint' ) ? 4294967296 : 65535 );
|
|
|
|
|
|
geometry.groupsNeedUpdate = false;
|
|
|
|
|
@@ -5784,6 +5738,8 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
function setTextureParameters ( textureType, texture, isImagePowerOfTwo ) {
|
|
|
|
|
|
+ var extension;
|
|
|
+
|
|
|
if ( isImagePowerOfTwo ) {
|
|
|
|
|
|
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, paramThreeToGL( texture.wrapS ) );
|
|
@@ -5802,11 +5758,13 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( _glExtensionTextureFilterAnisotropic && texture.type !== THREE.FloatType ) {
|
|
|
+ extension = extensions.get( 'EXT_texture_filter_anisotropic' );
|
|
|
+
|
|
|
+ if ( extension && texture.type !== THREE.FloatType ) {
|
|
|
|
|
|
if ( texture.anisotropy > 1 || texture.__oldAnisotropy ) {
|
|
|
|
|
|
- _gl.texParameterf( textureType, _glExtensionTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, _maxAnisotropy ) );
|
|
|
+ _gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, _this.getMaxAnisotropy() ) );
|
|
|
texture.__oldAnisotropy = texture.anisotropy;
|
|
|
|
|
|
}
|
|
@@ -6313,6 +6271,8 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
|
|
|
function paramThreeToGL ( p ) {
|
|
|
|
|
|
+ var extension;
|
|
|
+
|
|
|
if ( p === THREE.RepeatWrapping ) return _gl.REPEAT;
|
|
|
if ( p === THREE.ClampToEdgeWrapping ) return _gl.CLAMP_TO_EDGE;
|
|
|
if ( p === THREE.MirroredRepeatWrapping ) return _gl.MIRRORED_REPEAT;
|
|
@@ -6360,28 +6320,34 @@ THREE.WebGLRenderer = function ( parameters ) {
|
|
|
if ( p === THREE.OneMinusDstColorFactor ) return _gl.ONE_MINUS_DST_COLOR;
|
|
|
if ( p === THREE.SrcAlphaSaturateFactor ) return _gl.SRC_ALPHA_SATURATE;
|
|
|
|
|
|
- if ( _glExtensionCompressedTextureS3TC !== null ) {
|
|
|
+ extension = extensions.get( 'WEBGL_compressed_texture_s3tc' );
|
|
|
|
|
|
- if ( p === THREE.RGB_S3TC_DXT1_Format ) return _glExtensionCompressedTextureS3TC.COMPRESSED_RGB_S3TC_DXT1_EXT;
|
|
|
- if ( p === THREE.RGBA_S3TC_DXT1_Format ) return _glExtensionCompressedTextureS3TC.COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
|
|
- if ( p === THREE.RGBA_S3TC_DXT3_Format ) return _glExtensionCompressedTextureS3TC.COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
|
|
- if ( p === THREE.RGBA_S3TC_DXT5_Format ) return _glExtensionCompressedTextureS3TC.COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
|
|
+ if ( extension !== null ) {
|
|
|
+
|
|
|
+ if ( p === THREE.RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;
|
|
|
+ if ( p === THREE.RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
|
|
+ if ( p === THREE.RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
|
|
+ if ( p === THREE.RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( _glExtensionCompressedTexturePVRTC !== null ) {
|
|
|
+ extension = extensions.get( 'WEBGL_compressed_texture_pvrtc' );
|
|
|
+
|
|
|
+ if ( extension !== null ) {
|
|
|
|
|
|
- if ( p === THREE.RGB_PVRTC_4BPPV1_Format ) return _glExtensionCompressedTexturePVRTC.COMPRESSED_RGB_PVRTC_4BPPV1_IMG ;
|
|
|
- if ( p === THREE.RGB_PVRTC_2BPPV1_Format ) return _glExtensionCompressedTexturePVRTC.COMPRESSED_RGB_PVRTC_2BPPV1_IMG ;
|
|
|
- if ( p === THREE.RGBA_PVRTC_4BPPV1_Format ) return _glExtensionCompressedTexturePVRTC.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG ;
|
|
|
- if ( p === THREE.RGBA_PVRTC_2BPPV1_Format ) return _glExtensionCompressedTexturePVRTC.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG ;
|
|
|
+ if ( p === THREE.RGB_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
|
|
|
+ if ( p === THREE.RGB_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
|
|
|
+ if ( p === THREE.RGBA_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
|
|
|
+ if ( p === THREE.RGBA_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( _glExtensionBlendMinMax !== undefined ) {
|
|
|
+ extension = extensions.get( 'EXT_blend_minmax' );
|
|
|
+
|
|
|
+ if ( extension !== null ) {
|
|
|
|
|
|
- if ( p === THREE.MinEquation ) return _glExtensionBlendMinMax.MIN_EXT;
|
|
|
- if ( p === THREE.MaxEquation ) return _glExtensionBlendMinMax.MAX_EXT;
|
|
|
+ if ( p === THREE.MinEquation ) return extension.MIN_EXT;
|
|
|
+ if ( p === THREE.MaxEquation ) return extension.MAX_EXT;
|
|
|
|
|
|
}
|
|
|
|