Skip to content

Commit

Permalink
Fix scale calculation about view offset in OrthographicCamera
Browse files Browse the repository at this point in the history
In scaleW / zoomW, there are (this.view.width) in the numerator and denominator
  • Loading branch information
miyamonz committed Jan 4, 2020
1 parent c898be2 commit 5061ef6
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/cameras/OrthographicCamera.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,13 @@ OrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ),

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 );
var scaleW = ( this.right - this.left ) / this.view.width;
var scaleH = ( this.top - this.bottom ) / this.view.height;

left += scaleW * ( this.view.offsetX / zoomW );
right = left + scaleW * ( this.view.width / zoomW );
top -= scaleH * ( this.view.offsetY / zoomH );
bottom = top - scaleH * ( this.view.height / zoomH );
var scaleW = ( this.right - this.left ) / this.view.fullWidth / this.zoom;
var scaleH = ( this.top - this.bottom ) / this.view.fullHeight / this.zoom;

left += scaleW * this.view.offsetX;
right = left + scaleW * this.view.width;
top -= scaleH * this.view.offsetY;
bottom = top - scaleH * this.view.height;

}

Expand Down

0 comments on commit 5061ef6

Please sign in to comment.