SceneKit Within SwiftUI. A very close cousin of the newer… | by Mark Lucking | Mar, 2022

A very close cousin of the newer RealityKit/ARKit frameworks

Mark Locking

SceneKit Background

Image Credit: Apple SceneKit Framework Reference

Models

struct GameScene : View {
var body: some View {
let scene = SceneView(scene: SCNScene(named: "BTL-S8_K-wing_assault_starfighter.usdz"), options: [.autoenablesDefaultLighting,.allowsCameraControl])
return scene
}
}
let oldTransform = planeNode.transform
let rotation = SCNMatrix4MakeRotation(GLKMathDegreesToRadians(degrees), 0, 1, 0)
SCNTransaction.begin()
SCNTransaction.animationDuration = 2
planeNode.transform = SCNMatrix4Mult(rotation, oldTransform)
SCNTransaction.commit()
planeNode.scale = SCNVector3Make(-1,1,1)

Leave a Comment