import type { Vector3 } from "../../Maths/math.vector"; import type { IPhysicsEnginePlugin } from "./IPhysicsEnginePlugin"; /** * Interface for Physics-Joint data * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine */ export interface PhysicsJointData { /** * The main pivot of the joint */ mainPivot?: Vector3; /** * The connected pivot of the joint */ connectedPivot?: Vector3; /** * The main axis of the joint */ mainAxis?: Vector3; /** * The connected axis of the joint */ connectedAxis?: Vector3; /** * The collision of the joint */ 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 * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine */ export declare class PhysicsJoint { /** * The type of the physics joint */ type: number; /** * The data for the physics joint */ jointData: PhysicsJointData; private _physicsJoint; protected _physicsPlugin: IPhysicsEnginePlugin; /** * Initializes the physics joint * @param type The type of the physics joint * @param jointData The data for the physics joint */ constructor( /** * The type of the physics joint */ type: number, /** * The data for the physics joint */ jointData: PhysicsJointData); /** * Gets the physics joint */ get physicsJoint(): any; /** * Sets the physics joint */ set physicsJoint(newJoint: any); /** * Sets the physics plugin */ set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin); /** * 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 */ executeNativeFunction(func: (world: any, physicsJoint: any) => void): void; /** * Distance-Joint type */ static DistanceJoint: number; /** * Hinge-Joint type */ static HingeJoint: number; /** * Ball-and-Socket joint type */ static BallAndSocketJoint: number; /** * Wheel-Joint type */ static WheelJoint: number; /** * Slider-Joint type */ static SliderJoint: number; /** * Prismatic-Joint type */ static PrismaticJoint: number; /** * Universal-Joint type * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions) */ static UniversalJoint: number; /** * Hinge-Joint 2 type */ static Hinge2Joint: number; /** * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters */ static PointToPointJoint: number; /** * Spring-Joint type */ static SpringJoint: number; /** * Lock-Joint type */ static LockJoint: number; } /** * A class representing a physics distance joint * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine */ export declare class DistanceJoint extends PhysicsJoint { /** * * @param jointData The data for the Distance-Joint */ constructor(jointData: DistanceJointData); /** * Update the predefined distance. * @param maxDistance The maximum preferred distance * @param minDistance The minimum preferred distance */ updateDistance(maxDistance: number, minDistance?: number): void; } /** * Represents a Motor-Enabled Joint * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine */ export declare class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint { /** * Initializes the Motor-Enabled Joint * @param type The type of the joint * @param jointData The physical joint data for the joint */ constructor(type: number, jointData: PhysicsJointData); /** * Set the motor values. * Attention, this function is plugin specific. Engines won't react 100% the same. * @param force the force to apply * @param maxForce max force for this motor. */ setMotor(force?: number, maxForce?: number): void; /** * Set the motor's limits. * Attention, this function is plugin specific. Engines won't react 100% the same. * @param upperLimit The upper limit of the motor * @param lowerLimit The lower limit of the motor */ setLimit(upperLimit: number, lowerLimit?: number): void; } /** * This class represents a single physics Hinge-Joint * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine */ export declare class HingeJoint extends MotorEnabledJoint { /** * Initializes the Hinge-Joint * @param jointData The joint data for the Hinge-Joint */ constructor(jointData: PhysicsJointData); /** * 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. */ setMotor(force?: number, maxForce?: number): void; /** * Set the motor's limits. * Attention, this function is plugin specific. Engines won't react 100% the same. * @param upperLimit The upper limit of the motor * @param lowerLimit The lower limit of the motor */ setLimit(upperLimit: number, lowerLimit?: number): void; } /** * This class represents a dual hinge physics joint (same as wheel joint) * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine */ export declare class Hinge2Joint extends MotorEnabledJoint { /** * Initializes the Hinge2-Joint * @param jointData The joint data for the Hinge2-Joint */ constructor(jointData: PhysicsJointData); /** * Set the motor values. * Attention, this function is plugin specific. Engines won't react 100% the same. * @param targetSpeed the speed the motor is to reach * @param maxForce max force for this motor. * @param motorIndex motor's index, 0 or 1. */ setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void; /** * Set the motor limits. * Attention, this function is plugin specific. Engines won't react 100% the same. * @param upperLimit the upper limit * @param lowerLimit lower limit * @param motorIndex the motor's index, 0 or 1. */ setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void; } /** * Interface for a motor enabled joint * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine */ export interface IMotorEnabledJoint { /** * Physics joint */ physicsJoint: any; /** * Sets the motor of the motor-enabled joint * @param force The force of the motor * @param maxForce The maximum force of the motor * @param motorIndex The index of the motor */ setMotor(force?: number, maxForce?: number, motorIndex?: number): void; /** * Sets the limit of the motor * @param upperLimit The upper limit of the motor * @param lowerLimit The lower limit of the motor * @param motorIndex The index of the motor */ setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void; } /** * Joint data for a Distance-Joint * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine */ export interface DistanceJointData extends PhysicsJointData { /** * Max distance the 2 joint objects can be apart */ maxDistance: number; } /** * Joint data from a spring joint * @see https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine */ export interface SpringJointData extends PhysicsJointData { /** * Length of the spring */ length: number; /** * Stiffness of the spring */ stiffness: number; /** * Damping of the spring */ damping: number; /** this callback will be called when applying the force to the impostors. */ forceApplicationCallback: () => void; }