Sfoglia il codice sorgente

Fixed OrthographicCamera zoom. See #5364.

Mr.doob 11 anni fa
parent
commit
fb07c9bc19
1 ha cambiato i file con 6 aggiunte e 1 eliminazioni
  1. 6 1
      src/cameras/OrthographicCamera.js

+ 6 - 1
src/cameras/OrthographicCamera.js

@@ -26,7 +26,12 @@ THREE.OrthographicCamera.prototype = Object.create( THREE.Camera.prototype );
 
 THREE.OrthographicCamera.prototype.updateProjectionMatrix = function () {
 
-	this.projectionMatrix.makeOrthographic( this.left / this.zoom, this.right / this.zoom, this.top / this.zoom, this.bottom / this.zoom, this.near, this.far );
+	var dx = ( this.right - this.left ) / ( 2 * this.zoom );
+	var dy = ( this.top - this.bottom ) / ( 2 * this.zoom );
+	var cx = ( this.right + this.left ) / 2;
+	var cy = ( this.top + this.bottom ) / 2;
+
+	this.projectionMatrix.makeOrthographic( cx - dx, cx + dx, cy + dy, cy - dy, this.near, this.far );
 
 };