Browse Source

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 years ago
parent
commit
64c1c09101
1 changed files with 10 additions and 2 deletions
  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;
+
 	}
 
 };