Class HavokPlugin
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
-
new HavokPlugin(
_useDeltaForWorldStep?: boolean,
hpInjection?: any,
parameters?: HavokPluginParameters,
): HavokPluginParameters
- _useDeltaForWorldStep: boolean = true
- hpInjection: any = HK
- parameters: HavokPluginParameters = {}
Returns HavokPlugin
Properties
_ hknp
Reference to the WASM library
name
Name of the plugin
on Collision Ended Observable
Observable for collision ended events
on Collision Observable
Observable for collision started and collision continued events
on Trigger Collision Observable
Observable for trigger entered and trigger exited events
world
Created Havok world which physics bodies are added to (default world for non-floating-origin)
Methods
_ internal Set Motion Type
-
Parameters
- pluginData: BodyPluginData
- motionType: PhysicsMotionType
Returns void
add Child
-
addChild(
shape: PhysicsShape,
newChild: PhysicsShape,
translation?: Vector3,
rotation?: Quaternion,
scale?: Vector3,
): voidAdds a child shape to the given shape.
Parameters
- shape: PhysicsShape
The parent shape.
- newChild: PhysicsShape
The child shape to add.
Optionaltranslation: Vector3The relative translation of the child from the parent shape
Optionalrotation: QuaternionThe relative rotation of the child from the parent shape
Optionalscale: Vector3The relative scale scale of the child from the parent shaep
Returns void
- shape: PhysicsShape
add Constraint
-
addConstraint(
body: PhysicsBody,
childBody: PhysicsBody,
constraint: PhysicsConstraint,
instanceIndex?: number,
childInstanceIndex?: number,
): voidAdds 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.
OptionalinstanceIndex: numberIf this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.
OptionalchildInstanceIndex: numberIf 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
- body: PhysicsBody
apply Angular Impulse
-
Applies an angular impulse(torque) to a physics body
Parameters
- body: PhysicsBody
The physics body to apply the impulse to.
- angularImpulse: Vector3
The torque value
OptionalinstanceIndex: numberThe index of the instance to apply the impulse to. If not specified, the impulse will be applied to all instances.
Returns void
- body: PhysicsBody
apply Force
-
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.
OptionalinstanceIndex: numberThe 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
- body: PhysicsBody
apply Impulse
-
applyImpulse(
body: PhysicsBody,
impulse: Vector3,
location: Vector3,
instanceIndex?: number,
): voidApplies 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.
OptionalinstanceIndex: numberThe 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
- body: PhysicsBody
apply Torque
-
Applies a torque to a physics body.
Parameters
- body: PhysicsBody
The physics body to apply the torque to.
- torque: Vector3
The torque vector.
OptionalinstanceIndex: numberThe index of the instance to apply the torque to. If not specified, the torque will be applied to all instances.
This method is useful for applying a torque to a physics body. This can be used to simulate rotational forces such as motors, angular momentum, and rotational dynamics.
Returns void
- body: PhysicsBody
compute Mass Properties
-
Computes the mass properties of a physics body, from it's shape
Parameters
- body: PhysicsBody
The physics body to copmute the mass properties of
OptionalinstanceIndex: numberThe index of the instance to compute the mass properties of.
Returns PhysicsMassProperties
The mass properties of the physics body.
- body: PhysicsBody
dispose
-
Dispose the world and free resources
Returns void
dispose Body
-
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
- body: PhysicsBody
dispose Constraint
-
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
- constraint: PhysicsConstraint
dispose Shape
-
Releases a physics shape from the physics engine.
Parameters
- shape: PhysicsShape
The physics shape to be released.
This method is useful for releasing a physics shape from the physics engine, freeing up resources and preventing memory leaks.
Returns void
- shape: PhysicsShape
execute Step
-
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.
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.
Returns void
- delta: number
get Angular Damping
-
Gets the angular damping of a physics body.
Parameters
- body: PhysicsBody
The physics body to get the angular damping from.
OptionalinstanceIndex: numberThe index of the instance to get the angular damping from. If not specified, the angular damping of the first instance will be returned.
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.
- body: PhysicsBody
get Angular Velocity To Ref
-
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.
OptionalinstanceIndex: numberThe index of the instance to get the angular velocity from. If not specified, the angular velocity of the first instance will be returned.
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.
Returns void
- body: PhysicsBody
get Axis Friction
-
Gets the friction value of the specified axis of the given constraint.
Parameters
- constraint: PhysicsConstraint
The constraint to get the axis friction from.
- axis: PhysicsConstraintAxis
The axis to get the friction from.
Returns Nullable<number>
The friction value of the specified axis.
- constraint: PhysicsConstraint
get Axis Max Limit
-
Gets the maximum limit of the given axis of the given constraint.
Parameters
- constraint: PhysicsConstraint
The constraint to get the maximum limit from.
- axis: PhysicsConstraintAxis
The axis to get the maximum limit from.
Returns Nullable<number>
The maximum limit of the given axis of the given constraint.
- constraint: PhysicsConstraint
get Axis Min Limit
-
Gets the minimum limit of the specified axis of the given constraint.
Parameters
- constraint: PhysicsConstraint
The constraint to get the minimum limit from.
- axis: PhysicsConstraintAxis
The axis to get the minimum limit from.
Returns Nullable<number>
The minimum limit of the specified axis of the given constraint.
- constraint: PhysicsConstraint
get Axis Mode
-
getAxisMode(
constraint: PhysicsConstraint,
axis: PhysicsConstraintAxis,
): Nullable<PhysicsConstraintAxisLimitMode>Gets the axis limit mode of the given constraint.
Parameters
- constraint: PhysicsConstraint
The constraint to get the axis limit mode from.
- axis: PhysicsConstraintAxis
The axis to get the limit mode from.
Returns Nullable<PhysicsConstraintAxisLimitMode>
The axis limit mode of the given constraint.
- constraint: PhysicsConstraint
get Axis Motor Max Force
-
getAxisMotorMaxForce(
constraint: PhysicsConstraint,
axis: PhysicsConstraintAxis,
): Nullable<number>Gets the maximum force of the motor of the given constraint axis.
Parameters
- constraint: PhysicsConstraint
The constraint to get the motor maximum force from.
- axis: PhysicsConstraintAxis
The axis of the constraint to get the motor maximum force from.
Returns Nullable<number>
The maximum force of the motor of the given constraint axis.
- constraint: PhysicsConstraint
get Axis Motor Target
-
Gets the target of the motor of the given axis of the given constraint.
Parameters
- constraint: PhysicsConstraint
The constraint to get the motor target from.
- axis: PhysicsConstraintAxis
The axis of the constraint to get the motor target from.
Returns Nullable<number>
The target of the motor of the given axis of the given constraint.
- constraint: PhysicsConstraint
get Axis Motor Type
-
getAxisMotorType(
constraint: PhysicsConstraint,
axis: PhysicsConstraintAxis,
): Nullable<PhysicsConstraintMotorType>Gets the motor type of the specified axis of the given constraint.
Parameters
- constraint: PhysicsConstraint
The constraint to get the motor type from.
- axis: PhysicsConstraintAxis
The axis of the constraint to get the motor type from.
Returns Nullable<PhysicsConstraintMotorType>
The motor type of the specified axis of the given constraint.
- constraint: PhysicsConstraint
get Bodies Using Constraint
-
Get a list of all the pairs of bodies that are connected by this constraint.
Parameters
- constraint: PhysicsConstraint
the constraint to search from
Returns ConstrainedBodyPair[]
a list of parent, child pairs
- constraint: PhysicsConstraint
get Body Bounding Box
-
Calculates the world bounding box of a given physics body.
Parameters
- body: PhysicsBody
The physics body 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 body.
- body: PhysicsBody
get Body Geometry
-
getBodyGeometry(
body: PhysicsBody,
): {
indices: number[] | Uint32Array<ArrayBufferLike>;
positions: number[] | Float32Array<ArrayBufferLike>;
}Gets the geometry of a physics body.
Parameters
- body: PhysicsBody
The physics body.
Returns {
indices: number[] | Uint32Array<ArrayBufferLike>;
positions: number[] | Float32Array<ArrayBufferLike>;
}An object containing the positions and indices of the body's geometry.
- body: PhysicsBody
get Bounding Box
-
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.
- _shape: PhysicsShape
get Collision Ended Observable
-
getCollisionEndedObservable(
body: PhysicsBody,
instanceIndex?: number,
): Observable<IBasePhysicsCollisionEvent>Return the collision ended observable for a particular physics body.
Parameters
- body: PhysicsBody
the physics body
OptionalinstanceIndex: numberoptionally, the index of the instance in the body
Returns Observable<IBasePhysicsCollisionEvent>
the collision ended observable for the body
- body: PhysicsBody
get Collision Observable
-
getCollisionObservable(
body: PhysicsBody,
instanceIndex?: number,
): Observable<IPhysicsCollisionEvent>Return the collision observable for a particular physics body.
Parameters
- body: PhysicsBody
the physics body
OptionalinstanceIndex: numberoptionally, the index of the instance in the body
Returns Observable<IPhysicsCollisionEvent>
the collision observable for the body
- body: PhysicsBody
get Collisions Enabled
-
Gets whether collisions are enabled for the given constraint.
Parameters
- constraint: PhysicsConstraint
The constraint to get collisions enabled for.
Returns boolean
Whether collisions are enabled for the given constraint.
- constraint: PhysicsConstraint
get Density
-
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.
- shape: PhysicsShape
get Enabled
-
Gets the enabled state of the given constraint.
Parameters
- constraint: PhysicsConstraint
The constraint to get the enabled state from.
Returns boolean
The enabled state of the given constraint.
- constraint: PhysicsConstraint
get Event Mask
-
Retrieves the event mask of a physics body.
Parameters
- body: PhysicsBody
The physics body to retrieve the event mask from.
OptionalinstanceIndex: numberThe index of the instance to retrieve the event mask from.
Returns number
The event mask of the physics body.
- body: PhysicsBody
get Gravity
get Gravity Factor
-
Get the gravity factor of a body
Parameters
- body: PhysicsBody
the physics body to get the gravity factor from
OptionalinstanceIndex: numberthe 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
- body: PhysicsBody
get Linear Damping
-
Gets the linear damping of the given body.
Parameters
- body: PhysicsBody
The body to get the linear damping from.
OptionalinstanceIndex: numberThe index of the instance to get the linear damping from. If not specified, the linear damping of the first instance will be returned.
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.
- body: PhysicsBody
get Linear Velocity To Ref
-
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.
OptionalinstanceIndex: numberThe index of the instance to get the linear velocity from. If not specified, the linear velocity of the first instance will be returned.
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.
Returns void
- body: PhysicsBody
get Mass Properties
-
Gets the mass properties of a physics body.
Parameters
- body: PhysicsBody
The physics body to get the mass properties from.
OptionalinstanceIndex: numberThe index of the instance to get the mass properties from. If not specified, the mass properties of the first instance will be returned.
Returns PhysicsMassProperties
The mass properties of the physics body.
- body: PhysicsBody
get Material
-
Gets the material associated with a physics shape.
Parameters
- shape: PhysicsShape
The shape to get the material from.
Returns PhysicsMaterial
The material associated with the shape.
- shape: PhysicsShape
get Max Angular Velocity
-
Returns number
maximum allowed angular velocity
get Max Linear Velocity
-
Returns number
maximum allowed linear velocity
get Max Query Collector Hits
-
Gets the maximum number of raycast hits to process.
Returns number
The maximum number of raycast hits to process.
get Motion Type
-
Gets the motion type of a physics body.
Parameters
- body: PhysicsBody
The physics body to get the motion type from.
OptionalinstanceIndex: numberThe index of the instance to get the motion type from. If not specified, the motion type of the first instance will be returned.
Returns PhysicsMotionType
The motion type of the physics body.
- body: PhysicsBody
get Num Children
-
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.
- shape: PhysicsShape
get Plugin Version
-
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.
get Shape
-
Gets the shape of a physics body. This will create a new shape object
Parameters
- body: PhysicsBody
The physics body.
Returns Nullable<PhysicsShape>
The shape of the physics body.
- body: PhysicsBody
get Shape Filter Collide Mask
-
Gets the shape filter collide mask of a body
Parameters
- shape: PhysicsShape
The physics body to get the shape filter collide mask from.
Returns number
The shape filter collide mask of the given body.
- shape: PhysicsShape
get Shape Filter Membership Mask
-
Gets the shape filter membership mask of a body
Parameters
- shape: PhysicsShape
The physics body to get the shape filter membership mask from.
Returns number
The shape filter membership mask of the given body.
- shape: PhysicsShape
get Shape Type
-
Gets the type of a physics shape.
Parameters
- shape: PhysicsShape
The physics shape to get the type for.
Returns PhysicsShapeType
The type of the physics shape.
- shape: PhysicsShape
get Time Step
-
Gets the fixed time step used by the physics engine.
Returns number
The fixed time step used by the physics engine.
init Body
-
initBody(
body: PhysicsBody,
motionType: PhysicsMotionType,
position: Vector3,
orientation: Quaternion,
): voidInitializes 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
- body: PhysicsBody
init Body Instances
-
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
- body: PhysicsBody
init Constraint
-
initConstraint(
constraint: PhysicsConstraint,
body: PhysicsBody,
childBody: PhysicsBody,
instanceIndex?: number,
childInstanceIndex?: number,
): voidInitializes 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.
OptionalinstanceIndex: numberIf this body is instanced, the index of the instance to which the constraint will be applied. If not specified, no constraint will be applied.
OptionalchildInstanceIndex: numberIf 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
- constraint: PhysicsConstraint
init Shape
-
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
- shape: PhysicsShape
is Supported
-
If this plugin is supported
Returns boolean
true if its supported
point Proximity
-
Given a point, returns the closest physics body to that point.
Parameters
- query: IPhysicsPointProximityQuery
the query to perform.
- result: ProximityCastResult
contact point on the hit shape, in world space
Returns void
- query: IPhysicsPointProximityQuery
raycast
-
raycast(
from: Vector3,
to: Vector3,
result: PhysicsRaycastResult | PhysicsRaycastResult[],
query?: IRaycastQuery,
): voidPerforms 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 | PhysicsRaycastResult[]
The PhysicsRaycastResult object (or array of PhysicsRaycastResults) to store the result of the raycast.
Optionalquery: IRaycastQueryThe 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. If result is an empty array, it will be populated with every detected raycast hit. If result is a populated array, it will only fill the PhysicsRaycastResults present in the array.
Returns void
- from: Vector3
remove Body
-
Removes a body from the world. To dispose of a body, it is necessary to remove it from the world first.
Parameters
- body: PhysicsBody
The body to remove.
Returns void
- body: PhysicsBody
remove Child
-
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
- shape: PhysicsShape
set Activation Control
-
sets the activation control mode of a physics body, for instance if you need the body to never sleep.
Parameters
- body: PhysicsBody
The physics body to set the activation control mode.
- controlMode: PhysicsActivationControl
The activation control mode.
Returns void
- body: PhysicsBody
set Angular Damping
-
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.
OptionalinstanceIndex: numberThe index of the instance to set the angular damping for. If not specified, the angular damping of the first instance will be 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.
Returns void
- body: PhysicsBody
set Angular Velocity
-
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.
OptionalinstanceIndex: numberThe index of the instance to set the angular velocity of. If not specified, the angular velocity of the first instance will be 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.
Returns void
- body: PhysicsBody
set Axis Friction
-
setAxisFriction(
constraint: PhysicsConstraint,
axis: PhysicsConstraintAxis,
friction: number,
): voidSets the friction of the given axis of the given constraint.
Parameters
- constraint: PhysicsConstraint
The constraint to set the friction of.
- axis: PhysicsConstraintAxis
The axis of the constraint to set the friction of.
- friction: number
The friction to set.
Returns void
- constraint: PhysicsConstraint
set Axis Max Limit
-
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
- constraint: PhysicsConstraint
set Axis Min Limit
-
Sets the minimum limit of the given axis of the given constraint.
Parameters
- constraint: PhysicsConstraint
The constraint to set the minimum limit of.
- axis: PhysicsConstraintAxis
The axis to set the minimum limit of.
- limit: number
The minimum limit to set.
Returns void
- constraint: PhysicsConstraint
set Axis Mode
-
setAxisMode(
constraint: PhysicsConstraint,
axis: PhysicsConstraintAxis,
limitMode: PhysicsConstraintAxisLimitMode,
): voidSets the limit mode of the specified axis of the given constraint.
Parameters
- constraint: PhysicsConstraint
The constraint to set the axis mode of.
- axis: PhysicsConstraintAxis
The axis to set the limit mode of.
- limitMode: PhysicsConstraintAxisLimitMode
The limit mode to set.
Returns void
- constraint: PhysicsConstraint
set Axis Motor Max Force
-
setAxisMotorMaxForce(
constraint: PhysicsConstraint,
axis: PhysicsConstraintAxis,
maxForce: number,
): voidSets 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
- constraint: PhysicsConstraint
set Axis Motor Target
-
setAxisMotorTarget(
constraint: PhysicsConstraint,
axis: PhysicsConstraintAxis,
target: number,
): voidSets 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
- constraint: PhysicsConstraint
set Axis Motor Type
-
setAxisMotorType(
constraint: PhysicsConstraint,
axis: PhysicsConstraintAxis,
motorType: PhysicsConstraintMotorType,
): voidSets the motor type of the given axis of the given constraint.
Parameters
- constraint: PhysicsConstraint
The constraint to set the motor type of.
- axis: PhysicsConstraintAxis
The axis of the constraint to set the motor type of.
- motorType: PhysicsConstraintMotorType
The motor type to set.
Returns void
- constraint: PhysicsConstraint
set Collision Callback Enabled
-
Enable collision to be reported for a body when a callback is setup on the world
Parameters
- body: PhysicsBody
the physics body
- enabled: boolean
whether to enable or disable collision events
Returns void
- body: PhysicsBody
set Collision Ended Callback Enabled
-
Enable collision ended to be reported for a body when a callback is setup on the world
Parameters
- body: PhysicsBody
the physics body
- enabled: boolean
whether to enable or disable collision ended events
Returns void
- body: PhysicsBody
set Collisions Enabled
-
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
- constraint: PhysicsConstraint
set Density
-
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
- shape: PhysicsShape
set Enabled
-
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
- constraint: PhysicsConstraint
set Event Mask
-
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.
OptionalinstanceIndex: numberThe index of the instance to set the event mask for
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.
Returns void
- body: PhysicsBody
set Gravity
-
Sets the gravity of the physics world.
Parameters
- gravity: Vector3
The gravity vector to set.
OptionalworldPosition: Vector3Optional world position to specify which region's gravity to set. If provided, only the region containing this position will be updated. If not provided, all regions will be updated (default behavior). This is useful for planetary scenarios where gravity direction varies by location.
Returns void
- gravity: Vector3
set Gravity Factor
-
Sets the gravity factor of a body
Parameters
- body: PhysicsBody
the physics body to set the gravity factor for
- factor: number
the gravity factor
OptionalinstanceIndex: numberthe index of the instance in an instanced body
Returns void
- body: PhysicsBody
set Linear Damping
-
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.
OptionalinstanceIndex: numberThe index of the instance to set the linear damping for. If not specified, the linear damping of the first instance will be 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.
Returns void
- body: PhysicsBody
set Linear Velocity
-
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.
OptionalinstanceIndex: numberThe index of the instance to set the linear velocity of. If not specified, the linear velocity of the first instance will be 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.
Returns void
- body: PhysicsBody
set Mass Properties
-
setMassProperties(
body: PhysicsBody,
massProps: PhysicsMassProperties,
instanceIndex?: number,
): voidSets 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.
OptionalinstanceIndex: numberThe 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
- body: PhysicsBody
set Material
-
Sets the material of a physics shape.
Parameters
- shape: PhysicsShape
The physics shape to set the material of.
- material: PhysicsMaterial
The material to set.
Returns void
- shape: PhysicsShape
set Max Query Collector Hits
-
Sets the maximum number of raycast hits to process.
Parameters
- maxQueryCollectorHits: number
The maximum number of raycast hits to process.
Returns void
- maxQueryCollectorHits: number
set Motion Type
-
sets the motion type of a physics body.
Parameters
- body: PhysicsBody
The physics body to set the motion type for.
- motionType: PhysicsMotionType
The motion type to set.
OptionalinstanceIndex: numberThe index of the instance to set the motion type for. If undefined, the motion type of all the bodies will be set.
Returns void
- body: PhysicsBody
set Physics Body Transformation
-
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
- body: PhysicsBody
set Shape
-
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
- body: PhysicsBody
set Shape Filter Collide Mask
-
Sets the shape filter collide mask of a body
Parameters
- shape: PhysicsShape
The physics body to set the shape filter collide mask for.
- collideMask: number
The shape filter collide mask to set.
Returns void
- shape: PhysicsShape
set Shape Filter Membership Mask
-
Sets the shape filter membership mask of a body
Parameters
- shape: PhysicsShape
The physics body to set the shape filter membership mask for.
- membershipMask: number
The shape filter membership mask to set.
Returns void
- shape: PhysicsShape
set Target Transform
-
setTargetTransform(
body: PhysicsBody,
position: Vector3,
rotation: Quaternion,
instanceIndex?: number,
): voidSet 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
OptionalinstanceIndex: numberThe index of the instance in an instanced body
Returns void
- body: PhysicsBody
set Time Step
-
Sets the fixed time step for the physics engine.
Parameters
- timeStep: number
The fixed time step to use for the physics engine.
Returns void
- timeStep: number
set Trigger
-
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
- shape: PhysicsShape
set Velocity Limits
-
Set the maximum allowed linear and angular velocities
Parameters
- maxLinearVelocity: number
maximum allowed linear velocity
- maxAngularVelocity: number
maximum allowed angular velocity
Returns void
- maxLinearVelocity: number
shape Cast
-
shapeCast(
query: IPhysicsShapeCastQuery,
inputShapeResult: ShapeCastResult,
hitShapeResult: ShapeCastResult,
): voidGiven a shape in a specific orientation, cast it from the start to end position specified by the query, and return the first hit.
Parameters
- query: IPhysicsShapeCastQuery
the query to perform.
- inputShapeResult: ShapeCastResult
contact point on input shape, in input shape space
- hitShapeResult: ShapeCastResult
contact point on hit shape, in world space
Returns void
- query: IPhysicsShapeCastQuery
shape Proximity
-
shapeProximity(
query: IPhysicsShapeProximityCastQuery,
inputShapeResult: ProximityCastResult,
hitShapeResult: ProximityCastResult,
): voidGiven a shape in a specific position and orientation, returns the closest point to that shape.
Parameters
- query: IPhysicsShapeProximityCastQuery
the query to perform.
- inputShapeResult: ProximityCastResult
contact point on input shape, in input shape space
- hitShapeResult: ProximityCastResult
contact point on hit shape, in world space
Returns void
- query: IPhysicsShapeProximityCastQuery
sync
-
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
- body: PhysicsBody
sync Transform
-
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
- body: PhysicsBody
update Body Instances
-
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
- body: PhysicsBody
The Havok Physics plugin