Use SCNAction.rotateBy(x:y:z:duration:) to rotate the SCNNode.
Perform the action by passing the SCNAction to runAction() in SCNNode.
// Get Scene
letscene=SCNScene(named: "art.scnassets/main.scn")!
// Obtaining a Cylinder Node
Let cylinder=scene.rootNode.childNode(withName: "cylinder", recurring:true)!
// rotate the cylinder forever on the y-axis
cylinder.runAction (SCNAction.repeatForever (SCNAction.rotateBy(x:0,y:2,z:0,duration:1)))
© 2024 OneMinuteCode. All rights reserved.