Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PhysicsImpostor

Hierarchy

  • PhysicsImpostor

Index

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 | undefined

      The Babylon scene

    Returns PhysicsImpostor

Properties

afterStepSearch playground for afterStep

afterStep: () => void

this function is executed by the physics engine

Type declaration

    • (): void
    • Returns void

beforeStepSearch playground for beforeStep

beforeStep: () => void

this function is executed by the physics engine.

Type declaration

    • (): void
    • Returns void

objectSearch playground for object

The physics-enabled object used as the physics imposter

onCollideSearch playground for onCollide

onCollide: (e: { body: any; point: Nullable<Vector3> }) => void

event and body object due to cannon's event-based architecture.

param
param
param

Type declaration

onCollideEventSearch playground for onCollideEvent

onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>

Legacy collision detection event support

typeSearch playground for type

type: number

The type of the physics imposter

uniqueIdSearch playground for uniqueId

uniqueId: number

The unique id of the physics imposter set by the physics engine when adding this impostor to the array

Static BoxImpostorSearch playground for BoxImpostor

BoxImpostor: number

Box-Imposter type

Static CapsuleImpostorSearch playground for CapsuleImpostor

CapsuleImpostor: number

Capsule-Impostor type (Ammo.js plugin only)

Static ClothImpostorSearch playground for ClothImpostor

ClothImpostor: number

Cloth-Imposter type

Static ConvexHullImpostorSearch playground for ConvexHullImpostor

ConvexHullImpostor: number

ConvexHull-Impostor type (Ammo.js plugin only)

Static CustomImpostorSearch playground for CustomImpostor

CustomImpostor: number

Custom-Imposter type (Ammo.js plugin only)

Static CylinderImpostorSearch playground for CylinderImpostor

CylinderImpostor: number

Cylinder-Imposter type

Static DEFAULT_OBJECT_SIZESearch playground for DEFAULT_OBJECT_SIZE

DEFAULT_OBJECT_SIZE: Vector3

The default object size of the imposter

Static HeightmapImpostorSearch playground for HeightmapImpostor

HeightmapImpostor: number

Heightmap-Imposter type

Static IDENTITY_QUATERNIONSearch playground for IDENTITY_QUATERNION

IDENTITY_QUATERNION: Quaternion

The identity quaternion of the imposter

Static MeshImpostorSearch playground for MeshImpostor

MeshImpostor: number

Mesh-imposter type (Only available to objects with vertices data)

Static NoImpostorSearch playground for NoImpostor

NoImpostor: number

No-Imposter type

Static ParticleImpostorSearch playground for ParticleImpostor

ParticleImpostor: number

Particle-Imposter type

Static PlaneImpostorSearch playground for PlaneImpostor

PlaneImpostor: number

Plane-Imposter type

Static RopeImpostorSearch playground for RopeImpostor

RopeImpostor: number

Rope-Imposter type

Static SoftbodyImpostorSearch playground for SoftbodyImpostor

SoftbodyImpostor: number

Softbody-Imposter type

Static SphereImpostorSearch playground for SphereImpostor

SphereImpostor: number

Sphere-Imposter type

Accessors

friction

  • get friction(): number
  • set friction(value: number): any
  • Gets the coefficient of friction

    Returns number

  • Sets the coefficient of friction

    Parameters

    • value: number

    Returns any

isDisposed

  • get isDisposed(): boolean
  • Specifies if the physics imposter is disposed

    Returns boolean

mass

  • get mass(): number
  • set mass(value: number): any
  • Gets the mass of the physics imposter

    Returns number

  • Gets the mass of the physics imposter

    Parameters

    • value: number

    Returns any

parent

  • Get the parent of the physics imposter

    Returns Nullable<PhysicsImpostor>

    Physics imposter or null

  • Sets the parent of the physics imposter

    Parameters

    Returns any

    Physics imposter or null

physicsBody

  • get physicsBody(): any
  • set physicsBody(physicsBody: any): any
  • 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 any

positionIterations

  • get positionIterations(): number
  • set positionIterations(value: number): any
  • 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 any

pressure

  • get pressure(): number
  • set pressure(value: number): any
  • 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 any

restitution

  • get restitution(): number
  • set restitution(value: number): any
  • Gets the coefficient of restitution

    Returns number

  • Sets the coefficient of restitution

    Parameters

    • value: number

    Returns any

stiffness

  • get stiffness(): number
  • set stiffness(value: number): any
  • 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 any

velocityIterations

  • get velocityIterations(): number
  • set velocityIterations(value: number): any
  • 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 any

Methods

addAnchorSearch playground for addAnchor

  • addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor
  • 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

addHookSearch 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

addJointSearch playground for addJoint

  • Add a joint to this impostor with a different impostor

    Parameters

    Returns PhysicsImpostor

    The physics imposter

applyForceSearch playground for applyForce

  • Apply a force

    Parameters

    • force: Vector3

      The force to apply

    • contactPoint: Vector3

      The contact point for the force

    Returns PhysicsImpostor

    The physics imposter

applyImpulseSearch playground for applyImpulse

  • Apply an impulse

    Parameters

    • force: Vector3

      The impulse force

    • contactPoint: Vector3

      The contact point for the impulse force

    Returns PhysicsImpostor

    The physics imposter

cloneSearch playground for clone

  • Clones the physics imposter

    Parameters

    Returns Nullable<PhysicsImpostor>

    A nullable physics imposter

createJointSearch 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

  • dispose(): void
  • Disposes the physics imposter

    Returns void

executeNativeFunctionSearch playground for executeNativeFunction

  • executeNativeFunction(func: (world: any, physicsBody: any) => void): 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

    • func: (world: any, physicsBody: any) => void

      The function to execute with the physics plugin native code

        • (world: any, physicsBody: any): void
        • Parameters

          • world: any
          • physicsBody: any

          Returns void

    Returns void

forceUpdateSearch playground for forceUpdate

  • forceUpdate(): void
  • Force a regeneration of this or the parent's impostor's body. Use under cautious - This will remove all joints already implemented.

    Returns void

getAngularVelocitySearch playground for getAngularVelocity

  • Gets the angular velocity

    Returns Nullable<Vector3>

    angular velocity or null

getBoxSizeToRefSearch 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

getLinearVelocitySearch playground for getLinearVelocity

  • Gets the linear velocity

    Returns Nullable<Vector3>

    linear velocity or null

getObjectCenterSearch playground for getObjectCenter

  • Gets the object center

    Returns Vector3

    The object center

getObjectExtendSizeSearch playground for getObjectExtendSize

  • Gets the object extend size

    Returns Vector3

    the object extend size

getParamSearch playground for getParam

  • getParam(paramName: string): any
  • Get a specific parameter from the options parameters

    Parameters

    • paramName: string

      The object parameter name

    Returns any

    The object parameter

getParentsRotationSearch playground for getParentsRotation

  • Get the parent rotation

    Returns Quaternion

    The parent rotation

getRadiusSearch playground for getRadius

  • getRadius(): number
  • Gets the radius of the physics imposter

    Returns number

    Radius of the physics imposter

isBodyInitRequiredSearch playground for isBodyInitRequired

  • isBodyInitRequired(): boolean
  • Should a new body be generated.

    Returns boolean

    boolean specifying if body initialization is required

registerAfterPhysicsStepSearch playground for registerAfterPhysicsStep

  • registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void
  • Register a function that will be executed after the physics step

    Parameters

    Returns void

registerBeforePhysicsStepSearch playground for registerBeforePhysicsStep

  • registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void
  • Register a function that will be executed before the physics world is stepping forward

    Parameters

    Returns void

registerOnPhysicsCollideSearch playground for registerOnPhysicsCollide

resetUpdateFlagsSearch playground for resetUpdateFlags

  • resetUpdateFlags(): void
  • Resets the update flags

    Returns void

setAngularVelocitySearch playground for setAngularVelocity

  • Sets the angular velocity

    Parameters

    Returns void

setDeltaPositionSearch playground for setDeltaPosition

  • setDeltaPosition(position: Vector3): void
  • Sets the delta position

    Parameters

    • position: Vector3

      The delta position amount

    Returns void

setDeltaRotationSearch playground for setDeltaRotation

  • Sets the delta rotation

    Parameters

    Returns void

setLinearVelocitySearch playground for setLinearVelocity

  • Sets the linear velocity

    Parameters

    Returns void

setMassSearch playground for setMass

  • setMass(mass: number): void
  • Specifically change the body's mass option. Won't recreate the physics body object

    Parameters

    • mass: number

      The mass of the physics imposter

    Returns void

setParamSearch playground for setParam

  • setParam(paramName: string, value: number): void
  • 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

setScalingUpdatedSearch playground for setScalingUpdated

  • setScalingUpdated(): void
  • Sets the updated scaling

    Returns void

sleepSearch playground for sleep

  • Will keep this body still, in a sleep mode.

    Returns PhysicsImpostor

    the physics imposter

syncBoneWithImpostorSearch 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

syncImpostorWithBoneSearch 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

unregisterAfterPhysicsStepSearch playground for unregisterAfterPhysicsStep

  • unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void
  • Unregisters a function that will be executed after the physics step

    Parameters

    Returns void

unregisterBeforePhysicsStepSearch playground for unregisterBeforePhysicsStep

  • unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void
  • Unregister a function that will be executed before the physics world is stepping forward

    Parameters

    Returns void

unregisterOnPhysicsCollideSearch playground for unregisterOnPhysicsCollide

wakeUpSearch playground for wakeUp

  • Wake the body up.

    Returns PhysicsImpostor

    The physics imposter

Legend

  • Constructor
  • Property
  • Method
  • Accessor
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method