Socket
Socket
Sign inDemoInstall

planck-js

Package Overview
Dependencies
Maintainers
2
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

planck-js

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


Version published
Weekly downloads
500
increased by31.58%
Maintainers
2
Weekly downloads
 
Created
Source

Planck.js

Planck.js is JavaScript 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

  • Documentation Wiki - This is the best place to start, and find other resources
  • Examples - Online examples with editable code

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'

Install

v0.3 (stable release)

Package name for v0.3 is planck-js.

CDN

The library is available on jsDelivr.

NPM

Install NPM package.

npm install planck-js --save

Use core library.

const planck = require('planck-js');
Testbed

Use CDN in a web page.

<html><body>
  <script src="//cdn.jsdelivr.net/npm/planck-js@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-js/dist/planck-with-testbed');

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

v1.0 (alpha)

Staring from v1.0 package name is changed to planck. To install v1.0 see master branch.

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.

Keywords

FAQs

Package last updated on 11 May 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc