Browse Source

Merge pull request #12158 from WestLangley/dev-view_offset

Cameras: update setViewOffset()
Mr.doob 7 years ago
parent
commit
733be119b0
2 changed files with 36 additions and 14 deletions
  1. 18 7
      src/cameras/OrthographicCamera.js
  2. 18 7
      src/cameras/PerspectiveCamera.js

+ 18 - 7
src/cameras/OrthographicCamera.js

@@ -53,15 +53,26 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 
 	setViewOffset: function ( fullWidth, fullHeight, x, y, width, height ) {
 
-		this.view = {
-			fullWidth: fullWidth,
-			fullHeight: fullHeight,
-			offsetX: x,
-			offsetY: y,
-			width: width,
-			height: height
+		if ( this.view === null ) {
+
+			this.view = {
+				fullWidth: 1,
+				fullHeight: 1,
+				offsetX: 0,
+				offsetY: 0,
+				width: 1,
+				height: 1
+			};
+
 		};
 
+		this.view.fullWidth = fullWidth;
+		this.view.fullHeight = fullHeight;
+		this.view.offsetX = x;
+		this.view.offsetY = y;
+		this.view.width = width;
+		this.view.height = height;
+
 		this.updateProjectionMatrix();
 
 	},

+ 18 - 7
src/cameras/PerspectiveCamera.js

@@ -148,15 +148,26 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 
 		this.aspect = fullWidth / fullHeight;
 
-		this.view = {
-			fullWidth: fullWidth,
-			fullHeight: fullHeight,
-			offsetX: x,
-			offsetY: y,
-			width: width,
-			height: height
+		if ( this.view === null ) {
+
+			this.view = {
+				fullWidth: 1,
+				fullHeight: 1,
+				offsetX: 0,
+				offsetY: 0,
+				width: 1,
+				height: 1
+			};
+
 		};
 
+		this.view.fullWidth = fullWidth;
+		this.view.fullHeight = fullHeight;
+		this.view.offsetX = x;
+		this.view.offsetY = y;
+		this.view.width = width;
+		this.view.height = height;
+
 		this.updateProjectionMatrix();
 
 	},