<commit_before>module BABYLON {

    export interface PhysicsJointData {
        //Important for some engines, optional!
        mainPivot?: Vector3;
        connectedPivot?: Vector3;
        mainAxis?: Vector3,
        connectedAxis?: Vector3,
        collision?: boolean
        //Native Oimo/Cannon/Energy data
        nativeParams?: any;
    }

    /**
     * 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.
     */
    export class PhysicsJoint {

        private _physicsJoint: any;
        protected _physicsPlugin: IPhysicsEnginePlugin;

        constructor(public type: number, public jointData: PhysicsJointData) {
            jointData.nativeParams = jointData.nativeParams || {};
        }

        public get physicsJoint(): any {
            return this._physicsJoint;
        }

        public set physicsJoint(newJoint: any) {

            if (this._physicsJoint) {
                //remove from the wolrd
            }

            this._physicsJoint = newJoint;
        }

        public set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin) {
            this._physicsPlugin = physicsPlugin;
        }

        /**
         * 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.
         */
        public executeNativeFunction(func: (world: any, physicsJoint: any) => void) {
            func(this._physicsPlugin.world, this._physicsJoint)
        }


        //TODO check if the native joints are the same

        //Joint Types
        public static DistanceJoint = 0;
        public static HingeJoint = 1;
        public static BallAndSocketJoint = 2;
        public static WheelJoint = 3;
        public static SliderJoint = 4;
        //OIMO
        public static PrismaticJoint = 5;
        //ENERGY FTW! (compare with this - http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
        public static UniversalJoint = 6;
        public static Hinge2Joint = PhysicsJoint.WheelJoint;
        //Cannon
        //Similar to a Ball-Joint. Different in params
        public static PointToPointJoint = 8;
        //Cannon only at the moment
        public static SpringJoint = 9;
        public static LockJoint = 10;
    }

    /**
     * A class representing a physics distance joint.
     */
    export class DistanceJoint extends PhysicsJoint {
        constructor(jointData: DistanceJointData) {
            super(PhysicsJoint.DistanceJoint, jointData);
        }

        /**
         * Update the predefined distance.
         */
        public updateDistance(maxDistance: number, minDistance?: number) {
            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 || 0, 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
     */
    export class HingeJoint extends MotorEnabledJoint {

        constructor(jointData: PhysicsJointData) {
            super(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.
         */
        public setMotor(force?: number, maxForce?: number) {
            this._physicsPlugin.setMotor(this, force || 0, 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 dual hinge physics joint (same as wheel joint)
     */
    export class Hinge2Joint extends MotorEnabledJoint {

        constructor(jointData: PhysicsJointData) {
            super(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.
         */
        public setMotor(force?: number, maxForce?: number, motorIndex: number = 0) {
            this._physicsPlugin.setMotor(this, force || 0, 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.
         */
        public setLimit(upperLimit: number, lowerLimit?: number, motorIndex: number = 0) {
            this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
        }
    }

    export interface IMotorEnabledJoint {
        physicsJoint: any;
        setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
        setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
    }

    export interface DistanceJointData extends PhysicsJointData {
        maxDistance: number;
        //Oimo - minDistance
        //Cannon - maxForce
    }

    export interface SpringJointData extends PhysicsJointData {
        length: number;
        stiffness: number;
        damping: number;
        forceApplicationCallback: () => void;
    }
}<commit_msg>Update babylon.physicsJoint.ts<commit_after>module BABYLON {

    export interface PhysicsJointData {
        //Important for some engines, optional!
        mainPivot?: Vector3;
        connectedPivot?: Vector3;
        mainAxis?: Vector3,
        connectedAxis?: Vector3,
        collision?: boolean
        //Native Oimo/Cannon/Energy data
        nativeParams?: any;
    }

    /**
     * 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.
     */
    export class PhysicsJoint {

        private _physicsJoint: any;
        protected _physicsPlugin: IPhysicsEnginePlugin;

        constructor(public type: number, public jointData: PhysicsJointData) {
            jointData.nativeParams = jointData.nativeParams || {};
        }

        public get physicsJoint(): any {
            return this._physicsJoint;
        }

        public set physicsJoint(newJoint: any) {

            if (this._physicsJoint) {
                //remove from the wolrd
            }

            this._physicsJoint = newJoint;
        }

        public set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin) {
            this._physicsPlugin = physicsPlugin;
        }

        /**
         * 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.
         */
        public executeNativeFunction(func: (world: any, physicsJoint: any) => void) {
            func(this._physicsPlugin.world, this._physicsJoint)
        }


        //TODO check if the native joints are the same

        //Joint Types
        public static DistanceJoint = 0;
        public static HingeJoint = 1;
        public static BallAndSocketJoint = 2;
        public static WheelJoint = 3;
        public static SliderJoint = 4;
        //OIMO
        public static PrismaticJoint = 5;
        //ENERGY FTW! (compare with this - http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
        public static UniversalJoint = 6;
        public static Hinge2Joint = PhysicsJoint.WheelJoint;
        //Cannon
        //Similar to a Ball-Joint. Different in params
        public static PointToPointJoint = 8;
        //Cannon only at the moment
        public static SpringJoint = 9;
        public static LockJoint = 10;
    }

    /**
     * A class representing a physics distance joint.
     */
    export class DistanceJoint extends PhysicsJoint {
        constructor(jointData: DistanceJointData) {
            super(PhysicsJoint.DistanceJoint, jointData);
        }

        /**
         * Update the predefined distance.
         */
        public updateDistance(maxDistance: number, minDistance?: number) {
            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 || 0, 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
     */
    export class HingeJoint extends MotorEnabledJoint {

        constructor(jointData: PhysicsJointData) {
            super(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.
         */
        public setMotor(force?: number, maxForce?: number) {
            this._physicsPlugin.setMotor(this, force || 0, 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 dual hinge physics joint (same as wheel joint)
     */
    export class Hinge2Joint extends MotorEnabledJoint {

        constructor(jointData: PhysicsJointData) {
            super(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.
         */
        public setMotor(force?: number, maxForce?: number, motorIndex: number = 0) {
            this._physicsPlugin.setMotor(this, force || 0, 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.
         */
        public setLimit(upperLimit: number, lowerLimit?: number, motorIndex: number = 0) {
            this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
        }
    }

    export interface IMotorEnabledJoint {
        physicsJoint: any;
        setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
        setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
    }

    export interface DistanceJointData extends PhysicsJointData {
        maxDistance: number;
        //Oimo - minDistance
        //Cannon - maxForce
    }

    export interface SpringJointData extends PhysicsJointData {
        length: number;
        stiffness: number;
        damping: number;
        /* this callback will be called when applying the force to the impostors. */
        forceApplicationCallback: () => void;
    }
}
{'fraction_non_alphanumeric': 0.08368045224635526, 'fraction_numerical': 0.00669443617970842, 'mean_word_length': 2.0986402396865635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4023192', 'n_tokens_mistral': 3721, 'n_tokens_neox': 3376, 'n_words': 1115}