Build a Rubik Cube Using SceneView and SwiftUI | by Mark Lucking | Mar, 2022

Remedy the dice inside your apps

func addBox(xAxis: Float, yAxis: Float, zAxis: Float) 
let cubeNode = SCNNode(geometry: cubeGeometry)
cubeNode.place = SCNVector3(xAxis, yAxis, zAxis)
scene?.rootNode.addChildNode(cubeNode)
func changeCamera() 
let dx = cameraOrbit.eulerAngles.x
let dy = cameraOrbit.eulerAngles.y
let scrollWidthRatio = Float(settings.translation.width / screenWidth) / 16
let scrollHeightRatio = Float(settings.translation.peak / screenHeight) / 16
cameraOrbit.eulerAngles.y = Float(-2 * Float.pi) * scrollWidthRatio + dy
cameraOrbit.eulerAngles.x = Float(-Float.pi) * scrollHeightRatio + dx

More Posts