瀏覽代碼

AmmoPhysics: Reset angular and linear velocity in setMeshPosition.

Mr.doob 5 年之前
父節點
當前提交
c761f3da24
共有 1 個文件被更改,包括 6 次插入0 次删除
  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 body = bodies[ index ];
 
+			body.setAngularVelocity( new AmmoLib.btVector3( 0, 0, 0 ) );
+			body.setLinearVelocity( new AmmoLib.btVector3( 0, 0, 0 ) );
+
 			worldTransform.setIdentity();
 			worldTransform.setOrigin( new AmmoLib.btVector3( position.x, position.y, position.z ) );
 			body.setWorldTransform( worldTransform );
@@ -164,6 +167,9 @@ async function AmmoPhysics() {
 
 			const body = meshMap.get( mesh );
 
+			body.setAngularVelocity( new AmmoLib.btVector3( 0, 0, 0 ) );
+			body.setLinearVelocity( new AmmoLib.btVector3( 0, 0, 0 ) );
+
 			worldTransform.setIdentity();
 			worldTransform.setOrigin( new AmmoLib.btVector3( position.x, position.y, position.z ) );
 			body.setWorldTransform( worldTransform );