| 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='title' content=' PositionOrientationInterpolatorsExampleTraced.x3d '/> |
| 6 | <meta name='description' content='Demonstrate use of PositionInterpolator and OrientationInterpolator to animate object motion, with console output tracing added for PositionInterpolator and ROUTE events.'/> |
| 7 | <meta name='creator' content='Don Brutzman'/> |
| 8 | <meta name='created' content='5 August 2011'/> |
| 9 | <meta name='modified' content='8 September 2024'/> |
| 10 | <meta name='reference' content=' Chapter07EventAnimationInterpolation-EventTracing.pdf '/> |
| 11 | <meta name='reference' content=' Chapter07EventAnimationInterpolation-10StepAnimationDesignProcess.pdf '/> |
| 12 | <meta name='reference' content=' PositionOrientationInterpolatorsExampleTracedConsole.txt '/> |
| 13 | <meta name='MovingImage' content=' PositionOrientationInterpolatorsExample.mp4 '/> |
| 14 | <meta name='reference' content=' PositionOrientationInterpolatorsExample.x3d '/> |
| 15 | <meta name='reference' content='https://X3dGraphics.com'/> |
| 16 | <meta name='reference' content=' https://www.web3d.org/x3d/content/examples/X3dResources.html '/> |
| 17 | <meta name='rights' content='Copyright Don Brutzman and Leonard Daly 2007'/> |
| 18 | <meta name='subject' content='X3D book, X3D graphics, X3D-Edit, http://www.x3dGraphics.com'/> |
| 19 | <meta name='reference' content=' https://savage.nps.edu/Savage/Tools/Animation/WaypointInterpolatorExample.x3d '/> |
| 20 | <meta name='identifier' content=' https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter07EventAnimationInterpolation/PositionOrientationInterpolatorsExampleTraced.x3d '/> |
| 21 | <meta name='generator' content='X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit'/> |
| 22 | <meta name='license' content='../license.html'/> |
| 23 | </head> |
| 24 | <Scene> |
| 25 | <WorldInfo title='PositionOrientationInterpolatorsExampleTraced.x3d'/> |
| 26 | <Viewpoint description='Animation demo' orientation='1 0 0 -0.588003' position='0 8 12'/> |
| 27 | <Viewpoint centerOfRotation='5 0.1 5' description='View from above' orientation='1 0 0 -1.570796' position='0 15 0'/> |
| 28 |
<!-- ROUTE information for Pointer node:
[from PositionAnimator.value_changed to translation
]
[from OrientationAnimator.value_changed to set_rotation
]
-->
<Transform DEF='Pointer' translation='1 0 1'> |
| 29 | <Transform rotation='1 0 0 1.57'> |
| 30 | <Shape> |
| 31 | <Cone bottomRadius='0.5' height='1.5'/> |
| 32 | <Appearance> |
| 33 | <Material DEF='ConeMaterial' diffuseColor='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 |
<!-- ROUTE information for PositionAnimator node:
[from AnimationClock.fraction_changed to set_fraction
]
[from value_changed to Trace_ROUTE_PositionInterpolator_PositionAnimator.value_changed
]
[from key to Trace_ROUTE_PositionInterpolator_PositionAnimator.key
]
[from keyValue to Trace_ROUTE_PositionInterpolator_PositionAnimator.keyValue
]
[from value_changed to Pointer.translation
]
[from value_changed to Trace_ROUTE_PositionAnimator_value_changed_TO_Pointer_translation.traceValue
]
-->
<PositionInterpolator DEF='PositionAnimator' key='0 0.2 0.25 0.45 0.5 0.7 0.75 0.95 1' keyValue='-4 0 -4 -4 0 4 -4 0 4 4 0 4 4 0 4 4 0 -4 4 0 -4 -4 0 -4 -4 0 -4'/> |
| 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_PositionAnimator' mustEvaluate='true'> |
| 50 |
<field name='reportInterval' type='SFTime' value='1.0' accessType='initializeOnly'
appinfo='Sampling frequency in seconds (0 means all values)'/> |
| 51 | <!-- Trace ROUTEd values on X3D browser console --> |
| 52 | <field name='value_changed' type='SFVec3f' accessType='inputOnly'/> |
| 53 | <field name='key' type='MFFloat' accessType='inputOnly'/> |
| 54 | <field name='keyValue' type='MFVec3f' accessType='inputOnly'/> |
| 55 | <field name='timeStampPreviousReport' type='SFTime' value='-1' accessType='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_translation' mustEvaluate='true'> |
| 67 | <!-- Trace ROUTEd values on X3D browser console --> |
| 68 |
<field name='reportInterval' type='SFTime' value='1.0' accessType='initializeOnly'
appinfo='Sampling frequency in seconds (0 means all values)'/> |
| 69 | <field name='traceValue' type='SFVec3f' accessType='inputOnly'/> |
| 70 | <field name='timeStampPreviousReport' type='SFTime' value='-1' accessType='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='OrientationAnimator' key='0 0.2 0.25 0.45 0.5 0.7 0.75 0.95 1' keyValue='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 |
<!-- ROUTE information for AnimationClock node:
[from fraction_changed to PositionAnimator.set_fraction
]
[from fraction_changed to Trace_ROUTE_AnimationClock_fraction_changed_TO_PositionAnimator_set_fraction.traceValue
]
[from fraction_changed to OrientationAnimator.set_fraction
]
-->
<TimeSensor DEF='AnimationClock' cycleInterval='10' loop='true'/> |
| 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_fraction' mustEvaluate='true'> |
| 86 | <!-- Trace ROUTEd values on X3D browser console --> |
| 87 |
<field name='reportInterval' type='SFTime' value='1.0' accessType='initializeOnly'
appinfo='Sampling frequency in seconds (0 means all values)'/> |
| 88 | <field name='traceValue' type='SFFloat' accessType='inputOnly'/> |
| 89 | <field name='timeStampPreviousReport' type='SFTime' value='-1' accessType='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 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.
<!--
Color-coding 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)
-->
<!--
For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints.
-->