Convex polygon. The vertices must be in CCW order for a right-handed coordinate system with the z-axis coming out of the screen.

Hierarchy (View Summary)

Constructors

Properties

e_circleShape: number
e_edgeShape: number
e_hitCollide: number

Return value for TestSegment indicating a hit.

e_missCollide: number

Return value for TestSegment indicating a miss.

e_polygonShape: number
e_shapeTypeCount: number
e_unknownShape: number
startsInsideCollide: number

Return value for TestSegment indicating that the segment starting point, p1, is already inside the shape.

Methods

  • Compute the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin, not the centroid.

    Parameters

    • massData: b2MassData

      Calculate the mass, this argument is out.

    • density: number

    Returns void

  • Get the supporting vertex index in the given direction.

    Parameters

    Returns number

    Vertex index supporting the direction.

  • Copy vertices. This assumes the vertices define a convex polygon. It is assumed that the exterior is the the right of each edge.

    Parameters

    • vertices: b2Vec2[]

      List of vertices to create the polygon shape from.

    • OptionalvertexCount: number

      Number of vertices in the shape, default value is 0 and in the box2dweb.js code it is ignored.

    Returns void

    Convex polygon shape.

  • Build vertices to represent an axis-aligned box.

    Parameters

    • hx: number

      The half-width.

    • hy: number

      The half-height.

    Returns void

    Box polygon shape.

  • Build vertices to represent an oriented box.

    Parameters

    • hx: number

      The half-width.

    • hy: number

      The half-height.

    • Optionalcenter: b2Vec2

      The center of the box in local coordinates, default is null (no center?)

    • Optionalangle: number

      The rotation of the box in local coordinates, default is 0.0.

    Returns void

    Oriented box shape.

  • This assumes the vertices define a convex polygon. It is assumed that the exterior is the the right of each edge.

    Parameters

    • vertices: any[]

      List of vertices to create the polygon shape from.

    • OptionalvertexCount: number

      The number of vertices, default is 0 and in the box2dweb.js code it is ignored.

    Returns void

    Convex polygon shape.

  • Creates a b2PolygonShape from a vertices list. This assumes the vertices define a convex polygon. It is assumed that the exterior is the the right of each edge.

    Parameters

    • vertices: b2Vec2[]

      List of vertices to create the polygon shape from.

    • OptionalvertexCount: number

      Number of vertices in the shape, default value is 0 and in the box2dweb.js code it is ignored.

    Returns b2PolygonShape

    Convex polygon shape.

  • Build vertices to represent an oriented box.

    Parameters

    • hx: number

      The half-width.

    • hy: number

      The half-height.

    • Optionalcenter: b2Vec2

      The center of the box in local coordinates, default is null (no center?)

    • Optionalangle: number

      The rotation of the box in local coordinates, default is 0.0.

    Returns b2PolygonShape

    Oriented box shape.

  • This assumes the vertices define a convex polygon. It is assumed that the exterior is the the right of each edge.

    Parameters

    • vertices: b2Vec2[]

      List of vertices to create the polygon shape from.

    • OptionalvertexCount: number

      The number of vertices, default is 0 and in the box2dweb.js code it is ignored.

    Returns b2PolygonShape

    Convex polygon shape.