Selecting An Object
Node
TouchSensor • Attributes
Description
A Sphere located just beyond two parallel line of blocks. Touch the sphere to activate the Viewpoint motion past the blocks in order to examine the sphere.
VRIGNETTE Notes
This is a basic method for user-initiated animation. TouchSensor is connected to timers and interpolators through Route statements. No javascript needed.
Other Node(s)
Example
Touch the sphere to set the vrignette in motion.
Code
<x3d> <scene> <!-- World Info --> <worldInfo title="X3D TouchSensor Example"> </worldInfo> <!-- Navigation Info --> <navigationInfo speed="5.0" headlight="true" type="WALK" transitionType="LINEAR"> </navigationInfo> <!-- Avatar Viewpoint --> <viewpoint DEF="avatar" position="0.0 0.0 15.0"> </viewpoint> <!----- Light -----> <pointLight location="-2.9 2.5 0.0" radius="10.0"> </pointLight> <pointLight location="2.9 2.5 0.0" radius="10.0"> </pointLight> <!-- Left Blocks --> <transform translation="-3.0 0.0 0.0"> <shape DEF="YellowBlock"> <appearance> <material diffuseColor="1.0 0.50 0.0"> </material> </appearance> <box size="1.0 1.0 1.0"> </shape> </transform> <transform translation="-3.0 0.0 3.0"> <shape DEF="BlueBlock"> <appearance> <material diffuseColor="0.0 0.50 1.0"> </material> </appearance> <box size="1.0 1.0 1.0"> </shape> </transform> <transform translation="-3.0 0.0 6.0"> <shape USE="YellowBlock"> </shape> </transform> <transform translation="-3.0 0.0 -3.0"> <shape USE="BlueBlock"> </shape> </transform> <transform translation="-3.0 0.0 -6.0"> <shape USE="YellowBlock"> </shape> </transform> <!-- Right Blocks --> <transform translation="3.0 0.0 3.0"> <shape USE="YellowBlock"> </shape> </transform> <transform translation="3.0 0.0 0.0"> <shape USE="BlueBlock"> </shape> </transform> <transform translation="3.0 0.0 6.0"> <shape USE="BlueBlock"> </shape> </transform> <transform translation="3.0 0.0 -3.0"> <shape USE="YellowBlock"> </shape> </transform> <transform translation="3.0 0.0 -6.0"> <shape USE="BlueBlock"> </shape> </transform> <!-- Touch Sphere --> <transform translation="0.0 0.0 -25.0"> <touchSensor DEF="ball"> </touchSensor> <shape> <appearance> <material diffuseColor="0.0 0.5 0.5"> </material> </appearance> <sphere radius="2.0"> </sphere> </shape> </transform> <!-- Sensors/Interpolators --> <timeSensor DEF="timer" cycleInterval="5.0" loop="false"> </timeSensor> <positionInterpolator DEF="mover" key="0.0 0.5 1.0" keyValue="0.0 0.0 15.0 0.0 0.0 0.0 0.0 0.0 -12.0"> </positionInterpolator> <!-- Routes --> <route fromNode="ball" fromField="touchTime" toNode="timer" toField="startTime"> </route> <route fromNode="timer" fromField="fraction_changed" toNode="mover" toField="set_fraction"> </route> <route fromNode="mover" fromField="value_changed" toNode="avatar" toField="position"> </route> <!-- Scene Background --> <background skyColor="0.30 0.30 0.30" groundColor="0.20 0.20 0.20"> </background> </scene> <!-- End X3D Scene --> </x3d>