Class PhysicsImpostor
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
-
new PhysicsImpostor(
object: IPhysicsEnabledObject,
type: number,
_options?: PhysicsImpostorParameters,
_scene?: Scene,
): PhysicsImpostorInitializes 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.
- _options: PhysicsImpostorParameters = ...
The options for the physics imposter
Optional_scene: SceneThe Babylon scene
Returns PhysicsImpostor
- object: IPhysicsEnabledObject
Properties
object
The physics-enabled object used as the physics imposter
on Collide Event
(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void,
> = null
Legacy collision detection event support
type
The type of the physics imposter
unique Id
The unique id of the physics imposter set by the physics engine when adding this impostor to the array
StaticBox Impostor
Box-Imposter type
StaticCapsule Impostor
Capsule-Impostor type (Ammo.js plugin only)
StaticCloth Impostor
Cloth-Imposter type
StaticConvex Hull Impostor
ConvexHull-Impostor type (Ammo.js plugin only)
StaticCustom Impostor
Custom-Imposter type (Ammo.js plugin only)
StaticCylinder Impostor
Cylinder-Imposter type
StaticDEFAULT_ OBJECT_ SIZE
The default object size of the imposter
StaticHeightmap Impostor
Heightmap-Imposter type
StaticIDENTITY_ QUATERNION
The identity quaternion of the imposter
StaticMesh Impostor
Mesh-imposter type (Only available to objects with vertices data)
StaticNo Impostor
No-Imposter type
StaticParticle Impostor
Particle-Imposter type
StaticPlane Impostor
Plane-Imposter type
StaticRope Impostor
Rope-Imposter type
StaticSoftbody Impostor
Softbody-Imposter type
StaticSphere Impostor
Sphere-Imposter type
Accessors
friction
-
get friction(): number
Gets the coefficient of friction
Returns number
-
set friction(value: number): void
Sets the coefficient of friction
Parameters
- value: number
Returns void
is Disposed
-
get isDisposed(): boolean
Specifies if the physics imposter is disposed
Returns boolean
mass
-
get mass(): number
Gets the mass of the physics imposter
Returns number
-
set mass(value: number): void
Parameters
- value: number
Returns void
parent
physics Body
-
get physicsBody(): any
Gets the body that holds this impostor. Either its own, or its parent.
Returns any
-
set physicsBody(physicsBody: any): void
Set the physics body. Used mainly by the physics engine/plugin
Parameters
- physicsBody: any
Returns void
position Iterations
-
get positionIterations(): number
Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
Returns number
-
set positionIterations(value: number): void
Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
Parameters
- value: number
Returns void
pressure
-
get pressure(): number
Gets the pressure of a soft body; only supported by the AmmoJSPlugin
Returns number
-
set pressure(value: number): void
Sets the pressure of a soft body; only supported by the AmmoJSPlugin
Parameters
- value: number
Returns void
restitution
-
get restitution(): number
Gets the coefficient of restitution
Returns number
-
set restitution(value: number): void
Sets the coefficient of restitution
Parameters
- value: number
Returns void
stiffness
-
get stiffness(): number
Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
Returns number
-
set stiffness(value: number): void
Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
Parameters
- value: number
Returns void
velocity Iterations
-
get velocityIterations(): number
Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
Returns number
-
set velocityIterations(value: number): void
Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
Parameters
- value: number
Returns void
Methods
add Anchor
-
addAnchor(
otherImpostor: PhysicsImpostor,
width: number,
height: number,
influence: number,
noCollisionBetweenLinkedBodies: boolean,
): PhysicsImpostorAdd 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
- otherImpostor: PhysicsImpostor
add Hook
-
addHook(
otherImpostor: PhysicsImpostor,
length: number,
influence: number,
noCollisionBetweenLinkedBodies: boolean,
): PhysicsImpostorAdd 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
- otherImpostor: PhysicsImpostor
add Joint
-
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
- otherImpostor: PhysicsImpostor
after Step
-
this function is executed by the physics engine
Returns void
apply Force
apply Impulse
before Step
-
this function is executed by the physics engine.
Returns void
clone
-
Clones the physics imposter
Parameters
- newObject: IPhysicsEnabledObject
The physics imposter clones to this physics-enabled object
Returns Nullable<PhysicsImpostor>
A nullable physics imposter
- newObject: IPhysicsEnabledObject
create Joint
-
createJoint(
otherImpostor: PhysicsImpostor,
jointType: number,
jointData: PhysicsJointData,
): PhysicsImpostorA 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
- otherImpostor: PhysicsImpostor
dispose
-
Disposes the physics imposter
Returns void
execute Native Function
-
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
Returns void
- func: (world: any, physicsBody: any) => void
force Update
-
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 Velocity
get Box Size To Ref
-
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
- result: Vector3
get Linear Velocity
get Object Center
get Object Extents
get Param
-
Get a specific parameter from the options parameters
Parameters
- paramName: string
The object parameter name
Returns any
The object parameter
- paramName: string
get Parents Rotation
get Radius
-
Gets the radius of the physics imposter
Returns number
Radius of the physics imposter
is Body Init Required
-
Should a new body be generated.
Returns boolean
boolean specifying if body initialization is required
on Collide
register After Physics Step
-
Register a function that will be executed after the physics step
Parameters
- func: (impostor: PhysicsImpostor) => void
The function to execute after physics step
Returns void
- func: (impostor: PhysicsImpostor) => void
register Before Physics Step
-
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
Returns void
- func: (impostor: PhysicsImpostor) => void
register On Physics Collide
-
registerOnPhysicsCollide(
collideAgainst: PhysicsImpostor | PhysicsImpostor[],
func: (
collider: PhysicsImpostor,
collidedAgainst: PhysicsImpostor,
point: Nullable<Vector3>,
) => void,
): voidregister 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>,
) => voidCallback that is executed on collision
Returns void
- collideAgainst: PhysicsImpostor | PhysicsImpostor[]
reset Update Flags
-
Resets the update flags
Returns void
set Angular Velocity
set Delta Position
set Delta Rotation
set Linear Velocity
set Mass
-
Specifically change the body's mass. Won't recreate the physics body object
Parameters
- mass: number
The mass of the physics imposter
Returns void
- mass: number
set Param
-
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
- paramName: string
set Scaling Updated
-
Sets the updated scaling
Returns void
sleep
sync Bone With Impostor
-
syncBoneWithImpostor(
bone: Bone,
boneMesh: AbstractMesh,
jointPivot: Vector3,
distToJoint?: number,
adjustRotation?: Quaternion,
): voidSync 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.
OptionaldistToJoint: numberOptional distance from the impostor to the joint.
OptionaladjustRotation: QuaternionOptional quaternion for adjusting the local rotation of the bone.
Returns void
- bone: Bone
sync Impostor With Bone
-
syncImpostorWithBone(
bone: Bone,
boneMesh: AbstractMesh,
jointPivot: Vector3,
distToJoint?: number,
adjustRotation?: Quaternion,
boneAxis?: Vector3,
): voidSync 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.
OptionaldistToJoint: numberOptional distance from the impostor to the joint.
OptionaladjustRotation: QuaternionOptional quaternion for adjusting the local rotation of the bone.
OptionalboneAxis: Vector3Optional vector3 axis the bone is aligned with
Returns void
- bone: Bone
unregister After Physics Step
-
Unregisters a function that will be executed after the physics step
Parameters
- func: (impostor: PhysicsImpostor) => void
The function to execute after physics step
Returns void
- func: (impostor: PhysicsImpostor) => void
unregister Before Physics Step
-
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
Returns void
- func: (impostor: PhysicsImpostor) => void
unregister On Physics Collide
-
unregisterOnPhysicsCollide(
collideAgainst: PhysicsImpostor | PhysicsImpostor[],
func: (
collider: PhysicsImpostor,
collidedAgainst: PhysicsImpostor | PhysicsImpostor[],
point: Nullable<Vector3>,
) => void,
): voidUnregisters 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>,
) => voidCallback to execute on collision
Returns void
- collideAgainst: PhysicsImpostor | PhysicsImpostor[]
Represents a physics imposter
See
https://doc.babylonjs.com/features/featuresDeepDive/physics/usingPhysicsEngine