它非常简单,您只需添加并运行一个动作来旋转这样的虚拟对象
let rotateOne = SCNAction.rotateBy(x: 0, y: CGFloat(Float.pi), z: 0, duration: 5.0)
// let hoverUp = SCNAction.moveBy(x: 0, y: 0.2, z: 0, duration: 2.5) // to hover up with rotation
// let hoverDown = SCNAction.moveBy(x: 0, y: -0.2, z: 0, duration: 2.5) // to hover down with rotation
// let hoverSequence = SCNAction.sequence([hoverUp, hoverDown]) // to do this in sequence first it will hover up and then hover down
// let rotateAndHover = SCNAction.group([rotateOne, hoverSequence]) // rotation with hovering
// let repeatForever = SCNAction.repeatForever(rotateAndHover) // to rotate the object continuously with hovering
let repeatForever = SCNAction.repeatForever(rotateOne) // to rotate the object continuously without hovering
node.runAction(repeatForever) // here node is your virtual object