Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions reaction_components/grabbable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const base = inherit({}, physicsCore, buttonsCore)
AFRAME.registerComponent('grabbable', inherit(base, {
schema: {
maxGrabbers: {type: 'int', default: NaN},
maxGrabBehavior: {default: 'nothing', oneOf: ['nothing', 'drop']},
invert: {default: false},
suppressY: {default: false}
},
Expand Down Expand Up @@ -74,9 +75,13 @@ AFRAME.registerComponent('grabbable', inherit(base, {
return
}
// room for more grabbers?
const grabAvailable = !Number.isFinite(this.data.maxGrabbers) ||
let grabAvailable = !Number.isFinite(this.data.maxGrabbers) ||
this.grabbers.length < this.data.maxGrabbers

if (Number.isFinite(this.data.maxGrabbers) && !grabAvailable &&
this.grabbed && this.data.maxGrabBehavior === 'drop') {
this.grabbers[0].components['super-hands'].onGrabEndButton()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would crash the component if it has button filtering enabled with a TypeError from trying to access properties on a null event detail.
https://github.com/wmurphyrd/aframe-super-hands-component/blob/master/reaction_components/prototypes/buttons-proto.js#L5

grabAvailable = true
}
if (this.grabbers.indexOf(evt.detail.hand) === -1 && grabAvailable) {
if (!evt.detail.hand.object3D) {
console.warn('grabbable entities must have an object3D')
Expand Down