visionOS: importing USDZ file

Hi friends, my desired outcome is to import a USDZ file to visionOS simulator on XCode and to see how it looks via the visionOS Simulator.

I've imported a USDZ file and I can see it in the Swift IDE, but when I click on ContentView all I see is the default Apple living room. I have taken the following steps:

-the file is included in the "Copy Bundle Resources" phase of my target -Selected my project in the navigator. -Selected my app's target. -went to the "Build Phases" tab. -Expanded the "Copy Bundle Resources" section and the USDZ file is there

if I click on the actual file I can see the full USDZ model floating on the 'grid'. It's currently under Assets > ContentView > filename.usdz

Any suggestions/help are greatly appreciated.

Post not yet marked as solved Up vote post of bubbleguts Down vote post of bubbleguts
1k views

Replies

Model3D("filename")

Hi @HunterHarris that's what I have

import SwiftUI import RealityKit

struct ContentView: View { var body: some View { VStack { Model3D(named: "filename") { model in model } placeholder: { ProgressView() } .frame(height: 500) // Adjust this frame as needed .padding(.bottom, 50)

        Text("Hello, world!")
    }
    .padding()
}

}

struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }

Hi @bubbleguts Although it is in Japanese, please refer to the blog article. https://1planet.co.jp/tech-blog/applevisionpro-model3d-first-step

  • Thank you @sadaotokuyama this worked for me!! 私も日本語ok👌🏻

    Apple totally should have this in their basic tutorial somewhere, the usual drill for media is to drag into Assets section..

Add a Comment

Thank you @sadaotokuyama tokuyama-san. I will give this a try. Hey I was raised in Japan by the way. またね!

@sadaotokuyama I tried your code but all I'm getting is a spinning wheel against an opaque background in the midst of the "Content View" window.

import RealityKit

struct ContentView: View {
    var body: some View {
            Model3D(named: "room") { model in
                model
                    .resizable()
                    .aspectRatio(contentMode:.fit)
                    .frame(width: 380)
            } placeholder: {
                ProgressView()
            }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}
  • I think my file may be too big? It's 20mb but the only way to make it smaller is to reduce the quality of the textures. Suggestions are welcome.

Add a Comment