简体   繁体   English

如何使用设备指南针将对象或模型放置在统一的ARkit中?

[英]How to place objects or models in unity ARkit using device compass?

嗨,我想将模型放置在与北极相关的特定方向上。当我触摸屏幕后检测到平面后,将放置模型,但模型必须指向北极。我相信我们需要拿设备的陀螺仪并找到北极极点,然后放置模型。如果北极从我站立的地方成对角线,则放置模型时将保持对角线。因此,我必须增加或减少那么大的角度才能使模型笔直。从...开始。

I would set the alignment of the axes when you first configure your ARKit session so that they are aligned with gravity and heading. 首次配置ARKit会话时,我将设置轴的对齐方式,以使其与重力和航向对齐。 This is described here . 在这里描述。 So, after you do: 因此,执行以下操作后:

let configuration = ARWorldTrackingConfiguration()
configuration.worldAlignment = ARWorldTrackingConfiguration.WorldAlignment.gravityAndHeading
scnView.session.run(configuration)

It'll line up the axes with Magnetic North (note, this is slightly different from true north pole) . 它将使轴与“磁北极”对齐(请注意,这与真正的北极稍有不同)。 Now, if you place a model at (0,0,-1) , it'll show up 1 meter in the direction of Magnetic North 现在,如果您将模型放置在(0,0,-1) ,它将在磁北方向上显示1米

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM