Hi,
I've run into an issue with the scene.camera.follow function. The
documentation indicates that the line "scene.camera.follow(None)" should make the camera stop following an object, but when I run that line, I get an exception. I've modified an example program below to show the issue. If you start the program and check the checkbox, the camera should follow the object as expected. If you then try and uncheck the checkbox to stop the camera from following the object, you will get an exception. I'm using vpython 7.6.3 in spyder.
from vpython import *
scene.caption = """In GlowScript programs:
To rotate "camera", drag with right button or Ctrl-drag.
To zoom, drag with middle button or Alt/Option depressed, or use scroll wheel.
On a two-button mouse, middle is left + right.
To pan left/right and up/down, Shift-drag.
Touch screen: pinch/extend to zoom, swipe or two-finger rotate."""
scene.forward = vector(0,-.3,-1)
follow = False
def followFunc():
global follow
follow = check.checked
if follow:
scene.camera.follow(dwarf)
else:
scene.camera.follow(None)
check = checkbox(pos = scene.title_anchor, text = "Camera Follow", bind = followFunc)
G = 6.7e-11 # Newton gravitational constant
giant = sphere(pos=vector(-1e11,0,0), radius=2e10, color=color.red,
make_trail=True, trail_type='points', interval=10, retain=50)
giant.mass = 2e30
giant.p = vector(0, 0, -1e4) * giant.mass
dwarf = sphere(pos=vector(1.5e11,0,0), radius=1e10, color=color.yellow,
make_trail=True, interval=10, retain=50)
dwarf.mass = 1e30
dwarf.p = -giant.p
dt = 1e5
while True:
rate(200)
r = dwarf.pos - giant.pos
F = G * giant.mass * dwarf.mass * r.hat / mag(r)**2
giant.p = giant.p + F*dt
dwarf.p = dwarf.p - F*dt
giant.pos = giant.pos + (giant.p/giant.mass) * dt
dwarf.pos = dwarf.pos + (dwarf.p/dwarf.mass) * dt