Skip to content

Commit

Permalink
Merge pull request #84 from lauripiispanen/master
Browse files Browse the repository at this point in the history
fix projection issue on globe resize (re: #72)
  • Loading branch information
bwlewis authored Jan 23, 2019
2 parents 84e42da + 7828942 commit 6168c5f
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions inst/htmlwidgets/globe.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,9 @@ HTMLWidgets.widget(

resize: function(el, width, height, stuff)
{
stuff.renderer.clear();
stuff.camera.aspect = width / height;
stuff.camera.updateProjectionMatrix();
stuff.renderer.setSize( width, height );
stuff.width = width;
stuff.height = height;
var ymax = stuff.camera.near * Math.tan((Math.PI / 180) * stuff.camera.fov * 0.5);
var ymin = - ymax;
var xmin = ymin * stuff.camera.aspect;
var xmax = ymax * stuff.camera.aspect;
stuff.camera.projectionMatrix = new THREE.Matrix4().makePerspective(xmin, xmax, ymax, ymin, stuff.camera.near, stuff.camera.far);
stuff.camera.lookAt(stuff.scene.position);
stuff.renderer.render( stuff.scene, stuff.camera );
},

Expand Down

0 comments on commit 6168c5f

Please sign in to comment.