【问题标题】:Does SceneKit rotate(by:around:duration:) works?SceneKit rotate(by:around:duration:) 有效吗?
【发布时间】:2018-01-30 19:49:22
【问题描述】:

我想让所有的 SCNNodes 围绕一个轴旋转(SCNVector3Zero 在中心)。但是当我这样做时:

for node in nodes {
  node.runAction(SCNAction.rotate(by: 3.14, around: SCNVector3Zero, duration: 0.5))
}

什么都没有移动。更改为 SCNAction.move 而不是旋转可以正常工作。有什么想法吗?

我正在使用 ARKit 进行测试。

【问题讨论】:

    标签: swift scenekit arkit


    【解决方案1】:

    SCNVector3Zero 是零长度向量(0, 0, 0),它不是 指定方向或轴。

    例如,要绕 z 轴旋转,请使用

    SCNAction.rotate(by: .pi, around: SCNVector3(0, 0, 1), duration: 0.5)
    

    【讨论】:

    • 谢谢!我想我误解了绕轴的含义。有没有办法围绕一个节点位置旋转所有节点(比如在 SCNVector3Zero 位置)?
    • @LimThyeChean:这可能会有所帮助:developer.apple.com/documentation/scenekit/scnnode/…移动节点的旋转轴。例如,通过平移变换,您可以使节点围绕远处的点旋转,而不是围绕其中心旋转,...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-25
    • 2020-09-08
    • 2018-12-25
    • 2023-03-25
    • 2018-08-11
    • 1970-01-01
    • 2018-01-03
    相关资源
    最近更新 更多