1
votes

For placing object in front of the camera, I see there are 2 ways: using camera.transform and pointOfView

camera.transform is from SCNView and scnView.session.currentFrame.camera.transform https://developer.apple.com/documentation/arkit/arcamera

The position and orientation of the camera in world coordinate space.

Here is how to use it

var translation = matrix_identity_float4x4
translation.columns.3.z = -2
node.simdTransform = matrix_multiply(currentFrame.camera.transform, translation)

pointOfView is from SCNView and scnView.pointOfView https://developer.apple.com/documentation/scenekit/scnscenerenderer/1523982-pointofview

The node from which the scene’s contents are viewed for rendering

Here is how it is used, using convertPosition to convert to world coordinate

let camera = scnView.pointOfView!
let position = SCNVector3(x: 0, y: 0, z: -2)
node.position = camera.convertPosition(position, to: nil)

What is the difference between these 2? Both seems to refer to the camera

1

1 Answers

3
votes

The session property is exposed by ARSCNView, not directly by SCNView. ARKit uses its session's camera transform to drive the SceneKit scene's point of view, so in this case they match. But not every SceneKit application uses ARKit, and in this case orientating the point of view is the responsibility of the developer.