Przeglądaj źródła

rollback js files

gleborgne 9 lat temu
rodzic
commit
583b481cb1

+ 0 - 39
src/Physics/Plugins/babylon.cannonJSPlugin.js

@@ -162,7 +162,6 @@ var BABYLON;
             }*/
             }*/
             switch (impostorJoint.joint.type) {
             switch (impostorJoint.joint.type) {
                 case BABYLON.PhysicsJoint.HingeJoint:
                 case BABYLON.PhysicsJoint.HingeJoint:
-                case BABYLON.PhysicsJoint.Hinge2Joint:
                     constraint = new CANNON.HingeConstraint(mainBody, connectedBody, constraintData);
                     constraint = new CANNON.HingeConstraint(mainBody, connectedBody, constraintData);
                     break;
                     break;
                 case BABYLON.PhysicsJoint.DistanceJoint:
                 case BABYLON.PhysicsJoint.DistanceJoint:
@@ -372,18 +371,6 @@ var BABYLON;
         CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
         CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
             impostor.physicsBody.angularVelocity.copy(velocity);
             impostor.physicsBody.angularVelocity.copy(velocity);
         };
         };
-        CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
-            var v = impostor.physicsBody.velocity;
-            if (!v)
-                return null;
-            return new BABYLON.Vector3(v.x, v.y, v.z);
-        };
-        CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
-            var v = impostor.physicsBody.angularVelocity;
-            if (!v)
-                return null;
-            return new BABYLON.Vector3(v.x, v.y, v.z);
-        };
         CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
         CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
             impostor.physicsBody.mass = mass;
             impostor.physicsBody.mass = mass;
             impostor.physicsBody.updateMassProperties();
             impostor.physicsBody.updateMassProperties();
@@ -394,32 +381,6 @@ var BABYLON;
         CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
         CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
             impostor.physicsBody.wakeUp();
             impostor.physicsBody.wakeUp();
         };
         };
-        CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
-            joint.physicsJoint.distance = maxDistance;
-        };
-        CannonJSPlugin.prototype.enableMotor = function (joint, motorIndex) {
-            if (!motorIndex) {
-                joint.physicsJoint.enableMotor();
-            }
-        };
-        CannonJSPlugin.prototype.disableMotor = function (joint, motorIndex) {
-            if (!motorIndex) {
-                joint.physicsJoint.disableMotor();
-            }
-        };
-        CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
-            if (!motorIndex) {
-                joint.physicsJoint.enableMotor();
-                joint.physicsJoint.setMotorSpeed(speed);
-                if (maxForce) {
-                    this.setLimit(joint, maxForce);
-                }
-            }
-        };
-        CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
-            joint.physicsJoint.motorEquation.maxForce = upperLimit;
-            joint.physicsJoint.motorEquation.minForce = lowerLimit || -upperLimit;
-        };
         CannonJSPlugin.prototype.dispose = function () {
         CannonJSPlugin.prototype.dispose = function () {
             //nothing to do, actually.
             //nothing to do, actually.
         };
         };

+ 0 - 30
src/Physics/Plugins/babylon.oimoJSPlugin.js

@@ -264,18 +264,6 @@ var BABYLON;
         OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
         OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
             impostor.physicsBody.angularVelocity.init(velocity.x, velocity.y, velocity.z);
             impostor.physicsBody.angularVelocity.init(velocity.x, velocity.y, velocity.z);
         };
         };
-        OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
-            var v = impostor.physicsBody.linearVelocity;
-            if (!v)
-                return null;
-            return new BABYLON.Vector3(v.x, v.y, v.z);
-        };
-        OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
-            var v = impostor.physicsBody.angularVelocity;
-            if (!v)
-                return null;
-            return new BABYLON.Vector3(v.x, v.y, v.z);
-        };
         OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
         OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
             var staticBody = mass === 0;
             var staticBody = mass === 0;
             //this will actually set the body's density and not its mass.
             //this will actually set the body's density and not its mass.
@@ -289,24 +277,6 @@ var BABYLON;
         OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
         OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
             impostor.physicsBody.awake();
             impostor.physicsBody.awake();
         };
         };
-        OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
-            joint.physicsJoint.limitMotoe.upperLimit = maxDistance;
-            if (minDistance !== void 0) {
-                joint.physicsJoint.limitMotoe.lowerLimit = minDistance;
-            }
-        };
-        OimoJSPlugin.prototype.setMotor = function (joint, force, maxForce, motorIndex) {
-            var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.limitMotor;
-            if (motor) {
-                motor.setMotor(force, maxForce);
-            }
-        };
-        OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
-            var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.limitMotor;
-            if (motor) {
-                motor.setLimit(upperLimit, lowerLimit || -upperLimit);
-            }
-        };
         OimoJSPlugin.prototype.dispose = function () {
         OimoJSPlugin.prototype.dispose = function () {
             this.world.clear();
             this.world.clear();
         };
         };

+ 0 - 18
src/Physics/babylon.physicsEngine.js

@@ -24,7 +24,6 @@ var BABYLON;
          * default is 1/60.
          * default is 1/60.
          * To slow it down, enter 1/600 for example.
          * To slow it down, enter 1/600 for example.
          * To speed it up, 1/30
          * To speed it up, 1/30
-         * @param {number} newTimeStep the new timestep to apply to this world.
          */
          */
         PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
         PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
             if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
             if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
@@ -39,11 +38,6 @@ var BABYLON;
         PhysicsEngine.prototype.getPhysicsPluginName = function () {
         PhysicsEngine.prototype.getPhysicsPluginName = function () {
             return this._physicsPlugin.name;
             return this._physicsPlugin.name;
         };
         };
-        /**
-         * Adding a new impostor for the impostor tracking.
-         * This will be done by the impostor itself.
-         * @param {PhysicsImpostor} impostor the impostor to add
-         */
         PhysicsEngine.prototype.addImpostor = function (impostor) {
         PhysicsEngine.prototype.addImpostor = function (impostor) {
             this._impostors.push(impostor);
             this._impostors.push(impostor);
             //if no parent, generate the body
             //if no parent, generate the body
@@ -51,11 +45,6 @@ var BABYLON;
                 this._physicsPlugin.generatePhysicsBody(impostor);
                 this._physicsPlugin.generatePhysicsBody(impostor);
             }
             }
         };
         };
-        /**
-         * Remove an impostor from the engine.
-         * This impostor and its mesh will not longer be updated by the physics engine.
-         * @param {PhysicsImpostor} impostor the impostor to remove
-         */
         PhysicsEngine.prototype.removeImpostor = function (impostor) {
         PhysicsEngine.prototype.removeImpostor = function (impostor) {
             var index = this._impostors.indexOf(impostor);
             var index = this._impostors.indexOf(impostor);
             if (index > -1) {
             if (index > -1) {
@@ -67,19 +56,12 @@ var BABYLON;
                 }
                 }
             }
             }
         };
         };
-        /**
-         * Add a joint to the physics engine
-         * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
-         * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
-         * @param {PhysicsJoint} the joint that will connect both impostors.
-         */
         PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
         PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
             var impostorJoint = {
             var impostorJoint = {
                 mainImpostor: mainImpostor,
                 mainImpostor: mainImpostor,
                 connectedImpostor: connectedImpostor,
                 connectedImpostor: connectedImpostor,
                 joint: joint
                 joint: joint
             };
             };
-            joint.physicsPlugin = this._physicsPlugin;
             this._joints.push(impostorJoint);
             this._joints.push(impostorJoint);
             this._physicsPlugin.generateJoint(impostorJoint);
             this._physicsPlugin.generateJoint(impostorJoint);
         };
         };

+ 8 - 19
src/Physics/babylon.physicsImpostor.js

@@ -55,20 +55,15 @@ var BABYLON;
                     });
                     });
                 }
                 }
             };
             };
+            //default options params
+            this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
+            this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
+            this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
             this._physicsEngine = this._mesh.getScene().getPhysicsEngine();
             this._physicsEngine = this._mesh.getScene().getPhysicsEngine();
-            if (!this._physicsEngine) {
-                BABYLON.Tools.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
-            }
-            else {
-                //default options params
-                this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
-                this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
-                this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
-                this._joints = [];
-                //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
-                if (!this._mesh.parent) {
-                    this._init();
-                }
+            this._joints = [];
+            //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
+            if (!this._mesh.parent) {
+                this._init();
             }
             }
         }
         }
         /**
         /**
@@ -170,18 +165,12 @@ var BABYLON;
             }
             }
             this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
             this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
         };
         };
-        PhysicsImpostor.prototype.getLinearVelocity = function () {
-            return this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this);
-        };
         /**
         /**
          * Set the body's linear velocity.
          * Set the body's linear velocity.
          */
          */
         PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
         PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
             this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
             this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
         };
         };
-        PhysicsImpostor.prototype.getAngularVelocity = function () {
-            return this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this);
-        };
         /**
         /**
          * Set the body's linear velocity.
          * Set the body's linear velocity.
          */
          */

+ 1 - 102
src/Physics/babylon.physicsJoint.js

@@ -1,14 +1,5 @@
-var __extends = (this && this.__extends) || function (d, b) {
-    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
-    function __() { this.constructor = d; }
-    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
-};
 var BABYLON;
 var BABYLON;
 (function (BABYLON) {
 (function (BABYLON) {
-    /**
-     * This is a holder class for the physics joint created by the physics plugin.
-     * It holds a set of functions to control the underlying joint.
-     */
     var PhysicsJoint = (function () {
     var PhysicsJoint = (function () {
         function PhysicsJoint(type, jointData) {
         function PhysicsJoint(type, jointData) {
             this.type = type;
             this.type = type;
@@ -27,21 +18,6 @@ var BABYLON;
             enumerable: true,
             enumerable: true,
             configurable: true
             configurable: true
         });
         });
-        Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
-            set: function (physicsPlugin) {
-                this._physicsPlugin = physicsPlugin;
-            },
-            enumerable: true,
-            configurable: true
-        });
-        /**
-         * Execute a function that is physics-plugin specific.
-         * @param {Function} func the function that will be executed.
-         *                        It accepts two parameters: the physics world and the physics joint.
-         */
-        PhysicsJoint.prototype.executeNativeFunction = function (func) {
-            func(this._physicsPlugin.world, this._physicsJoint);
-        };
         //TODO check if the native joints are the same
         //TODO check if the native joints are the same
         //Joint Types
         //Joint Types
         PhysicsJoint.DistanceJoint = 0;
         PhysicsJoint.DistanceJoint = 0;
@@ -53,7 +29,7 @@ var BABYLON;
         PhysicsJoint.PrismaticJoint = 5;
         PhysicsJoint.PrismaticJoint = 5;
         //ENERGY FTW! (compare with this - http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
         //ENERGY FTW! (compare with this - http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
         PhysicsJoint.UniversalJoint = 6;
         PhysicsJoint.UniversalJoint = 6;
-        PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
+        PhysicsJoint.Hinge2Joint = 7;
         //Cannon
         //Cannon
         //Similar to a Ball-Joint. Different in params
         //Similar to a Ball-Joint. Different in params
         //TODO check!!
         //TODO check!!
@@ -63,81 +39,4 @@ var BABYLON;
         return PhysicsJoint;
         return PhysicsJoint;
     })();
     })();
     BABYLON.PhysicsJoint = PhysicsJoint;
     BABYLON.PhysicsJoint = PhysicsJoint;
-    /**
-     * A class representing a physics distance joint.
-     */
-    var DistanceJoint = (function (_super) {
-        __extends(DistanceJoint, _super);
-        function DistanceJoint(jointData) {
-            _super.call(this, PhysicsJoint.DistanceJoint, jointData);
-        }
-        /**
-         * Update the predefined distance.
-         */
-        DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
-            this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
-        };
-        return DistanceJoint;
-    })(PhysicsJoint);
-    BABYLON.DistanceJoint = DistanceJoint;
-    /**
-     * This class represents a single hinge physics joint
-     */
-    var HingeJoint = (function (_super) {
-        __extends(HingeJoint, _super);
-        function HingeJoint(jointData) {
-            _super.call(this, PhysicsJoint.HingeJoint, 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.
-         */
-        HingeJoint.prototype.setMotor = function (force, maxForce) {
-            this._physicsPlugin.setMotor(this, force, maxForce);
-        };
-        /**
-         * Set the motor's limits.
-         * Attention, this function is plugin specific. Engines won't react 100% the same.
-         */
-        HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
-            this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
-        };
-        return HingeJoint;
-    })(PhysicsJoint);
-    BABYLON.HingeJoint = HingeJoint;
-    /**
-     * This class represents a dual hinge physics joint (same as wheel joint)
-     */
-    var Hinge2Joint = (function (_super) {
-        __extends(Hinge2Joint, _super);
-        function Hinge2Joint(jointData) {
-            _super.call(this, PhysicsJoint.Hinge2Joint, 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.
-         * @param {motorIndex} the motor's index, 0 or 1.
-         */
-        Hinge2Joint.prototype.setMotor = function (force, maxForce, motorIndex) {
-            if (motorIndex === void 0) { motorIndex = 0; }
-            this._physicsPlugin.setMotor(this, force, maxForce, motorIndex);
-        };
-        /**
-         * Set the motor limits.
-         * Attention, this function is plugin specific. Engines won't react 100% the same.
-         * @param {number} upperLimit the upper limit
-         * @param {number} lowerLimit lower limit
-         * @param {motorIndex} the motor's index, 0 or 1.
-         */
-        Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
-            if (motorIndex === void 0) { motorIndex = 0; }
-            this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
-        };
-        return Hinge2Joint;
-    })(PhysicsJoint);
-    BABYLON.Hinge2Joint = Hinge2Joint;
 })(BABYLON || (BABYLON = {}));
 })(BABYLON || (BABYLON = {}));