Post

Replies

Boosts

Views

Activity

Reply to [Newbie] Why does my ShaderGraphMaterial appear distorted?
So, it turns out that models have internal properties that dictate how image based materials apply to them. You set these properties by "UV-unwrapping" the model, and what surface area of the texture maps to what surface areas on the model. For one reason or another I thought these UV properties were part of the material itself, but that would mean you couldn't use a material on multiple models, and that would be silly. I fixed up the UV Mapping of my model with Blender's "Project from View (bounds)" tool, and it now looks the way I expect.
Topic: Graphics & Games SubTopic: RealityKit Tags:
Aug ’23
Reply to visionOS - Positioning and sizing windows
You can do this by diving down into UIKit, but it requires some clever SwiftUI work if your app is SwiftUI based. (Most new VisionOS apps will be). If anyone picks up some mistakes in my SwiftUI explanations, or has some code improvements please call them out in the comments. The View struct ContentView: View { @EnvironmentObject var windowSceneBox: WindowSceneBox var body: some View { ZStack { Text("hello") } .glassBackgroundEffect() .onChange(of: windowSceneBox.windowScene) { old, new in new?.sizeRestrictions?.maximumSize = CGSize(width: 500, height: 500) } } } As you can see, when the scene of the view is set, the onChange fires and it immediately sets the size of the windowScene via the sizeRestrictions property. The VisionOS window-launch screen will appear large, and then animate smaller after the view loads. This image shows the window-resize chrome at the appropriate location for a 500x500 window (because it is!) What the heck is a WindowSceneBox? I like using SwiftUI environment variables for things like this, but because the view is added to a scene After it initialized I needed an optional property. I chose to wrap it in a "box" type, though there are other ways to achieve an optional Environment variable if you wanted to explore them. This is just an observable object with an optional scene property. It's what that .onChange is listening to. class WindowSceneBox: ObservableObject { @Published var windowScene: UIWindowScene? init(windowScene: UIWindowScene?) { self.windowScene = windowScene } } Where is the environmentObject set? In the window group: WindowGroup { WindowSceneReader { scene in ContentView() .environmentObject(WindowSceneBox(windowScene: scene)) } } Similar to a GeometryReader, I made a View that will watch for the UIScene that a view is assigned to. I named it WindowSceneReader, and similar to GeometryReader, you provide it with a view to display. Looks Great. Now what the heck is a WindowSceneReader? struct WindowSceneReader<Content>: View where Content: View { @State var windowScene: UIWindowScene? let contents: (UIWindowScene?) -> Content var body: some View { contents(windowScene) .background { WindowAccessor(windowScene: $windowScene) .accessibilityHidden(true) } } } The sceneReader is initialized with generic Content returning closure with a UIWindowScene parameter. The reader maintains the UIWindowScene as its state, so when it changes, it will re-render its body, and therefore invoke the Content closure again. What sets the windowScene property? How do we tie into UIKit? In the WindowSceneReader the Content is wrapped in a .background modifier. Within that background is a WindowAccessor that we pass our windowScene State too as a Binding. This view is: struct WindowAccessor: UIViewRepresentable { @Binding var windowScene: UIWindowScene? func makeUIView(context: Context) -> UIView { let view = UIView() DispatchQueue.main.async() { self.windowScene = view.window?.windowScene // << right after inserted in window } return view } func updateUIView(_ view: UIView, context: Context) { } } WindowAccessor is a represented UIView whose responsibility is to grab the windowScene after it's been installed in the hierarchy. The Chain of Events: The WindowAccessor is an empty UIView that sets the view's windowScene into the Binding. We make it an invisible background of a view. This binding is a @State of the WindowSceneReader and detects the scene being set. This causes it's content to be recreated, and provides the window scene when it does so. The Content of the WindowSceneReader is the rest of app window's view hierarchy The Content of the WindowSceneReader takes the windowScene provided by the reader and sets it into an EnvironmentObject so it's available throughout the entire window's view hierarchy via @EnvironmentObject Our window's ContentView see's that the windowScene is available and sets the sizeRestrictions, causing the VisionOS window to animate smaller. Wow that's a lot. What about UIKit? Just grab a UIView's .window?.windowScene property and configure the sizeRestrictions on it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’23
Reply to Model3D content clips through Modal
Lol yeah. I have this problem too. I hope an Apple Dev files a feedback for it so it gets fixed.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to About GestureState<ManipulationState>
The VisionOS sample code projects are not linked at the bottom of relevant WWDC videos. I think this is the one that involves interacting with a satellite? https://developer.apple.com/documentation/visionos/world/
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to Scene understanding missing from visionOS simulator?
Also filed this. I've about run out of things I can develop and feel I need to begin coding interactions with planes and the persistence of world anchors. https://feedbackassistant.apple.com/feedback/12639395 Hope the simulator gets this and I don't have to wait several years to continue.
Topic: Spatial Computing SubTopic: ARKit Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to 'MultipeerConnectivityService' is unavailable in visionOS?
As of now, VisionOS does not appear to support synchronization of ARKit entities. There are ”SharePlay” WWDC23 videos for sharing Shared-Space and Immersive-Space experiences, so you may want to see if that can solve your use case.
Replies
Boosts
Views
Activity
Aug ’23
Reply to Vision Pro Developer Lab registration rejected, but why?
Given Apple’s routine lack of transparency for many things, I don’t think we’ll ever know their criteria. Maybe they just had more applicants for that day that looked “better”? Who knows. I’m hoping we get world tracking support in the simulator so I don’t need to worry about needing real hardware for a few years.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to [Newbie] Why does my ShaderGraphMaterial appear distorted?
So, it turns out that models have internal properties that dictate how image based materials apply to them. You set these properties by "UV-unwrapping" the model, and what surface area of the texture maps to what surface areas on the model. For one reason or another I thought these UV properties were part of the material itself, but that would mean you couldn't use a material on multiple models, and that would be silly. I fixed up the UV Mapping of my model with Blender's "Project from View (bounds)" tool, and it now looks the way I expect.
Topic: Graphics & Games SubTopic: RealityKit Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to [Newbie] Why does my ShaderGraphMaterial appear distorted?
I'm looking int this more in Reality Composer pro and I'm seeing these distortions in RCP with the model that's programmatically receiving the texture. I guess this could be a modeling issue now, as this texture applies fine to the sphere in reality composer pro.
Topic: Graphics & Games SubTopic: RealityKit Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to Shared space app with full environment access
Correct. Apps running in the shared space can display windows and volumes but not immersive scenes. Only when an app is ”immersive” can it get access to world tracking information required for a RealityKit character to navigate the space.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Aug ’23
Reply to How To Rotate A 3D Model - Vision OS
I would add this in a gesture modifier to the RealityView: https://developer.apple.com/documentation/swiftui/rotategesture3d
Topic: Spatial Computing SubTopic: ARKit Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to How can I change the visibility of ornament with animation?
What happens if you change the visibility in a “withAnimation” block?
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to Can you use widget in Vision Pro?
Widget extensions are not supported on VisionOS, but you can spawn windows and set their size.
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to Render material on the inside of a sphere.
Almost like you need to reverse the direction of the mesh triangles. I wonder if there’s a convenient way to do that…
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to VisionOS developers - what's your background?
2D iOS/iPadOS/MacOS software developer. I wish there was a sensible framework for creating and manipulating 3D content built on top of reality kit. Every summer I think we’ll get one and we don’t. It still feels like there’s a piece missing to me.
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to Workflow Suggestions from Blender to Reality Composer
Same question.
Topic: Spatial Computing SubTopic: ARKit Tags:
Replies
Boosts
Views
Activity
Jul ’23
Reply to visionOS - Positioning and sizing windows
You can do this by diving down into UIKit, but it requires some clever SwiftUI work if your app is SwiftUI based. (Most new VisionOS apps will be). If anyone picks up some mistakes in my SwiftUI explanations, or has some code improvements please call them out in the comments. The View struct ContentView: View { @EnvironmentObject var windowSceneBox: WindowSceneBox var body: some View { ZStack { Text("hello") } .glassBackgroundEffect() .onChange(of: windowSceneBox.windowScene) { old, new in new?.sizeRestrictions?.maximumSize = CGSize(width: 500, height: 500) } } } As you can see, when the scene of the view is set, the onChange fires and it immediately sets the size of the windowScene via the sizeRestrictions property. The VisionOS window-launch screen will appear large, and then animate smaller after the view loads. This image shows the window-resize chrome at the appropriate location for a 500x500 window (because it is!) What the heck is a WindowSceneBox? I like using SwiftUI environment variables for things like this, but because the view is added to a scene After it initialized I needed an optional property. I chose to wrap it in a "box" type, though there are other ways to achieve an optional Environment variable if you wanted to explore them. This is just an observable object with an optional scene property. It's what that .onChange is listening to. class WindowSceneBox: ObservableObject { @Published var windowScene: UIWindowScene? init(windowScene: UIWindowScene?) { self.windowScene = windowScene } } Where is the environmentObject set? In the window group: WindowGroup { WindowSceneReader { scene in ContentView() .environmentObject(WindowSceneBox(windowScene: scene)) } } Similar to a GeometryReader, I made a View that will watch for the UIScene that a view is assigned to. I named it WindowSceneReader, and similar to GeometryReader, you provide it with a view to display. Looks Great. Now what the heck is a WindowSceneReader? struct WindowSceneReader<Content>: View where Content: View { @State var windowScene: UIWindowScene? let contents: (UIWindowScene?) -> Content var body: some View { contents(windowScene) .background { WindowAccessor(windowScene: $windowScene) .accessibilityHidden(true) } } } The sceneReader is initialized with generic Content returning closure with a UIWindowScene parameter. The reader maintains the UIWindowScene as its state, so when it changes, it will re-render its body, and therefore invoke the Content closure again. What sets the windowScene property? How do we tie into UIKit? In the WindowSceneReader the Content is wrapped in a .background modifier. Within that background is a WindowAccessor that we pass our windowScene State too as a Binding. This view is: struct WindowAccessor: UIViewRepresentable { @Binding var windowScene: UIWindowScene? func makeUIView(context: Context) -> UIView { let view = UIView() DispatchQueue.main.async() { self.windowScene = view.window?.windowScene // << right after inserted in window } return view } func updateUIView(_ view: UIView, context: Context) { } } WindowAccessor is a represented UIView whose responsibility is to grab the windowScene after it's been installed in the hierarchy. The Chain of Events: The WindowAccessor is an empty UIView that sets the view's windowScene into the Binding. We make it an invisible background of a view. This binding is a @State of the WindowSceneReader and detects the scene being set. This causes it's content to be recreated, and provides the window scene when it does so. The Content of the WindowSceneReader is the rest of app window's view hierarchy The Content of the WindowSceneReader takes the windowScene provided by the reader and sets it into an EnvironmentObject so it's available throughout the entire window's view hierarchy via @EnvironmentObject Our window's ContentView see's that the windowScene is available and sets the sizeRestrictions, causing the VisionOS window to animate smaller. Wow that's a lot. What about UIKit? Just grab a UIView's .window?.windowScene property and configure the sizeRestrictions on it.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’23