提交 5d1b8810 编写于 作者: M Mr.doob

Updated builds.

上级 f0e111b2
......@@ -18420,7 +18420,7 @@
* @author mrdoob / http://mrdoob.com/
*/
function WebGLTextures( _gl, extensions, state, properties, capabilities, paramThreeToGL, infoMemory ) {
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, infoMemory ) {
var _isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && _gl instanceof WebGL2RenderingContext );
......@@ -18679,8 +18679,8 @@
var image = cubeImage[ 0 ],
isPowerOfTwoImage = isPowerOfTwo( image ),
glFormat = paramThreeToGL( texture.format ),
glType = paramThreeToGL( texture.type );
glFormat = utils.convert( texture.format ),
glType = utils.convert( texture.type );
setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, isPowerOfTwoImage );
......@@ -18764,11 +18764,11 @@
if ( isPowerOfTwoImage ) {
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, paramThreeToGL( texture.wrapS ) );
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, paramThreeToGL( texture.wrapT ) );
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, utils.convert( texture.wrapS ) );
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, utils.convert( texture.wrapT ) );
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, paramThreeToGL( texture.magFilter ) );
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, paramThreeToGL( texture.minFilter ) );
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, utils.convert( texture.magFilter ) );
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, utils.convert( texture.minFilter ) );
} else {
......@@ -18840,8 +18840,8 @@
}
var isPowerOfTwoImage = isPowerOfTwo( image ),
glFormat = paramThreeToGL( texture.format ),
glType = paramThreeToGL( texture.type );
glFormat = utils.convert( texture.format ),
glType = utils.convert( texture.type );
setTextureParameters( _gl.TEXTURE_2D, texture, isPowerOfTwoImage );
......@@ -18875,7 +18875,7 @@
console.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );
texture.type = UnsignedShortType;
glType = paramThreeToGL( texture.type );
glType = utils.convert( texture.type );
}
......@@ -18895,7 +18895,7 @@
console.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' );
texture.type = UnsignedInt248Type;
glType = paramThreeToGL( texture.type );
glType = utils.convert( texture.type );
}
......@@ -18992,8 +18992,8 @@
// Setup storage for target texture and bind it to correct framebuffer
function setupFrameBufferTexture( framebuffer, renderTarget, attachment, textureTarget ) {
var glFormat = paramThreeToGL( renderTarget.texture.format );
var glType = paramThreeToGL( renderTarget.texture.type );
var glFormat = utils.convert( renderTarget.texture.format );
var glType = utils.convert( renderTarget.texture.type );
state.texImage2D( textureTarget, 0, glFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );
_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( renderTarget.texture ).__webglTexture, 0 );
......@@ -19255,7 +19255,7 @@
* @author mrdoob / http://mrdoob.com/
*/
function WebGLState( gl, extensions, paramThreeToGL ) {
function WebGLState( gl, extensions, utils ) {
function ColorBuffer() {
......@@ -19873,7 +19873,7 @@
if ( blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha ) {
gl.blendEquationSeparate( paramThreeToGL( blendEquation ), paramThreeToGL( blendEquationAlpha ) );
gl.blendEquationSeparate( utils.convert( blendEquation ), utils.convert( blendEquationAlpha ) );
currentBlendEquation = blendEquation;
currentBlendEquationAlpha = blendEquationAlpha;
......@@ -19882,7 +19882,7 @@
if ( blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha ) {
gl.blendFuncSeparate( paramThreeToGL( blendSrc ), paramThreeToGL( blendDst ), paramThreeToGL( blendSrcAlpha ), paramThreeToGL( blendDstAlpha ) );
gl.blendFuncSeparate( utils.convert( blendSrc ), utils.convert( blendDst ), utils.convert( blendSrcAlpha ), utils.convert( blendDstAlpha ) );
currentBlendSrc = blendSrc;
currentBlendDst = blendDst;
......@@ -20773,6 +20773,142 @@
}
/**
* @author thespite / http://www.twitter.com/thespite
*/
function WebGLUtils ( gl, extensions ) {
function convert ( p ) {
var extension;
if ( p === RepeatWrapping ) return gl.REPEAT;
if ( p === ClampToEdgeWrapping ) return gl.CLAMP_TO_EDGE;
if ( p === MirroredRepeatWrapping ) return gl.MIRRORED_REPEAT;
if ( p === NearestFilter ) return gl.NEAREST;
if ( p === NearestMipMapNearestFilter ) return gl.NEAREST_MIPMAP_NEAREST;
if ( p === NearestMipMapLinearFilter ) return gl.NEAREST_MIPMAP_LINEAR;
if ( p === LinearFilter ) return gl.LINEAR;
if ( p === LinearMipMapNearestFilter ) return gl.LINEAR_MIPMAP_NEAREST;
if ( p === LinearMipMapLinearFilter ) return gl.LINEAR_MIPMAP_LINEAR;
if ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;
if ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;
if ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;
if ( p === UnsignedShort565Type ) return gl.UNSIGNED_SHORT_5_6_5;
if ( p === ByteType ) return gl.BYTE;
if ( p === ShortType ) return gl.SHORT;
if ( p === UnsignedShortType ) return gl.UNSIGNED_SHORT;
if ( p === IntType ) return gl.INT;
if ( p === UnsignedIntType ) return gl.UNSIGNED_INT;
if ( p === FloatType ) return gl.FLOAT;
if ( p === HalfFloatType ) {
extension = extensions.get( 'OES_texture_half_float' );
if ( extension !== null ) return extension.HALF_FLOAT_OES;
}
if ( p === AlphaFormat ) return gl.ALPHA;
if ( p === RGBFormat ) return gl.RGB;
if ( p === RGBAFormat ) return gl.RGBA;
if ( p === LuminanceFormat ) return gl.LUMINANCE;
if ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;
if ( p === DepthFormat ) return gl.DEPTH_COMPONENT;
if ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;
if ( p === AddEquation ) return gl.FUNC_ADD;
if ( p === SubtractEquation ) return gl.FUNC_SUBTRACT;
if ( p === ReverseSubtractEquation ) return gl.FUNC_REVERSE_SUBTRACT;
if ( p === ZeroFactor ) return gl.ZERO;
if ( p === OneFactor ) return gl.ONE;
if ( p === SrcColorFactor ) return gl.SRC_COLOR;
if ( p === OneMinusSrcColorFactor ) return gl.ONE_MINUS_SRC_COLOR;
if ( p === SrcAlphaFactor ) return gl.SRC_ALPHA;
if ( p === OneMinusSrcAlphaFactor ) return gl.ONE_MINUS_SRC_ALPHA;
if ( p === DstAlphaFactor ) return gl.DST_ALPHA;
if ( p === OneMinusDstAlphaFactor ) return gl.ONE_MINUS_DST_ALPHA;
if ( p === DstColorFactor ) return gl.DST_COLOR;
if ( p === OneMinusDstColorFactor ) return gl.ONE_MINUS_DST_COLOR;
if ( p === SrcAlphaSaturateFactor ) return gl.SRC_ALPHA_SATURATE;
if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format ||
p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
extension = extensions.get( 'WEBGL_compressed_texture_s3tc' );
if ( extension !== null ) {
if ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;
if ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;
if ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;
if ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;
}
}
if ( p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format ||
p === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format ) {
extension = extensions.get( 'WEBGL_compressed_texture_pvrtc' );
if ( extension !== null ) {
if ( p === RGB_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
if ( p === RGB_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
if ( p === RGBA_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
if ( p === RGBA_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
}
}
if ( p === RGB_ETC1_Format ) {
extension = extensions.get( 'WEBGL_compressed_texture_etc1' );
if ( extension !== null ) return extension.COMPRESSED_RGB_ETC1_WEBGL;
}
if ( p === MinEquation || p === MaxEquation ) {
extension = extensions.get( 'EXT_blend_minmax' );
if ( extension !== null ) {
if ( p === MinEquation ) return extension.MIN_EXT;
if ( p === MaxEquation ) return extension.MAX_EXT;
}
}
if ( p === UnsignedInt248Type ) {
extension = extensions.get( 'WEBGL_depth_texture' );
if ( extension !== null ) return extension.UNSIGNED_INT_24_8_WEBGL;
}
return 0;
}
return { convert: convert }
}
// import { Sphere } from '../math/Sphere';
/**
* @author supereggbert / http://www.paulbrunt.co.uk/
......@@ -20989,6 +21125,8 @@
var background, morphtargets, bufferRenderer, indexedBufferRenderer;
var flareRenderer, spriteRenderer;
var utils;
function initGLContext() {
extensions = new WebGLExtensions( _gl );
......@@ -21006,14 +21144,16 @@
}
utils = new WebGLUtils( _gl, extensions );
capabilities = new WebGLCapabilities( _gl, extensions, parameters );
state = new WebGLState( _gl, extensions, paramThreeToGL );
state = new WebGLState( _gl, extensions, utils );
state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ) );
state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ) );
properties = new WebGLProperties();
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, paramThreeToGL, _infoMemory );
textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, _infoMemory );
attributes = new WebGLAttributes( _gl );
geometries = new WebGLGeometries( _gl, attributes, _infoMemory );
objects = new WebGLObjects( geometries, _infoRender );
......@@ -23180,14 +23320,14 @@
var textureFormat = texture.format;
var textureType = texture.type;
if ( textureFormat !== RGBAFormat && paramThreeToGL( textureFormat ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {
if ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {
console.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );
return;
}
if ( textureType !== UnsignedByteType && paramThreeToGL( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // IE11, Edge and Chrome Mac < 52 (#9513)
if ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // IE11, Edge and Chrome Mac < 52 (#9513)
! ( textureType === FloatType && ( extensions.get( 'OES_texture_float' ) || extensions.get( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox
! ( textureType === HalfFloatType && extensions.get( 'EXT_color_buffer_half_float' ) ) ) {
......@@ -23202,7 +23342,7 @@
if ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {
_gl.readPixels( x, y, width, height, paramThreeToGL( textureFormat ), paramThreeToGL( textureType ), buffer );
_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );
}
......@@ -23226,134 +23366,6 @@
};
// Map three.js constants to WebGL constants
function paramThreeToGL( p ) {
var extension;
if ( p === RepeatWrapping ) return _gl.REPEAT;
if ( p === ClampToEdgeWrapping ) return _gl.CLAMP_TO_EDGE;
if ( p === MirroredRepeatWrapping ) return _gl.MIRRORED_REPEAT;
if ( p === NearestFilter ) return _gl.NEAREST;
if ( p === NearestMipMapNearestFilter ) return _gl.NEAREST_MIPMAP_NEAREST;
if ( p === NearestMipMapLinearFilter ) return _gl.NEAREST_MIPMAP_LINEAR;
if ( p === LinearFilter ) return _gl.LINEAR;
if ( p === LinearMipMapNearestFilter ) return _gl.LINEAR_MIPMAP_NEAREST;
if ( p === LinearMipMapLinearFilter ) return _gl.LINEAR_MIPMAP_LINEAR;
if ( p === UnsignedByteType ) return _gl.UNSIGNED_BYTE;
if ( p === UnsignedShort4444Type ) return _gl.UNSIGNED_SHORT_4_4_4_4;
if ( p === UnsignedShort5551Type ) return _gl.UNSIGNED_SHORT_5_5_5_1;
if ( p === UnsignedShort565Type ) return _gl.UNSIGNED_SHORT_5_6_5;
if ( p === ByteType ) return _gl.BYTE;
if ( p === ShortType ) return _gl.SHORT;
if ( p === UnsignedShortType ) return _gl.UNSIGNED_SHORT;
if ( p === IntType ) return _gl.INT;
if ( p === UnsignedIntType ) return _gl.UNSIGNED_INT;
if ( p === FloatType ) return _gl.FLOAT;
if ( p === HalfFloatType ) {
extension = extensions.get( 'OES_texture_half_float' );
if ( extension !== null ) return extension.HALF_FLOAT_OES;
}
if ( p === AlphaFormat ) return _gl.ALPHA;
if ( p === RGBFormat ) return _gl.RGB;
if ( p === RGBAFormat ) return _gl.RGBA;
if ( p === LuminanceFormat ) return _gl.LUMINANCE;
if ( p === LuminanceAlphaFormat ) return _gl.LUMINANCE_ALPHA;
if ( p === DepthFormat ) return _gl.DEPTH_COMPONENT;
if ( p === DepthStencilFormat ) return _gl.DEPTH_STENCIL;
if ( p === AddEquation ) return _gl.FUNC_ADD;
if ( p === SubtractEquation ) return _gl.FUNC_SUBTRACT;
if ( p === ReverseSubtractEquation ) return _gl.FUNC_REVERSE_SUBTRACT;
if ( p === ZeroFactor ) return _gl.ZERO;
if ( p === OneFactor ) return _gl.ONE;
if ( p === SrcColorFactor ) return _gl.SRC_COLOR;
if ( p === OneMinusSrcColorFactor ) return _gl.ONE_MINUS_SRC_COLOR;
if ( p === SrcAlphaFactor ) return _gl.SRC_ALPHA;
if ( p === OneMinusSrcAlphaFactor ) return _gl.ONE_MINUS_SRC_ALPHA;
if ( p === DstAlphaFactor ) return _gl.DST_ALPHA;
if ( p === OneMinusDstAlphaFactor ) return _gl.ONE_MINUS_DST_ALPHA;
if ( p === DstColorFactor ) return _gl.DST_COLOR;
if ( p === OneMinusDstColorFactor ) return _gl.ONE_MINUS_DST_COLOR;
if ( p === SrcAlphaSaturateFactor ) return _gl.SRC_ALPHA_SATURATE;
if ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format ||
p === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {
extension = extensions.get( 'WEBGL_compressed_texture_s3tc' );
if ( extension !== null ) {
if ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;
if ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;
if ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;
if ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;
}
}
if ( p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format ||
p === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format ) {
extension = extensions.get( 'WEBGL_compressed_texture_pvrtc' );
if ( extension !== null ) {
if ( p === RGB_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;
if ( p === RGB_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
if ( p === RGBA_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;
if ( p === RGBA_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;
}
}
if ( p === RGB_ETC1_Format ) {
extension = extensions.get( 'WEBGL_compressed_texture_etc1' );
if ( extension !== null ) return extension.COMPRESSED_RGB_ETC1_WEBGL;
}
if ( p === MinEquation || p === MaxEquation ) {
extension = extensions.get( 'EXT_blend_minmax' );
if ( extension !== null ) {
if ( p === MinEquation ) return extension.MIN_EXT;
if ( p === MaxEquation ) return extension.MAX_EXT;
}
}
if ( p === UnsignedInt248Type ) {
extension = extensions.get( 'WEBGL_depth_texture' );
if ( extension !== null ) return extension.UNSIGNED_INT_24_8_WEBGL;
}
return 0;
}
}
/**
......@@ -32863,7 +32875,7 @@
if ( json.fragmentShader !== undefined ) material.fragmentShader = json.fragmentShader;
if ( json.vertexColors !== undefined ) material.vertexColors = json.vertexColors;
if ( json.fog !== undefined ) material.fog = json.fog;
if ( json.shading !== undefined ) material.shading = json.shading;
if ( json.flatShading !== undefined ) material.flatShading = json.flatShading;
if ( json.blending !== undefined ) material.blending = json.blending;
if ( json.side !== undefined ) material.side = json.side;
if ( json.opacity !== undefined ) material.opacity = json.opacity;
......@@ -32879,6 +32891,10 @@
if ( json.skinning !== undefined ) material.skinning = json.skinning;
if ( json.morphTargets !== undefined ) material.morphTargets = json.morphTargets;
// Deprecated
if ( json.shading !== undefined ) material.shading = json.shading;
// for PointsMaterial
if ( json.size !== undefined ) material.size = json.size;
......@@ -43978,6 +43994,7 @@
exports.Curve = Curve;
exports.ShapeUtils = ShapeUtils;
exports.SceneUtils = SceneUtils;
exports.WebGLUtils = WebGLUtils;
exports.WireframeGeometry = WireframeGeometry;
exports.ParametricGeometry = ParametricGeometry;
exports.ParametricBufferGeometry = ParametricBufferGeometry;
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册