Browse Source

AmmoPhysics: Reset angular and linear velocity in setMeshPosition.

Mr.doob 5 years ago
parent
commit
c761f3da24
1 changed files with 6 additions and 0 deletions
  1. 6 0
      examples/jsm/physics/AmmoPhysics.js

+ 6 - 0
examples/jsm/physics/AmmoPhysics.js

@@ -156,6 +156,9 @@ async function AmmoPhysics() {
 			const bodies = meshMap.get( mesh );
 			const bodies = meshMap.get( mesh );
 			const body = bodies[ index ];
 			const body = bodies[ index ];
 
 
+			body.setAngularVelocity( new AmmoLib.btVector3( 0, 0, 0 ) );
+			body.setLinearVelocity( new AmmoLib.btVector3( 0, 0, 0 ) );
+
 			worldTransform.setIdentity();
 			worldTransform.setIdentity();
 			worldTransform.setOrigin( new AmmoLib.btVector3( position.x, position.y, position.z ) );
 			worldTransform.setOrigin( new AmmoLib.btVector3( position.x, position.y, position.z ) );
 			body.setWorldTransform( worldTransform );
 			body.setWorldTransform( worldTransform );
@@ -164,6 +167,9 @@ async function AmmoPhysics() {
 
 
 			const body = meshMap.get( mesh );
 			const body = meshMap.get( mesh );
 
 
+			body.setAngularVelocity( new AmmoLib.btVector3( 0, 0, 0 ) );
+			body.setLinearVelocity( new AmmoLib.btVector3( 0, 0, 0 ) );
+
 			worldTransform.setIdentity();
 			worldTransform.setIdentity();
 			worldTransform.setOrigin( new AmmoLib.btVector3( position.x, position.y, position.z ) );
 			worldTransform.setOrigin( new AmmoLib.btVector3( position.x, position.y, position.z ) );
 			body.setWorldTransform( worldTransform );
 			body.setWorldTransform( worldTransform );