VRML Script Tutorial
VRML Interactive Tutorial
Let there be Light
Materials with Colored Lights
VRML File Structure
Drawing: Shape node
Hierarchical Node Structures
Defining and Instancing Nodes
Defining Levels of Detail
Events in VRML
Let the Music Play
Adding Realism to the world
Information about your world
Definition for Auxiliary Nodes
In the section events it was mentioned
that a node can send and receive events.
ROUTES are a simple way of defining a path between an event generated by
a node and a node receiving an event. The syntax is:
Note: because all exposed fields define implicitly an eventIn and an eventOut
fields, you don't have to write the prefix 'set_' or the suffix '_changed'.
The following syntax is valid in VRML as long as the eventIn and the eventOut
which appear in the ROUTE sentence belong to exposed fields.
ROUTE Node.eventOut_changed TO Node.set_eventIn
Because every time an exposed field is changed an event is generated it
is possible to have a cascade of events being generated. A time stamp is
given to each event which is generated, the same time stamp being given
for all events in a cascade as if all events in a cascade occurred simultaneously.
ROUTE Node.eventOut TO Node.eventIn
Now there is something missing isn't it? In the section events
it was mentioned the eventIn of an exposed field was used to set the
value of the respective field. However looking at the syntax of ROUTE there
is no explicit declaration of what the new value is. As mentioned before
in this section "ROUTES are a SIMPLE way of defining a path...",
and SIMPLE in this case has some limitations. The new value for the field
associated with the eventIn is the value of the field which caused the
eventOut to be generated.
Big deal, so what can I do with routes if I can't specify the value for
the field that I'm about to set? Well, you actually can do that using a
middle man, see Interpolators.
A cascade of events may result in an event being generated more than once
in the same cascade, this can cause a loop of events. In VRML loops are
not allowed, an event shall only be generated once in each cascade of events.
You don't have to worry about this, the browser will disable any event
which is repeated with the same time stamp.
It is possible that two different generated events in a cascade are linked
with a ROUTE to an eventIn. Results are undefined in this case. You should
try to avoid this type of situations.