This page shows the example 3D models from chapter 7 and the first half of chapter 8 of the The VRML 2.0 Handbook, by Jed Hartman and Josie Wernecke. For more information, see my main Handbook examples page.
In some cases, the download links download a Zip file containing the main VRML file plus any other associated files that the main file relies on, such as textures.
In the following Chapter 7 scripting examples, we have replaced javascript
with vrmlscript
. The specification changed to use vrmlscript
after publication of the book.
Example 7-1: Locate-highlighting with a Script node
Shows a skull. To highlight the skull, hover the mouse pointer over it.
Preview image

Live demo
Example 7-2: Animating the choices under a Switch node
Shows a flat square. To run the animation, click the square. (The animation of an eagle has been replaced with an animation of a circle moving and getting larger.)
Preview image

Live demo
Example 7-3: Keeping track of state with a script
Shows a brazier. The live demo is slightly different from the example in the book; it uses a small sphere instead of a point set, because the point set wasn’t rendering.
To start the animation, click the brazier. The spark (a small yellow sphere) flies up from the coals, and then the animation repeats. To stop the animation, click the brazier again.
Preview image

Live demo
Example 7-4, part 1: Animating a viewpoint
Shows a blank sign. The version of this example that appears in the book doesn’t quite work right, so we’ve changed some things for the version here. (For further improvements, see next example.) We apologize for the errors in the book; at the time of publication, some features were not yet implemented in VRML viewers, so we couldn’t test the code for this example.
Here are the errors in the book version, and what we did to fix them:
- A prototype reads its first node and adds it to the scene. Other nodes contained in the prototype can be referenced by routes or scripts, but they are not added to the scene. The example in the book assumed that such nodes would be added to the scene. The corrected example groups all the required nodes (the Viewpoint, the TouchSensor, the Signpost, and the ProximitySensor) under the same Transform node in the TourStop prototype so that they are all added to the scene.
- In the original example,
viewpointLocation
andviewpointOrientation
are fields. Instead, they need to be labeled asexposedField
. - Some of the viewpoints in the original example seemed to be pointing off into nothingness. This new version makes more visual sense.
Preview image

Live demo
Example 7-4, part 2: Further improvements
Shows a blank signpost. At some point after the above improved version of example 7-4, we made some further improvements. In this version, if you’re anywhere near a signpost and you click it, the tour first moves you to the specific location of the tour stop, then moves you to the next stop.
This version is still not perfect, but it works better than the previous versions.
In this demo, the signposts are blank, but you could add code to display words or images on them.
Preview image

Live demo
Example 8-1: Specifying colors per face
Shows a pyramid with a different color on each face.
Preview image

Live demo
Example 8-2: Specifying indexed colors per face
Shows a pyramid with the same color on some faces.Preview image

Live demo
Example 8-3: Specifying colors per vertex
Shows a pyramid with vertex coloring.Preview image

Live demo
Example 8-4: Specifying indexed colors per vertex
Shows a pyramid with indexed vertex coloring.Preview image
