相关疑难解决方法(0)

SwiftUI – 将数据从 SwiftUIView 传递到 SceneKit

目标:使用 Scenekit 控制 SwiftUI 视图的 SwiftUI 切换按钮(UIViewRepresentable)

// 显示统计信息,例如 fps 和计时信息

我做了什么:这是 UIViewRepresentable ScenekitView

import SwiftUI
import SceneKit

struct ScenekitView : UIViewRepresentable {
    let scene = SCNScene(named: "art.scnassets/ship.scn")!

    func makeUIView(context: Context) -> SCNView {
        // create and add a camera to the scene
        let cameraNode = SCNNode()
        cameraNode.camera = SCNCamera()
        scene.rootNode.addChildNode(cameraNode)

        // place the camera
        cameraNode.position = SCNVector3(x: 0, y: 0, z: 15)

        // create and add a light to the scene
        let lightNode = SCNNode()
        lightNode.light = SCNLight()
        lightNode.light!.type …
Run Code Online (Sandbox Code Playgroud)

xcode scenekit swift arkit swiftui

1
推荐指数
1
解决办法
2546
查看次数

标签 统计

arkit ×1

scenekit ×1

swift ×1

swiftui ×1

xcode ×1