cg1-visualisations/public/index.html

237 lines
4.6 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>CG1 MDI</title>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
<script src="matrix-math.js"></script>
<script src="shader.js"></script>
<script src="script.js"></script>
<style>
:root {
font-size: 20px;
--padding: 10px;
}
html, body {
margin: 0;
height: 100%;
}
body {
padding: 1vw;
box-sizing: border-box;
background-color: #1e1e2e;
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;
flex-grow: 1;
border: solid 2px #11111b;
}
#cv {
position: relative;
max-width: 100%;
max-height: 100%;
width: 100%;
height: 100%;
display: block;
background-color: #181825;
}
#stats, #controls {
padding: var(--padding);
display: block;
border: solid 2px #11111b;
border-radius: 20px;
}
#stats {
background-color: #31324480;
right: var(--padding);
position: absolute;
top: var(--padding);
}
#controls {
background-color: #313244;
}
#interpolate {
width: 100%;
}
#matrices {
display: grid;
grid-template-columns: 0px 1fr 0px 1fr 0px 1fr 0px 1fr 0px 1fr 0px 1fr 0px;
grid-gap: var(--padding);
padding-left: var(--padding);
padding-right: var(--padding);
}
.matrix {
background-color: #45475a;
border-radius: 20px;
display: flex;
justify-content: center;
align-items: center;
--fill-percentage: 0%;
position: relative;
overflow: hidden;
}
.matrix::before {
content: '';
position: absolute;
border-radius: 20px;
width: var(--fill-percentage);
height: 100%;
right: 0;
top: 0;
background-color: #585b70;
transition: width linear 0.05s;
}
#matrices > span {
display: flex;
justify-content: center;
align-items: center;
}
.matrix svg {
max-width: 100%;
height: auto;
}
.projection {
color: #f38ba8;
}
.lookAt {
color: #a6e3a1;
}
#copyright {
position: absolute;
bottom: var(--padding);
right: var(--padding);
text-shadow: 0px 0px 10px black;
text-align: right;
}
#copyright a {
color: #89b4fa;
}
</style>
</head>
<body>
<div id="display">
<canvas id="cv"></canvas>
<div id="stats">
<div>
FPS: <span id="fps"></span> - <span id="ms"></span>
</div>
<div>
Use virtual camera: <input type="checkbox" id="displayMatricesVirtually" checked autocomplete="off">
</div>
<div>
Backface Culling: <input type="checkbox" id="backfaceCulling" autocomplete="off">
</div>
</div>
<div id="copyright">
<a href="https://git.lgc.sh/HSH/cg1-visualisations">Source Code</a><br>
&copy; 2025 Luca Conte, Dennis Allerkamp
</div>
</div>
<div id="controls">
<div id="matrices">
<span></span>
<div class="matrix projection">
$$
\begin{pmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & -1 & 0 \\
0 & 0 & 0 & 1
\end{pmatrix}
$$
</div>
<span>$$\dot{}$$</span>
<div class="matrix projection">
$$
\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>
<span>$$\dot{}$$</span>
<div class="matrix projection">
$$
\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>
<span>$$\dot{}$$</span>
<div class="matrix projection">
$$
\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>
<span>$$\dot{}$$</span>
<div class="matrix lookAt">
$$
\begin{pmatrix}
u_x & u_y & u_z & 0 \\
v_x & v_y & v_z & 0 \\
n_x & n_y & n_z & 0 \\
0 & 0 & 0 & 1
\end{pmatrix}
$$
</div>
<span>$$\dot{}$$</span>
<div class="matrix lookAt">
$$
\begin{pmatrix}
1 & 0 & 0 & -e_x \\
0 & 1 & 0 & -e_y \\
0 & 0 & 1 & -e_z \\
0 & 0 & 0 & 1
\end{pmatrix}
$$
</div>
<span></span>
</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>