Overview of Python & VPython

  "Welcome to VPython" tutorial

  Introductory Videos

  Pictures of 3D objects




  VPython 7 web site
  VPython license

Log of major developments
ball in box

Also see "A time line for VPython development". There is also a log of work on the earlier Classic VPython.

2020 May 9: Web VPython 3.0
Significant improvements in translating VPython to JavaScript with respect to inserting async and await. RapydScript, which was a stepping stone to Web VPython, is not supported in Web VPython 3.0. JavaScript programs now link axis and size, as with VPython, and JavaScript programs need to handle async and await themselves (this is done automatically for VPython programs).

2019 Aug. 26: Web VPython 2.9
The Streamline library is eliminated thanks to the new "async" and "await" options in JavaScript; compilation is now about 6 times faster. Can now put waiting functions such as pause, waitfor, sleep, and rate in functions that are bound to events. A new input() function mimics that of Python, and the winput function is enhanced to permit use without binding to a function, and to provide a prompt for the user. It is now possible for a program to trigger an event to be processed by a bound function. There is no longer any need to avoid naming an object "wait", which was associated with the use of Streamline.

2018 June 20: Web VPython 2.8
An update to the Streamline library fixes bugs in complex programs.

2018 Jan. 28: Web VPythnon 2.7
Now two graphing packages are available, a somewhat improved version based on Flot (fast=True), and a new version based on Plotly (fast=False). The Plotly version offers powerful interactivity for the viewer but is significantly slower than the Flot version.

2017 Oct. 11 Provide clear error messages for scalar/vector errors.

2017 Sept. 7 Make it again possible to put pause() etc. inside functions.

2017 July 31: Web VPython 2.6
Significant fixes to cloning and to the 3D text object. Adam Thompson implemented being able to resize a canvas, either by resetting width and/or height, or by user dragging. Andrew Morrison improved graph xtitle and ytitle to appear below and to the left of the graph rather than above the graph. Web VPython 2.6 incorporates an update by Kovid Goyal to RapydScript-NG to support class variables (that is, variables that are shared by all instances of the class).

2017 June 11: Web VPython 2.5
Fix a bug in extrusion object that removed the last element in a user-supplied shape. The version number had to be incremented to 2.5 because some existing 2.4 programs might fail.

2017 Feb. 2: Web VPython 2.4
Fix a long-standing error in changing axis without updating up to remain perpendicular to axis (and vice versa). The result was that rotating an object by continually changing its axis could cause abrupt changes in the appearance of the object which were only noticeable if there was a texture or a compound object that lacked symmetry.

2017 Jan. 4: Web VPython 2.3
Replaced the original RapydScript Python-to-JavaScript compiler with RapydScript-NG by Kovid Goyal, which comes closer to supporting true Python syntax and also provides Python string methods such as lower() and upper() and split().

2016 Nov. 12: Web VPython 2.2
Improved extrusion and compound objects. They now have pos at their centers and size that represents the bounding box. The extrusion path is now specified by "path", making it possible to specify "pos" as the location of the center of the extrusion's bounding box.


2016 Aug. 22: Much more powerful version of the extrusion object, with full shapes and paths libraries. Also added text to radio buttons and check boxes.

2016 Aug. 4: Widgets implemented -- button, radio button, check box, slider, and drop-down menu.

2016 July 2: 3D text object implemented, with major contributions by Kadir Haldenbilen.


2016 Feb. 28: Web VPython 2.1
Improves and simplifies scene.title and scene.caption. Now you can say scene.title = "Watch the <b>ball</b>" ("ball" will be bold) and scene.caption = "This is what <i>always</i> happens" ("always" will be italic). You can also obtain the current contents for the title (T = scene.title) and caption (C = scene.caption). You can add to existing title or caption with scene.append_to_title(...) or scene.append_to_caption(...).

The old forms scene.title.text() and scene.title.html() could be used to specify the title but there wasn't a way to retrieve the current title. You had to decide between text and html, but now it doesn't matter; you always get full HTML capabilities.

These changes are not fully compatible with previous versions of Web VPython, which is why the version number has been changed to 2.1, but older versions will continue to work as before. Another reason for the changes has to do with making the Jupyter version of VPython work well.

Changes to the use of jQuery: If you use jQuery to display widgets (buttons, sliders, menus), see this documentation on changes to how to reference the title, caption, and print regions of the page.

2016 Jan. 24: Web VPython 2.0
* Fixes a serious problem in make_trail, that long trails were very slow. New trail-related features: trail_color, trail_radius, pps (points per second), clear() which deletes existing points. Setting make_trail False stops leaving a trail; setting make_trail True turns the trail on again, without drawing an undesirable line between the stop and start points.

* If v is a vector, v.mag() must now be written as v.mag and v.mag2() must now be written as v.mag2. The older form was a mistake and is incompatible with the new Jupyter version of VPython.

* display should be written as canvas; gdisplay as graph. The older names still work at present but are incompatible with the new Jupyter version of VPython.

* The list of positions in a curve named c cannot be referenced directly as c.pos. If the curve is named c and N is the nth point in the curve, c.point(N) returns {pos:p, color:col, radius:r, visible:v}. To change the nth point, use c.modify(N, pos=p, color=col, radius=r, visible=v). See the documentation for the curve object for the full list of methods available for accessing or changing an existing curve.

* The points object has a radius, not a size (size was a scalar and confusing given that size is a vector elsewhere; size_units can still be used to specify whether the radius is in pixels or real-world measure).

* Because it is hardly being used, CoffeeScript is not supported in Web VPython 2.0. It can still be used with "GlowScript 1.1 CoffeeScript".

* Here is a description of the plan for future development of VPython.


2015 Dec. 21: Update of files that permit operator overloading (being able to add two vectors a and b simply as a+b) and the ability to use synchronous code (such as infinite loops) thanks to files supplied by Salvatore di Dio. Changes to Firefox made this update necessary. An added bonus was that Web VPython now runs on Internet Explorer and Edge.

2015 Oct. 18: Implement display.delete(), gdisplay.delete(), and the ability to delete a set of data from a graph. Add to the make_trail machinery the ability to set trail_color and trail_radius without having to reference trail_object.

2015 Oct. 15: scene.mouse.pos now always contains the up-to-date mouse information, which makes it possible to drag objects with the mouse buttons up.

2015 Sept. 19: Implement the standard Python string.format mechanism.

2015 August 27: Improve sphere and curve rendering; provide textures.earth.

2015 August 2: Implement simple editor as alternative to the ACE editor, so that it is now possible to edit programs on mobile devices.

2015 June 23: Implement Python-style string formatting.

2015 June 3: Ring is now a regular primitive and supports transparency.

2015 April 21: Add factorial and combin functions.

2015 Feb. 22: Enable transparency on mobile devices.

2015 Jan. 20: Support touch inputs on touch-sensitive devices.

2014 November 17: Updated Web VPython 1.1 to fix a problem with JavaScript programs. This also introduces the ability to handle programs written in classic VPython, with some restrictions; see the VPython Help. There are new vector capabilities such as dot(A,B), equivalent to A.dot(B). The curve object now has an attribute "origin" for moving the entire curve, relative to this origin.

2014 October 25: Released Web VPython 1.1. Support added for RapydScript, a Python look-alike, with much help from Alexander Tsepkov, Charles Law, and Salvatore di Dio. CoffeScript compiler updated, which among other things means that 3**4 now equals 81. Also, jquery and jquery-ui updated thanks to the work of Adam Thompson, who also added the ability to place print output to the right of the canvas and improved resizing of a canvas.

2012 October 10: Textures can now use images from other ("CORS-enabled") web sites. Web VPython programs run well on the latest version of Firefox for Android (smartphones and tablets), though you can't yet rotate the camera, and transparency is buggy.

2012 September 12: Add functions compound_to_world, world_to_compound, pixel_to_world, print, print_options, get_library, and read_local_file. Improve rate behavior for high rate values.

2012 August 21: Updated Version 1.0 to improve error reporting for both JavaScript and CoffeeScript programs, and to improve editing of CoffeeScript programs. Added to the Help sections on text output for debugging, and how to run Web VPython in the absence of an internet connection.

2012 May 30: Version 1.0 implements triangles and quads, based on vertex objects, which make it possible to design your own objects and even change their shape dynamically. Also new are compound (groups of objects that can be manipulated as though they were one object) and clone (make a copy of an existing object). David Scherer made major contributions to the design of these new features. Also, the curve object now permits rapid change of position, size, and orientation, and the array scene.objects now includes label objects.

2012 April 21: Now in version 0.7 you can write your program in CoffeeScript as well as in JavaScript. See the home page for details.

2012 March 27: Transparency added to version 0.7. You can set the opacity of an object, with default = 1 (fully opaque); 0 is completely transparent.

2012 Jan. 29: Release version 0.7. The major new capability is textures, including bump maps (normal maps), for objects other than curves (and the curve-like objects helix and ring). Other new features include shininess, emissive, and scene.visible. Changes were made to require named arguments for object.rotate, vector.rotate, local and distant lights, and scene.mouse.project. Improved glowscript.org front page thanks to Tim Sherwood.

May/June 2011: David Scherer and Bruce Sherwood begin collaborating on implementing GlowScript, patterned on VPython but running in a web browser, exploiting the the new JavaScript/WebGL environment.