I am trying to get the forward (LookAt) vector of the camera in ARKit, but I think I getting something wrong.
After doing some research, I wrote this helper extension below, but I don't think it is right from the data I am getting. (The Y-Component is negative when I point the camera upwards).
Can someone let me know what I getting wrong about getting the vector the camera is pointing in world space? Also, if there is a better way to get it (CoreLocation?) I am open to that too.
extension ARCamera {
/**
The Camera forward orientation vector as vector_float3.
*/
var forward: vector_float3 {
get {
return vector_float3(-1 * self.transform.columns.3.x,
-1 * self.transform.columns.3.y,
-1 * self.transform.columns.3.z)
}
}
/**
The Camera forward orientation vector as vector_float3 normalized.
*/
var normalForward: vector_float3 {
get {
let theNormaled = simd_normalize(vector_float3(-1 * self.transform.columns.3.x,
-1 * self.transform.columns.3.y,
-1 * self.transform.columns.3.z))
return theNormaled
}
}
}
Thanks in advance.
Stan