Why am I unable to render .dae file in Playground?

This is my code in ContentView:

import SwiftUI
import SceneKit
import PlaygroundSupport

struct ContentView: View {
    var body: some View {
        VStack {
            Text("SceneKit with SwiftUI")
                .font(.headline)
                .padding()

            SceneView(
                scene: loadScene(),
                options: [.autoenablesDefaultLighting, .allowsCameraControl]
            )
            .frame(width: 400, height: 400)
            .border(Color.gray, width: 1)
        }
    }
}

func loadScene() -> SCNScene? {
    if let fileURL = Bundle.main.url(forResource: "a", withExtension: "dae") {
        do {
            let scene = try SCNScene(url: fileURL, options: [
                SCNSceneSource.LoadingOption.checkConsistency: true
            ])
            print("Scene loaded successfully.")
            return scene
        } catch {
            print("Error loading scene: \(error.localizedDescription)")
        }
    } else {
        print("Error: Unable to locate a.dae in Resources.")
    }
    return nil
}

a.dae file exists in the Resources section of macOS Playground app. And a.dae can be viewed in Xcode.

Console shows: Error loading scene: The operation couldn’t be completed. (Foundation._GenericObjCError error 0.)

Any input is appreciated.

Answered by PrabhasKumar in 818649022

Same code works when ran as normal App template. This makes be believe that this is problem of Playground not my code.

Therefore I went forward to test if SceneKit was the culprit. To test I just wrote code of simple sphere and it did render that. So SceneKit is supported in Playground and problem lies in rendering of .dae file.

Upon conversation with o1 for like 1 hour (1 conversion away from limit) — it recommended to test if problem lies for .scn files as being Apple extension may perform better or have been tested. And to my surprise IT DID!

So after converting my .dae files to .scn file — now my app works.

tldr;

At the time of writing, Playground can’t render .dae file using SceneKit. The workaround I’m using (which might be better in terms of storage efficiency) is converting them to .scn (SceneKit Scene file); which Playground was able to render.

Regards Prabhas

Accepted Answer

Same code works when ran as normal App template. This makes be believe that this is problem of Playground not my code.

Therefore I went forward to test if SceneKit was the culprit. To test I just wrote code of simple sphere and it did render that. So SceneKit is supported in Playground and problem lies in rendering of .dae file.

Upon conversation with o1 for like 1 hour (1 conversion away from limit) — it recommended to test if problem lies for .scn files as being Apple extension may perform better or have been tested. And to my surprise IT DID!

So after converting my .dae files to .scn file — now my app works.

tldr;

At the time of writing, Playground can’t render .dae file using SceneKit. The workaround I’m using (which might be better in terms of storage efficiency) is converting them to .scn (SceneKit Scene file); which Playground was able to render.

Regards Prabhas

Why am I unable to render .dae file in Playground?
 
 
Q