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?
Asked
Active
Viewed 1,269 times
3
-
What do you mean by not moving? People are never static. There will always be some movement. – Diego Marcos Dec 13 '16 at 10:21
-
I just want to detect the movement. Maybe I need threshhold to trigger events when some is moving/rotating his head etc. But I want to detect if there is a movement. ;) – casarock Dec 14 '16 at 07:48
2 Answers
3
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>

ngokevin
- 12,980
- 2
- 38
- 84
1
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

Laurie Clark
- 610
- 7
- 10