Mapbox Ar不能在所有方向上正常工作 [英] Mapbox Ar does not work in all directions

查看:120
本文介绍了Mapbox Ar不能在所有方向上正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过Mapbox在Unity中构建了增强现实应用程序.另外,我通过Mapbox定位了一些点.点似乎在应用程序的AR中.但是,我意识到,在初始化应用程序时,手机的方向很重要.当电话跟随北方时,它只是显示了事实.

I have built an augmented reality application in Unity through Mapbox. Also, I geolocated some points through Mapbox. Points seems in AR in the application. But, I realized that when application is initialized the direction of the phone is important. It just shows the truth when phone follows the north.

我在互联网上进行了一些搜索,但是找不到确切的信息.

I have some searched on internet, but I couldn't find any exact information.

我更喜欢独立于电话指导来处理应用程序. 有人可以解释一下,或者对此有任何解决方案吗?

I prefer to work application independently from phone direction. Can somebody explain that or are there any solution for this ?

推荐答案

您可能正在寻找的是 Input.compass Compass ,具体来说是

What you are probably looking for would be Input.compassCompass and in specific

Input.compass.magneticHeading

相对于磁性北极的航向,以度为单位. (只读)

The heading in degrees relative to the magnetic North Pole. (Read Only)

始终以相对于屏幕顶部当前方向的相对位置来测量此属性中的值.磁北的航向与真正的地理北并不完全相同-要获得确切的航向,请使用trueHeading属性.

The value in this property is always measured relative to the top of the screen in its current orientation. The heading of magnetic north is not exactly the same as true geographical north - to get the exact heading, use the trueHeading property.

public class Example : MonoBehaviour
{
    void Start()
    {
        Input.location.Start();
    }

    void Update()
    {
        // Orient an object to point to magnetic north.
        transform.rotation = Quaternion.Euler(0, -Input.compass.magneticHeading, 0);
    }
}

Input.compass.trueHeading

相对于地理北极的航向,以度为单位. (只读)

The heading in degrees relative to the geographic North Pole. (Read Only)

始终以相对于屏幕顶部当前方向的相对位置来测量此属性中的值. 请注意,如果您希望此属性包含有效值,则还必须通过调用Input.location.Start()启用位置更新.(只读)

The value in this property is always measured relative to the top of the screen in its current orientation. Note, that if you want this property to contain a valid value, you must also enable location updates by calling Input.location.Start(). (Read Only)

API的使用示例

public class Example : MonoBehaviour
{
    void Start()
    {
        Input.location.Start();
    }

    void Update()
    {
        // Orient an object to point northward.
        transform.rotation = Quaternion.Euler(0, -Input.compass.trueHeading, 0);
    }
}

这篇关于Mapbox Ar不能在所有方向上正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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