import type { Matrix, Vector3 } from "@babylonjs/core/Maths/math.vector"; import type { DeepImmutable, Nullable } from "@babylonjs/core/types"; import type { IBulletWasmInstance } from "./bulletWasmInstance"; import type { IPhysicsRuntime } from "./Impl/IPhysicsRuntime"; import type { RigidBody } from "./rigidBody"; import type { RigidBodyBundle } from "./rigidBodyBundle"; declare class ConstraintInner { private readonly _wasmInstance; private _ptr; private _bodyReference; private _referenceCount; constructor(wasmInstance: WeakRef, ptr: number, bodyReference: readonly [RigidBody, RigidBody] | RigidBodyBundle); dispose(): void; get ptr(): number; addReference(): void; removeReference(): void; get hasReferences(): boolean; } /** * Base class for all bullet physics constraints */ export declare abstract class Constraint { readonly runtime: IPhysicsRuntime; protected readonly _inner: ConstraintInner; private _worldReference; protected constructor(runtime: IPhysicsRuntime, ptr: number, bodyReference: readonly [RigidBody, RigidBody] | RigidBodyBundle); /** * Disposes the constraint and releases the resources associated with it */ dispose(): void; /** * @internal */ get ptr(): number; /** * @internal */ addReference(): void; /** * @internal */ removeReference(): void; /** * @internal */ setWorldReference(worldReference: Nullable): void; } export declare const enum ConstraintParams { ConstraintERP = 1, ConstraintStopERP = 2, ConstraintCFM = 3, ConstraintStopCFM = 4 } declare abstract class Generic6DofConstraintBase extends Constraint { /** * Sets the linear lower limit of the constraint * * If the constraint is added to a physics world, this operation will wait for the world evaluation to finish * @param limit linear lower limit */ setLinearLowerLimit(limit: DeepImmutable): void; /** * Sets the linear upper limit of the constraint * @param limit linear upper limit */ setLinearUpperLimit(limit: DeepImmutable): void; /** * Sets the angular lower limit of the constraint * @param limit angular lower limit */ setAngularLowerLimit(limit: DeepImmutable): void; /** * Sets the angular upper limit of the constraint * @param limit angular upper limit */ setAngularUpperLimit(limit: DeepImmutable): void; /** * Sets the parameter of the constraint * * axis is * - 0 for linear x * - 1 for linear y * - 2 for linear z * - 3 for angular x * - 4 for angular y * - 5 for angular z * * out of range axis will be ignored * * @param num parameter number * @param value parameter value * @param axis parameter axis */ setParam(num: ConstraintParams, value: number, axis: number): void; /** * Sets whether the constraint uses the frame offset * * This is used for matching the behavior of MMD * @param frameOffsetOnOff true to use the frame offset, false to not use it */ useFrameOffset(frameOffsetOnOff: boolean): void; } /** * Generic6DofConstraint is a constraint that allows for 6 degrees of freedom (3 linear and 3 angular) between two rigid bodies * * It can be used to create a variety of constraints, such as a hinge, slider, or ball-and-socket joint */ export declare class Generic6DofConstraint extends Generic6DofConstraintBase { /** * Creates a new Generic6DofConstraint * @param runtime physics runtime * @param bodyA rigid body A * @param bodyB rigid body B * @param frameA local frame A * @param frameB local frame B * @param useLinearReferenceFrameA if true, the linear reference frame is set to body A, otherwise it is set to body B */ constructor(runtime: IPhysicsRuntime, bodyA: RigidBody, bodyB: RigidBody, frameA: Matrix, frameB: Matrix, useLinearReferenceFrameA: boolean); /** * Creates a new Generic6DofConstraint * @param runtime physics runtime * @param bodyBundle rigid body bundle * @param bodyIndices indices of the rigid bodies in the bundle * @param frameA local frame A * @param frameB local frame B * @param useLinearReferenceFrameA if true, the linear reference frame is set to body A, otherwise it is set to body B */ constructor(runtime: IPhysicsRuntime, bodyBundle: RigidBodyBundle, bodyIndices: readonly [number, number], frameA: Matrix, frameB: Matrix, useLinearReferenceFrameA: boolean); } /** * Generic6DofSpringConstraint is a constraint that allows for 6 degrees of freedom (3 linear and 3 angular) between two rigid bodies * * It can be used to create a variety of constraints, such as a hinge, slider, or ball-and-socket joint * * This constraint also supports springs, which can be used to create a spring-like effect between the two bodies */ export declare class Generic6DofSpringConstraint extends Generic6DofConstraintBase { /** * Creates a new Generic6DofSpringConstraint * @param runtime physics runtime * @param bodyA rigid body A * @param bodyB rigid body B * @param frameA local frame A * @param frameB local frame B * @param useLinearReferenceFrameA if true, the linear reference frame is set to body A, otherwise it is set to body B */ constructor(runtime: IPhysicsRuntime, bodyA: RigidBody, bodyB: RigidBody, frameA: Matrix, frameB: Matrix, useLinearReferenceFrameA: boolean); /** * Creates a new Generic6DofSpringConstraint * @param runtime physics runtime * @param bodyBundle rigid body bundle * @param bodyIndices indices of the rigid bodies in the bundle * @param frameA local frame A * @param frameB local frame B * @param useLinearReferenceFrameA if true, the linear reference frame is set to body A, otherwise it is set to body B */ constructor(runtime: IPhysicsRuntime, bodyBundle: RigidBodyBundle, bodyIndices: readonly [number, number], frameA: Matrix, frameB: Matrix, useLinearReferenceFrameA: boolean); /** * Enables or disables the spring for the specified index * @param index index of the spring * @param onOff true to enable the spring, false to disable it */ enableSpring(index: number, onOff: boolean): void; /** * Sets the spring stiffness for the specified index * @param index index of the spring * @param stiffness spring stiffness */ setStiffness(index: number, stiffness: number): void; /** * Sets the spring damping for the specified index * @param index index of the spring * @param damping spring damping */ setDamping(index: number, damping: number): void; } export {};