|
|
|
@ -2989,8 +2989,21 @@ AFRAME.registerComponent('collider-check', { |
|
|
|
|
dependencies: ['raycaster'], |
|
|
|
|
|
|
|
|
|
init: function () { |
|
|
|
|
let worldPosition=new THREE.Vector3(); |
|
|
|
|
let v3 = new THREE.Vector3 |
|
|
|
|
let comeCloserInterval |
|
|
|
|
this.el.addEventListener('raycaster-intersection', function (e) { |
|
|
|
|
console.log('Player hit something!',e.detail); |
|
|
|
|
console.log('intersected') |
|
|
|
|
comeCloserInterval = setInterval( _=> { |
|
|
|
|
document.getElementById("leftHand").object3D.traverse( e => { if (e.name == "wrist") { |
|
|
|
|
worldPosition.copy(e.position);e.parent.updateMatrixWorld();e.parent.localToWorld(worldPosition) |
|
|
|
|
} }) |
|
|
|
|
e.detail.intersections[0]?.object.el.object3D.position.lerp(worldPosition, 0.1) |
|
|
|
|
}, 100) |
|
|
|
|
}); |
|
|
|
|
this.el.addEventListener('raycaster-intersection-cleared', function (e) { |
|
|
|
|
console.log('cleared') |
|
|
|
|
clearInterval( comeCloserInterval ) |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|