【问题标题】:SCNCamera won't update positionSCNCamera 不会更新位置
【发布时间】:2017-08-15 10:28:30
【问题描述】:

我有一个 SCNNode,它有一个名为 pointOfViewNode 的摄像头

每当我按下按钮时,我都会调用函数更新相机,我希望 SCNNode 在其中将其位置更改为聚焦目标,但是当我调用此函数时,位置不会按需要更改,我怎样才能将其移至可以吗?

func updateCamera()
{
    targetNode = SCNLookAtConstraint(target: planetNodeArray[currentFocusedElement])
    pointOfViewNode.constraints = [targetNode]
    //positions the camera node
    pointOfViewNode.position = SCNVector3(x: planetNodeArray[currentFocusedElement].position.x - 3 , y:planetNodeArray[currentFocusedElement].position.y + 65, z: planetNodeArray[currentFocusedElement].position.z + 2)
    pointOfViewNode.rotation = SCNVector4Make(1, 1, 1, -90)
    self.rootNode.addChildNode(pointOfViewNode)
    print(pointOfViewNode.position)
}

【问题讨论】:

    标签: swift scenekit


    【解决方案1】:

    我认为不是在 SCNView 上设置 pointOfView 属性,而是添加一个名为 pointOfViewNode 的节点。

    试试这个。

     self.scnView.pointOfView = someCameraNode;
    

    Here is the relevant reference.

    【讨论】:

      猜你喜欢
      • 2021-10-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-03
      • 2012-04-14
      • 2020-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多