如何在 SwiftUI 中清除 SceneView 3D 对象的背景

问题描述

有谁知道如何清除 SceneView 3D 对象的背景?我正在尝试使用 UIColor.clear,但它使它变成白色。 [

This should be clear,but it's 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()
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)