Post

Replies

Boosts

Views

Activity

Reply to Importing obj + mtl files into one scene in iOS app
Hi @morphing, have you found an elegant way to do this? I can use a document picker to open the .obj file but MDLAsset(url:) cannot find the corresponding .mtl and .jpg files. These files are definitely there, with the right names and in the right locations. Maybe I am using AccessingSecurityScopedResource in the wrong way ? Thanks for any pointers
Nov ’22
Reply to swift mac swift app fails to show image view crashes on first run
Solved by removing the let scene = sceneFromFile() initializer. Instead I added a button to explicitly load the file after an initial layout was done. I don't know how to do it without the button since an .onAppear { scene = sceneFromFile() } or .task { scene = sceneFromFile() } respectively crash or don't do anything. Still feels like a bug. import SceneKit func sceneFromFile() -> SCNScene? {   var scene: SCNScene?   let panel = NSOpenPanel()   panel.allowsMultipleSelection = false   panel.canChooseDirectories = false   if panel.runModal() == .OK {     if let sceneURL = panel.url {         scene = try? SCNScene(url: sceneURL)     }   }   return scene } @main struct SceneFromFileCrashApp: App {   @State var scene: SCNScene?       var body: some Scene {     WindowGroup {       VStack {         Button("Open") {           scene = sceneFromFile()         }         SceneView(scene: scene)       }     }   } }
Oct ’22
Reply to swift mac swift app fails to show image view crashes on first run
This is a minimal app that crashes after selecting a .usdz file. Error: Thread 1: EXC_BREAKPOINT (code=1, subcode=0x1a7f15ba4) "Secure coding for state restoration requested after it was initialized without. NSApplicationDelegate was probably established too late." import SwiftUI import SceneKit func sceneFromFile() -> SCNScene? {   var scene: SCNScene?   let panel = NSOpenPanel()   panel.allowsMultipleSelection = false   panel.canChooseDirectories = false   if panel.runModal() == .OK {     if let sceneURL = panel.url {       scene = try? SCNScene(url: sceneURL)     }   }   return scene } @main struct SceneFromFileCrashApp: App {   let scene = sceneFromFile()   var body: some Scene {     WindowGroup {       SceneView(scene: scene)     }   } }
Oct ’22