X3D Model Documentation: ColorInterpolatorExample.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
  3  <X3D profile='Immersive' version='3.3 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.3.xsd'>
  4       <head>
  5            <meta name='titlecontent='ColorInterpolatorExample.x3d'/>
  6            <meta name='descriptioncontent='Demonstrate basic design pattern for animating a node.'/>
  7            <meta name='creatorcontent='Don Brutzman'/>
  8            <meta name='createdcontent='17 April 2005'/>
  9            <meta name='modifiedcontent='20 October 2019'/>
 10            <meta name='drawingcontent='ColorInterpolatorExampleSceneGraphWithRoutes.png'/>
 11            <meta name='Imagecontent='ColorInterpolatorExample4Colors.png'/>
 12            <meta name='subjectcontent='Animation ColorInterpolator'/>
 13            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter07EventAnimationInterpolation/ColorInterpolatorExample.x3d'/>
 14            <meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
 15            <meta name='licensecontent='../license.html'/>
 16       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: AnimationClock, ColorChanger, SphereMaterial, TextTriggerTouchSensor
-->
 17       <Scene>
 18            <WorldInfo title='ColorInterpolatorExample.x3d'/>
 19            <Group>
 20                 <!-- Place triggering text above sphere of interest -->
 21                 <Transform translation='0 2 0'>
 22                      <Shape>
 23                           <Text string='"Touch text to" "start animation..."'>
 24                                <FontStyle justify='"MIDDLE" "MIDDLE"'/>
 25                           </Text>
 26                           <Appearance>
 27                                <Material/>
 28                           </Appearance>
 29                      </Shape>
 30                      <!-- Selectable Text design pattern has transparent Box and TouchSensor description as a tooltip -->
 31                      <Shape>
 32                           <Box size='6.2 2 .001'/>
 33                           <Appearance>
 34                                <Material transparency='1'/>
 35                           </Appearance>
 36                      </Shape>
 37                      <!-- This TouchSensor only reacts to user clicking on the sibling Shape and Text, because it is under a parent Transform grouping node -->
 38 
                    <!-- ROUTE information for TextTriggerTouchSensor node:  [from touchTime to AnimationClock.startTime ] -->
                    <TouchSensor DEF='TextTriggerTouchSensordescription='Touch text to start...'/>
 39                 </Transform>
 40                 <!-- Here is Sphere with accompanying Material that will get animated -->
 41                 <Transform translation='0 -1 0'>
 42                      <Shape>
 43                           <Sphere/>
 44                           <Appearance>
 45                                <!-- SphereMaterial diffuseColor gets overridden by interpolator output -->
 46 
                              <!-- ROUTE information for SphereMaterial node:  [from ColorChanger.value_changed to diffuseColor ] -->
                              <Material DEF='SphereMaterialdiffuseColor='0.5 0.5 0.5'/>
 47                           </Appearance>
 48                      </Shape>
 49                 </Transform>
 50                 <!-- TimeSensor is triggered to start by TouchSensor, then sends animating values to Interpolator -->
 51 
               <!-- ROUTE information for AnimationClock node:  [from TextTriggerTouchSensor.touchTime to startTime ] [from fraction_changed to ColorChanger.set_fraction ] -->
               <TimeSensor DEF='AnimationClockcycleInterval='6'/>
 52                 <!-- ROUTE 1: TouchSensor trigger to TimeSensor clock -->
 53                 < ROUTE  fromNode='TextTriggerTouchSensor' fromField='touchTime' toNode='AnimationClock' toField='startTime'/>
 54                 <!-- Interpolator: ColorChanger interpolates evenly between red, green, blue and then back to red -->
 55 
               <!-- 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'/>
 56                 <!-- ROUTE 2: the ColorChanger interpolator gets stimulated by AnimationClock TimeSensor fraction to compute a color value -->
 57                 < ROUTE  fromNode='AnimationClock' fromField='fraction_changed' toNode='ColorChanger' toField='set_fraction'/>
 58                 <!-- ROUTE 3: Interpolator output is sent to target node of interest. Changed color value is routed to SphereMaterial color. -->
 59                 < ROUTE  fromNode='ColorChanger' fromField='value_changed' toNode='SphereMaterial' toField='diffuseColor'/>
 60            </Group>
 61       </Scene>
 62  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->

<!-- to top Index for DEF nodes: AnimationClock, ColorChanger, SphereMaterial, TextTriggerTouchSensor
-->
X3D Tooltips element index: Appearance, Box, ColorInterpolator, FontStyle, Group, head, Material, meta, ROUTE, Scene, Shape, Sphere, Text, TimeSensor, TouchSensor, Transform, WorldInfo, X3D, accessType and type, XML data types, field types

Event Graph ROUTE Table entries with 3 ROUTE connections total, showing X3D event-model relationships for this scene.

Each row shows an event cascade that may occur during a single timestamp interval between frame renderings, as part of the X3D execution model.

TextTriggerTouchSensor
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
AnimationClock
TimeSensor
startTime
SFTime
then
 
 
 
AnimationClock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(2)
ColorChanger
ColorInterpolator
set_fraction
SFFloat
then
 
 
 
ColorChanger
ColorInterpolator
value_changed
SFColor

ROUTE
event to
(3)
SphereMaterial
Material
diffuseColor
SFColor

Additional guidance on X3D animation can be found in the 10-Step Animation Design Process and Event Tracing hint sheets. Have fun with X3D! 😀

-->
<!-- Online at
https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter07EventAnimationInterpolation/ColorInterpolatorExampleIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter07EventAnimationInterpolation/ColorInterpolatorExample.x3d -->

<!-- Color legend: X3D terminology <X3dNode DEF='idName' field='value'/> matches XML terminology <XmlElement DEF='idName' attribute='value'/>
(Light-blue background: event-based behavior node or statement) (Grey background inside box: inserted documentation) (Magenta background: X3D Extensibility)
-->

to top <!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->