declarations
Version:
[](https://www.npmjs.com/package/declarations)
2,045 lines (1,696 loc) • 148 kB
TypeScript
// Type definitions for bootstrap.timepicker
// Project: http://code.google.com/p/box2dweb/
// Definitions by: jbaldwin <https://github.com/jbaldwin/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Box2DWeb-2.1.d.ts Copyright (c) 2012-2013 Josh Baldwin http://github.com/jbaldwin/box2dweb.d.ts
* There are a few competing javascript Box2D ports.
* This definitions file is for Box2dWeb.js ->
* http://code.google.com/p/box2dweb/
*
* Box2D C++ Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
**/
declare namespace Box2D.Common {
/**
* Color for debug drawing. Each value has the range [0, 1].
**/
export class b2Color {
/**
* Red
**/
public r: number;
/**
* Green
**/
public g: number;
/**
* Blue
**/
public b: number;
/**
* RGB color as hex.
* @type uint
**/
public color: number;
/**
* Constructor
* @param rr Red value
* @param gg Green value
* @param bb Blue value
**/
constructor(rr: number, gg: number, bb: number);
/**
* Sets the Color to new RGB values.
* @param rr Red value
* @param gg Green value
* @param bb Blue value
**/
public Set(rr: number, gg: number, bb: number): void;
}
}
declare namespace Box2D.Common {
/**
* Controls Box2D global settings.
**/
export class b2Settings {
/**
* b2Assert is used internally to handle assertions. By default, calls are commented out to save performance, so they serve more as documentation than anything else.
* @param a Asset an expression is true.
**/
public static b2Assert(a: boolean): void;
/**
* Friction mixing law. Feel free to customize this.
* Friction values are usually set between 0 and 1. (0 = no friction, 1 = high friction)
* By default this is `return Math.sqrt(friction1, friction2);`
* @param friction1 Friction 1 to mix.
* @param friction2 Friction 2 to mix.
* @return The two frictions mixed as one value.
**/
public static b2MixFriction(friction1: number, friction2: number): number;
/**
* Restitution mixing law. Feel free to customize this. Restitution is used to make objects bounce.
* Restitution values are usually set between 0 and 1. (0 = no bounce (inelastic), 1 = perfect bounce (perfectly elastic))
* By default this is `return Math.Max(restitution1, restitution2);`
* @param restitution1 Restitution 1 to mix.
* @param restitution2 Restitution 2 to mix.
* @return The two restitutions mixed as one value.
**/
public static b2MixRestitution(restitution1: number, restitution2: number): number;
/**
* This is used to fatten AABBs in the dynamic tree. This allows proxies to move by a small amount without triggering a tree adjustment. This is in meters.
**/
public static b2_aabbExtension: number;
/**
* This is used to fatten AABBs in the dynamic tree. This is used to predict the future position based on the current displacement. This is a dimensionless multiplier.
**/
public static b2_aabbMultiplier: number;
/**
* A body cannot sleep if its angular velocity is above this tolerance.
**/
public static b2_angularSleepTolerance: number;
/**
* A small angle used as a collision and constraint tolerance. Usually it is chosen to be numerically significant, but visually insignificant.
**/
public static b2_angularSlop: number;
/**
* This scale factor controls how fast overlap is resolved. Ideally this would be 1 so that overlap is removed in one time step. However using values close to 1 often lead to overshoot.
**/
public static b2_contactBaumgarte: number;
/**
* A body cannot sleep if its linear velocity is above this tolerance.
**/
public static b2_linearSleepTolerance: number;
/**
* A small length used as a collision and constraint tolerance. Usually it is chosen to be numerically significant, but visually insignificant.
**/
public static b2_linearSlop: number;
/**
* The maximum angular position correction used when solving constraints. This helps to prevent overshoot.
**/
public static b2_maxAngularCorrection: number;
/**
* The maximum linear position correction used when solving constraints. This helps to prevent overshoot.
**/
public static b2_maxLinearCorrection: number;
/**
* Number of manifold points in a b2Manifold. This should NEVER change.
**/
public static b2_maxManifoldPoints: number;
/**
* The maximum angular velocity of a body. This limit is very large and is used to prevent numerical problems. You shouldn't need to adjust this.
**/
public static b2_maxRotation: number;
/**
* b2_maxRotation squared
**/
public static b2_maxRotationSquared: number;
/**
* Maximum number of contacts to be handled to solve a TOI island.
**/
public static b2_maxTOIContactsPerIsland: number;
/**
* Maximum number of joints to be handled to solve a TOI island.
**/
public static b2_maxTOIJointsPerIsland: number;
/**
* The maximum linear velocity of a body. This limit is very large and is used to prevent numerical problems. You shouldn't need to adjust this.
**/
public static b2_maxTranslation: number;
/**
* b2_maxTranslation squared
**/
public static b2_maxTranslationSquared: number;
/**
* 3.141592653589793
**/
public static b2_pi: number;
/**
* The radius of the polygon/edge shape skin. This should not be modified. Making this smaller means polygons will have and insufficient for continuous collision. Making it larger may create artifacts for vertex collision.
**/
public static b2_polygonRadius: number;
/**
* The time that a body must be still before it will go to sleep.
**/
public static b2_timeToSleep: number;
/**
* Continuous collision detection (CCD) works with core, shrunken shapes. This is the amount by which shapes are automatically shrunk to work with CCD. This must be larger than b2_linearSlop.
* @see also b2_linearSlop
**/
public static b2_toiSlop: number;
/**
* A velocity threshold for elastic collisions. Any collision with a relative linear velocity below this threshold will be treated as inelastic.
**/
public static b2_velocityThreshold: number;
/**
* Maximum unsigned short value.
**/
public static USHRT_MAX: number;
/**
* The current version of Box2D.
**/
public static VERSION: string;
}
}
declare namespace Box2D.Common.Math {
/**
* A 2-by-2 matrix. Stored in column-major order.
**/
export class b2Mat22 {
/**
* Column 1
**/
public col1: b2Vec2;
/**
* Column 2
**/
public col2: b2Vec2;
/**
* Empty constructor
**/
constructor();
/**
* Sets all internal matrix values to absolute values.
**/
public Abs(): void;
/**
* Adds the two 2x2 matricies together and stores the result in this matrix.
* @param m 2x2 matrix to add.
**/
public AddM(m: b2Mat22): void;
/**
* Creates a copy of the matrix.
* @return Copy of this 2x2 matrix.
**/
public Copy(): b2Mat22;
/**
* Creates a rotation 2x2 matrix from the given angle.
* R(theta) = [ cos(theta) -sin(theta) ]
* [ sin(theta) cos(theta) ]
* @param angle Matrix angle (theta).
* @return 2x2 matrix.
**/
public static FromAngle(angle: number): b2Mat22;
/**
* Creates a 2x2 matrix from two columns.
* @param c1 Column 1 vector.
* @param c2 Column 2 vector.
* @return 2x2 matrix.
**/
public static FromVV(c1: b2Vec2, c2: b2Vec2): b2Mat22;
/**
* Gets the rotation matrix angle.
* R(theta) = [ cos(theta) -sin(theta) ]
* [ sin(theta) cos(theta) ]
* @return The rotation matrix angle (theta).
**/
public GetAngle(): number;
/**
* Compute the inverse of this matrix, such that inv(A) A = identity.
* @param out Inverse matrix.
* @return Inverse matrix.
**/
public GetInverse(out: b2Mat22): b2Mat22;
/**
* Sets the 2x2 rotation matrix from the given angle.
* R(theta) = [ cos(theta) -sin(theta) ]
* [ sin(theta) cos(theta) ]
* @param angle Matrix angle (theta).
**/
public Set(angle: number): void;
/**
* Sets the 2x2 matrix to identity.
**/
public SetIdentity(): void;
/**
* Sets the 2x2 matrix from a 2x2 matrix.
* @param m 2x2 matrix values.
**/
public SetM(m: b2Mat22): void;
/**
* Sets the 2x2 matrix from 2 column vectors.
* @param c1 Column 1 vector.
* @param c2 Column 2 vector.
**/
public SetVV(c1: b2Vec2, c2: b2Vec2): void;
/**
* Sets the 2x2 matrix to all zeros.
**/
public SetZero(): void;
/**
* TODO, has something to do with the determinant
* @param out Solved vector
* @param bX
* @param bY
* @return Solved vector
**/
public Solve(out: b2Vec2, bX: number, bY: number): b2Vec2;
}
}
declare namespace Box2D.Common.Math {
/**
* A 3-by3 matrix. Stored in column-major order.
**/
export class b2Mat33 {
/**
* Column 1
**/
public col1: b2Vec3;
/**
* Column 2
**/
public col2: b2Vec3;
/**
* Column 3
**/
public col3: b2Vec3;
/**
* Constructor
* @param c1 Column 1
* @param c2 Column 2
* @param c3 Column 3
**/
constructor(c1: b2Vec3, c2: b2Vec3, c3: b2Vec3);
/**
* Adds the two 3x3 matricies together and stores the result in this matrix.
* @param m 3x3 matrix to add.
**/
public AddM(m: b2Mat33): void;
/**
* Creates a copy of the matrix.
* @return Copy of this 3x3 matrix.
**/
public Copy(): b2Mat33;
/**
* Sets the 3x3 matrix to identity.
**/
public SetIdentity(): void;
/**
* Sets the 3x3 matrix from a 3x3 matrix.
* @param m 3x3 matrix values.
**/
public SetM(m: b2Mat33): void;
/**
* Sets the 3x3 matrix from 3 column vectors.
* @param c1 Column 1 vector.
* @param c2 Column 2 vector.
* @param c3 Column 2 vector.
**/
public SetVVV(c1: b2Vec3, c2: b2Vec3, c3: b2Vec3): void;
/**
* Sets the 3x3 matrix to all zeros.
**/
public SetZero(): void;
/**
* TODO, has something to do with the determinant
* @param out Solved vector
* @param bX
* @param bY
* @return Solved vector
**/
public Solve22(out: b2Vec2, bX: number, bY: number): b2Vec2;
/**
* TODO, has something to do with the determinant
* @param out Solved vector
* @param bX
* @param bY
* @param bZ
* @return Solved vector
**/
public Solve33(out: b2Vec3, bX: number, bY: number, bZ: number): b2Vec3;
}
}
declare namespace Box2D.Common.Math {
/**
* Math utility functions.
**/
export class b2Math {
/**
* Determines if a number is valid. A number is valid if it is finite.
* @param x Number to check for validity.
* @return True if x is valid, otherwise false.
**/
public static IsValid(x: number): boolean;
/**
* Dot product of two vector 2s.
* @param a Vector 2 to use in dot product.
* @param b Vector 2 to use in dot product.
* @return Dot product of a and b.
**/
public static Dot(a: b2Vec2, b: b2Vec2): number;
/**
* Cross product of two vector 2s.
* @param a Vector 2 to use in cross product.
* @param b Vector 2 to use in cross product.
* @return Cross product of a and b.
**/
public static CrossVV(a: b2Vec2, b: b2Vec2): number;
/**
* Cross product of vector 2 and s.
* @param a Vector 2 to use in cross product.
* @param s s value.
* @return Cross product of a and s.
**/
public static CrossVF(a: b2Vec2, s: number): b2Vec2;
/**
* Cross product of s and vector 2.
* @param s s value.
* @param a Vector 2 to use in cross product.
* @return Cross product of s and a.
**/
public static CrossFV(s: number, a: b2Vec2): b2Vec2;
/**
* Multiply matrix and vector.
* @param A Matrix.
* @param v Vector.
* @return Result.
**/
public static MulMV(A: b2Mat22, v: b2Vec2): b2Vec2;
/**
*
* @param A
* @param v
* @return
**/
public static MulTMV(A: b2Mat22, v: b2Vec2): b2Vec2;
/**
*
* @param T
* @param v
* @return
**/
public static MulX(T: b2Transform, v: b2Vec2): b2Vec2;
/**
*
* @param T
* @param v
* @return
**/
public static MulXT(T: b2Transform, v: b2Vec2): b2Vec2;
/**
* Adds two vectors.
* @param a First vector.
* @param b Second vector.
* @return a + b.
**/
public static AddVV(a: b2Vec2, b: b2Vec2): b2Vec2;
/**
* Subtracts two vectors.
* @param a First vector.
* @param b Second vector.
* @return a - b.
**/
public static SubtractVV(a: b2Vec2, b: b2Vec2): b2Vec2;
/**
* Calculates the distance between two vectors.
* @param a First vector.
* @param b Second vector.
* @return Distance between a and b.
**/
public static Distance(a: b2Vec2, b: b2Vec2): number;
/**
* Calculates the squared distance between two vectors.
* @param a First vector.
* @param b Second vector.
* @return dist^2 between a and b.
**/
public static DistanceSquared(a: b2Vec2, b: b2Vec2): number;
/**
*
* @param s
* @param a
* @return
**/
public static MulFV(s: number, a: b2Vec2): b2Vec2;
/**
*
* @param A
* @param B
* @return
**/
public static AddMM(A: b2Mat22, B: b2Mat22): b2Mat22;
/**
*
* @param A
* @param B
* @return
**/
public static MulMM(A: b2Mat22, B: b2Mat22): b2Mat22;
/**
*
* @param A
* @param B
* @return
**/
public static MulTMM(A: b2Mat22, B: b2Mat22): b2Mat22;
/**
* Creates an ABS number.
* @param a Number to ABS.
* @return Absolute value of a.
**/
public static Abs(a: number): number;
/**
* Creates an ABS vector.
* @param a Vector to ABS all values.
* @return Vector with all positive values.
**/
public static AbsV(a: b2Vec2): b2Vec2;
/**
* Creates an ABS matrix.
* @param A Matrix to ABS all values.
* @return Matrix with all positive values.
**/
public static AbsM(A: b2Mat22): b2Mat22;
/**
* Determines the minimum number.
* @param a First number.
* @param b Second number.
* @return a or b depending on which is the minimum.
**/
public static Min(a: number, b: number): number;
/**
* Determines the minimum vector.
* @param a First vector.
* @param b Second vector.
* @return a or b depending on which is the minimum.
**/
public static MinV(a: b2Vec2, b: b2Vec2): b2Vec2;
/**
* Determines the max number.
* @param a First number.
* @param b Second number.
* @return a or b depending on which is the maximum.
**/
public static Max(a: number, b: number): number;
/**
* Determines the max vector.
* @param a First vector.
* @param b Second vector.
* @return a or b depending on which is the maximum.
**/
public static MaxV(a: b2Vec2, b: b2Vec2): b2Vec2;
/**
* Clamp a number to the range of low to high.
* @param a Number to clamp.
* @param low Low range.
* @param high High range.
* @return Number a clamped to range of low to high.
**/
public static Clamp(a: number, low: number, high: number): number;
/**
* Clamps a vector to the range of low to high.
* @param a Vector to clamp.
* @param low Low range.
* @param high High range.
* @return Vector a clamped to range of low to high.
**/
public static ClampV(a: b2Vec2, low: b2Vec2, high: b2Vec2): b2Vec2;
/**
* Swaps a and b objects.
* @param a a -> b.
* @param b b -> a.
**/
public static Swap(a: any, b: any): void;
/**
* Generates a random number.
* @param return Random number.
**/
public static Random(): number;
/**
* Returns a random number between lo and hi.
* @param lo Lowest random number.
* @param hi Highest random number.
* @return Number between lo and hi.
**/
public static RandomRange(lo: number, hi: number): number;
/**
* Calculates the next power of 2 after the given number.
* @param x Number to start search for the next power of 2.
* @return The next number that is a power of 2.
**/
public static NextPowerOfTwo(x: number): number;
/**
* Check if a number is a power of 2.
* @param x Number to check if it is a power of 2.
* @return True if x is a power of 2, otherwise false.
**/
public static IsPowerOfTwo(x: number): boolean;
/**
* Global instance of a zero'ed vector. Use as read-only.
**/
public static b2Vec2_zero: b2Vec2;
/**
* Global instance of a 2x2 identity matrix. Use as read-only.
**/
public static b2Mat22_identity: b2Mat22;
/**
* Global instance of an identity transform. Use as read-only.
**/
public static b2Transform_identity: b2Transform;
}
}
declare namespace Box2D.Common.Math {
/**
* This describes the motion of a body/shape for TOI computation. Shapes are defined with respect to the body origin, which may no coincide with the center of mass. However, to support dynamics we must interpolate the center of mass position.
**/
export class b2Sweep {
/**
* World angle.
**/
public a: number;
/**
* World angle.
**/
public a0: number;
/**
* Center world position.
**/
public c: b2Vec2;
/**
* Center world position.
**/
public c0: b2Vec2;
/**
* Local center of mass position.
**/
public localCenter: b2Vec2;
/**
* Time interval = [t0,1], where t0 is in [0,1].
**/
public t0: b2Vec2;
/**
* Advance the sweep forward, yielding a new initial state.
* @t The new initial time.
**/
public Advance(t: number): void;
/**
* Creates a copy of the sweep.
**/
public Copy(): b2Sweep;
/**
* Get the interpolated transform at a specific time.
* @param xf Transform at specified time, this is an out parameter.
* @param alpha Is a factor in [0,1], where 0 indicates t0.
**/
public GetTransform(xf: b2Transform, alpha: number): void;
/**
* Sets the sweep from a sweep.
* @param other Sweep values to copy from.
**/
public Set(other: b2Sweep): void;
}
}
declare namespace Box2D.Common.Math {
/**
* A transform contains translation and rotation. It is used to represent the position and orientation of rigid frames.
**/
export class b2Transform {
/**
* Transform position.
**/
public position: b2Vec2;
/**
* Transform rotation.
**/
public R: b2Mat22;
/**
* The default constructor does nothing (for performance).
* @param pos Position
* @param r Rotation
**/
constructor(pos: b2Vec2, r: b2Mat22);
/**
* Calculate the angle that the rotation matrix represents.
* @return Rotation matrix angle.
**/
public GetAngle(): number;
/**
* Initialize using a position vector and rotation matrix.
* @param pos Position
* @param r Rotation
**/
public Initialize(pos: b2Vec2, r: b2Mat22): void;
/**
* Sets the transfrom from a transfrom.
* @param x Transform to copy values from.
**/
public Set(x: b2Transform): void;
/**
* Set this to the identity transform.
**/
public SetIdentity(): void;
}
}
declare namespace Box2D.Common.Math {
/**
* A 2D column vector.
**/
export class b2Vec2 {
/**
* x value
**/
public x: number;
/**
* y value
**/
public y: number;
/**
* Creates a new vector 2.
* @param x x value, default = 0.
* @param y y value, default = 0.
**/
constructor(x?: number, y?: number);
/**
* Sets x and y to absolute values.
**/
public Abs(): void;
/**
* Adds the vector 2 to this vector 2. The result is stored in this vector 2.
* @param v Vector 2 to add.
**/
public Add(v: b2Vec2): void;
/**
* Creates a copy of the vector 2.
* @return Copy of this vector 2.
**/
public Copy(): b2Vec2;
/**
* Cross F V
* @param s
**/
public CrossFV(s: number): void;
/**
* Cross V F
* @param s
**/
public CrossVF(s: number): void;
/**
* Gets the negative of this vector 2.
* @return Negative copy of this vector 2.
**/
public GetNegative(): b2Vec2;
/**
* True if the vector 2 is valid, otherwise false. A valid vector has finite values.
* @return True if the vector 2 is valid, otherwise false.
**/
public IsValid(): boolean;
/**
* Calculates the length of the vector 2.
* @return The length of the vector 2.
**/
public Length(): number;
/**
* Calculates the length squared of the vector2.
* @return The length squared of the vector 2.
**/
public LengthSquared(): number;
/**
* Creates a new vector 2 from the given values.
* @param x x value.
* @param y y value.
**/
public static Make(x: number, y: number): b2Vec2;
/**
* Calculates which vector has the maximum values and sets this vector to those values.
* @param b Vector 2 to compare for maximum values.
**/
public MaxV(b: b2Vec2): void;
/**
* Calculates which vector has the minimum values and sets this vector to those values.
* @param b Vector 2 to compare for minimum values.
**/
public MinV(b: b2Vec2): void;
/**
* Matrix multiplication. Stores the result in this vector 2.
* @param A Matrix to muliply by.
**/
public MulM(A: b2Mat22): void;
/**
* Vector multiplication. Stores the result in this vector 2.
* @param a Value to multiple the vector's values by.
**/
public Multiply(a: number): void;
/**
* Dot product multiplication. Stores the result in this vector 2.
* @param A Matrix to multiply by.
**/
public MulTM(A: b2Mat22): void;
/**
* Sets this vector 2 to its negative.
**/
public NegativeSelf(): void;
/**
* Normalizes the vector 2 [0,1].
* @return Length.
**/
public Normalize(): number;
/**
* Sets the vector 2.
* @param x x value, default is 0.
* @param y y value, default is 0.
**/
public Set(x?: number, y?: number): void;
/**
* Sets the vector 2 from a vector 2.
* @param v Vector 2 to copy values from.
**/
public SetV(v: b2Vec2): void;
/**
* Sets the vector 2 to zero values.
**/
public SetZero(): void;
/**
* Subtracts the vector 2 from this vector 2. The result is stored in this vector 2.
* @param v Vector 2 to subtract.
**/
public Subtract(v: b2Vec2): void;
}
}
declare namespace Box2D.Common.Math {
/**
* A 2D column vector with 3 elements.
**/
export class b2Vec3 {
/**
* x value.
**/
public x: number;
/**
* y value.
**/
public y: number;
/**
* z value.
**/
public z: number;
/**
* Construct using coordinates x,y,z.
* @param x x value, default = 0.
* @param y y value, default = 0.
* @param z z value, default = 0.
**/
constructor(x?: number, y?: number, z?: number);
/**
* Adds the vector 3 to this vector 3. The result is stored in this vector 3.
* @param v Vector 3 to add.
**/
public Add(v: b2Vec3): void;
/**
* Creates a copy of the vector 3.
* @return Copy of this vector 3.
**/
public Copy(): b2Vec3;
/**
* Gets the negative of this vector 3.
* @return Negative copy of this vector 3.
**/
public GetNegative(): b2Vec3;
/**
* Vector multiplication. Stores the result in this vector 3.
* @param a Value to multiple the vector's values by.
**/
public Multiply(a: number): void;
/**
* Sets this vector 3 to its negative.
**/
public NegativeSelf(): void;
/**
* Sets the vector 3.
* @param x x value, default is 0.
* @param y y value, default is 0.
* @param z z value, default is 0.
**/
public Set(x?: number, y?: number, z?: number): void;
/**
* Sets the vector 3 from a vector 3.
* @param v Vector 3 to copy values from.
**/
public SetV(v: b2Vec3): void;
/**
* Sets the vector 3 to zero values.
**/
public SetZero(): void;
/**
* Subtracts the vector 3 from this vector 3. The result is stored in this vector 3.
* @param v Vector 3 to subtract.
**/
public Subtract(v: b2Vec3): void;
}
}
declare namespace Box2D.Collision {
/**
* Axis aligned bounding box.
**/
export class b2AABB {
/**
* Lower bound.
**/
public lowerBound: Box2D.Common.Math.b2Vec2;
/**
* Upper bound.
**/
public upperBound: Box2D.Common.Math.b2Vec2;
/**
* Combines two AABBs into one with max values for upper bound and min values for lower bound.
* @param aabb1 First AABB to combine.
* @param aabb2 Second AABB to combine.
* @return New AABB with max values from aabb1 and aabb2.
**/
public static Combine(aabb1: b2AABB, aabb2: b2AABB): b2AABB;
/**
* Combines two AABBs into one with max values for upper bound and min values for lower bound. The result is stored in this AABB.
* @param aabb1 First AABB to combine.
* @param aabb2 Second AABB to combine.
**/
public Combine(aabb1: b2AABB, aabb2: b2AABB): void;
/**
* Determines if an AABB is contained within this one.
* @param aabb AABB to see if it is contained.
* @return True if aabb is contained, otherwise false.
**/
public Contains(aabb: b2AABB): boolean;
/**
* Gets the center of the AABB.
* @return Center of this AABB.
**/
public GetCenter(): Box2D.Common.Math.b2Vec2;
/**
* Gets the extents of the AABB (half-widths).
* @return Extents of this AABB.
**/
public GetExtents(): Box2D.Common.Math.b2Vec2;
/**
* Verify that the bounds are sorted.
* @return True if the bounds are sorted, otherwise false.
**/
public IsValid(): boolean;
/**
* Perform a precise raycast against this AABB.
* @param output Ray cast output values.
* @param input Ray cast input values.
* @return True if the ray cast hits this AABB, otherwise false.
**/
public RayCast(output: b2RayCastOutput, input: b2RayCastInput): boolean;
/**
* Tests if another AABB overlaps this AABB.
* @param other Other AABB to test for overlap.
* @return True if other overlaps this AABB, otherwise false.
**/
public TestOverlap(other: b2AABB): boolean;
}
}
declare namespace Box2D.Collision {
/**
* We use contact ids to facilitate warm starting.
**/
export class b2ContactID {
/**
* Features
**/
public features: Features;
/**
* ID Key
**/
public Key: number;
/**
* Creates a new Contact ID.
**/
constructor();
/**
* Copies the Contact ID.
* @return Copied Contact ID.
**/
public Copy(): b2ContactID;
/**
* Sets the Contact ID from a Contact ID.
* @param id The Contact ID to copy values from.
**/
public Set(id: b2ContactID): void;
}
}
declare namespace Box2D.Collision {
/**
* This structure is used to report contact points.
**/
export class b2ContactPoint {
/**
* The combined friction coefficient.
**/
public friction: number;
/**
* The contact id identifies the features in contact.
**/
public id: b2ContactID;
/**
* Points from shape1 to shape2.
**/
public normal: Box2D.Common.Math.b2Vec2;
/**
* Position in world coordinates.
**/
public position: Box2D.Common.Math.b2Vec2;
/**
* The combined restitution coefficient.
**/
public restitution: number;
/**
* The separation is negative when shapes are touching.
**/
public separation: number;
/**
* The first shape.
**/
public shape1: Shapes.b2Shape;
/**
* The second shape.
**/
public shape2: Shapes.b2Shape;
/**
* Velocity of point on body2 relative to point on body1 (pre-solver).
**/
public velocity: Box2D.Common.Math.b2Vec2;
}
}
declare namespace Box2D.Collision {
/**
* Input for b2Distance. You have to option to use the shape radii in the computation. Even
**/
export class b2DistanceInput {
/**
* Proxy A
**/
public proxyA: b2DistanceProxy;
/**
* Proxy B
**/
public proxyB: b2DistanceProxy;
/**
* Transform A
**/
public transformA: Box2D.Common.Math.b2Transform;
/**
* Transform B
**/
public transformB: Box2D.Common.Math.b2Transform;
/**
* Use shape radii in computation?
**/
public useRadii: boolean;
}
}
declare namespace Box2D.Collision {
/**
* Output calculation for b2Distance.
**/
export class b2DistanceOutput {
/**
* Calculated distance.
**/
public distance: number;
/**
* Number of gjk iterations used in calculation.
**/
public iterations: number;
/**
* Closest point on shape A.
**/
public pointA: Box2D.Common.Math.b2Vec2;
/**
* Closest point on shape B.
**/
public pointB: Box2D.Common.Math.b2Vec2;
}
}
declare namespace Box2D.Collision {
/**
* A distance proxy is used by the GJK algorithm. It encapsulates any shape.
**/
export class b2DistanceProxy {
/**
* Count
**/
public m_count: number;
/**
* Radius
**/
public m_radius: number;
/**
* Verticies
**/
public m_vertices: Box2D.Common.Math.b2Vec2[];
/**
* Get the supporting vertex index in the given direction.
* @param d Direction to look for the supporting vertex.
* @return Supporting vertex index.
**/
public GetSupport(d: Box2D.Common.Math.b2Vec2): number;
/**
* Get the supporting vertex in the given direction.
* @param d Direction to look for the supporting vertex.
* @return Supporting vertex.
**/
public GetSupportVertex(d: Box2D.Common.Math.b2Vec2): Box2D.Common.Math.b2Vec2;
/**
* Get a vertex by index. Used by b2Distance.
* @param index Vetex's index.
* @return Vertex at the given index.
**/
public GetVertex(index: number): Box2D.Common.Math.b2Vec2;
/**
* Get the vertex count.
* @return The number of vertices. (m_vertices.length)
**/
public GetVertexCount(): number;
/**
* Initialize the proxy using the given shape. The shape must remain in scope while the proxy is in use.
* @param shape Shape to initialize the distance proxy.
**/
public Set(shape: Shapes.b2Shape): void;
}
}
declare namespace Box2D.Collision {
/**
* A dynamic tree arranges data in a binary tree to accelerate queries such as volume queries and ray casts. Leafs are proxies with an AABB. In the tree we expand the proxy AABB by b2_fatAABBFactor so that the proxy AABB is bigger than the client object. This allows the client object to move by small amounts without triggering a tree update. Nodes are pooled.
**/
export class b2DynamicTree {
/**
* Constructing the tree initializes the node pool.
**/
constructor();
/**
* Create a proxy. Provide a tight fitting AABB and a userData.
* @param aabb AABB.
* @param userDate User defined data for this proxy.
* @return Dynamic tree node.
**/
public CreateProxy(aabb: b2AABB, userData: any): b2DynamicTreeNode;
/**
* Destroy a proxy. This asserts if the id is invalid.
* @param proxy Proxy to destroy.
**/
public DestroyProxy(proxy: b2DynamicTreeNode): void;
/**
* Gets the Fat AABB for the proxy.
* @param proxy Proxy to retrieve Fat AABB.
* @return Fat AABB for proxy.
**/
public GetFatAABB(proxy: b2DynamicTreeNode): b2AABB;
/**
* Get user data from a proxy. Returns null if the proxy is invalid.
* Cast to your type on return.
* @param proxy Proxy to retrieve user data from.
* @return User data for proxy or null if proxy is invalid.
**/
public GetUserData(proxy: b2DynamicTreeNode): any;
/**
* Move a proxy with a swept AABB. If the proxy has moved outside of its fattened AABB, then the proxy is removed from the tree and re-inserted. Otherwise the function returns immediately.
* @param proxy Proxy to move.
* @param aabb Swept AABB.
* @param displacement Extra AABB displacement.
**/
public MoveProxy(proxy: b2DynamicTreeNode, aabb: b2AABB, displacement: Box2D.Common.Math.b2Vec2): boolean;
/**
* Query an AABB for overlapping proxies. The callback is called for each proxy that overlaps the supplied AABB. The callback should match function signature fuction callback(proxy:b2DynamicTreeNode):Boolean and should return false to trigger premature termination.
* @param callback Called for each proxy that overlaps the supplied AABB.
* param proxy Proxy overlapping the supplied AABB.
* @aabb Proxies are query for overlap on this AABB.
**/
public Query(callback: (proxy: b2DynamicTreeNode) => boolean, aabb: b2AABB): void;
/**
* Ray-cast against the proxies in the tree. This relies on the callback to perform a exact ray-cast in the case were the proxy contains a shape. The callback also performs the any collision filtering. This has performance roughly equal to k log(n), where k is the number of collisions and n is the number of proxies in the tree.
* @param callback Called for each proxy that is hit by the ray.
* param input Ray cast input data.
* param proxy The proxy hit by the ray cast.
* return Return value is the new value for maxFraction.
* @param input Ray cast input data. Query all proxies along this ray cast.
**/
public RayCast(callback: (input: b2RayCastInput, proxy: b2DynamicTreeNode) => number, input: b2RayCastInput): void;
/**
* Perform some iterations to re-balance the tree.
* @param iterations Number of rebalance iterations to perform.
**/
public Rebalance(iterations: number): void;
}
}
declare namespace Box2D.Collision {
/**
* The broad-phase is used for computing pairs and performing volume queries and ray casts. This broad-phase does not persist pairs. Instead, this reports potentially new pairs. It is up to the client to consume the new pairs and to track subsequent overlap.
**/
export class b2DynamicTreeBroadPhase implements IBroadPhase {
/**
* Creates the dynamic tree broad phase.
**/
constructor();
/**
* @see IBroadPhase.CreateProxy
**/
public CreateProxy(aabb: b2AABB, userData: any): b2DynamicTreeNode;
/**
* @see IBroadPhase.DestroyProxy
**/
public DestroyProxy(proxy: b2DynamicTreeNode): void;
/**
* @see IBroadPhase.GetFatAABB
**/
public GetFatAABB(proxy: b2DynamicTreeNode): b2AABB;
/**
* @see IBroadPhase.GetProxyCount
**/
public GetProxyCount(): number;
/**
* @see IBroadPhase.GetUserData
**/
public GetUserData(proxy: b2DynamicTreeNode): any;
/**
* @see IBroadPhase.MoveProxy
**/
public MoveProxy(proxy: b2DynamicTreeNode, aabb: b2AABB, displacement: Box2D.Common.Math.b2Vec2): void;
/**
* @see IBroadPhase.Query
**/
public Query(callback: (proxy: b2DynamicTreeNode) => boolean, aabb: b2AABB): void;
/**
* @see IBroadPhase.RayCast
**/
public RayCast(callback: (input: b2RayCastInput, proxy: b2DynamicTreeNode) => number, input: b2RayCastInput): void;
/**
* @see IBroadPhase.Rebalance
**/
public Rebalance(iterations: number): void;
/**
* Tests if two proxies overlap.
* @param proxyA First proxy to test.
* @param proxyB Second proxy to test.
* @return True if the proxyA and proxyB overlap with Fat AABBs, otherwise false.
**/
public TestOverlap(proxyA: b2DynamicTreeNode, proxyB: b2DynamicTreeNode): boolean;
/**
* Update the pairs. This results in pair callbacks. This can only add pairs.
* @param callback Called for all new proxy pairs.
* param userDataA Proxy A in the pair user data.
* param userDataB Proxy B in the pair user data.
**/
public UpdatePairs(callback: (userDataA: any, userDataB: any) => void ): void;
/**
* Validates the dynamic tree.
* NOTE: this says "todo" in the current Box2DFlash code.
**/
public Validate(): void;
}
}
declare namespace Box2D.Collision {
/**
* Empty declaration, used in many callbacks within b2DynamicTree.
* Use the b2DynamicTree functions to extract data from this shell.
**/
export class b2DynamicTreeNode {
}
}
declare namespace Box2D.Collision {
/**
* A manifold for two touching convex shapes. Box2D supports multiple types of contact: - clip point versus plane with radius - point versus point with radius (circles) The local point usage depends on the manifold type: -e_circles: the local center of circleA -e_faceA: the center of faceA -e_faceB: the center of faceB Similarly the local normal usage: -e_circles: not used -e_faceA: the normal on polygonA -e_faceB: the normal on polygonB We store contacts in this way so that position correction can account for movement, which is critical for continuous physics. All contact scenarios must be expressed in one of these types. This structure is stored across time steps, so we keep it small.
**/
export class b2Manifold {
/**
* Circles
**/
public static e_circles: number;
/**
* Face A
**/
public static e_faceA: number;
/**
* Face B
**/
public static e_faceB: number;
/**
* Not used for Type e_points
**/
public m_localPlaneNormal: Box2D.Common.Math.b2Vec2;
/**
* Usage depends on manifold type
**/
public m_localPoint: Box2D.Common.Math.b2Vec2;
/**
* The number of manifold points
**/
public m_pointCount: number;
/**
* The points of contact
**/
public m_points: b2ManifoldPoint[];
/**
* Manifold type.
**/
public m_type: number;
/**
* Creates a new manifold.
**/
constructor();
/**
* Copies the manifold.
* @return Copy of this manifold.
**/
public Copy(): b2Manifold;
/**
* Resets this manifold.
**/
public Reset(): void;
/**
* Sets this manifold from another manifold.
* @param m Manifold to copy values from.
**/
public Set(m: b2Manifold): void;
}
}
declare namespace Box2D.Collision {
/**
* A manifold point is a contact point belonging to a contact manifold. It holds details related to the geometry and dynamics of the contact points. The local point usage depends on the manifold type: -e_circles: the local center of circleB -e_faceA: the local center of cirlceB or the clip point of polygonB -e_faceB: the clip point of polygonA This structure is stored across time steps, so we keep it small. Note: the impulses are used for internal caching and may not provide reliable contact forces, especially for high speed collisions.
**/
export class b2ManifoldPoint {
/**
* Contact ID.
**/
public m_id: b2ContactID;
/**
* Local contact point.
**/
public m_localpoint: Box2D.Common.Math.b2Vec2;
/**
* Normal impluse for this contact point.
**/
public m_normalImpulse: number;
/**
* Tangent impulse for contact point.
**/
public m_tangentImpulse: number;
/**
* Creates a new manifold point.
**/
constructor();
/**
* Resets this manifold point.
**/
public Reset(): void;
/**
* Sets this manifold point from a manifold point.
* @param m The manifold point to copy values from.
**/
public Set(m: b2ManifoldPoint): void;
}
}
declare namespace Box2D.Collision {
/**
* An oriented bounding box.
**/
export class b2OBB {
/**
* The local centroid.
**/
public center: Box2D.Common.Math.b2Vec2;
/**
* The half-widths.
**/
public extents: Box2D.Common.Math.b2Vec2;
/**
* The rotation matrix.
**/
public R: Box2D.Common.Math.b2Mat22;
}
}
declare namespace Box2D.Collision {
/**
* Ray cast input data.
**/
export class b2RayCastInput {
/**
* Truncate the ray to reach up to this fraction from p1 to p2
**/
public maxFraction: number;
/**
* The start point of the ray.
**/
public p1: Box2D.Common.Math.b2Vec2;
/**
* The end point of the ray.
**/
public p2: Box2D.Common.Math.b2Vec2;
/**
* Creates a new ray cast input.
* @param p1 Start point of the ray, default = null.
* @param p2 End point of the ray, default = null.
* @param maxFraction Truncate the ray to reach up to this fraction from p1 to p2.
**/
constructor(p1?: Box2D.Common.Math.b2Vec2, p2?: Box2D.Common.Math.b2Vec2, maxFraction?: number);
}
}
declare namespace Box2D.Collision {
/**
* Results of a ray cast.
**/
export class b2RayCastOutput {
/**
* The fraction between p1 and p2 that the collision occurs at.
**/
public fraction: number;
/**
* The normal at the point of collision.
**/
public normal: Box2D.Common.Math.b2Vec2;
}
}
declare namespace Box2D.Collision {
/**
* A line in space between two given vertices.
**/
export class b2Segment {
/**
* The starting point.
**/
public p1: Box2D.Common.Math.b2Vec2;
/**
* The ending point.
**/
public p2: Box2D.Common.Math.b2Vec2;
/**
* Extends or clips the segment so that it's ends lie on the boundary of the AABB.
* @param aabb AABB to extend/clip the segement.
**/
public Extend(aabb: b2AABB): void;
/**
* See Extend, this works on the ending point.
* @param aabb AABB to extend/clip the ending point.
**/
public ExtendBackward(aabb: b2AABB): void;
/**
* See Extend, this works on the starting point.
* @param aabb AABB to extend/clip the starting point.
**/
public ExtendForward(aabb: b2AABB): void;
/**
* Ray cast against this segment with another segment.
* @param lambda returns the hit fraction. You can use this to compute the contact point * p = (1 - lambda) * segment.p1 + lambda * segment.p2 * @normal Normal at the contact point. If there is no intersection, the normal is not set.
* @param segment Defines the begining and end point of the ray cast.
* @param maxLambda a number typically in the range [0,1].
* @return True if there is an intersection, otherwise false.
**/
public TestSegment(
lambda: number[],
normal: Box2D.Common.Math.b2Vec2,
segment: b2Segment,
maxLambda: number): boolean;
}
}
declare namespace Box2D.Collision {
/**
* Used to warm start b2Distance. Set count to zero on first call.
**/
export class b2SimplexCache {
/**
* Number in cache.
**/
public count: number;
/**
* Vertices on shape a.
**/
public indexA: number[];
/**
* Vertices on shape b.
**/
public indexB: number[];
/**
* Length or area.
**/
public metric: number;
}
}
declare namespace Box2D.Collision {
/**
* Inpute parameters for b2TimeOfImpact
**/
export class b2TOIInput {
/**
* Proxy A
**/
public proxyA: b2DistanceProxy;
/**
* Proxy B
**/
public proxyB: b2DistanceProxy;
/**
* Sweep A
**/
public sweepA: Box2D.Common.Math.b2Sweep;
/**
* Sweep B
**/
public sweepB: Box2D.Common.Math.b2Sweep;
/**
* Tolerance
**/
public tolerance: number;
}
}
declare namespace Box2D.Collision {
/**
* This is used to compute the current state of a contact manifold.
**/
export class b2WorldManifold {
/**
* World vector pointing from A to B.
**/
public m_normal: Box2D.Common.Math.b2Vec2;
/**
* World contact point (point of intersection).
**/
public m_points: Box2D.Common.Math.b2Vec2[];
/**
* Creates a new b2WorldManifold.
**/
constructor();
/**
* Evaluate the manifold with supplied transforms. This assumes modest motion from the original state. This does not change the point count, impulses, etc. The radii must come from the shapes that generated the manifold.
* @param manifold Manifold to evaluate.
* @param xfA A transform.
* @param radiusA A radius.
* @param xfB B transform.
* @param radiusB B radius.
**/
public Initialize(
manifold: b2Manifold,
xfA: Box2D.Common.Math.b2Transform,
radiusA: number,
xfB: Box2D.Common.Math.b2Transform,
radiusB: number): void;
}
}
declare namespace Box2D.Collision {
/**
* We use contact ids to facilitate warm starting.
**/
export class Features {
/**
* A value of 1 indicates that the reference edge is on shape2.
**/
public flip: number;
/**
* The edge most anti-parallel to the reference edge.
**/
public incidentEdge: number;
/**
* The vertex (0 or 1) on the incident edge that was clipped.
**/
public incidentVertex: number;
/**
* The edge that defines the outward contact normal.
**/
public referenceEdge: number;
}
}
declare namespace Box2D.Collision {
/**
* Interface for objects tracking overlap of many AABBs.
**/
export interface IBroadPhase {
/**
* Create a proxy with an initial AABB. Pairs are not reported until UpdatePairs is called.
* @param aabb Proxy Fat AABB.
* @param userData User defined data.
* @return Proxy created from aabb and userData.
**/
CreateProxy(aabb: b2AABB, userData: any): b2DynamicTreeNode;
/**
* Destroy a proxy. It is up to the client to remove any pairs.
* @param proxy Proxy to destroy.
**/
DestroyProxy(proxy: b2DynamicTreeNode): void;
/**
* Get the Fat AABB for a proxy.
* @param proxy Proxy to retrieve the Fat AABB.
**/
GetFatAABB(proxy: b2DynamicTreeNode): b2AABB;
/**
* Get the number of proxies.
* @return Number of proxies.
**/
GetProxyCount(): number;
/**
* Get user data from a proxy. Returns null if the proxy is invalid.
* @param proxy Proxy to retrieve user data from.
* @return Gets the user data from proxy, or null if the proxy is invalid.
**/
GetUserData(proxy: b2DynamicTreeNode): any;
/**
* Call MoveProxy as many times as you like, then when you are done call UpdatePairs to finalized the proxy pairs (for your time step).
* @param proxy Proxy to move.
* @param aabb Swept AABB.
* @param displacement Extra AABB displacement.
**/
MoveProxy(proxy: b2DynamicTreeNode, aabb: b2AABB, displacement: Box2D.Common.Math.b2Vec2): void;
/**
* Query an AABB for overlapping proxies. The callback is called for each proxy that overlaps the supplied AABB. The callback should match function signature fuction callback(proxy:b2DynamicTreeNode):Boolean and should return false to trigger premature termination.
* @param callback Called for each proxy that overlaps the supplied AABB.
* param proxy Proxy overlapping the supplied AABB.
* @param aabb Proxies are query for overlap on this AABB.
**/
Query(callback: (proxy: b2DynamicTreeNode) => boolean, aabb: b2AABB): void;
/**
* Ray-cast against the proxies in the tree. This relies on the callback to perform a exact ray-cast in the case were the proxy contains a shape. The callback also performs the any collision filtering. This has performance roughly equal to k log(n), where k is the number of collisions and n is the number of proxies in the tree.
* @param callback Called for each proxy that is hit by the ray.
* param input Ray cast input data.
* param proxy The proxy hit by the ray cast.
* param return Return value is the new value for maxFraction.
* @param input Ray cast input data. Query all proxies along this ray cast.
**/
RayCast(callback: (input: b2RayCastInput, proxy: b2DynamicTreeNode) => number, input: b2RayCastInput): void;
/**
* Perform some iterations to re-balance the tree.
* @param iterations Number of rebalance iterations to perform.
**/
Rebalance(iterations: number): void;
}
}
declare namespace Box2D.Collision.Shapes {
/**
* A circle shape.
**/
export class b2CircleShape extends b2Shape {
/**
* Creates a new circle shape.
* @param radius Circle radius.
**/
constructor(radius?: number);
/**
* Given a transform, compute the associated axis aligned bounding box for this shape.
* @param aabb Calculated AABB, this argument is `out`.
* @param xf Transform to calculate the AABB.
**/
public ComputeAABB(aabb: b2AABB, xf: Box2D.Common.Math.b2Transform): void;
/**
* Compute the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin, not the centroid.
* @param massData Calculate the mass, this argument is `out`.
* @param density
**/
public ComputeMass(massData: b2MassData, density: number): void;
/**
* Compute the volume and centroid of this shape intersected with a half plane
* @param normal The surface normal.
* @param offset The surface offset along the normal.
* @param xf The shape transform.
* @param c The centroid, this argument is `out`.
**/
public ComputeSubmergedArea(
normal: Box2D.Common.Math.b2Vec2,
offset: number,
xf: Box2D.Common.Math.b2Transform,
c: Box2D.Common.Math.b2Vec2): number;
/**
* Copies the circle shape.
* @return Copy of this circle shape.
**/
public Copy(): b2CircleShape;
/**
* Get the local position of this circle in its parent body.
* @return This circle's local position.
**/
public GetLocalPosition(): Box2D.Common.Math.b2Vec2;
/**
* Get the radius of the circle.
* @return This circle's radius.
**/
public GetRadius(): number;
/**
* Cast a ray against this shape.
* @param output Ray cast results, this argument is `out`.
* @param input Ray cast input parameters.
* @param transform The transform to be applied to the shape.
* @return True if the ray hits the shape, otherwise false.
**/
public RayCast(
output: b2RayCastOutput,
input: b2RayCastInput,
transform: Box2D.Common.Math.b2Transform): boolean;
/**
* Set the circle shape values from another shape.
* @param other The other circle shape to copy values from.
**/
public Set(other: b2CircleShape): void;
/**
* Set the local position of this circle in its parent body.
* @param position The new local position of this circle.
**/
public SetLocalPosition(position: Box2D.Common.Math.b2Vec2): void;
/**
* Set the radius of the circle.
* @param radius The new radius of the circle.
**/
public SetRadius(radius: number): void;
/**
* Test a point for containment in this shape. This only works for convex shapes.
* @param xf Shape world transform.
* @param p Point to test against, in world coordinates.
* @return True if the point is in this shape, otherwise false.
**/
public TestPoint(xf: Box2D.Common.Math.b2Transform, p: Box2D.Common.Math.b2Vec2): boolean;
}
}
declare namespace Box2D.Collision.Shapes {
/**
* This structure is used to build edge shapes.
**/
export class b2EdgeChainDef {
/**
* Whether to create an extra edge between the first and last vertices