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

Updated builds.

上级 da7b874d
...@@ -6575,7 +6575,7 @@ ...@@ -6575,7 +6575,7 @@
} }
gl.useProgram( program ); state.useProgram( program );
state.initAttributes(); state.initAttributes();
state.enableAttribute( attributes.vertex ); state.enableAttribute( attributes.vertex );
...@@ -6722,7 +6722,7 @@ ...@@ -6722,7 +6722,7 @@
state.enable( gl.DEPTH_TEST ); state.enable( gl.DEPTH_TEST );
state.buffers.depth.setMask( true ); state.buffers.depth.setMask( true );
renderer.resetGLState(); state.reset();
}; };
...@@ -6752,6 +6752,21 @@ ...@@ -6752,6 +6752,21 @@
} }
/**
* @author mrdoob / http://mrdoob.com/
*/
function CanvasTexture( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
Texture.call( this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
this.needsUpdate = true;
}
CanvasTexture.prototype = Object.create( Texture.prototype );
CanvasTexture.prototype.constructor = CanvasTexture;
/** /**
* @author mikael emtinger / http://gomo.se/ * @author mikael emtinger / http://gomo.se/
* @author alteredq / http://alteredqualia.com/ * @author alteredq / http://alteredqualia.com/
...@@ -6834,8 +6849,7 @@ ...@@ -6834,8 +6849,7 @@
context.fillStyle = 'white'; context.fillStyle = 'white';
context.fillRect( 0, 0, 8, 8 ); context.fillRect( 0, 0, 8, 8 );
texture = new Texture( canvas ); texture = new CanvasTexture( canvas );
texture.needsUpdate = true;
} }
...@@ -6851,7 +6865,7 @@ ...@@ -6851,7 +6865,7 @@
} }
gl.useProgram( program ); state.useProgram( program );
state.initAttributes(); state.initAttributes();
state.enableAttribute( attributes.position ); state.enableAttribute( attributes.position );
...@@ -6999,7 +7013,7 @@ ...@@ -6999,7 +7013,7 @@
state.enable( gl.CULL_FACE ); state.enable( gl.CULL_FACE );
renderer.resetGLState(); state.reset();
}; };
...@@ -19131,6 +19145,8 @@ ...@@ -19131,6 +19145,8 @@
var compressedTextureFormats = null; var compressedTextureFormats = null;
var currentProgram = null;
var currentBlending = null; var currentBlending = null;
var currentBlendEquation = null; var currentBlendEquation = null;
var currentBlendSrc = null; var currentBlendSrc = null;
...@@ -19184,25 +19200,23 @@ ...@@ -19184,25 +19200,23 @@
emptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 ); emptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 );
emptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 ); emptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 );
// // init
function init() {
colorBuffer.setClear( 0, 0, 0, 1 ); colorBuffer.setClear( 0, 0, 0, 1 );
depthBuffer.setClear( 1 ); depthBuffer.setClear( 1 );
stencilBuffer.setClear( 0 ); stencilBuffer.setClear( 0 );
enable( gl.DEPTH_TEST ); enable( gl.DEPTH_TEST );
depthBuffer.setFunc( LessEqualDepth ); depthBuffer.setFunc( LessEqualDepth );
setFlipSided( false ); setFlipSided( false );
setCullFace( CullFaceBack ); setCullFace( CullFaceBack );
enable( gl.CULL_FACE ); enable( gl.CULL_FACE );
enable( gl.BLEND ); enable( gl.BLEND );
setBlending( NormalBlending ); setBlending( NormalBlending );
} //
function initAttributes() { function initAttributes() {
...@@ -19321,6 +19335,22 @@ ...@@ -19321,6 +19335,22 @@
} }
function useProgram( program ) {
if ( currentProgram !== program ) {
gl.useProgram( program );
currentProgram = program;
return true;
}
return false;
}
function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) { function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) {
if ( blending !== NoBlending ) { if ( blending !== NoBlending ) {
...@@ -19688,6 +19718,8 @@ ...@@ -19688,6 +19718,8 @@
currentTextureSlot = null; currentTextureSlot = null;
currentBoundTextures = {}; currentBoundTextures = {};
currentProgram = null;
currentBlending = null; currentBlending = null;
currentFlipSided = null; currentFlipSided = null;
...@@ -19707,7 +19739,6 @@ ...@@ -19707,7 +19739,6 @@
stencil: stencilBuffer stencil: stencilBuffer
}, },
init: init,
initAttributes: initAttributes, initAttributes: initAttributes,
enableAttribute: enableAttribute, enableAttribute: enableAttribute,
enableAttributeAndDivisor: enableAttributeAndDivisor, enableAttributeAndDivisor: enableAttributeAndDivisor,
...@@ -19716,6 +19747,8 @@ ...@@ -19716,6 +19747,8 @@
disable: disable, disable: disable,
getCompressedTextureFormats: getCompressedTextureFormats, getCompressedTextureFormats: getCompressedTextureFormats,
useProgram: useProgram,
setBlending: setBlending, setBlending: setBlending,
setMaterial: setMaterial, setMaterial: setMaterial,
...@@ -20377,9 +20410,10 @@ ...@@ -20377,9 +20410,10 @@
var _this = this, var _this = this,
_isContextLost = false,
// internal state cache // internal state cache
_currentProgram = null,
_currentRenderTarget = null, _currentRenderTarget = null,
_currentFramebuffer = null, _currentFramebuffer = null,
_currentMaterialId = - 1, _currentMaterialId = - 1,
...@@ -20520,6 +20554,7 @@ ...@@ -20520,6 +20554,7 @@
} }
_canvas.addEventListener( 'webglcontextlost', onContextLost, false ); _canvas.addEventListener( 'webglcontextlost', onContextLost, false );
_canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );
} catch ( error ) { } catch ( error ) {
...@@ -20527,74 +20562,65 @@ ...@@ -20527,74 +20562,65 @@
} }
var extensions = new WebGLExtensions( _gl ); var extensions, capabilities, state;
var properties, textures, attributes, geometries, objects;
var programCache, lightCache, renderLists;
extensions.get( 'WEBGL_depth_texture' ); var background, bufferRenderer, indexedBufferRenderer;
extensions.get( 'OES_texture_float' );
extensions.get( 'OES_texture_float_linear' );
extensions.get( 'OES_texture_half_float' );
extensions.get( 'OES_texture_half_float_linear' );
extensions.get( 'OES_standard_derivatives' );
extensions.get( 'ANGLE_instanced_arrays' );
if ( extensions.get( 'OES_element_index_uint' ) ) { function initGLContext() {
BufferGeometry.MaxIndex = 4294967296; extensions = new WebGLExtensions( _gl );
extensions.get( 'WEBGL_depth_texture' );
extensions.get( 'OES_texture_float' );
extensions.get( 'OES_texture_float_linear' );
extensions.get( 'OES_texture_half_float' );
extensions.get( 'OES_texture_half_float_linear' );
extensions.get( 'OES_standard_derivatives' );
extensions.get( 'ANGLE_instanced_arrays' );
} if ( extensions.get( 'OES_element_index_uint' ) ) {
var capabilities = new WebGLCapabilities( _gl, extensions, parameters );
var state = new WebGLState( _gl, extensions, paramThreeToGL ); BufferGeometry.MaxIndex = 4294967296;
var properties = new WebGLProperties(); }
var textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, paramThreeToGL, _infoMemory );
var attributes = new WebGLAttributes( _gl );
var geometries = new WebGLGeometries( _gl, attributes, _infoMemory );
var objects = new WebGLObjects( _gl, geometries, _infoRender );
var programCache = new WebGLPrograms( this, capabilities );
var lightCache = new WebGLLights();
var renderLists = new WebGLRenderLists();
var background = new WebGLBackground( this, state, objects, _premultipliedAlpha ); capabilities = new WebGLCapabilities( _gl, extensions, parameters );
var vr = new WebVRManager( this );
this.info.programs = programCache.programs; state = new WebGLState( _gl, extensions, paramThreeToGL );
state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ) );
state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ) );
var bufferRenderer = new WebGLBufferRenderer( _gl, extensions, _infoRender ); properties = new WebGLProperties();
var indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, _infoRender ); textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, paramThreeToGL, _infoMemory );
attributes = new WebGLAttributes( _gl );
geometries = new WebGLGeometries( _gl, attributes, _infoMemory );
objects = new WebGLObjects( _gl, geometries, _infoRender );
programCache = new WebGLPrograms( _this, capabilities );
lightCache = new WebGLLights();
renderLists = new WebGLRenderLists();
// background = new WebGLBackground( _this, state, objects, _premultipliedAlpha );
function getTargetPixelRatio() { bufferRenderer = new WebGLBufferRenderer( _gl, extensions, _infoRender );
indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, _infoRender );
return _currentRenderTarget === null ? _pixelRatio : 1; _this.info.programs = programCache.programs;
} }
function setDefaultGLState() { initGLContext();
state.init();
state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ) );
state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ) );
}
function resetGLState() { var vr = new WebVRManager( _this );
_currentProgram = null; //
_currentCamera = null;
_currentGeometryProgram = ''; function getTargetPixelRatio() {
_currentMaterialId = - 1;
state.reset(); return _currentRenderTarget === null ? _pixelRatio : 1;
} }
setDefaultGLState();
this.context = _gl; this.context = _gl;
this.capabilities = capabilities; this.capabilities = capabilities;
this.extensions = extensions; this.extensions = extensions;
...@@ -20636,6 +20662,13 @@ ...@@ -20636,6 +20662,13 @@
}; };
this.forceContextRestore = function () {
var extension = extensions.get( 'WEBGL_lose_context' );
if ( extension ) extension.restoreContext();
};
this.getMaxAnisotropy = function () { this.getMaxAnisotropy = function () {
return capabilities.getMaxAnisotropy(); return capabilities.getMaxAnisotropy();
...@@ -20788,13 +20821,12 @@ ...@@ -20788,13 +20821,12 @@
}; };
// Reset //
this.resetGLState = resetGLState;
this.dispose = function () { this.dispose = function () {
_canvas.removeEventListener( 'webglcontextlost', onContextLost, false ); _canvas.removeEventListener( 'webglcontextlost', onContextLost, false );
_canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false );
renderLists.dispose(); renderLists.dispose();
...@@ -20806,11 +20838,15 @@ ...@@ -20806,11 +20838,15 @@
event.preventDefault(); event.preventDefault();
resetGLState(); _isContextLost = true;
setDefaultGLState();
}
function onContextRestore( event ) {
initGLContext();
properties.clear(); _isContextLost = false;
objects.clear();
} }
...@@ -21369,6 +21405,8 @@ ...@@ -21369,6 +21405,8 @@
} }
if ( _isContextLost ) return;
// reset caching for this frame // reset caching for this frame
_currentGeometryProgram = ''; _currentGeometryProgram = '';
...@@ -21943,10 +21981,7 @@ ...@@ -21943,10 +21981,7 @@
p_uniforms = program.getUniforms(), p_uniforms = program.getUniforms(),
m_uniforms = materialProperties.shader.uniforms; m_uniforms = materialProperties.shader.uniforms;
if ( program.id !== _currentProgram ) { if ( state.useProgram( program.program ) ) {
_gl.useProgram( program.program );
_currentProgram = program.id;
refreshProgram = true; refreshProgram = true;
refreshMaterial = true; refreshMaterial = true;
...@@ -24535,21 +24570,6 @@ ...@@ -24535,21 +24570,6 @@
CompressedTexture.prototype.isCompressedTexture = true; CompressedTexture.prototype.isCompressedTexture = true;
/**
* @author mrdoob / http://mrdoob.com/
*/
function CanvasTexture( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
Texture.call( this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
this.needsUpdate = true;
}
CanvasTexture.prototype = Object.create( Texture.prototype );
CanvasTexture.prototype.constructor = CanvasTexture;
/** /**
* @author Matt DesLauriers / @mattdesl * @author Matt DesLauriers / @mattdesl
* @author atix / arthursilber.de * @author atix / arthursilber.de
...@@ -40837,7 +40857,7 @@ ...@@ -40837,7 +40857,7 @@
geometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); geometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
var material = new LineBasicMaterial( { fog: false, color: this.color } ); var material = new LineBasicMaterial( { fog: false } );
this.cone = new LineSegments( geometry, material ); this.cone = new LineSegments( geometry, material );
this.add( this.cone ); this.add( this.cone );
...@@ -41019,7 +41039,7 @@ ...@@ -41019,7 +41039,7 @@
this.color = color; this.color = color;
var geometry = new SphereBufferGeometry( sphereSize, 4, 2 ); var geometry = new SphereBufferGeometry( sphereSize, 4, 2 );
var material = new MeshBasicMaterial( { wireframe: true, fog: false, color: this.color } ); var material = new MeshBasicMaterial( { wireframe: true, fog: false } );
Mesh.call( this, geometry, material ); Mesh.call( this, geometry, material );
...@@ -41110,7 +41130,7 @@ ...@@ -41110,7 +41130,7 @@
this.color = color; this.color = color;
var material = new LineBasicMaterial( { fog: false, color: this.color } ); var material = new LineBasicMaterial( { fog: false } );
var geometry = new BufferGeometry(); var geometry = new BufferGeometry();
...@@ -41187,7 +41207,7 @@ ...@@ -41187,7 +41207,7 @@
var geometry = new OctahedronBufferGeometry( size ); var geometry = new OctahedronBufferGeometry( size );
geometry.rotateY( Math.PI * 0.5 ); geometry.rotateY( Math.PI * 0.5 );
this.material = new MeshBasicMaterial( { wireframe: true, fog: false, color: this.color } ); this.material = new MeshBasicMaterial( { wireframe: true, fog: false } );
if ( this.color === undefined ) this.material.vertexColors = VertexColors; if ( this.color === undefined ) this.material.vertexColors = VertexColors;
var position = geometry.getAttribute( 'position' ); var position = geometry.getAttribute( 'position' );
...@@ -41520,7 +41540,7 @@ ...@@ -41520,7 +41540,7 @@
- size, size, 0 - size, size, 0
], 3 ) ); ], 3 ) );
var material = new LineBasicMaterial( { fog: false, color: this.color } ); var material = new LineBasicMaterial( { fog: false } );
this.lightPlane = new Line( geometry, material ); this.lightPlane = new Line( geometry, material );
this.add( this.lightPlane ); this.add( this.lightPlane );
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
...@@ -6569,7 +6569,7 @@ function LensFlarePlugin( renderer, flares ) { ...@@ -6569,7 +6569,7 @@ function LensFlarePlugin( renderer, flares ) {
} }
gl.useProgram( program ); state.useProgram( program );
state.initAttributes(); state.initAttributes();
state.enableAttribute( attributes.vertex ); state.enableAttribute( attributes.vertex );
...@@ -6716,7 +6716,7 @@ function LensFlarePlugin( renderer, flares ) { ...@@ -6716,7 +6716,7 @@ function LensFlarePlugin( renderer, flares ) {
state.enable( gl.DEPTH_TEST ); state.enable( gl.DEPTH_TEST );
state.buffers.depth.setMask( true ); state.buffers.depth.setMask( true );
renderer.resetGLState(); state.reset();
}; };
...@@ -6746,6 +6746,21 @@ function LensFlarePlugin( renderer, flares ) { ...@@ -6746,6 +6746,21 @@ function LensFlarePlugin( renderer, flares ) {
} }
/**
* @author mrdoob / http://mrdoob.com/
*/
function CanvasTexture( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
Texture.call( this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
this.needsUpdate = true;
}
CanvasTexture.prototype = Object.create( Texture.prototype );
CanvasTexture.prototype.constructor = CanvasTexture;
/** /**
* @author mikael emtinger / http://gomo.se/ * @author mikael emtinger / http://gomo.se/
* @author alteredq / http://alteredqualia.com/ * @author alteredq / http://alteredqualia.com/
...@@ -6828,8 +6843,7 @@ function SpritePlugin( renderer, sprites ) { ...@@ -6828,8 +6843,7 @@ function SpritePlugin( renderer, sprites ) {
context.fillStyle = 'white'; context.fillStyle = 'white';
context.fillRect( 0, 0, 8, 8 ); context.fillRect( 0, 0, 8, 8 );
texture = new Texture( canvas ); texture = new CanvasTexture( canvas );
texture.needsUpdate = true;
} }
...@@ -6845,7 +6859,7 @@ function SpritePlugin( renderer, sprites ) { ...@@ -6845,7 +6859,7 @@ function SpritePlugin( renderer, sprites ) {
} }
gl.useProgram( program ); state.useProgram( program );
state.initAttributes(); state.initAttributes();
state.enableAttribute( attributes.position ); state.enableAttribute( attributes.position );
...@@ -6993,7 +7007,7 @@ function SpritePlugin( renderer, sprites ) { ...@@ -6993,7 +7007,7 @@ function SpritePlugin( renderer, sprites ) {
state.enable( gl.CULL_FACE ); state.enable( gl.CULL_FACE );
renderer.resetGLState(); state.reset();
}; };
...@@ -19125,6 +19139,8 @@ function WebGLState( gl, extensions, paramThreeToGL ) { ...@@ -19125,6 +19139,8 @@ function WebGLState( gl, extensions, paramThreeToGL ) {
var compressedTextureFormats = null; var compressedTextureFormats = null;
var currentProgram = null;
var currentBlending = null; var currentBlending = null;
var currentBlendEquation = null; var currentBlendEquation = null;
var currentBlendSrc = null; var currentBlendSrc = null;
...@@ -19178,25 +19194,23 @@ function WebGLState( gl, extensions, paramThreeToGL ) { ...@@ -19178,25 +19194,23 @@ function WebGLState( gl, extensions, paramThreeToGL ) {
emptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 ); emptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 );
emptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 ); emptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 );
// // init
function init() {
colorBuffer.setClear( 0, 0, 0, 1 ); colorBuffer.setClear( 0, 0, 0, 1 );
depthBuffer.setClear( 1 ); depthBuffer.setClear( 1 );
stencilBuffer.setClear( 0 ); stencilBuffer.setClear( 0 );
enable( gl.DEPTH_TEST ); enable( gl.DEPTH_TEST );
depthBuffer.setFunc( LessEqualDepth ); depthBuffer.setFunc( LessEqualDepth );
setFlipSided( false ); setFlipSided( false );
setCullFace( CullFaceBack ); setCullFace( CullFaceBack );
enable( gl.CULL_FACE ); enable( gl.CULL_FACE );
enable( gl.BLEND ); enable( gl.BLEND );
setBlending( NormalBlending ); setBlending( NormalBlending );
} //
function initAttributes() { function initAttributes() {
...@@ -19315,6 +19329,22 @@ function WebGLState( gl, extensions, paramThreeToGL ) { ...@@ -19315,6 +19329,22 @@ function WebGLState( gl, extensions, paramThreeToGL ) {
} }
function useProgram( program ) {
if ( currentProgram !== program ) {
gl.useProgram( program );
currentProgram = program;
return true;
}
return false;
}
function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) { function setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) {
if ( blending !== NoBlending ) { if ( blending !== NoBlending ) {
...@@ -19682,6 +19712,8 @@ function WebGLState( gl, extensions, paramThreeToGL ) { ...@@ -19682,6 +19712,8 @@ function WebGLState( gl, extensions, paramThreeToGL ) {
currentTextureSlot = null; currentTextureSlot = null;
currentBoundTextures = {}; currentBoundTextures = {};
currentProgram = null;
currentBlending = null; currentBlending = null;
currentFlipSided = null; currentFlipSided = null;
...@@ -19701,7 +19733,6 @@ function WebGLState( gl, extensions, paramThreeToGL ) { ...@@ -19701,7 +19733,6 @@ function WebGLState( gl, extensions, paramThreeToGL ) {
stencil: stencilBuffer stencil: stencilBuffer
}, },
init: init,
initAttributes: initAttributes, initAttributes: initAttributes,
enableAttribute: enableAttribute, enableAttribute: enableAttribute,
enableAttributeAndDivisor: enableAttributeAndDivisor, enableAttributeAndDivisor: enableAttributeAndDivisor,
...@@ -19710,6 +19741,8 @@ function WebGLState( gl, extensions, paramThreeToGL ) { ...@@ -19710,6 +19741,8 @@ function WebGLState( gl, extensions, paramThreeToGL ) {
disable: disable, disable: disable,
getCompressedTextureFormats: getCompressedTextureFormats, getCompressedTextureFormats: getCompressedTextureFormats,
useProgram: useProgram,
setBlending: setBlending, setBlending: setBlending,
setMaterial: setMaterial, setMaterial: setMaterial,
...@@ -20371,9 +20404,10 @@ function WebGLRenderer( parameters ) { ...@@ -20371,9 +20404,10 @@ function WebGLRenderer( parameters ) {
var _this = this, var _this = this,
_isContextLost = false,
// internal state cache // internal state cache
_currentProgram = null,
_currentRenderTarget = null, _currentRenderTarget = null,
_currentFramebuffer = null, _currentFramebuffer = null,
_currentMaterialId = - 1, _currentMaterialId = - 1,
...@@ -20514,6 +20548,7 @@ function WebGLRenderer( parameters ) { ...@@ -20514,6 +20548,7 @@ function WebGLRenderer( parameters ) {
} }
_canvas.addEventListener( 'webglcontextlost', onContextLost, false ); _canvas.addEventListener( 'webglcontextlost', onContextLost, false );
_canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );
} catch ( error ) { } catch ( error ) {
...@@ -20521,74 +20556,65 @@ function WebGLRenderer( parameters ) { ...@@ -20521,74 +20556,65 @@ function WebGLRenderer( parameters ) {
} }
var extensions = new WebGLExtensions( _gl ); var extensions, capabilities, state;
var properties, textures, attributes, geometries, objects;
var programCache, lightCache, renderLists;
extensions.get( 'WEBGL_depth_texture' ); var background, bufferRenderer, indexedBufferRenderer;
extensions.get( 'OES_texture_float' );
extensions.get( 'OES_texture_float_linear' );
extensions.get( 'OES_texture_half_float' );
extensions.get( 'OES_texture_half_float_linear' );
extensions.get( 'OES_standard_derivatives' );
extensions.get( 'ANGLE_instanced_arrays' );
if ( extensions.get( 'OES_element_index_uint' ) ) { function initGLContext() {
BufferGeometry.MaxIndex = 4294967296; extensions = new WebGLExtensions( _gl );
extensions.get( 'WEBGL_depth_texture' );
extensions.get( 'OES_texture_float' );
extensions.get( 'OES_texture_float_linear' );
extensions.get( 'OES_texture_half_float' );
extensions.get( 'OES_texture_half_float_linear' );
extensions.get( 'OES_standard_derivatives' );
extensions.get( 'ANGLE_instanced_arrays' );
} if ( extensions.get( 'OES_element_index_uint' ) ) {
var capabilities = new WebGLCapabilities( _gl, extensions, parameters );
var state = new WebGLState( _gl, extensions, paramThreeToGL ); BufferGeometry.MaxIndex = 4294967296;
var properties = new WebGLProperties(); }
var textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, paramThreeToGL, _infoMemory );
var attributes = new WebGLAttributes( _gl );
var geometries = new WebGLGeometries( _gl, attributes, _infoMemory );
var objects = new WebGLObjects( _gl, geometries, _infoRender );
var programCache = new WebGLPrograms( this, capabilities );
var lightCache = new WebGLLights();
var renderLists = new WebGLRenderLists();
var background = new WebGLBackground( this, state, objects, _premultipliedAlpha ); capabilities = new WebGLCapabilities( _gl, extensions, parameters );
var vr = new WebVRManager( this );
this.info.programs = programCache.programs; state = new WebGLState( _gl, extensions, paramThreeToGL );
state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ) );
state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ) );
var bufferRenderer = new WebGLBufferRenderer( _gl, extensions, _infoRender ); properties = new WebGLProperties();
var indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, _infoRender ); textures = new WebGLTextures( _gl, extensions, state, properties, capabilities, paramThreeToGL, _infoMemory );
attributes = new WebGLAttributes( _gl );
geometries = new WebGLGeometries( _gl, attributes, _infoMemory );
objects = new WebGLObjects( _gl, geometries, _infoRender );
programCache = new WebGLPrograms( _this, capabilities );
lightCache = new WebGLLights();
renderLists = new WebGLRenderLists();
// background = new WebGLBackground( _this, state, objects, _premultipliedAlpha );
function getTargetPixelRatio() { bufferRenderer = new WebGLBufferRenderer( _gl, extensions, _infoRender );
indexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, _infoRender );
return _currentRenderTarget === null ? _pixelRatio : 1; _this.info.programs = programCache.programs;
} }
function setDefaultGLState() { initGLContext();
state.init();
state.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ) );
state.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ) );
}
function resetGLState() { var vr = new WebVRManager( _this );
_currentProgram = null; //
_currentCamera = null;
_currentGeometryProgram = ''; function getTargetPixelRatio() {
_currentMaterialId = - 1;
state.reset(); return _currentRenderTarget === null ? _pixelRatio : 1;
} }
setDefaultGLState();
this.context = _gl; this.context = _gl;
this.capabilities = capabilities; this.capabilities = capabilities;
this.extensions = extensions; this.extensions = extensions;
...@@ -20630,6 +20656,13 @@ function WebGLRenderer( parameters ) { ...@@ -20630,6 +20656,13 @@ function WebGLRenderer( parameters ) {
}; };
this.forceContextRestore = function () {
var extension = extensions.get( 'WEBGL_lose_context' );
if ( extension ) extension.restoreContext();
};
this.getMaxAnisotropy = function () { this.getMaxAnisotropy = function () {
return capabilities.getMaxAnisotropy(); return capabilities.getMaxAnisotropy();
...@@ -20782,13 +20815,12 @@ function WebGLRenderer( parameters ) { ...@@ -20782,13 +20815,12 @@ function WebGLRenderer( parameters ) {
}; };
// Reset //
this.resetGLState = resetGLState;
this.dispose = function () { this.dispose = function () {
_canvas.removeEventListener( 'webglcontextlost', onContextLost, false ); _canvas.removeEventListener( 'webglcontextlost', onContextLost, false );
_canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false );
renderLists.dispose(); renderLists.dispose();
...@@ -20800,11 +20832,15 @@ function WebGLRenderer( parameters ) { ...@@ -20800,11 +20832,15 @@ function WebGLRenderer( parameters ) {
event.preventDefault(); event.preventDefault();
resetGLState(); _isContextLost = true;
setDefaultGLState();
}
function onContextRestore( event ) {
initGLContext();
properties.clear(); _isContextLost = false;
objects.clear();
} }
...@@ -21363,6 +21399,8 @@ function WebGLRenderer( parameters ) { ...@@ -21363,6 +21399,8 @@ function WebGLRenderer( parameters ) {
} }
if ( _isContextLost ) return;
// reset caching for this frame // reset caching for this frame
_currentGeometryProgram = ''; _currentGeometryProgram = '';
...@@ -21937,10 +21975,7 @@ function WebGLRenderer( parameters ) { ...@@ -21937,10 +21975,7 @@ function WebGLRenderer( parameters ) {
p_uniforms = program.getUniforms(), p_uniforms = program.getUniforms(),
m_uniforms = materialProperties.shader.uniforms; m_uniforms = materialProperties.shader.uniforms;
if ( program.id !== _currentProgram ) { if ( state.useProgram( program.program ) ) {
_gl.useProgram( program.program );
_currentProgram = program.id;
refreshProgram = true; refreshProgram = true;
refreshMaterial = true; refreshMaterial = true;
...@@ -24529,21 +24564,6 @@ CompressedTexture.prototype.constructor = CompressedTexture; ...@@ -24529,21 +24564,6 @@ CompressedTexture.prototype.constructor = CompressedTexture;
CompressedTexture.prototype.isCompressedTexture = true; CompressedTexture.prototype.isCompressedTexture = true;
/**
* @author mrdoob / http://mrdoob.com/
*/
function CanvasTexture( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {
Texture.call( this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );
this.needsUpdate = true;
}
CanvasTexture.prototype = Object.create( Texture.prototype );
CanvasTexture.prototype.constructor = CanvasTexture;
/** /**
* @author Matt DesLauriers / @mattdesl * @author Matt DesLauriers / @mattdesl
* @author atix / arthursilber.de * @author atix / arthursilber.de
...@@ -40831,7 +40851,7 @@ function SpotLightHelper( light, color ) { ...@@ -40831,7 +40851,7 @@ function SpotLightHelper( light, color ) {
geometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); geometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
var material = new LineBasicMaterial( { fog: false, color: this.color } ); var material = new LineBasicMaterial( { fog: false } );
this.cone = new LineSegments( geometry, material ); this.cone = new LineSegments( geometry, material );
this.add( this.cone ); this.add( this.cone );
...@@ -41013,7 +41033,7 @@ function PointLightHelper( light, sphereSize, color ) { ...@@ -41013,7 +41033,7 @@ function PointLightHelper( light, sphereSize, color ) {
this.color = color; this.color = color;
var geometry = new SphereBufferGeometry( sphereSize, 4, 2 ); var geometry = new SphereBufferGeometry( sphereSize, 4, 2 );
var material = new MeshBasicMaterial( { wireframe: true, fog: false, color: this.color } ); var material = new MeshBasicMaterial( { wireframe: true, fog: false } );
Mesh.call( this, geometry, material ); Mesh.call( this, geometry, material );
...@@ -41104,7 +41124,7 @@ function RectAreaLightHelper( light, color ) { ...@@ -41104,7 +41124,7 @@ function RectAreaLightHelper( light, color ) {
this.color = color; this.color = color;
var material = new LineBasicMaterial( { fog: false, color: this.color } ); var material = new LineBasicMaterial( { fog: false } );
var geometry = new BufferGeometry(); var geometry = new BufferGeometry();
...@@ -41181,7 +41201,7 @@ function HemisphereLightHelper( light, size, color ) { ...@@ -41181,7 +41201,7 @@ function HemisphereLightHelper( light, size, color ) {
var geometry = new OctahedronBufferGeometry( size ); var geometry = new OctahedronBufferGeometry( size );
geometry.rotateY( Math.PI * 0.5 ); geometry.rotateY( Math.PI * 0.5 );
this.material = new MeshBasicMaterial( { wireframe: true, fog: false, color: this.color } ); this.material = new MeshBasicMaterial( { wireframe: true, fog: false } );
if ( this.color === undefined ) this.material.vertexColors = VertexColors; if ( this.color === undefined ) this.material.vertexColors = VertexColors;
var position = geometry.getAttribute( 'position' ); var position = geometry.getAttribute( 'position' );
...@@ -41514,7 +41534,7 @@ function DirectionalLightHelper( light, size, color ) { ...@@ -41514,7 +41534,7 @@ function DirectionalLightHelper( light, size, color ) {
- size, size, 0 - size, size, 0
], 3 ) ); ], 3 ) );
var material = new LineBasicMaterial( { fog: false, color: this.color } ); var material = new LineBasicMaterial( { fog: false } );
this.lightPlane = new Line( geometry, material ); this.lightPlane = new Line( geometry, material );
this.add( this.lightPlane ); this.add( this.lightPlane );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册