<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://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 =' https://www.web3d.org/specifications/x3d-3.3.xsd ' >
<head>
<meta name='titlecontent=' ShuttlesAndPendulums.x3d '/>
<meta name='descriptioncontent='X3D encodings example: animation of shuttle and pendulum prototype nodes.'/>
<meta name='creatorcontent='Don Brutzman and Joe Williams'/>
<meta name='createdcontent='1 June 2002'/>
<meta name='modifiedcontent='28 October 2019'/>
<meta name='specificationSectioncontent=' X3D encodings, ISO/IEC 19776-1.3, Part 1: XML encoding, Annex C.14 Shuttles and pendulums'/>
<meta name='specificationUrlcontent=' https://www.web3d.org/documents/specifications/19776-1/V3.3/Part01/examples.html#ShuttlesAndPendulums '/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/ShuttlesAndPendulums.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: F, FF, I, II, S, SS, T, TT

Index for ProtoDeclare definitions: Pendulum, Shuttle
-->
<Scene>
<WorldInfo title='ShuttlesAndPendulums.x3d'/>
<ProtoDeclare name='Shuttle'>
<ProtoInterface>
<field name='ratetype='SFTimevalue='1accessType='initializeOnly'/>
<field name='distancetype='SFFloatvalue='1accessType='initializeOnly'/>
<field name='childrentype='MFNodeaccessType='initializeOnly'>
<!-- initial value is empty node array -->
</field>
<field name='startTimetype='SFTimevalue='0accessType='inputOutput'/>
<field name='stopTimetype='SFTimevalue='0accessType='inputOutput'/>
<field name='looptype='SFBoolvalue='trueaccessType='initializeOnly'/>
</ProtoInterface>
<ProtoBody>
<!-- ROUTE information for F node:  [from I.value_changed to translation ] -->
<Transform DEF='F'>
<IS>
<connect nodeField='childrenprotoField='children'/>
</IS>
</Transform>
<!-- after first node in ProtoDeclare, remainder of nodes do not render -->
<!-- ROUTE information for T node:  [from fraction_changed to I.set_fraction ] -->
<TimeSensor DEF='T'>
<IS>
<connect nodeField='cycleIntervalprotoField='rate'/>
<connect nodeField='startTimeprotoField='startTime'/>
<connect nodeField='stopTimeprotoField='stopTime'/>
<connect nodeField='loopprotoField='loop'/>
</IS>
</TimeSensor>
<!-- ROUTE information for S node:  [from position to I.keyValue ] -->
<Script DEF='S'>
<field name='distancetype='SFFloataccessType='initializeOnly'/>
<field name='positiontype='MFVec3faccessType='outputOnly'/>
<IS>
<connect nodeField='distanceprotoField='distance'/>
</IS>
<![CDATA[
          
ecmascript:
            function initialize () {     // constructor:setup interpolator
              pos1 = new SFVec3f(-distance, 0, 0);
              pos2 = new SFVec3f(distance, 0, 0);
              position = new MFVec3f(pos1, pos2, pos1);
            }

        
]]>
</Script>
<!-- ROUTE information for I node:  [from T.fraction_changed to set_fraction ] [from S.position to keyValue ] [from value_changed to F.translation ] -->
<PositionInterpolator DEF='Ikey='0 0.5 1keyValue='-1 0 0 1 0 0 -1 0 0'/>

< ROUTE  fromNode=' T' fromField='fraction_changed' toNode=' I' toField='set_fraction'/>
< ROUTE  fromNode=' I' fromField='value_changed' toNode=' F' toField='translation'/>
< ROUTE  fromNode=' S' fromField='position' toNode=' I' toField='keyValue'/>
</ProtoBody>
</ProtoDeclare>
<ProtoDeclare name='Pendulum'>
<ProtoInterface>
<field name='ratetype='SFTimevalue='1accessType='initializeOnly'/>
<field name='maxAngletype='SFFloatvalue='3.14159accessType='initializeOnly'/>
<field name='childrentype='MFNodeaccessType='initializeOnly'>
<!-- initial value is empty node array -->
</field>
<field name='startTimetype='SFTimevalue='0accessType='inputOutput'/>
<field name='stopTimetype='SFTimevalue='0accessType='inputOutput'/>
<field name='looptype='SFBoolvalue='trueaccessType='initializeOnly'/>
</ProtoInterface>
<ProtoBody>
<!-- ROUTE information for FF node:  [from II.value_changed to rotation ] -->
<Transform DEF='FF'>
<IS>
<connect nodeField='childrenprotoField='children'/>
</IS>
</Transform>
<!-- after first node in ProtoDeclare, remainder of nodes do not render -->
<!-- ROUTE information for TT node:  [from fraction_changed to II.set_fraction ] -->
<TimeSensor DEF='TT'>
<IS>
<connect nodeField='cycleIntervalprotoField='rate'/>
<connect nodeField='startTimeprotoField='startTime'/>
<connect nodeField='stopTimeprotoField='stopTime'/>
<connect nodeField='loopprotoField='loop'/>
</IS>
</TimeSensor>
<!-- ROUTE information for SS node:  [from rotation to II.keyValue ] -->
<Script DEF='SS'>
<field name='maxAngletype='SFFloataccessType='initializeOnly'/>
<field name='rotationtype='MFRotationaccessType='outputOnly'/>
<IS>
<connect nodeField='maxAngleprotoField='maxAngle'/>
</IS>
<![CDATA[
          
ecmascript:
            function initialize() {     // constructor: setup interpolator
              rot1 = new SFRotation(0, 0, 1, 0);
              rot2 = new SFRotation(0, 0, 1, maxAngle/2);
              rot3 = new SFRotation(0, 0, 1, maxAngle);
              rotation = new MFRotation(rot1, rot2, rot3, rot2, rot1);
            }

        
]]>
</Script>
<!-- ROUTE information for II node:  [from TT.fraction_changed to set_fraction ] [from SS.rotation to keyValue ] [from value_changed to FF.rotation ] -->
<OrientationInterpolator DEF='IIkey='0 0.25 0.5 0.75 1keyValue='0 0 1 0 0 0 1 1.57 0 0 1 3.14 0 0 1 1.57 0 0 1 0'/>

< ROUTE  fromNode=' TT' fromField='fraction_changed' toNode=' II' toField='set_fraction'/>
< ROUTE  fromNode=' II' fromField='value_changed' toNode=' FF' toField='rotation'/>
< ROUTE  fromNode=' SS' fromField='rotation' toNode=' II' toField='keyValue'/>
</ProtoBody>
</ProtoDeclare>
<Transform translation='-3 0 0'>
<ProtoInstance name='Pendulum'>
<fieldValue name='ratevalue='3'/>
<fieldValue name='maxAnglevalue='6.28'/>
<fieldValue name='children'>
<Shape>
<Cylinder height='5'/>
<Appearance>
<Material diffuseColor='0.8 0.1 0'/>
</Appearance>
</Shape>
</fieldValue>
</ProtoInstance>
</Transform>
<Transform>
<ProtoInstance name='Shuttle'>
<fieldValue name='ratevalue='2'/>
<fieldValue name='children'>
<Shape>
<Sphere/>
<Appearance>
<Material diffuseColor='0.1 0.8 0'/>
</Appearance>
</Shape>
</fieldValue>
</ProtoInstance>
</Transform>
</Scene>
</X3D>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: F, FF, I, II, S, SS, T, TT

Index for ProtoDeclare definitions: Pendulum, Shuttle
-->

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

T
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(1)
I
PositionInterpolator
set_fraction
SFFloat

 
 
then
I
PositionInterpolator
value_changed
SFVec3f

ROUTE
event to
(2)
F
Transform
translation
SFVec3f


TT
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(1)
II
OrientationInterpolator
set_fraction
SFFloat

 
 
then
II
OrientationInterpolator
value_changed
SFRotation

ROUTE
event to
(2)
FF
Transform
rotation
SFRotation


S
Script
position
SFVec3f

ROUTE
event to
(1)
I
PositionInterpolator
keyValue
MFVec3f

 
 
then
I
PositionInterpolator
value_changed
SFVec3f

ROUTE
event to
(2)
F
Transform
translation
SFVec3f


SS
Script
rotation
SFRotation

ROUTE
event to
(1)
II
OrientationInterpolator
keyValue
MFRotation

 
 
then
II
OrientationInterpolator
value_changed
SFRotation

ROUTE
event to
(2)
FF
Transform
rotation
SFRotation



ProtoInstance
Pendulum
No ROUTE connection found for output from this node.
Contains SFNode/MFNode field with indirect access to other nodes. 



ProtoInstance
Shuttle
No ROUTE connection found for output from this node.
Contains SFNode/MFNode field with indirect access to other nodes. 


-->

<!-- Online at
https://www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/ShuttlesAndPendulumsIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/Basic/X3dSpecifications/ShuttlesAndPendulums.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)
    <ProtoInstance name='ProtoName'> <field name='fieldName'/> </ProtoInstance> -->

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