finger-collision are HAPPENING
This commit is contained in:
parent
6f8403da9d
commit
c6f4b2fc77
1 changed files with 28 additions and 12 deletions
|
|
@ -8,10 +8,10 @@ AFRAME.registerComponent('pressable', {
|
||||||
},
|
},
|
||||||
init: function() {
|
init: function() {
|
||||||
this.worldPosition = new THREE.Vector3();
|
this.worldPosition = new THREE.Vector3();
|
||||||
this.handWorldPosition = new THREE.Vector3();
|
this.fingerWorldPosition = new THREE.Vector3();
|
||||||
|
this.raycaster = new THREE.Raycaster()
|
||||||
this.handEls = document.querySelectorAll('[hand-tracking-controls]');
|
this.handEls = document.querySelectorAll('[hand-tracking-controls]');
|
||||||
this.pressed = false;
|
this.pressed = false;
|
||||||
|
|
||||||
},
|
},
|
||||||
tick: function() {
|
tick: function() {
|
||||||
var handEls = this.handEls;
|
var handEls = this.handEls;
|
||||||
|
|
@ -20,18 +20,34 @@ AFRAME.registerComponent('pressable', {
|
||||||
for (var i = 0; i < handEls.length; i++) {
|
for (var i = 0; i < handEls.length; i++) {
|
||||||
handEl = handEls[i];
|
handEl = handEls[i];
|
||||||
let indexTipPosition = handEl.components['hand-tracking-controls'].indexTipPosition
|
let indexTipPosition = handEl.components['hand-tracking-controls'].indexTipPosition
|
||||||
handEl.object3D.localToWorld( this.handWorldPosition )
|
// Apply the relative position to the parent's world position
|
||||||
this.handWorldPosition.add( indexTipPosition )
|
handEl.object3D.updateMatrixWorld();
|
||||||
|
handEl.object3D.getWorldPosition( this.fingerWorldPosition )
|
||||||
|
this.fingerWorldPosition.add( indexTipPosition )
|
||||||
|
|
||||||
distance = this.calculateFingerDistance(this.handWorldPosition);
|
//distance = this.calculateFingerDistance(this.fingerWorldPosition);
|
||||||
if( xrf.debug == 10 && this.el.id == "xrf-button_teleport_me_down_there" ){ debugger }
|
|
||||||
|
|
||||||
if (distance < this.data.pressDistance && distance !== 0.0 ) {
|
//if (distance < this.data.pressDistance && distance !== 0.0 ) {
|
||||||
if (!this.pressed) {
|
// if (!this.pressed) {
|
||||||
this.el.emit('pressedstarted');
|
// this.el.emit('pressedstarted');
|
||||||
}
|
// }
|
||||||
this.pressed = true;
|
// this.pressed = true;
|
||||||
return;
|
// return;
|
||||||
|
//}
|
||||||
|
this.raycaster.far = 0.05
|
||||||
|
// Create a direction vector (doesnt matter because it is supershort for 'touch' purposes)
|
||||||
|
const direction = new THREE.Vector3(1.0,0,0);
|
||||||
|
this.raycaster.set(this.fingerWorldPosition, direction)
|
||||||
|
intersects = this.raycaster.intersectObjects([this.el.object3D])
|
||||||
|
|
||||||
|
this.el.object3D.getWorldPosition(this.worldPosition)
|
||||||
|
|
||||||
|
this.distance = this.fingerWorldPosition.distanceTo(this.worldPosition)
|
||||||
|
|
||||||
|
//if( xrf.debug == 10 && this.el.id == "xrf-button_teleport_me_down_there" ){ debugger }
|
||||||
|
|
||||||
|
if (intersects.length ){
|
||||||
|
debugger //if( xrf.debug == 10 && this.el.id == "xrf-button_teleport_me_down_there" ){ debugger }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.pressed) {
|
if (this.pressed) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue