Class PhysicsImpostor
Hierarchy
- PhysicsImpostor
Index
Constructors
Properties
Accessors
Methods
- add
Anchor - add
Hook - add
Joint - apply
Force - apply
Impulse - clone
- create
Joint - dispose
- execute
Native Function - force
Update - get
Angular Velocity - get
Box Size To Ref - get
Linear Velocity - get
Object Center - get
Object Extents - get
Param - get
Parents Rotation - get
Radius - is
Body Init Required - register
After Physics Step - register
Before Physics Step - register
On Physics Collide - reset
Update Flags - set
Angular Velocity - set
Delta Position - set
Delta Rotation - set
Linear Velocity - set
Mass - set
Param - set
Scaling Updated - sleep
- sync
Bone With Impostor - sync
Impostor With Bone - unregister
After Physics Step - unregister
Before Physics Step - unregister
On Physics Collide - wake
Up
Constructors
constructor
Initializes the physics imposter
Parameters
object: IPhysicsEnabledObject
The physics-enabled object used as the physics imposter
type: number
The type of the physics imposter. Types are available as static members of this class.
Optional _options: PhysicsImpostorParameters
The options for the physics imposter
Optional _scene: Scene
The Babylon scene
Returns PhysicsImpostor
Properties
after StepSearch playground for afterStep
Type declaration
this function is executed by the physics engine
Returns void
before StepSearch playground for beforeStep
Type declaration
this function is executed by the physics engine.
Returns void
objectSearch playground for object
The physics-enabled object used as the physics imposter
on CollideSearch playground for onCollide
on Collide EventSearch playground for onCollideEvent
Legacy collision detection event support
typeSearch playground for type
The type of the physics imposter
unique IdSearch playground for uniqueId
The unique id of the physics imposter set by the physics engine when adding this impostor to the array
Static Box ImpostorSearch playground for BoxImpostor
Box-Imposter type
Static Capsule ImpostorSearch playground for CapsuleImpostor
Capsule-Impostor type (Ammo.js plugin only)
Static Cloth ImpostorSearch playground for ClothImpostor
Cloth-Imposter type
Static Convex Hull ImpostorSearch playground for ConvexHullImpostor
ConvexHull-Impostor type (Ammo.js plugin only)
Static Custom ImpostorSearch playground for CustomImpostor
Custom-Imposter type (Ammo.js plugin only)
Static Cylinder ImpostorSearch playground for CylinderImpostor
Cylinder-Imposter type
Static DEFAULT_ OBJECT_ SIZESearch playground for DEFAULT_OBJECT_SIZE
The default object size of the imposter
Static Heightmap ImpostorSearch playground for HeightmapImpostor
Heightmap-Imposter type
Static IDENTITY_ QUATERNIONSearch playground for IDENTITY_QUATERNION
The identity quaternion of the imposter
Static Mesh ImpostorSearch playground for MeshImpostor
Mesh-imposter type (Only available to objects with vertices data)
Static No ImpostorSearch playground for NoImpostor
No-Imposter type
Static Particle ImpostorSearch playground for ParticleImpostor
Particle-Imposter type
Static Plane ImpostorSearch playground for PlaneImpostor
Plane-Imposter type
Static Rope ImpostorSearch playground for RopeImpostor
Rope-Imposter type
Static Softbody ImpostorSearch playground for SoftbodyImpostor
Softbody-Imposter type
Static Sphere ImpostorSearch playground for SphereImpostor
Sphere-Imposter type
Accessors
friction
Gets the coefficient of friction
Returns number
Sets the coefficient of friction
Parameters
value: number
Returns void
is Disposed
Specifies if the physics imposter is disposed
Returns boolean
mass
Gets the mass of the physics imposter
Returns number
Gets the mass of the physics imposter
Parameters
value: number
Returns void
parent
Get the parent of the physics imposter
Returns Nullable<PhysicsImpostor>
Physics imposter or null
Sets the parent of the physics imposter
Parameters
value: Nullable<PhysicsImpostor>
Returns void
Physics imposter or null
physics Body
Gets the body that holds this impostor. Either its own, or its parent.
Returns any
Set the physics body. Used mainly by the physics engine/plugin
Parameters
physicsBody: any
Returns void
position Iterations
Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
Returns number
Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
Parameters
value: number
Returns void
pressure
Gets the pressure of a soft body; only supported by the AmmoJSPlugin
Returns number
Sets the pressure of a soft body; only supported by the AmmoJSPlugin
Parameters
value: number
Returns void
restitution
Gets the coefficient of restitution
Returns number
Sets the coefficient of restitution
Parameters
value: number
Returns void
stiffness
Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
Returns number
Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
Parameters
value: number
Returns void
velocity Iterations
Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
Returns number
Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
Parameters
value: number
Returns void
Methods
add AnchorSearch playground for addAnchor
Add an anchor to a cloth impostor
Parameters
otherImpostor: PhysicsImpostor
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
the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch
noCollisionBetweenLinkedBodies: boolean
when true collisions between cloth impostor and anchor are ignored; default false
Returns PhysicsImpostor
impostor the soft imposter
add HookSearch playground for addHook
Add a hook to a rope impostor
Parameters
otherImpostor: PhysicsImpostor
rigid impostor to anchor to
length: number
ratio across rope from 0 to 1
influence: number
the elasticity between rope impostor and anchor from 0, very stretchy to 1, little stretch
noCollisionBetweenLinkedBodies: boolean
when true collisions between soft impostor and anchor are ignored; default false
Returns PhysicsImpostor
impostor the rope imposter
add JointSearch playground for addJoint
Add a joint to this impostor with a different impostor
Parameters
otherImpostor: PhysicsImpostor
A physics imposter used to add a joint
joint: PhysicsJoint
The joint to add
Returns PhysicsImpostor
The physics imposter
apply ForceSearch playground for applyForce
Apply a force
Parameters
Returns PhysicsImpostor
The physics imposter
apply ImpulseSearch playground for applyImpulse
Apply an impulse
Parameters
Returns PhysicsImpostor
The physics imposter
cloneSearch playground for clone
Clones the physics imposter
Parameters
newObject: IPhysicsEnabledObject
The physics imposter clones to this physics-enabled object
Returns Nullable<PhysicsImpostor>
A nullable physics imposter
create JointSearch playground for createJoint
A help function to create a joint
Parameters
otherImpostor: PhysicsImpostor
A physics imposter used to create a joint
jointType: number
The type of joint
jointData: PhysicsJointData
The data for the joint
Returns PhysicsImpostor
The physics imposter
disposeSearch playground for dispose
Disposes the physics imposter
Returns void
execute Native FunctionSearch playground for executeNativeFunction
Execute a function with the physics plugin native code Provide a function the will have two variables - the world object and the physics body object
Parameters
func: ((world: any, physicsBody: any) => void)
The function to execute with the physics plugin native code
Parameters
world: any
physicsBody: any
Returns void
Returns void
force UpdateSearch playground for forceUpdate
Force a regeneration of this or the parent's impostor's body. Use with caution - This will remove all previously-instantiated joints.
Returns void
get Angular VelocitySearch playground for getAngularVelocity
get Box Size To RefSearch playground for getBoxSizeToRef
Gets the box size of the physics imposter and stores the result in the input parameter
Parameters
result: Vector3
Stores the box size
Returns PhysicsImpostor
The physics imposter
get Linear VelocitySearch playground for getLinearVelocity
get Object CenterSearch playground for getObjectCenter
Gets the object center
Returns Vector3
The object center
get Object ExtentsSearch playground for getObjectExtents
Gets the object extents
Returns Vector3
the object extents
get ParamSearch playground for getParam
Get a specific parameter from the options parameters
Parameters
paramName: string
The object parameter name
Returns any
The object parameter
get Parents RotationSearch playground for getParentsRotation
Get the parent rotation
Returns Quaternion
The parent rotation
get RadiusSearch playground for getRadius
Gets the radius of the physics imposter
Returns number
Radius of the physics imposter
is Body Init RequiredSearch playground for isBodyInitRequired
Should a new body be generated.
Returns boolean
boolean specifying if body initialization is required
register After Physics StepSearch playground for registerAfterPhysicsStep
Register a function that will be executed after the physics step
Parameters
func: ((impostor: PhysicsImpostor) => void)
The function to execute after physics step
Parameters
impostor: PhysicsImpostor
Returns void
Returns void
register Before Physics StepSearch playground for registerBeforePhysicsStep
Register a function that will be executed before the physics world is stepping forward
Parameters
func: ((impostor: PhysicsImpostor) => void)
The function to execute before the physics world is stepped forward
Parameters
impostor: PhysicsImpostor
Returns void
Returns void
register On Physics CollideSearch playground for registerOnPhysicsCollide
register a function that will be executed when this impostor collides against a different body
Parameters
collideAgainst: PhysicsImpostor | PhysicsImpostor[]
Physics imposter, or array of physics imposters to collide against
func: ((collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void)
Callback that is executed on collision
Parameters
collider: PhysicsImpostor
collidedAgainst: PhysicsImpostor
point: Nullable<Vector3>
Returns void
Returns void
reset Update FlagsSearch playground for resetUpdateFlags
Resets the update flags
Returns void
set Angular VelocitySearch playground for setAngularVelocity
set Delta PositionSearch playground for setDeltaPosition
Sets the delta position
Parameters
position: Vector3
The delta position amount
Returns void
set Delta RotationSearch playground for setDeltaRotation
Sets the delta rotation
Parameters
rotation: Quaternion
The delta rotation amount
Returns void
set Linear VelocitySearch playground for setLinearVelocity
set MassSearch playground for setMass
Specifically change the body's mass. Won't recreate the physics body object
Parameters
mass: number
The mass of the physics imposter
Returns void
set ParamSearch playground for setParam
Sets a specific parameter in the options given to the physics plugin
Parameters
paramName: string
The parameter name
value: number
The value of the parameter
Returns void
set Scaling UpdatedSearch playground for setScalingUpdated
Sets the updated scaling
Returns void
sleepSearch playground for sleep
Will keep this body still, in a sleep mode.
Returns PhysicsImpostor
the physics imposter
sync Bone With ImpostorSearch playground for syncBoneWithImpostor
Sync a bone with this impostor
Parameters
bone: Bone
The bone to sync to the impostor.
boneMesh: AbstractMesh
The mesh that the bone is influencing.
jointPivot: Vector3
The pivot of the joint / bone in local space.
Optional distToJoint: number
Optional distance from the impostor to the joint.
Optional adjustRotation: Quaternion
Optional quaternion for adjusting the local rotation of the bone.
Returns void
sync Impostor With BoneSearch playground for syncImpostorWithBone
Sync impostor to a bone
Parameters
bone: Bone
The bone that the impostor will be synced to.
boneMesh: AbstractMesh
The mesh that the bone is influencing.
jointPivot: Vector3
The pivot of the joint / bone in local space.
Optional distToJoint: number
Optional distance from the impostor to the joint.
Optional adjustRotation: Quaternion
Optional quaternion for adjusting the local rotation of the bone.
Optional boneAxis: Vector3
Optional vector3 axis the bone is aligned with
Returns void
unregister After Physics StepSearch playground for unregisterAfterPhysicsStep
Unregisters a function that will be executed after the physics step
Parameters
func: ((impostor: PhysicsImpostor) => void)
The function to execute after physics step
Parameters
impostor: PhysicsImpostor
Returns void
Returns void
unregister Before Physics StepSearch playground for unregisterBeforePhysicsStep
Unregister a function that will be executed before the physics world is stepping forward
Parameters
func: ((impostor: PhysicsImpostor) => void)
The function to execute before the physics world is stepped forward
Parameters
impostor: PhysicsImpostor
Returns void
Returns void
unregister On Physics CollideSearch playground for unregisterOnPhysicsCollide
Unregisters the physics imposter's collision callback
Parameters
collideAgainst: PhysicsImpostor | PhysicsImpostor[]
The physics object to collide against
func: ((collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | PhysicsImpostor[], point: Nullable<Vector3>) => void)
Callback to execute on collision
Parameters
collider: PhysicsImpostor
collidedAgainst: PhysicsImpostor | PhysicsImpostor[]
point: Nullable<Vector3>
Returns void
Returns void
wake UpSearch playground for wakeUp
Wake the body up.
Returns PhysicsImpostor
The physics imposter
Represents a physics imposter
https://doc.babylonjs.com/how_to/using_the_physics_engine