GlowScript and VPython

From, "GlowScript is an easy-to-use, powerful environment for creating 3D animations and publishing them on the web. The design of GlowScript is based on that of VPython. Development of GlowScript was initiated by David Scherer and Bruce Sherwood in the summer of 2011."

GlowScript Example

Just like with GlowScript, you don't need to import any extra modules to get started. Visit the GlowScript Help pages for information on what types of objects, events, and other graphing functionality is available.

Here is a quick example to help get you started.

GlowScript 1.1 VPython
scene.caption.text("""Right button drag or Ctrl-drag to rotate "camera" to view scene.
Middle button or Alt-drag to drag up or down to zoom in or out.
  On a two-button mouse, middle is left + right.
Touch screen: pinch/extend to zoom, swipe or two-finger rotate.""")

side = 4.0
thk = 0.3
s2 = 2*side - thk
s3 = 2*side + thk

wallR = box (pos=vector( side, 0, 0), size=vector(thk, s2, s3),  color =
wallL = box (pos=vector(-side, 0, 0), size=vector(thk, s2, s3),  color =
wallB = box (pos=vector(0, -side, 0), size=vector(s3, thk, s3),  color =
wallT = box (pos=vector(0,  side, 0), size=vector(s3, thk, s3),  color =
wallBK = box(pos=vector(0, 0, -side), size=vector(s2, s2, thk), color = vector(0.7,0.7,0.7))

ball = sphere (color =, radius = 0.4, make_trail=True, retain=200)
ball.mass = 1.0
ball.p = vector (-0.15, -0.23, +0.27)

side = side - thk*0.5 - ball.radius

dt = 0.3
while True:
  ball.pos = ball.pos + (ball.p/ball.mass)*dt
  if not (side > ball.pos.x > -side):
    ball.p.x = -ball.p.x
  if not (side > ball.pos.y > -side):
    ball.p.y = -ball.p.y
  if not (side > ball.pos.z > -side):
    ball.p.z = -ball.p.z


Run your code first!

It looks like you haven't tried running your new code.

Try clicking  Run and if you like the result, try sharing again.


Are you sure?

Resetting will undo all of your current changes.

Cancel Yes, I am sure. ×

Broadcast Control Room

Share Your Code!
pro tip You can save a copy for yourself with the Copy or Remix button.
Embed Your Code!
Email Your Code!
pro tip You can save a copy for yourself with the Copy or Remix button.

Add to Group

Decide which group to add this trinket below.

    You don't have any groups that you can add a trinket to — try creating a new one!

    You can also create a new group.

    Create Group