浏览代码

fix Mirror.js

1.  It wasn't setting filtering and was getting errors

2.  It was trying to render itself to the mirror and getting errors
Gregg Tavares 10 年之前
父节点
当前提交
64c1c09101
共有 1 个文件被更改,包括 10 次插入2 次删除
  1. 10 2
      examples/js/Mirror.js

+ 10 - 2
examples/js/Mirror.js

@@ -112,8 +112,10 @@ THREE.Mirror = function ( renderer, camera, options ) {
 	this.mirrorCamera = this.camera.clone();
 	this.mirrorCamera.matrixAutoUpdate = true;
 
-	this.texture = new THREE.WebGLRenderTarget( width, height );
-	this.tempTexture = new THREE.WebGLRenderTarget( width, height );
+	var parameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBuffer: false };
+
+	this.texture = new THREE.WebGLRenderTarget( width, height, parameters );
+	this.tempTexture = new THREE.WebGLRenderTarget( width, height, parameters );
 
 	var mirrorShader = THREE.ShaderLib[ "mirror" ];
 	var mirrorUniforms = THREE.UniformsUtils.clone( mirrorShader.uniforms );
@@ -262,8 +264,14 @@ THREE.Mirror.prototype.render = function () {
 
 	if ( scene !== undefined && scene instanceof THREE.Scene) {
 
+		// We can't render ourself to ourself
+		var visible = this.material.visible;
+		this.material.visible = false;
+
 		this.renderer.render( scene, this.mirrorCamera, this.texture, true );
 
+		this.material.visible = visible;
+
 	}
 
 };