Wwdc20-10041 mentions that SceneKit can be now be imported into SwiftUI.
Before, the way to do that was using UIViewRepresentable, so we can display a scene of ship for ex.
What would be the new way to show the ship on a SwiftUI view?
Before, the way to do that was using UIViewRepresentable, so we can display a scene of ship for ex.
What would be the new way to show the ship on a SwiftUI view?
Howdy!
You can now import both SwiftUI and SceneKit and pass along your scenes, nodes, to a SceneView that can be configured to render your scene inside your hierarchy.
Example:
You can now import both SwiftUI and SceneKit and pass along your scenes, nodes, to a SceneView that can be configured to render your scene inside your hierarchy.
Example:
Code Block import SwiftUI import SceneKit struct ContentView: View { var scene = SCNScene(named: "MyScene") var cameraNode: SCNNode? { scene?.rootNode.childNode(withName: "camera", recursively: false) } var body: some View { SceneView( scene: scene, pointOfView: cameraNode, options: [] ) } }