zzlettle Posted April 17, 2018 Share Posted April 17, 2018 hi i get confused by the function Matrix decompose() api in this tutorial https://doc.babylonjs.com/resources/frame_of_reference i know mesh has its world matrix and its local frame of reference after apply some transform ( position, rotate and scale) whenever we want to get the mesh`s world matrix we can call mesh.getWorldMatrix(true); right? and i see lots of people use decompose() function after i checking its usage i thought the decompose() is for decompose a matrix like the mesh world matrix to get how the mesh be transformed that is to say how a identuty matrix [ BABYLON.Matrix.Identity()] be position, rotated and scaled by using decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3) we can get those three components am i right ? till i see some people use it in this way m.decompose(BABYLON.Vector3.Zero(), BABYLON.Quaternion.Identity(), position) that make me confused how can i set the components the scale set to BABYLON.Vector3.Zero() the rotation set to BABYLON.Quaternion.Identity() can some one tell me why? and how the matrix decompose() exactly the correct usage regards Quote Link to comment Share on other sites More sharing options...
Guest Posted April 17, 2018 Share Posted April 17, 2018 Hello! decompose is used to break a matrix into 3 basics component (scaling, quaternion and translation). So if you have a mesh and you want to decompose the world matrix to get, let's say, the position you will call something like that: var matrix = mesh.getWorldMatrix(); var position = BABYLON.Vector3.Zero(); matrix.decompose(null, null, position); // position now contains the translation part of the matrix Quote Link to comment Share on other sites More sharing options...
zzlettle Posted April 17, 2018 Author Share Posted April 17, 2018 thanks now i know the decompose() suage regards @Deltakosh GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.