camera.transform 和 pointOfView 有什么区别

What is the difference between camera.transform and pointOfView

为了将物体放在相机前面,我看到有两种方法:使用 camera.transformpointOfView

camera.transform 来自 SCNViewscnView.session.currentFrame.camera.transform https://developer.apple.com/documentation/arkit/arcamera

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

这里是使用方法

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

pointOfView 来自 SCNViewscnView.pointOfView https://developer.apple.com/documentation/scenekit/scnscenerenderer/1523982-pointofview

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

下面是使用方法,使用convertPosition转换为世界坐标

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

这两个有什么区别?两者似乎都指的是相机

session property is exposed by ARSCNView,不是直接SCNView。 ARKit 使用其会话的相机转换来驱动 SceneKit 场景的视角,因此在这种情况下它们是匹配的。但并非每个 SceneKit 应用程序都使用 ARKit,在这种情况下,定位视角是开发人员的责任。