Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Javascript 3D Physics Snippet One
<meta charset="utf-8">
<title>JS 3D Physics</title>
body { margin: 0; }
<script src="js/three.js"></script>
<script src="js/ammo.js"></script>
//variable declaration
let physicsWorld;
//Ammojs Initialization
Ammo().then( start )
function start(){
function setupPhysicsWorld(){
let collisionConfiguration = new Ammo.btDefaultCollisionConfiguration(),
dispatcher = new Ammo.btCollisionDispatcher(collisionConfiguration),
overlappingPairCache = new Ammo.btDbvtBroadphase(),
solver = new Ammo.btSequentialImpulseConstraintSolver();
physicsWorld = new Ammo.btDiscreteDynamicsWorld(dispatcher, overlappingPairCache, solver, collisionConfiguration);
physicsWorld.setGravity(new Ammo.btVector3(0, -10, 0));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment