1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
<!DOCTYPE X3D PUBLIC "ISO//Web3D//DTD X3D 3.0//EN" "https://www.web3d.org/specifications/x3d-3.0.dtd">
|
3 | <X3D profile='Immersive' version='3.0' xmlns:xsd='http://www.w3.org/2001/XMLSchema-instance' xsd:noNamespaceSchemaLocation='https://www.web3d.org/specifications/x3d-3.0.xsd'> |
4 | <head> |
5 | <meta name='title' content='KeySensorActivationKeySwitchTest.x3d'/> |
6 | <meta name='description' content='A simple scene to show KeySensor functionality using Text nodes.'/> |
7 | <meta name='creator' content='Don Brutzman'/> |
8 | <meta name='created' content='22 June 2001'/> |
9 | <meta name='modified' content='28 August 2023'/> |
10 | <meta name=' warning ' content=" This doesn't work because there is no KeySensor implementation yet! Prototype script (written in Java) or native node support for KeySensor is needed. "/> |
11 | <meta name=' warning ' content=' enabled accessType needs to be changed to exposedField once supported by Script capabilities '/> |
12 | <meta name='reference' content='https://www.web3d.org/x3d/specification-2000july/part1/nodesDef.html#KeySensor'/> |
13 | <meta name='reference' content='https://www.web3d.org/x3d/sai/javadoc/org/web3d/x3d/sai/Core/KeySensor.html'/> |
14 | <meta name='reference' content='https://www.web3d.org/x3d/content/examples/development/KeySensorActivationKeySwitchTest.x3d'/> |
15 | <meta name='identifier' content='https://www.web3d.org/x3d/content/examples/ConformanceNist/Sensors/Keyboard/KeySensorActivationKeySwitchTest.x3d'/> |
16 | <meta name='subject' content='KeySensor'/> |
17 | <meta name='generator' content='X3D-Edit 4.0, https://savage.nps.edu/X3D-Edit'/> |
18 | <meta name='license' content='../../license.html'/> |
19 | </head> |
20 | <Scene> |
21 | <!-- The KeySensor prototype can be omitted if native-node Keysensor support is provided by the VRML browser. --> |
22 | <WorldInfo title='KeySensorActivationKeySwitchTest.x3d'/> |
23 | <ProtoDeclare name='KeySensor'> |
24 | <ProtoInterface> |
25 | <!-- warning: enabled needs to become an exposedField once Scripts support exposedField --> |
26 | <field name='enabled' type='SFBool' value='true' accessType='initializeOnly'/> |
27 | <field name='set_enabled' type='SFBool' accessType='inputOnly'/> |
28 | <field name='enabled_changed' type='SFBool' accessType='outputOnly'/> |
29 | <field name='isActive' type='SFBool' accessType='outputOnly'/> |
30 | <field name='keyPress' type='SFInt32' accessType='outputOnly'/> |
31 | <field name='keyRelease' type='SFInt32' accessType='outputOnly'/> |
32 | <field name='actionKeyPress' type='SFInt32' accessType='outputOnly'/> |
33 | <field name='actionKeyRelease' type='SFInt32' accessType='outputOnly'/> |
34 | <field name='altKey' type='SFBool' accessType='outputOnly'/> |
35 | <field name='controlKey' type='SFBool' accessType='outputOnly'/> |
36 | <field name='shiftKey' type='SFBool' accessType='outputOnly'/> |
37 | </ProtoInterface> |
38 | <ProtoBody> |
39 | <!-- First node in prototype indicates node type, use Group so that this sensor is ChildNodeType. --> |
40 | <Group> |
41 | <Script DEF='KeySensorScript'> |
42 | <field name='altKey' type='SFBool' accessType='outputOnly'/> |
43 | <field name='keyPress' type='SFInt32' accessType='outputOnly'/> |
44 | <field name='set_enabled' type='SFBool' accessType='inputOnly'/> |
45 | <field name='keyRelease' type='SFInt32' accessType='outputOnly'/> |
46 | <field name='enabled' type='SFBool' accessType='initializeOnly'/> |
47 | <field name='shiftKey' type='SFBool' accessType='outputOnly'/> |
48 | <field name='actionKeyRelease' type='SFInt32' accessType='outputOnly'/> |
49 | <field name='isActive' type='SFBool' accessType='outputOnly'/> |
50 | <field name='actionKeyPress' type='SFInt32' accessType='outputOnly'/> |
51 | <field name='enabled_changed' type='SFBool' accessType='outputOnly'/> |
52 | <field name='controlKey' type='SFBool' accessType='outputOnly'/> |
53 | <IS> |
54 | <connect nodeField='enabled' protoField='enabled'/> |
55 | <connect nodeField='set_enabled' protoField='set_enabled'/> |
56 | <connect nodeField='enabled_changed' protoField='enabled_changed'/> |
57 | <connect nodeField='isActive' protoField='isActive'/> |
58 | <connect nodeField='keyPress' protoField='keyPress'/> |
59 | <connect nodeField='keyRelease' protoField='keyRelease'/> |
60 | <connect nodeField='actionKeyPress' protoField='actionKeyPress'/> |
61 | <connect nodeField='actionKeyRelease' protoField='actionKeyRelease'/> |
62 | <connect nodeField='altKey' protoField='altKey'/> |
63 | <connect nodeField='controlKey' protoField='controlKey'/> |
64 | <connect nodeField='shiftKey' protoField='shiftKey'/> |
65 | </IS> |
<![CDATA[
ecmascript: // Native support for KeySensor node // or keyboard-access code needed!
]]>
|
|
67 | </Script> |
68 | </Group> |
69 | </ProtoBody> |
70 | </ProtoDeclare> |
71 | <!-- ============================================ --> |
72 | <!-- Enabling this KeySensor (from TouchSensor.isActive) disables all other KeySensors. --> |
73 |
<!-- ROUTE information for SingleKeySensor node:
[from StartMessageTouched.isOver to enabled
]
[from actionKeyPress to ActivationKeyMessageSwitch.whichChoice
]
-->
<KeySensor DEF='SingleKeySensor' enabled='false'/> |
74 | <Billboard> |
75 | <Transform translation='0 2 0'> |
76 | <Shape> |
77 | <Text string='"Touch this text to enable" "KeySensor activation keys then" "press activation keys to test"'> |
78 | |
79 | </Text> |
80 | <Appearance> |
81 | <Material diffuseColor='0.9 0.9 0.4'/> |
82 | </Appearance> |
83 | </Shape> |
84 |
<!-- ROUTE information for StartMessageTouched node:
[from isOver to SingleKeySensor.enabled
]
-->
<TouchSensor DEF='StartMessageTouched' description='Touch this text to enable KeySensor activation keys then press activation keys to test'/> |
85 | < ROUTE fromNode='StartMessageTouched' fromField='isOver' toNode='SingleKeySensor' toField='enabled'/> |
86 | </Transform> |
87 | <Transform translation='0 -1 0'> |
88 |
<!-- ROUTE information for ActivationKeyMessageSwitch node:
[from SingleKeySensor.actionKeyPress to whichChoice
]
-->
<Switch DEF='ActivationKeyMessageSwitch' whichChoice='0'> |
89 | <!-- ROUTE is not treated as a selectable child of Switch --> |
90 | < ROUTE fromNode='SingleKeySensor' fromField='actionKeyPress' toNode='ActivationKeyMessageSwitch' toField='whichChoice'/> |
91 | <Shape DEF='Zero'> |
92 | <Text string='"No activation keypress sensed..."'> |
93 | <FontStyle USE='MiddleMiddle'/> |
94 | </Text> |
95 | |
96 | <Material diffuseColor='0 1 0'/> |
97 | </Appearance> |
98 | </Shape> |
99 | <Shape DEF='One'> |
100 | <Text string='"F1"'> |
101 | <FontStyle USE='MiddleMiddle'/> |
102 | </Text> |
103 | <Appearance USE='SelectionAppearance'/> |
104 | </Shape> |
105 | <Shape DEF='Two'> |
106 | <Text string='"F2"'> |
107 | <FontStyle USE='MiddleMiddle'/> |
108 | </Text> |
109 | <Appearance USE='SelectionAppearance'/> |
110 | </Shape> |
111 | <Shape DEF='Three'> |
112 | <Text string='"F3"'> |
113 | <FontStyle USE='MiddleMiddle'/> |
114 | </Text> |
115 | <Appearance USE='SelectionAppearance'/> |
116 | </Shape> |
117 | <Shape DEF='Four'> |
118 | <Text string='"F4"'> |
119 | <FontStyle USE='MiddleMiddle'/> |
120 | </Text> |
121 | <Appearance USE='SelectionAppearance'/> |
122 | </Shape> |
123 | <Shape DEF='Five'> |
124 | <Text string='"F5"'> |
125 | <FontStyle USE='MiddleMiddle'/> |
126 | </Text> |
127 | <Appearance USE='SelectionAppearance'/> |
128 | </Shape> |
129 | <Shape DEF='Six'> |
130 | <Text string='"F6"'> |
131 | <FontStyle USE='MiddleMiddle'/> |
132 | </Text> |
133 | <Appearance USE='SelectionAppearance'/> |
134 | </Shape> |
135 | <Shape DEF='Seven'> |
136 | <Text string='"F7"'> |
137 | <FontStyle USE='MiddleMiddle'/> |
138 | </Text> |
139 | <Appearance USE='SelectionAppearance'/> |
140 | </Shape> |
141 | <Shape DEF='Eight'> |
142 | <Text string='"F8"'> |
143 | <FontStyle USE='MiddleMiddle'/> |
144 | </Text> |
145 | <Appearance USE='SelectionAppearance'/> |
146 | </Shape> |
147 | <Shape DEF='Nine'> |
148 | <Text string='"F9"'> |
149 | <FontStyle USE='MiddleMiddle'/> |
150 | </Text> |
151 | <Appearance USE='SelectionAppearance'/> |
152 | </Shape> |
153 | <Shape DEF='Ten'> |
154 | <Text string='"F10"'> |
155 | <FontStyle USE='MiddleMiddle'/> |
156 | </Text> |
157 | <Appearance USE='SelectionAppearance'/> |
158 | </Shape> |
159 | <Shape DEF='Eleven'> |
160 | <Text string='"F11"'> |
161 | <FontStyle USE='MiddleMiddle'/> |
162 | </Text> |
163 | <Appearance USE='SelectionAppearance'/> |
164 | </Shape> |
165 | <Shape DEF='Twelve'> |
166 | <Text string='"F12"'> |
167 | <FontStyle USE='MiddleMiddle'/> |
168 | </Text> |
169 | <Appearance USE='SelectionAppearance'/> |
170 | </Shape> |
171 | <Shape DEF='Thirteen'> |
172 | <Text string='"13: HOME"'> |
173 | <FontStyle USE='MiddleMiddle'/> |
174 | </Text> |
175 | <Appearance USE='SelectionAppearance'/> |
176 | </Shape> |
177 | <Shape DEF='Fourteen'> |
178 | <Text string='"14: END"'> |
179 | <FontStyle USE='MiddleMiddle'/> |
180 | </Text> |
181 | <Appearance USE='SelectionAppearance'/> |
182 | </Shape> |
183 | <Shape DEF='Fifteen'> |
184 | <Text string='"15: LEFT"'> |
185 | <FontStyle USE='MiddleMiddle'/> |
186 | </Text> |
187 | <Appearance USE='SelectionAppearance'/> |
188 | </Shape> |
189 | <Shape DEF='Sixteen'> |
190 | <Text string='"16: RIGHT"'> |
191 | <FontStyle USE='MiddleMiddle'/> |
192 | </Text> |
193 | <Appearance USE='SelectionAppearance'/> |
194 | </Shape> |
195 | <Shape DEF='Seventeen'> |
196 | <Text string='"17: UP"'> |
197 | <FontStyle USE='MiddleMiddle'/> |
198 | </Text> |
199 | <Appearance USE='SelectionAppearance'/> |
200 | </Shape> |
201 | <Shape DEF='Eighteen'> |
202 | <Text string='"18: DOWN"'> |
203 | <FontStyle USE='MiddleMiddle'/> |
204 | </Text> |
205 | <Appearance USE='SelectionAppearance'/> |
206 | </Shape> |
207 | <Shape DEF='Nineteen'> |
208 | <Text string='"19: PGUP"'> |
209 | <FontStyle USE='MiddleMiddle'/> |
210 | </Text> |
211 | <Appearance USE='SelectionAppearance'/> |
212 | </Shape> |
213 | <Shape DEF='Twenty'> |
214 | <Text string='"20: PGDN"'> |
215 | <FontStyle USE='MiddleMiddle'/> |
216 | </Text> |
217 | <Appearance USE='SelectionAppearance'/> |
218 | </Shape> |
219 | </Switch> |
220 | </Transform> |
221 | </Billboard> |
222 | </Scene> |
223 | </X3D> |
Event Graph ROUTE Table entries with 2 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.
StartMessageTouched
TouchSensor isOver SFBool |
SingleKeySensor
KeySensor enabled SFBool |
then
|
SingleKeySensor
KeySensor actionKeyPress SFInt32 |
ActivationKeyMessageSwitch
Switch whichChoice SFInt32 |
<!--
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)
<ProtoDeclare
name='ProtoName'>
<field
name='fieldName'/> </ProtoDeclare>
-->
<!-- For additional help information about X3D scenes, please see X3D Tooltips, X3D Resources, and X3D Scene Authoring Hints. -->