How to add particles to a window, volume or space in VisionOS

For particle emitters created in Reality Composer Pro to work as expected, you must programmatically add them to the content of a RealityView.

Oscar de la Hera Gomez
Written by Oscar de la Hera Gomez
First published on 08/26/2024 at 12:26
Last Updated on 08/26/2024 at 12:56
<p>Three flowers that represent SwiftUI, RealityKit and XCode side by side. Beneath them sits the text "Particle Emitters".</p>

For particle emitters created in Reality Composer Pro to work as expected, you must programmatically add them to the content of a RealityView.

Subscribe

The code for the demonstration detailed on this post can be found at the tutorials/reality-composer-pro/fire branch of our open source tutorial linked below.

View RepositoryHow to make a fire effect using particles and Reality Composer ProHow to create a new RealityKitContent package for a VisionOS project
<p>A screenshot of the VisionOS simulator showing how a flame is not being rendered correctly.</p>

The following demonstration attempts to solve the issue illustrated above, which arises if you use a Model3D to add a particle effect to a window or volume.

The issue becomes obvious when you move the window or volume and the particle doesn't behave as expected.

<p>A screenshot of XCode showing how we programatically added the fire to a RealityView.</p>

To solve this issue, you must programatically add the particle to the window or volume, using code similar to that above. 

This will also render it correctly within a space.

How to programatically add a model in RealityKit
<p>A screenshot of the VisionOS simulator showing how the particle renders correctly even after a window has been adjusted.</p>

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

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

Search our Blog

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.
SubscribeContact UsVisit our BlogView our ServicesView our Work

Partner with us

We would love to get to know you and see how we can help your organization with its goals and needs.
Let's Talk

Stay Informed

Get occasional updates about our company, research, and product launches.
Subscribe