Class AmmoJSPlugin
Index
Constructors
Properties
Methods
Constructors
constructor
-
new AmmoJSPlugin(
_useDeltaForWorldStep?: boolean,
ammoInjection?: any,
overlappingPairCache?: any,
): AmmoJSPluginInitializes the ammoJS plugin
Parameters
- _useDeltaForWorldStep: boolean = true
if the time between frames should be used when calculating physics steps (Default: true)
- ammoInjection: any = Ammo
can be used to inject your own ammo reference
- overlappingPairCache: any = null
can be used to specify your own overlapping pair cache
Returns AmmoJSPlugin
- _useDeltaForWorldStep: boolean = true
Properties
bjs AMMO
Reference to the Ammo library
name
Name of the plugin
on Create Custom Convex Hull Impostor
The create custom convex hull impostor handler function to support building custom convex hull impostor vertex data
on Create Custom Mesh Impostor
The create custom mesh impostor handler function to support building custom mesh impostor vertex data
on Create Custom Shape
The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
world
Created ammoJS world which physics bodies are added to
Methods
append Anchor
-
appendAnchor(
impostor: PhysicsImpostor,
otherImpostor: PhysicsImpostor,
width: number,
height: number,
influence?: number,
noCollisionBetweenLinkedBodies?: boolean,
): voidAppend an anchor to a cloth object
Parameters
- impostor: PhysicsImpostor
is the cloth impostor to add anchor to
- otherImpostor: PhysicsImpostor
is the rigid impostor to anchor to
- width: number
ratio across width from 0 to 1
- height: number
ratio up height from 0 to 1
- influence: number = 1
the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
- noCollisionBetweenLinkedBodies: boolean = false
when true collisions between soft impostor and anchor are ignored; default false
Returns void
- impostor: PhysicsImpostor
append Hook
-
appendHook(
impostor: PhysicsImpostor,
otherImpostor: PhysicsImpostor,
length: number,
influence?: number,
noCollisionBetweenLinkedBodies?: boolean,
): voidAppend an hook to a rope object
Parameters
- impostor: PhysicsImpostor
is the rope impostor to add hook to
- otherImpostor: PhysicsImpostor
is the rigid impostor to hook to
- length: number
ratio along the rope from 0 to 1
- influence: number = 1
the elasticity between soft impostor and anchor from 0, very stretchy to 1, little stretch
- noCollisionBetweenLinkedBodies: boolean = false
when true collisions between soft impostor and anchor are ignored; default false
Returns void
- impostor: PhysicsImpostor
apply Force
-
Applies a force on the imposter
Parameters
- impostor: PhysicsImpostor
imposter to apply force
- force: Vector3
amount of force to be applied to the imposter
- contactPoint: Vector3
the location to apply the force on the imposter
Returns void
- impostor: PhysicsImpostor
apply Impulse
-
Applies an impulse on the imposter
Parameters
- impostor: PhysicsImpostor
imposter to apply impulse to
- force: Vector3
amount of force to be applied to the imposter
- contactPoint: Vector3
the location to apply the impulse on the imposter
Returns void
- impostor: PhysicsImpostor
dispose
-
Disposes of the impostor
Returns void
execute Step
-
Moves the physics simulation forward delta seconds and updates the given physics imposters Prior to the step the imposters physics location is set to the position of the babylon meshes After the step the babylon meshes are set to the position of the physics imposters
Parameters
- delta: number
amount of time to step forward
- impostors: PhysicsImpostor[]
array of imposters to update before/after the step
Returns void
- delta: number
generate Joint
-
Generates a joint
Parameters
- impostorJoint: PhysicsImpostorJoint
the imposter joint to create the joint with
Returns void
- impostorJoint: PhysicsImpostorJoint
generate Physics Body
-
Creates a physics body using the plugin
Parameters
- impostor: PhysicsImpostor
the imposter to create the physics body on
Returns void
- impostor: PhysicsImpostor
get Angular Velocity
-
gets the angular velocity
Parameters
- impostor: PhysicsImpostor
imposter to get angular velocity from
Returns Nullable<Vector3>
angular velocity
- impostor: PhysicsImpostor
get Body Friction
-
Gets friction of the impostor
Parameters
- impostor: PhysicsImpostor
impostor to get friction from
Returns number
friction value
- impostor: PhysicsImpostor
get Body Mass
-
Gets the mass of the physics body
Parameters
- impostor: PhysicsImpostor
imposter to get the mass from
Returns number
mass
- impostor: PhysicsImpostor
get Body Position Iterations
-
Gets positionIterations of the impostor
Parameters
- impostor: PhysicsImpostor
impostor to get position iterations from
Returns number
positionIterations value
- impostor: PhysicsImpostor
get Body Pressure
-
Gets pressure inside the impostor
Parameters
- impostor: PhysicsImpostor
impostor to get pressure from
Returns number
pressure value
- impostor: PhysicsImpostor
get Body Restitution
-
Gets restitution of the impostor
Parameters
- impostor: PhysicsImpostor
impostor to get restitution from
Returns number
restitution value
- impostor: PhysicsImpostor
get Body Stiffness
-
Gets stiffness of the impostor
Parameters
- impostor: PhysicsImpostor
impostor to get stiffness from
Returns number
pressure value
- impostor: PhysicsImpostor
get Body Velocity Iterations
-
Gets velocityIterations of the impostor
Parameters
- impostor: PhysicsImpostor
impostor to get velocity iterations from
Returns number
velocityIterations value
- impostor: PhysicsImpostor
get Box Size To Ref
-
Gets the box size of the impostor
Parameters
- impostor: PhysicsImpostor
impostor to get box size from
- result: Vector3
the resulting box size
Returns void
- impostor: PhysicsImpostor
get Linear Velocity
-
gets the linear velocity
Parameters
- impostor: PhysicsImpostor
imposter to get linear velocity from
Returns Nullable<Vector3>
linear velocity
- impostor: PhysicsImpostor
get Plugin Version
-
Returns number
plugin version
get Radius
-
Gets the radius of the impostor
Parameters
- impostor: PhysicsImpostor
impostor to get radius from
Returns number
the radius
- impostor: PhysicsImpostor
get Time Step
-
Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
Returns number
the current timestep in seconds
is Supported
-
If this plugin is supported
Returns boolean
true if its supported
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
- from: Vector3
remove Joint
-
Removes a joint
Parameters
- impostorJoint: PhysicsImpostorJoint
the imposter joint to remove the joint from
Returns void
- impostorJoint: PhysicsImpostorJoint
remove Physics Body
-
Removes the physics body from the imposter and disposes of the body's memory
Parameters
- impostor: PhysicsImpostor
imposter to remove the physics body from
Returns void
- impostor: PhysicsImpostor
set Angular Velocity
-
Sets the angular velocity of the physics body
Parameters
- impostor: PhysicsImpostor
imposter to set the velocity on
- velocity: Vector3
velocity to set
Returns void
- impostor: PhysicsImpostor
set Body Friction
-
Sets friction of the impostor
Parameters
- impostor: PhysicsImpostor
impostor to set friction on
- friction: number
friction value
Returns void
- impostor: PhysicsImpostor
set Body Mass
-
Sets the mass of physics body
Parameters
- impostor: PhysicsImpostor
imposter to set the mass on
- mass: number
mass to set
Returns void
- impostor: PhysicsImpostor
set Body Position Iterations
-
Sets positionIterations of the impostor
Parameters
- impostor: PhysicsImpostor
impostor to set position on
- positionIterations: number
positionIterations value
Returns void
- impostor: PhysicsImpostor
set Body Pressure
-
Sets pressure inside a soft body impostor Cloth and rope must remain 0 pressure
Parameters
- impostor: PhysicsImpostor
impostor to set pressure on
- pressure: number
pressure value
Returns void
- impostor: PhysicsImpostor
set Body Restitution
-
Sets restitution of the impostor
Parameters
- impostor: PhysicsImpostor
impostor to set resitution on
- restitution: number
resitution value
Returns void
- impostor: PhysicsImpostor
set Body Stiffness
-
Sets stiffness of the impostor
Parameters
- impostor: PhysicsImpostor
impostor to set stiffness on
- stiffness: number
stiffness value from 0 to 1
Returns void
- impostor: PhysicsImpostor
set Body Velocity Iterations
-
Sets velocityIterations of the impostor
Parameters
- impostor: PhysicsImpostor
impostor to set velocity iterations on
- velocityIterations: number
velocityIterations value
Returns void
- impostor: PhysicsImpostor
set Fixed Time Step
-
Increment to step forward in the physics engine (If timeStep is set to 1/60 and fixedTimeStep is set to 1/120 the physics engine should run 2 steps per frame) (Default: 1/60)
Parameters
- fixedTimeStep: number
fixedTimeStep to use in seconds
Returns void
- fixedTimeStep: number
set Gravity
-
Sets the gravity of the physics world (m/(s^2))
Parameters
- gravity: Vector3
Gravity to set
Returns void
- gravity: Vector3
set Limit
-
Sets the motors limit
Returns void
set Linear Velocity
-
Sets the linear velocity of the physics body
Parameters
- impostor: PhysicsImpostor
imposter to set the velocity on
- velocity: Vector3
velocity to set
Returns void
- impostor: PhysicsImpostor
set Max Steps
-
Sets the maximum number of steps by the physics engine per frame (Default: 5)
Parameters
- maxSteps: number
the maximum number of steps by the physics engine per frame
Returns void
- maxSteps: number
set Motor
-
Sets a motor on the joint
Parameters
- joint: IMotorEnabledJoint
joint to set motor on
Optionalspeed: numberspeed of the motor
OptionalmaxForce: numbermaximum force of the motor
Returns void
- joint: IMotorEnabledJoint
set Physics Body Transformation
-
setPhysicsBodyTransformation(
impostor: PhysicsImpostor,
newPosition: Vector3,
newRotation: Quaternion,
): voidSets the babylon object's position/rotation from the physics body's position/rotation
Parameters
- impostor: PhysicsImpostor
imposter containing the physics body and babylon object
- newPosition: Vector3
new position
- newRotation: Quaternion
new rotation
Returns void
- impostor: PhysicsImpostor
set Time Step
-
Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
Parameters
- timeStep: number
timestep to use in seconds
Returns void
- timeStep: number
set Transformation From Physics Body
-
Sets the mesh body position/rotation from the babylon impostor
Parameters
- impostor: PhysicsImpostor
imposter containing the physics body and babylon object
Returns void
- impostor: PhysicsImpostor
sleep Body
-
Sleeps the physics body and stops it from being active
Parameters
- impostor: PhysicsImpostor
impostor to sleep
Returns void
- impostor: PhysicsImpostor
sync Mesh With Impostor
-
Syncs the position and rotation of a mesh with the impostor
Parameters
- mesh: AbstractMesh
mesh to sync
- impostor: PhysicsImpostor
impostor to update the mesh with
Returns void
- mesh: AbstractMesh
update Distance Joint
-
Updates the distance parameters of the joint
Returns void
AmmoJS Physics plugin
See