【问题标题】:How to update the pointOfView in ARKit如何在 ARKit 中更新 pointOfView
【发布时间】:2017-10-13 12:12:01
【问题描述】:

我正在尝试构建我的第一个 ARKit 应用。该应用程序的目的是在相机所面对的方向上拍摄小块。现在,这是我的代码。

 sceneView.scene.physicsWorld.gravity = SCNVector3(x: 0, y: 0, z: -9.8)


 @IBAction func tapScreen() {
    if let camera = self.sceneView.pointOfView {
        let sphere = NodeGenerator.generateCubeInFrontOf(node: camera, physics: true)
        self.sceneView.scene.rootNode.addChildNode(sphere)
        var isSphereAdded = true
        print("Added box to scene")

    }


}

重力工作正常,每当我点击屏幕时,每次点击时块都会射出。但是,无论相机朝向哪个方向,它们都拍摄到同一个点。我试图了解 pointOfView 的工作原理,我需要重新渲染整个场景吗?还有什么我想不出来的?谢谢你的帮助!

【问题讨论】:

    标签: swift arkit


    【解决方案1】:

    更改此行
    self.sceneView.scene.rootNode.addChildNode(sphere)
    

    self.sceneView.pointOfView?.addChildNode(sphere)
    

    【讨论】:

      猜你喜欢
      • 2018-01-30
      • 2018-09-26
      • 1970-01-01
      • 2019-03-25
      • 2019-08-24
      • 2012-12-16
      • 1970-01-01
      • 2021-08-17
      • 1970-01-01
      相关资源
      最近更新 更多