X3D Model Documentation: EventGraphLoopTest.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 4.0//EN" "https://www.web3d.org/specifications/x3d-4.0.dtd">
  3  <X3D profile='Immersive' version='4.0 xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-4.0.xsd'>
  4       <head>
  5            <meta name='titlecontent='EventGraphLoopTest.x3d'/>
  6            <meta name='descriptioncontent='Diagnostic scene for tools to test event-graph loop detection'/>
  7            <meta name='creatorcontent='Don Brutzman'/>
  8            <meta name='createdcontent='4 February 2024'/>
  9            <meta name='modifiedcontent='4 May 2024'/>
 10            <meta name=' warning content=' includes intentional event loop '/>
 11            <meta name='referencecontent='https://www.web3d.org/x3d/stylesheets/X3dToXhtml.xslt'/>
 12            <meta name='referencecontent='EventGraphLoopTestConsoleLog.txt'/>
 13            <meta name='referencecontent='EventGraphLoopTestIndex.html'/>
 14            <meta name='specificationSectioncontent='X3D 4.0 Architecture, ISO/IEC 19775-1:2023, 4 Concepts, 4.4.8.4 Loops'/>
 15            <meta name='specificationUrlcontent='https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/concepts.html#Loops'/>
 16            <meta name='subjectcontent='X3D event graph loop detection'/>
 17            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/Animation/EventGraphLoopTest.x3d'/>
 18            <meta name='generatorcontent='X3D-Edit 4.0, https://savage.nps.edu/X3D-Edit'/>
 19            <meta name='licensecontent='../license.html'/>
 20       </head>
<!--

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

<!-- to top Index for DEF nodes: BoldFontStyle, Clock1, Clock2, Clock3, ClockReporter, LoopCounterText, LoopCounterTextShape, LoopCounterTransform, RotatingTransform, SpinnableTextShape, Spinner, TextAppearance
-->
 21       <Scene>
 22            <WorldInfo title='EventGraphLoopTest.x3d'/>
 23            <Background skyColor='1 1 0.858824'/>
 24 
          <!-- TimeSensor Clock1 is a DEF node that has 1 USE node: USE_1
          <!-- ROUTE information for Clock1 node:  [from Clock3.cycleTime to startTime ] [from cycleTime to Clock2.startTime ] -->
          <TimeSensor DEF='Clock1cycleInterval='8loop='true'/>
 25 
          <!-- ROUTE information for Clock2 node:  [from Clock1.cycleTime to startTime ] [from cycleTime to Clock3.startTime ] -->
          <TimeSensor DEF='Clock2cycleInterval='2'/>
 26 
          <!-- ROUTE information for Clock3 node:  [from Clock2.cycleTime to startTime ] [from cycleTime to Clock1.startTime ] [from cycleTime to ClockReporter.clockStart3 ] [from fraction_changed to Spinner.set_fraction ] -->
          <TimeSensor DEF='Clock3cycleInterval='2'/>
 27            < ROUTE  fromNode='Clock1' fromField='cycleTime' toNode='Clock2' toField='startTime'/>
 28            < ROUTE  fromNode='Clock2' fromField='cycleTime' toNode='Clock3' toField='startTime'/>
 29            < ROUTE  fromNode='Clock3' fromField='cycleTime' toNode='Clock1' toField='startTime'/>
 30 
          <!-- ROUTE information for ClockReporter node:  [from Clock3.cycleTime to clockStart3 ] [from loopCounterString to LoopCounterText.string ] -->
          <Script DEF='ClockReporter'>
 31                 <field name='clockStart1type='SFTimevalue='-1accessType='inputOutput'/>
 32                 <field name='clockStart2type='SFTimevalue='-1accessType='inputOutput'/>
 33                 <field name='clockStart3type='SFTimevalue='-1accessType='inputOutput'/>
 34                 <field name='handleClock1type='SFNodeaccessType='inputOutput'
                appinfo='enable indirect contol of node by this Script'>
 35                      <TimeSensor USE='Clock1'/>
 36                 </field>
 37                 <field name='loopCountertype='SFInt32value='0accessType='inputOutput'
                appinfo='loop count'/>
 38                 <field name='loopCounterStringtype='MFStringaccessType='outputOnly'
                appinfo='display latest loop count'/>
  <![CDATA[
      
ecmascript:


function initialize()
{
    Browser.println ('[Script ClockReporter] initialize()');
}

function clockStart1 (eventValue)
{
    // input eventValue received for inputOutput field
    clockStart1 = eventValue;
    Browser.println ('[Script ClockReporter] clockStart1(' + eventValue + ')');
}

function clockStart2 (eventValue)
{
    // input eventValue received for inputOutput field
    clockStart2 = eventValue;
    Browser.println ('[Script ClockReporter] clockStart2(' + eventValue + ')');
}

function clockStart3 (eventValue)
{
    // input eventValue received for inputOutput field
    clockStart3 = eventValue;
    loopCounter++;
    // send single-line MFString output event to Text node's string field
    loopCounterString = new MFString('loop ' + loopCounter);
    Browser.println ('[Script ClockReporter] clockStart3(' + eventValue + ') received event to start text spinning');
}

    
]]>
 40            </Script>
 41            < ROUTE  fromNode='Clock3' fromField='cycleTime' toNode='ClockReporter' toField='clockStart3'/>
 42            <!-- debug <ROUTE fromField='cycleTime' fromNode='Clock1' toField='clockStart1' toNode='ClockReporter'/> <ROUTE fromField='cycleTime' fromNode='Clock2' toField='clockStart2' toNode='ClockReporter'/> -->
 43 
          <!-- ROUTE information for RotatingTransform node:  [from Spinner.value_changed to rotation ] -->
          <Transform DEF='RotatingTransformtranslation='0 1 0'>
 44                 <Shape DEF='SpinnableTextShape'>
 45                      <Text string='"EventGraphLoopTest" "includes a" "three-ROUTE event loop"'>
 46 
                         <!-- FontStyle BoldFontStyle is a DEF node that has 1 USE node: USE_1 -->
                         <FontStyle DEF='BoldFontStylefamily='"SANS"justify='"MIDDLE" "MIDDLE"size='0.8style='BOLD'/>
 47                      </Text>
 48 
                    <!-- Appearance TextAppearance is a DEF node that has 1 USE node: USE_1 -->
                    <Appearance DEF='TextAppearance'>
 49                           <Material diffuseColor='1 0.4 0.2'/>
 50                      </Appearance>
 51                 </Shape>
 52            </Transform>
 53            <Transform DEF='LoopCounterTransformscale='0.8 0.8 0.8translation='0 -1.5 0'>
 54                 <Shape DEF='LoopCounterTextShape'>
 55 
                    <!-- ROUTE information for LoopCounterText node:  [from ClockReporter.loopCounterString to string ] -->
                    <Text DEF='LoopCounterTextstring='"loop 0"'>
 56                           <FontStyle USE='BoldFontStyle'/>
 57                      </Text>
 58                      <Appearance USE='TextAppearance'/>
 59                 </Shape>
 60            </Transform>
 61            < ROUTE  fromNode='ClockReporter' fromField='loopCounterString' toNode='LoopCounterText' toField='string'/>
 62 
          <!-- ROUTE information for Spinner node:  [from Clock3.fraction_changed to set_fraction ] [from value_changed to RotatingTransform.rotation ] -->
          <OrientationInterpolator DEF='Spinnerkey='0 0.3333 0.6667 1keyValue='0 1 0 0 0 1 0 2.094395 0 1 0 4.18879 0 1 0 0'/>
 63            < ROUTE  fromNode='Clock3' fromField='fraction_changed' toNode='Spinner' toField='set_fraction'/>
 64            < ROUTE  fromNode='Spinner' fromField='value_changed' toNode='RotatingTransform' toField='rotation'/>
 65       </Scene>
 66  </X3D>
<!--

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

<!-- to top Index for DEF nodes: BoldFontStyle, Clock1, Clock2, Clock3, ClockReporter, LoopCounterText, LoopCounterTextShape, LoopCounterTransform, RotatingTransform, SpinnableTextShape, Spinner, TextAppearance
-->
X3D Tooltips element index: Appearance, Background, field, FontStyle, head, Material, meta, OrientationInterpolator, ROUTE, Scene, Script, Shape, Text, TimeSensor, Transform, WorldInfo, X3D, accessType and type, XML data types, field types

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

      ClockReporter
Script
loopCounterString
MFString

ROUTE
event to
(1)
LoopCounterText
Text
string
MFString
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/X3dForAdvancedModeling/Animation/EventGraphLoopTestIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/Animation/EventGraphLoopTest.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. -->