pulling element to hand

laser-fallback
Fabien Benetou 2 years ago
parent ba8013a38e
commit 6b483775e8
  1. 15
      index.html

@ -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 )
});
}
});

Loading…
Cancel
Save