-
Notifications
You must be signed in to change notification settings - Fork 1
/
LookSensor.html
183 lines (175 loc) · 6.76 KB
/
LookSensor.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<html>
<!--
/*
* X3DOM JavaScript Library Addition
* http://www.x3dom.org
*
* V4 additions (C)2016 Daly Realism, Los Angeles
* X3DOM (C)2009 Fraunhofer IGD, Darmstadt, Germany
* Dual licensed under the MIT and GPL
*/
-->
<head>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>
<meta http-equiv="X-UA-Compatible" content="chrome=1,IE=edge" />
<link rel='stylesheet' type='text/css' href='page.css'>
<link rel='stylesheet' type='text/css' href='http://www.x3dom.org/download/x3dom.css'/>
<script type='text/javascript' src='http://www.x3dom.org/download/x3dom.js'> </script>
<script type='text/javascript' src='../src/nodes/PointingDeviceSensor/LookSensor.js'> </script>
<link rel='stylesheet' type='text/css' href='http://www.x3dom.org/download/x3dom.css'/>
<link rel='stylesheet' type='text/css' href='LookSensor.css'>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.0.min.js" ></script>
<script src="http://realism.com/sample/model/_lib/ui/1.11.1/jquery-ui.js"></script>
<style>
.x3dom-logContainer {font-size:small;}
</style>
<script>
var counterShader = 0;
var urlSearch = window.location.search.substring(1,window.location.search.length);
var nvPairs = urlSearch.split('&');
var tf = {'1':true, 'true':true, 'TRUE':true, '0':false, 'false':false, 'FALSE':false};
var flags = {
DEBUG : 0,
DESKTOP : 0,
VIEW : 'Viewer',
X3D : 1
};
for (ii=0; ii<nvPairs.length; ii++) {
nv = nvPairs[ii].split('=');
flags[nv[0].toUpperCase()] = nv[1];
}
flags.showStats = tf[flags.DEBUG];
flags.showLog = tf[flags.DEBUG];
flags.DESKTOP = tf[flags.DESKTOP];
flags.X3D = tf[flags.X3D];
if (flags.DESKTOP) {
//alert ('Loading jQuery-ui');
document.writeln ('<scri' + 'pt src="lib/jquery-ui-1.11.4/jquery-ui.js"></scr' + 'ipt>');
document.writeln ('<link rel="stylesheet" type="text/css" href="lib/jquery-ui-1.11.4/jquery-ui.css">');
}
</script>
<!-- link rel="stylesheet" href="http://realism.com/sample/model/_lib/ui/1.11.1/themes/smoothness/jquery-ui.css" -->
<style type='text/css' media='all'>
#goFullScreen {font-size:200%; font-weight:bold; position:absolute; height30px; width:300px; border:1 solid black; background-color:white; border-radius:7px; z-index:2; top:0px; left:250px; text-align:center; padding:10px 0 10px 0; }
</style>
</head>
<body style='width:100%; height:100%; border:0; margin:0; padding:0;'>
<div>
<b>Sensor:</b> <span id='sensor'>0</span>;
<b>Event:</b> <span id='event'>0</span>;
<div>
<b>Raw – </b>
<b>α:</b> <span id='alpha'>0.0</span>;
<b>β:</b> <span id='beta'>0.0</span>;
<b>γ</b>: <span id='gamma'>0.0</span>
</div>
<div>
<b>Adjusted – </b>
<b>α:</b> <span id='alpha_adj'>0.0</span>;
<b>β:</b> <span id='beta_adj'>0.0</span>;
<b>γ</b>: <span id='gamma_adj'>0.0</span>
</div>
<div id='goFullScreen'>Go Full Screen</div>
</div>
<div id='description' style='width:40em; '>
<p>This example tests the <b>LookSensor</b> node. The <b>LookSensor</b> node is declared to only consider <b>Shape</b> nodes that have the 'side' <i>class</i> attribute. In this example that is the cone and sphere. When either of those shapes is under the target marker, the marker begins its countdown. When the countdown is complete an HTML DOM <i>click</i> is generated and handled by the <i>onclick</i> handler for that shape.</p>
</div>
<div id='scene'>
<script>
if (flags.X3D) {
document.writeln ('<X3D id="x3dElement" x="0px" y="0px" width="768px" height="384px" showStat="' + flags.showStats + '" showLog="' + flags.showLog + '" >');
} else {
document.writeln ("<div style='display:none'>");
}
</script>
<scene id='Basx3DScene'>
<navigationInfo headlight='true' type='"EXAMINE" "WALK"'></navigationInfo>
<viewpoint DEF='vp' centerOfRotation='0 0 0' position='0 0 10'></viewpoint>
<background DEF='bgnd' skyColor="0.4 0.4 0.5"></background>
<Transform DEF='CenterBox' translation='0 0 0'>
<Shape id='center_box' class='s1' onclick='clickBox(event); return false;'>
<Box size='1 1 1'></Box>
<Appearance>
<Material diffusecolor='1 0 0'></Material>
</Appearance>
</Shape>
</Transform>
<Transform DEF='LeftSphere' translation='-4 0 0'>
<Shape id='left_sphere' class='s2 side' onclick='clickSphere(event); return false;'>
<Sphere radius='.5'></Sphere>
<Appearance>
<Material diffusecolor='0 1 0'></Material>
</Appearance>
</Shape>
</Transform>
<Transform DEF='RightCone' translation='4 0 0'>
<Shape id='right_cone' class='s3 side'>
<Cone height='1' bottomRadius='.5'></Cone>
<Appearance>
<Material diffusecolor='0 0 1'></Material>
</Appearance>
</Shape>
</Transform>
<LookSensor enabled='TRUE' objectClass='side'></LookSensor>
</scene>
<script>
if (flags.X3D) {
document.writeln ('</X3D>');
} else {
document.writeln ('</div>');
}
</script>
</div>
<div style='float:right; overflow:scroll; height:450px; width:450px; '>
<div style='background-color:white; width:16px; height:16px; padding:8px; border:1px black solid; float:left; '>
<div id='x3dom_LookSensor_target' class='x3dom_LookSensor_border1'>
<div class='x3dom_LookSensor_border2'>
<div id='x3dom_LookSensor_time1' class='x3dom_LookSensor_time1'>
<div id='x3dom_LookSensor_time2' class='x3dom_LookSensor_time2'>
<div id='x3dom_LookSensor_time3' class='x3dom_LookSensor_time3'>
</div>
</div>
</div>
</div>
</div>
</div>
<div style='background-color:black; width:16px; height:16px; padding:8px; border:1px white solid; float:left; '>
<div id='x3dom_LookSensor_target' class='x3dom_LookSensor_border1'>
<div class='x3dom_LookSensor_border2'>
<div id='x3dom_LookSensor_time1' class='x3dom_LookSensor_time1'>
<div id='x3dom_LookSensor_time2' class='x3dom_LookSensor_time2'>
<div id='x3dom_LookSensor_time3' class='x3dom_LookSensor_time3'>
</div>
</div>
</div>
</div>
</div>
</div>
<div style='clear:both;'>
<h3>Debug log</h3>
<div id='log_debug' style='overflow:scroll; height:350px; width:430px;'>
</div>
</div>
</div>
<script>
function clickSphere (t) {
jQuery('#log_debug').prepend('<div>Sphere click handler</div>');
}
function clickCone (t) {
jQuery('#log_debug').prepend('<div>Cone click handler</div>');
}
function clickBox (t) {
jQuery('#log_debug').prepend('<div>Box click handler</div>');
}
function clickHandler (ev) {
jQuery('#log_debug').prepend('<div>Event handler</div>');
}
var e = document.getElementById('x3dElement');
e.addEventListener('click', clickHandler, false);
e = document.getElementById('goFullScreen');
e.addEventListener('click', clickHandler, false);
e = document.getElementById('center_box');
e.addEventListener('click', clickHandler, false);
</script>
</body>
</html>