Skip to content

Commit

Permalink
Update Ammo.js to current version
Browse files Browse the repository at this point in the history
  • Loading branch information
yomboprime committed Mar 29, 2019
1 parent d874602 commit 089ae05
Show file tree
Hide file tree
Showing 10 changed files with 766 additions and 77 deletions.
663 changes: 643 additions & 20 deletions examples/js/libs/ammo.js

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions examples/webgl_loader_mmd.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,15 @@

var clock = new THREE.Clock();

init();
animate();
Ammo().then( function( AmmoLib ) {

Ammo = AmmoLib;

init();
animate();

} );


function init() {

Expand Down
10 changes: 8 additions & 2 deletions examples/webgl_loader_mmd_audio.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@

var clock = new THREE.Clock();

init();
animate();
Ammo().then( function( AmmoLib ) {

Ammo = AmmoLib;

init();
animate();

} );

function init() {

Expand Down
10 changes: 8 additions & 2 deletions examples/webgl_loader_mmd_pose.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@

var vpds = [];

init();
animate();
Ammo().then( function( AmmoLib ) {

Ammo = AmmoLib;

init();
animate();

} );

function init() {

Expand Down
74 changes: 40 additions & 34 deletions examples/webgl_loader_sea3d_physics.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,68 +73,74 @@

var loader;

// Initialize Three.JS
Ammo().then( function( AmmoLib ) {

init();
// Initialize Three.JS

// Initialize Physics Engine
init();

SEA3D.AMMO.init();
// Initialize Physics Engine

//
// SEA3D Loader
//
Ammo = AmmoLib;
SEA3D.AMMO.init();

loader = new THREE.SEA3D( {
//
// SEA3D Loader
//

container: scene // Container to add models
loader = new THREE.SEA3D( {

} );
container: scene // Container to add models

loader.onComplete = function () {
} );

new THREE.OrbitControls( camera );
loader.onComplete = function () {

// events
new THREE.OrbitControls( camera );

window.addEventListener( 'contextmenu', function ( e ) {
// events

e.preventDefault();
window.addEventListener( 'contextmenu', function ( e ) {

cloneAsset();
e.preventDefault();

} );
cloneAsset();

// prevent material compilation in render loop
} );

renderer.compile( scene, camera );
// prevent material compilation in render loop

animate();
renderer.compile( scene, camera );

};
animate();

loader.load( './models/sea3d/car.tjs.sea' );
};

var cloneAsset = function () {
loader.load( './models/sea3d/car.tjs.sea' );

var offset = 0;
var cloneAsset = function () {

return function () {
var offset = 0;

var domain = this.loader.clone( { lights: false, runScripts: false, autoPlay: false, enabledPhysics: false } );
return function () {

offset -= 180;
var domain = this.loader.clone( { lights: false, runScripts: false, autoPlay: false, enabledPhysics: false } );

domain.container.position.x += offset;
domain.applyContainerTransform();
domain.enabledPhysics( true );
domain.runScripts();
offset -= 180;

this.scene.add( domain.container );
domain.container.position.x += offset;
domain.applyContainerTransform();
domain.enabledPhysics( true );
domain.runScripts();

};
this.scene.add( domain.container );

};

}();
}();


} );

//

Expand Down
14 changes: 11 additions & 3 deletions examples/webgl_physics_cloth.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,18 @@
var margin = 0.05;
var hinge;
var cloth;
var transformAux1 = new Ammo.btTransform();
var transformAux1;

var armMovement = 0;

init();
animate();
Ammo().then( function( AmmoLib ) {

Ammo = AmmoLib;

init();
animate();

} );


function init() {
Expand Down Expand Up @@ -148,6 +154,8 @@
physicsWorld.setGravity( new Ammo.btVector3( 0, gravityConstant, 0 ) );
physicsWorld.getWorldInfo().set_m_gravity( new Ammo.btVector3( 0, gravityConstant, 0 ) );

transformAux1 = new Ammo.btTransform();

}

function createObjects() {
Expand Down
16 changes: 12 additions & 4 deletions examples/webgl_physics_convex_break.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@

var pos = new THREE.Vector3();
var quat = new THREE.Quaternion();
var transformAux1 = new Ammo.btTransform();
var tempBtVec3_1 = new Ammo.btVector3( 0, 0, 0 );
var transformAux1;
var tempBtVec3_1;

var time = 0;

Expand All @@ -96,8 +96,14 @@

// - Main code -

init();
animate();
Ammo().then( function( AmmoLib ) {

Ammo = AmmoLib;

init();
animate();

} );


// - Functions -
Expand Down Expand Up @@ -183,6 +189,8 @@
physicsWorld = new Ammo.btDiscreteDynamicsWorld( dispatcher, broadphase, solver, collisionConfiguration );
physicsWorld.setGravity( new Ammo.btVector3( 0, - gravityConstant, 0 ) );

transformAux1 = new Ammo.btTransform();
tempBtVec3_1 = new Ammo.btVector3( 0, 0, 0 );
}

function createObject( mass, halfExtents, pos, quat, material ) {
Expand Down
14 changes: 11 additions & 3 deletions examples/webgl_physics_rope.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,18 @@
var margin = 0.05;
var hinge;
var rope;
var transformAux1 = new Ammo.btTransform();
var transformAux1;

var armMovement = 0;

init();
animate();
Ammo().then( function( AmmoLib ) {

Ammo = AmmoLib;

init();
animate();

} );

function init() {

Expand Down Expand Up @@ -153,6 +159,8 @@
physicsWorld.setGravity( new Ammo.btVector3( 0, gravityConstant, 0 ) );
physicsWorld.getWorldInfo().set_m_gravity( new Ammo.btVector3( 0, gravityConstant, 0 ) );

transformAux1 = new Ammo.btTransform();

}

function createObjects() {
Expand Down
14 changes: 11 additions & 3 deletions examples/webgl_physics_terrain.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
var solver;
var physicsWorld;
var dynamicObjects = [];
var transformAux1 = new Ammo.btTransform();
var transformAux1;

var heightData = null;
var ammoHeightData = null;
Expand All @@ -78,8 +78,14 @@
var timeNextSpawn = time + objectTimePeriod;
var maxNumObjects = 30;

init();
animate();
Ammo().then( function( AmmoLib ) {

Ammo = AmmoLib;

init();
animate();

} );

function init() {

Expand Down Expand Up @@ -210,6 +216,8 @@
var groundBody = new Ammo.btRigidBody( new Ammo.btRigidBodyConstructionInfo( groundMass, groundMotionState, groundShape, groundLocalInertia ) );
physicsWorld.addRigidBody( groundBody );

transformAux1 = new Ammo.btTransform();

}

function generateHeight( width, depth, minHeight, maxHeight ) {
Expand Down
17 changes: 13 additions & 4 deletions examples/webgl_physics_volume.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,17 @@
var rigidBodies = [];
var softBodies = [];
var margin = 0.05;
var transformAux1 = new Ammo.btTransform();
var softBodyHelpers = new Ammo.btSoftBodyHelpers();
var transformAux1;
var softBodyHelpers;

init();
animate();
Ammo().then( function( AmmoLib ) {

Ammo = AmmoLib;

init();
animate();

} );

function init() {

Expand Down Expand Up @@ -149,6 +155,9 @@
physicsWorld.setGravity( new Ammo.btVector3( 0, gravityConstant, 0 ) );
physicsWorld.getWorldInfo().set_m_gravity( new Ammo.btVector3( 0, gravityConstant, 0 ) );

transformAux1 = new Ammo.btTransform();
softBodyHelpers = new Ammo.btSoftBodyHelpers();

}

function createObjects() {
Expand Down

0 comments on commit 089ae05

Please sign in to comment.