In the three_js package, the implementation of Object3D.applyMatrix4 diverges from both three.js and three_dart, resulting in an incorrect transformation order when applying matrices.
Current Behavior (Bug)
In packages/three_js_core/lib/core/object_3d.dart#L230:
This post-multiplies the object’s current matrix by the input matrix (M = M * m).
As a result, applying a world-space transformation (e.g., translation) ends up being applied in local coordinates, producing unexpected or incorrect transformations — especially noticeable when an object already has rotation.
Expected Behavior
According to the original three.js implementation Object3D.js#L427:
this.matrix.premultiply(matrix);
and three_dart correctly mirrors this: object_3d.dart#L218
That order (M = m * M) ensures the applied matrix operates in world space, matching three.js semantics.
Impact
- Applying a transformation matrix yields rotated or offset translations.
- Scene updates depending on applyMatrix4 (e.g., aligning models, placing objects in world space) behave incorrectly.
- This breaks API parity with both three.js and three_dart.