From an external application I get the rotation matrix and convert it to angles. Then I change the angles.
How do I get a rotation matrix with changed angles?

There are a few ways to do that using babylonâ€™s math functions.

The first is to use quaternions, as quaternions have toRotationMatrix function. That would be the simplest (i guess), though it depend on your implementation. What you can always do is get the rotation from the objectâ€™s world matrix. The matrixâ€™s class has the function getRotationMatrix (and ...ToRef as well) that can be called on the objectâ€™s world matrix (after computing it, if you just changed the rotation).

If you want to show a playground of how you use the object, it will be simpler to provide some code to show you how to do it.

A matrix is a matrix. We have 4x4 matrix support, which means you get 16 values. But just like the matrix you provide, the last values can be â€śignoredâ€ť, since, in a rotation-only matrix, they are not really used.

A playground would be helpful if you want some code examples

toRotationMatrix is what I needed, thanks!
I havenâ€™t found a way to convert the current matrix, but it is possible to create a new one with the angles calculated from the current matrix.

newQuaternion = new BABYLON.Quaternion.RotationYawPitchRoll(sphere.rotation.x sphere.rotation.y, sphere.rotation.z);
newMatrix = newQuaternion .toRotationMatrix(BABYLON.Matrix.Zero());