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

**URL:** <https://forum.babylonjs.com/t/how-to-apply-a-4x4-transformation-matrix-to-a-mesh-abstractmesh/24693>\
**Category:** Questions\
**Created:** [October 19, 2021, 3:51pm UTC](https://forum.babylonjs.com/t/how-to-apply-a-4x4-transformation-matrix-to-a-mesh-abstractmesh/24693 "2021-10-19T15:51:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anand471](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/anand471/32/20479_2.png) [@anand471](https://forum.babylonjs.com/u/anand471)\
**Post date:** [October 19, 2021, 3:51pm UTC](https://forum.babylonjs.com/t/how-to-apply-a-4x4-transformation-matrix-to-a-mesh-abstractmesh/24693/1 "2021-10-19T15:51:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [October 19, 2021, 3:54pm UTC](https://forum.babylonjs.com/t/how-to-apply-a-4x4-transformation-matrix-to-a-mesh-abstractmesh/24693/2 "2021-10-19T15:54:54Z")

</div>

It is funny the question popped a couple days back here: [Set transform on mesh and view in inspector - #4 by sebavan](https://forum.babylonjs.com/t/set-transform-on-mesh-and-view-in-inspector/24671/4)

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

---

<div class="post-metadata">

**Author:** ![anand471](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/anand471/32/20479_2.png) [@anand471](https://forum.babylonjs.com/u/anand471)\
**Post date:** [October 19, 2021, 7:05pm UTC](https://forum.babylonjs.com/t/how-to-apply-a-4x4-transformation-matrix-to-a-mesh-abstractmesh/24693/3 "2021-10-19T19:05:51Z")

</div>

Oh! ok. Got it. Thanks for the immediate reply.  
Like you quoted, these lines of code from [playground sample](https://playground.babylonjs.com/#1PEB08#2) 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 😉.  
All along, I was expecting a setWorldMatrix() kindof API for Mesh.

---

<div class="post-metadata">

**Author:** ![msDestiny14](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/msdestiny14/32/9572_2.png) [@msDestiny14](https://forum.babylonjs.com/u/msDestiny14)\
**Post date:** [October 19, 2021, 7:21pm UTC](https://forum.babylonjs.com/t/how-to-apply-a-4x4-transformation-matrix-to-a-mesh-abstractmesh/24693/4 "2021-10-19T19:21:57Z")

</div>

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