X3D Model Documentation: ScriptSimpleStateEvents.x3d

  1  <?xml version="1.0" encoding="UTF-8"?>
  2  <!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.3//EN" "https://www.web3d.org/specifications/x3d-3.3.dtd">
  3  <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'>
  4       <head>
  5            <meta name='titlecontent='ScriptSimpleStateEvents.x3d'/>
  6            <meta name='descriptioncontent='A Script node drives an animated push button that turns a light on and off.'/>
  7            <meta name='creatorcontent='Leonard Daly and Don Brutzman'/>
  8            <meta name='createdcontent='10 June 2006'/>
  9            <meta name='modifiedcontent='20 October 2019'/>
 10            <meta name='referencecontent='https://X3dGraphics.com'/>
 11            <meta name='referencecontent='https://www.web3d.org/x3d/content/examples/X3dResources.html'/>
 12            <meta name='rightscontent='Copyright 2006, Daly Realism and Don Brutzman'/>
 13            <meta name='subjectcontent='X3D book, X3D graphics, X3D-Edit, http://www.x3dGraphics.com'/>
 14            <meta name='identifiercontent='https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter09EventUtilitiesScripting/ScriptSimpleStateEvents.x3d'/>
 15            <meta name='generatorcontent='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/>
 16            <meta name='licensecontent='../license.html'/>
 17       </head>
<!--

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

<!-- to top Index for DEF nodes: Base, Bulb, Button, ButtonMover, ButtonTimer, ButtonTouch, ControlBox, ControlButton, ControlScript, Lamp, LightBulbMaterial, PushBox

Index for Viewpoint node: Viewpoint_1
-->
 18       <Scene>
 19            <WorldInfo title='ScriptSimpleStateEvents.x3d'/>
 20            <Background skyColor='1 1 1'/>
 21            <Viewpoint description='click switch to toggle lightorientation='-0.993 0.101 -0.063 1.06position='0.06 3.63 2.29'/>
 22            <Transform DEF='PushBoxtranslation='-2 0 0'>
 23                 <Transform DEF='ControlBox'>
 24                      <Shape>
 25                           <Appearance>
 26                                <Material diffuseColor='0 .8 0'/>
 27                           </Appearance>
 28                           <Box size='1 .5 1'/>
 29                      </Shape>
 30                 </Transform>
 31 
               <!-- ROUTE information for ControlButton node:  [from ButtonMover.value_changed to translation ] -->
               <Transform DEF='ControlButtontranslation='0 .25 0'>
 32 
                    <!-- ROUTE information for ButtonTouch node:  [from touchTime to ButtonTimer.startTime ] -->
                    <TouchSensor DEF='ButtonTouchdescription='touch to toggle'/>
 33                      <Shape>
 34                           <Appearance>
 35                                <Material diffuseColor='1 0 0'/>
 36                           </Appearance>
 37                           <Cylinder DEF='Buttonbottom='falseheight='.5radius='.25'/>
 38                      </Shape>
 39 
                    <!-- 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'/>
 40 
                    <!-- 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'/>
 41                      < ROUTE  fromNode='ButtonTouch' fromField='touchTime' toNode='ButtonTimer' toField='startTime'/>
 42                      < ROUTE  fromNode='ButtonTimer' fromField='fraction_changed' toNode='ButtonMover' toField='set_fraction'/>
 43                      < ROUTE  fromNode='ButtonMover' fromField='value_changed' toNode='ControlButton' toField='translation'/>
 44                 </Transform>
 45            </Transform>
 46            <Transform DEF='Lamptranslation='1 0 0'>
 47                 <Transform DEF='Base'>
 48                      <Shape>
 49                           <Appearance>
 50                                <Material/>
 51                           </Appearance>
 52                           <Cylinder height='.5radius='.25'/>
 53                      </Shape>
 54                 </Transform>
 55                 <Transform DEF='Bulbtranslation='0 .5 0'>
 56                      <Shape>
 57                           <Appearance>
 58 
                              <!-- ROUTE information for LightBulbMaterial node:  [from ControlScript.lightColor to diffuseColor ] -->
                              <Material DEF='LightBulbMaterialdiffuseColor='.4 .4 .4'/>
 59                           </Appearance>
 60                           <Sphere radius='.5'/>
 61                      </Shape>
 62                 </Transform>
 63            </Transform>
 64 
 65                 <field name='buttonDowntype='SFBoolvalue='falseaccessType='initializeOnly'/>
 66                 <field name='buttonTimerActivetype='SFBoolaccessType='inputOnly'/>
 67                 <field name='newButtonPathtype='MFVec3faccessType='outputOnly'/>
 68                 <field name='lightColortype='SFColoraccessType='outputOnly'/>
 69            </Script>
 70            < ROUTE  fromNode='ButtonTimer' fromField='isActive' toNode='ControlScript' toField='buttonTimerActive'/>
 71            < ROUTE  fromNode='ControlScript' fromField='newButtonPath' toNode='ButtonMover' toField='keyValue'/>
 72            < ROUTE  fromNode='ControlScript' fromField='lightColor' toNode='LightBulbMaterial' toField='diffuseColor'/>
 73       </Scene>
 74  </X3D>
<!--

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

<!-- to top Index for DEF nodes: Base, Bulb, Button, ButtonMover, ButtonTimer, ButtonTouch, ControlBox, ControlButton, ControlScript, Lamp, LightBulbMaterial, PushBox

Index for Viewpoint node: Viewpoint_1
-->
X3D Tooltips element index: Appearance, Background, Box, Cylinder, field, head, Material, meta, PositionInterpolator, ROUTE, Scene, Script, Shape, Sphere, TimeSensor, TouchSensor, Transform, Viewpoint, WorldInfo, X3D, accessType and type, XML data types, field types

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.

ButtonTouch
TouchSensor
touchTime
SFTime

ROUTE
event to
(1)
ButtonTimer
TimeSensor
startTime
SFTime
then
 
 
 
ButtonTimer
TimeSensor
fraction_changed
SFFloat

ROUTE
event to
(2)
ButtonMover
PositionInterpolator
set_fraction
SFFloat
then
 
 
 
ButtonMover
PositionInterpolator
value_changed
SFVec3f

ROUTE
event to
(3)
ControlButton
Transform
translation
SFVec3f
  then
 
 
 
ButtonTimer
TimeSensor
isActive
SFBool

ROUTE
event to
(2)
ControlScript
Script
buttonTimerActive
SFBool
then
 
 
 
ControlScript
Script
lightColor
SFColor

ROUTE
event to
(3)
LightBulbMaterial
Material
diffuseColor
SFColor
  then
 
 
 
ControlScript
Script
newButtonPath
MFVec3f

ROUTE
event to
(3)
ButtonMover
PositionInterpolator
keyValue
MFVec3f
then
 
 
 
ButtonMover
PositionInterpolator
value_changed
SFVec3f

ROUTE
event to
(4)
ControlButton
Transform
translation
SFVec3f

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/X3dForWebAuthors/Chapter09EventUtilitiesScripting/ScriptSimpleStateEventsIndex.html -->
<!-- Version control at
https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter09EventUtilitiesScripting/ScriptSimpleStateEvents.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. -->