Table of Contents Previous Chapter Summary Chapter Viewpoint Slideshow Javadoc for translated java source Next Chapter Summary X3D Resources

X3D Example Archives: VRML 2 Sourcebook, Chapter 30 Scripts

Figure 30.4 Script Spiraling Ball Trace

Scripts allow authors to define their own event-handling code to improve animation sophistication.

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.

  5 X3D Scenes       Scene Descriptions
Figure30_1ScriptSlidingBall 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.
Figure30_2ScriptBackgroundSelect Figure 30 2 Script Background Select Click on a geometric Shape to change the scene Background. A Script node controls the state changes.
Figure30_3ScriptSoundActivate Figure 30 3 Script Sound Activate A pair of filter scripts used to create a toggle on-off switch.
Figure30_4ScriptSpiralingBallTrace Figure 30 4 Script Spiraling Ball Trace A spiraling red sphere and a custom interpolation script.
Figure30_5ScriptTorusBuilder 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/Vrml2Sourcebook/Chapter30Scripts

Validate XHTML 1.1

Master source-code model archive is under subversion control at
http://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Vrml2Sourcebook/Chapter30Scripts

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

Table of Contents Previous Chapter Summary Chapter Viewpoint Slideshow Javadoc for translated java source Next Chapter Summary X3D Resources