From 8bdc4754647c9c6691130fa91d51fee93c5fc88f Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 1 Feb 2026 10:51:15 +0100 Subject: feat: Implement 3D system and procedural texture manager - Extended mini_math.h with mat4 multiplication and affine transforms. - Implemented TextureManager for runtime procedural texture generation and GPU upload. - Added 3D system components: Camera, Object, Scene, and Renderer3D. - Created test_3d_render mini-demo for interactive 3D verification. - Fixed WebGPU validation errors regarding depthSlice and unimplemented WaitAny. --- src/tests/test_maths.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/tests/test_maths.cc') diff --git a/src/tests/test_maths.cc b/src/tests/test_maths.cc index d9bc4d1..64bbb45 100644 --- a/src/tests/test_maths.cc +++ b/src/tests/test_maths.cc @@ -110,6 +110,25 @@ void test_matrices() { mat4 view = mat4::look_at(eye, target, up); // Point (0,0,0) in world should be at (0,0,-5) in view space assert(near(view.m[14], -5.0f)); + + // Test matrix multiplication + mat4 t = mat4::translate({1, 2, 3}); + mat4 s = mat4::scale({2, 2, 2}); + mat4 ts = t * s; // Scale then Translate (if applied to vector on right: M*v) + + // v = (1,1,1,1) -> scale(2,2,2) -> (2,2,2,1) -> translate(1,2,3) -> (3,4,5,1) + vec4 v(1, 1, 1, 1); + vec4 res = ts * v; + assert(near(res.x, 3.0f)); + assert(near(res.y, 4.0f)); + assert(near(res.z, 5.0f)); + + // Test Rotation + // Rotate 90 deg around Z. (1,0,0) -> (0,1,0) + mat4 r = mat4::rotate({0, 0, 1}, 1.570796f); + vec4 v_rot = r * vec4(1, 0, 0, 1); + assert(near(v_rot.x, 0.0f)); + assert(near(v_rot.y, 1.0f)); } // Tests easing curves -- cgit v1.2.3