当标记处于垂直位置时如何配置ar.js

时间:2018-12-13 13:39:20

标签: aframe ar.js

我发现的每个示例在桌子上或地板上都有标记。但是,如果我将标记放在墙上,它会旋转旋转,以使高度成为深度,依此类推。我知道我可以旋转对象,但是如果我想使用物理学或例如超级手势,它的控件不是向上/向下,而是向前/向后。如何更改标记轴?

1 个答案:

答案 0 :(得分:0)

我不知道ar.js是否具有直接实现此目的的方式。

您可以在所使用的任何设备(我假设的电话)中使用陀螺仪来跟踪方向并相应地修改模型的方向。例如,您可以使用组件轮询相机的方向,将其保持在状态,并在渲染模型时使用该状态来修改模型的方向,以使其始终面向相机。

有关我所讨论内容的示例,请参见下文

AFRAME.registerComponent('orientation-listener', {
  tick: function () {
    var cameraEl = this.el.sceneEl.camera.el;
    var cameraOrientation = cameraEl.getAttribute('rotation');

    // modify state to reflect current orientation of camera 
    // (cameraOrientation)
    // then have your model use that state to orient itself to the 
    // camera
  }
});
相关问题