3D Animation Workshop: Lesson 30: VRML 97--Touch and Go! | 2 | WebReference

3D Animation Workshop: Lesson 30: VRML 97--Touch and Go! | 2

Lesson 30 - VRML 97--Touch and Go! - Part 3

The first ROUTE statement in the last example reads as follows:

ROUTE Click.touchTime TO Timer.startTime

The two fields connected by this ROUTE statement will make a lot more sense if we consider the full definitions of the TouchSensor and TimeSensor nodes from the VRML 97 specification.

You can see that our simple examples have been hiding a lot, and we won't pretend to cover it all here. But the main thing worth noting is that the sensors are composed of two kinds of fields. An eventOut field contains a value that can be sent out by a ROUTE statement to another node. An exposedField contains a value that can be both received from another node and (like an eventOut) also be routed to another node. A third kind of field called an eventIn (not shown here) can receive a value routed from another node. Thus an exposedField is a combination of an eventIn and an eventOut.

In our ROUTE statement at the top, the value in the touchTime field in theTouchSensor (Click) is routed (copied) to the startTime field in the TimeSensor (Timer). When the user clicks on the box, the time value at the moment of the click is copied to the startTime field of TimeSensor. This starts the TimeSensor running and it's worth understanding precisely why. The browser is always keeping track of the current time. Once the value in startTime is equal (or earlier than) the current time, the TimeSensor becomes active and starts generating eventOuts to be routed to other nodes and control them. In our examples, the activated TimeSensor is sending fraction_changed values to the interpolator. This idea is undoubtedly rather subtle, so take a moment to make sure you understand it. Notice that the default value of stopTime is 0. Because this value is less than startTime, it's ignored. If it were greater (later) than startTime, it would make logical sense and the TimeSensor will deactivate when stopTime is reached.

The fields in boldface have default values as indicated. Thus our default TouchSensor was enabled (its Boolean value is TRUE), meaning that it was ready to respond to user mouseovers and clicks. Our TimeSensor would have used its default one-second cycle had we not overridden it with a ten-second value. In our looping example (without the TouchSensor) the TimeSensor became activated on read because the default value of startTime is 0. Time in VRML 97 is measured in seconds from midnight GMT January 1, 1970. Thus the browser's current time when the file is read is always later than the value in startTime, and the TimeSensor is necessarily activated.

To Return to Parts 1 and 2, Use Arrow Buttons

Previous Lesson / Table of Contents / Next Lesson

Created: December 23, 1997
Revised: December 23, 1997

URL: http://webreference.com/3d/lesson30/part3.html