相关疑难解决方法(0)

如何让SceneView的背景透明?

我想打开一个 3D 模型并使其背景透明,以便我可以看到 SceneView 后面的 UI。我试过这段代码,但 sceneView 变成白色,不透明。


struct ModelView: View {
    var body: some View {
        ZStack {
            Text("Behind Text Behind Text Behind Text")
            SceneView(
                scene: { () -> SCNScene in
                    let scene = SCNScene()
                    scene.background.contents = UIColor.clear
                    return scene
                }(),
                pointOfView: { () -> SCNNode in
                    let cameraNode = SCNNode()
                    cameraNode.camera = SCNCamera()
                    cameraNode.position = SCNVector3(x: 0, y: 0, z: 10)
                    return cameraNode
                }(),
                options: [
                    .allowsCameraControl,
                    .temporalAntialiasingEnabled,
                ]
            )
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我使用 XCode 12.5 和 iPhone …

scenekit swiftui

9
推荐指数
2
解决办法
2492
查看次数

标签 统计

scenekit ×1

swiftui ×1