浏览代码

WebGLShadowMap context lost support.

Mr.doob 8 年之前
父节点
当前提交
f6392b404c
共有 1 个文件被更改,包括 5 次插入3 次删除
  1. 5 3
      src/renderers/webgl/WebGLShadowMap.js

+ 5 - 3
src/renderers/webgl/WebGLShadowMap.js

@@ -18,9 +18,7 @@ import { Frustum } from '../../math/Frustum';
 
 
 function WebGLShadowMap( _renderer, _objects, maxTextureSize ) {
 function WebGLShadowMap( _renderer, _objects, maxTextureSize ) {
 
 
-	var _gl = _renderer.context,
-		_state = _renderer.state,
-		_frustum = new Frustum(),
+	var _frustum = new Frustum(),
 		_projScreenMatrix = new Matrix4(),
 		_projScreenMatrix = new Matrix4(),
 
 
 		_shadowMapSize = new Vector2(),
 		_shadowMapSize = new Vector2(),
@@ -106,6 +104,10 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) {
 
 
 		if ( lights.length === 0 ) return;
 		if ( lights.length === 0 ) return;
 
 
+		// TODO Clean up (needed in case of contextlost)
+		var _gl = _renderer.context;
+		var _state = _renderer.state;
+
 		// Set GL state for depth map.
 		// Set GL state for depth map.
 		_state.disable( _gl.BLEND );
 		_state.disable( _gl.BLEND );
 		_state.buffers.color.setClear( 1, 1, 1, 1 );
 		_state.buffers.color.setClear( 1, 1, 1, 1 );