I often find myself getting the world position of an object via object.matrixWorld.decompose(position, quaternion, scale)
, without any need to get the quaternion or scale. However, not passing in a valid quaternion/euler or scale results in an error.
Would it be possible ignore undefined parameters with something like the following pseudo code?
if (position) {
calculate and set position;
}
if (quaternion) {
calculate and set quaternion;
}
if (scale) {
calculate and set scale;
}
Alternatively, could a extractPosition()
function and maybe a extractScale()
function be added to go along with extractRotation()
?
You can use these Vector3
methods:
vector.setFromMatrixPosition( matrix );
vector.setFromMatrixScale( matrix );
You can use these
Vector3
methods:vector.setFromMatrixPosition( matrix ); vector.setFromMatrixScale( matrix );
Ah, that's how it's done. Thank you very much!
I actually ran into this before because I wasn't aware of the Vector3 functions for getting translation / scale from a Matrix4.
Maybe it's worth adding a link in the docs, for functions like Matrix4.setPosition
, to their corresponding getter functions like Vector3.setFromMatrixPosition
?
Sounds good to me.
Feel free to send a PR with the enhancement 馃檹
Added to the docs in #18767
Most helpful comment
You can use these
Vector3
methods: