| Cover | TOC | Chap | Prev Chap | Prev Fig | Next Fig | Next Chap |
|
Figure 9.1
A cube that spins when the viewer's cursor moves over it. |
|
|
Click on the image to view the VRML scene. |
#VRML V2.0 utf8
# The VRML 2.0 Sourcebook
# Copyright (c) 1997
# Andrea L. Ames, David R. Nadeau, and John L. Moreland
Group {
children [
# Rotating Cube
DEF Cube Transform {
children Shape {
appearance Appearance {
material Material { }
}
geometry Box { }
}
},
# Sensor
DEF Touch TouchSensor { },
# Animation clock
DEF Clock TimeSensor {
enabled FALSE
cycleInterval 4.0
loop TRUE
},
# Animation path
DEF CubePath OrientationInterpolator {
key [ 0.0, 0.50, 1.0 ]
keyValue [
0.0 1.0 0.0 0.0,
0.0 1.0 0.0 3.14,
0.0 1.0 0.0 6.28
]
}
]
}
ROUTE Touch.isOver TO Clock.set_enabled
ROUTE Clock.fraction_changed TO CubePath.set_fraction
ROUTE CubePath.value_changed TO Cube.set_rotation