繁体   English   中英

动画 SceneKit SCNNode 位置不起作用

[英]Animating SceneKit SCNNode position not working

我完全按照这个: 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))

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

let animation = CABasicAnimation(keyPath: "position")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM