Building 3D Models for the Web

Simple Event and Route Examples

These examples are from The VRML 2.0 Handbook, Addison-Wesley Developers Press.

Light a Lightbulb Example (p. 117)

Group {
  children [
    DEF LIGHT_CONTROL TouchSensor { }
    Inline {
      url [ "lightswitch.wrl" ]  # click this to light the light
    }
  ]
}
DEF LIGHT PointLight {
  location -6 4 2
  on FALSE
}
Inline { url [ "table.wrl" ] } # objects to be lit
ROUTE LIGHT_CONTROL.isActive TO LIGHT.on

Here is the light switch example in action.

Ring a Doorbell Example (p. 122)

Group {
  children [
    DEF PUSH TouchSensor { }
    Inline { url [ "doorbell.wrl" ] }  # doorbell geometry
  ]
}
Sound {
  source DEF BUZZ AudioClip { url [ "doorbell.wav" ] }
  maxFront 50
  minFront  5
}
ROUTE PUSH.touchTime TO BUZZ.startTime

Here is the doorbell example in action.

Dimmer Switch Example (p. 129)

When you enter a 25 meter cube, a ProximitySensor makes the light gradually come to full intensity in 2 seconds.

#VRML V2.0 utf8

Viewpoint {
  position 0 0 15
}

DEF DETECTOR ProximitySensor {
  size 25 25 25
}
DEF TIMER TimeSensor {
  cycleInterval 2
}
DEF LIGHT PointLight {
  color 1 0 0
  intensity 0
  location 3 3 3
}
Inline {
  url [ "chacmool.wrl" ]  # object to be lit
}
ROUTE DETECTOR.enterTime TO TIMER.startTime
ROUTE TIMER.fraction_changed TO LIGHT.intensity

Here is the dimmer switch example in action.

Maintained by H. Edward Donley <hedonley@grove.iup.edu>
Last Modified Monday, 13-Aug-2001 16:53:26 EDT