فهرست منبع

Adding MotorEnabledJoint to allow different joints to have motor functionality

SliderJoint is an example.
Raanan Weber 10 سال پیش
والد
کامیت
54636fc19b
1فایلهای تغییر یافته به همراه27 افزوده شده و 2 حذف شده
  1. 27 2
      src/Physics/babylon.physicsJoint.ts

+ 27 - 2
src/Physics/babylon.physicsJoint.ts

@@ -86,11 +86,36 @@ module BABYLON {
             this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
             this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
         }
         }
     }
     }
+    
+    export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
+        
+        constructor(type: number, jointData:PhysicsJointData) {
+            super(type, jointData);
+        }
+        
+        /**
+         * Set the motor values.
+         * Attention, this function is plugin specific. Engines won't react 100% the same.
+         * @param {number} force the force to apply
+         * @param {number} maxForce max force for this motor.
+         */
+        public setMotor(force?: number, maxForce?: number) {
+            this._physicsPlugin.setMotor(this, force, maxForce);
+        }
+        
+        /**
+         * Set the motor's limits.
+         * Attention, this function is plugin specific. Engines won't react 100% the same.
+         */
+        public setLimit(upperLimit: number, lowerLimit?: number) {
+            this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
+        }
+    }
 
 
     /**
     /**
      * This class represents a single hinge physics joint
      * This class represents a single hinge physics joint
      */
      */
-    export class HingeJoint extends PhysicsJoint implements IMotorEnabledJoint {
+    export class HingeJoint extends MotorEnabledJoint {
         
         
         constructor(jointData:PhysicsJointData) {
         constructor(jointData:PhysicsJointData) {
             super(PhysicsJoint.HingeJoint, jointData);
             super(PhysicsJoint.HingeJoint, jointData);
@@ -118,7 +143,7 @@ module BABYLON {
     /**
     /**
      * This class represents a dual hinge physics joint (same as wheel joint)
      * This class represents a dual hinge physics joint (same as wheel joint)
      */
      */
-    export class Hinge2Joint extends PhysicsJoint implements IMotorEnabledJoint {
+    export class Hinge2Joint extends MotorEnabledJoint {
         
         
         constructor(jointData:PhysicsJointData) {
         constructor(jointData:PhysicsJointData) {
             super(PhysicsJoint.Hinge2Joint, jointData);
             super(PhysicsJoint.Hinge2Joint, jointData);