Options
All
  • Public
  • Public/Protected
  • All
Menu

PhysicsShape class. This class is useful for creating a physics shape that can be used in a physics engine. A Physic Shape determine how collision are computed. It must be attached to a body.

Hierarchy

Index

Constructors

  • Constructs a new physics shape.

    Parameters

    • options: PhysicShapeOptions

      The options for the physics shape. These are:

      • type: The type of the shape. This can be one of the following: SPHERE, BOX, CAPSULE, CYLINDER, CONVEX_HULL, MESH, HEIGHTFIELD, CONTAINER
      • parameters: The parameters of the shape.
      • pluginData: The plugin data of the shape. This is used if you already have a reference to the object on the plugin side. You need to specify either type or pluginData.
    • scene: Scene

      The scene the shape belongs to.

      This code is useful for creating a new physics shape with the given type, options, and scene. It also checks that the physics engine and plugin version are correct. If not, it throws an error. This ensures that the shape is created with the correct parameters and is compatible with the physics engine.

    Returns PhysicsShape

Properties

_pluginData: any

V2 Physics plugin private data for single shape

Accessors

  • get density(): number
  • set density(density: number): void
  • Returns the density of the physics shape.

    Returns number

    The density of the physics shape.

  • Sets the density of the physics shape.

    Parameters

    • density: number

      The density of the physics shape.

    Returns void

  • get filterCollideMask(): number
  • set filterCollideMask(collideMask: number): void
  • Sets the collide mask of a shape. This is a bitfield of arbitrary "categories" to which this shape collides with. Given two shapes, the engine will check if the collide mask and membership overlap: shapeA.filterMembershipMask & shapeB.filterCollideMask

    If this value is zero (i.e. shapeB only collides with categories which shapeA is not a member of) then the shapes will not collide.

    Note, the engine will also perform the same test with shapeA and shapeB swapped; the shapes will not collide if either shape has a collideMask which prevents collision with the other shape.

    Returns number

    Bitmask of categories that this shape should collide with

  • Sets the collide mask of a shape. This is a bitfield of arbitrary "categories" to which this shape collides with. Given two shapes, the engine will check if the collide mask and membership overlap: shapeA.filterMembershipMask & shapeB.filterCollideMask

    If this value is zero (i.e. shapeB only collides with categories which shapeA is not a member of) then the shapes will not collide.

    Note, the engine will also perform the same test with shapeA and shapeB swapped; the shapes will not collide if either shape has a collideMask which prevents collision with the other shape.

    Parameters

    • collideMask: number

      Bitmask of categories this shape should collide with

    Returns void

  • get filterMembershipMask(): number
  • set filterMembershipMask(membershipMask: number): void
  • Get the membership mask of a shape.

    Returns number

    Bitmask of categories which this shape is a member of.

  • Set the membership mask of a shape. This is a bitfield of arbitrary "categories" to which the shape is a member. This is used in combination with the collide mask to determine if this shape should collide with another.

    Parameters

    • membershipMask: number

      Bitfield of categories of this shape.

    Returns void

  • get isTrigger(): boolean
  • set isTrigger(isTrigger: boolean): void
  • Returns boolean

  • Parameters

    • isTrigger: boolean

    Returns void

  • Returns the material of the physics shape.

    Returns PhysicsMaterial

    The material of the physics shape.

  • Parameters

    Returns void

  • Returns the type of the physics shape.

    Returns PhysicsShapeType

    The type of the physics shape.

Methods

  • Adds a child shape to a container with an optional transform

    Parameters

    • newChild: PhysicsShape

      The new PhysicsShape to add

    • Optional translation: Vector3

      Optional position of the child shape relative to this shape

    • Optional rotation: Quaternion

      Optional rotation of the child shape relative to this shape

    • Optional scale: Vector3

      Optional scale of the child shape relative to this shape

    Returns void

  • Utility to add a child shape to this container, automatically computing the relative transform between the container shape and the child instance.

    Parameters

    • parentTransform: TransformNode

      The transform node associated with this shape

    • newChild: PhysicsShape

      The new PhysicsShape to add

    • childTransform: TransformNode

      The transform node associated with the child shape

    Returns void

  • dispose(): void
  • Dispose the shape and release its associated resources.

    Returns void

  • Returns the bounding box of the physics shape.

    Returns BoundingBox

    The bounding box of the physics shape.

  • getClassName(): string
  • Returns the string "PhysicsShape".

    Returns string

    "PhysicsShape"

  • getNumChildren(): number
  • Returns the number of children of a physics shape.

    Returns number

    The number of children of a physics shape.

  • removeChild(childIndex: number): void
  • Removes a child shape from this shape.

    Parameters

    • childIndex: number

      The index of the child shape to remove

    Returns void

Legend

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

Settings

Theme