GithubHelp home page GithubHelp logo

box2d-native's Introduction

Build Status

box2d-native

Box2D v2.3.1 as native Node.js addon.

Details

Box2D compiled as static library, Node.js C++ addon produced by swig.

Install

Requires curl, make, cmake, g++. See also requirements for building swig and node-gyp

Install with NPM:

npm install node-gyp -g
npm install box2d-native

IMPORTANT: Installation tested only on Linux with Node.js >= 4.2.1 and gc++ 4.9.

Usage

import {World, Vec2, BodyDef, Body} from 'box2d-native';

let world = new World(gravity);
let body = world.CreateBody(new BodyDef());

world.Step(1 / 60, 3, 3);

Original "namespaced" Box2D classes (b2Vec2, b2World...) are also exposed.

Demo

IMPORTANT: Runs only with Node.js v4.2.1

npm install node-gyp -g
git checkout https://github.com/zuker/box2d-native.git
cd box2d-native/demo
npm install
npm start

Performance

Results from bench2d (i7 2.9GHZ, 4GB RAM, Ubuntu 15.04):

  • box2d.js: ms/frame: 3.5537109375 5th %ile: 3 95th %ile: 4

  • box2d-native: ms/frame: 1.689453125 5th %ile: 1 95th %ile: 2

TODO

  • Improve demo (implement all stuff from C++ Box2D testbed).
  • Refactor build, use more convenient tool.
  • Provide more benchmark results to compare with.
  • Tests.

box2d-native's People

Contributors

zuker avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.