【发布时间】:2017-12-18 10:42:42
【问题描述】:
我正在同时学习 ARKit 和 Scenekit,这有点挑战。
创建了 ARWorldTrackingSessionConfiguration 会话后,我想知道是否有人知道在场景会话中获取用户“相机”位置的方法。这个想法是我想为用户当前位置的对象设置动画。
let reaperScene = SCNScene(named: "reaper.dae")!
let reaperNode = reaperScene.rootNode.childNode(withName: "reaper", recursively: true)!
reaperNode.position = SCNVector3Make(0, 0, -1)
let scene = SCNScene()
scene.rootNode.addChildNode(reaperNode)
// some unknown amount of time later
let currentCameraPosition = sceneView.pointOfView?.position
let moveAction = SCNAction.move(to: currentCameraPosition!, duration: 1.0)
reaperNode.runAction(moveAction)
但是,即使我正在移动相机,currentCameraPosition 似乎总是 [0,0,0]。知道我做错了什么吗?最终的想法是我将围绕一个不可见的球体旋转对象,直到它位于相机前面,然后对其进行动画处理,执行类似于此的操作:Rotate SCNCamera node looking at an object around an imaginary sphere(这样用户会看到对象向他们移动)
感谢您的帮助。
【问题讨论】:
标签: swift scenekit augmented-reality arkit