CLASSES
TagsA - Z

PhysicsImpostor

Description

class PhysicsImpostor

Constructor

new PhysicsImpostor(object, type, _options, _scene)

Parameters

Name Type Description
object IPhysicsEnabledObject
type number
optional _options PhysicsImpostorParameters

Members

object : IPhysicsEnabledObject

type : number

static DEFAULT_OBJECT_SIZE : Vector3

static IDENTITY_QUATERNION : Quaternion

isDisposed : boolean

mass : number

friction : number

restitution : number

uniqueId : number

physicsBody : any

Gets the body that holds this impostor. Either its own, or its parent.

Set the physics body. Used mainly by the physics engine/plugin

parent : PhysicsImpostor

void : undefined

beforeStep : () => void

this function is executed by the physics engine.

afterStep : () => void

this function is executed by the physics engine.

onCollideEvent : (collider: undefined, collidedWith: undefined) => void

Legacy collision detection event support

onCollide : (e: { body: any }) => void

static NoImpostor : number

static SphereImpostor : number

static BoxImpostor : number

static PlaneImpostor : number

static MeshImpostor : number

static CylinderImpostor : number

static ParticleImpostor : number

static HeightmapImpostor : number

Methods

isBodyInitRequired() boolean

Should a new body be generated.

setScalingUpdated(updated) void

Parameters

Name Type Description
updated boolean

forceUpdate() void

Force a regeneration of this or the parent's impostor's body.

Use under cautious - This will remove all joints already implemented.

resetUpdateFlags() void

getObjectExtendSize() Vector3

getObjectCenter() Vector3

getParam(paramName) any

Get a specific parametes from the options parameter.

Parameters

Name Type Description
paramName string

setParam(paramName, value) void

Sets a specific parameter in the options given to the physics plugin

Parameters

Name Type Description
paramName string
value number

setMass(mass) void

Specifically change the body's mass option. Won't recreate the physics body object

Parameters

Name Type Description
mass number

getLinearVelocity() Vector3

setLinearVelocity(velocity) void

Parameters

Name Type Description
velocity Vector3

getAngularVelocity() Vector3

setAngularVelocity(velocity) void

Parameters

Name Type Description
velocity Vector3

executeNativeFunction(func) void

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

Name Type Description
func (world: any, physicsBody: any) => void

registerBeforePhysicsStep(func) void

Register a function that will be executed before the physics world is stepping forward.

Parameters

Name Type Description
func (impostor: PhysicsImpostor) => void

unregisterBeforePhysicsStep(func) void

Parameters

Name Type Description
func (impostor: PhysicsImpostor) => void

registerAfterPhysicsStep(func) void

Register a function that will be executed after the physics step

Parameters

Name Type Description
func (impostor: PhysicsImpostor) => void

unregisterAfterPhysicsStep(func) void

Parameters

Name Type Description
func (impostor: PhysicsImpostor) => void

registerOnPhysicsCollide(collideAgainst, Array, func) void

register a function that will be executed when this impostor collides against a different body.

Parameters

Name Type Description
collideAgainst PhysicsImpostor or Array
func (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void

unregisterOnPhysicsCollide(collideAgainst, Array, func) (collideAgainst, Array, func)

Parameters

Name Type Description
collideAgainst PhysicsImpostor or Array
func (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, Array: undefined) =>

applyForce(force, contactPoint) void

Apply a force

Parameters

Name Type Description
force Vector3
contactPoint Vector3

applyImpulse(force, contactPoint) void

Apply an impulse

Parameters

Name Type Description
force Vector3
contactPoint Vector3

createJoint(otherImpostor, jointType, jointData) void

A help function to create a joint.

Parameters

Name Type Description
otherImpostor PhysicsImpostor
jointType number
jointData PhysicsJointData

addJoint(otherImpostor, joint) void

Add a joint to this impostor with a different impostor.

Parameters

Name Type Description
otherImpostor PhysicsImpostor
joint PhysicsJoint

sleep() void

Will keep this body still, in a sleep mode.

wakeUp() void

Wake the body up.

clone(newObject) PhysicsImpostor

Parameters

Name Type Description
newObject IPhysicsEnabledObject

dispose() void

setDeltaPosition(position) void

Parameters

Name Type Description
position Vector3

setDeltaRotation(rotation) void

Parameters

Name Type Description
rotation Quaternion

getBoxSizeToRef(result) void

Parameters

Name Type Description
result Vector3

getRadius() number

syncBoneWithImpostor(bone, boneMesh, jointPivot, distToJoint, adjustRotation) void

Sync a bone with this impostor

Parameters

Name Type Description
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.

syncImpostorWithBone(bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) void

Sync impostor to a bone

Parameters

Name Type Description
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.