Does anyone knows how to clear the background of a SceneView 3D Object? I'm trying using UIColor.clear, but it makes it white. []
import SwiftUI
import SceneKit
struct TestView: View {
var body: some View {
ZStack{
Color.green
SceneView(
scene: {
let scene = SCNScene(named: "Earth.scn")!
scene.background.contents = UIColor.clear
return scene
}(),
options: [.autoenablesDefaultLighting,.allowsCameraControl]
)
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height/2, alignment: .center)
}
}
}
struct TestView_Previews: PreviewProvider {
static var previews: some View {
TestView()
}
}
Here's a solution that worked for me, mostly adopted from the answers here:
Then you can use it in your view as: