AmmoJSPlugin

Hierarchy

  • AmmoJSPlugin

Implements

  • IPhysicsEnginePlugin

Index

Constructors

constructor

Find examples in Playground
  • new AmmoJSPlugin(_useDeltaForWorldStep?: boolean, ammoInjection?: 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

    Returns AmmoJSPlugin

Properties

bjsAMMO

Find examples in Playground
bjsAMMO: any

Reference to the Ammo library

name

Find examples in Playground
name: string

Name of the plugin

world

Find examples in Playground
world: any

Created ammoJS world which physics bodies are added to

Methods

appendAnchor

Find examples in Playground
  • 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 strech

    • Optional noCollisionBetweenLinkedBodies: boolean

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

    Returns void

appendHook

Find examples in Playground
  • 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 strech

    • Optional noCollisionBetweenLinkedBodies: boolean

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

    Returns void

applyForce

Find examples in Playground
  • 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

applyImpulse

Find examples in Playground
  • 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

dispose

Find examples in Playground
  • dispose(): void
  • Disposes of the impostor

    Returns void

executeStep

Find examples in Playground
  • 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

generateJoint

Find examples in Playground
  • Generates a joint

    Parameters

    Returns void

generatePhysicsBody

Find examples in Playground
  • Creates a physics body using the plugin

    Parameters

    Returns void

getAngularVelocity

Find examples in Playground

getBodyFriction

Find examples in Playground
  • Gets friction of the impostor

    Parameters

    Returns number

    friction value

getBodyMass

Find examples in Playground
  • Gets the mass of the physics body

    Parameters

    Returns number

    mass

getBodyPositionIterations

Find examples in Playground
  • Gets positionIterations of the impostor

    Parameters

    Returns number

    positionIterations value

getBodyPressure

Find examples in Playground
  • Gets pressure inside the impostor

    Parameters

    Returns number

    pressure value

getBodyRestitution

Find examples in Playground
  • Gets restitution of the impostor

    Parameters

    Returns number

    restitution value

getBodyStiffness

Find examples in Playground
  • Gets stiffness of the impostor

    Parameters

    Returns number

    pressure value

getBodyVelocityIterations

Find examples in Playground
  • Gets velocityIterations of the impostor

    Parameters

    Returns number

    velocityIterations value

getBoxSizeToRef

Find examples in Playground
  • Gets the box size of the impostor

    Parameters

    Returns void

getLinearVelocity

Find examples in Playground

getRadius

Find examples in Playground
  • Gets the radius of the impostor

    Parameters

    Returns number

    the radius

getTimeStep

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

    Returns number

    the current timestep in seconds

isSupported

Find examples in Playground
  • isSupported(): boolean
  • If this plugin is supported

    Returns boolean

    true if its supported

raycast

Find examples in Playground
  • 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

removeJoint

Find examples in Playground
  • Removes a joint

    Parameters

    Returns void

removePhysicsBody

Find examples in Playground
  • Removes the physics body from the imposter and disposes of the body's memory

    Parameters

    Returns void

setAngularVelocity

Find examples in Playground
  • Sets the angular velocity of the physics body

    Parameters

    Returns void

setBodyFriction

Find examples in Playground
  • Sets friction of the impostor

    Parameters

    • impostor: PhysicsImpostor

      impostor to set friction on

    • friction: number

      friction value

    Returns void

setBodyMass

Find examples in Playground
  • Sets the mass of physics body

    Parameters

    • impostor: PhysicsImpostor

      imposter to set the mass on

    • mass: number

      mass to set

    Returns void

setBodyPositionIterations

Find examples in Playground
  • 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

setBodyPressure

Find examples in Playground
  • 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

setBodyRestitution

Find examples in Playground
  • Sets resitution of the impostor

    Parameters

    • impostor: PhysicsImpostor

      impostor to set resitution on

    • restitution: number

      resitution value

    Returns void

setBodyStiffness

Find examples in Playground
  • Sets stiffness of the impostor

    Parameters

    • impostor: PhysicsImpostor

      impostor to set stiffness on

    • stiffness: number

      stiffness value from 0 to 1

    Returns void

setBodyVelocityIterations

Find examples in Playground
  • 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

setFixedTimeStep

Find examples in Playground
  • 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

setGravity

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

    Parameters

    Returns void

setLimit

Find examples in Playground
  • Sets the motors limit

    Parameters

    • joint: IMotorEnabledJoint

      joint to set limit on

    • upperLimit: number

      upper limit

    • Optional lowerLimit: number

      lower limit

    Returns void

setLinearVelocity

Find examples in Playground
  • Sets the linear velocity of the physics body

    Parameters

    Returns void

setMaxSteps

Find examples in Playground
  • 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

setMotor

Find examples in Playground
  • setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void
  • 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

    • Optional motorIndex: number

      index of the motor

    Returns void

setPhysicsBodyTransformation

Find examples in Playground
  • Sets the babylon object's position/rotation from the physics body's position/rotation

    Parameters

    Returns void

setTimeStep

Find examples in Playground
  • 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

setTransformationFromPhysicsBody

Find examples in Playground
  • 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

sleepBody

Find examples in Playground
  • Sleeps the physics body and stops it from being active

    Parameters

    Returns void

syncMeshWithImpostor

Find examples in Playground
  • Syncs the position and rotation of a mesh with the impostor

    Parameters

    Returns void

updateDistanceJoint

Find examples in Playground
  • updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void
  • Updates the distance parameters of the joint

    Parameters

    • joint: PhysicsJoint

      joint to update

    • maxDistance: number

      maximum distance of the joint

    • Optional minDistance: number

      minimum distance of the joint

    Returns void

wakeUpBody

Find examples in Playground
  • Activates the physics body

    Parameters

    Returns void

Generated using TypeDoc