Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rotate a Virtual Object in ARKit with Swift 4

I am trying to make a VirtualObject, in Apple's new ARKit, rotate. I want the object to rotate infinitely until it is stopped. I have tried multiple things, such as:

angleDegrees = Int(((object.eulerAngles.y) * 180) / Float.pi) % 360
object.eulerAngles.y = initialObjectAngle + amoutnToSpinPerSpin

... but nothing seemed to work. I have the virtual object setup and with a press of a button, I would like the object to spin.
How can I achieve that?

like image 622
Noah H Avatar asked Nov 30 '25 06:11

Noah H


1 Answers

Remember that ARKit is not a rendering / display technology. The main thing ARKit does for you is set things up so that whatever graphics technology you choose — SceneKit, Unity, your own custom engine, etc — can easily render on top of the camera feed in a way that makes for good AR experiences. So any question about how to draw or animate AR content is really a question about whichever display technology you're using.

That looks like SceneKit in this case. Have you looked at the (admittedly rather sparse) documentation for SceneKit, which includes its several ways to do animation? There's also sample code attached to the SceneKit WWDC session from this year (and years past) that demonstrates... well, a whole lot of things, but there are continuous spinning animations in there.

like image 186
rickster Avatar answered Dec 02 '25 20:12

rickster