swift - SCNVector4 : Rotate on x-axis

标签 swift augmented-reality arkit cabasicanimation

我有一个球体并设法旋转它。但不幸的是沿着错误的轴线。

我的目标是像地球一样沿 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/

相关文章:

字符串到 NSDate 的转换适用于英语,但不适用于俄语

ios - 如何停止设备方向改变

swift - 将 SCNNodes 排列成圆形

java - ARCore – 渲染距离相机 200 米的物体

iphone - 适用于 iOS 的增强现实和快速前置摄像头应用程序

swift - 在 Swift 中使自定义类型数组可转换

ios - 如何在 UIStackView Swift 4 中查找所选项目的索引

java - 如何在arCore平面中设置3d模型而无需点击

ios - 如何防止物体在场景包中转换阴影?