I have a SCN Node that I have Transformed to a desired Rotation and Angle.
I now want to rotate it infinitely on its new x-axis, but I can't seem to get it to rotate 360 degrees, it just shifts slightly.
let spin = CABasicAnimation(keyPath: "rotation")
spin.fromValue = NSValue(SCNVector4: SCNVector4(x: item.rotation.x, y: item.rotation.y, z: item.rotation.z, w: item.rotation.w))
spin.toValue = NSValue(SCNVector4: SCNVector4(x: Float(2*M_PI), y: item.rotation.y, z: item.rotation.z, w: item.rotation.w))
spin.duration = 3
spin.repeatCount = .infinity
item.addAnimation(spin, forKey: "spin around")
Note I found the rotation code from an earlier question, and it works as expected, but not if I want to rotate on the transformed node.
EDIT: The Transform Code:
self.item.transform = SCNMatrix4Mult(SCNMatrix4Mult(SCNMatrix4MakeScale(1.1, 1.1, 1.1), SCNMatrix4MakeRotation(2.2, 228.0, 120.0, 55.2)), SCNMatrix4MakeTranslation(-2.5, 12, 6))
self.item.pivot = SCNMatrix4MakeTranslation(0, 0, 4)
self.item.transform = SCNMatrix4Mult(SCNMatrix4MakeTranslation(0, 0, 4), item.transform)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…