-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
371 lines (330 loc) · 19.2 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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
<title>Physics Engine</title>
<script src="./out/main.js" type="Module"></script>
</head>
<body>
<div class="container-fluid" style="max-width: 1700px;">
<div class="row">
<div class="col p-0" style="margin-left:1rem;">
<div class="row">
<div class="col title fs-1">Rigid Body Simulation</div>
<div class="col align-self-end frame_counter fs-5 text-end">0fps</div>
</div>
<canvas id="canvas" style="border: 2px solid black; width: 1280px; height: 720px;"></canvas>
</div>
<div class="col fw-normal" style="margin: 3.8rem 1rem 1rem 1rem">
<div class="row">
<select class="form-select form-select-sm mb-2" aria-label=".form-select-sm example" id="demo_select"></select>
</div>
<div class="row mb-1">
<button class="btn btn-primary" type="button" id="restart">
Restart
</button>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="pause">Pause</label>
<input class="form-check-input" type="checkbox" role="switch" id="pause">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="gravity">Apply gravity</label>
<input class="form-check-input " type="checkbox" role="switch" id="gravity" checked>
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="indicateCoM">Indicate center of mass</label>
<input class="form-check-input " type="checkbox" role="switch" id="indicateCoM">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="indicateContact">Indicate contact information</label>
<input class="form-check-input " type="checkbox" role="switch" id="indicateContact">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="showBB">Show bounding box</label>
<input class="form-check-input " type="checkbox" role="switch" id="showBB">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="showInfo">Show body info</label>
<input class="form-check-input" type="checkbox" role="switch" id="showInfo">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="showProfile">Show profile</label>
<input class="form-check-input" type="checkbox" role="switch" id="showProfile">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="contactLink">Show contact link</label>
<input class="form-check-input" type="checkbox" role="switch" id="contactLink">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="colorizeBody">Colorize body</label>
<input class="form-check-input" type="checkbox" role="switch" id="colorizeBody">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="colorizeIsland">Colorize island</label>
<input class="form-check-input" type="checkbox" role="switch" id="colorizeIsland">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="colorizeActiveBody">Colorize active body</label>
<input class="form-check-input" type="checkbox" role="switch" id="colorizeActiveBody">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="visualizeAABBTree">Visualize dynamic AABB Tree</label>
<input class="form-check-input" type="checkbox" role="switch" id="visualizeAABBTree">
</div>
</div>
<div class="row">
<label for="frequency" class="form-label col-9 p-0 m-0">Frequency</label>
<div class="col text-end p-0 m-0" id="frequency_label">0Hz</div>
<input type="range" class="form-range " id="frequency">
</div>
<div class="row">
<label for="iteration" class="form-label col-9 p-0 m-0">Iterations</label>
<div class="col text-end p-0 m-0" id="iteration_label">0</div>
<input type="range" class="form-range " id="iteration">
</div>
<div class="row">
<div class="m-0 p-0">Mouse mode</div>
<div class="form-check m-0 ms-2">
<input class="form-check-input" type="radio" name="modeRadios" id="modeRadios1" value="0" checked>
<label class="form-check-label" for="modeRadios1">
Grab
</label>
</div>
<div class="form-check m-0 ms-2">
<input class="form-check-input" type="radio" name="modeRadios" id="modeRadios2" value="1">
<label class="form-check-label" for="modeRadios2">
Force
</label>
</div>
<div class="row p-0 m-0">
<label for="strength" class="form-label col-9 p-0 ms-2 mb-0">Strength</label>
<div class="col text-end p-0 m-0" id="strength_label">0</div>
<input type="range" class="form-range ps-2" id="strength">
</div>
</div>
<div class="row mb-2 mt-1">
<button type="button" class="btn btn-primary " data-bs-toggle="modal" data-bs-target="#exampleModal">
Shortcuts
</button>
</div>
<!-- Shorcut modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Shortcuts</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body ms-2">
<div class="row">
- ESC to pause simulation
</div>
<div class="row">
- Scroll to zoom
</div>
<div class="row">
- Right click drag to move camera
</div>
<div class="row">
- Click the air to generate a new rigidbody
</div>
<div class="row">
- Drag the rigidbody to add force
</div>
<div class="row">
- Right click or Wheel drag to remove rigidbody
</div>
<div class="row">
- Arrow keys to move around
</div>
<div class="row">
- R to restart simulation
</div>
<div class="row">
- M to indicate the center of mass
</div>
<div class="row">
- P to indicate contact information
</div>
<div class="row">
- G to toggle gravity force
</div>
<div class="row">
- B to show bounding box
</div>
<div class="row">
- I to show body info
</div>
<div class="row">
- F to show profile
</div>
<div class="row">
- V to visualize dynamic AABB tree
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="row mb-2">
<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseNewBody" aria-expanded="false" aria-controls="collapseExample">
New Rigidbody Settings
</button>
</div>
<div class="row collapse mb-2" id="collapseNewBody">
<div class="card card-body py-2 px-4">
<div class="row">
<div class="m-0 p-0">Shape</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="shapeRadios" id="shapeRadios1" value="0" checked>
<label class="form-check-label" for="shapeRadios1">
Box
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="shapeRadios" id="shapeRadios2" value="1">
<label class="form-check-label" for="shapeRadios2">
Circle
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="shapeRadios" id="shapeRadios3" value="2">
<label class="form-check-label" for="shapeRadios3">
Regular polygon
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="shapeRadios" id="shapeRadios4" value="3">
<label class="form-check-label" for="shapeRadios4">
Random
</label>
</div>
<div class="row m-0 p-0">
<label for="density" class="form-label col-9 p-0 m-0">Density</label>
<div class="col text-end p-0 m-0" id="density_label">0</div>
<input type="range" class="form-range " id="density">
</div>
<div class="row m-0 p-0">
<label for="size" class="form-label col-9 p-0 m-0">Size</label>
<div class="col text-end p-0 m-0" id="size_label">0</div>
<input type="range" class="form-range " id="size">
</div>
<div class="row m-0 p-0">
<label for="friction" class="form-label col-9 p-0 m-0">Friction</label>
<div class="col text-end p-0 m-0" id="friction_label">0</div>
<input type="range" class="form-range " id="friction">
</div>
<div class="row m-0 p-0">
<label for="restitution" class="form-label col-9 p-0 m-0">Restitution</label>
<div class="col text-end p-0 m-0" id="restitution_label">0</div>
<input type="range" class="form-range " id="restitution">
</div>
<div class="row m-0 p-0" id="vertices_div" hidden>
<label for="vertices" class="form-label col-9 p-0 m-0">Number of vertices</label>
<div class="col text-end p-0 m-0" id="vertices_label">0</div>
<input type="range" class="form-range " id="vertices">
</div>
</div>
</div>
</div>
<div class="row mb-2">
<button class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#collapseAdvanced" aria-expanded="false" aria-controls="collapseExample">
Advanced
</button>
</div>
<div class="row collapse mb-2" id="collapseAdvanced">
<div class="card card-body py-2 px-4">
<div class="row">
<label for="gravityForce" class="form-label col-9 p-0 m-0">Gravity</label>
<div class="col text-end p-0 m-0" id="gravityForce_label">0</div>
<input type="range" class="form-range " id="gravityForce">
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="correction">Position correction</label>
<input class="form-check-input " type="checkbox" role="switch" id="correction" checked>
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="accumulation">Impulse accumulation</label>
<input class="form-check-input " type="checkbox" role="switch" id="accumulation" checked>
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="warmstarting">Warm starting</label>
<input class="form-check-input " type="checkbox" role="switch" id="warmstarting" checked>
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="blockSolve">Block solve</label>
<input class="form-check-input" type="checkbox" role="switch" id="blockSolve">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="sleepEnabled">Sleeping</label>
<input class="form-check-input" type="checkbox" role="switch" id="sleepEnabled">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="clampedWarmStarting">Apply warm starting threshold</label>
<input class="form-check-input" type="checkbox" role="switch" id="applyWarmStartingThreshold">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0 mt-2">
<label class="form-check-label" for="grabCenter">Grab center</label>
<input class="form-check-input" type="checkbox" role="switch" id="grabCenter">
</div>
</div>
<div class="row">
<div class="form-check form-switch m-0">
<label class="form-check-label" for="resetCamera">Reset camera when restart</label>
<input class="form-check-input" type="checkbox" role="switch" id="resetCamera">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>