Examples

The following links take you to view standalone examples from The VRML 2.0 Handbook by Jed Hartman and Josie Wernecke.

Note about the different browsers: The examples given below are VRML 2.0 compliant. All the available browsers are in different states of completion (as of this writing on December 10, 1996), so not all the features below will work perfectly in all broswers, with the exception of the CosmoWorlds running on SGI machines, which is currently the furthest towards completion. We urge you to keep downloading the latest version of your favorite browser in order to track the updates.

The next release of the CosmoWorlds browser for the PC platform is expected to be in the middle of December.

I have made a page of stills of each of these examples as they should appear in your browser. Feel free to use these to check whether your browser is displaying the right thing.

As these samples are all small, they have not been gzipped, thus avoiding some of the current problems in some of the browsers. When this is fixed, all these files will be in the gzip format.

Example 4-1. The complete small temple
This example is referenced on page 59 of the book.

Example 4-2. Rotating an object

Example 4-3. Combining transformations

Example 4-4a. Rotation followed by translation, part 1

Example 4-4b. Rotation followed by translation, part 2

Example 4-5a. Translation followed by rotation, part 1

Example 4-5b. Translation followed by rotation, part 2

Example 4-6. Using a Box node

Example 4-7. Placing a box in two different places

Example 4-8. Using a Cylinder node

Example 4-9. Using a Coordinate node

Example 4-10. Using an IndexedFaceSet node

Example 4-11. Using an IndexedLineSet node

Example 4-12. Using a Text node
Note that text nodes not working on PC version of CosmoPlayer yet.

Example 4-13. Specifying fonts
Note that text nodes not working on PC version of CosmoPlayer yet.

Example 4-14. Using diffuse color in a Material node

Example 4-15. Ambient intensity

Example 4-17. Prototyping a column

Example 4-18. Prototyping with an exposed field

Example 4-19. External prototype syntax

Chapter 4 - Ceiling example

Chapter 4 - Scaling a box example

Chapter 5 - Elevation grid example

Chapter 5 - Point light example

Example 6-1. Using a TouchSensor node

Example 6-2. Using a PlaneSensor node
Note that PlaneSensor not working on PC version of CosmoPlayer yet.

Example 6-3. Using a ProximitySensor node

Example 6-4. Using an interpolator
Try this version if you are running on a PC. I made the spark into a small sphere so that it is more visible. I also added texture coordinates explicitly so that the mapping is performed correctly.

Chapter 6 - Lights example

Please note that in these following Chapter 7 scripting examples, we have substituted "vrmlscript" for "javascript". This was a change that was necessary after the book publication.

Example 7-1. Locate-highlighting with a Script node

Example 7-2. Animating the choices under a Switch node
After you click on the image to activate it, try it again. It works better the second time around!

Example 7-3. Keeping track of state with a script
Try this version if you are running on a PC. I made the spark into a small sphere so that it is more
visible. I also added texture coordinates explicitly so that the mapping is performed correctly.

Example 7-4. Animating a viewpoint
This example has changed a bit from what appears in the book. Please note that some important changes are necessary to make Example 7-4 work correctly. 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 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 will all be added to the scene.

In the original example, viewpointLocation and viewpointOrientation are fields. They need to be exposedFields. We also changed some of the viewpoints in the original example because they seemed to be pointing off into nothingness. This new version makes more visual sense.

(We apologize for these errors. This feature was not implemented at the time of publication and could not be tested. Please use this correction version of Example 7-4.)

Example 8-1. Specifying colors per face

Example 8-2. Specifying indexed colors per face

Example 8-3. Specifying colors per vertex

Example 8-4. Specifying indexed colors per vertex

Example 8-5. Specifying normals per face

Example 8-6. Specifying normals per vertex

Example 8-7. Specifying indexed vertex normals

Example 8-8. Combining color per vertex with a one-component texture

Example 8-9. Using default texture mapping
Note that now the default texture mapping differs in the SGI and PC versions--the PC version maps to the front face of the object, whereas the SGI version maps to the top of the object. This will eventually work the same way. The safest way to insure that mapping works the same across all browsers (at this point in time) is to specify texture coordinates explicitly.

Example 8-10. Specifying texture coordinates

Example 8-11. Scaling a texture

Example 8-12. Repeating and clamping textures
Note that clamping does not yet work on the CosmoPlayer PC browser yet.

Example 8-13. Specifying a pixel texture

Example 8-15. Specifying ground colors

Example 8-16. Specifying sky colors

For detailed illustrations of all VRML nodes, be sure to consult the VRML source for the Tenochtitlan world.