Skip to content

Commit

Permalink
Limit camera position to be above ground level.
Browse files Browse the repository at this point in the history
  • Loading branch information
timhutton committed Aug 3, 2018
1 parent 662b528 commit ac2a730
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
function repositionCamera() {
var look_at = p3(0,0,0);
var d = 40;
var vd = d * view_height;
var vd = Math.max( ground_level, d * view_height );
var hd = Math.sqrt( d*d - vd*vd );
camera.p = p3( hd*Math.cos(camera_theta), hd*Math.sin(camera_theta), vd );
camera.z = normalize( sub( look_at, camera.p ) );
Expand Down Expand Up @@ -285,6 +285,7 @@
f:canvas.height,
pp:p2(canvas.width/2,canvas.height/2)
};
ground_level = 0;
repositionCamera();

var scale_slider = document.getElementById("scale_slider");
Expand Down

0 comments on commit ac2a730

Please sign in to comment.