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='BindingOperations.x3d'/> |
6 | <meta name='description' content='Illustrate Viewpoint binding operations (in gory detail!) as described in Chapter 4 concepts. Scene design: a TimeSensor clock drives and IntegerSequencer for each t0/t1/etc. event, and a customized Script node sends bind/unbind events to the correct Viewpoint. Display the browser console to see occurrence of each event.'/> |
7 | <meta name='creator' content='Don Brutzman'/> |
8 | <meta name='created' content='5 January 2008'/> |
9 | <meta name='modified' content='4 August 2024'/> |
10 | <meta name='reference' content='BindingOperations.console.txt'/> |
11 | <meta name='reference' content='BindingStackOperations.png'/> |
12 | <meta name='reference' content='X3D for Web Authors, Section 2.5.1, Figure 4.1'/> |
13 | <meta name='reference' content='https://X3dGraphics.com'/> |
14 | <meta name='reference' content='https://www.web3d.org/x3d/content/examples/X3dResources.html'/> |
15 | <meta name='rights' content='Copyright Don Brutzman and Leonard Daly 2007'/> |
16 | <meta name='subject' content='X3D book, X3D graphics, X3D-Edit, http://www.x3dGraphics.com'/> |
17 | <meta name='identifier' content='https://www.web3d.org/x3d/content/examples/X3dForWebAuthors/Chapter04ViewingNavigation/BindingOperations.x3d'/> |
18 | <meta name='generator' content='X3D-Edit 4.0, https://savage.nps.edu/X3D-Edit'/> |
19 | <meta name='license' content='../license.html'/> |
20 | </head> |
21 | <Scene> |
22 | <WorldInfo title='BindingOperations.x3d'/> |
23 |
<!-- ROUTE information for View1 node:
[from BindingSequencerEngine.bindView1 to set_bind
]
[from isBound to BindingSequencerEngine.view1Bound
]
-->
<Viewpoint DEF='View1' centerOfRotation='-6 0 0' description='Viewpoint 1' position='-6 0 5'/> |
24 |
<!-- ROUTE information for View2 node:
[from BindingSequencerEngine.bindView2 to set_bind
]
[from isBound to BindingSequencerEngine.view2Bound
]
-->
<Viewpoint DEF='View2' centerOfRotation='-2 0 0' description='Viewpoint 2' position='-2 0 5'/> |
25 |
<!-- ROUTE information for View3 node:
[from BindingSequencerEngine.bindView3 to set_bind
]
[from isBound to BindingSequencerEngine.view3Bound
]
-->
<Viewpoint DEF='View3' centerOfRotation='2 0 0' description='Viewpoint 3' position='2 0 5'/> |
26 |
<!-- ROUTE information for View4 node:
[from BindingSequencerEngine.bindView4 to set_bind
]
[from isBound to BindingSequencerEngine.view4Bound
]
-->
<Viewpoint DEF='View4' centerOfRotation='6 0 0' description='Viewpoint 4' position='6 0 5'/> |
27 | <!-- Script initialization ought to first bind view5 below. --> |
28 | <Group> |
29 | <Transform DEF='Text1' translation='-6 0 0'> |
30 | <Shape> |
31 | <Text string='"View" "# 1"'> |
32 |
<!-- FontStyle
CenterJustify is a DEF node that has 3 USE nodes: USE_1, USE_2, USE_3 --> <FontStyle DEF='CenterJustify' justify='"MIDDLE" "MIDDLE"'/> |
33 | </Text> |
34 | <Appearance> |
35 | <Material diffuseColor='1 0 0'/> |
36 | </Appearance> |
37 | </Shape> |
38 | </Transform> |
39 | <Transform DEF='Text2' translation='-2 0 0'> |
40 | <Shape> |
41 | <Text string='"View" "# 2"'> |
42 | <FontStyle USE='CenterJustify'/> |
43 | </Text> |
44 | <Appearance> |
45 | <Material diffuseColor='0 1 0'/> |
46 | </Appearance> |
47 | </Shape> |
48 | </Transform> |
49 | <Transform DEF='Text3' translation='2 0 0'> |
50 | <Shape> |
51 | <Text string='"View" "# 3"'> |
52 | <FontStyle USE='CenterJustify'/> |
53 | </Text> |
54 | <Appearance> |
55 | <Material diffuseColor='0 0 1'/> |
56 | </Appearance> |
57 | </Shape> |
58 | </Transform> |
59 | <Transform DEF='Text4' translation='6 0 0'> |
60 | <Shape> |
61 | <Text string='"View" "# 4"'> |
62 | <FontStyle USE='CenterJustify'/> |
63 | </Text> |
64 | <Appearance> |
65 | <Material/> |
66 | </Appearance> |
67 | </Shape> |
68 | </Transform> |
69 | </Group> |
70 | <!-- The following advanced animation sequence uses nodes covered in Chapters 7, 8 and 9. --> |
71 | <!-- It does not need to be studied in this chapter. --> |
72 | <Transform translation='0 -3 8'> |
73 | <!-- notice this next Viewpoint has been transformed with the text, so its position is relative. it is called view5 in the Script. --> |
74 |
<!-- ROUTE information for ClickToAnimateView node:
[from BindingSequencerEngine.bindView5 to set_bind
]
-->
<Viewpoint DEF='ClickToAnimateView' description='Select animation sequence' position='0 0 7'/> |
75 | <Shape> |
76 | <Text string='"Click here to animate"'> |
77 | <FontStyle justify='"MIDDLE" "BEGIN"'/> |
78 | </Text> |
79 | <Appearance> |
80 | <Material diffuseColor='0.8 0.4 0'/> |
81 | </Appearance> |
82 | </Shape> |
83 | <Shape> |
84 | <Box size='7 1 0.02'/> |
85 | <Appearance> |
86 | <Material transparency='1'/> |
87 | </Appearance> |
88 | </Shape> |
89 |
<!-- ROUTE information for TextTouchSensor node:
[from touchTime to Clock.set_startTime
]
-->
<TouchSensor DEF='TextTouchSensor' description='Click to begin animating viewpoint selections'/> |
90 |
<!-- ROUTE information for Clock node:
[from TextTouchSensor.touchTime to set_startTime
]
[from fraction_changed to TimingSequencer.set_fraction
]
-->
<TimeSensor DEF='Clock' cycleInterval='10'/> |
91 | < ROUTE fromNode='TextTouchSensor' fromField='touchTime' toNode='Clock' toField='set_startTime'/> |
92 |
<!-- ROUTE information for TimingSequencer node:
[from Clock.fraction_changed to set_fraction
]
[from value_changed to BindingSequencerEngine.set_timeEvent
]
-->
<IntegerSequencer DEF='TimingSequencer' key='0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 1.0' keyValue='0 1 2 3 4 5 6 7 8 10'/> |
93 | < ROUTE fromNode='Clock' fromField='fraction_changed' toNode='TimingSequencer' toField='set_fraction'/> |
94 |
<!-- ROUTE information for BindingSequencerEngine node:
[from TimingSequencer.value_changed to set_timeEvent
]
[from View1.isBound to view1Bound
]
[from View2.isBound to view2Bound
]
[from View3.isBound to view3Bound
]
[from View4.isBound to view4Bound
]
[from bindView1 to View1.set_bind
]
[from bindView2 to View2.set_bind
]
[from bindView3 to View3.set_bind
]
[from bindView4 to View4.set_bind
]
[from bindView5 to ClickToAnimateView.set_bind
]
-->
<Script DEF='BindingSequencerEngine'> |
95 | <field name='set_timeEvent' type='SFInt32' accessType='inputOnly'/> |
96 | <field name='bindView1' type='SFBool' accessType='outputOnly'/> |
97 | <field name='bindView2' type='SFBool' accessType='outputOnly'/> |
98 | <field name='bindView3' type='SFBool' accessType='outputOnly'/> |
99 | <field name='bindView4' type='SFBool' accessType='outputOnly'/> |
100 | <field name='bindView5' type='SFBool' accessType='outputOnly'/> |
101 | <field name='view1Bound' type='SFBool' accessType='inputOnly'/> |
102 | <field name='view2Bound' type='SFBool' accessType='inputOnly'/> |
103 | <field name='view3Bound' type='SFBool' accessType='inputOnly'/> |
104 | <field name='view4Bound' type='SFBool' accessType='inputOnly'/> |
105 | <field name='priorInputvalue' type='SFInt32' value='-1' accessType='initializeOnly'/> |
<![CDATA[
ecmascript: function initialize () { bindView5 = true; Browser.println ('Timing script initialized and ready for activation'); } function set_timeEvent (inputValue) { if (inputValue == priorInputvalue) { return; // ignore repeated inputs } // new value provided priorInputvalue = inputValue; // Browser.println ('timeEvent inputValue=' + inputValue); // mimics user execution of Figure 4.1 steps t_0 through t_8 if (inputValue == 0) { Browser.println ('==========='); Browser.println ('time t0'); bindView1 = true; } else if (inputValue == 1) { Browser.println ('==========='); Browser.println ('time t1'); bindView2 = true; } else if (inputValue == 2) { Browser.println ('==========='); Browser.println ('time t2'); bindView3 = true; } else if (inputValue == 3) { Browser.println ('==========='); Browser.println ('time t3'); bindView3 = false; } else if (inputValue == 4) { Browser.println ('==========='); Browser.println ('time t4'); bindView1 = true; } else if (inputValue == 5) { Browser.println ('==========='); Browser.println ('time t5'); bindView2 = false; } else if (inputValue == 6) { Browser.println ('==========='); Browser.println ('time t6'); bindView1 = false; } else if (inputValue == 7) { Browser.println ('==========='); Browser.println ('time t7'); bindView4 = true; } else if (inputValue == 8) { Browser.println (); Browser.println ('==========='); Browser.println ('time t8, no action, all done'); } } function view1Bound (inputValue) { Browser.println (', view1Bound ' + (inputValue)); if (priorInputvalue == -1) Browser.println (); } function view2Bound (inputValue) { Browser.println (', view2Bound ' + (inputValue)); } function view3Bound (inputValue) { Browser.println (', view3Bound ' + (inputValue)); } function view4Bound (inputValue) { Browser.println (', view4Bound ' + (inputValue)); } function view5Bound (inputValue) { Browser.println (', view5Bound ' + (inputValue)); }
]]>
|
|
107 | </Script> |
108 | <!-- drive Script with TimeSensor clock --> |
109 | < ROUTE fromNode='TimingSequencer' fromField='value_changed' toNode='BindingSequencerEngine' toField='set_timeEvent'/> |
110 | <!-- Script will bind and unbind Viewpoint nodes --> |
111 | < ROUTE fromNode='BindingSequencerEngine' fromField='bindView1' toNode='View1' toField='set_bind'/> |
112 | < ROUTE fromNode='BindingSequencerEngine' fromField='bindView2' toNode='View2' toField='set_bind'/> |
113 | < ROUTE fromNode='BindingSequencerEngine' fromField='bindView3' toNode='View3' toField='set_bind'/> |
114 | < ROUTE fromNode='BindingSequencerEngine' fromField='bindView4' toNode='View4' toField='set_bind'/> |
115 | < ROUTE fromNode='BindingSequencerEngine' fromField='bindView5' toNode='ClickToAnimateView' toField='set_bind'/> |
116 | <!-- Viewpoint nodes report bind and unbind events to Script for recording results --> |
117 | < ROUTE fromNode='View1' fromField='isBound' toNode='BindingSequencerEngine' toField='view1Bound'/> |
118 | < ROUTE fromNode='View2' fromField='isBound' toNode='BindingSequencerEngine' toField='view2Bound'/> |
119 | < ROUTE fromNode='View3' fromField='isBound' toNode='BindingSequencerEngine' toField='view3Bound'/> |
120 | < ROUTE fromNode='View4' fromField='isBound' toNode='BindingSequencerEngine' toField='view4Bound'/> |
121 | <!-- Note that Script inputs do not cause Script outputs, and therefore no event loops occur. --> |
122 | <!-- It is possible to silence event-loop diagnostic warnings by separating the functionality of Script inputs and outputs into two separate Script nodes. --> |
123 | </Transform> |
124 | </Scene> |
125 | </X3D> |
Event Graph ROUTE Table entries with 12 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.
<!--
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. -->