Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AmmoJSPlugin

Hierarchy

  • AmmoJSPlugin

Implements

  • IPhysicsEnginePlugin

Index

Constructors

constructor

  • new AmmoJSPlugin(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any): AmmoJSPlugin
  • Initializes the ammoJS plugin

    Parameters

    • Optional _useDeltaForWorldStep: boolean

      if the time between frames should be used when calculating physics steps (Default: true)

    • Optional ammoInjection: any

      can be used to inject your own ammo reference

    • Optional overlappingPairCache: any

      can be used to specify your own overlapping pair cache

    Returns AmmoJSPlugin

Properties

bjsAMMOSearch playground for bjsAMMO

bjsAMMO: any

Reference to the Ammo library

nameSearch playground for name

name: string

Name of the plugin

onCreateCustomConvexHullImpostorSearch playground for onCreateCustomConvexHullImpostor

onCreateCustomConvexHullImpostor: (impostor: PhysicsImpostor) => any

The create custom convex hull impostor handler function to support building custom convex hull impostor vertex data

Type declaration

onCreateCustomMeshImpostorSearch playground for onCreateCustomMeshImpostor

onCreateCustomMeshImpostor: (impostor: PhysicsImpostor) => any

The create custom mesh impostor handler function to support building custom mesh impostor vertex data

Type declaration

onCreateCustomShapeSearch playground for onCreateCustomShape

onCreateCustomShape: (impostor: PhysicsImpostor) => any

The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor

Type declaration

worldSearch playground for world

world: any

Created ammoJS world which physics bodies are added to

Methods

appendAnchorSearch playground for appendAnchor

  • appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void
  • Append 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

    • Optional influence: number

      the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little stretch

    • Optional noCollisionBetweenLinkedBodies: boolean

      when true collisions between soft impostor and anchor are ignored; default false

    Returns void

appendHookSearch playground for appendHook

  • appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void
  • Append 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

    • Optional influence: number

      the elasticity between soft impostor and anchor from 0, very stretchy to 1, little stretch

    • Optional noCollisionBetweenLinkedBodies: boolean

      when true collisions between soft impostor and anchor are ignored; default false

    Returns void

applyForceSearch playground for applyForce

  • 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

applyImpulseSearch playground for applyImpulse

  • 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

disposeSearch playground for dispose

  • dispose(): void
  • Disposes of the impostor

    Returns void

executeStepSearch playground for executeStep

  • 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: Array<PhysicsImpostor>

      array of imposters to update before/after the step

    Returns void

generateJointSearch playground for generateJoint

  • Generates a joint

    Parameters

    Returns void

generatePhysicsBodySearch playground for generatePhysicsBody

  • Creates a physics body using the plugin

    Parameters

    Returns void

getAngularVelocitySearch playground for getAngularVelocity

  • gets the angular velocity

    Parameters

    Returns Nullable<Vector3>

    angular velocity

getBodyFrictionSearch playground for getBodyFriction

  • Gets friction of the impostor

    Parameters

    Returns number

    friction value

getBodyMassSearch playground for getBodyMass

  • Gets the mass of the physics body

    Parameters

    Returns number

    mass

getBodyPositionIterationsSearch playground for getBodyPositionIterations

  • Gets positionIterations of the impostor

    Parameters

    Returns number

    positionIterations value

getBodyPressureSearch playground for getBodyPressure

  • Gets pressure inside the impostor

    Parameters

    Returns number

    pressure value

getBodyRestitutionSearch playground for getBodyRestitution

  • Gets restitution of the impostor

    Parameters

    Returns number

    restitution value

getBodyStiffnessSearch playground for getBodyStiffness

  • Gets stiffness of the impostor

    Parameters

    Returns number

    pressure value

getBodyVelocityIterationsSearch playground for getBodyVelocityIterations

  • Gets velocityIterations of the impostor

    Parameters

    Returns number

    velocityIterations value

getBoxSizeToRefSearch playground for getBoxSizeToRef

  • Gets the box size of the impostor

    Parameters

    Returns void

getLinearVelocitySearch playground for getLinearVelocity

  • gets the linear velocity

    Parameters

    Returns Nullable<Vector3>

    linear velocity

getRadiusSearch playground for getRadius

  • Gets the radius of the impostor

    Parameters

    Returns number

    the radius

getTimeStepSearch playground for getTimeStep

  • getTimeStep(): number
  • Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)

    Returns number

    the current timestep in seconds

isSupportedSearch playground for isSupported

  • isSupported(): boolean
  • If this plugin is supported

    Returns boolean

    true if its supported

raycastSearch playground for raycast

  • Does a raycast in the physics world

    Parameters

    • from: Vector3

      when should the ray start?

    • to: Vector3

      when should the ray end?

    Returns PhysicsRaycastResult

    PhysicsRaycastResult

removeJointSearch playground for removeJoint

  • Removes a joint

    Parameters

    Returns void

removePhysicsBodySearch playground for removePhysicsBody

  • Removes the physics body from the imposter and disposes of the body's memory

    Parameters

    Returns void

setAngularVelocitySearch playground for setAngularVelocity

  • Sets the angular velocity of the physics body

    Parameters

    Returns void

setBodyFrictionSearch playground for setBodyFriction

  • Sets friction of the impostor

    Parameters

    • impostor: PhysicsImpostor

      impostor to set friction on

    • friction: number

      friction value

    Returns void

setBodyMassSearch playground for setBodyMass

  • Sets the mass of physics body

    Parameters

    • impostor: PhysicsImpostor

      imposter to set the mass on

    • mass: number

      mass to set

    Returns void

setBodyPositionIterationsSearch playground for setBodyPositionIterations

  • setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void
  • Sets positionIterations of the impostor

    Parameters

    • impostor: PhysicsImpostor

      impostor to set position on

    • positionIterations: number

      positionIterations value

    Returns void

setBodyPressureSearch playground for setBodyPressure

  • 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

setBodyRestitutionSearch playground for setBodyRestitution

  • Sets restitution of the impostor

    Parameters

    • impostor: PhysicsImpostor

      impostor to set resitution on

    • restitution: number

      resitution value

    Returns void

setBodyStiffnessSearch playground for setBodyStiffness

  • Sets stiffness of the impostor

    Parameters

    • impostor: PhysicsImpostor

      impostor to set stiffness on

    • stiffness: number

      stiffness value from 0 to 1

    Returns void

setBodyVelocityIterationsSearch playground for setBodyVelocityIterations

  • setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void
  • Sets velocityIterations of the impostor

    Parameters

    • impostor: PhysicsImpostor

      impostor to set velocity iterations on

    • velocityIterations: number

      velocityIterations value

    Returns void

setFixedTimeStepSearch playground for setFixedTimeStep

  • setFixedTimeStep(fixedTimeStep: number): void
  • 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

setGravitySearch playground for setGravity

  • setGravity(gravity: Vector3): void
  • Sets the gravity of the physics world (m/(s^2))

    Parameters

    Returns void

setLimitSearch playground for setLimit

  • setLimit(): void
  • Sets the motors limit

    Returns void

setLinearVelocitySearch playground for setLinearVelocity

  • Sets the linear velocity of the physics body

    Parameters

    Returns void

setMaxStepsSearch playground for setMaxSteps

  • setMaxSteps(maxSteps: number): void
  • 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

setMotorSearch playground for setMotor

  • Sets a motor on the joint

    Parameters

    • joint: IMotorEnabledJoint

      joint to set motor on

    • Optional speed: number

      speed of the motor

    • Optional maxForce: number

      maximum force of the motor

    Returns void

setPhysicsBodyTransformationSearch playground for setPhysicsBodyTransformation

  • Sets the babylon object's position/rotation from the physics body's position/rotation

    Parameters

    Returns void

setTimeStepSearch playground for setTimeStep

  • setTimeStep(timeStep: number): void
  • 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

setTransformationFromPhysicsBodySearch playground for setTransformationFromPhysicsBody

  • Sets the physics body position/rotation from the babylon mesh's position/rotation

    Parameters

    • impostor: PhysicsImpostor

      imposter containing the physics body and babylon object

    Returns void

sleepBodySearch playground for sleepBody

  • Sleeps the physics body and stops it from being active

    Parameters

    Returns void

syncMeshWithImpostorSearch playground for syncMeshWithImpostor

  • Syncs the position and rotation of a mesh with the impostor

    Parameters

    Returns void

updateDistanceJointSearch playground for updateDistanceJoint

  • updateDistanceJoint(): void
  • Updates the distance parameters of the joint

    Returns void

wakeUpBodySearch playground for wakeUpBody

  • Activates the physics body

    Parameters

    Returns void

Legend

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