import { Observable, Event, Component, ContextManager, Behavior } from '@zcomponent/core'; import { IPhysicsCollisionEvent, PhysicsMassProperties, PhysicsPrestepType } from '../IPhysics'; import { HP_ShapeId } from '@babylonjs/havok'; import * as THREE from 'three'; import { Collider } from './Colliders/Collider'; import { Group } from '@zcomponent/three/lib/components/Group'; import { HavokContext } from '../contexts/HavokContext'; import { Object3D } from '@zcomponent/three/lib/components/Object3D'; import { RigidbodyGrabber } from './RigidbodyGrabber'; export interface IRigidBody { onGrabInRange: Event<[RigidbodyGrabber]>; onGrabOutOfRange: Event<[RigidbodyGrabber]>; onGrab: Event<[RigidbodyGrabber]>; onRelease: Event<[RigidbodyGrabber]>; ready: Observable; attachListeners: () => void; isRigidBody: true; getElement(): THREE.Object3D; getInstance(): Component; _calculateQTransform(): [[number, number, number], [number, number, number, number]]; _dirtyFlags: { massProperties: boolean; gravityFactor: boolean; linearDamping: boolean; angularDamping: boolean; density: boolean; transforms: boolean; motionType: boolean; targetTransform: boolean; }; colliders: Collider[]; motionType: Observable; onCollision: Event<[IPhysicsCollisionEvent]>; reportCollisions: boolean; bodyId: HP_ShapeId; containerShapeID: HP_ShapeId; physicsContex: HavokContext; grabbable: boolean; reset(): void; bounciness: Observable; friction: Observable; centerOfMass: Observable<[number, number, number] | undefined>; mass: Observable; /** * * The principal moments of inertia of this object * for a unit mass. This determines how easy it is * for the body to rotate. A value of zero on any * axis will be used as infinite interia about that * axis. * * If not provided, the physics engine will compute * an appropriate value. * @zprop * @zgroup Mass * @zgrouppriority 22 * @zdefault [0,0,0] */ inertia: Observable<[number, number, number] | undefined>; inertiaOrientation: Observable<[number, number, number, number] | undefined>; targetTransform: Observable<[[number, number, number], [number, number, number, number]] | null>; gravityFactor: Observable; linearDamping: Observable; angularDamping: Observable; density: Observable; propsWorldTransform: Observable; applyImpulse(impulse: THREE.Vector3 | [number, number, number], location?: THREE.Vector3 | [number, number, number]): void; applyForce(force: THREE.Vector3 | [number, number, number], location?: THREE.Vector3 | [number, number, number]): void; setAngularVelocity(angVel: THREE.Vector3 | [number, number, number]): void; setLinearVelocity(linVel: THREE.Vector3 | [number, number, number]): void; getLinearDamping(): number; getMassProperties(): PhysicsMassProperties; setGravityFactor(factor: number): void; getGravityFactor(): number; setLinearDamping(damping: number): void; setAngularDamping(damping: number): void; getAngularDamping(): number; getLinearVelocityToRef(linVel: THREE.Vector3): void; getAngularVelocityToRef(angVel: THREE.Vector3): void; setMotionType(motionType: MotionType): void; getMotionType(): MotionType; setPrestepType(prestepType: PhysicsPrestepType): void; getPrestepType(): PhysicsPrestepType; dispose(): void; _syncTransform(position: THREE.Vector3, quaternion: THREE.Quaternion, scene: THREE.Scene): void; } export declare enum MotionType { STATIC = "Static", DYNAMIC = "Dynamic", KINEMATIC = "Kinematic" } export interface RigidBodyonstructorProps { motionType?: MotionType; /** * @zprop * @zdefault true */ reportCollisions: boolean; } type Constructor = new (...args: any[]) => T; export declare function RigidBodyMixin(Base: TBase): { new (...args: any[]): { [x: string]: any; /** * Emitted when the rigid body is ready to be used. */ ready: Observable; /** * Emitted when a RigidbodyGrabber is within range of the object. * @zprop */ onGrabInRange: Event<[RigidbodyGrabber]>; /** * Emitted when a RigidbodyGrabber is within range of the object. * @zprop */ onGrabOutOfRange: Event<[RigidbodyGrabber]>; /** * Emit when a RigidbodyGrabber grabs the object. * @zprop */ onGrab: Event<[RigidbodyGrabber]>; /** * Emitted when a RigidbodyGrabber releases the object. * @zprop */ onRelease: Event<[RigidbodyGrabber]>; /** * Sets the motion type of a physics body. * * - Static: The body is not affected by forces or collisions. It remains fixed in place unless moved manually. * Use this for objects that should not move or interact with other physics objects, such as walls or stationary obstacles. * * - Dynamic: The body is affected by forces and collisions. It responds to gravity, collisions, and other physical interactions. * Use this for objects that should have realistic physics behavior, such as falling boxes, projectiles, or characters. * * - Kinematic: The body is not affected by forces, but can be moved by setting its transform. It does not respond to collisions. * Use this for objects that need to be animated or moved programmatically, such as moving platforms or camera-controlled objects. * Note: Kinematic objects can suffer from teleportation issues and may clip through other objects if animated too quickly. * * @zprop * @zdefault Dynamic */ motionType: Observable; /** * Indicates how to handle position/rotation changes of scene objects attached to physics bodies * * @zprop * @zdefault Disabled * @zgroup Physics Prestep * @zgrouppriority 25 */ prestepType: Observable; targetTransform: Observable<[[number, number, number], [number, number, number, number]] | null, never>; /** * When true, the object can be picked up using the `RigidbodyGrabber` component. * * The rigid body must have a `DYNAMIC` motion type to be grabbable. * * @zgroup Grab * @zdefault false * @zgrouppriority 24 * @zprop */ grabbable: boolean; isRigidBody: true; getElement(): THREE.Object3D; getInstance(): Component; physicsContex: HavokContext; _dirtyFlags: { massProperties: boolean; gravityFactor: boolean; linearDamping: boolean; angularDamping: boolean; density: boolean; transforms: boolean; motionType: boolean; targetTransform: boolean; }; /** * Sets the bounciness of the physics material.z * * The bounciness is a factor which describes, the amount of energy that is retained after a collision, * which should be a number between 0 and 1.. * * A bounciness of 0 means that no energy is retained and the objects will not bounce off each other, * while a bounciness of 1 means that all energy is retained and the objects will bounce. * * Note, though, due that due to the simulation implementation, an object with a bounciness of 1 may * still lose energy over time. * * If not provided, a default value of 0 will be used. * @zprop * @zgroup Collider Properties * @zdefault 0 * @ztype proportion */ bounciness: Observable; /** * Sets the friction used by this material * * The friction determines how much an object will slow down when it is in contact with another object. * This is important for simulating realistic physics, such as when an object slides across a surface. * * If not provided, a default value of 0.5 will be used. * @zprop * @zgroup Collider Properties * @zdefault 0.5 * @ztype proportion */ friction: Observable; /** * * The total mass of this object, in kilograms. This * affects how easy it is to move the body. A value * of zero will be used as an infinite mass. * * If not provided, the physics engine will compute * an appropriate value. * * @zprop * @zgroup Mass * @zgrouppriority 22 * @zdefault 0 */ mass: Observable; /** * * The principal moments of inertia of this object * for a unit mass. This determines how easy it is * for the body to rotate. A value of zero on any * axis will be used as infinite interia about that * axis. * * If not provided, the physics engine will compute * an appropriate value. * @zprop * @zgroup Mass * @zgrouppriority 22 * @zdefault [0,0,0] */ inertia: Observable<[number, number, number] | undefined, never>; /** * The rotation rotating from inertia major axis space * to parent space (i.e., the rotation which, when * applied to the 3x3 inertia tensor causes the inertia * tensor to become a diagonal matrix). This determines * how the values of inertia are aligned with the parent * object. * * If not provided, the physics engine will compute * an appropriate value. * * @zprop * @zdefault * @zgroup Mass * @zgrouppriority 22 * @zdefault [0,0,0,0] */ inertiaOrientation: Observable<[number, number, number, number] | undefined, never>; /** * Sets the gravity factor of a body. * @zprop * @zdefault 1 * @zgroup Gravity * @zgrouppriority 23 */ gravityFactor: Observable; /** * Sets the linear damping of the given body. * * This method is useful for controlling the linear damping of a body in a physics engine. * Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body. * This method allows the user to set the linear damping of a body, which can be used to control the motion of the body. * @zprop * @zdefault 0 * @zgroup Damping * @zgrouppriority 24 */ linearDamping: Observable; /** * Sets the angular damping of a physics body. * * This function is useful for controlling the angular velocity of a physics body. * By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations. * @zprop * @zdefault 0 * @zgroup Damping * @zgrouppriority 24 */ angularDamping: Observable; /** * Sets the density of a physics shape. * @zprop * @zdefault 0 * @zgroup Density * @zgrouppriority 24 */ density: Observable; /** * Applies an impulse to a physics body at a given location. * @param impulse - The impulse vector to apply. * @param location - The location in world space to apply the impulse. * * * This method is useful for applying an impulse to a physics body at a given location. * This can be used to simulate physical forces such as explosions, collisions, and gravity. * * If location is not provided, the impulse will be applied to the center of the body. */ applyImpulse(impulse: THREE.Vector3 | [number, number, number], location?: THREE.Vector3 | [number, number, number]): void; /** * Applies a force to a physics body at a given location. * @param force - The force vector to apply. * @param location - The location in world space to apply the impulse. * * This method is useful for applying a force to a physics body at a given location. * This can be used to simulate physical forces such as explosions, collisions, and gravity. * * * If location is not provided, the force will be applied to the center of the body. */ applyForce(force: THREE.Vector3 | [number, number, number], location?: THREE.Vector3 | [number, number, number]): void; /** * Sets the angular velocity of a physics body. * @param angVel - The angular velocity vector to set. */ setAngularVelocity(angVel: THREE.Vector3 | [number, number, number]): void; /** * Sets the linear velocity of a physics body. * @param linVel - The linear velocity vector to set. */ setLinearVelocity(linVel: THREE.Vector3 | [number, number, number]): void; /** * Gets the linear damping of a physics body. * @returns The linear damping of the body. */ getLinearDamping(): number; /** * Gets the mass properties of a physics body. * @returns The mass properties of the body. */ getMassProperties(): PhysicsMassProperties; /** * Sets the gravity factor of a body. * @param factor - The gravity factor to set. */ setGravityFactor(factor: number): void; /** * Gets the gravity factor of a body. * @returns The gravity factor of the body. */ getGravityFactor(): number; /** * Sets the linear damping of the given body. * @param damping - The linear damping to set. * * This method is useful for controlling the linear damping of a body in a physics engine. * Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body. * This method allows the user to set the linear damping of a body, which can be used to control the motion of the body. */ setLinearDamping(damping: number): void; /** * Sets the angular damping of a physics body. * @param damping - The angular damping value to set. * * This function is useful for controlling the angular velocity of a physics body. * By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations. */ setAngularDamping(damping: number): void; /** * Gets the angular damping of a physics body. * @returns The angular damping of the body. * * This function is useful for retrieving the angular damping of a physics body, * which is used to control the rotational motion of the body. The angular damping is a value between 0 and 1, where 0 is no damping and 1 is full damping. */ getAngularDamping(): number; /** * Gets the linear velocity of a physics body and stores it in a given vector. * @param body - The physics body to get the linear velocity from. * * This method is useful for retrieving the linear velocity of a physics body, * which can be used to determine the speed and direction of the body. This * information can be useful to simulate realistic physics behavior in a game. */ getLinearVelocityToRef(linVel: THREE.Vector3): void; getAngularVelocityToRef(angVel: THREE.Vector3): void; /** * Sets the motion type of a physics body. * Can be STATIC, DYNAMIC, or KINEMATIC. */ setMotionType(motionType: MotionType): void; /** * Gets the motion type of a physics body. */ getMotionType(): MotionType; /** * Sets the prestep type of a physics body. */ setPrestepType(prestepType: PhysicsPrestepType): void; /** * Gets the prestep type of a physics body. */ getPrestepType(): PhysicsPrestepType; /** * Defaults to the center of the rigid body. * The center of mass, in local space. This is The * point the body will rotate around when applying * an angular velocity. * * If not provided, the physics engine will compute * an appropriate value. * @zprop * @zgroup Mass * @zgrouppriority 22 * @zdefault [0,0,0] */ centerOfMass: Observable<[number, number, number] | undefined, never>; propsWorldTransform: Observable; onPropsTransformationChanged: () => void; attachTransformationListenersRecursive(component: Component): void; attachListeners: () => void; reset: () => void; dispose(): any; onCollision: Event<[IPhysicsCollisionEvent]>; reportCollisions: boolean; colliders: Collider[]; /** * Identifier for the physics body associated with this collider in the physics world. */ bodyId: HP_ShapeId; /** * Identifier for the shape used in the physics engine. */ containerShapeID: HP_ShapeId; _tempMatrix: THREE.Matrix4; _tempPosition: THREE.Vector3; _tempQuaternion: THREE.Quaternion; _tempScale: THREE.Vector3; _calculateQTransform(): [[number, number, number], [number, number, number, number]]; _syncTransform(position: THREE.Vector3, quaternion: THREE.Quaternion, scene: THREE.Scene): void; }; } & TBase; declare const RigidBodyComponent_base: { new (...args: any[]): { [x: string]: any; /** * Emitted when the rigid body is ready to be used. */ ready: Observable; /** * Emitted when a RigidbodyGrabber is within range of the object. * @zprop */ onGrabInRange: Event<[RigidbodyGrabber]>; /** * Emitted when a RigidbodyGrabber is within range of the object. * @zprop */ onGrabOutOfRange: Event<[RigidbodyGrabber]>; /** * Emit when a RigidbodyGrabber grabs the object. * @zprop */ onGrab: Event<[RigidbodyGrabber]>; /** * Emitted when a RigidbodyGrabber releases the object. * @zprop */ onRelease: Event<[RigidbodyGrabber]>; /** * Sets the motion type of a physics body. * * - Static: The body is not affected by forces or collisions. It remains fixed in place unless moved manually. * Use this for objects that should not move or interact with other physics objects, such as walls or stationary obstacles. * * - Dynamic: The body is affected by forces and collisions. It responds to gravity, collisions, and other physical interactions. * Use this for objects that should have realistic physics behavior, such as falling boxes, projectiles, or characters. * * - Kinematic: The body is not affected by forces, but can be moved by setting its transform. It does not respond to collisions. * Use this for objects that need to be animated or moved programmatically, such as moving platforms or camera-controlled objects. * Note: Kinematic objects can suffer from teleportation issues and may clip through other objects if animated too quickly. * * @zprop * @zdefault Dynamic */ motionType: Observable; /** * Indicates how to handle position/rotation changes of scene objects attached to physics bodies * * @zprop * @zdefault Disabled * @zgroup Physics Prestep * @zgrouppriority 25 */ prestepType: Observable; targetTransform: Observable<[[number, number, number], [number, number, number, number]] | null, never>; /** * When true, the object can be picked up using the `RigidbodyGrabber` component. * * The rigid body must have a `DYNAMIC` motion type to be grabbable. * * @zgroup Grab * @zdefault false * @zgrouppriority 24 * @zprop */ grabbable: boolean; isRigidBody: true; getElement(): THREE.Object3D; getInstance(): Component; physicsContex: HavokContext; _dirtyFlags: { massProperties: boolean; gravityFactor: boolean; linearDamping: boolean; angularDamping: boolean; density: boolean; transforms: boolean; motionType: boolean; targetTransform: boolean; }; /** * Sets the bounciness of the physics material.z * * The bounciness is a factor which describes, the amount of energy that is retained after a collision, * which should be a number between 0 and 1.. * * A bounciness of 0 means that no energy is retained and the objects will not bounce off each other, * while a bounciness of 1 means that all energy is retained and the objects will bounce. * * Note, though, due that due to the simulation implementation, an object with a bounciness of 1 may * still lose energy over time. * * If not provided, a default value of 0 will be used. * @zprop * @zgroup Collider Properties * @zdefault 0 * @ztype proportion */ bounciness: Observable; /** * Sets the friction used by this material * * The friction determines how much an object will slow down when it is in contact with another object. * This is important for simulating realistic physics, such as when an object slides across a surface. * * If not provided, a default value of 0.5 will be used. * @zprop * @zgroup Collider Properties * @zdefault 0.5 * @ztype proportion */ friction: Observable; /** * * The total mass of this object, in kilograms. This * affects how easy it is to move the body. A value * of zero will be used as an infinite mass. * * If not provided, the physics engine will compute * an appropriate value. * * @zprop * @zgroup Mass * @zgrouppriority 22 * @zdefault 0 */ mass: Observable; /** * * The principal moments of inertia of this object * for a unit mass. This determines how easy it is * for the body to rotate. A value of zero on any * axis will be used as infinite interia about that * axis. * * If not provided, the physics engine will compute * an appropriate value. * @zprop * @zgroup Mass * @zgrouppriority 22 * @zdefault [0,0,0] */ inertia: Observable<[number, number, number] | undefined, never>; /** * The rotation rotating from inertia major axis space * to parent space (i.e., the rotation which, when * applied to the 3x3 inertia tensor causes the inertia * tensor to become a diagonal matrix). This determines * how the values of inertia are aligned with the parent * object. * * If not provided, the physics engine will compute * an appropriate value. * * @zprop * @zdefault * @zgroup Mass * @zgrouppriority 22 * @zdefault [0,0,0,0] */ inertiaOrientation: Observable<[number, number, number, number] | undefined, never>; /** * Sets the gravity factor of a body. * @zprop * @zdefault 1 * @zgroup Gravity * @zgrouppriority 23 */ gravityFactor: Observable; /** * Sets the linear damping of the given body. * * This method is useful for controlling the linear damping of a body in a physics engine. * Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body. * This method allows the user to set the linear damping of a body, which can be used to control the motion of the body. * @zprop * @zdefault 0 * @zgroup Damping * @zgrouppriority 24 */ linearDamping: Observable; /** * Sets the angular damping of a physics body. * * This function is useful for controlling the angular velocity of a physics body. * By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations. * @zprop * @zdefault 0 * @zgroup Damping * @zgrouppriority 24 */ angularDamping: Observable; /** * Sets the density of a physics shape. * @zprop * @zdefault 0 * @zgroup Density * @zgrouppriority 24 */ density: Observable; /** * Applies an impulse to a physics body at a given location. * @param impulse - The impulse vector to apply. * @param location - The location in world space to apply the impulse. * * * This method is useful for applying an impulse to a physics body at a given location. * This can be used to simulate physical forces such as explosions, collisions, and gravity. * * If location is not provided, the impulse will be applied to the center of the body. */ applyImpulse(impulse: THREE.Vector3 | [number, number, number], location?: THREE.Vector3 | [number, number, number] | undefined): void; /** * Applies a force to a physics body at a given location. * @param force - The force vector to apply. * @param location - The location in world space to apply the impulse. * * This method is useful for applying a force to a physics body at a given location. * This can be used to simulate physical forces such as explosions, collisions, and gravity. * * * If location is not provided, the force will be applied to the center of the body. */ applyForce(force: THREE.Vector3 | [number, number, number], location?: THREE.Vector3 | [number, number, number] | undefined): void; /** * Sets the angular velocity of a physics body. * @param angVel - The angular velocity vector to set. */ setAngularVelocity(angVel: THREE.Vector3 | [number, number, number]): void; /** * Sets the linear velocity of a physics body. * @param linVel - The linear velocity vector to set. */ setLinearVelocity(linVel: THREE.Vector3 | [number, number, number]): void; /** * Gets the linear damping of a physics body. * @returns The linear damping of the body. */ getLinearDamping(): number; /** * Gets the mass properties of a physics body. * @returns The mass properties of the body. */ getMassProperties(): PhysicsMassProperties; /** * Sets the gravity factor of a body. * @param factor - The gravity factor to set. */ setGravityFactor(factor: number): void; /** * Gets the gravity factor of a body. * @returns The gravity factor of the body. */ getGravityFactor(): number; /** * Sets the linear damping of the given body. * @param damping - The linear damping to set. * * This method is useful for controlling the linear damping of a body in a physics engine. * Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body. * This method allows the user to set the linear damping of a body, which can be used to control the motion of the body. */ setLinearDamping(damping: number): void; /** * Sets the angular damping of a physics body. * @param damping - The angular damping value to set. * * This function is useful for controlling the angular velocity of a physics body. * By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations. */ setAngularDamping(damping: number): void; /** * Gets the angular damping of a physics body. * @returns The angular damping of the body. * * This function is useful for retrieving the angular damping of a physics body, * which is used to control the rotational motion of the body. The angular damping is a value between 0 and 1, where 0 is no damping and 1 is full damping. */ getAngularDamping(): number; /** * Gets the linear velocity of a physics body and stores it in a given vector. * @param body - The physics body to get the linear velocity from. * * This method is useful for retrieving the linear velocity of a physics body, * which can be used to determine the speed and direction of the body. This * information can be useful to simulate realistic physics behavior in a game. */ getLinearVelocityToRef(linVel: THREE.Vector3): void; getAngularVelocityToRef(angVel: THREE.Vector3): void; /** * Sets the motion type of a physics body. * Can be STATIC, DYNAMIC, or KINEMATIC. */ setMotionType(motionType: MotionType): void; /** * Gets the motion type of a physics body. */ getMotionType(): MotionType; /** * Sets the prestep type of a physics body. */ setPrestepType(prestepType: PhysicsPrestepType): void; /** * Gets the prestep type of a physics body. */ getPrestepType(): PhysicsPrestepType; /** * Defaults to the center of the rigid body. * The center of mass, in local space. This is The * point the body will rotate around when applying * an angular velocity. * * If not provided, the physics engine will compute * an appropriate value. * @zprop * @zgroup Mass * @zgrouppriority 22 * @zdefault [0,0,0] */ centerOfMass: Observable<[number, number, number] | undefined, never>; propsWorldTransform: Observable; onPropsTransformationChanged: () => void; attachTransformationListenersRecursive(component: Component): void; attachListeners: () => void; reset: () => void; dispose(): any; onCollision: Event<[IPhysicsCollisionEvent]>; reportCollisions: boolean; colliders: Collider[]; /** * Identifier for the physics body associated with this collider in the physics world. */ bodyId: HP_ShapeId; /** * Identifier for the shape used in the physics engine. */ containerShapeID: HP_ShapeId; _tempMatrix: THREE.Matrix4; _tempPosition: THREE.Vector3; _tempQuaternion: THREE.Quaternion; _tempScale: THREE.Vector3; _calculateQTransform(): [[number, number, number], [number, number, number, number]]; _syncTransform(position: THREE.Vector3, quaternion: THREE.Quaternion, scene: THREE.Scene): void; }; } & typeof Group; export declare class RigidBodyComponent extends RigidBodyComponent_base { constructor(contextManager: ContextManager, constructorProps: RigidBodyonstructorProps); private _onPhysicsStart; } declare const RigidBodyBehavior_base: { new (...args: any[]): { [x: string]: any; /** * Emitted when the rigid body is ready to be used. */ ready: Observable; /** * Emitted when a RigidbodyGrabber is within range of the object. * @zprop */ onGrabInRange: Event<[RigidbodyGrabber]>; /** * Emitted when a RigidbodyGrabber is within range of the object. * @zprop */ onGrabOutOfRange: Event<[RigidbodyGrabber]>; /** * Emit when a RigidbodyGrabber grabs the object. * @zprop */ onGrab: Event<[RigidbodyGrabber]>; /** * Emitted when a RigidbodyGrabber releases the object. * @zprop */ onRelease: Event<[RigidbodyGrabber]>; /** * Sets the motion type of a physics body. * * - Static: The body is not affected by forces or collisions. It remains fixed in place unless moved manually. * Use this for objects that should not move or interact with other physics objects, such as walls or stationary obstacles. * * - Dynamic: The body is affected by forces and collisions. It responds to gravity, collisions, and other physical interactions. * Use this for objects that should have realistic physics behavior, such as falling boxes, projectiles, or characters. * * - Kinematic: The body is not affected by forces, but can be moved by setting its transform. It does not respond to collisions. * Use this for objects that need to be animated or moved programmatically, such as moving platforms or camera-controlled objects. * Note: Kinematic objects can suffer from teleportation issues and may clip through other objects if animated too quickly. * * @zprop * @zdefault Dynamic */ motionType: Observable; /** * Indicates how to handle position/rotation changes of scene objects attached to physics bodies * * @zprop * @zdefault Disabled * @zgroup Physics Prestep * @zgrouppriority 25 */ prestepType: Observable; targetTransform: Observable<[[number, number, number], [number, number, number, number]] | null, never>; /** * When true, the object can be picked up using the `RigidbodyGrabber` component. * * The rigid body must have a `DYNAMIC` motion type to be grabbable. * * @zgroup Grab * @zdefault false * @zgrouppriority 24 * @zprop */ grabbable: boolean; isRigidBody: true; getElement(): THREE.Object3D; getInstance(): Component; physicsContex: HavokContext; _dirtyFlags: { massProperties: boolean; gravityFactor: boolean; linearDamping: boolean; angularDamping: boolean; density: boolean; transforms: boolean; motionType: boolean; targetTransform: boolean; }; /** * Sets the bounciness of the physics material.z * * The bounciness is a factor which describes, the amount of energy that is retained after a collision, * which should be a number between 0 and 1.. * * A bounciness of 0 means that no energy is retained and the objects will not bounce off each other, * while a bounciness of 1 means that all energy is retained and the objects will bounce. * * Note, though, due that due to the simulation implementation, an object with a bounciness of 1 may * still lose energy over time. * * If not provided, a default value of 0 will be used. * @zprop * @zgroup Collider Properties * @zdefault 0 * @ztype proportion */ bounciness: Observable; /** * Sets the friction used by this material * * The friction determines how much an object will slow down when it is in contact with another object. * This is important for simulating realistic physics, such as when an object slides across a surface. * * If not provided, a default value of 0.5 will be used. * @zprop * @zgroup Collider Properties * @zdefault 0.5 * @ztype proportion */ friction: Observable; /** * * The total mass of this object, in kilograms. This * affects how easy it is to move the body. A value * of zero will be used as an infinite mass. * * If not provided, the physics engine will compute * an appropriate value. * * @zprop * @zgroup Mass * @zgrouppriority 22 * @zdefault 0 */ mass: Observable; /** * * The principal moments of inertia of this object * for a unit mass. This determines how easy it is * for the body to rotate. A value of zero on any * axis will be used as infinite interia about that * axis. * * If not provided, the physics engine will compute * an appropriate value. * @zprop * @zgroup Mass * @zgrouppriority 22 * @zdefault [0,0,0] */ inertia: Observable<[number, number, number] | undefined, never>; /** * The rotation rotating from inertia major axis space * to parent space (i.e., the rotation which, when * applied to the 3x3 inertia tensor causes the inertia * tensor to become a diagonal matrix). This determines * how the values of inertia are aligned with the parent * object. * * If not provided, the physics engine will compute * an appropriate value. * * @zprop * @zdefault * @zgroup Mass * @zgrouppriority 22 * @zdefault [0,0,0,0] */ inertiaOrientation: Observable<[number, number, number, number] | undefined, never>; /** * Sets the gravity factor of a body. * @zprop * @zdefault 1 * @zgroup Gravity * @zgrouppriority 23 */ gravityFactor: Observable; /** * Sets the linear damping of the given body. * * This method is useful for controlling the linear damping of a body in a physics engine. * Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body. * This method allows the user to set the linear damping of a body, which can be used to control the motion of the body. * @zprop * @zdefault 0 * @zgroup Damping * @zgrouppriority 24 */ linearDamping: Observable; /** * Sets the angular damping of a physics body. * * This function is useful for controlling the angular velocity of a physics body. * By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations. * @zprop * @zdefault 0 * @zgroup Damping * @zgrouppriority 24 */ angularDamping: Observable; /** * Sets the density of a physics shape. * @zprop * @zdefault 0 * @zgroup Density * @zgrouppriority 24 */ density: Observable; /** * Applies an impulse to a physics body at a given location. * @param impulse - The impulse vector to apply. * @param location - The location in world space to apply the impulse. * * * This method is useful for applying an impulse to a physics body at a given location. * This can be used to simulate physical forces such as explosions, collisions, and gravity. * * If location is not provided, the impulse will be applied to the center of the body. */ applyImpulse(impulse: THREE.Vector3 | [number, number, number], location?: THREE.Vector3 | [number, number, number] | undefined): void; /** * Applies a force to a physics body at a given location. * @param force - The force vector to apply. * @param location - The location in world space to apply the impulse. * * This method is useful for applying a force to a physics body at a given location. * This can be used to simulate physical forces such as explosions, collisions, and gravity. * * * If location is not provided, the force will be applied to the center of the body. */ applyForce(force: THREE.Vector3 | [number, number, number], location?: THREE.Vector3 | [number, number, number] | undefined): void; /** * Sets the angular velocity of a physics body. * @param angVel - The angular velocity vector to set. */ setAngularVelocity(angVel: THREE.Vector3 | [number, number, number]): void; /** * Sets the linear velocity of a physics body. * @param linVel - The linear velocity vector to set. */ setLinearVelocity(linVel: THREE.Vector3 | [number, number, number]): void; /** * Gets the linear damping of a physics body. * @returns The linear damping of the body. */ getLinearDamping(): number; /** * Gets the mass properties of a physics body. * @returns The mass properties of the body. */ getMassProperties(): PhysicsMassProperties; /** * Sets the gravity factor of a body. * @param factor - The gravity factor to set. */ setGravityFactor(factor: number): void; /** * Gets the gravity factor of a body. * @returns The gravity factor of the body. */ getGravityFactor(): number; /** * Sets the linear damping of the given body. * @param damping - The linear damping to set. * * This method is useful for controlling the linear damping of a body in a physics engine. * Linear damping is a force that opposes the motion of the body, and is proportional to the velocity of the body. * This method allows the user to set the linear damping of a body, which can be used to control the motion of the body. */ setLinearDamping(damping: number): void; /** * Sets the angular damping of a physics body. * @param damping - The angular damping value to set. * * This function is useful for controlling the angular velocity of a physics body. * By setting the angular damping, the body's angular velocity will be reduced over time, allowing for more realistic physics simulations. */ setAngularDamping(damping: number): void; /** * Gets the angular damping of a physics body. * @returns The angular damping of the body. * * This function is useful for retrieving the angular damping of a physics body, * which is used to control the rotational motion of the body. The angular damping is a value between 0 and 1, where 0 is no damping and 1 is full damping. */ getAngularDamping(): number; /** * Gets the linear velocity of a physics body and stores it in a given vector. * @param body - The physics body to get the linear velocity from. * * This method is useful for retrieving the linear velocity of a physics body, * which can be used to determine the speed and direction of the body. This * information can be useful to simulate realistic physics behavior in a game. */ getLinearVelocityToRef(linVel: THREE.Vector3): void; getAngularVelocityToRef(angVel: THREE.Vector3): void; /** * Sets the motion type of a physics body. * Can be STATIC, DYNAMIC, or KINEMATIC. */ setMotionType(motionType: MotionType): void; /** * Gets the motion type of a physics body. */ getMotionType(): MotionType; /** * Sets the prestep type of a physics body. */ setPrestepType(prestepType: PhysicsPrestepType): void; /** * Gets the prestep type of a physics body. */ getPrestepType(): PhysicsPrestepType; /** * Defaults to the center of the rigid body. * The center of mass, in local space. This is The * point the body will rotate around when applying * an angular velocity. * * If not provided, the physics engine will compute * an appropriate value. * @zprop * @zgroup Mass * @zgrouppriority 22 * @zdefault [0,0,0] */ centerOfMass: Observable<[number, number, number] | undefined, never>; propsWorldTransform: Observable; onPropsTransformationChanged: () => void; attachTransformationListenersRecursive(component: Component): void; attachListeners: () => void; reset: () => void; dispose(): any; onCollision: Event<[IPhysicsCollisionEvent]>; reportCollisions: boolean; colliders: Collider[]; /** * Identifier for the physics body associated with this collider in the physics world. */ bodyId: HP_ShapeId; /** * Identifier for the shape used in the physics engine. */ containerShapeID: HP_ShapeId; _tempMatrix: THREE.Matrix4; _tempPosition: THREE.Vector3; _tempQuaternion: THREE.Quaternion; _tempScale: THREE.Vector3; _calculateQTransform(): [[number, number, number], [number, number, number, number]]; _syncTransform(position: THREE.Vector3, quaternion: THREE.Quaternion, scene: THREE.Scene): void; }; } & typeof Behavior; export declare class RigidBodyBehavior extends RigidBodyBehavior_base { constructor(contextManager: ContextManager, instance: Object3D, constructorProps: RigidBodyonstructorProps); private _onPhysicsStart; } export {};