我有一个球体并设法旋转它。但不幸的是沿着错误的轴线。
我的目标是像地球一样沿 x 轴旋转。你能帮我申请这个吗?
这是我现有的代码:
let spin = CABasicAnimation(keyPath: "rotation")
// Use from-to to explicitly make a full rotation around z
spin.fromValue = NSValue(scnVector4: SCNVector4(x: 1, y: 0, z: 0, w: 0))
spin.toValue = NSValue(scnVector4: SCNVector4(x: 1, y: 0, z: 0, w: Float(CGFloat(-2 * Double.pi))))
spin.duration = 30
spin.repeatCount = .infinity
sphereNode.addAnimation(spin, forKey: "spin around")
最佳答案
会是这样的
self.imageView.layer.transform = CATransform3DConcat(self.imageView.layer.transform, CATransform3DMakeRotation(M_PI,1.0,0.0,0.0));
关于swift - SCNVector4 : Rotate on x-axis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46069807/