any possibility of adding a up vector to this function?
also here's my THREE js interpretation with NaN protection
function rotLookAt(dir, obj)
{
let x = new THREE.Vector3(1,0,0);
let y = new THREE.Vector3(0,1,0);
let z = new THREE.Vector3(0,0,1);
// Checks if we are about to divide by zero
if(dir.length() == 0)
{
console.log("dir equal zero dummy :(")
return obj.rotation;
}
let phi1 = dir.dot(x)/dir.length();
let phi2 = dir.dot(y)/dir.length();
let phi3 = dir.dot(z)/dir.length();
let zAngle = Math.atan(phi2/phi1);
let yAngle = Math.atan2(phi3, phi1);
let xAngle = Math.atan(phi2/phi3);
return new THREE.Euler(zAngle, -yAngle, obj.rotation.x, "ZYX");
}