我正在尝试显示一个指向z轴的金字塔,然后绕z旋转.由于我的相机在z轴上,我期待从上面看到金字塔.我设法旋转金字塔以这种方式看到它,但是当我添加动画时,它似乎在多个轴上旋转.
这是我的代码:
// The following create the pyramid and place it how I want
let pyramid = SCNPyramid(width: 1.0, height: 1.0, length: 1.0)
let pyramidNode = SCNNode(geometry: pyramid)
pyramidNode.position = SCNVector3(x: 0, y: 0, z: 0)
pyramidNode.rotation = SCNVector4(x: 1, y: 0, z: 0, w: Float(M_PI / 2))
scene.rootNode.addChildNode(pyramidNode)
// But the animation seems to rotate aroun 2 axis and not just z
var spin = CABasicAnimation(keyPath: "rotation")
spin.byValue = NSValue(SCNVector4: SCNVector4(x: 0, y: 0, z: 1, w: 2*Float(M_PI)))
spin.duration …Run Code Online (Sandbox Code Playgroud)