@@ -434,4 +434,27 @@ suite('super-hands & physics integration', function () {
434434 assert . isTrue ( this . target1 . body . shapes [ 1 ] . halfExtents . almostEquals ( check , 0.001 ) , 'scale' )
435435 assert . isTrue ( this . target1 . body . shapeOffsets [ 1 ] . almostEquals ( check , 0.001 ) , 'offset' )
436436 } )
437+ test ( 'net physics stretch correct when throttled' , function ( ) {
438+ const stretch = this . target1 . components . stretchable
439+ const size2 = new window . CANNON . Vec3 ( 1 , 1 , 1 )
440+ const offset2 = new window . CANNON . Vec3 ( 1 , 1 , 1 )
441+ const shape2 = new window . CANNON . Box ( size2 )
442+ this . target1 . body . addShape ( shape2 , offset2 )
443+ this . hand2 . setAttribute ( 'position' , '1 1 1' )
444+ stretch . start ( { detail : { hand : this . hand1 } } )
445+ stretch . start ( { detail : { hand : this . hand2 } } )
446+ stretch . tick ( 1 , 1 )
447+ this . hand2 . setAttribute ( 'position' , '1.5 1 1' )
448+ stretch . tick ( 6 , 5 )
449+ const check = new window . CANNON . Vec3 ( 0.5 , 0.5 , 0.5 )
450+ assert . isTrue ( this . target1 . body . shapes [ 0 ] . halfExtents . almostEquals ( check , 0.001 ) , 'throttled' )
451+ this . hand2 . setAttribute ( 'position' , '2 1 1' )
452+ stretch . tick ( 2006 , 2000 )
453+ check . set ( 0.707 , 0.707 , 0.707 )
454+ assert . isTrue ( this . target1 . body . shapes [ 0 ] . halfExtents . almostEquals ( check , 0.001 ) )
455+ assert . isTrue ( this . target2 . body . shapes [ 0 ] . halfExtents . almostEquals ( check , 0.001 ) , 'child' )
456+ check . set ( 1.414 , 1.414 , 1.414 )
457+ assert . isTrue ( this . target1 . body . shapes [ 1 ] . halfExtents . almostEquals ( check , 0.001 ) , 'scale' )
458+ assert . isTrue ( this . target1 . body . shapeOffsets [ 1 ] . almostEquals ( check , 0.001 ) , 'offset' )
459+ } )
437460} )
0 commit comments