201 lines
3.8 KiB
HTML
201 lines
3.8 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;
|
|
background-color: #31324480;
|
|
border-radius: 20px;
|
|
}
|
|
|
|
#stats {
|
|
right: var(--padding);
|
|
position: absolute;
|
|
top: var(--padding);
|
|
}
|
|
|
|
#controls {
|
|
|
|
}
|
|
|
|
#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(255, 255, 255, 0.1);
|
|
}
|
|
</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>
|
|
<div id="controls">
|
|
<div id="matrices">
|
|
<div>
|
|
$$
|
|
\color{red}
|
|
\begin{pmatrix}
|
|
1 & 0 & 0 & 0 \\
|
|
0 & 1 & 0 & 0 \\
|
|
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 \\
|
|
v_x & v_y & v_z & 0 \\
|
|
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 \\
|
|
0 & 0 & 1 & -e_z \\
|
|
0 & 0 & 0 & 1
|
|
\end{pmatrix}
|
|
$$
|
|
</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> |