0

I'm new to using Swift, I'm making an app, which shows 3d models ".usdz" using SceneView.
I am trying to change the texture of these either with a .jpg or .png image, it should be noted that I am using "ContentView" forms.

import SwiftUI
import SceneKit
import ARKit

struct Model3d: View {
    var body: some View {
        Home()
    }
}

struct Model3d_Previews: PreviewProvider {
    static var previews: some View {
        Model3d()
    }
}

struct Home : View {
    @State var models = [
        Model(id: 0, name: "model1", modelName: "model1.usdz", details: "12+12"),]

    @State var index = 0
    var body: some View {
    
        VStack {
            SceneView(scene: SCNScene(named: models[index].modelName), options: 
            [.autoenablesDefaultLighting,.allowsCameraControl])
            .frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height / 2)
            
            Spacer(minLength: 0)
        }
     }
  }

 struct Model : Identifiable {
     var id: Int
     var name: String
     var modelName: String
     var details : String
 }

enter image description here

stackich
  • 3,607
  • 3
  • 17
  • 41

0 Answers0