<commit_before># cannon.js - a lightweight 3D physics engine for the web

<a href="http://schteppe.github.com/cannon.js"> Click here for examples >><br><img src="http://granular.cs.umu.se/browserphysics/wp-content/uploads/2012/01/myphysicslib_javascript.png" width="300"></a>

Inspired by [three.js](https://github.com/mrdoob/three.js) and [ammo.js](https://github.com/kripken/ammo.js), and driven by the fact that the web lacks a physics engine, here comes cannon.js.

## Features

* Lightweight - less than 40Kb compressed. For comparison: [ammo.js](https://github.com/kripken/ammo.js/) uses 1.12Mb when compressed.
* Supports solid spheres and static planes at the moment - soon also boxes
* 100% open source JavaScript, written from scratch
* Uses typed arrays for [fast number crunching](http://granular.cs.umu.se/browserphysics/?p=729)
* Uses an iterative Gauss-Seidel solver to solve generic constraints
* Uses [SPOOK](https://www8.cs.umu.se/kurser/5DV058/VT09/lectures/spooknotes.pdf) for time stepping

## Example
    // Setup our world
    var world = new CANNON.World();
    world.gravity(new CANNON.Vec3(0,0,-50));
    var bp = new CANNON.BroadPhase();
    world.broadphase(bp);
    
    // Create a plane
    var plane = new CANNON.Plane(new CANNON.Vec3(0,0,0), new CANNON.Vec3(0,0,1));
    world.add(plane);
    
    // Create a sphere
    var sphere = new CANNON.Sphere(new CANNON.Vec3(0,0,2),1,5);
    world.add(sphere);
    
    // Step the simulation
    setInterval(function(){
      world.step(1.0/60.0);
    }, 1000.0/60.0);

<commit_msg>Added syntax highlighting to example.<commit_after># cannon.js - a lightweight 3D physics engine for the web

<a href="http://schteppe.github.com/cannon.js"> Click here for examples >><br><img src="http://granular.cs.umu.se/browserphysics/wp-content/uploads/2012/01/myphysicslib_javascript.png" width="300"></a>

Inspired by [three.js](https://github.com/mrdoob/three.js) and [ammo.js](https://github.com/kripken/ammo.js), and driven by the fact that the web lacks a physics engine, here comes cannon.js.

## Features

* Lightweight - less than 40Kb compressed. For comparison: [ammo.js](https://github.com/kripken/ammo.js/) uses 1.12Mb when compressed.
* Supports solid spheres and static planes at the moment - soon also boxes
* 100% open source JavaScript, written from scratch
* Uses typed arrays for [fast number crunching](http://granular.cs.umu.se/browserphysics/?p=729)
* Uses an iterative Gauss-Seidel solver to solve generic constraints
* Uses [SPOOK](https://www8.cs.umu.se/kurser/5DV058/VT09/lectures/spooknotes.pdf) for time stepping

## Example

```javascript
// Setup our world
var world = new CANNON.World();
world.gravity(new CANNON.Vec3(0,0,-50));
var bp = new CANNON.BroadPhase();
world.broadphase(bp);
    
// Create a plane
var plane = new CANNON.Plane(new CANNON.Vec3(0,0,0), new CANNON.Vec3(0,0,1));
world.add(plane);
    
// Create a sphere
var sphere = new CANNON.Sphere(new CANNON.Vec3(0,0,2),1,5);
world.add(sphere);
    
// Step the simulation
setInterval(function(){
  world.step(1.0/60.0);
}, 1000.0/60.0);
```

{'fraction_non_alphanumeric': 0.1461290322580645, 'fraction_numerical': 0.03870967741935484, 'mean_word_length': 4.034090909090909, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '754557', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1049, 'n_words': 271}