如何在RealityKit中仅绕一个轴旋转对象? [英] How do I rotate an object around only one axis in RealityKit?

查看:167
本文介绍了如何在RealityKit中仅绕一个轴旋转对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绕其z轴旋转一个多维数据集,但找不到方法.

I'm trying to rotate a cube around its z-axis but I can't find how.

RealityKit中有一种方法可以做到这一点吗?

Is there a way in RealityKit to do this?

推荐答案

在RealityKit中,至少有两种方法可以使对象围绕单轴旋转:

第一种方法:

let boxAnchor = try! Experience.loadBox()

boxAnchor.steelBox?.orientation = simd_quatf(angle: .pi/4,      /* 45 Deg in Rad */
                                              axis: [0, 0, 1])  /* Around Z axis */

第二种方法:

boxAnchor.steelBox?.transform = Transform(pitch: 0, 
                                            yaw: 0, 
                                           roll: .pi/4)         /* Around Z axis */

  • 螺距是X轴(以弧度表示)
  • 偏航是Y轴(以弧度表示)
  • roll 是Z轴(以弧度表示)
    • pitch is X axis (expressed in radians)
    • yaw is Y axis (expressed in radians)
    • roll is Z axis (expressed in radians)
    • 这篇关于如何在RealityKit中仅绕一个轴旋转对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆