Skip to main content

One post tagged with "graphics"

View All Tags

(WIP) The Humblest Equation In 3D Graphics - (x', y') = (x/z, y/z)

· One min read

Index.html

<canvas id="vfx"></canvas>
<script src="cube.js"></script>
<script src="index.js"></script>

Cube.js

const vertices = [
{ x: 0.25, y: 0.25, z: 0.25 },
{ x: -0.25, y: 0.25, z: 0.25 },
{ x: -0.25, y: -0.25, z: 0.25 },
{ x: 0.25, y: -0.25, z: 0.25 },

{ x: 0.25, y: 0.25, z: -0.25 },
{ x: -0.25, y: 0.25, z: -0.25 },
{ x: -0.25, y: -0.25, z: -0.25 },
{ x: 0.25, y: -0.25, z: -0.25 },
];

const faces = [
[0, 1, 2, 3],
[4, 5, 6, 7],
[0, 4],
[1, 5],
[2, 6],
[3, 7],
];