【问题标题】:Detect a head/camera motion with aframe使用 aframe 检测头部/相机运动
【发布时间】:2017-04-28 06:13:42
【问题描述】:

我正在寻找带有 a-frame 的运动检测。我想要实现的是检测是否有人在 VR 模式下移动他的头。我可以检查实体的任何属性吗?或者相机组件本身是否有任何位置/旋转/我可以用于检测的任何属性?

【问题讨论】:

  • 不动是什么意思?人从来都不是静止的。总会有一些动静。
  • 我只想检测运动。当一些人移动/旋转他的头部等时,也许我需要阈值来触发事件。但我想检测是否有运动。 ;)

标签: javascript aframe webvr


【解决方案1】:

https://aframe.io/docs/0.3.0/core/entity.html#listening-for-component-changes

AFRAME.registerComponent('do-something-on-head-movement', {
  init: function () {
    var scene = this.el;
    var camera = scene.cameraEl;

    camera.addEventListener('componentchanged', function (evt) {
      if (evt.detail.name === 'rotation' || evt.detail.name === 'position') {
        // Do something.
      }
    });
  }
});

<a-scene do-something-on-head-movement>

【讨论】:

    【解决方案2】:

    我使用此功能检测耳机何时放下(面朝下)以“暂停”应用程序

    function process(event) {
      var gamma = event.gamma;
      if((gamma < -10)||(gamma>5)){
        playApp();
      }else{
        pauseApp();
      }
    }
    

    http://w3c.github.io/deviceorientation/spec-source-orientation.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-15
      • 1970-01-01
      • 2015-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多