Skip to content

Commit

Permalink
created grabbable setting
Browse files Browse the repository at this point in the history
  • Loading branch information
disasteroftheuniverse committed Dec 31, 2019
1 parent 69e4df4 commit 3f5e18f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"eslint.format.enable": true,
"eslint.enable": false
}
53 changes: 49 additions & 4 deletions src/components/aframe-oculus-quest-hands.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,23 @@ module.exports = {
intersections = this.collider.getIntersections('grabbable', true);
if (intersections) {
this.holdingEl = intersections.nearestEl;

this.holdingEl.setAttribute('constraint', {
parent: this.el
});
this.el.addState('holding-something');

if (!this.el.is('holding-something'))
{
this.el.addState('holding-something');
this.holdingEl.emit('grabbed',{handEl: this.el, hand: this.data.hand});
this.el.emit('grab',{holdingEl: this.holdingEl});
}

if (this.holdingEl.components.grabbable)
{
this.holdingEl.components.grabbable.onGrab(this);
}

} else {
this.el.addState('gripping');
}
Expand Down Expand Up @@ -419,6 +432,7 @@ module.exports = {
if (!this.subscribed) {
this.system.subscribe(this);
this.subscribed = true;
this.el.emit('colliderready',{el: this.el, collider: this},false);
}
},
update: function (oldData) {
Expand Down Expand Up @@ -490,8 +504,8 @@ module.exports = {
createAABBFromProxy: function () {

this.AABB.setFromObject(this.el.object3DMap.proxy);
console.log(this.el.object3DMap);
console.log(this.el.object3DMap.proxy);
//console.log(this.el.object3DMap);
//console.log(this.el.object3DMap.proxy);

var helper = new THREE.Box3Helper(this.AABB);
this.el.sceneEl.object3D.add(helper);
Expand Down Expand Up @@ -544,7 +558,7 @@ module.exports = {
}, false);
el.emit('hitstart', {
el: el,
intersectedEls: this.intersectedEls
//intersectedEls: this.intersectedEls
}, false);
}
},
Expand Down Expand Up @@ -618,6 +632,10 @@ module.exports = {
remove: function () {
this.system.unsubscribe(this);

if (this.data.bounds=='auto' && this.el.object3DMap.proxy){
this.el.removeAttribute('proxy');
}


}
}),
Expand Down Expand Up @@ -840,5 +858,32 @@ z: ${this.data.z.toFixed(2)}`
el: this.el
}, false);
}
}),
'grabbable': AFRAME.registerComponent('grabbable', {
schema: {

},
init: function () {
this.onColliderReady = this.onColliderReady.bind(this);
this.onGrab = this.onGrab.bind(this);

if (this.el.components.collider && this.el.components.collider.subscribed) {
this.onColliderReady();
} else {
this.el.addEventListener('colliderready', this.onColliderReady,{once: true});
}
},
onColliderReady: function(){
this.originalColliderProperties = AFRAME.utils.getComponentProperty();
},
onGrab: function(hand){

},
update: function () {

},
remove: function () {

}
})
};

0 comments on commit 3f5e18f

Please sign in to comment.