Table of Contents Previous Chapter Details Viewpoint Slideshow Next Chapter Details X3D Resources

X3D Example Archives: VRML 2.0 Sourcebook, Chapter 30 - Scripts

Figure 30.4 Script Spiraling Ball Trace

Many actions are too complex for animation nodes, such as computed animation paths (e.g. gravity), algorithmic shapes (e.g. fractals), or collaborative environments (e.g. games). You can create new sensors, interpolators, etc., using program scripts written in Java (a powerful general-purpose language) or ECMAscript (JavaScript, an easy-to-learn language). The Script node selects a program script, specified by a url or contained source code. Program scripts have field and event interface declarations, each with a data type, a name, and an initial value (for fields only).

These X3D scenes are adapted directly from the original VRML 2.0 Sourcebook chapter examples. Also available: Introduction to VRML97 SIGGRAPH98 course notes.

X3D Scenes Descriptions
Figure 30.1 Script Sliding Ball A sliding red sphere and a custom interpolation script. Three ways to include ECMAScript (JavaScript) programming are compared: external file, url script code, and embedded script code. Recommendation: use embedded script code inside a CDATA block.
Figure 30.2 Script Background Select Click on a geometric Shape to change the scene Background. A Script node controls the state changes.
Figure 30.3 Script Sound Activate A pair of filter scripts used to create a toggle on-off switch.
Figure 30.4 Script Spiraling Ball Trace A spiraling red sphere and a custom interpolation script.
Figure 30.5 Script Torus Builder A torus shape built with a donut-maker program script. Also see Figures 31.6 and 31.7 for comparison.

Online at http://www.web3d.org/x3d/content/examples/Vrml2.0Sourcebook/Chapter30-Scripts

Master source code archive is under subversion control at
http://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Vrml2.0Sourcebook/Chapter30-Scripts

Table of Contents Previous Chapter Details Viewpoint Slideshow Next Chapter Details X3D Resources

Also available: current and archived nightly builds and distributions of these examples, all published under an Open-Source License.

The X3D Resources: Examples page and Savage Developers Guide provide more information about the production of this archive.