API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classPolygon

@codexo/exojs / math / stable

Mutable convex polygon defined by a world-space offset `(x, y)` and an array of local-space vertex Vectors. Implements ShapeLike with full SAT collision response. Edge vectors are recomputed whenever `setPoints` is called; normals are cached lazily and invalidated on any positional or point mutation. `Polygon.temp` is a shared scratch instance.

7
props
13
methods
0
events
Import
import { Polygon } from '@codexo/exojs'

Mutable convex polygon defined by a world-space offset `(x, y)` and an array of local-space vertex Vectors. Implements ShapeLike with full SAT collision response.

Edge vectors are recomputed whenever `setPoints` is called; normals are cached lazily and invalidated on any positional or point mutation.

`Polygon.temp` is a shared scratch instance.

Constructors 1
new(points: Vector[], x: number, y: number): Polygon
Methods 13
clone(): this
collidesWith(target: Collidable): CollisionResponse | null
contains(x: number, y: number): boolean
copy(polygon: Polygon): this
destroy(): void
equals(__namedParameters: Partial<Polygon>): boolean
getBounds(): Rectangle
getNormals(): Vector[]
intersectsWith(target: Collidable): boolean
project(axis: Vector, result: Interval): Interval
set(x: number, y: number, points: Vector[]): this
setPoints(newPoints: Vector[]): this
setPosition(x: number, y: number): this
Properties 7
collisionType: CollisionType
edges: Vector[]
points: Vector[]
position: Vector
x: number
y: number
temp: Polygon
Source