npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@d-pollard/planck

v1.0.5

Published

2D JavaScript/TypeScript physics engine for cross-platform HTML5 game development

Downloads

7

Readme

Planck.js

Planck.js is JavaScript (TypeScript) rewrite of Box2D physics engine for cross-platform HTML5 game development.

Motivations

  • Taking advantage of Box2D's efforts and achievements
  • Developing readable and maintainable JavaScript code
  • Optimizing the library for web and mobile platforms
  • Providing a JavaScript-friendly API

Documentation

Community

API and Architecture

Planck.js includes Box2D algorithms without modification and its architecture is very similar to Box2D. However some internal changes and refactoring are made during rewrite to address differences between C++ and JavaScript.

Planck.js public API closely follows Box2D API, with the following differences:

  • b2 prefix is dropped from class names, for example b2World is now available as planck.World.
  • Method names are converted from UpperCamelCase to lowerCamelCase.
  • Definition classes/objects (BodyDef, FixtureDef, etc.) are replaced by inline JavaScript objects ({}).
  • Shapes are considered immutable and are not cloned when used to create fixtures.
  • Contact filtering can be customized by overriding shouldCollide method of Fixture.
  • Listener classes are replaced with simple functions.
  • World#on(eventName, listenerFn) and World#off(eventName, listenerFn) are added to add and remove event listeners. Currently supported events are: 'begin-contact', 'end-contact', 'pre-solve', 'post-solve', 'remove-joint', 'remove-fixture', 'remove-body'

Updates

v1.0-alpha

  • Source code is migrated to TypeScript, to improves library usability, documentation and maintenance.

  • Package name for v1.0+ is changed to planck. Package name for releases before v1.0 is planck-js.

  • planck.internal namespace is deprecated and everything is directly available under main namesapce (except planck.internal.stats).

  • Source files are moved to /src directory (from /lib) and directory layout is updated to match Box2D.

  • Rollup is used to build the project.

Install

v0.3 (stable release)

To install [email protected] (stable release) see v0.3 branch.

v1.0 (alpha)

Staring from v1.0 package name is changed to planck. Releases and updates before v1.0 will remain available under planck-js.

CDN

Planck.js is available on jsDelivr.

NPM

Install npm package.

npm install planck

Import it in your code.

import * as planck from 'planck';
Testbed

Use CDN in a web page.

<html><body>
  <script src="//cdn.jsdelivr.net/npm/planck@latest/dist/planck-with-testbed.min.js"></script>
  <script>
    planck.testbed(function(testbed) {
      // Your testbed code
    });
  </script>
</body></html>

Use NPM package in Node.

const planck = require('planck/dist/planck-with-testbed');

planck.testbed(function() {
  // ...
});

Projects

Games

Dynamic Visualization

Science and AI

Game Development

Credits

Box2D is a popular C++ 2D rigid-body physics engine created by Erin Catto. Box2D is used in several popular games, such as Angry Birds, Limbo and Crayon Physics, as well as game development tools and libraries such as Apple's SpriteKit.

Planck.js is developed and maintained by Ali Shakiba.

TypeScript definitions for planck.js are developed by Oliver Zell.

License

Planck.js is available under the MIT license.