Options
All
  • Public
  • Public/Protected
  • All
Menu

Class World

The world is container for bodies and joints.

Events:

  • add-body
  • remove-body
  • add-joint
  • remove-joint

Hierarchy

Index

Constructors

constructor

Properties

activeBodies

activeBodies: Map<number, Body<any>> = ...

bodies

bodies: Map<number, Body<any>> = ...

engine

engine: Engine

Private eventIds

eventIds: Map<number, number[]> = ...

joints

joints: Map<number, Joint<any>> = ...

kinematicBodies

kinematicBodies: Map<number, Body<any>> = ...

sleepingBodies

sleepingBodies: Map<number, Body<any>> = ...

staticBodies

staticBodies: Map<number, Body<any>> = ...

Methods

add

  • add(...objects: (Joint<any> | Body<any>)[]): void

addBody

  • addBody(...bodies: Body<any>[]): void
  • Adds given objects to the world.

    Parameters

    • Rest ...bodies: Body<any>[]

    Returns void

addJoint

  • addJoint(...joints: Joint<any>[]): void
  • Adds the given joints to the world.

    Parameters

    • Rest ...joints: Joint<any>[]

    Returns void

all

  • Returns the array of all bodies and joints that exists in the world.

    Returns (Joint<any> | Body<any>)[]

    The array of all bodies and joints that exists in the world

allBodies

  • allBodies(): Body<any>[]
  • Returns all bodies that exists in the world.

    Returns Body<any>[]

    All bodies that exists in the world

allJoints

  • allJoints(): Joint<any>[]
  • Returns all joints that exists in the world.

    Returns Joint<any>[]

    All joints that exists in the world

clear

  • clear(): void

clearBodies

  • clearBodies(): void

clearJoints

  • clearJoints(): void

getActiveBodies

  • getActiveBodies(): Body<any>[]

getBody

  • getBody(id: number): undefined | Body<any>
  • Returns the body with the given id if the body exists in the world.

    Parameters

    • id: number

    Returns undefined | Body<any>

    The Body with the given id if the body exists in the world

getJoint

  • getJoint(id: number): undefined | Joint<any>
  • Returns the joint with the given id if a joint exists in the world.

    Parameters

    • id: number

    Returns undefined | Joint<any>

    The joint with the given id if a joint exists in the world

getSleepingBodies

  • getSleepingBodies(): Body<any>[]

getStaticBodies

  • getStaticBodies(): Body<any>[]

hasBody

  • hasBody(id: number): boolean
  • Returns true if the body with given id exists in the world.

    Parameters

    • id: number

    Returns boolean

    True if the body with given id exists in the world

hasJoint

  • hasJoint(id: number): boolean
  • Returns true if the joint with the given id exists in the world.

    Parameters

    • id: number

    Returns boolean

    True if the joint with the given id exists in the world

off

  • off(id: number): boolean
  • Unsubscribes the callback function from the given event name.

    Parameters

    • id: number

    Returns boolean

    True if the event was successfully unsubscribed, otherwise false

on

  • on(name: string, callback: (...args: any[]) => void): number
  • Subscribes the callback function to the given event name.

    Parameters

    • name: string
    • callback: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns number

    The id of the event

once

  • once(name: string, callback: (...args: any[]) => void): void
  • Subscribes the callback function to the given event name for one time.

    Parameters

    • name: string
    • callback: (...args: any[]) => void
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns void

removeBody

  • removeBody(...bodies: Body<any>[]): void
  • Removes the given bodies from the world.

    Parameters

    • Rest ...bodies: Body<any>[]

    Returns void

removeJoint

  • removeJoint(...joints: Joint<any>[]): void
  • Removes the given joints from the world.

    Parameters

    • Rest ...joints: Joint<any>[]

    Returns void

trigger

  • trigger(name: string, args?: any[]): void
  • Triggers all the callbacks subscribed to the given name.

    Parameters

    • name: string
    • args: any[] = []

    Returns void

Generated using TypeDoc