use raycaster over aabb-collider for saber collisions
This commit is contained in:
@@ -2,16 +2,14 @@
|
||||
* Listen to aabb-collider event for wall haptics.
|
||||
*/
|
||||
AFRAME.registerComponent('haptics-wall', {
|
||||
dependencies: ['aabb-collider'],
|
||||
|
||||
init: function () {
|
||||
const el = this.el;
|
||||
this.isHittingWall = false;
|
||||
el.setAttribute('haptics__wall', {dur: 50, force: 0.025});
|
||||
|
||||
this.checkIfHittingWall = this.checkIfHittingWall.bind(this);
|
||||
el.addEventListener('hitstart', this.checkIfHittingWall);
|
||||
el.addEventListener('hitend', this.checkIfHittingWall);
|
||||
el.addEventListener('mouseenter', this.checkIfHittingWall);
|
||||
el.addEventListener('mouseleave', this.checkIfHittingWall);
|
||||
|
||||
this.tick = AFRAME.utils.throttleTick(this.tick.bind(this), 50);
|
||||
},
|
||||
@@ -20,7 +18,7 @@ AFRAME.registerComponent('haptics-wall', {
|
||||
* On aabb-collider event, check if we are still hitting a wall.
|
||||
*/
|
||||
checkIfHittingWall: function () {
|
||||
const intersectedEls = this.el.components['aabb-collider'].intersectedEls;
|
||||
const intersectedEls = this.el.components.raycaster__game.intersectedEls;
|
||||
this.isHittingWall = false;
|
||||
for (let i = 0; i < intersectedEls.length; i++) {
|
||||
if (intersectedEls[i].components.wall) {
|
||||
|
||||
Reference in New Issue
Block a user