rendajs / Renda

A modern rendering engine for the web.
https://rendajs.org
MIT License
10 stars 4 forks source link

Setting `Entity.worldMatrix` does not always update its children. #873

Closed jespertheend closed 6 months ago

jespertheend commented 6 months ago

Here's a test to reproduce the issue:

Deno.test({
    name: "setting world matrix affects children",
    only: true,
    fn() {
        const root = new Entity();
        const childA = root.add(new Entity()); // The entity we will be moving up
        const childB = childA.add(new Entity()); // The entity we will reset (i.e. move down again)
        const childC = childB.add(new Entity()); // The entity that should have the identity matrix

        childA.worldMatrix.set(Mat4.createTranslation(0, 1, 0));
        assertMatAlmostEquals(childB.worldMatrix, Mat4.createTranslation(0, 1, 0));
        assertMatAlmostEquals(childC.worldMatrix, Mat4.createTranslation(0, 1, 0));

        childB.worldMatrix.set(new Mat4());
        assertMatAlmostEquals(childC.worldMatrix, new Mat4());
    },
});