nitrio DGArt

DGArt Poly Plane to Playground

Using SceneKit in Swift Playground Demo 1 : iPadOS

Create your 3D model using DGArt and import it into the Playground App for your own app project. The example PolyPlane was modeled using DGArt and used in the Playground app. And the 3D scene contains a "Plane" node with a child node named "Propeller".

Make both the plane and propeller rotate.

Import the .scn file into the Playgrounds app using the following steps: Edit the ContentView code as shown below:

import SwiftUI
import SceneKit

struct ContentView: View {
    var scene: SCNScene? {
        let scene = SCNScene(named: "PolyPlane.scn")
        
        let plane = scene?.rootNode.childNode(withName: "Plane", recursively: true)
        plane?.runAction(SCNAction.repeatForever(SCNAction.rotateBy(x: 0, y: 0.5, z: 0, duration: 1)))
        
        let propeller = scene?.rootNode.childNode(withName: "Propeller", recursively: true)
        propeller?.runAction(SCNAction.repeatForever(SCNAction.rotateBy(x: 0, y: 0, z: 15, duration: 1)))
        
        return scene
    }
    
    var cameraNode: SCNNode? {
        let cameraNode = SCNNode()
        cameraNode.camera = SCNCamera()
        cameraNode.position = SCNVector3(x: 5, y: 5, z: 5)
        cameraNode.look(at: SCNVector3(x: 0, y: 0, z: 0))
        return cameraNode
    }
    var body: some View {
        SceneView(
            scene: scene,
            pointOfView: cameraNode,
            options: [
                .allowsCameraControl,
                .autoenablesDefaultLighting,
                .temporalAntialiasingEnabled
            ]
            
        )
        VStack {
            Text("Hello, Plane!")
        }
    }
}

Finally, you will be able to see the PolyPlane animation appear beside.

Alternatively, you can obtain the playground file here for exercise mentioned above. Download SceneKitPlane.swiftpm.zip