【问题标题】:Animating SceneKit SCNNode position not working动画 SceneKit SCNNode 位置不起作用
【发布时间】:2020-03-01 14:56:00
【问题描述】:

我完全按照这个:https://developer.apple.com/documentation/scenekit/animation/animating_scenekit_content

我在另一个具有用户面部几何形状的 SCNNode 上有一个 SCNNode。

面部 SCNNode 上的 SCNNode,我希望运动具有动画效果。我正在调用这个函数,它位于我想要动画的 SCNNode 的子类中。它所占用的属性是面上的一个位置。这个功能根本不起作用:

 func move(to vertex: SCNVector3) {
  let animation = CABasicAnimation(keyPath: "move")
  animation.fromValue = SCNVector3(self.position.x, self.position.y, self.position.z)
  animation.toValue = vertex
  animation.duration = 3.0
  self.addAnimation(animation, forKey: "move")
 }

这个功能非常好用:

 func move(to vertex: SCNVector3) {
  self.position.x = vertex.x
  self.position.y = vertex.y
  self.position.z = vertex.z
 }

两个函数的函数调用:

move(to: SCNVector3(anchor.geometry.vertices[Node.oldVertexPos].x, anchor.geometry.vertices[Node.oldVertexPos].y, anchor.geometry.vertices[Node.oldVertexPos].z))

【问题讨论】:

    标签: ios swift animation cabasicanimation scnnode


    【解决方案1】:

    SCNNode 上不存在 keyPath “move”,您应该为该位置设置动画。

    let animation = CABasicAnimation(keyPath: "position")

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-21
      • 2014-10-07
      • 2017-04-15
      • 1970-01-01
      • 2016-12-01
      • 2016-12-29
      • 2018-12-06
      • 2021-03-11
      相关资源
      最近更新 更多