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);
}
});
편집 : 내가 How to listen to camera's world position in A-Frame?