-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
222 lines (203 loc) · 9.41 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.6.0/p5.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/daisyui@3.3.1/dist/full.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.tailwindcss.com"></script>
<style>
* {
font-family: ShareTechMono-Regular, monospace;
}
</style>
<!-- <link rel="stylesheet" type="text/css" href="style.css"> -->
</head>
<!-- Took inspiration from Matthias (I took his permission don't cut my marks): https://editor.p5js.org/Apollo199999999/sketches/K6hNOWJeI -->
<body onload="UIEvents.documentLoaded()">
<div class="flex">
<div id="controlsPage" class="bg-base-100 flex-1 p-4 max-h-screen overflow-y-auto overflow-x-hidden">
<div class="alert alert-info">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#000000"
stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="4" y1="21" x2="4" y2="14"></line>
<line x1="4" y1="10" x2="4" y2="3"></line>
<line x1="12" y1="21" x2="12" y2="12"></line>
<line x1="12" y1="8" x2="12" y2="3"></line>
<line x1="20" y1="21" x2="20" y2="16"></line>
<line x1="20" y1="12" x2="20" y2="3"></line>
<line x1="1" y1="14" x2="7" y2="14"></line>
<line x1="9" y1="8" x2="15" y2="8"></line>
<line x1="17" y1="16" x2="23" y2="16"></line>
</svg>
<span class="text-xl font-bold">Simulation Controls</span>
</div>
<!-- Simulation play/pause panel -->
<div class="flex gap-2 mt-5">
<!-- Play button -->
<div class="tooltip tooltip-bottom" data-tip="Play / Pause">
<button onclick="UIEvents.playPauseBtnClicked()" class="btn btn-primary">
<span id="playIcon">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewbox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M5.25 5.653c0-.856.917-1.398 1.667-.986l11.54 6.348a1.125 1.125 0 010 1.971l-11.54 6.347a1.125 1.125 0 01-1.667-.985V5.653z" />
</svg>
</span>
<span id="pauseIcon" class="hidden">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewbox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 5.25v13.5m-7.5-13.5v13.5" />
</svg>
</span>
</button>
</div>
<!-- Forward 1 frame button -->
<div class="tooltip tooltip-bottom" data-tip="Forward 1 frame">
<button class="btn btn-square btn-outline btn-neutral" onclick="UIEvents.forwardOneFrameBtnClicked()">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewbox="0 0 24 24" stroke-width="1.5"
stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M3 8.688c0-.864.933-1.405 1.683-.977l7.108 4.062a1.125 1.125 0 010 1.953l-7.108 4.062A1.125 1.125 0 013 16.81V8.688zM12.75 8.688c0-.864.933-1.405 1.683-.977l7.108 4.062a1.125 1.125 0 010 1.953l-7.108 4.062a1.125 1.125 0 01-1.683-.977V8.688z" />
</svg>
</button>
</div>
</div>
<!-- Simulation speed section -->
<p class="text-xl mt-5" id="outputSimSpeed"></p>
<input oninput="UIEvents.simulationSpeedChanged()" id="simulationSpeedSlider" type="range" min="0.25" max="3.0"
value="1.0" step="0.25" class="range range-primary mt-4" />
<!-- Elasticity slider section -->
<p class="text-xl mt-5" id="outputElasticity"></p>
<input oninput="UIEvents.elasticityValueChanged()" id="elasticityValueSlider" type="range" min="5" max="100"
value="90" step="5" class="range range-primary mt-4" />
</div>
<!-- Div to contain the canvas element for the sketch -->
<div class="relative" style="flex: 0 0 auto;">
<!-- Main element is where the canvas element for the sketch is located -->
<main></main>
</div>
<!-- Right control panel (previously "Data" tab) -->
<div id="dataPage" class="bg-base-100 flex-1 p-4 pr-3 max-h-screen overflow-y-auto overflow-x-hidden">
<div class="alert alert-info">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#000000"
stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round">
<line x1="18" y1="20" x2="18" y2="10"></line>
<line x1="12" y1="20" x2="12" y2="4"></line>
<line x1="6" y1="20" x2="6" y2="14"></line>
</svg>
<span class="text-xl font-bold">Data Panel</span>
</div>
<!-- Number of bodies section -->
<p class="text-xl mt-5">Number of bodies (1-5)</p>
<input id="circlesNumInput" oninput="UIEvents.numCirclesChanged()"
class="input input-bordered input-primary mt-4 mb-8 w-20" type="number" value="3" min="1"
max="5" step="1" />
</div>
<!-- Floating help button at bottom right corner of div -->
<details class="dropdown dropdown-left dropdown-end absolute right-6 bottom-6 drop-shadow-2xl">
<summary class="btn btn-secondary">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewbox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round"
d="M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z" />
</svg>
Help
</summary>
<div tabindex="0" class="dropdown-content z-[1] p-4 mr-2 shadow-2xl bg-base-100 rounded-box w-max">
<p class="text-lg font-bold">Welcome to Collision Simulation!</p>
<ul class="list-disc list-outside pl-4">
<li>
To control how the simulation behaves, use the left panel.
</li>
<li>
To control the bodies in the simulation, use the right panel.
</li>
<li>
In the right panel, click on the (+) icon to show more details about a body.
</li>
<li>
You can click and drag on the bodies to change their position.
</li>
<li>
You can also click and drag on the velocity vector on a body to change its velocity.
</li>
</ul>
</div>
</details>
</div>
<!-- Template element to show data readouts for each body (cloned in javascript) -->
<div class="collapse collapse-plus bg-base-200 mt-2 hidden bodyDataControl" id="bodyDataLayout">
<input type="checkbox" />
<div class="collapse-title text-xl font-medium">
<p class="body-circle mb-2 h-12 w-12 rounded-full inline-block" />
<p class="collapse-title-label">Body 1 Data</p>
</div>
<div class="collapse-content">
<!-- Body mass readouts -->
<p class="text-lg">Mass</p>
<input class="input input-bordered input-primary mt-3 mb-6 mass" style="width: 5.5em" type="number" step="1"
min="1" max="10" data-bodyindex="-1" />
<!-- Body position readouts -->
<p class="text-lg">Position</p>
<table class="table table-zebra">
<!-- head -->
<thead class="text-lg">
<tr>
<th>x:</th>
<th>y:</th>
</tr>
</thead>
<!-- body -->
<tbody class="text-lg">
<tr>
<td>
<input class="input input-bordered input-primary px" style="width: 5.5em" type="number" step="1"
data-bodyindex="-1" />
</td>
<td>
<input class="input input-bordered input-primary py" style="width: 5.5em" type="number" step="1"
data-bodyindex="-1" />
</td>
</tr>
</tbody>
</table>
<!-- Body velocity readouts -->
<p class="text-lg mt-4">Velocity</p>
<table class="table table-zebra">
<!-- head -->
<thead class="text-lg">
<tr>
<th>x:</th>
<th>y:</th>
</tr>
</thead>
<!-- body -->
<tbody class="text-lg">
<tr>
<td>
<input class="input input-bordered input-primary vx" style="width: 5.5em" type="number" step="0.5"
max="50" data-bodyindex="-1" />
</td>
<td>
<input class="input input-bordered input-primary vy" style="width: 5.5em" type="number" step="0.5"
max="50" data-bodyindex="-1" />
</td>
</tr>
</tbody>
</table>
<!-- Body KE and overall momentum readouts -->
<p class="text-lg mt-4">Kinetic Energy</p>
<input class="input input-bordered input-primary mt-3 mb-6 ke" style="width: 5.5em" type="number" step="0.5"
data-bodyindex="-1" readonly />
<p class="text-lg mt-4">Momentum</p>
<input class="input input-bordered input-primary mt-3 mb-6 momentum" style="width: 5.5em" type="number" step="0.5"
data-bodyindex="-1" readonly />
</div>
</div>
<script src="ui_events.js"></script>
<script src="sketch.js"></script>
<script src="circle.js"></script>
<script src="particle.js"></script>
</div>
</body>
</html>