Post

Replies

Boosts

Views

Activity

SwiftUI: Overlay an SKScene over an SCNScene
Setup: For displaying 3D elements Scenekit is used. For 2D elements Spritekit. SceneView() is used to display a scene. An SCNScene and an SCNNode for the camera are given. Goal: Now I want to put a 2D overlay over the SCNScene. Previously this could be achieved using the overlaySKScene property of the SCNView. But now that in SwiftUI only the scene and camera are given I wonder how this can be achieved. Thanks already in advance.
0
0
665
Apr ’21
The renderer function in SCNSceneRendererDelegate is only called by input, not automatically
It is unclear to me how the whole thing has to be implemented in SwiftUI. Currently: After an input (for example moving the camera) the renderer function is called correctly. Goal: The renderer function should also be called without needing input. Setup: struct ContentView: View {   @ObservedObject var gameData : GameViewModel       var body: some View {     SceneView(       scene: gameData.scene,       pointOfView: gameData.camera,       options: [         .allowsCameraControl       ],       delegate: gameData     )   } } class GameViewModel: NSObject, ObservableObject { ... } extension GameViewModel: SCNSceneRendererDelegate {   func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) { ... } }
1
0
822
Mar ’21