As other users have mentioned, this is a current limitation of PhysicsJS. It's being worked out:
- scoping of collisions https://github.com/wellcaffeinated/PhysicsJS/issues/30
- constraints https://github.com/wellcaffeinated/PhysicsJS/issues/5
In the mean time, instead of patching the library, why not create a custom pin constraint behavior. For a simple pin constraint behavior that pins the body centroid to a target position, it's quite easy. Here's a jsFiddle of your example with a custom pin constraint manager defined at the beginning.
http://jsfiddle.net/wellcaffeinated/2HRGW/50/
// create a behavior to handle pin constraints
Physics.behavior('pin-constraints', function( parent ){
return {
init: function( opts ){
parent.init.call( this, opts );
this.pins = [];
},
add: function( body, targetPos ){
this.pins.push({
body: body,
target: Physics.vector( targetPos )
});
},
behave: function( data ){
var pins = this.pins
,pin
;
for (var i = 0, l = pins.length; i < l; i++){
pin = pins[ i ];
// move body to correct position
pin.body.state.pos.clone( pin.target );
}
}
};
});