Skip to content

Commit da80bbf

Browse files
Add attribute to change the constraint component used by physics-grab-proto
1 parent 2dae475 commit da80bbf

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

reaction_components/prototypes/physics-grab-proto.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// base code used by grabbable for physics interactions
22
module.exports = {
33
schema: {
4-
usePhysics: {default: 'ifavailable'}
4+
usePhysics: {default: 'ifavailable'},
5+
constraintComponentName: {default: 'constraint'}
56
},
67
physicsInit: function () {
78
this.constraints = new Map()
@@ -19,7 +20,7 @@ module.exports = {
1920
if (this.data.usePhysics !== 'never' && this.el.body &&
2021
evt.detail.hand.body && !this.constraints.has(evt.detail.hand)) {
2122
const newConId = Math.random().toString(36).substr(2, 9)
22-
this.el.setAttribute('constraint__' + newConId, {
23+
this.el.setAttribute(this.data.constraintComponentName + '__' + newConId, {
2324
target: evt.detail.hand
2425
})
2526
this.constraints.set(evt.detail.hand, newConId)
@@ -32,7 +33,7 @@ module.exports = {
3233
physicsEnd: function (evt) {
3334
let constraintId = this.constraints.get(evt.detail.hand)
3435
if (constraintId) {
35-
this.el.removeAttribute('constraint__' + constraintId)
36+
this.el.removeAttribute(this.data.constraintComponentName + '__' + constraintId)
3637
this.constraints.delete(evt.detail.hand)
3738
}
3839
},

0 commit comments

Comments
 (0)