Does anyone knows how I could make the background of the USDZ files transparent or black in color? When building my Xcode project I can't seem to make the background black in color, even with changing the USDZ's background and lighting to the colour black. I have attached the code here below. Unfortunately I won't upload the USDZ files since I couldn't find a way to share it.
// ContentView.swift
// USDZviewer
//
// Created by Conqueriings on 31/10/21.
// CREDITS: Kavsoft
import SwiftUI
import SceneKit
struct ContentView: View {
var body: some View {
Home()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
Home()
}
}
struct Home : View {
@State var models = [
Model(id: 0, name: "Cookie", modelName: "cookie.usdz"),
Model(id: 0, name: "Micro:Bit (Front)", modelName: "mbfront.usdz"),
Model(id: 0, name: "Micro:Bit (Back)", modelName: "mb2.usdz"),
Model(id: 0, name: "RaspberryPi 4", modelName: "RPIv5.usdz")
]
@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)
ZStack{
HStack{
Button(action: {
withAnimation{
if index > 0{
index -= 1
}
}
}, label: {
Image(systemName: "chevron.left")
.font(.system(size: 35, weight: .bold))
.opacity(index == 0 ? 0.3 : 1)
})
.disabled(index == 0 ? true : false)
Spacer(minLength: 0)
Button(action: {
withAnimation{
if index < models.count{
index += 1
}
}
}, label: {
Image(systemName: "chevron.right")
.font(.system(size: 35, weight: .bold))
// disabling button when no other data ....
.opacity(index == models.count - 1 ? 0.3 : 1)
})
.disabled(index == models.count - 1 ? true : false)
}
Text(models[index].name)
.font(.system(size: 25, weight: .bold))
}
.foregroundColor(.white)
.padding(.horizontal)
.padding(.vertical,30)
}
}
}
// Data Model...
struct Model : Identifiable {
var id : Int
var name : String
var modelName : String
}