Every mathematical vector and transformation is expressed in a certain frame of reference. This is for example handled by the BABYLON.Space.LOCAL
and BABYLON.Space.WORLD
constants used in the rotate()
and translate()
functions cited above, or locallyTranslate()
and other similar functions.
A frame of reference is in fact a regular transformation matrix, i.e. an association of rotation, translation and scaling operations.
You may need to express a certain vector in a precise frame of reference, be it the one of a mesh or an arbitrary one. In this case, the function BABYLON.Vector3.TransformCoordinates()
will come in handy.
Here is how you would compute the up vector (Y+) inside the frame of reference of a mesh:
mesh.computeWorldMatrix();
var matrix = mesh.getWorldMatrix();
var up_local = new BABYLON.Vector3(0,1,0);
var up_global = BABYLON.Vector3.TransformCoordinates(up_local, matrix);
Potential uses of BABYLON.Vector3.TransformCoordinates()
may be:
applyImpulse()
and other physics-related functions