-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFPS_Visualizer.html
More file actions
744 lines (654 loc) · 26.1 KB
/
Copy pathFPS_Visualizer.html
File metadata and controls
744 lines (654 loc) · 26.1 KB
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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Airsoft BB Performance Visualizer</title>
<style>
:root {
color-scheme: light;
--bg: #f4f6f1;
--panel: #ffffff;
--ink: #18211d;
--muted: #5d6962;
--line: #d8ded6;
--accent: #1d6f63;
--accent-2: #c0582a;
--warn: #a33a26;
--shadow: 0 18px 45px rgba(31, 44, 37, 0.12);
}
* {
box-sizing: border-box;
}
body {
margin: 0;
min-height: 100vh;
background: var(--bg);
color: var(--ink);
font-family: Arial, Helvetica, sans-serif;
}
main {
width: min(1180px, calc(100vw - 28px));
margin: 0 auto;
padding: 28px 0 42px;
}
header {
display: flex;
justify-content: space-between;
gap: 20px;
align-items: end;
margin-bottom: 18px;
}
h1 {
margin: 0;
font-size: clamp(1.7rem, 3vw, 3rem);
line-height: 1.03;
letter-spacing: 0;
}
.subtitle {
max-width: 720px;
margin: 10px 0 0;
color: var(--muted);
line-height: 1.45;
}
.status {
min-width: 190px;
padding: 12px 14px;
border: 1px solid var(--line);
border-radius: 8px;
background: var(--panel);
box-shadow: var(--shadow);
font-size: 0.92rem;
line-height: 1.35;
}
.layout {
display: grid;
grid-template-columns: 340px 1fr;
gap: 18px;
align-items: start;
}
.panel {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 8px;
box-shadow: var(--shadow);
}
.controls {
padding: 18px;
display: grid;
gap: 15px;
}
.control {
display: grid;
grid-template-columns: 1fr auto;
gap: 8px 12px;
align-items: center;
}
.control label {
font-weight: 700;
font-size: 0.95rem;
}
.control output {
color: var(--muted);
font-variant-numeric: tabular-nums;
font-size: 0.9rem;
}
input[type="number"],
select {
width: 100%;
grid-column: 1 / -1;
min-height: 38px;
border: 1px solid #bfc8c0;
border-radius: 6px;
padding: 8px 10px;
font-size: 1rem;
color: var(--ink);
background: #fff;
}
input[type="range"] {
grid-column: 1 / -1;
width: 100%;
accent-color: var(--accent);
}
.hint {
grid-column: 1 / -1;
margin: -3px 0 0;
color: var(--muted);
font-size: 0.84rem;
line-height: 1.35;
}
.results {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 10px;
padding: 14px;
border-bottom: 1px solid var(--line);
}
.metric {
min-height: 92px;
border: 1px solid var(--line);
border-radius: 8px;
padding: 12px;
background: #fbfcfa;
}
.metric span {
display: block;
color: var(--muted);
font-size: 0.78rem;
text-transform: uppercase;
letter-spacing: 0;
}
.metric strong {
display: block;
margin-top: 8px;
font-size: clamp(1.25rem, 2vw, 1.85rem);
font-variant-numeric: tabular-nums;
line-height: 1;
}
.metric small {
display: block;
margin-top: 8px;
color: var(--muted);
line-height: 1.25;
}
.chart-wrap {
padding: 14px;
}
canvas {
display: block;
width: 100%;
height: 430px;
border: 1px solid var(--line);
border-radius: 8px;
background: #fbfcfa;
}
.table-wrap {
padding: 0 14px 14px;
overflow-x: auto;
}
table {
width: 100%;
border-collapse: collapse;
min-width: 620px;
font-variant-numeric: tabular-nums;
}
th,
td {
border-bottom: 1px solid var(--line);
padding: 10px 8px;
text-align: right;
white-space: nowrap;
}
th:first-child,
td:first-child {
text-align: left;
}
th {
color: var(--muted);
font-size: 0.78rem;
text-transform: uppercase;
letter-spacing: 0;
}
.notes {
margin-top: 18px;
padding: 16px 18px;
color: var(--muted);
line-height: 1.5;
}
.notes strong {
color: var(--ink);
}
.warning {
color: var(--warn);
font-weight: 700;
}
@media (max-width: 900px) {
header,
.layout {
grid-template-columns: 1fr;
display: grid;
}
.results {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
canvas {
height: 340px;
}
}
@media (max-width: 520px) {
main {
width: min(100vw - 18px, 1180px);
padding-top: 16px;
}
.results {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<main>
<header>
<div>
<h1>Airsoft BB Performance Visualizer</h1>
<p class="subtitle">A quick estimator for BB energy, velocity loss, flight time, drop, and range using kinetic energy plus a transparent drag-based trajectory model.</p>
</div>
<div class="status" id="modelStatus">Ready</div>
</header>
<section class="layout">
<aside class="panel controls" aria-label="Ballistic controls">
<div class="control">
<label for="fps">Chrono velocity</label>
<output id="fpsOut"></output>
<input id="fps" type="range" min="120" max="650" step="1" value="350">
<input id="fpsNumber" type="number" min="120" max="650" step="1" value="350" aria-label="Chrono velocity in feet per second">
</div>
<div class="control">
<label for="weight">BB weight</label>
<output id="weightOut"></output>
<input id="weight" type="range" min="0.12" max="0.50" step="0.01" value="0.20">
<input id="weightNumber" type="number" min="0.12" max="0.50" step="0.01" value="0.20" aria-label="BB weight in grams">
</div>
<div class="control">
<label for="angle">Muzzle angle</label>
<output id="angleOut"></output>
<input id="angle" type="range" min="-3" max="12" step="0.1" value="3">
<p class="hint">Positive angles simulate an upward shot line. Most field estimates should stay low.</p>
</div>
<div class="control">
<label for="hop">Hop-up lift estimate</label>
<output id="hopOut"></output>
<input id="hop" type="range" min="0" max="75" step="1" value="45">
<p class="hint">This reduces effective gravity to approximate backspin lift. The equations are exact for the chosen value, but real hop tuning varies.</p>
</div>
<div class="control">
<label for="target">Target distance</label>
<output id="targetOut"></output>
<input id="target" type="range" min="25" max="300" step="5" value="150">
</div>
<div class="control">
<label for="drag">Drag coefficient</label>
<output id="dragOut"></output>
<input id="drag" type="range" min="0.35" max="0.65" step="0.01" value="0.47">
<p class="hint">0.47 is a common sphere estimate. Imperfect BBs and spin can move this around.</p>
</div>
<div class="control">
<label for="impactEnergy">Useful impact energy</label>
<output id="impactOut"></output>
<input id="impactEnergy" type="range" min="0.05" max="1.00" step="0.05" value="0.20">
<p class="hint">Used only for the estimated useful range marker.</p>
</div>
</aside>
<section class="panel" aria-label="Performance results">
<div class="results">
<div class="metric">
<span>Muzzle energy</span>
<strong id="muzzleEnergy">0.00 J</strong>
<small id="energyClass"></small>
</div>
<div class="metric">
<span>Estimated max range</span>
<strong id="maxRange">0 ft</strong>
<small>Until the BB intersects ground height.</small>
</div>
<div class="metric">
<span>Useful range</span>
<strong id="usefulRange">0 ft</strong>
<small id="usefulText"></small>
</div>
<div class="metric">
<span>At target distance</span>
<strong id="targetEnergy">0.00 J</strong>
<small id="targetText"></small>
</div>
</div>
<div class="chart-wrap">
<canvas id="trajectory" width="1000" height="520" aria-label="Trajectory and velocity chart"></canvas>
</div>
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Distance</th>
<th>Speed</th>
<th>Energy</th>
<th>Drop</th>
<th>Flight time</th>
</tr>
</thead>
<tbody id="rangeRows"></tbody>
</table>
</div>
</section>
</section>
<section class="panel notes">
<strong>Model:</strong>
muzzle energy uses E = 1/2 m v^2. Trajectory uses quadratic drag,
Fd = 1/2 rho Cd A v^2, integrated in small time steps for a 6 mm spherical BB.
Hop-up is not guessed secretly; it is represented by the adjustable lift estimate that reduces effective gravity.
<span class="warning">Do not use this as a field limit authority.</span> Chronograph with the BB weight your field requires.
</section>
</main>
<script>
const FT_TO_M = 0.3048;
const M_TO_FT = 3.280839895;
const G = 9.80665;
const AIR_DENSITY = 1.225;
const BB_DIAMETER_M = 0.006;
const BB_AREA_M2 = Math.PI * Math.pow(BB_DIAMETER_M / 2, 2);
const DT = 0.002;
const MAX_TIME = 8;
const els = {
fps: document.getElementById("fps"),
fpsNumber: document.getElementById("fpsNumber"),
fpsOut: document.getElementById("fpsOut"),
weight: document.getElementById("weight"),
weightNumber: document.getElementById("weightNumber"),
weightOut: document.getElementById("weightOut"),
angle: document.getElementById("angle"),
angleOut: document.getElementById("angleOut"),
hop: document.getElementById("hop"),
hopOut: document.getElementById("hopOut"),
target: document.getElementById("target"),
targetOut: document.getElementById("targetOut"),
drag: document.getElementById("drag"),
dragOut: document.getElementById("dragOut"),
impactEnergy: document.getElementById("impactEnergy"),
impactOut: document.getElementById("impactOut"),
status: document.getElementById("modelStatus"),
muzzleEnergy: document.getElementById("muzzleEnergy"),
energyClass: document.getElementById("energyClass"),
maxRange: document.getElementById("maxRange"),
usefulRange: document.getElementById("usefulRange"),
usefulText: document.getElementById("usefulText"),
targetEnergy: document.getElementById("targetEnergy"),
targetText: document.getElementById("targetText"),
rangeRows: document.getElementById("rangeRows"),
canvas: document.getElementById("trajectory")
};
const ctx = els.canvas.getContext("2d");
function clamp(value, min, max) {
return Math.min(max, Math.max(min, value));
}
function kgFromGrams(grams) {
return grams / 1000;
}
function metersPerSecondFromFps(fps) {
return fps * FT_TO_M;
}
function fpsFromMetersPerSecond(ms) {
return ms * M_TO_FT;
}
function joulesFromFps(fps, grams) {
const massKg = kgFromGrams(grams);
const velocity = metersPerSecondFromFps(fps);
return 0.5 * massKg * velocity * velocity;
}
function fpsForJoules(joules, grams) {
const massKg = kgFromGrams(grams);
return fpsFromMetersPerSecond(Math.sqrt((2 * joules) / massKg));
}
function energyFromSpeed(speedMS, grams) {
const massKg = kgFromGrams(grams);
return 0.5 * massKg * speedMS * speedMS;
}
function interpolate(a, b, distanceM) {
if (!a || !b || b.x === a.x) return a || b;
const t = (distanceM - a.x) / (b.x - a.x);
return {
x: distanceM,
y: a.y + (b.y - a.y) * t,
speed: a.speed + (b.speed - a.speed) * t,
energy: a.energy + (b.energy - a.energy) * t,
time: a.time + (b.time - a.time) * t
};
}
function sampleAt(points, distanceFt) {
const distanceM = distanceFt * FT_TO_M;
if (distanceM <= 0) return points[0];
for (let i = 1; i < points.length; i++) {
if (points[i].x >= distanceM) {
return interpolate(points[i - 1], points[i], distanceM);
}
}
return null;
}
function findRangeAtEnergy(points, minimumEnergy) {
for (let i = 1; i < points.length; i++) {
if (points[i].energy <= minimumEnergy) {
const prev = points[i - 1];
const cur = points[i];
const span = prev.energy - cur.energy;
const t = span === 0 ? 0 : (prev.energy - minimumEnergy) / span;
return (prev.x + (cur.x - prev.x) * t) * M_TO_FT;
}
}
return points[points.length - 1].x * M_TO_FT;
}
function simulate(input) {
const massKg = kgFromGrams(input.weight);
const speed0 = metersPerSecondFromFps(input.fps);
const angleRad = input.angle * Math.PI / 180;
const effectiveG = G * (1 - input.hop / 100);
const dragK = 0.5 * AIR_DENSITY * input.drag * BB_AREA_M2 / massKg;
let x = 0;
let y = 1.4;
let vx = speed0 * Math.cos(angleRad);
let vy = speed0 * Math.sin(angleRad);
let time = 0;
const points = [];
while (time <= MAX_TIME && y >= 0 && x <= 220) {
const speed = Math.hypot(vx, vy);
points.push({
x,
y,
speed,
energy: energyFromSpeed(speed, input.weight),
time
});
const ax = -dragK * speed * vx;
const ay = -effectiveG - dragK * speed * vy;
vx += ax * DT;
vy += ay * DT;
x += vx * DT;
y += vy * DT;
time += DT;
if (speed < 1) break;
}
if (points.length > 1 && y < 0) {
const prev = points[points.length - 1];
const speed = Math.hypot(vx, vy);
points.push({
x,
y,
speed,
energy: energyFromSpeed(speed, input.weight),
time
});
const ground = interpolate(prev, points[points.length - 1], prev.x + (0 - prev.y) * (x - prev.x) / (y - prev.y));
ground.y = 0;
points[points.length - 1] = ground;
}
return points;
}
function getInput() {
return {
fps: Number(els.fps.value),
weight: Number(els.weight.value),
angle: Number(els.angle.value),
hop: Number(els.hop.value),
target: Number(els.target.value),
drag: Number(els.drag.value),
impactEnergy: Number(els.impactEnergy.value)
};
}
function setOutputs(input) {
els.fpsOut.textContent = `${input.fps.toFixed(0)} fps`;
els.fpsNumber.value = input.fps.toFixed(0);
els.weightOut.textContent = `${input.weight.toFixed(2)} g`;
els.weightNumber.value = input.weight.toFixed(2);
els.angleOut.textContent = `${input.angle.toFixed(1)} deg`;
els.hopOut.textContent = `${input.hop.toFixed(0)}%`;
els.targetOut.textContent = `${input.target.toFixed(0)} ft`;
els.dragOut.textContent = input.drag.toFixed(2);
els.impactOut.textContent = `${input.impactEnergy.toFixed(2)} J`;
}
function drawChart(points, input, usefulRangeFt) {
const c = els.canvas;
const width = c.width;
const height = c.height;
const pad = { left: 58, right: 22, top: 28, bottom: 48 };
const plotW = width - pad.left - pad.right;
const plotH = height - pad.top - pad.bottom;
const maxX = Math.max(100, Math.ceil(points[points.length - 1].x * M_TO_FT / 25) * 25);
const maxY = Math.max(20, Math.ceil(Math.max(...points.map(p => p.y * M_TO_FT)) / 10) * 10);
ctx.clearRect(0, 0, width, height);
ctx.fillStyle = "#fbfcfa";
ctx.fillRect(0, 0, width, height);
function px(xFt) {
return pad.left + (xFt / maxX) * plotW;
}
function py(yFt) {
return pad.top + plotH - (yFt / maxY) * plotH;
}
ctx.strokeStyle = "#d8ded6";
ctx.lineWidth = 1;
ctx.fillStyle = "#5d6962";
ctx.font = "13px Arial";
ctx.textAlign = "right";
ctx.textBaseline = "middle";
const xStep = maxX <= 150 ? 25 : 50;
for (let x = 0; x <= maxX; x += xStep) {
const xPos = px(x);
ctx.beginPath();
ctx.moveTo(xPos, pad.top);
ctx.lineTo(xPos, pad.top + plotH);
ctx.stroke();
ctx.fillText(String(x), xPos + 8, pad.top + plotH + 24);
}
for (let y = 0; y <= maxY; y += 10) {
const yPos = py(y);
ctx.beginPath();
ctx.moveTo(pad.left, yPos);
ctx.lineTo(pad.left + plotW, yPos);
ctx.stroke();
ctx.fillText(String(y), pad.left - 10, yPos);
}
ctx.strokeStyle = "#1d6f63";
ctx.lineWidth = 3;
ctx.beginPath();
points.forEach((p, index) => {
const xFt = p.x * M_TO_FT;
const yFt = Math.max(0, p.y * M_TO_FT);
if (index === 0) ctx.moveTo(px(xFt), py(yFt));
else ctx.lineTo(px(xFt), py(yFt));
});
ctx.stroke();
const targetPoint = sampleAt(points, input.target);
if (targetPoint) {
drawMarker(input.target, Math.max(0, targetPoint.y * M_TO_FT), "#c0582a", "target");
}
drawVertical(usefulRangeFt, "#1d6f63", "useful");
ctx.fillStyle = "#18211d";
ctx.font = "14px Arial";
ctx.textAlign = "center";
ctx.fillText("Distance (ft)", pad.left + plotW / 2, height - 12);
ctx.save();
ctx.translate(18, pad.top + plotH / 2);
ctx.rotate(-Math.PI / 2);
ctx.fillText("Height above ground (ft)", 0, 0);
ctx.restore();
function drawMarker(xFt, yFt, color, label) {
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(px(xFt), py(yFt), 6, 0, Math.PI * 2);
ctx.fill();
ctx.font = "13px Arial";
ctx.textAlign = "left";
ctx.fillText(label, px(xFt) + 9, py(yFt) - 9);
}
function drawVertical(xFt, color, label) {
const xPos = px(clamp(xFt, 0, maxX));
ctx.strokeStyle = color;
ctx.setLineDash([6, 5]);
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(xPos, pad.top);
ctx.lineTo(xPos, pad.top + plotH);
ctx.stroke();
ctx.setLineDash([]);
ctx.fillStyle = color;
ctx.font = "13px Arial";
ctx.textAlign = "left";
ctx.fillText(label, xPos + 8, pad.top + 18);
}
}
function renderRows(points, input) {
const distances = [50, 100, 150, 200, 250, 300].filter(d => d <= Math.max(300, input.target));
els.rangeRows.innerHTML = distances.map(distance => {
const point = sampleAt(points, distance);
if (!point) {
return `<tr><td>${distance} ft</td><td colspan="4">past estimated flight path</td></tr>`;
}
const speedFps = fpsFromMetersPerSecond(point.speed);
const dropFt = (1.4 - point.y) * M_TO_FT;
return `<tr>
<td>${distance} ft</td>
<td>${speedFps.toFixed(0)} fps</td>
<td>${point.energy.toFixed(2)} J</td>
<td>${dropFt.toFixed(1)} ft</td>
<td>${point.time.toFixed(2)} s</td>
</tr>`;
}).join("");
}
function classifyEnergy(joules, weight) {
const oneJouleFps = fpsForJoules(1, weight);
if (joules < 0.8) return `Below 0.80 J. 1.00 J at this weight is ${oneJouleFps.toFixed(0)} fps.`;
if (joules <= 1.5) return `Typical field-check territory. 1.00 J at this weight is ${oneJouleFps.toFixed(0)} fps.`;
return `High energy setup. 1.00 J at this weight is ${oneJouleFps.toFixed(0)} fps.`;
}
function update() {
const input = getInput();
setOutputs(input);
const points = simulate(input);
const muzzleEnergy = joulesFromFps(input.fps, input.weight);
const maxRangeFt = points[points.length - 1].x * M_TO_FT;
const usefulRangeFt = findRangeAtEnergy(points, input.impactEnergy);
const targetPoint = sampleAt(points, input.target);
els.muzzleEnergy.textContent = `${muzzleEnergy.toFixed(2)} J`;
els.energyClass.textContent = classifyEnergy(muzzleEnergy, input.weight);
els.maxRange.textContent = `${maxRangeFt.toFixed(0)} ft`;
els.usefulRange.textContent = `${usefulRangeFt.toFixed(0)} ft`;
els.usefulText.textContent = `Until impact energy falls below ${input.impactEnergy.toFixed(2)} J.`;
if (targetPoint) {
const speedFps = fpsFromMetersPerSecond(targetPoint.speed);
const dropFt = (1.4 - targetPoint.y) * M_TO_FT;
els.targetEnergy.textContent = `${targetPoint.energy.toFixed(2)} J`;
els.targetText.textContent = `${speedFps.toFixed(0)} fps, ${dropFt.toFixed(1)} ft drop, ${targetPoint.time.toFixed(2)} s flight.`;
} else {
els.targetEnergy.textContent = "Out";
els.targetText.textContent = "Target is beyond the estimated flight path.";
}
els.status.textContent = `6 mm BB, Cd ${input.drag.toFixed(2)}, air density ${AIR_DENSITY} kg/m3`;
drawChart(points, input, usefulRangeFt);
renderRows(points, input);
}
function connectRangeAndNumber(range, number, min, max) {
range.addEventListener("input", update);
number.addEventListener("input", () => {
const value = clamp(Number(number.value), min, max);
if (Number.isFinite(value)) {
range.value = value;
update();
}
});
}
connectRangeAndNumber(els.fps, els.fpsNumber, 120, 650);
connectRangeAndNumber(els.weight, els.weightNumber, 0.12, 0.50);
[els.angle, els.hop, els.target, els.drag, els.impactEnergy].forEach(el => {
el.addEventListener("input", update);
});
update();
</script>
</body>
</html>