How to set the position, scale or rotation of a model in RealityKit

Oscar de la Hera Gomez
Three flowers that represent SwiftUI, RealityKit and XCode side by side. Beneath them sits the text "Position, Scale & Rotation".

To set the position, scale or rotation add a model within a window, volume or space, use a RealityView, load the model and set the relevant parameters.

The code for the demonstration detailed on this post can be found at the tutorials/immersive-spaces/position-scale-and-rotation-with-animation branch within the repository below.

A screenshot of XCode showing how to programmatically add content to an RealityView.

Specifically, the code that adds content to a window, volume or space is found within the body, where it loads an entity (i.e. scene), sets the position, scale and rotation and then adds it the element using content.add(scene).

This content parameter is gathered from the RealityView's closure (i.e. { content in ... }).

A screenshot of the simulator showing the model in space.

If you run similar code in the simulator, you will see a result similar to the one above.

Looking to learn more about SwiftUI, Swift, RealityKit, Design and Technology?

Search our blog to learn more about Swift, SwiftUI, RealityKit, design and technology.

Any Questions?

We are actively looking for feedback on how to improve this resource. Please send us a note to inquiries@delasign.com with any thoughts or feedback you may have.
delasign logo

Book a Free Consultation.

An icon of an email.

Click here to email us.

Fill in the details below to book a free consultation or to let us know about something else. Whatever it is, we are here to help.

How can we help you ?

Contact Details