Reputation: 663
I have a camera motion callback function, implemented in aframe. But the callback is never called. I am registering the component like this:
window.onload = function () {
AFRAME.registerComponent('listener', {
tick: function () {
console.log("TICK IS CALLED");
}
});
addMaze();
};
and the scene looks like this:
<body>
<a-scene physics id="a">
<a-entity position="33 0 -33" rotation="0 180 0" id="camera" camera="userHeight: 1.6" kinematic-body universal-controls listener>
</a-entity>
<!-- walls -->
<a-box color="#abc" static-body position="-35 0 0" width="0.001" height="6" depth="70"></a-box>
<a-box color="#abc" static-body position="35 0 0" width="0.001" height="6" depth="70"></a-box>
<!-- Lighting -->
<a-light type="ambient" color="#bbb"></a-light>
<a-light color="#ccc" position="0 30 0" distance="100" intensity="0.4" type="point"></a-light>
<a-light color="#ccc" position="3 10 -10" distance="50" intensity="0.4" type="point"></a-light>
</a-scene>
</body>
When moving the mouse, the callback is never called. How can I ensure it is called correctly?
Upvotes: 0
Views: 157
Reputation: 13233
The component should be registered before anything happens.
<head>
<script>
AFRAME.registerComponent('listener', {...});
</script>
</head>
<body>
<a-scene>
<!-- ... -->
</a-scene>
</body>
Upvotes: 1