ios - camera.transform 和 pointOfView 有什么区别

标签 ios camera transform scenekit arkit

为了将物体放在相机前面,我看到有两种方法:使用 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属性由 ARSCNView 公开,而不是直接通过 SCNView。 ARKit 使用其 session 的相机转换来驱动 SceneKit 场景的视角,因此在这种情况下它们是匹配的。但并非每个 SceneKit 应用程序都使用 ARKit,在这种情况下,定位视角是开发人员的责任。

关于ios - camera.transform 和 pointOfView 有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49432817/

相关文章:

css - 如何使用 CSS3 比例保持背景纵横比?

ios - UIView animatewithDuration - 移除动画

ios - 存储试用期日期

iphone - iOS 5 横向应用程序。工作完美。在 iOS 6 设备上锁定为纵向

html - 输入类型文件标签中的 capture ="user"和 capture ="camera"有什么区别?

android - 如何通过html5访问手机上的特定摄像头

css - "Card flip"不暴露背面的复选框

ios - iOS 上的 crt_externs.h ?

Python 没有从 Raspberry Pi 相机以最高分辨率拍照

ios - 动画转换 UILabel 的一部分