Shape

Shape

This class makes a body tangible to collision detection and response.Without it,the body will not be able to interact with other bodies.

Constructor

new Shape(vertices)

Source:
Parameters:
Name Type Description
vertices Array.<Vector2> The vertices of the shape in local space coordinates.

Classes

Shape

Members

angle :number

Source:
Type:
  • number

geometry :Geometry

Description:
  • Keeps the original normals and vertices of this shape
Source:
Keeps the original normals and vertices of this shape
Type:

(readonly) type :number

Description:
  • Used to determine what type of shape this is.
Source:
Used to determine what type of shape this is.
Type:
  • number

vertices :Array.<Vector2>

Description:
  • The vertices describing the shape.
Source:
The vertices describing the shape.
Type:

Methods

(static) calcInertia(shape, mass) → {number}

Description:
  • Calculates the inertia of a given shape.
Source:
Parameters:
Name Type Description
shape Shape
mass number
Returns:
Type
number

(static) getArea(shape)

Description:
  • TODO - Actually implement this
Source:
Parameters:
Name Type Description
shape Shape

(static) getNormals(shape, refshape, outopt) → {Array.<Vector2>}

Description:
  • Returns the normals of the faces when rotated.
Source:
Parameters:
Name Type Attributes Description
shape Shape
refshape Shape
out Array.<Vector2> <optional>
An array where results are stored.
Returns:
Type
Array.<Vector2>

(static) getVertices(shape, axis, out) → {Array.<Vector2>}

Description:
  • Returns the world coordinates of the vertices.
Source:
Parameters:
Name Type Description
shape T
axis Vector2
out Array.<Vector2>
Returns:
Type
Array.<Vector2>

(static) update(shape, position, angle, scale)

Description:
  • Transforms the local coordinates of the vertices to world coordinates.
Source:
Parameters:
Name Type Description
shape T
position Vector2 the world position of the body
angle number the orientation of body
scale Vector2 the scale of the body