yuccai Posted June 10, 2016 Share Posted June 10, 2016 Hi, I know that the worldMatrix and projectionMatrix are computed from other properties (like position/rotation/rotationQuaternion/scaling for worldMatrix and fieldOfView/ZNear/ZFar for projectionMatrix). I would like to know if I can proceed the inverse way. I mean I want to set these 2 matrices and automatically update the other properties which depend on it. Thanks for your help, Quote Link to comment Share on other sites More sharing options...
adam Posted June 10, 2016 Share Posted June 10, 2016 There is currently not a way to update in that direction. Quote Link to comment Share on other sites More sharing options...
adam Posted June 10, 2016 Share Posted June 10, 2016 You could probably write a function that executes in beforeRender that could do this using Matrix.decompose. Quote Link to comment Share on other sites More sharing options...
Kesshi Posted June 10, 2016 Share Posted June 10, 2016 to set the matrix for a mesh i use this typescript function: public static setMatrix(pMesh: BABYLON.AbstractMesh, pMatrix: BABYLON.Matrix): boolean { let tPos = BABYLON.Vector3.Zero(); let tRot = new BABYLON.Quaternion(); let tScale = new BABYLON.Vector3(1, 1, 1); if (pMatrix.decompose(tScale, tRot, tPos)) { pMesh.position = tPos; pMesh.rotationQuaternion = tRot; pMesh.scaling = tScale; return (true); } return (false); } Quote Link to comment Share on other sites More sharing options...
yuccai Posted June 10, 2016 Author Share Posted June 10, 2016 I know this possibility to set the worldMatrix but in this case I lost informations : I have the matrix to set A I compute the the scaling, rotation, position from A thanks to decompose I get a new matrix B but B is similar to A but not exactly the same. I found a solution for this case : Define a parent mesh that I call handler Use handler.setPivotMatrix(A) The visual result is exactly the same as if I had set A to the worldMatrix of the mesh I want to move but I can't find this kind of solution to set the projectionMatrix of a camera. I can retrieve fov/znear/zfar/aspectRatio from the original matrix, then set these values to the corresponding properties of the camera but then the projection matrix is still different of the original. dbawel 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted June 13, 2016 Share Posted June 13, 2016 Hey ProjectionMatrix is a different matrix computed here: https://github.com/BabylonJS/Babylon.js/blob/master/src/Cameras/babylon.camera.ts#L413 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.