@footgun/planck
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

@footgun/planck

This is an independently maintained fork of Planck.js at v1.0.6

Why the fork?

There are 2 main reasons:

  1. Use array notation for Vectors instead of Objects.
  2. 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

Package Sidebar

Install

npm i @footgun/planck

Weekly Downloads

0

Version

0.2.3

License

MIT

Unpacked Size

3.05 MB

Total Files

9

Last publish

Collaborators

  • mreinstein