-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathBezierView.html
249 lines (209 loc) · 6.96 KB
/
BezierView.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<!-- The main file which will act as the interface to BezierView
Author(s):
Ruijin Wu
Shayan Javed [shayanj at gmail.com]
Saleh Dindar
-->
<!-- TODO:
-User Interface for modifying parameters
-Rendering surfaces and surface properties (curvature, reflection lines, normals, etc.)
-Reading in multiple types
-->
<!doctype html>
<html lang="en">
<head>
<title>BezierView</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<link rel="stylesheet" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css">
</head>
<body>
<script src="js/jquery-1.7.1.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.18.min.js"></script>
<!-- The Three.js library for rendering -->
<script src="js/Three.js"></script>
<!-- The library for curvature rendering -->
<script src="js/crv.js"></script>
<!-- The library for highlight/reflectline -->
<script src="js/highlight.js"></script>
<!-- The library for bvPatch -->
<script src="js/bvPatch.js"></script>
<!-- Evaluating patches -->
<script src="js/eval.js"></script>
<!-- The library for reading patches -->
<script src="js/read.js"></script>
<!-- The library for reading patches -->
<script src="js/ObjectControls.js"></script>
<!-- The main renderer and starting point -->
<script src="js/render.js"></script>
<!-- For reading the query string -->
<script src="js/querystring.js"></script>
<script>
<!-- On window resize, resize the renderer -->
$(window).resize(function() {
setRendererSize();
}
);
<!-- User input mesh -->
function setCustomMesh() {
removeAllMeshes();
var inputText = document.getElementById("customMesh").value;
loadMesh(inputText);
}
dialogs = new Object();
var lastmenu = null;
// On startup
$(document).ready(function(){
// webgl check first
var contextNames = ["webgl","experimental-webgl","moz-webgl","webkit-3d"];
var canvas = document.createElement('canvas');
for(var i = 0; i < contextNames.length; i++){
try{
gl = canvas.getContext(contextNames[i]);
if(gl){
break;
}
}catch(e){
continue;//noWebGL("Unfortunately, there's a WebGL compatibility problem. </br> You may want to check your system settings.");
//return;
}
}
if(gl === undefined) {
alert("WebGL has not been detected on your system. Please check your settings.");
return;
}
// Menu and Gui setup
for( m in $('div.menu')) {
$(".title", m).click(function(){
if(lastmenu!=null)
$(lastmenu).hide();
lastmenu =
$("+ .content",this).slideDown("fast");
return false;
});
}
model = queryString("model");
var viewer = init(default_mesh);
$('#glviewer').replaceWith(viewer);
animate();
$('div.dialog').each(function(index){
var t = $(".title", this);
dialogs[$(this).attr('ID')]=
$(this).dialog({ autoOpen:false, title: t });
return true;
});
dialogs['custominput']=createCustomInputDialog();
dialogs['welcome'].dialog('open');
});
$(document).click(function(ev) {
$(".content").slideUp("fast");
});
function createCustomInputDialog(){
return $("#custominput").dialog({
autoOpen: false, width: 400, height: 330,
title: $("#custominput .title"),
buttons: {
"Update": function () {
setCustomMesh();
}
}
});
}
function gallery_select(filename){
setMesh(filename);
//removeAllMeshes();
//loadMeshFromFile(filename);
}
function closedialog(name){
dialogs[name].dialog('close');
}
function showdialog(name){
dialogs[name].dialog('open');
}
</script>
<!-- UI -->
<div id="ui">
<!-- Meshes -->
<div id="uibg"> </div>
<div class="menubar">
<div class="apptitle">BezierView WebGL</div>
<div class="menu" >
<div class="title" >Mesh</div>
<ul class="content" style="width:10em" >
<li>
<a href="javascript:" onclick="showdialog('gallery')">Mesh Gallery</a>
</li><li>
<a href="javascript:" onclick="showdialog('custominput')">BV Text Input</a>
</li><li>
</li>
</ul>
</div>
<div class="menu" >
<div class="title" >Show</div>
<ul class="content" style="width:10em" >
<li>
<input type = "checkbox" checked="checked" id="cb_controlMesh" onClick="toggle_controlMeshes(true);"/>
<label for="cb_controlMesh" >Control Mesh</label>
</li>
<li>
<input type = "checkbox" checked="checked" id="cb_patches" onClick="toggle_patches(true);"/>
<label for="cb_patches">Patches</label>
</li>
</ul>
</div>
<div class="menu" >
<div class="title" >View</div>
<ul class="content" style="width:20em" >
<li>
<input type="radio" name="renderMode" value="normal" id="normal"
onclick="setRenderMode(bvPatch.Normal);"
checked = "checked"><label for="normal" >Regular</label>
</li><li>
<input type="radio" name="renderMode" value="crv" id="crv"
onclick="setRenderMode(bvPatch.CurvatureColor);">
<label for="crv" >Curvature </label>
</li><li>
<input type="radio" name="renderMode" value="highlight" id="highlight"
onclick="setRenderMode(bvPatch.HighlightLine);"
>
<label for="highlight" >Highlight Lines </label>
</li><li>
<input type="radio" name="renderMode" value="reflect" id="reflect"
onclick="setRenderMode(bvPatch.ReflectionLine);">
<label for="reflect" >Reflection Lines </label>
</li>
</ul>
</div>
</div>
</div>
<div id="gallery" class="dialog" >
<span class="title">Mesh Gallery</span>
<ul>
<li><a href="javascript:" onclick="gallery_select('data/cube.bv')">Cube(Polyhedron)</a></li>
<li><a href="javascript:" onclick="gallery_select('data/dtorus.bv')">Double torus</a></li>
<li><a href="javascript:" onclick="gallery_select('data/hand.bv')">Hand (Rational)</a></li>
<li><a href="javascript:" onclick="gallery_select('data/tri1.bv')">Triangular Bezier</a></li>
<li><a href="javascript:" onclick="gallery_select('data/hex2.bv')">Hex2 (Tensor-product)</a></li>
</ul>
</div>
<!-- Initial dialog -->
<div id="welcome" class="dialog" >
<span class="title">Welcome to BezierView</span>
<ul>
<li><a href="javascript:" onclick="showdialog('gallery'); closedialog('welcome');">
Select a mesh from our gallery</a></li>
<li><a href="javascript:" onclick="showdialog('custominput'); closedialog('welcome');">
Enter the text of your .BV file</a></li>
</ul>
</div>
<!-- Custom mesh input -->
<div id="custominput" style="padding:0px;display:none" >
<div class="title" >Text Input</div>
<textarea id="customMesh" name="custom" style="width:97%;height:95%" rows="15">
</textarea>
</div>
<!-- DOM element to hold the WebGL renderer element -->
<div id="viewer" ><div id="glviewer"></div></div>
</body>
</html>