-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
205 lines (179 loc) · 6.21 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" href="favicon.ico" />
<title>Voxels <-> slexoV</title>
<meta name="description" content="voxels">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/app.css">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/dot-luv/jquery-ui.min.css">
<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
</head>
<body>
<div id="main"></div>
<div id="dialog" title="Voxels <-> slexoV">
<p>Drag to move the view.</p>
<p>Scroll / pinch to zoom.</p>
<p>Pick a face and glue a new voxel to it.</p>
<p>Double click / tap to remove a voxel.</p>
</div>
<div id="topbarLeft" class="gui">
<input type="checkbox" id="axis"><label id="axisLabel" for="axis">Show axis</label>
<input type="checkbox" id="rndColors"><label id="rndColorsLabel" for="rndColors">Random colors</label>
<p>Borders width</p>
<div id="bordersSlider" class="slider"></div>
</div>
<div id="topbarRight" class="gui">
<button id="reset">reset</button>
<button id="save">save</button>
<button id="screenshot">screenshot</button>
<button id="fullscreen">fullscreen</button>
<button id="showHelp">?</button>
</div>
<div id="leftColumn" class="gui">
<ul id="menu0" class="ui-menu ui-widget menu"></ul>
<ul id="menu1" class="ui-menu ui-widget menu"></ul>
<img id="centerView" class="menu" width='48' height='48' src='images/Meeting_point_64.png' />
</div>
<div id="rightColumn" class="gui">
<input type="color" id="color" value="#ffffff" />
<input type="color" id="centerColor" value="#ffffff" />
</div>
<div id="clipboard" title="Link to your build - copy it to save it"></div>
<script id="shader-fs" type="x-shader/x-fragment">#ifdef GL_ES
#extension GL_OES_standard_derivatives : enable
#endif
// uniform vec4 u_color;
uniform vec3 u_borderColor;
uniform float u_borderWidth;
varying vec3 v_color;
varying float v_centerFlag;
varying float v_highlightVoxel;
varying float v_highlightFace;
float edgeFactor(const float thickness, const float centerFlag)
{
return smoothstep(0.0, fwidth(centerFlag)*thickness, centerFlag);
}
void main()
{
vec3 col = v_color;
float c = 0.5+0.5*cos(3.0*6.28*v_centerFlag);
// variant: thinner, sharper stripes
// if ( c > 0.85 ) {
// if ( v_highlightFace > 0.0 ) {
// col.r = 1.0;
// col.g = 0.2;
// col.b = 0.0;
// }
// else if ( v_highlightVoxel > 0.0 ) {
// col.r = 0.0;
// col.g = 0.0;
// col.b = 0.0;
// }
// }
if ( v_highlightFace > 0.0 ) {
col.r = c * col.r + (1.0-c);
col.g = c * col.g + 0.2*(1.0-c);
col.b = c * col.b;
}
else if ( v_highlightVoxel > 0.0 ) {
col.r = c*col.r;
col.g = c*col.g;
col.b = c*col.b;
}
float f = edgeFactor(u_borderWidth, v_centerFlag);
gl_FragColor = vec4 (
mix(u_borderColor,
col,
f),
1.0
);
}</script>
<script id="shader-vs" type="x-shader/x-vertex">#ifdef GL_ES
#extension GL_OES_standard_derivatives : enable
#endif
attribute float a_centerFlag;
attribute vec3 a_normal;
attribute vec3 a_color;
attribute float a_pickColor;
uniform mat4 u_mvpMat;
uniform float u_time;
uniform float u_highlightFlag;
uniform float u_faceHighlightFlag;
varying vec3 v_color;
varying float v_centerFlag;
varying float v_highlightVoxel;
varying float v_highlightFace;
void main()
{
gl_Position = u_mvpMat * vec4(position, 1.0);
v_color = a_color;
v_centerFlag = a_centerFlag;
v_highlightVoxel = 0.0;
v_highlightFace = 0.0;
if ( u_faceHighlightFlag == a_pickColor ) {
v_highlightFace = 1.0;
} else if ( u_highlightFlag == mod(a_pickColor, 131072.0) ) {
v_highlightVoxel = 1.0;
}
}</script>
<script id="shader-pick-fs" type="x-shader/x-fragment">#ifdef GL_ES
#extension GL_OES_standard_derivatives : enable
#endif
varying vec3 v_color;
void main()
{
gl_FragColor = vec4 ( v_color, 1.0 );
}</script>
<script id="shader-pick-vs" type="x-shader/x-vertex">#ifdef GL_ES
#extension GL_OES_standard_derivatives : enable
#endif
attribute vec3 a_normal;
attribute float a_pickColor;
uniform mat4 u_mvpMat;
uniform float u_time;
varying vec3 v_color;
vec3 unpackColor(float f) {
vec3 color;
color.r = floor(f / 256.0 / 256.0);
color.g = floor((f - color.r * 256.0 * 256.0) / 256.0);
color.b = floor(f - color.r * 256.0 * 256.0 - color.g * 256.0);
// now we have a vec3 with the 3 components in range [0..255]. Let's normalize it!
return color / 255.0;
}
void main()
{
gl_Position = u_mvpMat * vec4(position, 1.0);
v_color = unpackColor(a_pickColor);
// v_color = a_pickColor;
}</script>
<script id="shader-axis-fs" type="x-shader/x-fragment">#ifdef GL_ES
#extension GL_OES_standard_derivatives : enable
#endif
varying vec3 v_color;
void main()
{
gl_FragColor = vec4 ( v_color, 1.0 );
}</script>
<script id="shader-axis-vs" type="x-shader/x-vertex">#ifdef GL_ES
#extension GL_OES_standard_derivatives : enable
#endif
attribute vec3 a_color;
uniform mat4 u_mvpMat;
varying vec3 v_color;
void main()
{
gl_Position = u_mvpMat * vec4(position, 1.0);
v_color = a_color;
}</script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/three.js/r71/three.min.js"></script>
<script type="text/javascript" src="js/lib/threex.windowresize.js"></script>
<script type="text/javascript" src="js/lib/THREEx.FullScreen.js"></script>
<script type="text/javascript" src="js/lib/stats.min.js"></script>
<script type="text/javascript" src="http://hammerjs.github.io/dist/hammer.min.js"></script>
<script type="text/javascript" src="target/scala-2.11/voxels-opt.js"></script>
<script type="text/javascript" src="js/threeApp.js"></script>
</body>
</html>