未验证 提交 b2a8cd42 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #16100 from yomboprime/update_ammo

Update Ammo.js to current version
此差异已折叠。
......@@ -59,8 +59,15 @@
var clock = new THREE.Clock();
init();
animate();
Ammo().then( function( AmmoLib ) {
Ammo = AmmoLib;
init();
animate();
} );
function init() {
......
......@@ -60,8 +60,14 @@
var clock = new THREE.Clock();
init();
animate();
Ammo().then( function( AmmoLib ) {
Ammo = AmmoLib;
init();
animate();
} );
function init() {
......
......@@ -57,8 +57,14 @@
var vpds = [];
init();
animate();
Ammo().then( function( AmmoLib ) {
Ammo = AmmoLib;
init();
animate();
} );
function init() {
......
......@@ -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 );
};
}();
}();
} );
//
......
......@@ -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() {
......@@ -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() {
......
......@@ -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;
......@@ -96,8 +96,14 @@
// - Main code -
init();
animate();
Ammo().then( function( AmmoLib ) {
Ammo = AmmoLib;
init();
animate();
} );
// - Functions -
......@@ -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 ) {
......
......@@ -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() {
......@@ -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() {
......
......@@ -68,7 +68,7 @@
var solver;
var physicsWorld;
var dynamicObjects = [];
var transformAux1 = new Ammo.btTransform();
var transformAux1;
var heightData = null;
var ammoHeightData = null;
......@@ -78,8 +78,14 @@
var timeNextSpawn = time + objectTimePeriod;
var maxNumObjects = 30;
init();
animate();
Ammo().then( function( AmmoLib ) {
Ammo = AmmoLib;
init();
animate();
} );
function init() {
......@@ -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 ) {
......
......@@ -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() {
......@@ -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() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册