Skip to content

Commit 3c32969

Browse files
committed
added Constraint.pointAWorld and Constraint.pointBWorld
1 parent 94e9614 commit 3c32969

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/constraint/Constraint.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,32 @@ var Common = require('../core/Common');
300300
}
301301
};
302302

303+
/**
304+
* Returns the world-space position of `constraint.pointA`, accounting for `constraint.bodyA`.
305+
* @method pointAWorld
306+
* @param {constraint} constraint
307+
* @returns {vector} the world-space position
308+
*/
309+
Constraint.pointAWorld = function(constraint) {
310+
return {
311+
x: (constraint.bodyA ? constraint.bodyA.position.x : 0) + constraint.pointA.x,
312+
y: (constraint.bodyA ? constraint.bodyA.position.y : 0) + constraint.pointA.y
313+
};
314+
};
315+
316+
/**
317+
* Returns the world-space position of `constraint.pointB`, accounting for `constraint.bodyB`.
318+
* @method pointBWorld
319+
* @param {constraint} constraint
320+
* @returns {vector} the world-space position
321+
*/
322+
Constraint.pointBWorld = function(constraint) {
323+
return {
324+
x: (constraint.bodyB ? constraint.bodyB.position.x : 0) + constraint.pointB.x,
325+
y: (constraint.bodyB ? constraint.bodyB.position.y : 0) + constraint.pointB.y
326+
};
327+
};
328+
303329
/*
304330
*
305331
* Properties Documentation

0 commit comments

Comments
 (0)