Discuss spatial computing on Apple platforms and how to design and build an entirely new universe of apps and games for Apple Vision Pro.

All subtopics

Post

Replies

Boosts

Views

Activity

Can’t Figure Out How to Get My Earth Entity to Rotate on its Axis
I can‘t Figure Out How to Get My Earth Entity to Rotate on its Axis. This is a follow up post from a previous Apple Developer forum post. How would I have the earth (parent) entity rotate CCW underneath the orbiting starship child? I tried adding the following code block to the RealityView but it is not working: if let rotatingEarth = starshipEntity.findEntity(named: "Earth") { rotatingEarth.transform.rotation = simd_quatf.init(angle: 360, axis: SIMD3(x: 0, y: 1, z: 0)) if let animation = try? AnimationResource.generate(with: rotatingEarth as! AnimationDefinition) { rotatingEarth.playAnimation(animation) } } Any advice on getting the earth to rotate? I tried reviewing the Hello World WWDC23 project code, but I was unable to understand the complexity and how that sample project got the earth to rotate. i want to do this for visionOS 1.2. I realize there are some new animation and possible other capabilities coming up in vision 2.0 but I want to try to address this issue in the current released visionOS version.
3
0
170
6d
RealityKit Subdivide
In the Discover RealityKit APIs for iOS, macOS, and visionOS presentation, there was a slide at the end highlighting new features not covered in the video. One of them was surface subdivision, but I have not been able to find any documentation or APIs that support this feature. Does anyone have any further details or how this works in RealityKit?
3
1
178
1w
Understanding the Topology of LowLevelMesh in RealityKitDrawingApp Sample Code
I have recently developed an interest in the shader effects commonly found in Apple's UI and have been studying them. Additionally, as I own a Vision Pro, I have a strong desire to understand LowLevelMesh and am currently analyzing the sample code after watching the related session. The part where I am completely stuck and unable to understand is the initializer section of CurveExtruder. /// Initializes the `CurveExtruder` with the shape to sweep along the curve. /// /// - Parameters: /// - shape: The 2D shape to sweep along the curve. init(shape: [SIMD2<Float>]) { self.shape = shape // Compute topology // // Triangle fan lists each vertex in `shape` once for each ring, except for vertex `0` of `shape` which // is listed twice. Plus one extra index for the end-index (0xFFFFFFFF). let indexCountPerFan = 2 * (shape.count + 1) + 1 var topology: [UInt32] = [] topology.reserveCapacity(indexCountPerFan) // Build triangle fan. for vertexIndex in shape.indices.reversed() { topology.append(UInt32(vertexIndex)) topology.append(UInt32(shape.count + vertexIndex)) } // Wrap around to the first vertex. topology.append(UInt32(shape.count - 1)) topology.append(UInt32(2 * shape.count - 1)) // Add end-index. topology.append(UInt32.max) assert(topology.count == indexCountPerFan) I have tried to understand why the capacity reserved for the topology array is 2 * (shape.count + 1) + 1, but I am struggling to figure it out. I do not understand the principle behind the order in which vertexIndex is added to the topology. The confusion is even greater because, while the comment mentions trianglefan, the actual creation of the LowLevelMesh.Part object uses the topology: .triangleStrip argument. (Did I misunderstand? I know that the topology option includes triangle, but this uses duplicated vertices.) I am feeling very stuck. It's hard to find answers even through search options or LLMs. Maybe this requires specialized knowledge in computer graphics, which makes me feel embarrassed to ask. However, personally, I have tried various directions without external help but still cannot find a clear path, so I am desperately seeking assistance! P.S. As Korean is my primary language, I apologize in advance if there are any awkward or rude expressions.
0
0
107
1d
Content inside volume gets clipped
I am using the Xcode visionOS debugging tool to visualize the bounds of all the containers, but it shows my Entity is inside the Volume. Then why does it get clipped? Is there something wrong with the debugger, or am I missing something? import SwiftUI @main struct RealityViewAttachmentApp: App { var body: some Scene { WindowGroup { ContentView() } .windowStyle(.volumetric) .defaultSize(Size3D(width: 1, height: 1, depth: 1), in: .meters) } } import SwiftUI import RealityKit import RealityKitContent struct ContentView: View { var body: some View { RealityView { content, attachments in if let earth = try? await Entity(named: "Scene", in: realityKitContentBundle) { content.add(earth) if let earthAttachment = attachments.entity(for: "earth_label") { earthAttachment.position = [0, -0.15, 0] earth.addChild(earthAttachment) } if let textAttachment = attachments.entity(for: "text_label") { textAttachment.position = [-0.5, 0, 0] earth.addChild(textAttachment) } } } attachments: { Attachment(id: "earth_label") { Text("Earth") } Attachment(id: "text_label") { VStack { Text("This is just an example") .font(.title) .padding(.bottom, 20) Text("This is just some random content") .font(.caption) } .frame(minWidth: 100, maxWidth: 300, minHeight: 100, maxHeight: 300) .glassBackgroundEffect() } } } }
0
0
47
2d
PreviewApplication open Spatial Video issue
Hi, I have a Spatial Video that I am trying to load in a visionOS app with PreviewApplication API let url = URL(string: "https://mauiman.azureedge.net/videos/SpatialJourney/watermelon_cat.MOV") let item = PreviewItem(url: url!) _ = PreviewApplication.open(items: [item]) When I run the application, I am getting the following error. Did I miss anything? QLUbiquitousItemFetcher: <QLUbiquitousItemFetcher: 0x6000022edfe0> could not create sandbox wrapper. Error: Error Domain=NSPOSIXErrorDomain Code=2 "couldn't issue sandbox extension com.apple.quicklook.readonly for '/videos/SpatialJourney/watermelon_cat.MOV': No such file or directory" UserInfo={NSDescription=couldn't issue sandbox extension com.apple.quicklook.readonly for '/videos/SpatialJourney/watermelon_cat.MOV': No such file or directory} #PreviewItem The screen shows up as: Putting the spatial video locally, I get the following error: let url = URL(fileURLWithPath: "watermelon_cat.MOV") let item = PreviewItem(url: url) _ = PreviewApplication.open(items: [item]) Error getting the size of file(watermelon_cat.MOV -- file:///) with error (Error Domain=NSCocoaErrorDomain Code=260 "The file “watermelon_cat.MOV” couldn’t be opened because there is no such file." UserInfo={NSURL=watermelon_cat.MOV -- file:///, NSFilePath=/watermelon_cat.MOV, NSUnderlyingError=0x600000ea1650 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}) #Generic Any help is greatly appreciated. Thank you in advance.
3
1
111
3d
How to control the position of windows and volumes in immersive space
My app has a window and a volume. I am trying to display the volume on the right side of the window. I know .defaultWindowPlacement can achieve that, but I want more control over the exact position of my volume in relation to my window. I need the volume to move as I move the window so that it always stays in the same position relative to the window. I think I need a way to track the positions of both the window and the volume. If this can be achieved without immersive space, it would be great. If not, how do I do that in immersive space? Current code: import SwiftUI @main struct tiktokForSpacialModelingApp: App { @State private var appModel: AppModel = AppModel() var body: some Scene { WindowGroup(id: appModel.launchWindowID) { LaunchWindow() .environment(appModel) } .windowResizability(.contentSize) WindowGroup(id: appModel.mainViewWindowID) { MainView() .frame(minWidth: 500, maxWidth: 600, minHeight: 1200, maxHeight: 1440) .environment(appModel) } .windowResizability(.contentSize) WindowGroup(id: appModel.postVolumeID) { let initialSize = Size3D(width: 900, height: 500, depth: 900) PostVolume() .frame(minWidth: initialSize.width, maxWidth: initialSize.width * 4, minHeight: initialSize.height, maxHeight: initialSize.height * 4) .frame(minDepth: initialSize.depth, maxDepth: initialSize.depth * 4) } .windowStyle(.volumetric) .windowResizability(.contentSize) .defaultWindowPlacement { content, context in // Get WindowProxy from context based on id if let mainViewWindow = context.windows.first(where: { $0.id == appModel.mainViewWindowID }) { return WindowPlacement(.trailing(mainViewWindow)) } else { return WindowPlacement() } } ImmersiveSpace(id: appModel.immersiveSpaceID) { ImmersiveView() .onAppear { appModel.immersiveSpaceState = .open } .onDisappear { appModel.immersiveSpaceState = .closed } } .immersionStyle(selection: .constant(.progressive), in: .progressive) } }
0
0
74
2d
Are PhysicsJoints supported?
I am trying to add joints via code in my visionOS app. My scenario requires me to combine models from Reality Composer Pro with entities and components from code to generate the dynamic result. I am using the latest visionOS beta and Xcode versions and there is no documentation about joints. I tried to add them via the available API but regardless of how I combine pins, joints and various component, my entities will not get restricted or stay fixated like they are when they are in a child/parent relationship. I am using RealityKit and RealityView in mixed mode. I also searched the whole internet for related information without finding anything. Any insights or pointers appreciated!
0
0
90
2d
visionOS console warning: Trying to convert coordinates between views that are in different UIWindows
Hello, I have an iOS app that is using SwiftUI but the gesture code is written using UIGestureRecognizer. When I run this app on visionOS using the "Designed for iPad" destination and try to use any of my gestures I see this warning in the console: Trying to convert coordinates between views that are in different UIWindows, which isn't supported. Use convertPoint:fromCoordinateSpace: instead. But I don't see any visible problems with the gestures. I see this warning printed out after the gesture takes place but before any of our gesture methods get kicked off. So now I am wondering if this is something we need to deal with or some internal work that needs to happen in UIKit. Does anyone have any thoughts on this?
0
0
115
2d
Not being able to set maximum window size for Views under different tabs
On TikTok on Vision Pro, the home page has different minimum and maximum window heights and widths compared to the search page. Now I am able to set minimum window size for different tab views but maximum size doesn't seem to work Code: // WindowSizeModel.swift import Foundation import SwiftUI enum TabType { case home case search case profile } @Observable class WindowSizeModel { var minWidth: CGFloat = 400 var maxWidth: CGFloat = 500 var minHeight: CGFloat = 400 var maxHeight: CGFloat = 500 func setWindowSize(for tab: TabType) { switch tab { case .home: configureWindowSize(minWidth: 400, maxWidth: 500, minHeight: 400, maxHeight: 500) case .search: configureWindowSize(minWidth: 300, maxWidth: 800, minHeight: 300, maxHeight: 800) case .profile: configureWindowSize(minWidth: 800, maxWidth: 1000, minHeight: 800, maxHeight: 1000) } } private func configureWindowSize(minWidth: CGFloat, maxWidth: CGFloat, minHeight: CGFloat, maxHeight: CGFloat) { self.minWidth = minWidth self.maxWidth = maxWidth self.minHeight = minHeight self.maxHeight = maxHeight } } // tiktokForSpacialModelingApp.swift import SwiftUI @main struct tiktokForSpacialModelingApp: App { @State private var windowSizeModel: WindowSizeModel = WindowSizeModel() var body: some Scene { WindowGroup { MainView() .frame( minWidth: windowSizeModel.minWidth, maxWidth: windowSizeModel.maxWidth, minHeight: windowSizeModel.minHeight, maxHeight: windowSizeModel.maxHeight) .environment(windowSizeModel) } .windowResizability(.contentSize) } } // MainView.swift import SwiftUI import RealityKit struct MainView: View { @State private var selectedTab: TabType = TabType.home @Environment(WindowSizeModel.self) var windowSizeModel; var body: some View { @Bindable var windowSizeModel = windowSizeModel TabView(selection: $selectedTab) { Tab("Home", systemImage: "play.house", value: TabType.home) { HomeView() } Tab("Search", systemImage: "magnifyingglass", value: TabType.search) { SearchView() } Tab("Profile", systemImage: "person.crop.circle", value: TabType.profile) { ProfileView() } } .onAppear { windowSizeModel.setWindowSize(for: TabType.home) } .onChange(of: selectedTab) { oldTab, newTab in if oldTab == newTab { return } else if newTab == TabType.home { windowSizeModel.setWindowSize(for: TabType.home) } else if newTab == TabType.search { windowSizeModel.setWindowSize(for: TabType.search) } else if newTab == TabType.profile { windowSizeModel.setWindowSize(for: TabType.profile) } } } }
1
0
72
5d
ARKit tracked images, best practices
I'm developing an augmented images app using ARKit. The images themselves are sourced online. The app is mostly done and working fine. However, I download the images the app will be tracking every time the app starts up. I'd like to avoid this by perhaps downloading the images and storing them to the device. My concern is that as the number of images grow, the app would download too many images to the device. I'd like some thoughts on how to best approach this. For example, should I download and store some of the images in CoreData, or perhaps not store them at all?
0
0
64
2d
What is the difference between an entity Action and Animation
What’s the difference between an action and an animation eg.: FromToByAnimation vs FromToByAction. The documentation on them is pretty similar and I'm not understanding the differences exactly... : S FromToByAnimation → https://developer.apple.com/documentation/realitykit/fromtobyanimation?changes=__2_2 FromToByAction → https://developer.apple.com/documentation/realitykit/fromtobyaction?changes=__2_2 As developer, when should we reach out to use an animation vs action ? 🤔
0
1
86
3d