<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "http://www.web3d.org/specifications/x3d-3.3.dtd">
<X3D profile='Immersive' version='3.3 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation =' http://www.web3d.org/specifications/x3d-3.3.xsd '>
<meta name='titlecontent='ColorInterpolatorExample.x3d'/>
<meta name='descriptioncontent='Demonstrate basic design pattern for animating a node.'/>
<meta name='creatorcontent='Don Brutzman'/>
<meta name='createdcontent='17 April 2005'/>
<meta name='modifiedcontent='5 October 2015'/>
<meta name='drawingcontent='ColorInterpolatorExampleSceneGraphWithRoutes.png'/>
<meta name='Imagecontent='ColorInterpolatorExample4Colors.png'/>
<meta name='subjectcontent='Animation ColorInterpolator'/>
<meta name='identifiercontent=' http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter07EventAnimationInterpolation/ColorInterpolatorExample.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
<!-- -->
<!-- Place triggering text above sphere of interest -->
<Transform translation='0 2 0'>
<Text string='"Touch text to" "start animation..."'>
<FontStyle justify='"MIDDLE" "MIDDLE"'/>
<!-- Selectable Text design pattern has transparent Box and TouchSensor description as a tooltip -->
<Box size='6.2 2 .001'/>
<Material transparency='1'/>
<!-- This TouchSensor only reacts to user clicking on the sibling Shape and Text, because it is under a parent Transform grouping node -->
<!-- ROUTE information for TextTriggerTouchSensor node:  [from touchTime to AnimationClock.startTime ] -->
<TouchSensor DEF='TextTriggerTouchSensordescription='Touch text to start...'/>
<!-- Here is Sphere with accompanying Material that will get animated -->
<Transform translation='0 -1 0'>
<!-- SphereMaterial diffuseColor gets overridden by interpolator output -->
<!-- ROUTE information for SphereMaterial node:  [from ColorChanger.value_changed to diffuseColor ] -->
<Material DEF='SphereMaterialdiffuseColor='0.5 0.5 0.5'/>
<!-- TimeSensor is triggered to start by TouchSensor, then sends animating values to Interpolator -->
<!-- ROUTE information for AnimationClock node:  [from TextTriggerTouchSensor.touchTime to startTime ] [from fraction_changed to ColorChanger.set_fraction ] -->
<TimeSensor DEF='AnimationClockcycleInterval='6'/>
<!-- ROUTE 1: TouchSensor trigger to TimeSensor clock -->
<ROUTE fromNode='TextTriggerTouchSensorfromField='touchTimetoNode='AnimationClocktoField='startTime'/>
<!-- Interpolator: ColorChanger interpolates evenly between red, green, blue and then back to red -->
<!-- ROUTE information for ColorChanger node:  [from AnimationClock.fraction_changed to set_fraction ] [from value_changed to SphereMaterial.diffuseColor ] -->
<ColorInterpolator DEF='ColorChangerkey='0 0.3333 0.6666 1keyValue='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='AnimationClockfromField='fraction_changedtoNode='ColorChangertoField='set_fraction'/>
<!-- ROUTE 3: Interpolator output is sent to target node of interest. Changed color value is routed to SphereMaterial color. -->
<ROUTE fromNode='ColorChangerfromField='value_changedtoNode='SphereMaterialtoField='diffuseColor'/>

Index for DEF nodes : AnimationClock, ColorChanger, SphereMaterial, TextTriggerTouchSensor

<!-- Color key: <X3dNode DEF='idName' field='value'/> matches <XmlElement DEF='idName' attribute='value'/>
(Light blue background: behavior node) (Grey background: inserted documentation) (Magenta background: X3D Extensibility)

<!-- Additional help information about X3D scenes: X3D Resources, X3D Scene Authoring Hints and X3D Tooltips -->