在ARKit中向3D模型添加动画 [英] Adding animation to 3D models in ARKit
问题描述
在此视频中,为对象提供了一个动画,使其在放置时悬停在房间周围,然后在被轻击时将其与另一个动画放在一起. 如何在我的项目中添加这种动画? 是添加已动画对象的唯一方法吗?
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?
谢谢
推荐答案
我认为上下浮动很可能是动画序列.以下用于悬停效果的动画序列将在第一个下拉选择功能内起作用.
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可能是PhysicalBody,并且在轻击重力属性之前
The last part dropping to the floor, the node2animate might be a physicsBody and before the tap the gravity attribute
node2animate.physicsBody?.isAffectedByGravity = false
点击后将其设置为真
node2animate.physicsBody?.isAffectedByGravity = true
还有其他事情正在进行,还设置了与地板的碰撞等.
There is other stuff going on as well, collision with the floor have also been set etc.
这篇关于在ARKit中向3D模型添加动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!