nape-js API
    Preparing search index...

    Class Circle

    A circular physics shape. The simplest and most performant collision shape.

    Hierarchy (View Summary)

    Index

    Constructors

    • Create a circle with the given radius and optional local centre-of-mass offset.

      Parameters

      • radius: number = 50

        Circle radius (must be > 0).

      • OptionallocalCOM: Vec2

        Local centre offset (defaults to origin).

      • Optionalmaterial: Material

        Material to assign (uses default if omitted).

      • Optionalfilter: InteractionFilter

        InteractionFilter to assign (uses default if omitted).

      Returns Circle

    Accessors

    • get angDrag(): number

      Angular drag coefficient for this shape.

      Returns number

    • get area(): number

      Cross-sectional area of this shape.

      Returns number

    • get castBody(): any

      Cast to Body — returns the Body wrapper if this is a Body, else null.

      Returns any

    • get castCapsule(): Shape | null

      Cast to Capsule, or null if this is not a capsule.

      Returns Shape | null

    • get castCircle(): Shape | null

      Cast to Circle, or null if this is not a circle.

      Returns Shape | null

    • get castCompound(): any

      Cast to Compound — returns the Compound wrapper if this is a Compound, else null.

      Returns any

    • get castPolygon(): Shape | null

      Cast to Polygon, or null if this is not a polygon.

      Returns Shape | null

    • get castShape(): any

      Cast to Shape — returns the Shape wrapper if this is a Shape, else null.

      Returns any

    • get fluidEnabled(): boolean

      If true, this shape participates in fluid interaction.

      Returns boolean

    • set fluidEnabled(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get id(): number

      Unique numeric identifier for this interactor.

      Returns number

    • get inertia(): number

      Contribution to moment of inertia (about local centroid, unit density).

      Returns number

    • get sensorEnabled(): boolean

      If true, this shape acts as a sensor (no physical response, only callbacks).

      Returns boolean

    • set sensorEnabled(value: boolean): void

      Parameters

      • value: boolean

      Returns void

    • get userData(): Record<string, unknown>

      User-defined data storage object.

      Returns Record<string, unknown>

    • get worldCOM(): Vec2

      World-space centre of mass of this shape (read-only, lazy-computed).

      Returns Vec2

    Methods

    • Return true if the given world-space point lies inside this shape. Requires the shape to be attached to a Body.

      Parameters

      • point: Vec2

        The world-space point to test.

      Returns boolean

      True if the point is inside this shape.

    • Create a deep copy of this shape with the same type, geometry, material, and filter.

      Returns Shape

      A new Shape instance independent of this one.

    • Rotate the shape's local vertices by angle radians.

      Parameters

      • angle: number

        Rotation in radians.

      Returns Shape

      this for chaining.

    • Scale the shape's local geometry. Circles require uniform scaling.

      Parameters

      • scaleX: number

        Horizontal scale factor (must be non-zero).

      • scaleY: number

        Vertical scale factor (must be non-zero).

      Returns Shape

      this for chaining.

    • Apply a Mat23 affine transform to the shape's local geometry.

      Parameters

      • matrix: { _inner: any }

        The transformation matrix (must be non-singular; Circles require equiorthogonal).

      Returns Shape

      this for chaining.