import { Rotation, Vector } from "../math"; import { RawJointParams, RawJointSet } from "../raw"; import { RigidBodyHandle } from "./rigid_body"; /** * The integer identifier of a collider added to a `ColliderSet`. */ export declare type JointHandle = number; /** * An enum grouping all possible types of joints: * - `Ball`: A Ball joint that removes all relative linear degrees of freedom between the affected bodies. * - `Fixed`: A fixed joint that removes all relative degrees of freedom between the affected bodies. * - `Prismatic`: A prismatic joint that removes all degrees of freedom between the affected * bodies except for the translation along one axis. * - `Revolute`: (3D only) A revolute joint that removes all degrees of freedom between the affected * bodies except for the rotation along one axis. */ export declare enum JointType { Ball = 0, Fixed = 1, Prismatic = 2 } export declare enum SpringModel { Disabled = 0, VelocityBased = 1, AccelerationBased = 2, ForceBased = 3 } export declare class Joint { protected rawSet: RawJointSet; handle: JointHandle; constructor(rawSet: RawJointSet, handle: JointHandle); /** * Checks if this joint is still valid (i.e. that it has * not been deleted from the joint set yet). */ isValid(): boolean; /** * The unique integer identifier of the first rigid-body this joint it attached to. */ bodyHandle1(): RigidBodyHandle; /** * The unique integer identifier of the second rigid-body this joint is attached to. */ bodyHandle2(): RigidBodyHandle; /** * The type of this joint given as a string. */ type(): JointType; /** * The position of the first anchor of this joint. * * The first anchor gives the position of the points application point on the * local frame of the first rigid-body it is attached to. */ anchor1(): Vector; /** * The position of the second anchor of this joint. * * The second anchor gives the position of the points application point on the * local frame of the second rigid-body it is attached to. */ anchor2(): Vector; /** * The first axis of this joint, if any. * * For joints where an application axis makes sense (e.g. the revolute and prismatic joins), * this returns the application axis on the first rigid-body this joint is attached to, expressed * in the local-space of this first rigid-body. */ axis1(): Vector; /** * The second axis of this joint, if any. * * For joints where an application axis makes sense (e.g. the revolute and prismatic joins), * this returns the application axis on the second rigid-body this joint is attached to, expressed * in the local-space of this second rigid-body. */ axis2(): Vector; } export declare class UnitJoint extends Joint { /** * Are the limits enabled for this joint? */ limitsEnabled(): boolean; /** * The min limit of this joint. */ limitsMin(): number; /** * The max limit of this joint. */ limitsMax(): number; configureMotorModel(model: SpringModel): void; configureMotorVelocity(targetVel: number, factor: number): void; configureMotorPosition(targetPos: number, stiffness: number, damping: number): void; configureMotor(targetPos: number, targetVel: number, stiffness: number, damping: number): void; } export declare class FixedJoint extends Joint { } export declare class PrismaticJoint extends UnitJoint { } export declare class BallJoint extends UnitJoint { } export declare class JointParams { anchor1: Vector; anchor2: Vector; axis1: Vector; axis2: Vector; tangent1: Vector; tangent2: Vector; frame1: Rotation; frame2: Rotation; jointType: JointType; limitsEnabled: boolean; limits: Array; private constructor(); /** * Create a new joint descriptor that builds Ball joints. * * A ball joints allows three relative rotational degrees of freedom * by preventing any relative translation between the anchors of the * two attached rigid-bodies. * * @param anchor1 - Point where the joint is attached on the first rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. * @param anchor2 - Point where the joint is attached on the second rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. */ static ball(anchor1: Vector, anchor2: Vector): JointParams; /** * Creates a new joint descriptor that builds a Fixed joint. * * A fixed joint removes all the degrees of freedom between the affected bodies, ensuring their * anchor and local frames coincide in world-space. * * @param anchor1 - Point where the joint is attached on the first rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. * @param frame1 - The reference orientation of the joint wrt. the first rigid-body. * @param anchor2 - Point where the joint is attached on the second rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. * @param frame2 - The reference orientation of the joint wrt. the second rigid-body. */ static fixed(anchor1: Vector, frame1: Rotation, anchor2: Vector, frame2: Rotation): JointParams; /** * Creates a new joint descriptor that builds a Prismatic joint. * * A prismatic joint removes all the degrees of freedom between the * affected bodies, except for the translation along one axis. * * @param anchor1 - Point where the joint is attached on the first rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. * @param axis1 - Axis of the joint, expressed in the local-space of the first rigid-body it is attached to. * @param anchor2 - Point where the joint is attached on the second rigid-body affected by this joint. Expressed in the * local-space of the rigid-body. * @param axis2 - Axis of the joint, expressed in the local-space of the second rigid-body it is attached to. */ static prismatic(anchor1: Vector, axis1: Vector, anchor2: Vector, axis2: Vector): JointParams; intoRaw(): RawJointParams; }