move matrices below canvas & add "progress bar"

This commit is contained in:
Luca Conte 2025-05-10 01:17:24 +02:00
parent 4752146630
commit 9861a1dfd6
2 changed files with 84 additions and 23 deletions

View File

@ -11,6 +11,7 @@
<style>
:root {
font-size: 20px;
--padding: 10px;
}
html, body {
@ -25,14 +26,19 @@
color: #cdd6f4;
font-family: monospace;
overflow: hidden;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
gap: var(--padding);
}
#display {
position: relative;
overflow: hidden;
box-sizing: border-box;
border-radius: 20px;
height: 100%;
width: 100%;
flex-grow: 1;
border: solid 2px #11111b;
}
@ -46,9 +52,7 @@
background-color: #181825;
}
#stats, #controls {
position: absolute;
top: 20px;
padding: 20px;
padding: var(--padding);
display: block;
border: solid 2px #11111b;
background-color: #31324480;
@ -56,16 +60,48 @@
}
#stats {
right: 20px;
right: var(--padding);
position: absolute;
top: var(--padding);
}
#controls {
left: 20px;
}
#interpolate {
width: 100%;
}
#matrices {
display: grid;
grid-template-columns: repeat(6, 1fr);
grid-gap: var(--padding);
padding-left: var(--padding);
padding-right: var(--padding);
}
#matrices > div {
background-color: rgba(255, 255, 255, 0.1);
border-radius: 20px;
display: flex;
justify-content: center;
align-items: center;
--fill-percentage: 0%;
position: relative;
overflow: hidden;
}
#matrices > div::before {
content: '';
position: absolute;
border-radius: 20px;
width: var(--fill-percentage);
height: 100%;
right: 0;
top: 0;
background-color: rgba(32, 32, 128, 0.3);
}
</style>
</head>
<body>
@ -82,8 +118,9 @@
Backface Culling: <input type="checkbox" id="backfaceCulling" autocomplete="off">
</div>
</div>
<div id="controls">
</div>
<div id="controls">
<div id="matrices">
<div>
$$
\color{red}
@ -93,24 +130,43 @@
0 & 0 & -1 & 0 \\
0 & 0 & 0 & 1
\end{pmatrix}
$$
</div>
<div>
$$
\color{red}
\begin{pmatrix}
\frac{2}{r-l} & 0 & 0 & 0 \\
0 & \frac{2}{t-b} & 0 & 0 \\
0 & 0 & \frac{2}{f-n} & 0 \\
0 & 0 & 0 & 1
\end{pmatrix}
$$
</div>
<div>
$$
\color{red}
\begin{pmatrix}
1 & 0 & 0 & - \frac{r+l}{2} \\
0 & 1 & 0 & - \frac{t+b}{2} \\
0 & 0 & 1 & \frac{n+f}{2} \\
0 & 0 & 0 & 1
\end{pmatrix}
$$
</div>
<div>
$$
\color{red}
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 1 + \frac{f}{n} & f \\
0 & 0 & - \frac{1}{n} & 0
\end{pmatrix}
$$
</div>
<div>
$$
\color{green}
\begin{pmatrix}
u_x & u_y & u_z & 0 \\
@ -118,6 +174,11 @@
n_x & n_y & n_z & 0 \\
0 & 0 & 0 & 1
\end{pmatrix}
$$
</div>
<div>
$$
\color{green}
\begin{pmatrix}
1 & 0 & 0 & -e_x \\
0 & 1 & 0 & -e_y \\
@ -125,19 +186,16 @@
0 & 0 & 0 & 1
\end{pmatrix}
$$
<input id="interpolate" type="range" min="0" max="6" step="0.05" value="6" autocomplete="off" list="steplist">
<datalist id="steplist">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</datalist>
</div>
<div>
</div>
</div>
<input id="interpolate" type="range" min="0" max="6" step="0.05" value="6" autocomplete="off" list="steplist">
<datalist id="steplist">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</datalist>
</div>
</body>
</html>

View File

@ -76,15 +76,18 @@ async function init() {
invertZAxis = true;
}
for (let i = 0; i < 6; ++i) {
let v;
if (i > t) {
interpolate[i] = 0.0;
v = 0.0;
}
else if (i+1 > t) {
interpolate[i] = t - Math.floor(t);
v = t - Math.floor(t);
}
else {
interpolate[i] = 1.0;
v = 1.0;
}
interpolate[i] = v;
document.getElementById("matrices").children[5-i].style.setProperty("--fill-percentage", (v * 100) + "%");
}
});
document.getElementById("displayMatricesVirtually").addEventListener("input", (e) => {