有谁知道如何清除 SceneView 3D 对象的背景?我正在尝试使用 UIColor.clear,但它使它变成白色。[ ]
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()
}
}