Class PhysicsEngineV2
Implements
- IPhysicsEngine
Constructors
constructor
-
new PhysicsEngineV2(
gravity: Nullable<Vector3>,
_physicsPlugin?: IPhysicsEnginePluginV2,
): PhysicsEngineV2
Methods
_ step
-
Called by the scene. No need to call it.
Parameters
- delta: number
defines the timespan between frames
Returns void
- delta: number
add Body
-
Add a body as an active component of this engine
Parameters
- physicsBody: PhysicsBody
The body to add
Returns void
- physicsBody: PhysicsBody
dispose
-
Release all resources
Returns void
get Bodies
-
Returns PhysicsBody[]
an array of bodies added to this engine
get Max Angular Velocity
-
Returns number
maximum allowed angular velocity
get Max Linear Velocity
-
Returns number
maximum allowed linear velocity
get Physics Plugin
-
Gets the current plugin used to run the simulation
Returns IPhysicsEnginePluginV2
current plugin
get Physics Plugin Name
-
Gets the name of the current physics plugin
Returns string
the name of the plugin
get Plugin Version
-
Returns number
physics plugin version
get Sub Time Step
-
Get the sub time step of the physics engine.
Returns number
the current sub time step
get Time Step
-
Get the time step of the physics engine.
Returns number
the current time step
raycast
-
Does a raycast in the physics world
Parameters
- from: Vector3
when should the ray start?
- to: Vector3
when should the ray end?
Optionalquery: IRaycastQueryraycast query object
Returns PhysicsRaycastResult
PhysicsRaycastResult
- from: Vector3
raycast Multi
-
Does a raycast through multiple objects in the physics world
Parameters
- from: Vector3
when should the ray start?
- to: Vector3
when should the ray end?
Optionalquery: IRaycastQueryraycast query object
Returns PhysicsRaycastResult[]
array of PhysicsRaycastResult
- from: Vector3
raycast To Ref
-
raycastToRef(
from: Vector3,
to: Vector3,
result: PhysicsRaycastResult | PhysicsRaycastResult[],
query?: IRaycastQuery,
): voidDoes a raycast in the physics world
Parameters
- from: Vector3
when should the ray start?
- to: Vector3
when should the ray end?
- result: PhysicsRaycastResult | PhysicsRaycastResult[]
resulting PhysicsRaycastResult or array of PhysicsRaycastResults
Optionalquery: IRaycastQueryraycast query 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 particular body from this engine
Parameters
- physicsBody: PhysicsBody
The body to remove from the simulation
Returns void
- physicsBody: PhysicsBody
set Gravity
-
Sets the gravity vector used by the simulation
Parameters
- gravity: Vector3
defines the gravity vector to use
Returns void
- gravity: Vector3
set Sub Time Step
-
Set the sub time step of the physics engine. Default is 0 meaning there is no sub steps To increase physics resolution precision, set a small value (like 1 ms)
Parameters
- subTimeStep: number = 0
defines the new sub timestep used for physics resolution.
Returns void
- subTimeStep: number = 0
set Time Step
-
Set the time step of the physics engine. Default is 1/60. To slow it down, enter 1/600 for example. To speed it up, 1/30 Unit is seconds.
Parameters
- newTimeStep: number = ...
defines the new timestep to apply to this world.
Returns void
- newTimeStep: number = ...
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
StaticDefault Plugin Factory
-
Factory used to create the default physics plugin.
Returns IPhysicsEnginePluginV2
The default physics plugin
Class used to control physics engine
See
https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine