• Stars
    star
    3,054
  • Rank 14,753 (Top 0.3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 11 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Lightweight 3d physics engine for javascript


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

UPDATE

Is time to switch ES6 worker version with the last OimoPhysics 1.2.2 :)
go to new PHY repro

More Repositories

1

3d.city

3d city builder game
JavaScript
1,544
star
2

uil

simple javascript ui
JavaScript
555
star
3

phy

Physics for three. Game engine
JavaScript
509
star
4

fullik

javascript fast iterative solver for Inverse Kinematics
JavaScript
356
star
5

neo

Ultimate timeline
JavaScript
282
star
6

Ammo.lab

Ammo.lab advanced 3d physics worker for three.js
JavaScript
266
star
7

Avatar.lab

Human avatar and animation for three.js
JavaScript
189
star
8

Shader.lab

Advanced shader for three.js
GLSL
107
star
9

Dedal.lab

advanced pathfinding
JavaScript
80
star
10

Liquid.lab

LiquidFun advanced 2d physics stuff
JavaScript
79
star
11

root

source factory & demo labs
JavaScript
72
star
12

Crowd.lab

Lightweight crowd simulation engine
JavaScript
66
star
13

olympe

sea3d exemple for three js
JavaScript
58
star
14

Turbulence

Universal mechanical linkage for representing the voluntary movements of nature animals
JavaScript
35
star
15

lab

main source for all my repro in .lab, with three.js, codemirror, and other...
JavaScript
25
star
16

Character-sea3d

Advanced Character tutorial with sea3d and three.js
JavaScript
19
star
17

Energy.lab

3d physics for three.js
JavaScript
17
star
18

terra

noise explorer
JavaScript
15
star
19

pi

game test html 5
JavaScript
13
star
20

sed

webgl nodes seriously effects editor
JavaScript
13
star
21

labs

personal portfolio - three advanced experiments
JavaScript
12
star
22

loth

sea3d three.js/away3d labs
ActionScript
11
star
23

hex

simplified lzma compactor for js script or all txt files
JavaScript
10
star
24

three.lab

extend test for three js
JavaScript
10
star
25

RAPT

and other game test
JavaScript
9
star
26

loth_labs

away3d experiment with AWD
ActionScript
6
star
27

crossed

minimal game test on all navigator
JavaScript
6
star
28

RadioWeb

webgl streaming shoutcast
JavaScript
2
star