【问题标题】:Set camera in motion within DeviceOrientationControls在 DeviceOrientationControls 中设置相机运动
【发布时间】:2016-01-27 01:37:18
【问题描述】:

我正在使用 Three.js 创建一个 webVR 应用程序。我已经实现了 DeviceOrientationControls,但现在想用谷歌纸板上的磁铁按钮在虚拟空间中移动。

我想要它,因此只需单击磁铁,相机就会在我所看的任何方向上移动。再次单击将停止运动。

这可能吗?如果是这样,我怎么能实现这个,我完全被卡住了。 我的假设是磁铁会导致“点击”事件。但是检测到这个点击后,如何让摄像头朝着我看的方向移动呢?

谢谢

【问题讨论】:

    标签: javascript three.js device-orientation


    【解决方案1】:

    使用DeviceOrientationControlsfreeze 属性:

    var controls = new THREE.DeviceOrientationControls(camera);
    controls.connect();
    controls.update();
    
    window.addEventListener('click', function() { controls.freeze = !controls.freeze; }, false);
    

    这当然只有在您拥有与屏幕接触的 Google Cardboard 版本时才有效。带有仅磁场开关的原装 Cardboard 将无法访问,因为没有暴露的磁力计 API(除非,例如,您的设备具有质量差的旋转传感器,因此首先使用 DeviceOrientationControls 是个坏主意)。

    【讨论】:

    • 谢谢。我没有按钮实际触摸屏幕以创建“点击”的版本,但我认为我别无选择。我可能需要在纸板上安装一些东西才能触摸屏幕。
    猜你喜欢
    • 2017-04-26
    • 1970-01-01
    • 2016-08-09
    • 2013-08-10
    • 2023-04-08
    • 2013-08-30
    • 2010-12-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多