Coder Social home page Coder Social logo

devhang / oimo.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lo-th/oimo.js

0.0 1.0 0.0 31.13 MB

Lightweight 3d physics engine for javascript

Home Page: http://lo-th.github.io/Oimo.js

License: MIT License

JavaScript 99.81% HTML 0.19%

oimo.js's Introduction


Oimo.js is a lightweight 3d physics engine for JavaScript.
It's a full javascript conversion of OimoPhysics
Originally created by Saharan for actionscript 3.0.
Version Version

Home

Docs

  • docs (in progress)

Demo

Usage

Download the minified library and include it in your HTML.
Alternatively, use Node and install the package: npm install oimo

<script src="js/oimo.min.js"></script>

Create physics world:

world = new OIMO.World({ 
    timestep: 1/60, 
    iterations: 8, 
    broadphase: 2, // 1 brute force, 2 sweep and prune, 3 volume tree
    worldscale: 1, // scale full world 
    random: true,  // randomize sample
    info: false,   // calculate statistic or not
    gravity: [0,-9.8,0] 
});

Add physics object or joint

var body = world.add({ 
    type:'sphere', // type of shape : sphere, box, cylinder 
    size:[1,1,1], // size of shape
    pos:[0,0,0], // start position in degree
    rot:[0,0,90], // start rotation in degree
    move:true, // dynamic or statique
    density: 1,
    friction: 0.2,
    restitution: 0.2,
    belongsTo: 1, // The bits of the collision groups to which the shape belongs.
    collidesWith: 0xffffffff; // The bits of the collision groups with which the shape collides.
});

var body = world.add({ 
    type:'jointHinge', // type of joint : jointDistance, jointHinge, jointPrisme, jointSlide, jointWheel
    body1: "b1", // name or id of attach rigidbody
    body2: "b1", // name or id of attach rigidbody
});


// update world
world.step();

// and copy position and rotation to three mesh
myMesh.position.copy( body.getPosition() );
myMesh.quaternion.copy( body.getQuaternion() );

Note

Oimo Physics uses international system units: 0.1 to 10 meters max for dynamic body.
In basic demo with THREE, I scaled all by 100 so objects are between 10 to 1000 in THREE units.

/!\ Shape name change in last version
SphereShape to Sphere, BoxShape to Box, CylinderShape to Cylinder

oimo.js's People

Contributors

lo-th avatar positlabs avatar akiyah avatar davidlyons avatar sufuf3 avatar raananw avatar oakes avatar

Watchers

 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.