gl-matrix
gl-matrix copied to clipboard
Nan when up is aligned with target
I'm not sure what's the right way to fix this or even whether a fix is necessary. Just wanted to log it here:
// glMatrix version 3.3.0
// Note that both `up` and `direction` are the same
let q = mat4.getRotation([], mat4.targetTo([], [0, 0, -1], [0, 0, 0], [0, 0, 1]))
// Now all quaternion components are not numbers
assert(Number.isNaN(q[0]))
assert(Number.isNaN(q[1]))
assert(Number.isNaN(q[2]))
assert(Number.isNaN(q[3]))
I have the same issue. Seems like it doesn't work when target is at 0, 0, 0. Why is that?
const matrix = glMatrix.mat4.targetTo(glMatrix.mat4.create(),
[0, 5, 0], [0, 0, 0], [0, 1, 0])
let rot = glMatrix.mat4.getRotation(glMatrix.quat.create(), matrix)
console.log(rot) // Float32Array(4) [NaN, NaN, NaN, NaN]
This results in a quat with "NaN, NaN, NaN, NaN"