Post

Replies

Boosts

Views

Activity

Reply to Loading USDZ files with SwiftUI
Of course if you do want to go down the document based app route, it's possible but it has some weirdness about it (mostly due to limitations with the FileDocument API). Because of the bizarre ways the document based API works, I'd still suggest using the file picker approach, despite this taking care of the sandbox access for you. You're on the right lines with your code, but because the FileDocument API doesn't give you the URL, and there's no mechanism for loading a USDZ as an Entity from Data, you have to write the USDZ contents to a temporary directory that you can access from your app sandbox, and then load it using the standard mechanism. This is demonstrated here: https://vimeo.com/922479510. import RealityKit import SwiftUI import UniformTypeIdentifiers struct USDDocumentLoaderDocument: FileDocument { // The entity will hold the contents of the USDZ file. // var entity: Entity static var readableContentTypes: [UTType] { [.usdz] } init(configuration: ReadConfiguration) throws { // Load the contents of the USDZ file. // guard let data = configuration.file.regularFileContents else { throw CocoaError(.fileReadCorruptFile) } // Write the data to a temporary location. // let temporaryFile = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString, conformingTo: .usdz) try data.write(to: temporaryFile) // Load the USDZ from the temporary file. This blocks, which isn't ideal. // self.entity = try Entity.load(contentsOf: temporaryFile) } func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper { throw CocoaError(.featureUnsupported) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’24
Reply to glDrawPixels equalent for Metal API
What's your use case? Without more information it's difficult to say, but it sounds like you might want to use a MTLBlitCommandEncoder to copy the data from some buffer to the drawable texture. It should achieve a similar effect. But if it doesn't, please provide more information.
Topic: Graphics & Games SubTopic: General Tags:
Mar ’24
Reply to Cursor data on VisionOS
I'm afraid eye tracking information isn't currently available at all, regardless of the immersion level of your app. When creating an app in the mixed space, Apple handles eye tracking for you (but it's abstracted away), but when creating a fully immersive app you get nothing. So you'll need to come up with an alternative mechanism of input, for example using a game controller to manipulate an onscreen cursor. It's a shame, and is the biggest limitation of the system right now IMO.
Topic: Graphics & Games SubTopic: General Tags:
Mar ’24