如何在 SceneKit 中反转动画?
How can I reverse an animation in SceneKit?
我正在使用 Fox 2 示例(您可以在此处找到它 https://developer.apple.com/videos/play/wwdc2017/604/ and here https://developer.apple.com/library/content/samplecode/scenekit-2017/Introduction/Intro.html)学习如何使用 SceneKit
中的动画功能,我有一个问题:
如何反转动画?
我在官方文档(非常非常差)和网上都搜索了,但是似乎没有内置可以反转动画的功能。
我发现了三个有趣的参数:
.autoreverses
: "when true, the object plays backwards after playing forwards. Defaults to NO"
.fillsBackward
: "when true, the animation is active before its active duration and evaluates to its start value. Defaults to NO"
.fillsForward
: "when true, the animation remains active after its active duration and evaluates to its end value. Defaults to NO"
问题是第一个参数不符合我的要求,当我使用其他两个参数时,没有任何反应:S
我是这样使用这些参数的:
我在角色模型中加载动画的地方
let spinAnimation = Character.loadAnimation(fromSceneNamed: "Art.scnassets/character/max_spin.scn")
spinAnimation.animation.isRemovedOnCompletion = false
spinAnimation.speed = 1.5
spinAnimation.stop()
model!.addAnimationPlayer(spinAnimation, forKey: "spin")
我在哪里创建角色并开始动画
character2 = Character.init(scene: scnScene!)
character2?.model.position = SCNVector3(x: 0.15, y: -0.3, z: 0)
scnScene!.rootNode.addChildNode(character2!.node!)
character2?.model.animationPlayer(forKey: "spin")?.animation.fillsForward = true //or fillsBackward or autoreverses
character2?.model.animationPlayer(forKey: "spin")?.play()
我是不是误解了.fillsBackward
和.fillsForward
?是否有详尽且更新的 SceneKit 文档?
我不知道如何关闭这个问题,因为问题已经解决了所以:
要在 SceneKit 中反转动画,只需将速度设置为负值(例如:-1)
我正在使用 Fox 2 示例(您可以在此处找到它 https://developer.apple.com/videos/play/wwdc2017/604/ and here https://developer.apple.com/library/content/samplecode/scenekit-2017/Introduction/Intro.html)学习如何使用 SceneKit
中的动画功能,我有一个问题:
如何反转动画?
我在官方文档(非常非常差)和网上都搜索了,但是似乎没有内置可以反转动画的功能。
我发现了三个有趣的参数:
.autoreverses
: "when true, the object plays backwards after playing forwards. Defaults to NO".fillsBackward
: "when true, the animation is active before its active duration and evaluates to its start value. Defaults to NO".fillsForward
: "when true, the animation remains active after its active duration and evaluates to its end value. Defaults to NO"
问题是第一个参数不符合我的要求,当我使用其他两个参数时,没有任何反应:S
我是这样使用这些参数的:
我在角色模型中加载动画的地方
let spinAnimation = Character.loadAnimation(fromSceneNamed: "Art.scnassets/character/max_spin.scn") spinAnimation.animation.isRemovedOnCompletion = false spinAnimation.speed = 1.5 spinAnimation.stop() model!.addAnimationPlayer(spinAnimation, forKey: "spin")
我在哪里创建角色并开始动画
character2 = Character.init(scene: scnScene!) character2?.model.position = SCNVector3(x: 0.15, y: -0.3, z: 0) scnScene!.rootNode.addChildNode(character2!.node!) character2?.model.animationPlayer(forKey: "spin")?.animation.fillsForward = true //or fillsBackward or autoreverses character2?.model.animationPlayer(forKey: "spin")?.play()
我是不是误解了.fillsBackward
和.fillsForward
?是否有详尽且更新的 SceneKit 文档?
我不知道如何关闭这个问题,因为问题已经解决了所以: 要在 SceneKit 中反转动画,只需将速度设置为负值(例如:-1)