How to apply a 4x4 transformation matrix to a Mesh / AbstractMesh

Hi,
I’ve a 4x4 transformation matrix that I prefer to apply to Mesh / AbstractMesh.

I see API options to rotate, translate meshes & apply quaternions, but couldn’t locate API for applying transformation matrix (mat4 GLSL type).
The transformation matrix I get from an another application has values of rotation, translation, scaling, reflection embedded in it.

Is there a way apply this mat4 data to Babylon’s AbstractMesh & get it transformed?

Thanks

It is funny the question popped a couple days back here: Set transform on mesh and view in inspector - #4 by sebavan

It shows how to do it and explain what are the limitations.

2 Likes

Oh! ok. Got it. Thanks for the immediate reply.
Like you quoted, these lines of code from playground sample had the answer to my query.

let sourceMatrix = BABYLON.Matrix.FromValues(2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0, 2, 0, 1);
let matrix = sphere.getWorldMatrix();
matrix.copyFrom( sourceMatrix ); 

I need to come out of C++ mindset and learn these Javascript tricks :wink:.
All along, I was expecting a setWorldMatrix() kindof API for Mesh.

2 Likes

I can relate. I’ve been in Javascript land for a little over a year now. And I only started finally using === :wink:

2 Likes