Options
All
  • Public
  • Public/Protected
  • All
Menu

The Havok Physics plugin

Hierarchy

  • HavokPlugin

Implements

  • IPhysicsEnginePluginV2

Index

Constructors

  • new HavokPlugin(_useDeltaForWorldStep?: boolean, hpInjection?: any): HavokPlugin
  • Parameters

    • Optional _useDeltaForWorldStep: boolean
    • Optional hpInjection: any

    Returns HavokPlugin

Properties

_hknp: any

Reference to the WASM library

name: string

Name of the plugin

onCollisionEndedObservable: Observable<IBasePhysicsCollisionEvent>

Observable for collision ended events

onCollisionObservable: Observable<IPhysicsCollisionEvent>

Observable for collision started and collision continued events

onTriggerCollisionObservable: Observable<IBasePhysicsCollisionEvent>

Observable for trigger entered and trigger exited events

world: any

Created Havok world which physics bodies are added to

Accessors

  • get numBodies(): any
  • Gets the number of bodies in the world

    Returns any

Methods

  • Adds a child shape to the given shape.

    Parameters

    • shape: PhysicsShape

      The parent shape.

    • newChild: PhysicsShape

      The child shape to add.

    • Optional translation: Vector3

      The relative translation of the child from the parent shape

    • Optional rotation: Quaternion

      The relative rotation of the child from the parent shape

    • Optional scale: Vector3

      The relative scale scale of the child from the parent shaep

    Returns void

  • Adds a constraint to the physics engine.

    Parameters

    • body: PhysicsBody

      The main body to which the constraint is applied.

    • childBody: PhysicsBody

      The body to which the constraint is applied.

    • constraint: PhysicsConstraint

      The constraint to be applied.

    • Optional instanceIndex: number

      If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.

    • Optional childInstanceIndex: number

      If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.

    Returns void

  • Applies a force to a physics body at a given location.

    Parameters

    • body: PhysicsBody

      The physics body to apply the impulse to.

    • force: Vector3

      The force vector to apply.

    • location: Vector3

      The location in world space to apply the impulse.

    • Optional instanceIndex: number

      The index of the instance to apply the force to. If not specified, the force will be applied to all instances.

      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.

    Returns void

  • Applies an impulse to a physics body at a given location.

    Parameters

    • body: PhysicsBody

      The physics body to apply the impulse to.

    • impulse: Vector3

      The impulse vector to apply.

    • location: Vector3

      The location in world space to apply the impulse.

    • Optional instanceIndex: number

      The index of the instance to apply the impulse to. If not specified, the impulse will be applied to all instances.

      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.

    Returns void

  • Computes the mass properties of a physics body, from it's shape

    Parameters

    • body: PhysicsBody

      The physics body to copmute the mass properties of

    • Optional instanceIndex: number

    Returns PhysicsMassProperties

  • dispose(): void
  • Dispose the world and free resources

    Returns void

  • Disposes a physics body.

    Parameters

    • body: PhysicsBody

      The physics body to dispose.

      This method is useful for releasing the resources associated with a physics body when it is no longer needed. This is important for avoiding memory leaks in the physics engine.

    Returns void

  • Disposes a physics constraint.

    Parameters

    • constraint: PhysicsConstraint

      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.

    Returns void

  • Releases a physics shape from the physics engine.

    Parameters

    Returns void

    void

    This method is useful for releasing a physics shape from the physics engine, freeing up resources and preventing memory leaks.

  • executeStep(delta: number, physicsBodies: PhysicsBody[]): void
  • Executes a single step of the physics engine.

    Parameters

    • delta: number

      The time delta in seconds since the last step.

    • physicsBodies: PhysicsBody[]

      An array of physics bodies to be simulated.

    Returns void

    void

    This method is useful for simulating the physics engine. It sets the physics body transformation, steps the world, syncs the physics body, and notifies collisions. This allows for the physics engine to accurately simulate the physics bodies in the world.

  • getAngularDamping(body: PhysicsBody, instanceIndex?: number): number
  • Gets the angular damping of a physics body.

    Parameters

    • body: PhysicsBody

      The physics body to get the angular damping from.

    • Optional instanceIndex: number

    Returns number

    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.

  • Gets the angular velocity of a body.

    Parameters

    • body: PhysicsBody

      The body to get the angular velocity from.

    • angVel: Vector3

      The vector3 to store the angular velocity.

      This method is useful for getting the angular velocity of a body in a physics engine. It takes the body and a vector3 as parameters and stores the angular velocity of the body in the vector3. This is useful for getting the angular velocity of a body in order to calculate the motion of the body in the physics engine.

    • Optional instanceIndex: number

    Returns void

  • Gets the friction value of the specified axis of the given constraint.

    Parameters

    Returns Nullable<number>

    The friction value of the specified axis.

  • Gets the maximum limit of the given axis of the given constraint.

    Parameters

    Returns Nullable<number>

    The maximum limit of the given axis of the given constraint.

  • Gets the minimum limit of the specified axis of the given constraint.

    Parameters

    Returns Nullable<number>

    The minimum limit of the specified axis of the given constraint.

  • Gets the axis limit mode of the given constraint.

    Parameters

    Returns Nullable<PhysicsConstraintAxisLimitMode>

    The axis limit mode of the given constraint.

  • Gets the maximum force of the motor of the given constraint axis.

    Parameters

    Returns Nullable<number>

    The maximum force of the motor of the given constraint axis.

  • Gets the target of the motor of the given axis of the given constraint.

    Parameters

    Returns Nullable<number>

    The target of the motor of the given axis of the given constraint.

  • Gets the motor type of the specified axis of the given constraint.

    Parameters

    Returns Nullable<PhysicsConstraintMotorType>

    The motor type of the specified axis of the given constraint.

  • Get a list of all the pairs of bodies that are connected by this constraint.

    Parameters

    Returns ConstrainedBodyPair[]

    a list of parent, child pairs

  • getBodyGeometry(body: PhysicsBody): { indices: never[]; positions: never[] } | { indices: Uint32Array; positions: Float32Array }
  • Gets the geometry of a physics body.

    Parameters

    Returns { indices: never[]; positions: never[] } | { indices: Uint32Array; positions: Float32Array }

    An object containing the positions and indices of the body's geometry.

  • Calculates the bounding box of a given physics shape.

    Parameters

    • _shape: PhysicsShape

      The physics shape to calculate the bounding box for.

    Returns BoundingBox

    The calculated bounding box.

    This method is useful for physics engines as it allows to calculate the boundaries of a given shape. Knowing the boundaries of a shape is important for collision detection and other physics calculations.

  • Return the collision ended observable for a particular physics body.

    Parameters

    Returns Observable<IBasePhysicsCollisionEvent>

  • Return the collision observable for a particular physics body.

    Parameters

    Returns Observable<IPhysicsCollisionEvent>

  • Gets whether collisions are enabled for the given constraint.

    Parameters

    Returns boolean

    Whether collisions are enabled for the given constraint.

  • Calculates the density of a given physics shape.

    Parameters

    • shape: PhysicsShape

      The physics shape to calculate the density of.

    Returns number

    The density of the given physics shape.

  • Gets the enabled state of the given constraint.

    Parameters

    Returns boolean

    The enabled state of the given constraint.

  • getEventMask(body: PhysicsBody, instanceIndex?: number): number
  • Retrieves the event mask of a physics body.

    Parameters

    • body: PhysicsBody

      The physics body to retrieve the event mask from.

    • Optional instanceIndex: number

    Returns number

    The event mask of the physics body.

  • getGravityFactor(body: PhysicsBody, instanceIndex?: number): number
  • Get the gravity factor of a body

    Parameters

    • body: PhysicsBody

      the physics body to get the gravity factor from

    • Optional instanceIndex: number

      the index of the instance in an instanced body. If not specified, the gravity factor of the first instance will be returned.

    Returns number

    the gravity factor

  • getLinearDamping(body: PhysicsBody, instanceIndex?: number): number
  • Gets the linear damping of the given body.

    Parameters

    • body: PhysicsBody

      The body to get the linear damping from.

    • Optional instanceIndex: number

    Returns number

    The linear damping of the given body.

    This method is useful for getting 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. It is used to simulate the effects of air resistance and other forms of friction.

  • Gets the linear velocity of a physics body and stores it in a given vector.

    Parameters

    • body: PhysicsBody

      The physics body to get the linear velocity from.

    • linVel: Vector3

      The vector to store the linear velocity in.

      This function 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 used to simulate realistic physics behavior in a game.

    • Optional instanceIndex: number

    Returns void

  • Parameters

    Returns PhysicsMassProperties

  • Parameters

    Returns PhysicsMotionType

  • Returns the number of children of the given shape.

    Parameters

    • shape: PhysicsShape

      The shape to get the number of children from.

    Returns number

    The number of children of the given shape.

  • getPluginVersion(): number
  • Returns the version of the physics engine plugin.

    Returns number

    The version of the physics engine plugin.

    This method is useful for determining the version of the physics engine plugin that is currently running.

  • Gets the shape of a physics body. This will create a new shape object

    Parameters

    Returns Nullable<PhysicsShape>

    The shape of the physics body.

  • Parameters

    Returns number

  • Parameters

    Returns number

  • Gets the type of a physics shape.

    Parameters

    Returns PhysicsShapeType

    The type of the physics shape.

  • getTimeStep(): number
  • Gets the fixed time step used by the physics engine.

    Returns number

    The fixed time step used by the physics engine.

  • Initializes a physics body with the given position and orientation.

    Parameters

    • body: PhysicsBody

      The physics body to initialize.

    • motionType: PhysicsMotionType

      The motion type of the body.

    • position: Vector3

      The position of the body.

    • orientation: Quaternion

      The orientation of the body. This code is useful for initializing a physics body with the given position and orientation. It creates a plugin data for the body and adds it to the world. It then converts the position and orientation to a transform and sets the body's transform to the given values.

    Returns void

  • Initializes the body instances for a given physics body and mesh.

    Parameters

    • body: PhysicsBody

      The physics body to initialize.

    • motionType: PhysicsMotionType

      How the body will be handled by the engine

    • mesh: Mesh

      The mesh to initialize.

      This code is useful for creating a physics body from a mesh. It creates a body instance for each instance of the mesh and adds it to the world. It also sets the position of the body instance to the position of the mesh instance. This allows for the physics engine to accurately simulate the mesh in the world.

    Returns void

  • Initializes a physics constraint with the given parameters.

    Parameters

    • constraint: PhysicsConstraint

      The physics constraint to be initialized.

    • body: PhysicsBody

      The main body

    • childBody: PhysicsBody

      The child body.

    • Optional instanceIndex: number

      If this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.

    • Optional childInstanceIndex: number

      If the child body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.

      This function is useful for setting up a physics constraint in a physics engine.

    Returns void

  • Initializes a physics shape with the given type and parameters.

    Parameters

    • shape: PhysicsShape

      The physics shape to initialize.

    • type: PhysicsShapeType

      The type of shape to initialize.

    • options: PhysicsShapeParameters

      The parameters for the shape.

      This code is useful for initializing a physics shape with the given type and parameters. It allows for the creation of a sphere, box, capsule, container, cylinder, mesh, and heightfield. Depending on the type of shape, different parameters are required. For example, a sphere requires a radius, while a box requires extents and a rotation.

    Returns void

  • isSupported(): boolean
  • If this plugin is supported

    Returns boolean

    true if its supported

  • Performs a raycast from a given start point to a given end point and stores the result in a given PhysicsRaycastResult object.

    Parameters

    • from: Vector3

      The start point of the raycast.

    • to: Vector3

      The end point of the raycast.

    • result: PhysicsRaycastResult

      The PhysicsRaycastResult object to store the result of the raycast.

    • Optional query: IRaycastQuery

      The raycast query options. See IRaycastQuery for more information.

      Performs a raycast. It takes in two points, from and to, and a PhysicsRaycastResult object to store the result of the raycast. It then performs the raycast and stores the hit data in the PhysicsRaycastResult object.

    Returns void

  • Removes a body from the world. To dispose of a body, it is necessary to remove it from the world first.

    Parameters

    Returns void

  • Removes a child shape from a parent shape.

    Parameters

    • shape: PhysicsShape

      The parent shape.

    • childIndex: number

      The index of the child shape to remove.

    Returns void

  • setAngularDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void
  • Sets the angular damping of a physics body.

    Parameters

    • body: PhysicsBody

      The physics body to set the angular damping for.

    • damping: number

      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.

    • Optional instanceIndex: number

    Returns void

  • Sets the angular velocity of a physics body.

    Parameters

    • body: PhysicsBody

      The physics body to set the angular velocity of.

    • angVel: Vector3

      The angular velocity to set.

      This function is useful for setting the angular velocity of a physics body in a physics engine. This allows for more realistic simulations of physical objects, as they can be given a rotational velocity.

    • Optional instanceIndex: number

    Returns void

  • Sets the friction of the given axis of the given constraint.

    Parameters

    Returns void

    void

  • Sets the maximum limit of the given axis of the given constraint.

    Parameters

    • constraint: PhysicsConstraint

      The constraint to set the maximum limit of the given axis.

    • axis: PhysicsConstraintAxis

      The axis to set the maximum limit of.

    • limit: number

      The maximum limit to set.

    Returns void

  • Sets the minimum limit of the given axis of the given constraint.

    Parameters

    Returns void

  • Sets the limit mode of the specified axis of the given constraint.

    Parameters

    Returns void

  • Sets the maximum force that can be applied by the motor of the given constraint axis.

    Parameters

    • constraint: PhysicsConstraint

      The constraint to set the motor max force for.

    • axis: PhysicsConstraintAxis

      The axis of the constraint to set the motor max force for.

    • maxForce: number

      The maximum force that can be applied by the motor.

    Returns void

  • Sets the target of an axis motor of a constraint.

    Parameters

    • constraint: PhysicsConstraint

      The constraint to set the axis motor target of.

    • axis: PhysicsConstraintAxis

      The axis of the constraint to set the motor target of.

    • target: number

      The target of the axis motor.

    Returns void

  • Sets the motor type of the given axis of the given constraint.

    Parameters

    Returns void

    void

  • setCollisionCallbackEnabled(body: PhysicsBody, enabled: boolean): void
  • Enable collision to be reported for a body when a callback is setup on the world

    Parameters

    Returns void

  • setCollisionEndedCallbackEnabled(body: PhysicsBody, enabled: boolean): void
  • Enable collision ended to be reported for a body when a callback is setup on the world

    Parameters

    Returns void

  • Enables or disables collisions for the given constraint.

    Parameters

    • constraint: PhysicsConstraint

      The constraint to enable or disable collisions for.

    • isEnabled: boolean

      Whether collisions should be enabled or disabled.

    Returns void

  • Sets the density of a physics shape.

    Parameters

    • shape: PhysicsShape

      The physics shape to set the density of.

    • density: number

      The density to set.

    Returns void

  • Enables or disables a constraint in the physics engine.

    Parameters

    • constraint: PhysicsConstraint

      The constraint to enable or disable.

    • isEnabled: boolean

      Whether the constraint should be enabled or disabled.

    Returns void

  • setEventMask(body: PhysicsBody, eventMask: number, instanceIndex?: number): void
  • Sets the event mask of a physics body.

    Parameters

    • body: PhysicsBody

      The physics body to set the event mask for.

    • eventMask: number

      The event mask to set.

      This function is useful for setting the event mask of a physics body, which is used to determine which events the body will respond to. This is important for ensuring that the physics engine is able to accurately simulate the behavior of the body in the game world.

    • Optional instanceIndex: number

    Returns void

  • Sets the gravity of the physics world.

    Parameters

    • gravity: Vector3

      The gravity vector to set.

    Returns void

  • setGravityFactor(body: PhysicsBody, factor: number, instanceIndex?: number): void
  • Sets the gravity factor of a body

    Parameters

    • body: PhysicsBody

      the physics body to set the gravity factor for

    • factor: number

      the gravity factor

    • Optional instanceIndex: number

      the index of the instance in an instanced body

    Returns void

  • setLinearDamping(body: PhysicsBody, damping: number, instanceIndex?: number): void
  • Sets the linear damping of the given body.

    Parameters

    • body: PhysicsBody

      The body to set the linear damping for.

    • damping: number

      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.

    • Optional instanceIndex: number

    Returns void

  • Sets the linear velocity of a physics body.

    Parameters

    • body: PhysicsBody

      The physics body to set the linear velocity of.

    • linVel: Vector3

      The linear velocity to set.

      This function is useful for setting the linear velocity of a physics body, which is necessary for simulating motion in a physics engine. The linear velocity is the speed and direction of the body's movement.

    • Optional instanceIndex: number

    Returns void

  • Sets the mass properties of a physics body.

    Parameters

    • body: PhysicsBody

      The physics body to set the mass properties of.

    • massProps: PhysicsMassProperties

      The mass properties to set.

    • Optional instanceIndex: number

      The index of the instance to set the mass properties of. If undefined, the mass properties of all the bodies will be set. This function is useful for setting the mass properties of a physics body, such as its mass, inertia, and center of mass. This is important for accurately simulating the physics of the body in the physics engine.

    Returns void

  • Sets the material of a physics shape.

    Parameters

    Returns void

  • Parameters

    Returns void

  • Sets the transformation of the given physics body to the given transform node.

    Parameters

    • body: PhysicsBody

      The physics body to set the transformation for.

    • node: TransformNode

      The transform node to set the transformation from. Sets the transformation of the given physics body to the given transform node.

      This function is useful for setting the transformation of a physics body to a transform node, which is necessary for the physics engine to accurately simulate the motion of the body. It also takes into account instances of the transform node, which is necessary for accurate simulation of multiple bodies with the same transformation.

    Returns void

  • Sets the shape of a physics body.

    Parameters

    • body: PhysicsBody

      The physics body to set the shape for.

    • shape: Nullable<PhysicsShape>

      The physics shape to set.

      This function is used to set the shape of a physics body. It is useful for creating a physics body with a specific shape, such as a box or a sphere, which can then be used to simulate physical interactions in a physics engine. This function is especially useful for meshes with multiple instances, as it will set the shape for each instance of the mesh.

    Returns void

  • setShapeFilterCollideMask(shape: PhysicsShape, collideMask: number): void
  • Parameters

    Returns void

  • setShapeFilterMembershipMask(shape: PhysicsShape, membershipMask: number): void
  • Parameters

    Returns void

  • Set the target transformation (position and rotation) of the body, such that the body will set its velocity to reach that target

    Parameters

    • body: PhysicsBody

      The physics body to set the target transformation for.

    • position: Vector3

      The target position

    • rotation: Quaternion

      The target rotation

    • Optional instanceIndex: number

      The index of the instance in an instanced body

    Returns void

  • setTimeStep(timeStep: number): void
  • Sets the fixed time step for the physics engine.

    Parameters

    • timeStep: number

      The fixed time step to use for the physics engine.

    Returns void

  • Marks the shape as a trigger

    Parameters

    • shape: PhysicsShape

      the shape to mark as a trigger

    • isTrigger: boolean

      if the shape is a trigger

    Returns void

  • Synchronizes the transform of a physics body with its transform node.

    Parameters

    • body: PhysicsBody

      The physics body to synchronize.

      This function is useful for keeping the physics body's transform in sync with its transform node. This is important for ensuring that the physics body is accurately represented in the physics engine.

    Returns void

  • Synchronizes the transform of a physics body with the transform of its corresponding transform node.

    Parameters

    • body: PhysicsBody

      The physics body to synchronize.

    • transformNode: TransformNode

      The destination Transform Node.

      This code is useful for synchronizing the position and orientation of a physics body with the position and orientation of its corresponding transform node. This is important for ensuring that the physics body and the transform node are in the same position and orientation in the scene. This is necessary for the physics engine to accurately simulate the physical behavior of the body.

    Returns void

  • Update the internal body instances for a given physics body to match the instances in a mesh.

    Parameters

    • body: PhysicsBody

      the body that will be updated

    • mesh: Mesh

      the mesh with reference instances

    Returns void

Legend

  • Constructor
  • Property
  • Method
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Property
  • Method
  • Static method

Settings

Theme