2 ms·
I didn't look at the code, but canvas only supports 3x3 transforms and you need 4x4 to do perspective: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRe
by arnioxux 9y ago
I didn't look at the code, but canvas only supports 3x3 transforms and you need 4x4 to do perspective: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/transform https://developer.mozilla.org/en-US/docs/Web/API/CanvasRende...
So if those cubes are textured, you'd need to subdivide the texture and approximate each with affine transforms. Here's an example of this hack (which was only necessary years ago before webgl
existed): https://acko.net/blog/projective-texturing-with-canvas/ https://acko.net/blog/projective-texturing-with-canvas/
- Matheus28 9y agoFor wireframe objects like the one in the OP (which actually does use a perspective projection it seems), that's not really a problem. Just have your own code that does all the matrix multiplication, and you get a point you can plug right into moveTo/lineTo