LittleJS 1.27.0

Box2D

LittleJS Box2D Physics Plugin

  • Box2dObject extends EngineObject with Box2D physics
  • Call box2dInit() to enable
  • You will also need to include box2d.wasm.js
  • Uses a super fast web assembly port of Box2D v2.3.1
  • More info: https://github.com/kripken/box2d.js
  • Functions to create polygon, circle, and edge shapes
  • Contact begin and end callbacks
  • Wraps b2Vec2 type to/from Vector2
  • Raycasting and querying
  • Box2dTileLayer for grid based collision
  • Every type of joint
  • Debug physics drawing
  • Box2D works per second: its velocities and accelerations are in units per second, and it reads the engine's gravity as units per second squared, where an EngineObject's are per frame

Classes

Functions

Members

Functions

box2dInit() → Promise<Box2dPlugin>asyncbox2d.js:2496

Box2d Init - Call with await to init box2d

await box2dInit();
box2dSetDebug(enable)box2d.js:151

Enable Box2D debug drawing

enable boolean

Members

Global Box2d Plugin object

box2dDebug : boolean default falsebox2d.js:31

Enable Box2D debug drawing