Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lucy-b2

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lucy-b2

2D physics (Box2D with liquidfun particles).

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

Lucy b2 Build Status

Box2D by Erin Catto with google's particle simulation liquidfun for node.js.

This fork

Fork from box2d.js.

Due to the fact that we are not creating sub-classes of C++ classes, we do not need to use 'b2' prefix to separate namespaces so this prefix has been removed.

// Instead of writing box2d.b2Vec2
// Write this:
const b2 = require ( 'lucy-b2' )
let gravity = new b2.Vec2  ( 0, -9.8 )
let world   = new b2.World ( gravity )
// ...
let shape = new b2.PolygonShape

Documentation

Example

Here is a falling ball simulation.

'use strict'
const b2 = require ( 'lucy-b2' )

// Create world
let gravity = new b2.Vec2  ( 0, -9.8 )
let world   = new b2.World ( gravity )

// Define body
let bodyDef = new b2.BodyDef
bodyDef.type = b2.BodyType.dynamicBody

// Create body with definition
let body = world.CreateBody ( bodyDef )

// Define fixture
let fixDef = new b2.FixtureDef
fixDef.density     = 1.0
fixDef.friction    = 0.2
fixDef.restitution = 0.8

let shape = new b2.PolygonShape
shape.SetAsBox ( 0.1, 0.1 )

fixDef.shape = shape

// Create fixture
body.CreateFixture ( fixDef )

// Move body into initial position ( and rotation )
body.SetTransform ( 0, 2, 0 )

// Run simulation
for ( let i = 0; i < 10; i++ )
{ world.Step ( 1/60, 10, 10 )
  console.log ( body.GetPosition ().y )
}

Installation

npm install lucy-b2 --save

Tests

npm test

Contributing

Please see box2d.js for contributions. The port from this library is just a few Regexp executed on the minified JS version and a wrapper for node.js.

Please use 'jessy style' if you want to write some unit tests for lucy-b2...

Release History

  • 1.0.1 (2015-09-22) Fixed readme.
  • 1.0.0 (2015-09-09) Initial release.

Keywords

FAQs

Package last updated on 22 Sep 2015

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