X3D Model Documentation: PositionOrientationInterpolatorsExampleTraced.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='PositionOrientationInterpolatorsExampleTraced.x3d'/>
  6            <meta name='descriptioncontent='Demonstrate use of PositionInterpolator and OrientationInterpolator to animate object motion, with console output tracing added for PositionInterpolator and ROUTE events.'/>
  7            <meta name='creatorcontent='Don Brutzman'/>
  8            <meta name='createdcontent='5 August 2011'/>
  9            <meta name='modifiedcontent='8 September 2024'/>
 10            <meta name='referencecontent='Chapter07EventAnimationInterpolation-EventTracing.pdf'/>
 11            <meta name='referencecontent='Chapter07EventAnimationInterpolation-10StepAnimationDesignProcess.pdf'/>
 12            <meta name='referencecontent='PositionOrientationInterpolatorsExampleTracedConsole.txt'/>
 13            <meta name='MovingImagecontent='PositionOrientationInterpolatorsExample.mp4'/>
 14            <meta name='referencecontent='PositionOrientationInterpolatorsExample.x3d'/>
 15            <meta name='referencecontent='https://X3dGraphics.com'/>
 16            <meta name='referencecontent='https://www.web3d.org/x3d/content/examples/X3dResources.html'/>
 17            <meta name='rightscontent='Copyright Don Brutzman and Leonard Daly 2007'/>
 18            <meta name='subjectcontent='X3D book, X3D graphics, X3D-Edit, http://www.x3dGraphics.com'/>
 19            <meta name='referencecontent='https://savage.nps.edu/Savage/Tools/Animation/WaypointInterpolatorExample.x3d'/>
 20            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter07EventAnimationInterpolation/PositionOrientationInterpolatorsExampleTraced.x3d'/>
 21            <meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
 22            <meta name='licensecontent='../license.html'/>
 23       </head>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: AnimationClock, ConeMaterial, Floor, OrientationAnimator, Pointer, PositionAnimator, Trace_ROUTE_AnimationClock_fraction_changed_TO_PositionAnimator_set_fraction, Trace_ROUTE_PositionAnimator_value_changed_TO_Pointer_translation, Trace_ROUTE_PositionInterpolator_PositionAnimator

Index for Viewpoint nodes: Viewpoint_1, Viewpoint_2
-->
 24       <Scene>
 25            <WorldInfo title='PositionOrientationInterpolatorsExampleTraced.x3d'/>
 26            <Viewpoint description='Animation demoorientation='1 0 0 -0.588003position='0 8 12'/>
 27            <Viewpoint centerOfRotation='5 0.1 5description='View from aboveorientation='1 0 0 -1.570796position='0 15 0'/>
 28 
          <!-- ROUTE information for Pointer node:  [from PositionAnimator.value_changed to translation ] [from OrientationAnimator.value_changed to set_rotation ] -->
          <Transform DEF='Pointertranslation='1 0 1'>
 29                 <Transform rotation='1 0 0 1.57'>
 30                      <Shape>
 31                           <Cone bottomRadius='0.5height='1.5'/>
 32                           <Appearance>
 33                                <Material DEF='ConeMaterialdiffuseColor='0.427451 1 0.160784'/>
 34                           </Appearance>
 35                      </Shape>
 36                 </Transform>
 37            </Transform>
 38            <Shape DEF='Floor'>
 39                 <Box size='12 0.05 12'/>
 40                 <Appearance>
 41                      <Material diffuseColor='0 0.262745 0.941176'/>
 42                 </Appearance>
 43            </Shape>
 44            <!-- note that final value equals first value in keyValue array in order to support smooth looping -->
 45            <!-- first drive around the location -->
 46 
 47            <Group>
 48                 <!-- ======= PositionInterpolator Trace ============================================== -->
 49 
               <!-- ROUTE information for Trace_ROUTE_PositionInterpolator_PositionAnimator node:  [from PositionAnimator.value_changed to value_changed ] [from PositionAnimator.key to key ] [from PositionAnimator.keyValue to keyValue ] -->
               <Script DEF='Trace_ROUTE_PositionInterpolator_PositionAnimatormustEvaluate='true'>
 50                      <field name='reportIntervaltype='SFTimevalue='1.0accessType='initializeOnly'
                     appinfo='Sampling frequency in seconds (0 means all values)'/>
 51                      <!-- Trace ROUTEd values on X3D browser console -->
 52                      <field name='value_changedtype='SFVec3faccessType='inputOnly'/>
 53                      <field name='keytype='MFFloataccessType='inputOnly'/>
 54                      <field name='keyValuetype='MFVec3faccessType='inputOnly'/>
 55                      <field name='timeStampPreviousReporttype='SFTimevalue='-1accessType='initializeOnly'/>
  <![CDATA[
        
ecmascript:
    function value_changed (eventValue, timeStamp) {
      if (timeStamp - timeStampPreviousReport >= reportInterval) {
        Browser.println ('Trace_ROUTE_PositionInterpolator_PositionAnimator type=SFVec3f value_changed=' + eventValue.toString());
        timeStampPreviousReport = timeStamp;
      }
    }
    function key (eventValue) {
      Browser.println ('Trace_ROUTE_PositionInterpolator_PositionAnimator type=MFFloat key=' + eventValue.toString());
    }
    function keyValue (eventValue) {
      Browser.println ('Trace_ROUTE_PositionInterpolator_PositionAnimator type=MFVec3f keyValue=' + eventValue.toString());
    }

      
]]>
 57                 </Script>
 58                 < ROUTE  fromNode='PositionAnimator' fromField='value_changed' toNode='Trace_ROUTE_PositionInterpolator_PositionAnimator' toField='value_changed'/>
 59                 < ROUTE  fromNode='PositionAnimator' fromField='key' toNode='Trace_ROUTE_PositionInterpolator_PositionAnimator' toField='key'/>
 60                 < ROUTE  fromNode='PositionAnimator' fromField='keyValue' toNode='Trace_ROUTE_PositionInterpolator_PositionAnimator' toField='keyValue'/>
 61                 <!-- ======= PositionInterpolator Trace block complete ===================================================== -->
 62            </Group>
 63            < ROUTE  fromNode='PositionAnimator' fromField='value_changed' toNode='Pointer' toField='translation'/>
 64            <Group>
 65                 <!-- ======= ROUTE Trace ============================================== -->
 66 
               <!-- ROUTE information for Trace_ROUTE_PositionAnimator_value_changed_TO_Pointer_translation node:  [from PositionAnimator.value_changed to traceValue ] -->
               <Script DEF='Trace_ROUTE_PositionAnimator_value_changed_TO_Pointer_translationmustEvaluate='true'>
 67                      <!-- Trace ROUTEd values on X3D browser console -->
 68                      <field name='reportIntervaltype='SFTimevalue='1.0accessType='initializeOnly'
                     appinfo='Sampling frequency in seconds (0 means all values)'/>
 69                      <field name='traceValuetype='SFVec3faccessType='inputOnly'/>
 70                      <field name='timeStampPreviousReporttype='SFTimevalue='-1accessType='initializeOnly'/>
  <![CDATA[
        
ecmascript:
    function traceValue (eventValue, timeStamp) {
      // input eventValue received for trace field
      if (timeStamp - timeStampPreviousReport >= reportInterval) {
        Browser.println ('Trace_ROUTE_PositionAnimator_value_changed_TO_Pointer_translation type=SFVec3f value=' + eventValue.toString());
        timeStampPreviousReport = timeStamp;
      }
    }
    function timeOfDay (someTime) {
      hh = Math.floor (someTime /(60*60)) % 24;
      mm = Math.floor (someTime / 60)     % 60;
      ss = Math.floor (someTime)          % 60;
      if (hh < 9) hour   = '0' + hh;
      else        hour   =       hh;
      if (mm < 9) minute = '0' + mm;
      else        minute =       mm;
      if (ss < 9) second = '0' + ss;
      else        second =       ss;
      return '(' + hour + ':' + minute + ':' + second + ' GMT)';
    }

      
]]>
 72                 </Script>
 73                 < ROUTE  fromNode='PositionAnimator' fromField='value_changed' toNode='Trace_ROUTE_PositionAnimator_value_changed_TO_Pointer_translation' toField='traceValue'/>
 74                 <!-- ======= ROUTE Trace block complete ===================================================== -->
 75            </Group>
 76            <!-- then rotate the pointer to match next direction while paused at each position -->
 77 
          <!-- ROUTE information for OrientationAnimator node:  [from AnimationClock.fraction_changed to set_fraction ] [from value_changed to Pointer.set_rotation ] -->
          <OrientationInterpolator DEF='OrientationAnimatorkey='0 0.2 0.25 0.45 0.5 0.7 0.75 0.95 1keyValue='0 1 0 0 0 1 0 0 0 1 0 1.57 0 1 0 1.57 0 1 0 3.14 0 1 0 3.14 0 1 0 4.71 0 1 0 4.71 0 1 0 6.283'/>
 78            <!-- final rotation value is 2pi rather than 0 so that rotation animation is smooth, not flip-flopping -->
 79            < ROUTE  fromNode='OrientationAnimator' fromField='value_changed' toNode='Pointer' toField='set_rotation'/>
 80            <!-- put TimeSensor clock last so that animation design pattern and ROUTE events flow upward -->
 81 
 82            < ROUTE  fromNode='AnimationClock' fromField='fraction_changed' toNode='PositionAnimator' toField='set_fraction'/>
 83            <Group>
 84                 <!-- ======= ROUTE Trace ============================================== -->
 85 
               <!-- ROUTE information for Trace_ROUTE_AnimationClock_fraction_changed_TO_PositionAnimator_set_fraction node:  [from AnimationClock.fraction_changed to traceValue ] -->
               <Script DEF='Trace_ROUTE_AnimationClock_fraction_changed_TO_PositionAnimator_set_fractionmustEvaluate='true'>
 86                      <!-- Trace ROUTEd values on X3D browser console -->
 87                      <field name='reportIntervaltype='SFTimevalue='1.0accessType='initializeOnly'
                     appinfo='Sampling frequency in seconds (0 means all values)'/>
 88                      <field name='traceValuetype='SFFloataccessType='inputOnly'/>
 89                      <field name='timeStampPreviousReporttype='SFTimevalue='-1accessType='initializeOnly'/>
  <![CDATA[
        
ecmascript:
    function traceValue (eventValue, timeStamp) {
      // input eventValue received for trace field
      if (timeStamp - timeStampPreviousReport >= reportInterval) {
        Browser.println ('Trace_ROUTE_AnimationClock_fraction_changed_TO_PositionAnimator_set_fraction type=SFFloat value=' + eventValue);
        timeStampPreviousReport = timeStamp;
      }
    }
    function timeOfDay (someTime) {
      hh = Math.floor (someTime /(60*60)) % 24;
      mm = Math.floor (someTime / 60)     % 60;
      ss = Math.floor (someTime)          % 60;
      if (hh < 9) hour   = '0' + hh;
      else        hour   =       hh;
      if (mm < 9) minute = '0' + mm;
      else        minute =       mm;
      if (ss < 9) second = '0' + ss;
      else        second =       ss;
      return '(' + hour + ':' + minute + ':' + second + ' GMT)';
    }

      
]]>
 91                 </Script>
 92                 < ROUTE  fromNode='AnimationClock' fromField='fraction_changed' toNode='Trace_ROUTE_AnimationClock_fraction_changed_TO_PositionAnimator_set_fraction' toField='traceValue'/>
 93                 <!-- ======= ROUTE Trace block complete ===================================================== -->
 94            </Group>
 95            < ROUTE  fromNode='AnimationClock' fromField='fraction_changed' toNode='OrientationAnimator' toField='set_fraction'/>
 96            <!-- notice that explanatory Text is placed later in scene although it is graphically located above driving plane -->
 97            <Transform translation='0 4 0'>
 98                 <Billboard axisOfRotation='0 0 0'>
 99                      <Shape>
100                           <Text string='"Animation using PositionInterpolator" "and OrientationInterpolator"'>
101                                <FontStyle justify='"MIDDLE" "MIDDLE"size='0.6'/>
102                           </Text>
103                           <Appearance>
104                                <Material/>
105                           </Appearance>
106                      </Shape>
107                 </Billboard>
108            </Transform>
109       </Scene>
110  </X3D>
<!--

<!--
Event Graph ROUTE Table shows event connections.
-->
<!-- to top Index for DEF nodes: AnimationClock, ConeMaterial, Floor, OrientationAnimator, Pointer, PositionAnimator, Trace_ROUTE_AnimationClock_fraction_changed_TO_PositionAnimator_set_fraction, Trace_ROUTE_PositionAnimator_value_changed_TO_Pointer_translation, Trace_ROUTE_PositionInterpolator_PositionAnimator

Index for Viewpoint nodes: Viewpoint_1, Viewpoint_2
-->
X3D Tooltips element index: Appearance, Billboard, Box, Cone, field, FontStyle, Group, head, Material, meta, OrientationInterpolator, PositionInterpolator, ROUTE, Scene, Script, Shape, Text, TimeSensor, Transform, Viewpoint, WorldInfo, X3D, plus documentation for accessType definitions, type definitions, XML data types, and field types

Event Graph ROUTE Table entries with 9 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.

AnimationClock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(1)
PositionAnimator
PositionInterpolator
set_fraction
SFFloat
then
 
 
 
PositionAnimator
PositionInterpolator
key
MFFloat

ROUTE
event to
(2)
Trace_ROUTE_PositionInterpolator_PositionAnimator
Script
key
MFFloat
  then
 
 
 
PositionAnimator
PositionInterpolator
keyValue
MFVec3f

ROUTE
event to
(2)
Trace_ROUTE_PositionInterpolator_PositionAnimator
Script
keyValue
MFVec3f
  then
 
 
 
PositionAnimator
PositionInterpolator
value_changed
SFVec3f

ROUTE
event to
(2)
Trace_ROUTE_PositionInterpolator_PositionAnimator
Script
value_changed
SFVec3f
  then
 
 
 
PositionAnimator
PositionInterpolator
value_changed
SFVec3f

ROUTE
event to
(2)
Pointer
Transform
translation
SFVec3f
  then
 
 
 
PositionAnimator
PositionInterpolator
value_changed
SFVec3f

ROUTE
event to
(2)
Trace_ROUTE_PositionAnimator_value_changed_TO_Pointer_translation
Script
traceValue
SFVec3f
AnimationClock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(1)
Trace_ROUTE_AnimationClock_fraction_changed_TO_PositionAnimator_set_fraction
Script
traceValue
SFFloat
AnimationClock
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(1)
OrientationAnimator
OrientationInterpolator
set_fraction
SFFloat
then
 
 
 
OrientationAnimator
OrientationInterpolator
value_changed
SFRotation

ROUTE
event to
(2)
Pointer
Transform
set_rotation
SFRotation


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/PositionOrientationInterpolatorsExampleTracedIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter07EventAnimationInterpolation/PositionOrientationInterpolatorsExampleTraced.x3d -->

<!-- Color-coding legend: X3D terminology <X3dNode  DEF='idNamefield='value'/> matches XML terminology <XmlElement  DEF='idNameattribute='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. -->