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='EventUtilityPrototypes.x3d'/> |
6 | <meta name='description' content='Event utility node prototypes for boolean filtering and other event utility nodes.'/> |
7 | <meta name='creator' content='Nick Polys, Tony Parisi, Don Brutzman, Justin Couch'/> |
8 | <meta name='created' content='25 September 2002'/> |
9 | <meta name='modified' content='20 January 2020'/> |
10 | <meta name=' warning ' content=' Under development, IntegerTrigger example needed. '/> |
11 | <meta name='reference' content='EventUtilityExamples.x3d'/> |
12 | <meta name='subject' content='BooleanFilter BooleanToggle BooleanTrigger IntegerTrigger TimeTrigger'/> |
13 | <meta name='identifier' content='https://www.web3d.org/x3d/content/examples/Basic/development/EventUtilityPrototypes.x3d'/> |
14 | <meta name='generator' content='X3D-Edit 3.3, https://savage.nps.edu/X3D-Edit'/> |
15 | <meta name='license' content='../license.html'/> |
16 | </head> |
17 | <Scene> |
18 | <WorldInfo title='EventUtilityPrototypes.x3d'/> |
19 | <ProtoDeclare name='BooleanFilter' appinfo='BooleanFilter selectively passes true false or negated events.'> |
20 | <ProtoInterface> |
21 |
<field name='set_boolean' type='SFBool' accessType='inputOnly'
appinfo='set_boolean is the input value to be filtered.'/> |
22 |
<field name='inputTrue' type='SFBool' accessType='outputOnly'
appinfo='inputTrue only passes a true value when set_boolean input is true.'/> |
23 |
<field name='inputFalse' type='SFBool' accessType='outputOnly'
appinfo='inputFalse only passes a false value when set_boolean is false.'/> |
24 |
<field name='inputNegate' type='SFBool' accessType='outputOnly'
appinfo='inputNegate provides opposite value by negating set_boolean input.'/> |
25 | </ProtoInterface> |
26 | <ProtoBody> |
27 | <Script DEF='BooleanFilterScript'> |
28 | <field name='set_boolean' type='SFBool' accessType='inputOnly'/> |
29 | <field name='inputTrue' type='SFBool' accessType='outputOnly'/> |
30 | <field name='inputFalse' type='SFBool' accessType='outputOnly'/> |
31 | <field name='inputNegate' type='SFBool' accessType='outputOnly'/> |
32 | <IS> |
33 | <connect nodeField='set_boolean' protoField='set_boolean'/> |
34 | <connect nodeField='inputTrue' protoField='inputTrue'/> |
35 | <connect nodeField='inputFalse' protoField='inputFalse'/> |
36 | <connect nodeField='inputNegate' protoField='inputNegate'/> |
37 | </IS> |
<![CDATA[
ecmascript: function set_boolean (value, timestamp) { if (value) inputTrue = value; else inputFalse = value; inputNegate = !value; // if (value) Browser.println ('[BooleanFilter] set_boolean=' + value + ', inputTrue=' + inputTrue + ', inputNegate=' + inputNegate); // else Browser.println ('[BooleanFilter] set_boolean=' + value + ', inputFalse=' + inputFalse + ', inputNegate=' + inputNegate); }
]]>
|
|
39 | </Script> |
40 | </ProtoBody> |
41 | </ProtoDeclare> |
42 | <!-- ======================================== --> |
43 | <ProtoDeclare name='BooleanToggle' appinfo='BooleanToggle maintains state and negates output when a true input is provided.'> |
44 | <ProtoInterface> |
45 |
<field name='set_boolean' type='SFBool' accessType='inputOnly'
appinfo='If set_boolean input is true toggle state.'/> |
46 |
<field name='set_toggle' type='SFBool' accessType='inputOnly'
appinfo='Reset persistent state value.'/> |
47 |
<field name='toggle' type='SFBool' value='false' accessType='initializeOnly'
appinfo='Persistent state value that gets toggled or reset.'/> |
48 |
<field name='toggle_changed' type='SFBool' accessType='outputOnly'
appinfo='Output toggled persistent state value.'/> |
49 | <!-- warning: toggle depends on exposedField functionality in Script node, not compatible with VRML 97. implemented as inputOnly/initializeOnly/outputOnly triplet. --> |
50 | </ProtoInterface> |
51 | <ProtoBody> |
52 | <Group> |
53 | <Script DEF='BooleanToggleScript'> |
54 | <field name='set_boolean' type='SFBool' accessType='inputOnly'/> |
55 | <field name='set_toggle' type='SFBool' accessType='inputOnly'/> |
56 | <field name='toggle' type='SFBool' value='false' accessType='initializeOnly'/> |
57 | <field name='toggle_changed' type='SFBool' accessType='outputOnly'/> |
58 | <field name='traceEnabled' type='SFBool' value='false' accessType='initializeOnly'/> |
59 | <IS> |
60 | <connect nodeField='set_boolean' protoField='set_boolean'/> |
61 | <connect nodeField='set_toggle' protoField='set_toggle'/> |
62 | <connect nodeField='toggle_changed' protoField='toggle_changed'/> |
63 | </IS> |
<![CDATA[
ecmascript: function initialize () { if (traceEnabled) Browser.println ('[BooleanToggle] toggle=' + toggle); } function set_boolean (value, timestamp) { if (value == true) // only toggle on true input { if (toggle == true) toggle = false; else toggle = true; } toggle_changed = toggle; // Browser.println ('[BooleanToggle] traceEnabled=' + traceEnabled); if (traceEnabled) Browser.println ('[BooleanToggle] set_boolean=' + value + ', toggle=' + toggle); } function set_toggle (value, timestamp) { toggle = value; toggle_changed = toggle; if (traceEnabled) Browser.println ('[BooleanToggle] set_toggle=' + set_toggle); }
]]>
|
|
65 | </Script> |
66 | </Group> |
67 | </ProtoBody> |
68 | </ProtoDeclare> |
69 | <!-- ======================================== --> |
70 | <ProtoDeclare name='BooleanTrigger' appinfo='BooleanTrigger converts time events to boolean true events.'> |
71 | <ProtoInterface> |
72 |
<field name='set_triggerTime' type='SFTime' accessType='inputOnly'
appinfo='set_triggerTime provides input time event typical event sent is TouchSensor touchTime.'/> |
73 |
<field name='triggerTrue' type='SFBool' accessType='outputOnly'
appinfo='triggerTrue outputs a true value whenever a triggerTime event is received.'/> |
74 | </ProtoInterface> |
75 | <ProtoBody> |
76 | <Script DEF='TriggerBooleanScript'> |
77 | <field name='set_triggerTime' type='SFTime' accessType='inputOnly'/> |
78 | <field name='triggerTrue' type='SFBool' accessType='outputOnly'/> |
79 | <IS> |
80 | <connect nodeField='set_triggerTime' protoField='set_triggerTime'/> |
81 | <connect nodeField='triggerTrue' protoField='triggerTrue'/> |
82 | </IS> |
<![CDATA[
ecmascript: function set_triggerTime (value, timestamp) { triggerTrue = true; // Browser.println ('triggerTrue = true'); }
]]>
|
|
84 | </Script> |
85 | </ProtoBody> |
86 | </ProtoDeclare> |
87 | <!-- ======================================== --> |
88 | <ProtoDeclare name='IntegerTrigger' appinfo='IntegerTrigger converts boolean true or time input events to integer value (suitable for Switch node).'> |
89 | <ProtoInterface> |
90 |
<field name='set_boolean' type='SFBool' accessType='inputOnly'
appinfo='If set_boolean input is true trigger output of integer value.'/> |
91 |
<field name='set_integerKey' type='SFInt32' accessType='inputOnly'
appinfo='Resets value used for output when triggered later.'/> |
92 |
<field name='integerKey' type='SFInt32' value='-1' accessType='inputOutput'
appinfo='integerKey is value for output when triggered.'/> |
93 |
<field name='integerKey_changed' type='SFInt32' accessType='outputOnly'
appinfo='Reports change in integerKey value.'/> |
94 |
<field name='triggerValue' type='SFInt32' accessType='outputOnly'
appinfo='triggerValue provides integer event output matching integerKey when true set_boolean received.'/> |
95 | </ProtoInterface> |
96 | <ProtoBody> |
97 | <Group> |
98 |
<!-- Switch
IntegerKeyHolder is a DEF node that has 1 USE node: USE_1 -->
<Switch DEF='IntegerKeyHolder' whichChoice='-1'> |
99 | <IS> |
100 | <connect nodeField='whichChoice' protoField='integerKey'/> |
101 | </IS> |
102 | </Switch> |
103 | <Script DEF='TriggerIntegerScript' directOutput='true'> |
104 | <field name='set_boolean' type='SFBool' accessType='inputOnly'/> |
105 | <field name='set_integerKey' type='SFInt32' accessType='inputOnly'/> |
106 | <field name='integerKeyHolderNode' type='SFNode' accessType='initializeOnly'> |
107 | <Switch USE='IntegerKeyHolder'/> |
108 | </field> |
109 | <field name='integerKey_changed' type='SFInt32' accessType='outputOnly'/> |
110 | <field name='triggerValue' type='SFInt32' accessType='outputOnly'/> |
111 | <IS> |
112 | <connect nodeField='set_boolean' protoField='set_boolean'/> |
113 | <connect nodeField='set_integerKey' protoField='set_integerKey'/> |
114 | <connect nodeField='integerKey_changed' protoField='integerKey_changed'/> |
115 | <connect nodeField='triggerValue' protoField='triggerValue'/> |
116 | </IS> |
<![CDATA[
ecmascript: function set_boolean (inputValue, timestamp) { if (inputValue == true) { integerKey = integerKeyHolderNode.whichChoice; triggerValue = integerKey; // send output event } } function set_integerKey (inputValue, timestamp) { integerKey = inputValue; integerKeyHolderNode.whichChoice = integerKey; integerKey_changed = integerKey; // send output event }
]]>
|
|
118 | </Script> |
119 | </Group> |
120 | </ProtoBody> |
121 | </ProtoDeclare> |
122 | <!-- ======================================== --> |
123 | <ProtoDeclare name='TimeTrigger' appinfo='TimeTrigger converts boolean true events to time events.'> |
124 | <ProtoInterface> |
125 |
<field name='set_boolean' type='SFBool' accessType='inputOnly'
appinfo='If set_boolean input is true trigger output time value.'/> |
126 |
<field name='triggerTime' type='SFTime' accessType='outputOnly'
appinfo='triggerTime is output time event sent when set_boolean input is true.'/> |
127 | </ProtoInterface> |
128 | <ProtoBody> |
129 | <Script DEF='TriggerTimeScript'> |
130 | <field name='set_boolean' type='SFBool' accessType='inputOnly'/> |
131 | <field name='triggerTime' type='SFTime' accessType='outputOnly'/> |
132 | <IS> |
133 | <connect nodeField='set_boolean' protoField='set_boolean'/> |
134 | <connect nodeField='triggerTime' protoField='triggerTime'/> |
135 | </IS> |
<![CDATA[
ecmascript: function set_boolean (value, timestamp) { if (value) triggerTime = timestamp; }
]]>
|
|
137 | </Script> |
138 | </ProtoBody> |
139 | </ProtoDeclare> |
140 | <!-- ======================================== --> |
141 | <Anchor description='EventUtilityExamples' parameter='"target=_blank"' url=' "EventUtilityExamples.x3d" "https://www.web3d.org/x3d/content/examples/Basic/development/EventUtilityExamples.x3d" "EventUtilityExamples.wrl" "https://www.web3d.org/x3d/content/examples/Basic/development/EventUtilityExamples.wrl" '> |
142 | <Shape> |
143 | <Text string='"EventUtilityPrototype" "defines prototypes" "" "Click text to see" "EventUtilityExamples"'> |
144 | <FontStyle justify='"MIDDLE" "MIDDLE"' size='0.9'/> |
145 | </Text> |
146 | <Appearance> |
147 | <Material diffuseColor='1 1 0.2'/> |
148 | </Appearance> |
149 | </Shape> |
150 | </Anchor> |
151 | </Scene> |
152 | </X3D> |
Event Graph ROUTE Table with 0 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.
BooleanToggleScript
Script |
No ROUTE connection found for output events from this node. This Script has no direct access to other nodes. |
Anchor |
description='EventUtilityExamples' User-interaction hint for this node. |
<!--
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. -->