Skip to content

Commit

Permalink
Set camera frustum to include entire scene
Browse files Browse the repository at this point in the history
  • Loading branch information
alja authored and linev committed Apr 23, 2020
1 parent 906484d commit f2ac498
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions ui5/eve7/lib/GlViewerThree.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,10 @@ sap.ui.define([
lc[1].position.set(-extR, extR, extR);
lc[2].position.set( extR, extR, extR);

let s = 1.02;
if (this.camera.isPerspectiveCamera)
{
let posC = new THREE.Vector3(-0.7 * extR, 0.5 * extR, -0.7 * extR);
let posC = new THREE.Vector3(-s * extR, s * extR, -s * extR);

this.camera.position.copy(posC);

Expand All @@ -307,9 +308,23 @@ sap.ui.define([
let posC = new THREE.Vector3(0, 0, 1000);

this.camera.position.copy(posC);
let ex, ey;
if (extV.x > extV.y)
{
ex = extV.x;
ey = ex / this.get_width() * this.get_height();
if (ey < extV.y)
s *= extV.y/ey;
}
else {
ey = extV.y;
ex = ey / this.get_height() * this.get_width();
if (ex < extV.x)
s *= extV.x/ex;
}

let ey = 1.02 * extV.y;
let ex = ey / this.get_height() * this.get_width();
ex *= s;
ey *= s;
this.camera.left = -ex;
this.camera.right = ex;
this.camera.top = ey;
Expand Down

0 comments on commit f2ac498

Please sign in to comment.