let box = SCNBox(width: 0.5, height: 0.5, length: 0.5, chamferRadius: 0)
box.firstMaterial?.diffuse.contents="art.scnassets/10.jpg";
let boxNode = SCNNode()
boxNode.geometry = box
boxNode.position = SCNVector3(0, 0, -2)
addAnimation(node: boxNode)
let scene = SCNScene()
scene.rootNode.addChildNode(boxNode)
sceneView.scene = scene
}
//旋轉 參考 https://medium.com/s23nyc-tech/arkit-scenekit-and-how-to-control-the-world-dc7377eb1dc6
func addAnimation(node: SCNNode) {
let rotateOne = SCNAction.rotateBy(x: 0, y: CGFloat(Float.pi), z: 0, duration: 5.0)
let repeatForever = SCNAction.repeatForever(rotateOne)
node.runAction(repeatForever)
}
沒有留言:
張貼留言