Hi @dawickizer
World matrix (and matrices in general) are 16 numbers (4x4) used to transform positions and vectors from 1 reference space to another.
They contain everything to translate, rotate and scale. You’ll often see in tools like 3d modelers, engines,… some input box for specifying translate,rotate and scale of a mesh. Those values are then converted to a matrix. Math and computation are simpler when dealing with a matrix.
Mesh vertex position, normal vectors,… everything space related are multiplied by this matrix to compute the final result.
The notion of local coordinate and world coordinate is really important. local is position or vector before its transformation with a matrix.
A world matrix transforms a local coordinate to a world coordinate. Hence its name.
On the same trend, cameras also have matrices in order to convert the mesh into the camera space.
Matrices are 4 vectors that look like this for mesh matrices:
RightX, RightY, RightZ, 0
UpX, UpY, UpZ, 0
DirectionX, DirectionY, DirectionZ, 0
TranslationX, TranslationY, TranslationZ, 1
the magnitude of Right,Up and Direction vectors give the scale of the mesh
Concerning your code, origin is the position of the camera (the position of the eye)
wm, is the world matrix (camera position, orientation)
Vector3.TransformCoordinates(Vector3.Forward(), wm)
This code transform the local position Vector3.Forward with the worldMatrix giving a world position. It will be a position just in front of the camera.
Then, this world position is substracted with the camera origin in order to get a vector. This vector is the direction of the camera. Vector is then normalized so its length is 1.
This code can be simplified to:
let wm = this.camera.getWorldMatrix();
let aimVector = Vector3.TransformNormal(Vector3.Forward(), wm).normalize();
Instead of computing 2 world position and substracting, the forward vector is transformed from local to world coordinate and normalized.
Here is a good tutorial with a bunch of math but also some nice pictures that will help you understand
http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/