我想打开一个 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 …