const ctx = canvas.getContext('2d');
const focusLength = 300;
const pos = { x: 200, y: 200, z: 200 };
const perspective = focusLength / (focusLength + pos.z);
ctx.translate(pos.x * perspective, pos.y * perspective);
ctx.scale(perspective, perspective);