Class PhysicsEngine
Implements
- IPhysicsEngine
Constructors
constructor
-
new PhysicsEngine(
gravity: Nullable<Vector3>,
_physicsPlugin?: IPhysicsEnginePlugin,
): PhysicsEngine
Methods
_ step
-
Called by the scene. No need to call it.
Parameters
- delta: number
defines the timespan between frames
Returns void
- delta: number
add Impostor
-
Adding a new impostor for the impostor tracking. This will be done by the impostor itself.
Parameters
- impostor: PhysicsImpostor
the impostor to add
Returns void
- impostor: PhysicsImpostor
add Joint
-
addJoint(
mainImpostor: PhysicsImpostor,
connectedImpostor: PhysicsImpostor,
joint: PhysicsJoint,
): voidAdd a joint to the physics engine
Parameters
- mainImpostor: PhysicsImpostor
defines the main impostor to which the joint is added.
- connectedImpostor: PhysicsImpostor
defines the impostor that is connected to the main impostor using this joint
- joint: PhysicsJoint
defines the joint that will connect both impostors.
Returns void
- mainImpostor: PhysicsImpostor
dispose
-
Release all resources
Returns void
get Impostor For Physics Object
-
Gets the impostor for a physics enabled object
Parameters
- object: IPhysicsEnabledObject
defines the object impersonated by the impostor
Returns Nullable<PhysicsImpostor>
the PhysicsImpostor or null if not found
- object: IPhysicsEnabledObject
get Impostors
get Impostor With Physics Body
-
Gets the impostor for a physics body object
Parameters
- body: any
defines physics body used by the impostor
Returns Nullable<PhysicsImpostor>
the PhysicsImpostor or null if not found
- body: any
get Physics Plugin
-
Gets the current plugin used to run the simulation
Returns IPhysicsEnginePlugin
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
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
raycast To Ref
-
Does a raycast in the physics world
Parameters
- from: Vector3
when should the ray start?
- to: Vector3
when should the ray end?
- result: PhysicsRaycastResult
resulting PhysicsRaycastResult
Returns void
true if the ray hits an impostor, else false
- from: Vector3
remove Impostor
-
Remove an impostor from the engine. This impostor and its mesh will not longer be updated by the physics engine.
Parameters
- impostor: PhysicsImpostor
the impostor to remove
Returns void
- impostor: PhysicsImpostor
remove Joint
-
removeJoint(
mainImpostor: PhysicsImpostor,
connectedImpostor: PhysicsImpostor,
joint: PhysicsJoint,
): voidRemoves a joint from the simulation
Parameters
- mainImpostor: PhysicsImpostor
defines the impostor used with the joint
- connectedImpostor: PhysicsImpostor
defines the other impostor connected to the main one by the joint
- joint: PhysicsJoint
defines the joint to remove
Returns void
- mainImpostor: PhysicsImpostor
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
Parameters
- newTimeStep: number = ...
defines the new timestep to apply to this world.
Returns void
- newTimeStep: number = ...
StaticDefault Plugin Factory
-
Factory used to create the default physics plugin.
Returns IPhysicsEnginePlugin
The default physics plugin
Class used to control physics engine
See
https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine