|Home||Pictures of 3D objects|
Choose from the menus above for documentation of GlowScript.
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. Here is an overview of the project, and here is a log of developments. Here is the open source for this project. Some technical overviews are available.
Descriptions of the options available at the top of the page:
Be sure to explore the many example programs that are available.
Using the GlowScript editor
GlowScript uses the ACE text editor. Here is a list of keyboard shortcuts for find, replace, etc. While editing, press Ctrl-1 to run your program in the same window. Press Ctrl-2 to run your program in a separate window, which can be convenient for comparing the program with its behavior. If you change your program, press Ctrl-2 again in the editor display to re-run the program with the new changes. Because ACE doesn't work on mobile devices, a simpler editor is used there.
A simple program: In the editor, after the GlowScript header, enter the statement "sphere()" and choose "Run this program". You should see a 3D sphere. Read the Help discussions on cylinder and box objects to learn how to customize 3D objects (position, color, size, etc.).
Rotate and zoom: You can rotate and zoom the camera using the mouse; for instructions, see the Example program AtomicSolid.
When developing a program it can be very useful to comment out a block of code temporarily. Here is how to do this in the three languages:
# VPython or RapydScript (can also use '''):
GlowScript uses the WebGL 3D graphics library that is included in current versions of major web browsers. You must have a modern graphics card with Graphics Processing Units (GPUs). Here are browser details:
Chrome, Firefox, Safari, Internet Explorer, and Edge all support WebGL and GlowScript.
Tablets and smart phones: Most tablets and smart phones support WebGL and GlowScript, both Android and iOS.
Testing: If things don't work, it may be useful to visit get.webgl.org which checks whether WebGL is working properly on your computer. Also, here is a repository of WebGL demo programs, where it may be useful to see whether these programs will run on your computer.
RapydScript, a Python look-alike
Because the design of GlowScript is based on that of VPython, and to facilitate moving programs between GlowScript and VPython, GlowScript makes it possible to write GlowScript programs in RapydScript, a programming language that is very simiilar to Python but programs written in RapydScript can run in a browser.
You can write programs using the syntax of VPython, or to run many existing VPython programs. The VPython Help documents this syntax for the GlowScript context. The VPython Help also includes a Python program that can convert an existing VPython program to a form that will run in the GlowScript browser environment.
When you create a new program, a header line is inserted that looks like this:
GlowScript 2.0 VPython
If you are new to programming or to RapydScript/Python, you'll find the Python tutorials at www.codecademy.com very helpful
var x, y
You can initialize new variables at the same time that you introduce them:
var x = 5, y = 3
Post to the GlowScript Forum or write to if you don't find what you need, or to tell us how you are using GlowScript. To prevent spam, your first post will be reviewed before becoming public.
Using the GlowScript libraries
It is possible to use GlowScript locally, without an internet connection, though you will need to copy and paste your programs to glowscript.org if you want them stored in the cloud. Here are the instructions.
The text editor automatically inserts a header of the form "GlowScript X.Y VPython" at the start of every new program, where X.Y is the current version number. If future development of GlowScript should cause incompatibilities with earlier versions, old programs will be run with old versions of GlowScript, thereby ensuring to the extent possible that all programs will continue to work as they did originally. The "version" variable provides information about the version number:
version is ['X.Y', 'glowscript']
Technical issue with execution speed
In order to make it possible to add and subtract 3D vectors, and to be able to multiple or divide a vector by a scalar, all add, subtract, multiply, and divide operations are converted into function calls. If you have a critical function that needs to run as fast as possible, use the following vector operations, where A and B are vectors and k is an ordinary number:
A+B -> A.add(B)
The Example program SurfaceCharge uses this technique in the Efield function. Here is one of the expressions in that function (divided across two lines to fit into this web page):
This corresponds to the following expression:
For users of VPython
See this comparison of VPython and GlowScript.
To invoke CoffeeScript with GlowScript 1.0 or 1.1, just add CoffeeScript to the GlowScript header:
GlowScript 2.0 CoffeeScript
You need not use upper-case letters; "coffeescript" will also work. After making such a change, replot the browser page. CoffeeScript is not available in GlowScript 2.0 or later, due to there being very little use of it now that VPython is available.
Top of page