A soft body: particles linked by elastic constraints (edges, bending constraints and cells), simulated together with the rigid bodies, contacts and joints of the world.

A soft body lives in a SoftBodySet and is referenced by its integer handle. Its hidden root rigid body (rootBody()) stands for the whole body in joints and islands; its clusters add more rigid-body proxies that joints and colliders can attach to.

Constructors

  • Parameters

    Returns SoftBody

Properties

bodies: any
colliders: any
handle: number
rawSet: any
userData?: unknown

An arbitrary user-defined object associated with this soft body.

Methods

  • Adds a force to every particle of this soft body (spread by mass).

    Parameters

    Returns void

  • Adds a force to the i-th particle of this soft body.

    Parameters

    • i: number
    • force: Vector
    • wakeUp: boolean

    Returns void

  • Applies an impulse to every particle of this soft body (spread by mass).

    Parameters

    • impulse: Vector
    • wakeUp: boolean

    Returns void

  • Applies an impulse to the particles within falloffRadius of point, scaled down linearly with their distance to it (falloffRadius <= 0 applies it to every particle).

    Parameters

    • impulse: Vector
    • point: Vector
    • falloffRadius: number
    • wakeUp: boolean

    Returns void

  • Applies an impulse to the i-th particle of this soft body.

    Parameters

    • i: number
    • impulse: Vector
    • wakeUp: boolean

    Returns void

  • Applies an impulse of the given magnitude pushing the particles away from center (a blast), scaled down linearly up to falloffRadius.

    Parameters

    • center: Vector
    • magnitude: number
    • falloffRadius: number
    • wakeUp: boolean

    Returns void

  • Attaches the i-th particle to a rigid body, at the particle's current position.

    Parameters

    Returns void

  • The rigid body of the i-th attachment.

    Parameters

    • i: number

    Returns RigidBody

  • The particle of the i-th attachment.

    Parameters

    • i: number

    Returns number

  • The boundary elements of this soft body (segments in 2D, triangles in 3D), flattened (two or three particle indices per element), oriented outward.

    Returns Uint32Array

  • The rest area/volume of the i-th cell.

    Parameters

    • i: number

    Returns number

  • The stiffness multiplier of the i-th cell.

    Parameters

    • i: number

    Returns number

  • The load of the i-th cell relative to its tear threshold (1 tears it).

    Parameters

    • i: number

    Returns number

  • The multiplier of the tear thresholds of the i-th cell.

    Parameters

    • i: number

    Returns number

  • The particles of every cell, flattened (three indices per cell in 2D, four in 3D).

    Returns Uint32Array

  • The center of mass of this soft body's particles.

    Parameters

    Returns Vector

  • The particles of the i-th cluster.

    Parameters

    • i: number

    Returns Uint32Array

  • The rigid body standing for the i-th cluster: joints and colliders attach to it.

    Parameters

    • i: number

    Returns RigidBody

  • Does the i-th cluster hold its shape by shape matching?

    Parameters

    • i: number

    Returns boolean

  • Detaches the i-th particle from the rigid body it was attached to.

    Returns false if the particle was not attached.

    Parameters

    • i: number

    Returns boolean

  • The impulse applied by the i-th edge during the last step.

    Parameters

    • i: number

    Returns number

  • The relative change of the i-th edge's rest length due to plastic flow.

    Parameters

    • i: number

    Returns number

  • The rest length of the i-th edge.

    Parameters

    • i: number

    Returns number

  • The load of the i-th edge relative to its tear threshold (1 tears it).

    Parameters

    • i: number

    Returns number

  • The multiplier of the tear thresholds of the i-th edge.

    Parameters

    • i: number

    Returns number

  • The particle pairs of every edge, flattened (two indices per edge).

    Returns Uint32Array

  • Enables or disables shape matching on the i-th cluster.

    Parameters

    • i: number
    • enabled: boolean

    Returns void

  • Enables or disables the global area/volume preservation of this soft body.

    Parameters

    • enabled: boolean

    Returns void

  • Internal

    Parameters

    Returns void

  • The gravity scale of this soft body's particles.

    Returns number

  • Are there tears requested for the next step?

    Returns boolean

  • Does the i-th cluster still exist?

    Parameters

    • i: number

    Returns boolean

  • Is the i-th edge a bending edge (rather than a structural one)?

    Parameters

    • i: number

    Returns boolean

  • Is this soft body enabled (simulated)?

    Returns boolean

  • Does the shape of the i-th collision mesh carry the ORIENTED flag (see SoftBodyDesc.setOriented)?

    Parameters

    • i: number

    Returns boolean

  • Is the i-th collision mesh skinned (embedded in the cells) rather than bound vertex-to-particle?

    Parameters

    • i: number

    Returns boolean

  • Has an element of the i-th particle torn?

    Parameters

    • i: number

    Returns boolean

  • Does the i-th particle lie on the body's surface?

    Parameters

    • i: number

    Returns boolean

  • Is the i-th particle pinned (held in place)?

    Parameters

    • i: number

    Returns boolean

  • Is this soft body sleeping?

    Returns boolean

  • Checks if this soft body is still valid (i.e. that it has not been deleted from the soft-body set yet).

    Returns boolean

  • The linear damping of this soft body's particles.

    Returns number

  • The total mass of this soft body's particles.

    Returns number

  • The cluster holding the i-th collision mesh.

    Parameters

    • i: number

    Returns number

  • The collider holding the i-th collision mesh.

    Parameters

    • i: number

    Returns Collider

  • Does the i-th collision mesh collide?

    Parameters

    • i: number

    Returns boolean

  • The elements of the i-th collision mesh, flattened (two vertex indices per segment in 2D, three per triangle in 3D).

    Parameters

    • i: number

    Returns Uint32Array

  • The index of the collision mesh held by a deformable collider of this soft body.

    Parameters

    Returns number

  • The world-space vertex positions of the i-th collision mesh, flattened.

    Parameters

    • i: number

    Returns Float32Array

  • The number of particles attached to rigid bodies.

    Returns number

  • The number of cells (triangles in 2D, tetrahedra in 3D) of this soft body.

    Returns number

  • The number of cluster slots of this soft body (some may have been removed: see isClusterLive).

    Returns number

  • The number of edges (structural and bending) of this soft body.

    Returns number

  • The number of collision meshes held by this soft body's clusters (its own deformable surface included).

    Returns number

  • The number of particles of this soft body.

    Returns number

  • The soft body this one was split off from by a tear, if any.

    Returns number

  • The mass of the i-th particle.

    Parameters

    • i: number

    Returns number

  • The world-space position of the i-th particle.

    Parameters

    • i: number
    • Optional target: Vector

    Returns Vector

  • The world-space positions of every particle, flattened (two or three floats per particle).

    Returns Float32Array

  • The thickness of this soft body's particles.

    Returns number

  • The rest position of the i-th particle (the position its constraints hold it at).

    Parameters

    • i: number
    • Optional target: Vector

    Returns Vector

  • The velocities of every particle, flattened (two or three floats per particle).

    Returns Float32Array

  • The velocity of the i-th particle.

    Parameters

    • i: number
    • Optional target: Vector

    Returns Vector

  • The handles of the soft bodies that tears split off from this one.

    Returns number[]

  • Resets the user forces applied to this soft body's particles.

    Parameters

    • wakeUp: boolean

    Returns void

  • Forgets every plastic deformation: the rest shapes return to their initial values.

    Returns void

  • The rest area/volume enclosed by this soft body's closed surfaces.

    Returns number

  • The hidden rigid body standing for this soft body in joints and islands.

    Returns RigidBody

  • Sets the extra internal PGS iterations run per substep for this soft body and everything it touches.

    Parameters

    • iterations: number

    Returns void

  • Overrides the softness of the edges of the i-th cluster (null restores the material's).

    Parameters

    Returns void

  • Moves the i-th cluster rigidly to the given pose over the next step.

    Parameters

    • i: number
    • translation: Vector
    • rotation: number

    Returns void

  • Pins (or releases) every particle of the i-th cluster.

    Parameters

    • i: number
    • pinned: boolean

    Returns void

  • Scales the stiffness of the elements of the i-th cluster.

    Parameters

    • i: number
    • scale: number

    Returns void

  • Scales the tear thresholds of the elements of the i-th cluster.

    Parameters

    • i: number
    • resistance: number

    Returns void

  • Enables or disables this soft body.

    Parameters

    • enabled: boolean

    Returns void

  • Replaces this soft body's material.

    Parameters

    Returns void

  • Moves the pinned i-th particle to position over the next step, like a position-based kinematic body (it pushes what it meets), then holds it there. Ignored for a free particle.

    Parameters

    Returns void

  • Pins (or releases) the i-th particle.

    Parameters

    • i: number
    • pinned: boolean

    Returns void

  • Sets the world-space position of the i-th particle.

    Parameters

    Returns void

  • Sets the velocity of the i-th particle.

    Parameters

    Returns void

  • Sets the solver holding the cells of this soft body together.

    Parameters

    Returns void

  • Sets the target volume multiplier of the volume preservation (> 1 inflates the body).

    Parameters

    • factor: number

    Returns void

  • The solver holding the cells of this soft body together.

    Returns SoftBodySolver

  • Requests the i-th cell to tear at the end of the next step.

    Parameters

    • i: number

    Returns void

  • Requests the i-th edge to tear at the end of the next step.

    Parameters

    • i: number

    Returns void

  • A counter incremented by every change of the body's topology (tears, cuts, splits).

    Returns number

  • The current area/volume enclosed by this soft body's closed surfaces.

    Returns number

  • The target volume multiplier of the volume preservation (> 1 inflates the body).

    Returns number

  • Is the global area/volume preservation of this soft body enabled?

    Returns boolean

  • Wakes this soft body up.

    Returns void