Просмотр исходного кода

Fix for cannon material init

No contact materials are used. Each impostor has its unique material
that defines the friction and restitution.
Raanan Weber 10 лет назад
Родитель
Сommit
ad4128cfb5
1 измененных файлов с 5 добавлено и 11 удалено
  1. 5 11
      src/Physics/Plugins/babylon.cannonJSPlugin.ts

+ 5 - 11
src/Physics/Plugins/babylon.cannonJSPlugin.ts

@@ -68,7 +68,7 @@
                 }
                 
                 //create the body and material
-                var material = this._addMaterial(impostor.getParam("friction"), impostor.getParam("restitution"));
+                var material = this._addMaterial("mat-" + impostor.mesh.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
 
                 var bodyCreationObject = {
                     mass: impostor.getParam("mass"),
@@ -184,7 +184,7 @@
             //TODO
         }
 
-        private _addMaterial(friction: number, restitution: number) {
+        private _addMaterial(name: string, friction: number, restitution: number) {
             var index;
             var mat;
 
@@ -197,16 +197,10 @@
             }
 
             var currentMat = new CANNON.Material("mat");
+            currentMat.friction = friction;
+            currentMat.restitution = restitution;
+            
             this._physicsMaterials.push(currentMat);
-
-            for (index = 0; index < this._physicsMaterials.length; index++) {
-                mat = this._physicsMaterials[index];
-
-                var contactMaterial = new CANNON.ContactMaterial(mat, currentMat, { friction: friction, restitution: restitution });
-
-                this.world.addContactMaterial(contactMaterial);
-            }
-
             return currentMat;
         }