Skip to content

Commit 8c80985

Browse files
committed
- new style
1 parent 4932e3b commit 8c80985

1 file changed

Lines changed: 81 additions & 84 deletions

File tree

examples/dfsph.html

Lines changed: 81 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
<html class="no-js" lang="en">
33
<head>
44
<meta charset="utf-8">
5-
<style>
6-
body {font-family: Helvetica, sans-serif;}
7-
table {background-color:#CCDDEE;text-align:left}
8-
</style>
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link rel="stylesheet" href="https://interactivecomputergraphics.github.io/physics-simulation/examples/style.css">
97
<script type="text/x-mathjax-config">
108
MathJax.Hub.Config({
119
extensions: ["tex2jax.js"],
@@ -18,91 +16,88 @@
1816
"HTML-CSS": { fonts: ["TeX"] }
1917
});
2018
</script>
21-
<script type="text/javascript" aync src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js"></script>
19+
<script type="text/javascript" async src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js"></script>
2220
<title>Divergence-Free SPH (DFSPH)</title>
2321
</head>
2422
<body>
23+
24+
<header class="page-header">
25+
<h1>Divergence-Free SPH (DFSPH)</h1>
26+
</header>
27+
2528
<main>
26-
<h1 style="text-align:center">Divergence-Free SPH (DFSPH)</h1>
29+
<!-- Simulation panel: canvas + controls -->
2730
<table style="align_center;border-radius: 20px;padding: 20px;margin:auto">
28-
<col width="1100">
29-
<col width="400">
31+
<col width="75%">
32+
<col width="25%">
3033
<tr>
3134
<td>
32-
<canvas id="simCanvas" width="1024" height="768" style="border:2px solid #000000;border-radius: 20px;background-color:#EEEEEE">Your browser does not support the HTML5 canvas tag.</canvas>
35+
<div class="card sim-panel">
36+
<div class="sim-canvas-wrap">
37+
<canvas id="simCanvas" width="1024" height="960" style="border:2px solid #000000;border-radius: 20px;background-color:#EEEEEE">Your browser does not support the HTML5 canvas tag.</canvas>
38+
</div>
39+
</div>
3340
</td>
3441
<td>
35-
<table>
36-
<col width="200" style="padding-right:10px">
37-
<col width="100">
38-
<tr>
39-
<td><label>Current time</label></td>
40-
<td><span id="time">0.00</span> s</td>
41-
</tr>
42-
<tr>
43-
<td><label>Time per sim. step</label></td>
44-
<td><span id="timePerStep">0.00</span> ms</td>
45-
</tr>
46-
<tr>
47-
<td><label>Required iterations (rho)</label></td>
48-
<td><span id="iterations">0</span></td>
49-
</tr>
50-
<tr>
51-
<td><label>Required iterations (div v)</label></td>
52-
<td><span id="iterationsV">0</span></td>
53-
</tr>
54-
<tr>
55-
<td><label># particles</label></td>
56-
<td><span id="numParticles">0</span></td>
57-
</tr>
58-
<tr>
59-
<td><label for="widthInput">Width</label></td>
60-
<td><input onchange="gui.restart()" id="widthInput" type="number" value="30" step="1"></td>
61-
</tr>
62-
<tr>
63-
<td><label for="heightInput">Height</label></td>
64-
<td><input onchange="gui.restart()" id="heightInput" type="number" value="30" step="1"></td>
65-
</tr>
66-
<tr>
67-
<td><label for="timeStepSizeInput">Time step size</label></td>
68-
<td><input onchange="gui.sim.timeStepSize=parseFloat(value)" id="timeStepSizeInput" type="number" value="0.005" step="0.001"></td>
69-
</tr>
70-
<tr>
71-
<td><label for="maxErrorInput">Max. density error (%)</label></td>
72-
<td><input onchange="gui.sim.maxError=parseFloat(value)" id="maxErrorInput" type="number" value="0.1" step="0.01"></td>
73-
</tr>
74-
<tr>
75-
<td><label for="maxErrorVInput">Max. divergence error (%)</label></td>
76-
<td><input onchange="gui.sim.maxErrorV=parseFloat(value)" id="maxErrorVInput" type="number" value="0.5" step="0.01"></td>
77-
</tr>
78-
<tr>
79-
<td><label for="iterationsInput">Max. iterations (rho)</label></td>
80-
<td><input onchange="gui.sim.maxIterations=parseInt(value)" id="iterationsInput" type="number" value="100" step="1"></td>
81-
</tr>
82-
<tr>
83-
<td><label for="iterationsVInput">Max. iterations (div v)</label></td>
84-
<td><input onchange="gui.sim.maxIterationsV=parseInt(value)" id="iterationsVInput" type="number" value="100" step="1"></td>
85-
</tr>
86-
<tr>
87-
<td><label for="viscosityInput">Viscosity</label></td>
88-
<td><input onchange="gui.sim.viscosity=parseFloat(value)" id="viscosityInput" type="number" value="0.05" step="0.01"></td>
89-
</tr>
90-
<tr>
91-
<td><label for="gravityInput">Gravity</label></td>
92-
<td><input onchange="gui.sim.gravity=parseFloat(value)" id="gravityInput" type="number" value="-9.81" step="0.01"></td>
93-
</tr>
94-
<tr>
95-
<td></td>
96-
<td><button onclick="gui.restart()" type="button" id="restart">Restart</button></td>
97-
</tr>
98-
<tr>
99-
<td></td>
100-
<td><button onclick="gui.doPause()" type="button" id="Pause">Pause</button></td>
101-
</tr>
102-
</table>
42+
<div class="controls-panel">
43+
<h3>Controls</h3>
44+
<div class="controls-grid">
45+
<label>Current time</label>
46+
<span class="stat-value"><span id="time">0.00</span> s</span>
47+
48+
<label>Time per sim. step</label>
49+
<span class="stat-value"><span id="timePerStep">0.00</span> ms</span>
50+
51+
<label>Required iter. (rho)</label>
52+
<span id="iterations">0</span>
53+
54+
<label>Required iter. (div v)</label>
55+
<span id="iterationsV">0</span>
56+
57+
<label># particles</label>
58+
<span class="stat-value"><span id="numParticles">0</span></span>
59+
60+
<label for="widthInput">Width</label>
61+
<input onchange="gui.restart()" id="widthInput" type="number" value="40" step="1">
62+
63+
<label for="heightInput">Height</label>
64+
<input onchange="gui.restart()" id="heightInput" type="number" value="30" step="1">
65+
66+
<label for="timeStepSizeInput">Time step size</label>
67+
<input onchange="gui.sim.timeStepSize=parseFloat(value)" id="timeStepSizeInput" type="number" value="0.002" step="0.001">
68+
69+
<label for="maxErrorInput">Max. density error (%)</label>
70+
<input onchange="gui.sim.maxError=parseFloat(value)" id="maxErrorInput" type="number" value="0.1" step="0.01">
71+
72+
<label for="maxErrorVInput">Max. div. error (%)</label>
73+
<input onchange="gui.sim.maxErrorV=parseFloat(value)" id="maxErrorVInput" type="number" value="0.5" step="0.01">
74+
75+
<label for="iterationsInput">Max. iterations (rho)</label>
76+
<input onchange="gui.sim.maxIterations=parseInt(value)" id="iterationsInput" type="number" value="100" step="1">
77+
78+
<label for="iterationsVInput">Max. iterations (div v)</label>
79+
<input onchange="gui.sim.maxIterationsV=parseInt(value)" id="iterationsVInput" type="number" value="100" step="1">
80+
81+
<label for="viscosityInput">Viscosity</label>
82+
<input onchange="gui.sim.viscosity=parseFloat(value)" id="viscosityInput" type="number" value="0.05" step="0.01">
83+
84+
<label for="gravityInput">Gravity</label>
85+
<input onchange="gui.sim.gravity=parseFloat(value)" id="gravityInput" type="number" value="-9.81" step="0.01">
86+
87+
<div class="full-width">
88+
<button onclick="gui.restart()" id="restart">&#9654; Restart</button>
89+
</div>
90+
<div class="full-width">
91+
<button onclick="gui.doPause()" id="Pause" class="btn-secondary">&#9646;&#9646; Pause</button>
92+
</div>
93+
</div>
94+
</div>
10395
</td>
10496
</tr>
105-
<tr><td>
97+
</table>
98+
99+
<!-- Theory section -->
100+
<div class="card theory">
106101
<h2>DFSPH algorithm:</h2>
107102
This example shows the DFSPH method introduced by Bender and Koschier [BK17]:
108103
<ul>
@@ -227,7 +222,7 @@ <h3>References</h3>
227222
<li>[AIA+12] Nadir Akinci, Markus Ihmsen, Gizem Akinci, Barbara Solenthaler, and Matthias Teschner, "Versatile rigid-fluid coupling for incompressible SPH", ACM Transactions on Graphics 31(4), 2012</li>
228223
</ul>
229224
</td></tr>
230-
</table>
225+
</div>
231226

232227
</main>
233228

@@ -974,8 +969,8 @@ <h3>References</h3>
974969
this.timeSum = 0.0;
975970
this.counter = 0;
976971
this.pause = false;
977-
this.origin = { x : this.canvas.width / 2, y : this.canvas.height/2+200};
978-
this.zoom = 100;
972+
this.origin = { x : this.canvas.width / 2, y : this.canvas.height/2+250};
973+
this.zoom = 120;
979974
this.selectedParticle = -1;
980975

981976
// register mouse event listeners (zoom/selection)
@@ -1126,10 +1121,12 @@ <h3>References</h3>
11261121

11271122
getMousePos(canvas, event)
11281123
{
1129-
let rect = canvas.getBoundingClientRect();
1124+
const rect = canvas.getBoundingClientRect();
1125+
const scaleX = canvas.width / rect.width; // buffer / displayed size
1126+
const scaleY = canvas.height / rect.height;
11301127
return {
1131-
x: event.clientX - rect.left,
1132-
y: event.clientY - rect.top
1128+
x: (event.clientX - rect.left) * scaleX,
1129+
y: (event.clientY - rect.top) * scaleY
11331130
};
11341131
}
11351132

0 commit comments

Comments
 (0)