【发布时间】:2020-03-25 16:19:02
【问题描述】:
我想知道如何在 swift UI 中添加 3D 形状(例如球体)
我尝试添加一个场景并在 swift UI 中使用它,但我收到一条错误消息
//SceneKit
class myscene: SCNScene{
override init(){
super.init()
}
required init?(coder: NSCoder) {
fatalError("init(coder: ) has not been implemented")
}
}
//Swift UI
struct ContentView: View {
var body: some View {
let sphere = SCNSphere(radius: 2.0)
sphere.firstMaterial?.diffuse.contents = UIColor.blue
let spherenode = SCNNode(geometry: sphere)
spherenode.position = SCNVector3(x: 0.0, y: 3.0, z: 0.0)
}
}
错误消息位于var body: some View { 行,内容如下:
Function declares an opaque return type, but has no return statements in its body from which to infer an underlying type
请帮我解决这个问题......
【问题讨论】:
标签: swift scenekit swiftui swift-playground swift5