improve 3d renderer

This commit is contained in:
asrael 2025-11-19 22:18:08 -06:00
parent f19b06d705
commit a9de20cdea
17 changed files with 572 additions and 489 deletions

View file

@ -5,7 +5,7 @@
(var angle-y 0)
(var angle-z 0)
(var auto-rotate? true)
(var orthographic? true)
(var orthographic? false)
(var wireframe? true)
(var time 0)
(var zoom 5.0)
@ -27,7 +27,7 @@
(set angle-y 0)
(set angle-z 0)
(set auto-rotate? true)
(set orthographic? true)
(set orthographic? false)
(set wireframe? true)
(set time 0)
(set zoom 5.0)
@ -169,12 +169,11 @@
(fn draw-cube [pos scale rotation-offset]
(let [[x y z] pos
model (-> (pxl8.mat4_identity)
(pxl8.mat4_multiply (pxl8.mat4_scale scale scale scale))
(pxl8.mat4_multiply (pxl8.mat4_rotate_x (+ angle-x rotation-offset)))
(pxl8.mat4_multiply (pxl8.mat4_rotate_y (+ angle-y (* rotation-offset 1.3))))
model (-> (pxl8.mat4_translate x y z)
(pxl8.mat4_multiply (pxl8.mat4_rotate_z (+ angle-z (* rotation-offset 0.7))))
(pxl8.mat4_multiply (pxl8.mat4_translate x y z)))]
(pxl8.mat4_multiply (pxl8.mat4_rotate_y (+ angle-y (* rotation-offset 1.3))))
(pxl8.mat4_multiply (pxl8.mat4_rotate_x (+ angle-x rotation-offset)))
(pxl8.mat4_multiply (pxl8.mat4_scale scale scale scale)))]
(pxl8.set_model model))
(let [vertices (make-cube-vertices)]