0
私はシーン内のすべてのカメラに添付して、このカメラでユーザーが入力できる各チェックポイントのアクションを登録するコンポーネントを持っています。今は、カメラの開始点を基準にしてカメラの位置を確認することで動作しますが、どうすればそのカメラを世界的な位置にして、これがアクティブなカメラであることを確認できますか?それ以来、非アクティブなカメラは、物理学によって位置が変わったときにイベントを発し続けているようです。どのようにカメラの世界の位置を聞くことができますか?
AFRAME.registerComponent('user-checkpoints', {
init: function() {
var self = this;
this.el.addEventListener('componentchanged', isOnCheckPoint);
// Is user in checkpoint
function isOnCheckPoint (evt) {
// We don't want such precision what event emits
if (evt.detail.name !== 'position' || (
(evt.detail.oldData.x).toFixed(1) === (evt.detail.newData.x).toFixed(1) &&
(evt.detail.oldData.y).toFixed(1) === (evt.detail.newData.y).toFixed(1) &&
(evt.detail.oldData.z).toFixed(1) === (evt.detail.newData.z).toFixed(1))
) { return; }
// Position has changed enough to check it
self.LookForCheckPoint(evt.detail.newData.x, evt.detail.newData.y, evt.detail.newData.z);
}
},
LookForCheckPoint: function (x, y, z) {
// All the chekpoints are checked here
console.log('x:' + x + ' y:' + y + ' z:' + z);
}
});
EDIT:私はHow to listen to camera's world position in A-Frame?