Browse Source

Rectangle: Added copy().

Mr.doob 9 years ago
parent
commit
5e2ee5c6ec

+ 4 - 2
examples/js/postprocessing/EffectComposer.js

@@ -112,8 +112,10 @@ THREE.EffectComposer.prototype = {
 
 			var pixelRatio = this.renderer.getPixelRatio();
 
-			renderTarget.width  = Math.floor( this.renderer.context.canvas.width  / pixelRatio );
-			renderTarget.height = Math.floor( this.renderer.context.canvas.height / pixelRatio );
+			renderTarget.setSize(
+				Math.floor( this.renderer.context.canvas.width  / pixelRatio ),
+				Math.floor( this.renderer.context.canvas.height / pixelRatio )
+			);
 
 		}
 

+ 11 - 0
src/math/Rectangle.js

@@ -21,6 +21,17 @@ THREE.Rectangle.prototype = {
 
 		return this;
 
+	},
+
+	copy: function ( source ) {
+
+		this.x = source.x;
+		this.y = source.y;
+		this.width = source.width;
+		this.height = source.height;
+
+		return this;
+
 	}
 
 };

+ 4 - 2
src/renderers/WebGLRenderTarget.js

@@ -40,12 +40,12 @@ THREE.WebGLRenderTarget.prototype = {
 			this.width = width;
 			this.height = height;
 
-			this.viewport.set( 0, 0, width, height );
-
 			this.dispose();
 
 		}
 
+		this.viewport.set( 0, 0, width, height );
+
 	},
 
 	setViewport: function ( x, y, width, height ) {
@@ -65,6 +65,8 @@ THREE.WebGLRenderTarget.prototype = {
 		this.width = source.width;
 		this.height = source.height;
 
+		this.viewport.copy( source.viewport );
+
 		this.texture = source.texture.clone();
 
 		this.depthBuffer = source.depthBuffer;