vPython / GlowScript Sensor Position

365 Views Asked by At

I'm showing some strange discrepancies between my declared camera position (scene.camera.pos), and the actual camera position. I can't believe this feature is just broken, am I missing something here?

Here's the code, and the output shown below

 GlowScript 3.1 VPython

cube = box(pos=vector(0, 0, 0), size=vector(1,1,1), color=color.red, texture=textures.rough)

scene.lights = [distant_light(direction=vector(0.4226, 0, -0.9063),color=color.gray(0.7)),distant_light(direction=vector(0.4226, 0, -0.9063),color=color.gray(0.7))]
scene.background = color.gray(0.8)
scene.camera.pos = vector(3,3,-3)
scene.camera.axis = cube.pos - scene.camera.pos
#scene.forward=cube.pos
#scene.camera.center=cube.pos
#scene.camera.fov = (pi/180)*10
#scene.camera.axis = vector(0, 0, 0)
#scene.up = vector(0,1,0)

while True:
    rate(0.5)
    scene.append_to_title(scene.camera.pos)
    #scene.camera.rotate(angle=0.05, axis=vec(0,0,1), origin=vec(0,10,0))
    #scene.capture("woah")

enter image description here

2

There are 2 best solutions below

1
On

I think I see the problem. There is a conflict between you manipulating the camera and the default scene.autoscale = True. If you set scene.autoscale = False before manipulating the camera, I think you'll find that the program behaves as expected. At the very least, this implies a need for the camera documentation to point out this conflict.

1
On

Finally checked back in on this and it's working properly now.