소스 검색

ammoJS support get friction and restitution

Trevor Baron 6 년 전
부모
커밋
4c8b8cddf0
2개의 변경된 파일7개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 1
      dist/preview release/what's new.md
  2. 6 3
      src/Physics/Plugins/babylon.ammoJSPlugin.ts

+ 1 - 1
dist/preview release/what's new.md

@@ -6,7 +6,7 @@
 - [Inspector v2.0](https://doc.babylonjs.com/features/playground_debuglayer). [Dev log](https://medium.com/@babylonjs/dev-log-creating-the-new-inspector-b15c50900205) ([Deltakosh](https://github.com/deltakosh))
 - Added support for [parallel shader compilation](https://www.khronos.org/registry/webgl/extensions/KHR_parallel_shader_compile/) ([Deltakosh](https://github.com/deltakosh))
 - Added [Object Based Motion Blur](http://doc.babylonjs.com/how_to/using_motionblurpostprocess) post-process ([julien-moreau](https://github.com/julien-moreau))
-- Added [support for AmmoJS](https://doc.babylonjs.com/how_to/using_the_physics_engine) as a physics plugin (Composite objects, joints, motors) ([TrevorDev](https://github.com/TrevorDev))
+- Added [support for AmmoJS](https://doc.babylonjs.com/how_to/using_the_physics_engine) as a physics plugin (Composite objects, motors, joints) ([TrevorDev](https://github.com/TrevorDev))
 - Added support for [WebXR](https://doc.babylonjs.com/how_to/webxr) ([TrevorDev](https://github.com/TrevorDev))
   - Add customAnimationFrameRequester to allow sessions to hook into engine's render loop ([TrevorDev](https://github.com/TrevorDev))
   - camera customDefaultRenderTarget to allow cameras to render to a custom render target (eg. xr framebuffer) instead of the canvas ([TrevorDev](https://github.com/TrevorDev))

+ 6 - 3
src/Physics/Plugins/babylon.ammoJSPlugin.ts

@@ -263,9 +263,10 @@ module BABYLON {
                     body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
                 }
 
-                body.setRestitution(impostor.getParam("restitution"));
                 this.world.addRigidBody(body);
                 impostor.physicsBody = body;
+                this.setBodyRestitution(impostor, impostor.getParam("restitution"));
+                this.setBodyFriction(impostor, impostor.getParam("friction"));
 
                 impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
             }
@@ -611,7 +612,7 @@ module BABYLON {
          * @returns friction value
          */
         public getBodyFriction(impostor: PhysicsImpostor): number {
-            return impostor.physicsBody.getFriction();
+            return impostor._pluginData.friction;
         }
 
         /**
@@ -621,6 +622,7 @@ module BABYLON {
          */
         public setBodyFriction(impostor: PhysicsImpostor, friction: number) {
             impostor.physicsBody.setFriction(friction);
+            impostor._pluginData.friction = friction;
         }
 
         /**
@@ -629,7 +631,7 @@ module BABYLON {
          * @returns restitution value
          */
         public getBodyRestitution(impostor: PhysicsImpostor): number {
-            return impostor.physicsBody.getRestitution();
+            return impostor._pluginData.restitution;
         }
 
         /**
@@ -639,6 +641,7 @@ module BABYLON {
          */
         public setBodyRestitution(impostor: PhysicsImpostor, restitution: number) {
             impostor.physicsBody.setRestitution(restitution);
+            impostor._pluginData.restitution = restitution;
         }
 
         /**