-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
207 lines (190 loc) · 8.02 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>T-spline demo</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/p5@1.1.9/lib/p5.js"></script>
<style>
body{padding:0; margin:0;}
#wrapper{ display: flex; align-items: stretch; width: 100vw; height: 100vh; }
#one{ width: 90%; background-color: #6f6f6f; display: flex; flex-direction: column; }
#two{ flex-grow: 100; background-color: #fcfcfc; display: flex; flex-direction: column; }
#leiras{ min-height: 5%; background-color: #fcfcfc; display: flex; align-items: center; justify-content: center; border-right: 2px solid #6f6f6f; }
#pleir{ color: #543E00; margin: 0 2rem 0 2rem;}
#cvas{ flex-grow: 100; padding: 0; margin: 0;}
#usage{ font-weight: bold; color: darkgrey; }
input{ font-size: 14px; max-width: 3rem; }
.popuptext {
visibility: hidden;
width: 160px;
background-color: #F9FDB8;
color: black;
text-align: center;
border-radius: 6px;
padding: 8px 0;
position: fixed;
z-index: 1;
top: 100px;
left: 100px;
margin-left: 0px;
}
.show {
visibility: visible;
}
.popdiv {
padding: 0 0.25rem;
display: inline-block;
border-left: 1px solid black;
border-right: 1px solid black;
}
#mesh { visibility: hidden; position: fixed; z-index: 2; top: 7vh; left: 25vw; }
#btmesh {
background-color: #4CAF50; /* Green */
border: none;
color: white;
padding: 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
border-radius: 8px;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="one">
<div id="leiras">
<p id="pleir"><span id="usage">Usage:</span> Hover mouse above the point you want to select, and on a selected point you can adjust the x, y, z coordinates and the weight of that point, all of these are feasible by scroll up / scroll down on the corresponding part of the appearing popup. Disappear popup: mouse click. Camera moving around the object: dragging with left mouse button. Camera moves: dragging with right mouse button, original position: middle mouse button. Zoom in / out: wheel up / down. <a href="https://peterpolgar.github.io/T-spline-demo">Source code</a></p>
</div>
<div id="cvas"></div>
</div>
<div id="two" style="">
<div style="padding: 0.5rem 0 0.5rem 1rem; margin-top: 30vh"><input type="checkbox" id="cpCheck" checked='true'><span id="cpspan"> controlpoints visible</span></div>
<div style="padding: 0.5rem 0 0.5rem 1rem"><input type="checkbox" id="cnCheck" checked='true'><span id="cnspan"> controllnet visible</span></div>
<div style="padding: 0.5rem 0 0.5rem 1rem"><input type="checkbox" id="kpCheck" checked='true'><span id="kpspan"> knotnet visible</span></div>
<div style="padding: 0.5rem 0 0.5rem 1rem"><input type="checkbox" id="dmCheck"><span id="dmspan"> drawed mesh visible</span></div>
<div style="padding: 0.5rem 0 0.5rem 1rem"><button id="btmesh">Show T-mesh</button></div>
</div>
<div class="popuptext" id="myPopup" onmouseleave="LeavePopup()" onmouseenter="EnterPopup()">
<div id="xcor" class="popdiv">X</div>
<div id="ycor" class="popdiv">Y</div>
<div id="zcor" class="popdiv">Z</div>
<div id="pwt" class="popdiv">W</div>
</div>
<div id="mesh"></div>
</div>
<script src="addScreenPositionFunction.js"></script>
<script src="tspline_gl_5.min.js"></script>
<script type="text/javascript">
function LeavePopup() {
var popup = document.getElementById("myPopup");
popup.classList.remove("show");
on_point = -1;
notPopup = true;
entered_pop = false;
}
function EnterPopup() {
entered_pop = true;
}
document.getElementById('xcor').addEventListener('wheel', Fwheel);
document.getElementById('ycor').addEventListener('wheel', Fwheel);
document.getElementById('zcor').addEventListener('wheel', Fwheel);
document.getElementById('pwt').addEventListener('wheel', Fwheel);
function Fwheel(e) {
point_changed = true;
switch ( this.id[0] ) {
case 'x' : if(e.deltaY > 0) points[on_point * 3] -= 3; else points[on_point * 3] += 3; break;
case 'y' : if(e.deltaY > 0) points[on_point * 3 + 1] += 3; else points[on_point * 3 + 1] -= 3; break;
case 'z' : if(e.deltaY > 0) points[on_point * 3 + 2] += 3; else points[on_point * 3 + 2] -= 3; break;
case 'p' :
w_arr[on_point] += e.deltaY > 0 ? -1 : 1;
if ( w_arr[on_point] < 0 ) {
w_arr[on_point] = 0;
point_changed = false;
}
if ( w_arr[on_point] == 0 ) {
pointsize_arr[on_point] = 0;
}else if( w_arr[on_point] == 1 ){
pointsize_arr[on_point] = 1;
}else {
pointsize_arr[on_point] *= e.deltaY > 0 ? 0.9 : 1.1;
}
}
redraw();
}
document.getElementById('cnCheck').addEventListener('change', CnCheck);
document.getElementById('cpCheck').addEventListener('change', CpCheck);
document.getElementById('kpCheck').addEventListener('change', KpCheck);
document.getElementById('dmCheck').addEventListener('change', DmCheck);
document.getElementById('cnspan').addEventListener('click', paCnCheck);
document.getElementById('cpspan').addEventListener('click', paCpCheck);
document.getElementById('kpspan').addEventListener('click', paKpCheck);
document.getElementById('dmspan').addEventListener('click', paDmCheck);
document.getElementById('btmesh').addEventListener('click', Tmesh_visible);
function CnCheck() {
drawcn = this.checked;
redraw();
}
function CpCheck() {
drawcp = this.checked;
redraw();
}
function KpCheck() {
drawkp = this.checked;
redraw();
}
function DmCheck() {
drawdm = this.checked;
redraw();
}
function paCnCheck() {
let tmp = !document.getElementById("cnCheck").checked;
document.getElementById("cnCheck").checked = tmp;
drawcn = tmp;
redraw();
}
function paCpCheck() {
let tmp = !document.getElementById("cpCheck").checked;
document.getElementById("cpCheck").checked = tmp;
drawcp = tmp;
redraw();
}
function paKpCheck() {
let tmp = !document.getElementById("kpCheck").checked;
document.getElementById("kpCheck").checked = tmp;
drawkp = tmp;
redraw();
}
function paDmCheck() {
let tmp = !document.getElementById("dmCheck").checked;
document.getElementById("dmCheck").checked = tmp;
drawdm = tmp;
redraw();
}
var show_tmesh = false;
function Tmesh_visible() {
if ( show_tmesh ) {
document.getElementById("mesh").style.visibility = "hidden";
show_tmesh = false;
no_tmesh = true;
this.innerHTML = "Show T-mesh";
}else {
document.getElementById("mesh").style.visibility = "visible";
show_tmesh = true;
no_tmesh = false;
this.innerHTML = "Hide T-mesh";
}
}
document.getElementById("cvas").addEventListener('contextmenu', Norightclick);
function Norightclick(e) {
e.preventDefault();
return false;
}
</script>
<script src="show.js"></script>
</body>
</html>