Skip to content
21 changes: 16 additions & 5 deletions dist/super-hands.js
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,9 @@ module.exports = {
schema: {
usePhysics: {
default: 'ifavailable'
},
constraintComponentName: {
default: 'constraint'
}
},
physicsInit: function () {
Expand All @@ -1091,7 +1094,7 @@ module.exports = {
// initiate physics constraint if available and not already existing
if (this.data.usePhysics !== 'never' && this.el.body && evt.detail.hand.body && !this.constraints.has(evt.detail.hand)) {
const newConId = Math.random().toString(36).substr(2, 9);
this.el.setAttribute('constraint__' + newConId, {
this.el.setAttribute(this.data.constraintComponentName + '__' + newConId, {
target: evt.detail.hand
});
this.constraints.set(evt.detail.hand, newConId);
Expand All @@ -1106,7 +1109,7 @@ module.exports = {
physicsEnd: function (evt) {
const constraintId = this.constraints.get(evt.detail.hand);
if (constraintId) {
this.el.removeAttribute('constraint__' + constraintId);
this.el.removeAttribute(this.data.constraintComponentName + '__' + constraintId);
this.constraints.delete(evt.detail.hand);
}
},
Expand Down Expand Up @@ -1245,8 +1248,11 @@ AFRAME.registerComponent('stretchable', inherit(base, {
}
let physicsShape;
let offset;
for (let i = 0; i < el.body.shapes.length; i++) {
physicsShape = el.body.shapes[i];

// CANNON.js has el.body.shapes. Ammo has collisionShapes in the shape component.
const shapesList = el.body.shapes ? el.body.shapes : el.components['ammo-shape'].collisionShapes;
for (let i = 0; i < shapesList.length; i++) {
physicsShape = shapesList[i];
if (physicsShape.halfExtents) {
physicsShape.halfExtents.scale(deltaStretch, physicsShape.halfExtents);
physicsShape.updateConvexPolyhedronRepresentation();
Expand All @@ -1261,7 +1267,12 @@ AFRAME.registerComponent('stretchable', inherit(base, {
offset = el.body.shapeOffsets[i];
offset.scale(deltaStretch, offset);
}
el.body.updateBoundingRadius();
if (el.body.updateBoundingRadius) {
// This only exists in CANNON, not Ammo.js
// I'm not aware of any requirement to call an equivalent function
// in Ammo.js
el.body.updateBoundingRadius();
}
}
}));

Expand Down
11 changes: 6 additions & 5 deletions dist/super-hands.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading