我想知道如何在快速UI中添加3D形状(例如Sphere)>
我曾尝试添加一个场景并在迅速的用户界面中使用它,但收到错误消息
//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 UI中添加3D形状(例如Sphere),我曾尝试添加scnscene并在swift UI中使用它,但我收到一条错误消息// SceneKit类myscene:SCNScene {覆盖init(。 。
这是最简单的代码,用于演示如何使用球体设置SceneKit场景。希望对您有所帮助。