-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
334 lines (282 loc) · 11.7 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
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!doctype html>
<html>
<head>
<title>livery customizer demo</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r120/three.min.js" integrity="sha512-kgjZw3xjgSUDy9lTU085y+UCVPz3lhxAtdOVkcO4O2dKl2VSBcNsQ9uMg/sXIM4SoOmCiYfyFO/n1/3GSXZtSg==" crossorigin="anonymous"></script>
<script src='src/GLTFLoader.js'></script>
<script src='src/TrackballControls.js'></script>
<script src='src/GLTFExporter.js'></script>
</head>
<style>
body {
font-family: monospace;
}
#header {
text-align: center;
position: relative;
display: block;
padding: 0px 5px 5px 5px;
}
#controls {
position: fixed;
top: 0;
border: 1px solid #000;
padding: 1%;
background-color: rgba(255, 255, 255, 0.98);
z-index: 100;
height: 100%;
overflow-y: auto;
box-sizing: border-box;
}
.controls-off {
width: 0;
left: -300px;
transition: 0.5s;
}
.controls-on {
left: 0;
width: 15%;
transition: 0.5s;
}
.section-title {
font-weight: bold;
text-align: center;
}
#colorWheel {
display: block;
margin: 0 auto;
}
.flex {
display: flex;
flex-flow: wrap;
}
#display {
position: relative;
display: block;
margin: 0 auto;
}
#modelCanvas {
width: 680px;
height: 720px;
}
#editArea {
text-align: center;
margin: 0 auto;
}
#colorPickedfromTexture {
border: 1px solid #000;
}
#liveryDisplay {
position: relative;
margin: 0px auto;
padding: 1px;
width: 100%;
height: 100%;
}
#liveryCanvas {
border: 1px solid #000;
}
#liveryCanvas:hover {
cursor: crosshair;
}
#brushSize {
vertical-align: bottom;
}
ul {
padding: 0;
}
li {
display: inline-block;
}
canvas {
touch-action: none;
}
img {
width: 70%;
height: 70%;
}
span {
font-size: 14px;
}
</style>
<body>
<button class="icon toggleControls" style="position: fixed; z-index: 100;">
<i class="fa fa-bars"></i>
</button>
<div id='header'>
<h1> livery customizer <span><a href='https://github.com/syncopika/livery' target="_blank"> src </a></span></h1>
</div>
<div id="controls" class="controls-off">
<button class="icon toggleControls">
<i class="fa fa-bars"></i>
</button>
<br />
<br />
<button id='updateModel' style='display: block; margin: 0 auto'>update model</button>
<hr />
<div>
<!-- buttons specific to model -->
<p class="section-title"> model controls </p>
<label for='selectModel'> select model: </label>
<select id='selectModel'>
<option value="f-16" selected>f16</option>
<option value="biplane">biplane</option>
<option value="porsche">porsche</option>
<option value="nissan-gtr">nissan gt-r</option>
<option value="cow">cow</option>
<option value="turtle">turtle</option>
</select>
<ul id='toolbar'>
<li>
<button id='importModel' title='import model'>
<img src="./icons/import_texture.svg" alt="import model">
</button>
</li>
<li>
<button id='selectMesh' title='select mesh to edit texture of'>
<img src="./icons/select_mesh.svg" alt="select mesh to edit texture of">
</button>
</li>
<li>
<button id='lockRotation' title="lock trackball rotation">
<img src="./icons/lock_rotation.svg" alt="lock trackball rotation">
</button>
</li>
<li>
<button id='drawOnModel' title='draw on the model with the brush'>
<img src="./icons/pencil.svg" alt="draw on model">
</button>
</li>
<li>
<button id='selectMeshFace' title='click on the model to find the corresponding triangle on the texture'>
<img src="./icons/select_mesh_face.svg" alt="select mesh face">
</button>
</li>
<li>
<button id='exportModel' title='export model'>
<img src="./icons/import_texture.svg" alt="export model" style="transform: rotate(180deg)">
</button>
</li>
</ul>
<label for="toggleWireframe">wireframe: </label> <input type="checkbox" id="toggleWireframe">
<label for="toggleShading">flat shading: </label> <input type="checkbox" id="toggleShading">
<!-- buttons specific to texture -->
<hr />
<p class="section-title"> texture controls </p>
<label for='imageFilters'> filter: </label>
<select id='imageFilters'>
<option value=""></option>
<option value="invert">invert</option>
<option value="mosaic">mosaic</option>
<option value="saturate">saturate</option>
</select>
<ul>
<li id='resetTexture'>
<button title="reset texture">
<img src="./icons/reset.svg" alt="reset texture">
</button>
</li>
<li>
<button id='pickColorFromTexture' title="pick a pixel's color from the texture canvas">
<img src="./icons/eye_dropper.svg" alt="texture color picker">
</button>
</li>
<li>
<button id='toggleMaskingLayer' title="toggle masking layer">
<img src="./icons/mask.svg" alt="toggle masking layer">
</button>
</li>
<li>
<button id='applyMaskingLayer' title="apply masking layer">
<img src="./icons/mask-apply.svg" alt="apply masking layer">
</button>
</li>
<li>
<button id='clearMaskingLayer' title="clear masking layer">
<img src="./icons/mask-clear.svg" alt="clear masking layer">
</button>
</li>
<li>
<button id='importTexture' title='import texture'>
<img src="./icons/import_texture.svg" alt="import texture">
</button>
</li>
<li>
<button id='exportTexture' title='export texture'>
<img src="./icons/import_texture.svg" alt="export texture" style="transform: rotate(180deg)">
</button>
</li>
</ul>
<!-- brush section -->
<hr />
<p class="section-title"> brush controls </p>
<span>size: </span>
<input id='brushSize' type="range" min="1" max="20" value="3" name="brushSize"/>
<label for='brushSize' id="currBrushSize">3</label>
<br /><br />
<label for='colorInput'>pen color: </label>
<input id='colorInput' name="colorInput" type="text" value="rgba(0,0,0,255)"/>
<br /><br />
<label for='bgColorInput'>background color: </label>
<input id='bgColorInput' name="bgColorInput" type="text" value="rgb(255,255,255)"/>
<br />
<p id='colorPickedfromTexture'>picked texture color goes here</p>
<br />
<div id="colorWheelContainer"></div>
<!-- lighting control -->
<hr />
<p class="section-title"> directional light control </p>
<label for='dirLightX'>x pos: </label>
<input id='dirLightX' type="range" max="100" min="-100" value="0" step="1"></input>
<label id='dirLightXVal'>0</label>
<br />
<label for='dirLightY'>y pos: </label>
<input id='dirLightY' type="range" max="100" min="-100" value="100" step="1"></input>
<label id='dirLightYVal'>100</label>
<br />
<label for='dirLightZ'>z pos: </label>
<input id='dirLightZ' type="range" max="100" min="-100" value="-10" step="1"></input>
<label id='dirLightZVal'>-10</label>
<br />
<label for='dirLightIntensity'>intensity: </label>
<input id='dirLightIntensity' type="range" max="3" min="0.1" value="1" step="0.1"></input>
<label id='dirLightIntensityVal'>1</label>
</div>
</div>
<div class='flex'>
<div id='display'>
<canvas id="modelCanvas"></canvas>
</div>
<div id='editArea'>
<div id='liveryDisplay'>
<canvas id='liveryCanvas'>
</canvas>
<canvas id='maskingLayer'>
</canvas>
<canvas id='meshFaceLayer'>
</canvas>
</div>
</div>
</div>
</body>
<script>
let controlsOn = false;
document.querySelectorAll('.toggleControls').forEach(btn => {
btn.addEventListener('click', (evt) => {
controlsOn = !controlsOn;
const controls = document.getElementById('controls');
if(controlsOn){
controls.className = "controls-on";
}else{
controls.className = "controls-off";
}
});
});
</script>
<script src='src/pasteImageUtils.js'></script>
<script src='src/colorPicker.js'></script>
<script src='src/maskingCanvasUtils.js'></script>
<script src='src/filters.js'></script>
<script src='src/index.js'></script>
</html>