<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "http://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 =' http://www.web3d.org/specifications/x3d-3.3.xsd '>
<head>
<meta name='titlecontent='ScriptSimpleStateEvents.x3d'/>
<meta name='descriptioncontent='A Script node drives an animated push button that turns a light on and off.'/>
<meta name='creatorcontent='Leonard Daly and Don Brutzman'/>
<meta name='createdcontent='10 June 2006'/>
<meta name='modifiedcontent='10 January 2014'/>
<meta name='referencecontent=' http://X3dGraphics.com '/>
<meta name='referencecontent=' http://www.web3d.org/x3d/content/examples/X3dResources.html '/>
<meta name='rightscontent='Copyright 2006, Daly Realism and Don Brutzman'/>
<meta name='subjectcontent=' X3D book, X3D graphics, X3D-Edit, http://www.x3dGraphics.com '/>
<meta name='identifiercontent=' http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter09EventUtilitiesScripting/ScriptSimpleStateEvents.x3d '/>
<meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
<meta name='licensecontent=' ../license.html'/>
</head>
<!-- -->
<Scene>
<Background skyColor='1 1 1'/>
<Viewpoint description='click switch to toggle lightorientation='-0.993 0.101 -0.063 1.06position='0.06 3.63 2.29'/>
<Transform DEF='PushBoxtranslation='-2 0 0'>
<Transform DEF='ControlBox'>
<Shape>
<Appearance>
<Material diffuseColor='0 .8 0'/>
</Appearance>
<Box size='1 .5 1'/>
</Shape>
</Transform>
<!-- ROUTE information for ControlButton node:  [from ButtonMover.value_changed to translation ] -->
<Transform DEF='ControlButtontranslation='0 .25 0'>
<!-- ROUTE information for ButtonTouch node:  [from touchTime to ButtonTimer.startTime ] -->
<TouchSensor DEF='ButtonTouchdescription='touch to toggle'/>
<Shape>
<Appearance>
<Material diffuseColor='1 0 0'/>
</Appearance>
<Cylinder DEF='Buttonbottom='falseheight='.5radius='.25'/>
</Shape>
<!-- ROUTE information for ButtonMover node:  [from ButtonTimer.fraction_changed to set_fraction ] [from ControlScript.newButtonPath to keyValue ] [from value_changed to ControlButton.translation ] -->
<PositionInterpolator DEF='ButtonMoverkey='0 1keyValue='0 .25 0 0 .05 0'/>
<!-- ROUTE information for ButtonTimer node:  [from ButtonTouch.touchTime to startTime ] [from fraction_changed to ButtonMover.set_fraction ] [from isActive to ControlScript.buttonTimerActive ] -->
<TimeSensor DEF='ButtonTimer'/>
<ROUTE fromNode='ButtonTouchfromField='touchTimetoNode='ButtonTimertoField='startTime'/>
<ROUTE fromNode='ButtonTimerfromField='fraction_changedtoNode='ButtonMovertoField='set_fraction'/>
<ROUTE fromNode='ButtonMoverfromField='value_changedtoNode='ControlButtontoField='translation'/>
</Transform>
</Transform>
<Transform DEF='Lamptranslation='1 0 0'>
<Transform DEF='Base'>
<Shape>
<Appearance>
<Material/>
</Appearance>
<Cylinder height='.5radius='.25'/>
</Shape>
</Transform>
<Transform DEF='Bulbtranslation='0 .5 0'>
<Shape>
<Appearance>
<!-- ROUTE information for LightBulbMaterial node:  [from ControlScript.lightColor to diffuseColor ] -->
<Material DEF='LightBulbMaterialdiffuseColor='.4 .4 .4'/>
</Appearance>
<Sphere radius='.5'/>
</Shape>
</Transform>
</Transform>
<!-- ROUTE information for ControlScript node:  [from ButtonTimer.isActive to buttonTimerActive ] [from newButtonPath to ButtonMover.keyValue ] [from lightColor to LightBulbMaterial.diffuseColor ] -->
<Script DEF='ControlScript'
  url=' "ScriptSimpleStateEvents.js" "http://X3dGraphics.com/examples/X3dForWebAuthors/Chapter09EventUtilitiesScripting/ScriptSimpleStateEvents.js" '>
<field name='buttonDowntype='SFBoolvalue='falseaccessType='initializeOnly'/>
<field name='buttonTimerActivetype='SFBoolaccessType='inputOnly'/>
<field name='newButtonPathtype='MFVec3faccessType='outputOnly'/>
<field name='lightColortype='SFColoraccessType='outputOnly'/>
</Script>
<ROUTE fromNode='ButtonTimerfromField='isActivetoNode='ControlScripttoField='buttonTimerActive'/>
<ROUTE fromNode='ControlScriptfromField='newButtonPathtoNode='ButtonMovertoField='keyValue'/>
<ROUTE fromNode='ControlScriptfromField='lightColortoNode='LightBulbMaterialtoField='diffuseColor'/>
</Scene>
</X3D>
<!--

Index for DEF nodes : Base, Bulb, Button, ButtonMover, ButtonTimer, ButtonTouch, ControlBox, ControlButton, ControlScript, Lamp, LightBulbMaterial, PushBox

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)
-->

<!-- Additional help information about X3D scenes: X3D Resources, X3D Scene Authoring Hints and X3D Tooltips -->