@@ -285,9 +285,11 @@ AFRAME.registerComponent('super-hands', {
285285 const hoverEls = this . hoverEls ;
286286 const hitElIndex = this . hoverEls . indexOf ( hitEl ) ;
287287 let hoverNeedsUpdate = false ;
288- if ( dist && intersection . instanceId !== undefined ) hitEl . object3D . userData = {
289- instanceId : intersection . instanceId
290- } ;
288+ if ( dist && intersection . instanceId !== undefined ) {
289+ hitEl . object3D . userData = {
290+ instanceId : intersection . instanceId
291+ } ;
292+ }
291293 if ( hitElIndex === - 1 ) {
292294 hoverNeedsUpdate = true ;
293295 // insert in order of distance when available
@@ -1059,6 +1061,9 @@ module.exports = {
10591061 schema : {
10601062 usePhysics : {
10611063 default : 'ifavailable'
1064+ } ,
1065+ constraintComponentName : {
1066+ default : 'constraint'
10621067 }
10631068 } ,
10641069 physicsInit : function ( ) {
@@ -1076,7 +1081,7 @@ module.exports = {
10761081 // initiate physics constraint if available and not already existing
10771082 if ( this . data . usePhysics !== 'never' && this . el . body && evt . detail . hand . body && ! this . constraints . has ( evt . detail . hand ) ) {
10781083 const newConId = Math . random ( ) . toString ( 36 ) . substr ( 2 , 9 ) ;
1079- this . el . setAttribute ( 'constraint__ ' + newConId , {
1084+ this . el . setAttribute ( this . data . constraintComponentName + '__ ' + newConId , {
10801085 target : evt . detail . hand
10811086 } ) ;
10821087 this . constraints . set ( evt . detail . hand , newConId ) ;
@@ -1091,7 +1096,7 @@ module.exports = {
10911096 physicsEnd : function ( evt ) {
10921097 const constraintId = this . constraints . get ( evt . detail . hand ) ;
10931098 if ( constraintId ) {
1094- this . el . removeAttribute ( 'constraint__ ' + constraintId ) ;
1099+ this . el . removeAttribute ( this . data . constraintComponentName + '__ ' + constraintId ) ;
10951100 this . constraints . delete ( evt . detail . hand ) ;
10961101 }
10971102 } ,
@@ -1227,8 +1232,11 @@ AFRAME.registerComponent('stretchable', inherit(base, {
12271232 }
12281233 let physicsShape ;
12291234 let offset ;
1230- for ( let i = 0 ; i < el . body . shapes . length ; i ++ ) {
1231- physicsShape = el . body . shapes [ i ] ;
1235+
1236+ // CANNON.js has el.body.shapes. Ammo has collisionShapes in the shape component.
1237+ const shapesList = el . body . shapes ? el . body . shapes : el . components [ 'ammo-shape' ] . collisionShapes ;
1238+ for ( let i = 0 ; i < shapesList . length ; i ++ ) {
1239+ physicsShape = shapesList [ i ] ;
12321240 if ( physicsShape . halfExtents ) {
12331241 physicsShape . halfExtents . scale ( deltaStretch , physicsShape . halfExtents ) ;
12341242 physicsShape . updateConvexPolyhedronRepresentation ( ) ;
@@ -1243,7 +1251,12 @@ AFRAME.registerComponent('stretchable', inherit(base, {
12431251 offset = el . body . shapeOffsets [ i ] ;
12441252 offset . scale ( deltaStretch , offset ) ;
12451253 }
1246- el . body . updateBoundingRadius ( ) ;
1254+ if ( el . body . updateBoundingRadius ) {
1255+ // This only exists in CANNON, not Ammo.js
1256+ // I'm not aware of any requirement to call an equivalent function
1257+ // in Ammo.js
1258+ el . body . updateBoundingRadius ( ) ;
1259+ }
12471260 }
12481261} ) ) ;
12491262
0 commit comments