瀏覽代碼

Add viewOffset.enabled flag

WestLangley 7 年之前
父節點
當前提交
20b800c303
共有 2 個文件被更改,包括 18 次插入4 次删除
  1. 9 2
      src/cameras/OrthographicCamera.js
  2. 9 2
      src/cameras/PerspectiveCamera.js

+ 9 - 2
src/cameras/OrthographicCamera.js

@@ -56,6 +56,7 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 		if ( this.view === null ) {
 
 			this.view = {
+				enabled: true,
 				fullWidth: 1,
 				fullHeight: 1,
 				offsetX: 0,
@@ -66,6 +67,7 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 
 		}
 
+		this.view.enabled = true;
 		this.view.fullWidth = fullWidth;
 		this.view.fullHeight = fullHeight;
 		this.view.offsetX = x;
@@ -79,7 +81,12 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 
 	clearViewOffset: function () {
 
-		this.view = null;
+		if ( this.view !== null ) {
+
+			this.view.enabled = false;
+
+		}
+
 		this.updateProjectionMatrix();
 
 	},
@@ -96,7 +103,7 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 		var top = cy + dy;
 		var bottom = cy - dy;
 
-		if ( this.view !== null ) {
+		if ( this.view !== null && this.view.enabled ) {
 
 			var zoomW = this.zoom / ( this.view.width / this.view.fullWidth );
 			var zoomH = this.zoom / ( this.view.height / this.view.fullHeight );

+ 9 - 2
src/cameras/PerspectiveCamera.js

@@ -151,6 +151,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 		if ( this.view === null ) {
 
 			this.view = {
+				enabled: true,
 				fullWidth: 1,
 				fullHeight: 1,
 				offsetX: 0,
@@ -161,6 +162,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 
 		}
 
+		this.view.enabled = true;
 		this.view.fullWidth = fullWidth;
 		this.view.fullHeight = fullHeight;
 		this.view.offsetX = x;
@@ -174,7 +176,12 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 
 	clearViewOffset: function () {
 
-		this.view = null;
+		if ( this.view !== null ) {
+
+			this.view.enabled = false;
+
+		}
+
 		this.updateProjectionMatrix();
 
 	},
@@ -189,7 +196,7 @@ PerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ),
 			left = - 0.5 * width,
 			view = this.view;
 
-		if ( view !== null ) {
+		if ( this.view !== null && this.view.enabled ) {
 
 			var fullWidth = view.fullWidth,
 				fullHeight = view.fullHeight;