<!-- Place triggering text above sphere of interest -->
<
Transform translation='
0 2 0'>
<
Shape>
<
Text string='
"Touch text to" "start animation..."'
solid='
true'>
<FontStyle justify='"MIDDLE" "MIDDLE"'/>
</
Text>
</
Shape>
<!-- This TouchSensor only reacts to user clicking on the sibling Shape and Text, because it is under a parent Transform grouping node -->
<!--
TextTriggerTouchSensor ROUTE:
[
from touchTime to AnimationClock.startTime
]
-->
<
TouchSensor DEF='
TextTriggerTouchSensor'
description='
Touch text to start...'/>
</
Transform>
<!-- Here is Sphere with accompanying Material that will get animated -->
<
Transform translation='
0 -1 0'>
<
Shape>
<
Sphere/>
<
Appearance>
</
Appearance>
</
Shape>
</
Transform>
<!-- TimeSensor is triggered to start by TouchSensor, then sends animating values to Interpolator -->
<!--
AnimationClock ROUTEs:
[
from TextTriggerTouchSensor.touchTime to startTime
]
[
from fraction_changed to ColorChanger.set_fraction
]
-->
<
TimeSensor DEF='
AnimationClock'
cycleInterval='
6'/>
<!-- ROUTE 1: TouchSensor trigger to TimeSensor clock -->
<
ROUTE fromNode='
TextTriggerTouchSensor'
fromField='
touchTime'
toNode='
AnimationClock'
toField='
startTime'/>
<!-- Interpolator: ColorChanger interpolates evenly between red, green, blue and then back to red -->
<!--
ColorChanger ROUTEs:
[
from AnimationClock.fraction_changed to set_fraction
]
[
from value_changed to SphereMaterial.diffuseColor
]
-->
<
ColorInterpolator DEF='
ColorChanger'
key='
0 0.3333 0.6666 1'
keyValue='
1 0 0 0 1 0 0 0 1 1 0 0'/>
<!-- ROUTE 2: the ColorChanger interpolator gets stimulated by AnimationClock TimeSensor fraction to compute a color value -->
<
ROUTE fromNode='
AnimationClock'
fromField='
fraction_changed'
toNode='
ColorChanger'
toField='
set_fraction'/>
<!-- ROUTE 3: Interpolator output is sent to target node of interest. Changed color value is routed to SphereMaterial color. -->
<
ROUTE fromNode='
ColorChanger'
fromField='
value_changed'
toNode='
SphereMaterial'
toField='
diffuseColor'/>