I want to rotate the geometry of iOS-SceneKit.

Asked 2 years ago, Updated 2 years ago, 33 views

If you look at the geometry of the Cylinder like the one in the image (tilt 22 degrees in the x-axis direction), I would like to rotate around the axis of the green line, but I don't know how to do it.
I would appreciate it if you could let me know.

Enter a description of the image here

swift ios

2022-09-30 19:18

1 Answers

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)))


2022-09-30 19:18

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.