import { Observable } from '@zcomponent/core'; import { HP_BodyId, HP_ConstraintId, HP_ShapeId, HP_WorldId, HavokPhysicsWithBindings } from '@babylonjs/havok'; import { Vector3, Quaternion } from 'three'; import { PhysicsConstraintAxis, PhysicsConstraintAxisLimitMode, PhysicsConstraintMotorType, PhysicsMassProperties, PhysicsMaterialCombineMode, PhysicsShapeType, PluginMemoryRef } from '../IPhysics'; import { MotionType } from '../components/IRigidBody'; import { PhysicsConstraint } from '../behaviors/constraints/PhysicsConstraint'; export declare class HavokInternalAPI { private havok; world: HP_WorldId; _tabInFocus: boolean; private _queryCollector; private _bodyBuffer; private syncNewWorldPosition; private syncNewWorldQuaternion; constructor(havok: HavokPhysicsWithBindings, gravity: Observable<[number, number, number]>); createShape(shapeType: PhysicsShapeType, position: Vector3, quaternion: Quaternion, scale: Vector3, vertices: Vector3[] | undefined, indicies: number[] | undefined): HP_ShapeId; getTriangles(indices: number[]): PluginMemoryRef; private _initializeTabFocusEvents; private _handleVisibilityChange; dispose: () => void; getUpdatedPhysicsTransforms(bodyId: HP_BodyId): [Vector3, Quaternion]; _internalComputeMassProperties(bodyId: HP_BodyId): [[number, number, number], number, [number, number, number], [number, number, number, number]]; setMassProperties(bodyId: HP_BodyId, centerOfMass?: [number, number, number], mass?: number, inertia?: [number, number, number], inertiaOrientation?: [number, number, number, number]): void; setQTransform(bodyId: HP_BodyId, transform: [[number, number, number], [number, number, number, number]]): void; _frame: (step: number) => void; setBodyTargetQTransform(bodyId: HP_BodyId, transform: [[number, number, number], [number, number, number, number]]): void; getBodyGeometry(bodyId: HP_BodyId): { positions: never[]; indices: never[]; } | { positions: Float32Array; indices: Uint32Array; }; freeBuffer(arr: PluginMemoryRef): void; getVerticesMemoryRef(vertices: Vector3[]): PluginMemoryRef; /** * Enable collision to be reported for a body when a callback is settup on the world * @param body the physics body * @param enabled */ setCollisionCallbackEnabled(bodyId: HP_BodyId, enabled: boolean): void; addShapeToBody: (containerShapeID: HP_ShapeId, shape: HP_ShapeId, transforms: any) => void; removeBodyFromWorld: (bodyId: HP_BodyId) => void; removeShapeFromBody: (containerShapeID: HP_ShapeId, shapeIndex: number) => void; releaseShape: (shapeId: HP_ShapeId) => void; createContainer: () => HP_ShapeId; createBody: () => HP_BodyId; addBodyToWorld: (bodyId: HP_BodyId) => void; setBodyShape: (bodyId: HP_BodyId, containerShapeID: HP_ShapeId) => void; getMassProperties: (bodyId: HP_BodyId) => PhysicsMassProperties; applyImpulse: (bodyId: HP_BodyId, impulse: [number, number, number], location: [number, number, number]) => void; getNumBodies: () => number; setAngularVelocity: (bodyId: HP_BodyId, angVel: [number, number, number]) => void; getAngularVelocityToRef: (bodyId: HP_BodyId, angVel: Vector3) => void; setGravityFactor: (bodyId: HP_BodyId, factor: number) => void; getGravityFactor: (bodyId: HP_BodyId) => number; setLinearVelocity: (bodyId: HP_BodyId, linVel: [number, number, number]) => void; setLinearDamping: (bodyId: HP_BodyId, damping: number) => void; setMotionType: (bodyId: HP_BodyId, motionType: MotionType) => void; getMotionType: (bodyId: HP_BodyId) => any; setAngularDamping: (bodyId: HP_BodyId, damping: number) => void; getAngularDamping: (bodyId: HP_BodyId) => number; getLinearVelocityToRef: (bodyId: HP_BodyId, linVel: Vector3) => void; getLinearDamping: (bodyId: HP_BodyId) => number; setConstraintEnabled: (constraintID: HP_ConstraintId, enabled: boolean) => void; getConstraintEnabled: (constraintID: HP_ConstraintId) => boolean; setCollisionsEnabled: (constraintID: HP_ConstraintId, enabled: boolean) => void; setDensity: (containerShapeID: HP_ShapeId, density: number) => void; getDensity: (containerShapeID: HP_ShapeId) => number; setSpeedLimit: (worldId: HP_WorldId | undefined, maxLinearVelocity: number, maxAngularVelocity: number) => void; getSpeedLimit: (worldId?: HP_WorldId) => number; getMaterial: (shapeID: HP_ShapeId) => { staticFriction: number; dynamicFriction: number; restitution: number; frictionCombine: PhysicsMaterialCombineMode | undefined; restitutionCombine: PhysicsMaterialCombineMode | undefined; }; setMaterial: (shapeId: HP_ShapeId, material: { dynamicFriction?: number; staticFriction?: number; restitution?: number; frictionCombine?: PhysicsMaterialCombineMode; restitutionCombine?: PhysicsMaterialCombineMode; }) => void; /** * Initializes a physics constraint with the given parameters. * * @param constraint - The physics constraint to be initialized. * @param body - The main body * @param childBody - The child body. * * This function is useful for setting up a physics constraint in a physics engine. */ initConstraint(constraint: PhysicsConstraint): void; private _constraintAxisToNative; /** * Sets the friction of the given axis of the given constraint. * * @param constraint - The constraint to set the friction of. * @param axis - The axis of the constraint to set the friction of. * @param friction - The friction to set. * */ setAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, friction: number): void; /** * Gets the friction value of the specified axis of the given constraint. * * @param constraint - The constraint to get the axis friction from. * @param axis - The axis to get the friction from. * @returns The friction value of the specified axis. * */ getAxisFriction(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number; /** * Sets the limit mode of the specified axis of the given constraint. * @param constraint - The constraint to set the axis mode of. * @param axis - The axis to set the limit mode of. * @param limitMode - The limit mode to set. */ setAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limitMode: PhysicsConstraintAxisLimitMode): void; /** * Gets the axis limit mode of the given constraint. * * @param constraint - The constraint to get the axis limit mode from. * @param axis - The axis to get the limit mode from. * @returns The axis limit mode of the given constraint. * */ getAxisMode(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): PhysicsConstraintAxisLimitMode; /** * Sets the minimum limit of the given axis of the given constraint. * @param constraint - The constraint to set the minimum limit of. * @param axis - The axis to set the minimum limit of. * @param limit - The minimum limit to set. * */ setAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void; /** * Gets the minimum limit of the specified axis of the given constraint. * @param constraint - The constraint to get the minimum limit from. * @param axis - The axis to get the minimum limit from. * @returns The minimum limit of the specified axis of the given constraint. * */ getAxisMinLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number; /** * Sets the maximum limit of the given axis of the given constraint. * @param constraint - The constraint to set the maximum limit of the given axis. * @param axis - The axis to set the maximum limit of. * @param limit - The maximum limit to set. * */ setAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, limit: number): void; /** * Gets the maximum limit of the given axis of the given constraint. * * @param constraint - The constraint to get the maximum limit from. * @param axis - The axis to get the maximum limit from. * @returns The maximum limit of the given axis of the given constraint. * */ getAxisMaxLimit(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number; /** * Sets the motor type of the given axis of the given constraint. * @param constraint - The constraint to set the motor type of. * @param axis - The axis of the constraint to set the motor type of. * @param motorType - The motor type to set. * @returns void * */ setAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, motorType: PhysicsConstraintMotorType): void; /** * Gets the motor type of the specified axis of the given constraint. * @param constraint - The constraint to get the motor type from. * @param axis - The axis of the constraint to get the motor type from. * @returns The motor type of the specified axis of the given constraint. * */ getAxisMotorType(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): PhysicsConstraintMotorType; /** * Sets the target of an axis motor of a constraint. * * @param constraint - The constraint to set the axis motor target of. * @param axis - The axis of the constraint to set the motor target of. * @param target - The target of the axis motor. * */ setAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, target: number): void; /** * Gets the target of the motor of the given axis of the given constraint. * * @param constraint - The constraint to get the motor target from. * @param axis - The axis of the constraint to get the motor target from. * @returns The target of the motor of the given axis of the given constraint. * */ getAxisMotorTarget(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number; /** * Sets the maximum force that can be applied by the motor of the given constraint axis. * @param constraint - The constraint to set the motor max force for. * @param axis - The axis of the constraint to set the motor max force for. * @param maxForce - The maximum force that can be applied by the motor. * */ setAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis, maxForce: number): void; /** * Gets the maximum force of the motor of the given constraint axis. * * @param constraint - The constraint to get the motor maximum force from. * @param axis - The axis of the constraint to get the motor maximum force from. * @returns The maximum force of the motor of the given constraint axis. * */ getAxisMotorMaxForce(constraint: PhysicsConstraint, axis: PhysicsConstraintAxis): number; private _limitModeToNative; private _nativeToMotorType; private _constraintMotorTypeToNative; private _nativeToLimitMode; /** * Disposes a physics constraint. * * @param constraint - The physics constraint to dispose. * * This method is useful for releasing the resources associated with a physics constraint, such as * the Havok constraint, when it is no longer needed. This is important for avoiding memory leaks. */ disposeConstraint(constraint: PhysicsConstraint): void; }