Members
- Source:
Type:
defaultCollisionHandler :CollisionHandler
- Source:
- Default Value:
Type:
last_MSA_min :number
- Source:
- Default Value:
Type:
NONE :array
- Source:
Type:
- Source:
- Default Value:
Type:
numLeaves :number
- Source:
- Default Value:
Type:
numNodes :number
- Source:
- Default Value:
Type:
numPairs :number
- Source:
- Default Value:
Type:
shapeIDCounter :number
- Source:
- Default Value:
Type:
(constant) vzero :cp.Vect
- Source:
Type:
Methods
assert(value, message)
- Source:
Evaluate assertion.
Parameters:
Name |
Type |
Description |
value |
boolean
|
To test for truthiness. |
message |
string
|
To display on Error. |
assertSoft(value, message)
- Source:
Parameters:
Name |
Type |
Description |
value |
boolean
|
To test for truthiness. |
message |
string
|
To display on Error. |
assertSpaceUnlocked(space)
- Source:
Parameters:
bbArea(bb) → {number}
- Source:
Returns the area of the bounding box.
Parameters:
Name |
Type |
Description |
bb |
cp.BB
|
Bounding box. |
Returns:
Area of bounding box.
-
Type
-
number
bbClampVect(bb, v) → {cp.Vect}
- Source:
Clamp a vector to a bounding box.
Parameters:
Returns:
-
Type
-
cp.Vect
bbContainsBB(bb, other) → {boolean}
- Source:
Returns true if other lies completely within bb.
Parameters:
Name |
Type |
Description |
bb |
cp.BB
|
Bounding box. |
other |
cp.BB
|
Another bounding box. |
Returns:
-
Type
-
boolean
bbContainsVect(a, b) → {boolean}
- Source:
Returns true if bb contains v.
Parameters:
Name |
Type |
Description |
a |
cp.BB
|
Source bounding box. |
b |
cp.Vect
|
Target point. |
Returns:
-
Type
-
boolean
bbContainsVect2(l, b, r, t, v) → {boolean}
- Source:
Returns true if bounding box in l, b, r, t contains v.
Parameters:
Name |
Type |
Description |
l |
number
|
Left. |
b |
number
|
Bottom. |
r |
number
|
Right. |
t |
number
|
Top. |
v |
cp.Vect
|
Target point. |
Returns:
-
Type
-
boolean
bbExpand(bb, v) → {cp.BB}
- Source:
Returns a bounding box that holds both bb and v.
Parameters:
Name |
Type |
Description |
bb |
cp.BB
|
Bounding box. |
v |
cp.Vect
|
Point. |
Returns:
New bounding box which holds box bb and point v.
-
Type
-
cp.BB
bbIntersects(a, b) → {boolean}
- Source:
Returns true if a and b intersect.
Parameters:
Name |
Type |
Description |
a |
cp.BB
|
Bounding box A. |
b |
cp.BB
|
Bounding box B. |
Returns:
-
Type
-
boolean
bbIntersects2(bb, l, b, r, t) → {boolean}
- Source:
Parameters:
Name |
Type |
Description |
bb |
cp.BB
|
Bounding box. |
l |
number
|
Left. |
b |
number
|
Bottom. |
r |
number
|
Right. |
t |
number
|
Top. |
Returns:
-
Type
-
boolean
bbIntersectsSegment(bb, a, b) → {boolean}
- Source:
Return true if the bounding box intersects the line segment with ends a and b.
Parameters:
Name |
Type |
Description |
bb |
cp.BB
|
Bounding box. |
a |
cp.Vect
|
One endpoint of the segment. |
b |
cp.Vect
|
Another endpoint of the segment. |
Returns:
-
Type
-
boolean
bbMerge(a, b) → {cp.BB}
- Source:
Returns a bounding box that holds both bounding boxes.
Parameters:
Name |
Type |
Description |
a |
cp.BB
|
Bounding box A. |
b |
cp.BB
|
Bounding box B. |
Returns:
New bounding box which holds box A and B.
-
Type
-
cp.BB
bbMergedArea(a, b) → {number}
- Source:
Merges a and b and returns the area of the merged bounding box.
Parameters:
Name |
Type |
Description |
a |
cp.BB
|
Bounding box A. |
b |
cp.BB
|
Bounding box B. |
Returns:
Area of merged bounding box (box A and B).
-
Type
-
number
bbMergedArea2(bb, l, b, r, t) → {number}
- Source:
Parameters:
Name |
Type |
Description |
bb |
cp.BB
|
Bounding box. |
l |
number
|
Left. |
b |
number
|
Bottom. |
r |
number
|
Right. |
t |
number
|
Top. |
Returns:
Area of merged bounding box.
-
Type
-
number
bbNewForCircle(p, r) → {cp.BB}
- Source:
Constructs a cpBB for a circle with the given position and radius.
Parameters:
Name |
Type |
Description |
p |
cp.Vect
|
Target position. |
r |
number
|
Redius. |
Returns:
-
Type
-
cp.BB
bbProximity(a, b) → {number}
- Source:
Parameters:
Returns:
-
Type
-
number
bbTreeIntersectsNode(a, b) → {boolean}
- Source:
Parameters:
Returns:
-
Type
-
boolean
bbTreeMergedArea(a, b) → {number}
- Source:
Parameters:
Returns:
-
Type
-
number
bbTreeMergedArea2(node, l, b, r, t) → {number}
- Source:
Parameters:
Name |
Type |
Description |
node |
Node
|
|
l |
number
|
|
b |
number
|
|
r |
number
|
|
t |
number
|
|
Returns:
-
Type
-
number
bbWrapVect(bb, v) → {cp.Vect}
- Source:
- To Do:
-
Wrap a vector to a bounding box.
Parameters:
Returns:
-
Type
-
cp.Vect
circle2circle(circ1, circ2) → {Array.<Contract>}
- Source:
Collide circle shapes.
Parameters:
Returns:
-
Type
-
Array.<Contract>
circle2circleQuery(p1, p2, r1, r2) → {Contract}
- Source:
Add contact points for circle to circle collisions.
Used by several collision tests.
Parameters:
Returns:
-
Type
-
Contract
circle2poly(circ, poly) → {Array.<Contact>}
- Source:
- To Do:
-
This one is less gross, but still gross.
Parameters:
Returns:
-
Type
-
Array.<Contact>
circle2segment(circleShape, segmentShape) → {Array.<Contract>}
- Source:
Parameters:
Returns:
-
Type
-
Array.<Contract>
clamp(f, minv, maxv) → {number}
- Source:
Clamp f to be between min and max.
Parameters:
Name |
Type |
Description |
f |
number
|
|
minv |
number
|
Min value. |
maxv |
number
|
Max value. |
Returns:
-
Type
-
number
clamp01(f) → {number}
- Source:
Clamp f to be between 0 and 1.
Parameters:
Name |
Type |
Description |
f |
number
|
|
Returns:
-
Type
-
number
closestPointOnSegment(p, a, b) → {cp.Vect}
- Source:
Returns the closest point on the line segment ab, to the point p.
Parameters:
Name |
Type |
Description |
p |
cp.Vect
|
Target point. |
a |
cp.Vect
|
One endpoint of segment. |
b |
cp.Vect
|
Another endpoint of segment. |
Returns:
Closest point.
-
Type
-
cp.Vect
closestPointOnSegment2(px, py, ax, ay, bx, by) → {cp.Vect}
- Source:
Returns the closest point on the line segment ab, to the point p.
Parameters:
Name |
Type |
Description |
px |
number
|
X coordinate of target point. |
py |
number
|
Y coordinate of target point. |
ax |
number
|
X coordinate of one endpoint of segment. |
ay |
number
|
Y coordinate of one endpoint of segment. |
bx |
number
|
X coordinate of another endpoint of segment. |
by |
number
|
Y coordinate of another endpoint of segment. |
Returns:
Closeset point.
-
Type
-
cp.Vect
componentActivate(root)
- Source:
Parameters:
componentActive(root, threshold) → {boolean}
- Source:
Parameters:
Name |
Type |
Description |
root |
cp.Body
|
|
threshold |
number
|
|
Returns:
-
Type
-
boolean
componentAdd(root, body)
- Source:
Parameters:
componentRoot(body) → {cp.Body}
- Source:
Parameters:
Returns:
-
Type
-
cp.Body
createStaticBody() → {cp.Body}
- Source:
Returns:
-
Type
-
cp.Body
deleteObjFromList(arr, obj)
- Source:
Delete an object from a List(array type).
Parameters:
Name |
Type |
Description |
arr |
array
|
Source list(array). |
obj |
object
|
Target object that to be delete. |
filterConstraints(node, body, filter) → {cp.Constraint}
- Source:
Parameters:
Name |
Type |
Description |
node |
cp.Constraint
|
|
body |
cp.Body
|
|
filter |
cp.Constraint
|
|
Returns:
-
Type
-
cp.Constraint
findMSA(poly, planes) → {number}
- Source:
Find the minimum separating axis for the given poly and axis list.
This function needs to return two values - the index of the min. separating axis and
the value itself. Short of inlining MSA, returning values through a global like this
is the fastest implementation.
See: http://jsperf.com/return-two-values-from-function/2
Parameters:
Returns:
-
Type
-
number
findPointsBehindSeg(arr, seg, poly, pDist, coef)
- Source:
Identify vertexes that have penetrated the segment.
Parameters:
findVerts(poly1, poly2, n, dist) → {Array.<Contact>}
- Source:
Add contacts for penetrating vertexes.
Parameters:
Returns:
-
Type
-
Array.<Contact>
findVertsFallback(poly1, poly2, n, dist) → {Array.<Contact>}
- Source:
Add contacts for probably penetrating vertexes.
This handles the degenerate case where an overlap was detected, but no vertexes fall inside
the opposing polygon. (like a star of david)
Parameters:
Returns:
-
Type
-
Array.<Contact>
floodFillComponent(root, body)
- Source:
Parameters:
hashPair(a, b) → {string}
- Source:
The hashpair function takes two numbers and returns a hash code for them.
Required that hashPair(a, b) === hashPair(b, a).
Chipmunk's hashPair function is defined as:
#define CP_HASH_COEF (3344921057ul)
#define CP_HASH_PAIR(A, B) ((cpHashValue)(A)*CP_HASH_COEF ^ (cpHashValue)(B)*CP_HASH_COEF)
But thats not suitable in javascript because multiplying by a large number will make the number
a large float.
The result of hashPair is used as the key in objects, so it returns a string.
Parameters:
Name |
Type |
Description |
a |
number
|
|
b |
number
|
|
Returns:
Hash code.
-
Type
-
string
lerp(f1, f2, t) → {number}
- Source:
Linearly interpolate (or extrapolate) between f1 and f2 by t percent.
Parameters:
Name |
Type |
Description |
f1 |
number
|
|
f2 |
number
|
|
t |
number
|
percentage |
Returns:
-
Type
-
number
lerpconst(f1, f2, d) → {number}
- Source:
Linearly interpolate from f1 to f2 by no more than d.
Parameters:
Name |
Type |
Description |
f1 |
number
|
|
f2 |
number
|
|
d |
number
|
|
Returns:
-
Type
-
number
mymax(a, b) → {number}
- Source:
Return the bigger one between parameter a and b.
Parameters:
Name |
Type |
Description |
a |
number
|
|
b |
number
|
|
Returns:
-
Type
-
number
mymin(a, b) → {number}
- Source:
Return the smaller one between parameter a and b.
Parameters:
Name |
Type |
Description |
a |
number
|
|
b |
number
|
|
Returns:
-
Type
-
number
nodeRender(node, depth)
- Source:
Parameters:
Name |
Type |
Description |
node |
Nodde
|
|
depth |
number
|
|
nodeSegmentQuery(node, a, b) → {number}
- Source:
Returns the fraction along the segment query the node hits. Returns Infinity if it doesn't hit.
Parameters:
Returns:
-
Type
-
number
pairInsert(a, b, tree)
- Source:
Parameters:
partitionNodes(tree, nodes, offset, count) → {Node}
- Source:
Parameters:
Name |
Type |
Description |
tree |
cp.BBTree
|
|
nodes |
Array.<Node>
|
|
offset |
number
|
|
count |
number
|
|
Returns:
-
Type
-
Node
poly2poly(poly1, poly2) → {Array.<Contact>}
- Source:
Collide poly shapes together.
Parameters:
Returns:
-
Type
-
Array.<Contact>
polyValidate(verts) → {boolean}
- Source:
Check that a set of vertexes is convex and has a clockwise winding.
Parameters:
Name |
Type |
Description |
verts |
Array.<number>
|
|
Returns:
-
Type
-
boolean
QHullPartition(verts, offs, count, a, b, tol)
- Source:
Parameters:
Name |
Type |
Description |
verts |
Array.<number>
|
|
offs |
number
|
|
count |
number
|
|
a |
cp.Vect
|
|
b |
cp.Vect
|
|
tol |
number
|
|
QHullReduce(tol, verts, offs, count, a, pivot, b, retultPos) → {number}
- Source:
Parameters:
Name |
Type |
Description |
tol |
number
|
|
verts |
Array.<number>
|
|
offs |
number
|
|
count |
number
|
|
a |
cp.Vect
|
|
pivot |
cp.Vect
|
|
b |
cp.Vect
|
|
retultPos |
number
|
|
Returns:
-
Type
-
number
return {boolean}()
- Source:
Returns true if the body is static.
seg2poly(seg, poly) → {Array.<Contact>}
- Source:
- To Do:
-
This one is complicated and gross. Just don't go there...
Parameters:
Returns:
-
Type
-
Array.<Contact>
segValueOnAxis(seg, n, d) → {number}
- Source:
Like cpPolyValueOnAxis(), but for segments.
Parameters:
Returns:
-
Type
-
number
SplittingPlane(n, d)
- Source:
Parameters:
Name |
Type |
Description |
n |
cp.Vect
|
|
d |
number
|
|
subtreeInsert(subtree, leaf, tree) → {Node}
- Source:
Parameters:
Returns:
-
Type
-
Node
subtreeQuery(subtree, bb, func)
- Source:
Parameters:
Name |
Type |
Description |
subtree |
Node
|
|
bb |
Node
|
|
func |
function
|
|
subtreeRemove(subtree, leaf, tree) → {Node}
- Source:
Parameters:
Returns:
-
Type
-
Node
subtreeSegmentQuery(subtree, a, b, t_exit, func) → {number}
- Source:
Parameters:
Returns:
-
Type
-
number
SWAP(arr, idx1, idx2)
- Source:
Swap two elements in an array.
Parameters:
Name |
Type |
Description |
arr |
array
|
Source array. |
idx1 |
number
|
Index of target element. |
idx2 |
number
|
Index of another target element. |
unlinkThread(prev, leaf, next)
- Source:
Parameters:
unthreadHelper(arb, body, prev, next)
- Source:
Parameters:
updateFunc(shape)
- Source:
Parameters:
vcross2(x1, y1, x2, y2) → {cp.Vect}
- Source:
Parameters:
Name |
Type |
Description |
x1 |
number
|
|
y1 |
number
|
|
x2 |
number
|
|
y2 |
number
|
|
Returns:
-
Type
-
cp.Vect
vdot2(x1, y1, x2, y2) → {number}
- Source:
Parameters:
Name |
Type |
Description |
x1 |
number
|
|
y1 |
number
|
|
x2 |
number
|
|
y2 |
number
|
|
Returns:
-
Type
-
number
voidQueryFunc(obj1, obj2)
- Source:
Parameters:
Name |
Type |
Description |
obj1 |
|
|
obj2 |
|
|