change-mat4-coordinate-system
Convert a 4x4 column major matrix from left handed to right handed coordinate system
Background / Initial Motivation
Blender exports bone matrices in using a handed coordinate system, but WebGL uses a left handed coordinate system.
I used to know change coordinate systems by changing my final gl_Position
's coordinates, but I now need to manipulate
coordinates before I get to my vertex shader (to find the location and rotation of a bone so that I can render something
on top of it).
This module helps me with converting everything to left handed during compile time, so that I don't need to do any
coordinate system conversion during runtime.
To Install
$ npm install --save change-mat4-coordinate-system
Usage
var changeMat4Coords = // Don't worry, both rotations and translations will be converted.// It's just easier to demonstrate translations here.var rightHandedMatrix = 1 0 0 0 0 1 0 0 0 0 1 0 0 5 1 1 var leftHandedMatrix = changeMat4Coords console// [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, -5, 1]
License
MIT