@footgun/planck
v0.2.3
Published
2D JavaScript/TypeScript physics engine for cross-platform HTML5 game development
Downloads
304
Maintainers
Readme
@footgun/planck
This is an independently maintained fork of Planck.js at v1.0.6
Why the fork?
There are 2 main reasons:
- Use array notation for Vectors instead of Objects.
- Vectors should be pure data, rather than having every single vector instance a class with dozens of methods attached.
Planck way:
import { Vec2 } from 'planck'
const p = new Vec2(50, 50) // generates an Object Oriented monstrosity
console.log(p) // { x: 50, y: 50, ...pile o' functions }
I use array notation in my projects, so I want to declare vectors like this:
import { Vec2 } from '@footgun/planck'
const p = Vec2.create(50, 50) // generates pure data
console.log(p) // [ 50, 50 ] A nice simple array. You know, like, data. :)
These 2 changes make it possible to re-use other popular libraries for vector/matrix math.
Vectors produced by gl-matrix
and wgpu-matrix
are fully interoperable with this physics engine.
References
You can find the original library here.
All of the same examples and documentation should be the same for this port,
except for constructing Vec2
and Vec3
instances.
For a fantastic, compatible Vector/Matrix/Math library check out wgpu-matrix