tried this still not good with scene.camera

20 views
Skip to first unread message

Dale Griffiths

unread,
Dec 4, 2021, 5:30:47 PM12/4/21
to Glowscript Users
Wondered if you could attach camera to the position of an object, obviously if you give the ball a radius your camera is stuck inside the ball so i tried making radius = 0. This does then do what I'd expect with the position of the ball and therefore camera moving out along the negative z axis, however the green floor is not visible. However if i manually zoom out with the track pad then I see the green square (it's as if the camera was way into the negative z direction so can't see the square , which shouldn't be the case) also once the square is in view after zooming it just stay there???

GlowScript 3.1 VPython
floor = box (pos=vec(0,0,0), size=vec(1000, 1000,1), color=color.green)
scene.camera.axis = vec(0,0,-1)
ball = sphere(pos=vec(0,0,20), radius=0)
scene.camera.pos = ball.pos
while True:
  rate(1)
  #scene.camera.pos.z += 1
  ball.pos.z += 1
  scene.camera.pos = ball.pos
  print(scene.camera.pos)

Dale Griffiths

unread,
Dec 4, 2021, 5:39:19 PM12/4/21
to Glowscript Users
Aha, this seems to work for some reason updating the axis as a vector from the camera to the floor in the while loop!

GlowScript 3.1 VPython

floor = box (pos=vec(0,0,0), size=vec(1000, 1000,1), color=color.green)
scene.camera.axis = vec(0,0,-1)
ball = sphere(pos=vec(0,0,20), radius=0)
scene.camera.pos = ball.pos
while True:
  rate(50)
  #scene.camera.pos.z += 1
  ball.pos.z += 1
  scene.camera.pos = ball.pos
  scene.camera.axis = floor.pos - scene.camera.pos
  print(scene.camera.pos)

Bruce Sherwood

unread,
Dec 4, 2021, 10:44:10 PM12/4/21
to Glowscript Users
Setting scene.camera.axis to vec(0,0,-1) changes scene.center
from <0,0,0> to <0,0,952>, very far from the floor.

Do review the effects of changing scene.camera.pos and scene.camera.axis here:


Bruce

Reply all
Reply to author
Forward
0 new messages