在 ARKit 中为 3D 模型添加动画 [英] Adding animation to 3D models in ARKit

查看:49
本文介绍了在 ARKit 中为 3D 模型添加动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个视频中,一个物体被赋予了一个动画,它在放置时会在房间周围盘旋,然后当点击它时,它会以另一个动画下降.如何在我的项目中添加这种动画?添加一个已经动画的对象是唯一的方法吗?

In this video an object is given an animation to hover around the room when placed and then when tapped it gets dropped down with another animation. How can I add this kind of animations in my project? Is adding an already animated object the only way?

谢谢

https://youtu.be/OS_kScr0XkQ

推荐答案

我认为上下悬停很可能是一个动画序列.以下用于悬停效果的动画序列将在第一个下拉选择功能中起作用.

I think the hovering up and down is most likely an animation sequence. The following animation sequence for a hovering effect will work inside the first drop down selection function.

        let moveDown = SCNAction.move(by: SCNVector3(0, -0.1, 0), duration: 1)
        let moveUp = SCNAction.move(by: SCNVector3(0,0.1,0), duration: 1)
        let waitAction = SCNAction.wait(duration: 0.25)
        let hoverSequence = SCNAction.sequence([moveUp,waitAction,moveDown])
        let loopSequence = SCNAction.repeatForever(hoverSequence)
        node2Animate.runAction(loopSequence)

        self.sceneView.scene.rootNode.addChildNode(node2Animate)

当你点击节点时停止动画的第二部分把它放在点击手势功能中.

The second part to stop the animation when you tap the node put this inside the tap gesture function.

node2animate.removeAllActions()

最后一部分掉到地板上,node2animate 可能是一个physicsBody,在点击之前是gravity 属性

The last part dropping to the floor, the node2animate might be a physicsBody and before the tap the gravity attribute

node2animate.physicsBody?.isAffectedByGravity = false

点击后将其设置为 true

after the tap you set it to true

node2animate.physicsBody?.isAffectedByGravity = true

还有其他的事情发生了,也设置了与地板的碰撞等.

There is other stuff going on as well, collision with the floor have also been set etc.

这篇关于在 ARKit 中为 3D 模型添加动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆