scenekitios10.3

Scene Kit: Set camera rotation from lookAt vector and up vector


I wanted to ask you how to set the local camera rotation from the lookAt vector and the up vector in SceneKit? Is there any function for it like in Unity3D? Further I wanted to ask if the camera can be rotated relative to the camera node? As I understand it, the coordinate system from the camera is different to the global coordinate system (z is inverse).

Thanks a lot in advance!


Solution

  • The new util methods mentioned by Confused can be found on the SCNNode class. The one you're most likely interested in is simdLook(at:up:localFront:)

    func simdLook(at worldTarget: vector_float3, 
                  up worldUp: vector_float3, 
                  localFront: simd_float3)