My contribution to society is an app that puts the user in a permanent rain of confetti 🎉 😄
Anyone want a confetti cannon for their Apple Vision Pro? 😄 🎉

Can we show a classic SwiftUI window in an immersive space? 🤔

I’d like to show a window that hosts a few controls to customize the cannon.

What I'd really like is to show a classic SwiftUI window and ensure that it cannot be closed because I can't find a good way to let users restore the window once it's closed 🤔
@simonbs If you don’t want it to be closed then maybe it shouldn’t be a window but just a view. Like attaching a control panel with buttons to the cannon.
@nighthawk That’s what I’ve ended up doing but then I don’t get the default controls for moving and resizing a window. I hoped there was a way to get those for RealityView attachments, alas.
@simonbs I went down a similar route with the control panel in my immersive space. Experimented with a window but in actual use I preferred the simple fixed position and have that slightly out of the way, rather than having to manage the window which always spawned in your face and you had to move it out of the way. Would indeed be nice to customise where windows are located when they spawn.
@cdoncarroll Excellent! Will need to figure out how to do that then 😄
@simonbs I’m pretty sure that you can just use the open window action from the SwiftUI environment to open any window you’ve defined in your app.

If there is anyone experienced with RealityKit out there who has ideas for how I can make this look more realistic, then I’m all ears 😃

I have a feeling that there are some features in the framework that I’m not taking proper advantage of.

@simonbs while the confetti is packed together it has more mass and flies faster and farther. Moving through the air, it will start to expand and shed outer layers, losing momentum.

the confetti needs to come out at a higher velocity as a “ball” and then when it hits the “wall” of air and begins to expand, it needs to slow way down and start to drop

@simonbs right now it looks like liquid bubbling out of a sporadically pressurized faucet

No idea how to do that with reality kit though 😬

If this is a particle emitter, I’d probably animate the emitter source launching from the cannon, and then have a ramp on the particle density and amount of gravity that gradually takes hold the farther out it goes

@cameronmcefee I hear what you’re saying. I’m not sure a particle emitter can produce this effect. I think I’d have to get fancy with multiple particle emitters to create each phase of the effect.
@simonbs understood, I’ve never looked at RealityKit so I’m just back-seat animating, sorry
@simonbs Love it! Materials are your friend, have a play with PhysicallyBasedMaterial as that brings reflections and lighting to the mix in an “easy” way
@stuart Good idea! I had postponed this because I couldn't find a way to get it working with the 3D software I use but now I found a way to modify the materials of my ModelEntity on runtime 😄
Added a tiny settings view that let users to choose between being surrounded by confetti or FIRING THE CONFETTI CANNON! 🎉 😄
I have got spatial audio working for the cannon. Please note that audio from the simulator is not included in recordings, so you will just have to take my word for it when I say that it works 😄
My confetti app now has an app icon 😃
@simonbs which tech did you use to make it work? Standard audio node properties or reality kit’s?
@zino Yes, I just configured the spatialAudio property on my emitter entity and call entity.playAudio(...). Should I have done it differently? 😄

@simonbs no no just curious as usual 😊

Simpler is often better

@simonbs Does the confetti interact with the ‘room’ you’re in? like, bounce off / pile up out a counter?
@simonbs If you are using a RealityView here, you can create attachments which return a SwiftUI view - is that what you were after?
@andyq I am using a RealityView. I haven’t looked into attachments but maybe that’s the way to go about it. However, I was planning to have a window that’s moved independently of the 3D model. Not sure if that’s possible with attachments.
@simonbs somthing like:
RealityView { content, attachments in

} update: { content, attachments in
if let att = attachments.entity(for: "window”) {
att.position = [0, 0.1, 0]
content.entities[0].addChild(att, preservingWorldTransform: true)
}
} attachments: {
Attachment(id: "window”) {
VStack {

}
}
@andyq Tried this but it doesn't behave like a standard window on visionOS, which is what I'm going for.
@simonbs Ahhhhhhh!
@andyq Turns out standard windows don’t behave like I want them to when presenting along an immersive space. I think I’ll go for an attachment like you suggested. It seems there are no approach that gives me exactly what I want but an attachment seems to come closest.
@simonbs very nice! Did you make the cannon with Reality Composer?
@hyperbolic Nah, I based it on a model that I found online and edited in spline.design 😊
@simonbs Ah nice! I’ll have a look into that. Thanks 🙏
@simonbs Thanks, now I have something stuck in my eye.