| 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=' ScriptControlEvents.x3d '/> |
| 6 | <meta name='description' content='A three-way light controlled by a Script node.'/> |
| 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/ScriptControlEvents.x3d '/> |
| 15 | <meta name='generator' content='X3D-Edit 3.3, https://www.web3d.org/x3d/tools/X3D-Edit'/> |
| 16 | <meta name='license' content='../license.html'/> |
| 17 | </head> |
| 18 | <Scene> |
| 19 | <WorldInfo title='ScriptControlEvents.x3d'/> |
| 20 | <Background skyColor='1 1 1'/> |
| 21 | <Viewpoint description='Push button to change light color' orientation='1 0 0 -0.45' position='0 2 5'/> |
| 22 | <Viewpoint description='Book View' orientation='0 1 0 0.83' position='0.92 0.07 0.63'/> |
| 23 | <Transform DEF='PushButtonBox' translation='-2 0 0'> |
| 24 | <Transform DEF='ControlBox'> |
| 25 | <Shape> |
| 26 | <Appearance> |
| 27 | <Material diffuseColor='0 .8 0'/> |
| 28 | </Appearance> |
| 29 | <Box size='1 .5 1'/> |
| 30 | </Shape> |
| 31 | </Transform> |
| 32 |
<!-- ROUTE information for ControlButton node:
[from ButtonMover.value_changed to translation
]
-->
<Transform DEF='ControlButton' translation='0 .25 0'> |
| 33 |
<!-- ROUTE information for ButtonTouch node:
[from touchTime to ButtonTimer.startTime
]
-->
<TouchSensor DEF='ButtonTouch' description='touch to activate'/> |
| 34 | <Shape> |
| 35 | <Cylinder DEF='Button' bottom='false' height='.5' radius='.25'/> |
| 36 | <Appearance> |
| 37 | <Material diffuseColor='1 0 0'/> |
| 38 | </Appearance> |
| 39 | </Shape> |
| 40 |
<!-- ROUTE information for ButtonMover node:
[from ButtonTimer.fraction_changed to set_fraction
]
[from ControlScript.motion to keyValue
]
[from value_changed to ControlButton.translation
]
-->
<PositionInterpolator DEF='ButtonMover' key='0 1' keyValue='0 .25 0 0 .05 0'/> |
| 41 |
<!-- ROUTE information for ButtonTimer node:
[from ButtonTouch.touchTime to startTime
]
[from fraction_changed to ButtonMover.set_fraction
]
[from isActive to ControlScript.buttonMotionDone
]
-->
<TimeSensor DEF='ButtonTimer' stopTime='1'/> |
| 42 | < ROUTE fromNode='ButtonTouch' fromField='touchTime' toNode='ButtonTimer' toField='startTime'/> |
| 43 | < ROUTE fromNode='ButtonTimer' fromField='fraction_changed' toNode='ButtonMover' toField='set_fraction'/> |
| 44 | < ROUTE fromNode='ButtonMover' fromField='value_changed' toNode='ControlButton' toField='translation'/> |
| 45 | </Transform> |
| 46 | </Transform> |
| 47 | <Transform DEF='Lamp' translation='1 0 0'> |
| 48 | <Transform DEF='Base'> |
| 49 | <Shape> |
| 50 | <Appearance> |
| 51 | <Material/> |
| 52 | </Appearance> |
| 53 | <Cylinder height='.5' radius='.25'/> |
| 54 | </Shape> |
| 55 | </Transform> |
| 56 | <Transform DEF='Bulb' translation='0 .5 0'> |
| 57 | <Shape> |
| 58 | <Appearance> |
| 59 |
<!-- ROUTE information for lightBulb node:
[from ControlScript.lightColor to diffuseColor
]
-->
<Material DEF='lightBulb' diffuseColor='.4 .4 .4'/> |
| 60 | </Appearance> |
| 61 | <Sphere radius='.5'/> |
| 62 | </Shape> |
| 63 | </Transform> |
| 64 | </Transform> |
| 65 |
<!-- ROUTE information for ControlScript node:
[from ButtonTimer.isActive to buttonMotionDone
]
[from motion to ButtonMover.keyValue
]
[from lightColor to lightBulb.diffuseColor
]
-->
<Script DEF='ControlScript' url=' "ScriptControlEvents.js" "https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter09EventUtilitiesScripting/ScriptControlEvents.js" '> |
| 66 | <field name='buttonMotionDone' type='SFBool' accessType='inputOnly'/> |
| 67 | <field name='motion' type='MFVec3f' accessType='outputOnly'/> |
| 68 | <field name='buttonDown' type='SFBool' value='true' accessType='initializeOnly'/> |
| 69 | <field name='lightColor' type='SFColor' accessType='outputOnly'/> |
| 70 | </Script> |
| 71 | < ROUTE fromNode='ButtonTimer' fromField='isActive' toNode='ControlScript' toField='buttonMotionDone'/> |
| 72 | < ROUTE fromNode='ControlScript' fromField='motion' toNode='ButtonMover' toField='keyValue'/> |
| 73 | < ROUTE fromNode='ControlScript' fromField='lightColor' toNode='lightBulb' toField='diffuseColor'/> |
| 74 | </Scene> |
| 75 | </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 buttonMotionDone SFBool |
then
|
ControlScript
Script lightColor SFColor |
lightBulb
Material diffuseColor SFColor |
|||||||||
|
then
|
ControlScript
Script motion MFVec3f |
ButtonMover
PositionInterpolator keyValue MFVec3f |
then
|
ButtonMover
PositionInterpolator value_changed SFVec3f |
ControlButton
Transform translation SFVec3f |
|||||||||
<!--
Color-coding 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.
-->