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='title' content='ScriptSimpleStateEvents.x3d'/> |
6 | <meta name='description' content='A Script node drives an animated push button that turns a light on and off.'/> |
7 | <meta name='creator' content='Leonard Daly and Don Brutzman'/> |
8 | <meta name='created' content='10 June 2006'/> |
9 | <meta name='modified' content='20 October 2019'/> |
10 | <meta name='reference' content='https://X3dGraphics.com'/> |
11 | <meta name='reference' content='https://www.web3d.org/x3d/content/examples/X3dResources.html'/> |
12 | <meta name='rights' content='Copyright 2006, Daly Realism and Don Brutzman'/> |
13 | <meta name='subject' content='X3D book, X3D graphics, X3D-Edit, http://www.x3dGraphics.com'/> |
14 | <meta name='identifier' content='https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter09EventUtilitiesScripting/ScriptSimpleStateEvents.x3d'/> |
15 | <meta name='generator' content='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/> |
16 | <meta name='license' content='../license.html'/> |
17 | </head> |
18 | <Scene> |
19 | <WorldInfo title='ScriptSimpleStateEvents.x3d'/> |
20 | <Background skyColor='1 1 1'/> |
21 | <Viewpoint description='click switch to toggle light' orientation='-0.993 0.101 -0.063 1.06' position='0.06 3.63 2.29'/> |
22 | <Transform DEF='PushBox' translation='-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='ControlButton' translation='0 .25 0'> |
32 |
<!-- ROUTE information for ButtonTouch node:
[from touchTime to ButtonTimer.startTime
]
-->
<TouchSensor DEF='ButtonTouch' description='touch to toggle'/> |
33 | <Shape> |
34 | <Appearance> |
35 | <Material diffuseColor='1 0 0'/> |
36 | </Appearance> |
37 | <Cylinder DEF='Button' bottom='false' height='.5' radius='.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='ButtonMover' key='0 1' keyValue='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='Lamp' translation='1 0 0'> |
47 | <Transform DEF='Base'> |
48 | <Shape> |
49 | <Appearance> |
50 | <Material/> |
51 | </Appearance> |
52 | <Cylinder height='.5' radius='.25'/> |
53 | </Shape> |
54 | </Transform> |
55 | <Transform DEF='Bulb' translation='0 .5 0'> |
56 | <Shape> |
57 | <Appearance> |
58 |
<!-- ROUTE information for LightBulbMaterial node:
[from ControlScript.lightColor to diffuseColor
]
-->
<Material DEF='LightBulbMaterial' diffuseColor='.4 .4 .4'/> |
59 | </Appearance> |
60 | <Sphere radius='.5'/> |
61 | </Shape> |
62 | </Transform> |
63 | </Transform> |
64 |
<!-- 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" "https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter09EventUtilitiesScripting/ScriptSimpleStateEvents.js" '> |
65 | <field name='buttonDown' type='SFBool' value='false' accessType='initializeOnly'/> |
66 | <field name='buttonTimerActive' type='SFBool' accessType='inputOnly'/> |
67 | <field name='newButtonPath' type='MFVec3f' accessType='outputOnly'/> |
68 | <field name='lightColor' type='SFColor' accessType='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 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 |
ButtonTimer
TimeSensor startTime SFTime |
then
|
ButtonTimer
TimeSensor fraction_changed SFFloat |
ButtonMover
PositionInterpolator set_fraction SFFloat |
then
|
ButtonMover
PositionInterpolator value_changed SFVec3f |
ControlButton
Transform translation SFVec3f |
|||||||
then
|
ButtonTimer
TimeSensor isActive SFBool |
ControlScript
Script buttonTimerActive SFBool |
then
|
ControlScript
Script lightColor SFColor |
LightBulbMaterial
Material diffuseColor SFColor |
|||||||||
then
|
ControlScript
Script newButtonPath MFVec3f |
ButtonMover
PositionInterpolator keyValue MFVec3f |
then
|
ButtonMover
PositionInterpolator value_changed SFVec3f |
ControlButton
Transform translation SFVec3f |
<!--
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)
-->
<!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->