Class PhysicsEngineV2
Hierarchy
- PhysicsEngineV2
Implements
Index
Constructors
constructor
Creates a new Physics Engine
Parameters
gravity: Nullable<Vector3>
defines the gravity vector used by the simulation
Optional _physicsPlugin: IPhysicsEnginePluginV2
defines the plugin to use (CannonJS by default)
Returns PhysicsEngineV2
Properties
gravitySearch playground for gravity
Gets the gravity vector used by the simulation
Methods
_stepSearch playground for _step
Called by the scene. No need to call it.
Parameters
delta: number
defines the timespan between frames
Returns void
add BodySearch playground for addBody
Add a body as an active component of this engine
Parameters
physicsBody: PhysicsBody
Returns void
disposeSearch playground for dispose
Release all resources
Returns void
get BodiesSearch playground for getBodies
Returns an array of bodies added to this engine
Returns PhysicsBody[]
get Physics PluginSearch playground for getPhysicsPlugin
Gets the current plugin used to run the simulation
Returns IPhysicsEnginePluginV2
current plugin
get Physics Plugin NameSearch playground for getPhysicsPluginName
Gets the name of the current physics plugin
Returns string
the name of the plugin
get Plugin VersionSearch playground for getPluginVersion
Returns number
physics plugin version
get Sub Time StepSearch playground for getSubTimeStep
Get the sub time step of the physics engine.
Returns number
the current sub time step
get Time StepSearch playground for getTimeStep
Get the time step of the physics engine.
Returns number
the current time step
raycastSearch playground for raycast
Does a raycast in the physics world
Parameters
Returns PhysicsRaycastResult
PhysicsRaycastResult
raycast To RefSearch playground for raycastToRef
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
remove BodySearch playground for removeBody
Removes a particular body from this engine
Parameters
physicsBody: PhysicsBody
Returns void
set GravitySearch playground for setGravity
Sets the gravity vector used by the simulation
Parameters
gravity: Vector3
defines the gravity vector to use
Returns void
set Sub Time StepSearch playground for setSubTimeStep
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
Optional subTimeStep: number
defines the new sub timestep used for physics resolution.
Returns void
set Time StepSearch playground for setTimeStep
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
Optional newTimeStep: number
defines the new timestep to apply to this world.
Returns void
Static Default Plugin FactorySearch playground for DefaultPluginFactory
Factory used to create the default physics plugin.
Returns IPhysicsEnginePluginV2
The default physics plugin
Class used to control physics engine
https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine