<?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='TimeSensorChaining.x3d'/>
<meta name='descriptioncontent='Connecting TimeSensor nodes so that the completion of one behavior chain triggers another.'/>
<meta name='creatorcontent='Don Brutzman and MV3204 class'/>
<meta name='createdcontent='2 September 2009'/>
<meta name='modifiedcontent='20 October 2019'/>
<meta name=' warning content=' under development '/>
<meta name='identifiercontent=' https://X3dGraphics.com/examples/X3dForWebAuthors/Chapter07EventAnimationInterpolation/TimeSensorChaining.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!-- -->
<Scene>
<WorldInfo title='TimeSensorChaining.x3d'/>
<Viewpoint description='TimeSensor chaining exampleposition='0 1 6'/>
<!-- ROUTE information for DoorHingeTransform node:  [from DoorOpener.value_changed to rotation ] -->
<Transform DEF='DoorHingeTransformcenter='-0.65 0 0translation='0 1 0'>
<!-- ROUTE information for UserClick node:  [from touchTime to ClockNumber1.startTime ] [from isActive to SetTextInMotion.set_boolean ] [from touchTime to ClockNumber3.startTime ] -->
<TouchSensor DEF='UserClickdescription='click to operate door'/>
<Shape>
<Box size='1.3 2.5 0.08'/>
<Appearance>
<!-- ROUTE information for DoorColor node:  [from DoorColorInterpolator.value_changed to diffuseColor ] -->
<Material DEF='DoorColordiffuseColor='1 0 0'/>
</Appearance>
</Shape>
</Transform>
<Transform scale='0.6 0.6 0.6translation='0 -1 0'>
<!-- ROUTE information for TextSwitcher node:  [from SetTextInMotion.triggerValue to whichChoice ] [from SetTextOpen.triggerValue to whichChoice ] [from SetTextShut.triggerValue to whichChoice ] -->
<Switch DEF='TextSwitcherwhichChoice='0'>
<Group>
<Shape>
<Text string='"Door is closed"'>
<FontStyle DEF='MiddleJustifyjustify='"MIDDLE" "MIDDLE"'/>
</Text>
<Appearance DEF='TextAppearance'>
<Material/>
</Appearance>
</Shape>
</Group>
<Group>
<Shape>
<Text string='"Door in motion..."'>
<FontStyle USE='MiddleJustify'/>
</Text>
<Appearance USE='TextAppearance'/>
</Shape>
</Group>
<Group>
<Shape>
<Text string='"Door is open"'>
<FontStyle USE='MiddleJustify'/>
</Text>
<Appearance USE='TextAppearance'/>
</Shape>
</Group>
</Switch>
</Transform>
<!-- ===== open the door ===== -->
<!-- ROUTE information for ClockNumber1 node:  [from UserClick.touchTime to startTime ] [from fraction_changed to DoorOpener.set_fraction ] [from isActive to DoorOpenComplete.set_boolean ] [self-route from isActive to enabled ] -->
<TimeSensor DEF='ClockNumber1cycleInterval='2'/>
<ROUTE fromNode='UserClickfromField='touchTimetoNode='ClockNumber1toField='startTime'/>
<!-- ROUTE information for DoorOpener node:  [from ClockNumber1.fraction_changed to set_fraction ] [from ClockReversal.value_changed to set_fraction ] [from value_changed to DoorHingeTransform.rotation ] -->
<OrientationInterpolator DEF='DoorOpenerkey='0 0.5 1keyValue='0 1 0 0 0 1 0 4.7124 0 1 0 3'/>
<ROUTE fromNode='ClockNumber1fromField='fraction_changedtoNode='DoorOpenertoField='set_fraction'/>
<ROUTE fromNode='DoorOpenerfromField='value_changedtoNode='DoorHingeTransformtoField='rotation'/>
<!-- ROUTE information for SetTextInMotion node:  [from UserClick.isActive to set_boolean ] [from triggerValue to TextSwitcher.whichChoice ] -->
<IntegerTrigger DEF='SetTextInMotionintegerKey='1containerField='children'/>
<ROUTE fromNode='UserClickfromField='isActivetoNode='SetTextInMotiontoField='set_boolean'/>
<ROUTE fromNode='SetTextInMotionfromField='triggerValuetoNode='TextSwitchertoField='whichChoice'/>
<!-- ===== door is now open ===== -->
<!-- ROUTE information for DoorOpenComplete node:  [from ClockNumber1.isActive to set_boolean ] [from inputFalse to TriggerOpeningAnimation.set_boolean ] [from inputFalse to SetTextOpen.set_boolean ] [from inputFalse to ClockNumber3.enabled ] -->
<BooleanFilter DEF='DoorOpenCompletecontainerField='children'/>
<ROUTE fromNode='ClockNumber1fromField='isActivetoNode='DoorOpenCompletetoField='set_boolean'/>
<!-- disable ClockNumber1 by turning itself off when complete -->
<ROUTE fromNode='ClockNumber1fromField='isActivetoNode='ClockNumber1toField='enabled'/>
<!-- ROUTE information for TriggerOpeningAnimation node:  [from DoorOpenComplete.inputFalse to set_boolean ] [from triggerTime to ClockNumber2.startTime ] -->
<TimeTrigger DEF='TriggerOpeningAnimationcontainerField='children'/>
<ROUTE fromNode='DoorOpenCompletefromField='inputFalsetoNode='TriggerOpeningAnimationtoField='set_boolean'/>
<!-- ROUTE information for ClockNumber2 node:  [from TriggerOpeningAnimation.triggerTime to startTime ] [from fraction_changed to DoorColorInterpolator.set_fraction ] -->
<TimeSensor DEF='ClockNumber2cycleInterval='0.5'/>
<ROUTE fromNode='TriggerOpeningAnimationfromField='triggerTimetoNode='ClockNumber2toField='startTime'/>
<!-- ROUTE information for SetTextOpen node:  [from DoorOpenComplete.inputFalse to set_boolean ] [from triggerValue to TextSwitcher.whichChoice ] -->
<IntegerTrigger DEF='SetTextOpenintegerKey='2containerField='children'/>
<ROUTE fromNode='DoorOpenCompletefromField='inputFalsetoNode='SetTextOpentoField='set_boolean'/>
<ROUTE fromNode='SetTextOpenfromField='triggerValuetoNode='TextSwitchertoField='whichChoice'/>
<!-- ROUTE information for DoorColorInterpolator node:  [from ClockNumber2.fraction_changed to set_fraction ] [from ClockReversal.value_changed to set_fraction ] [from value_changed to DoorColor.diffuseColor ] -->
<ColorInterpolator DEF='DoorColorInterpolatorkey='0 0.5 1keyValue='1 0 0 0.1 0.1 0.1 0.203922 0.701961 0'/>
<ROUTE fromNode='ClockNumber2fromField='fraction_changedtoNode='DoorColorInterpolatortoField='set_fraction'/>
<ROUTE fromNode='DoorColorInterpolatorfromField='value_changedtoNode='DoorColortoField='diffuseColor'/>
<!-- ===== shut the door ===== -->
<!-- ROUTE information for ClockNumber3 node:  [from UserClick.touchTime to startTime ] [from DoorOpenComplete.inputFalse to enabled ] [from fraction_changed to ClockReversal.set_fraction ] [from stopTime to Clock3CompleteTrigger.set_triggerTime ] [self-route from isActive to enabled ] -->
<TimeSensor DEF='ClockNumber3cycleInterval='2enabled='false'/>
<ROUTE fromNode='UserClickfromField='touchTimetoNode='ClockNumber3toField='startTime'/>
<!-- enable ClockNumber3 once door is fully open -->
<ROUTE fromNode='DoorOpenCompletefromField='inputFalsetoNode='ClockNumber3toField='enabled'/>
<!-- disable ClockNumber3 by turning itself off when complete -->
<ROUTE fromNode='ClockNumber3fromField='isActivetoNode='ClockNumber3toField='enabled'/>
<!-- ROUTE information for ClockReversal node:  [from ClockNumber3.fraction_changed to set_fraction ] [from value_changed to DoorOpener.set_fraction ] [from value_changed to DoorColorInterpolator.set_fraction ] -->
<ScalarInterpolator DEF='ClockReversalkey='0 1keyValue='1 0'/>
<ROUTE fromNode='ClockNumber3fromField='fraction_changedtoNode='ClockReversaltoField='set_fraction'/>
<ROUTE fromNode='ClockReversalfromField='value_changedtoNode='DoorOpenertoField='set_fraction'/>
<ROUTE fromNode='ClockReversalfromField='value_changedtoNode='DoorColorInterpolatortoField='set_fraction'/>
<!-- enable ClockNumber1 when door is fully shut -->
<!-- ROUTE information for Clock3CompleteTrigger node:  [from ClockNumber3.stopTime to set_triggerTime ] [from triggerTrue to SetTextShut.set_boolean ] -->
<BooleanTrigger DEF='Clock3CompleteTriggercontainerField='children'/>
<ROUTE fromNode='ClockNumber3fromField='stopTimetoNode='Clock3CompleteTriggertoField='set_triggerTime'/>
<!-- ROUTE information for SetTextShut node:  [from Clock3CompleteTrigger.triggerTrue to set_boolean ] [from triggerValue to TextSwitcher.whichChoice ] -->
<IntegerTrigger DEF='SetTextShutintegerKey='0containerField='children'/>
<ROUTE fromNode='Clock3CompleteTriggerfromField='triggerTruetoNode='SetTextShuttoField='set_boolean'/>
<ROUTE fromNode='SetTextShutfromField='triggerValuetoNode='TextSwitchertoField='whichChoice'/>
</Scene>
</X3D>
<!--

Index for DEF nodes : Clock3CompleteTrigger, ClockNumber1, ClockNumber2, ClockNumber3, ClockReversal, DoorColor, DoorColorInterpolator, DoorHingeTransform, DoorOpenComplete, DoorOpener, MiddleJustify, SetTextInMotion, SetTextOpen, SetTextShut, TextAppearance, TextSwitcher, TriggerOpeningAnimation, UserClick

Index for Viewpoint image : Viewpoint_1
-->

<!-- Color key: <X3dNode DEF='idName' field='value'/> matches <XmlElement DEF='idName' attribute='value'/>
(Light blue background: behavior node) (Grey background: inserted documentation) (Magenta background: X3D Extensibility)
-->

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