I'm in search for a motion detection in with a-frame. What I want to achieve is a detection if someone is moving his head when being in VR-Mode. Is there any property for an entity I can check? Or does the camera component itself has any position/rotaion/whatever attributes I can use for a detection?
3
votes
2 Answers
3
votes
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>
1
votes
I used this function to detect when the headset was put down (face down) to "pause" the app
function process(event) {
var gamma = event.gamma;
if((gamma < -10)||(gamma>5)){
playApp();
}else{
pauseApp();
}
}
http://w3c.github.io/deviceorientation/spec-source-orientation.html