<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 4.0//EN" "https://www.web3d.org/specifications/x3d-4.0.dtd">
<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 ' >
<head>
<meta name='titlecontent=' EventGraphLoopTest.x3d '/>
<meta name='descriptioncontent='Diagnostic scene for tools to test event-graph loop detection'/>
<meta name='creatorcontent='Don Brutzman'/>
<meta name='createdcontent='4 February 2024'/>
<meta name='modifiedcontent='3 May 2024'/>
<meta name='referencecontent=' https://www.web3d.org/x3d/stylesheets/X3dToXhtml.xslt '/>
<meta name='referencecontent=' EventGraphLoopTestConsoleLog.txt '/>
<meta name='referencecontent=' EventGraphLoopTestIndex.html '/>
<meta name='specificationSectioncontent=' X3D 4.0 Architecture, ISO/IEC 19775-1:2023, 4 Concepts, 4.4.8.4 Loops'/>
<meta name='specificationUrlcontent=' https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/concepts.html#Loops '/>
<meta name='subjectcontent='X3D event graph loop detection'/>
<meta name='identifiercontent=' https://www.web3d.org/x3d/content/examples/X3dForAdvancedModeling/Animation/EventGraphLoopTest.x3d '/>
<meta name='generatorcontent='X3D-Edit 4.0, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!-- -->
<Scene>
<WorldInfo title='EventGraphLoopTest.x3d'/>
<Background skyColor='1 1 0.858824'/>
<!-- ROUTE information for Clock1 node:  [from Clock3.cycleTime to startTime ] [from cycleTime to Clock2.startTime ] -->
<TimeSensor DEF='Clock1cycleInterval='8loop='true'/>

<!-- ROUTE information for Clock2 node:  [from Clock1.cycleTime to startTime ] [from cycleTime to Clock3.startTime ] -->
<TimeSensor DEF='Clock2cycleInterval='2'/>


< ROUTE  fromNode=' Clock1' fromField='cycleTime' toNode=' Clock2' toField='startTime'/>
< ROUTE  fromNode=' Clock2' fromField='cycleTime' toNode=' Clock3' toField='startTime'/>
< ROUTE  fromNode=' Clock3' fromField='cycleTime' toNode=' Clock1' toField='startTime'/>
<!-- ROUTE information for ClockReporter node:  [from Clock3.cycleTime to clockStart3 ] [from loopCounterString to LoopCounterText.string ] -->
<Script DEF='ClockReporter'>
<field name='clockStart1type='SFTimevalue='-1accessType='inputOutput'/>
<field name='clockStart2type='SFTimevalue='-1accessType='inputOutput'/>
<field name='clockStart3type='SFTimevalue='-1accessType='inputOutput'/>
<field name='handleClock1type='SFNodeaccessType='inputOutput'
 appinfo='enable indirect contol of node by this Script' >
<TimeSensor USE=' Clock1'/>
</field>
<field name='loopCountertype='SFInt32value='0accessType='inputOutput'
 appinfo='loop count' />

<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');
}

    
]]>
</Script>
< ROUTE  fromNode=' Clock3' fromField='cycleTime' toNode=' ClockReporter' toField='clockStart3'/>
<!-- debug <ROUTE fromField='cycleTime' fromNode='Clock1' toField='clockStart1' toNode='ClockReporter'/> <ROUTE fromField='cycleTime' fromNode='Clock2' toField='clockStart2' toNode='ClockReporter'/> -->
<!-- ROUTE information for RotatingTransform node:  [from Spinner.value_changed to rotation ] -->
<Transform DEF='RotatingTransformtranslation='0 1 0'>
<Shape DEF='SpinnableTextShape'>
<Text string='"EventGraphLoopTest" "includes a" "three-ROUTE event loop"'>
<FontStyle DEF='BoldFontStylefamily='"SANS"justify='"MIDDLE" "MIDDLE"size='0.8style='BOLD'/>
</Text>
<Appearance DEF='TextAppearance'>
<Material diffuseColor='1 0.4 0.2'/>
</Appearance>
</Shape>
</Transform>
<Transform DEF='LoopCounterTransformscale='0.8 0.8 0.8translation='0 -1.5 0'>
<Shape DEF='LoopCounterTextShape'>
<!-- ROUTE information for LoopCounterText node:  [from ClockReporter.loopCounterString to string ] -->
<Text DEF='LoopCounterTextstring='"loop 0"'>
<FontStyle USE=' BoldFontStyle'/>
</Text>
<Appearance USE=' TextAppearance'/>
</Shape>
</Transform>
< ROUTE  fromNode=' ClockReporter' fromField='loopCounterString' toNode=' LoopCounterText' toField='string'/>
<!-- 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'/>

< ROUTE  fromNode=' Clock3' fromField='fraction_changed' toNode=' Spinner' toField='set_fraction'/>
< ROUTE  fromNode=' Spinner' fromField='value_changed' toNode=' RotatingTransform' toField='rotation'/>
</Scene>
</X3D>
<!--

to top <!-- Event Graph ROUTE Table shows event connections -->
 
<!-- Index for DEF nodes: BoldFontStyle, Clock1, Clock2, Clock3, ClockReporter, LoopCounterText, LoopCounterTextShape, LoopCounterTransform, RotatingTransform, SpinnableTextShape, Spinner, TextAppearance
-->

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.

The following ROUTE begins an event-routing loop! Loop occurs at nodeDepth=4.
 
ROUTE Clock1.cycleTime TO Clock2.startTime
Clock1
TimeSensor
cycleTime
SFTime

ROUTE
event to
(1)
Clock2
TimeSensor
startTime
SFTime

 
 
then
Clock2
TimeSensor
cycleTime
SFTime

ROUTE
event to
(2)
Clock3
TimeSensor
startTime
SFTime

 
 
then
Clock3
TimeSensor
cycleTime
SFTime

ROUTE
event to
(3)
Clock1
TimeSensor
startTime
SFTime

 
 
then
Clock1
TimeSensor
cycleTime
SFTime

ROUTE
event to
(4)
Clock2
TimeSensor
startTime
SFTime

 
 
then
Clock2
TimeSensor
cycleTime
SFTime

ROUTE
event to
(5)
Clock3
TimeSensor
startTime
SFTime

 
 
then
Clock3
TimeSensor
cycleTime
SFTime

ROUTE
event to
(6)
Clock1
TimeSensor
startTime
SFTime

 
 
then
Clock1
TimeSensor
cycleTime
SFTime

ROUTE
event to
(7)
Clock2
TimeSensor
startTime
SFTime
 
 
 
then
Clock3
TimeSensor
cycleTime
SFTime

ROUTE
event to
(6)
ClockReporter
Script
clockStart3
SFTime

 
 
then
ClockReporter
Script
loopCounterString
MFString

ROUTE
event to
(7)
LoopCounterText
Text
string
MFString
 
 
 
then
Clock3
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(6)
Spinner
OrientationInterpolator
set_fraction
SFFloat

 
 
then
Spinner
OrientationInterpolator
value_changed
SFRotation

ROUTE
event to
(7)
RotatingTransform
Transform
rotation
SFRotation
 
 
 
then
Clock3
TimeSensor
cycleTime
SFTime

ROUTE
event to
(3)
ClockReporter
Script
clockStart3
SFTime

 
 
then
ClockReporter
Script
loopCounterString
MFString

ROUTE
event to
(4)
LoopCounterText
Text
string
MFString
 
 
 
then
Clock3
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(3)
Spinner
OrientationInterpolator
set_fraction
SFFloat

 
 
then
Spinner
OrientationInterpolator
value_changed
SFRotation

ROUTE
event to
(4)
RotatingTransform
Transform
rotation
SFRotation


      ClockReporter
Script
loopCounterString
MFString

ROUTE
event to
(1)
LoopCounterText
Text
string
MFString


-->

<!-- 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. -->