Trouble figuring out how to set camera POV

30 views
Skip to first unread message

Erik the Anarchitect

unread,
Jul 24, 2016, 6:50:37 PM7/24/16
to Glowscript Users
The first thing I did was write a program that built a model of a building.
The camera automatically was pointed at where the building was, and that was nice.

The next thing I tried: I wanted an illusion of having the ground and the horizon (I realize I can't have a true horizon because glowscript does not support points at infinity)

So I made a giant disk (used cyilinder with a very thin length and a very large radius, colored green)

The trouble is this causes the camera to automaticcally move to include the whole big green disk in the view and obviously I don't want to do that.

But I had trouble making the attributes of scene.camera work here, so I am a bit confused.

Bruce Sherwood

unread,
Jul 24, 2016, 7:02:00 PM7/24/16
to Glowscript Users
The simplest thing to do is to set scene.range to some small number R. This will turn off autoscaling and place the camera so that a box located at vec(0,0,0), with size vec(2*R,2*R,0.1*R), will about fill the canvas.

Here's an example:

scene.range = 2
box()
cylinder(pos=vec(0,-1.5,0), radius=100, color=color.green, axis=vec(0,1,0))

Aaron Titus

unread,
Jul 24, 2016, 7:02:16 PM7/24/16
to glowscri...@googlegroups.com
You may want to set the range of the scene using:

L=10
scene.range=L


You can set L to be whatever is larger than the length of the building.


You can also turn autoscaling off after you create the building and before you create the green disk using:

scene.autoscale=0


Aaron

Erik the Anarchitect

unread,
Jul 24, 2016, 8:49:37 PM7/24/16
to Glowscript Users
Thank you both. That did what it was supposed to, except for one little detail. The height of the camera is zero. So is the height of the ground plane. That means that the ground is invisible until you shift the POV with the mouse. So what do I do to set the camera just a little higher than its default position?

Bruce Sherwood

unread,
Jul 24, 2016, 10:07:56 PM7/24/16
to Glowscript Users
That's why I provided a working program fragment. Look again and you'll see that I moved the disk down to y = -1.5, so that the top of the disk of thickness 1 is at y = -0.5, which is the bottom of the 1x1x1 box.

Alternatively, you can say scene.center = vec(0,y,0) with y chosen to do what you want. Note too that you can aim the camera using scene.forward.
Reply all
Reply to author
Forward
0 new messages