Options
All
  • Public
  • Public/Protected
  • All
Menu

PhysicsBody is useful for creating a physics body that can be used in a physics engine. It allows the user to set the mass and velocity of the body, which can then be used to calculate the motion of the body in the physics engine.

Hierarchy

  • PhysicsBody

Index

Constructors

  • Constructs a new physics body for the given node.

    Parameters

    • transformNode: TransformNode

      The Transform Node to construct the physics body for.

    • scene: Scene

      The scene containing the physics engine.

      This code is useful for creating a physics body for a given Transform Node in a scene. It checks the version of the physics engine and the physics plugin, and initializes the body accordingly. It also sets the node's rotation quaternion if it is not already set. Finally, it adds the body to the physics engine.

    Returns PhysicsBody

Properties

_pluginData: any

V2 Physics plugin private data for single Transform

_pluginDataInstances: any[]

V2 Physics plugin private data for instances

disablePreStep: boolean

Disable pre-step that consists in updating Physics Body from Transform Node Translation/Orientation. True by default for maximum performance.

transformNode: TransformNode

The transform node associated with this Physics Body

Methods

  • Applies an impulse to the physics object.

    Parameters

    • location: Vector3

      The location of the impulse.

    • impulse: Vector3

      The impulse vector.

      This method is useful for applying an impulse to a physics object, which can be used to simulate physical forces such as gravity, collisions, and explosions. This can be used to create realistic physics simulations in a game or other application.

    Returns void

  • dispose(): void
  • Disposes the body from the physics engine.

    This method is useful for cleaning up the physics engine when a body is no longer needed. Disposing the body will free up resources and prevent memory leaks.

    Returns void

  • getAngularDamping(): number
  • Gets the angular damping of the physics body.

    Returns number

    The angular damping of the physics body.

    This method is useful for getting the angular damping of the physics body, which is the rate of reduction of the angular velocity over time. This is important for simulating realistic physics behavior in a game.

  • getAngularVelocityToRef(angVel: Vector3): void
  • Gets the angular velocity of the physics body and stores it in the given vector3.

    Parameters

    • angVel: Vector3

      The vector3 to store the angular velocity in.

      This method is useful for getting the angular velocity of a physics body, which can be used to determine the body's rotational speed. This information can be used to create realistic physics simulations.

    Returns void

  • getEventMask(): number
  • Gets the event mask of the physics engine.

    Returns number

    The event mask of the physics engine.

    This method is useful for getting the event mask of the physics engine, which is used to determine which events the engine will respond to. This is important for ensuring that the engine is responding to the correct events and not wasting resources on unnecessary events.

  • getFilterGroup(): number
  • Gets the filter group of the physics engine.

    Returns number

    The filter group of the physics engine.

    This method is useful for getting the filter group of the physics engine, which is used to determine which objects will interact with each other. This is important for creating realistic physics simulations.

  • getGeometry(): {}
  • Retrieves the geometry of the body from the physics plugin.

    Returns {}

    The geometry of the body.

    This method is useful for retrieving the geometry of the body from the physics plugin, which can be used for various physics calculations.

    • getLinearDamping(): number
    • Gets the linear damping of the physics body.

      Returns number

      The linear damping of the physics body.

      This method is useful for retrieving the linear damping of the physics body, which is the amount of resistance the body has to linear motion. This is useful for simulating realistic physics behavior in a game.

    • getLinearVelocityToRef(linVel: Vector3): void
    • Gets the linear velocity of the physics body and stores it in the given vector3.

      Parameters

      • linVel: Vector3

        The vector3 to store the linear velocity in.

        This method is useful for getting the linear velocity of a physics body in a physics engine. This can be used to determine the speed and direction of the body, which can be used to calculate the motion of the body.

      Returns void

    • getMassProperties(): undefined | MassProperties
    • Retrieves the mass properties of the object.

      Returns undefined | MassProperties

      The mass properties of the object, or undefined if the physics plugin does not support mass properties.

      This method is useful for physics simulations, as it allows the user to retrieve the mass properties of the object, such as its mass, center of mass, and moment of inertia. This information is necessary for accurate physics simulations.

    • Retrieves the physics shape associated with this object.

      Returns undefined | PhysicsShape

      The physics shape associated with this object, or undefined if no shape is associated.

      This method is useful for retrieving the physics shape associated with this object, which can be used to apply physical forces to the object or to detect collisions.

    • Register a collision callback that is called when the body collides Filtering by body is inefficient. It's more preferable to register a collision callback for the entire world and do the filtering on the user side.

      Parameters

      Returns void

    • setAngularDamping(damping: number): void
    • Sets the angular damping of the physics body.

      Parameters

      • damping: number

        The angular damping of the body.

        This method is useful for controlling the angular velocity of a physics body. By setting the damping, the body's angular velocity will be reduced over time, simulating the effect of friction. This can be used to create realistic physical behavior in a physics engine.

      Returns void

    • setAngularVelocity(angVel: Vector3): void
    • Sets the angular velocity of the physics object.

      Parameters

      • angVel: Vector3

        The angular velocity to set.

        This method is useful for setting the angular velocity of a physics object, which is necessary for simulating realistic physics behavior. The angular velocity is used to determine the rate of rotation of the object, which is important for simulating realistic motion.

      Returns void

    • setEventMask(eventMask: number): void
    • Sets the event mask for the physics engine.

      Parameters

      • eventMask: number

        A bitmask that determines which events will be sent to the physics engine.

        This method is useful for setting the event mask for the physics engine, which determines which events will be sent to the physics engine. This allows the user to control which events the physics engine will respond to.

      Returns void

    • setFilterGroup(group: number): void
    • Sets the filter group of the physics body.

      Parameters

      • group: number

        The filter group of the physics body.

        This method is useful for setting the filter group of the physics body. The filter group is used to determine which bodies should collide with each other. This allows for more control over the physics engine and can be used to create more realistic simulations.

      Returns void

    • setLinearDamping(damping: number): void
    • Sets the linear damping of the physics body.

      Parameters

      • damping: number

        The linear damping value.

        This method is useful for controlling the linear damping of the physics body, which is the rate at which the body's velocity decreases over time. This is useful for simulating the effects of air resistance or other forms of friction.

      Returns void

    • setLinearVelocity(linVel: Vector3): void
    • Sets the linear velocity of the physics object.

      Parameters

      • linVel: Vector3

        The linear velocity to set.

        This method is useful for setting the linear velocity of a physics object, which is necessary for simulating realistic physics in a game engine. By setting the linear velocity, the physics object will move in the direction and speed specified by the vector. This allows for realistic physics simulations, such as simulating the motion of a ball rolling down a hill.

      Returns void

    • setMassProperties(massProps: MassProperties): void
    • Sets the mass properties of the physics object.

      Parameters

      • massProps: MassProperties

        The mass properties to set.

        This method is useful for setting the mass properties of a physics object, such as its mass, inertia, and center of mass. This is important for accurately simulating the physics of the object in the physics engine.

      Returns void

    • Sets the shape of the physics body.

      Parameters

      • shape: PhysicsShape

        The shape of the physics body.

        This method is useful for setting the shape of the physics body, which is necessary for the physics engine to accurately simulate the body's behavior. The shape is used to calculate the body's mass, inertia, and other properties.

      Returns void

    Legend

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

    Settings

    Theme