A SoftBody Component.

Hierarchy (view full)

Accessors

  • get allowDynamicOrKinematic(): boolean
  • When this body is created as MOTION_TYPE_STATIC, this setting tells Jolt system to create a MotionProperties object internally, so that the object can be switched to kinematic or dynamic. Use false, if you don't intend to switch the type of this body from static. This is a performance optimization.

    Returns boolean

    Allow/Disallow a static body to be switched to kinematic/dynamic.

    Default Value

    false
    
  • get allowSleeping(): boolean
  • Specifies if this body go to sleep or not.

    Returns boolean

    Boolean, telling if a body can go to sleep.

    Default Value

    true
    
  • set allowSleeping(bool): void
  • Specifies, whether a body can go to sleep or not.

    • true: allow sleeping
    • false: do not allow to go sleep

    Parameters

    • bool: boolean

      Boolean, telling if a body may go to sleep

    Returns void

  • get allowedDOFs(): number
  • Which degrees of freedom this body has (can be used to limit simulation to 2D). For example, using DOF_TRANSLATION_X restricts a body to move in world space X axis.

    Returns number

    Bit number, representing the degrees of freedom.

    Default Value

    DOF_ALL
    
  • set allowedDOFs(degree): void
  • Changes the allowed degrees of freedom. You can use a combination of following bits:

    DOF_TRANSLATION_X
    
    DOF_TRANSLATION_Y
    
    DOF_TRANSLATION_Z
    
    DOF_ROTATION_X
    
    DOF_ROTATION_Y
    
    DOF_ROTATION_Z
    
    DOF_ALL
    

    Parameters

    • degree: number

      Constant number, representing a degree of freedom.

    Returns void

    Example

    // lock translation to X and Z axis and rotation to Y axis
    entity.body.allowedDOFs = DOF_TRANSLATION_X | DOF_TRANSLATION_Z | DOF_ROTATION_Y;
  • get angularDamping(): number
  • Tells how quickly a body loses angular velocity.

    Returns number

    Number, representing angular damping.

    Default Value

    0
    
  • set angularDamping(factor): void
  • Sets angular damping factor. The formula used:

    dw/dt = -factor * w
    

    factor must be between 0 and 1 but is usually close to 0.

    Parameters

    • factor: number

      Factor number.

    Returns void

  • get angularVelocity(): Vec3
  • World space angular velocity.

    Returns Vec3

    Vec3, containing the current angular velocity of this body.

    Default Value

    Vec3(0, 0, 0) (rad/s)
    
  • set angularVelocity(velocity): void
  • Parameters

    • velocity: Vec3

      Angular velocity Vec3 (rad/s per axis) to set this body to.

    Returns void

  • get autoUpdateIsometry(): boolean
  • Returns a boolean, telling if the position and rotation of this body is updated automatically.

    Returns boolean

    • Boolean, telling the isometry update state.

    Default Value

    false
    
  • set autoUpdateIsometry(bool): void
  • Changes the isometry update method:

    • true: framework will synchronize entity position/rotation in visual world with a physical body in physics world automatically.
    • false: framework expects a user to do it manually.

    If false is set, then physics will no longer auto-update entity/body position/rotation.

    • Backend will not tell frontend where dynamic body is.
    • Frontend will not tell backend where kinematic body is.
    • This setting has no effect on a static body.

    This is useful, for example, when you have many kinematic objects and you rarely change their isometry. In some cases this is also useful for dynamic bodies, e.g. when their gravity factor is set to zero, and you use moveKinematic to translate it manually.

    Parameters

    • bool: boolean

    Returns void

    Example

    entity.addComponent('body', {
    motionType: MOTION_TYPE_KINEMATIC,
    objectLayer: OBJ_LAYER_MOVING,
    autoUpdateIsometry: false
    });

    // then on frame update, or when needed, move both - body and entity
    entity.setPosition(newPosition);
    entity.body.teleport(newPosition);
    // or any of the body movement methods, e.g.
    // entity.body.moveKinematic(newPosition, Quat.IDENTITY, time);
  • get collisionGroup(): number
  • The collision group this body belongs to (determines if two objects can collide). Expensive, so disabled by default. Prefer to use broadphase and object layers instead for filtering.

    Returns number

    returns a number, representing a collision group this body belongs to. If no group is set, returns -1;

    Default Value

    -1 (disabled)
    
  • get convexRadius(): number
  • Internally the convex radius will be subtracted from the half extent, so the total size will not grow with the convex radius. You can increase this value to make the edges of the collision shape rounded.

    Note:

    • Only used by shapes with sharp edges: SHAPE_BOX and SHAPE_CYLINDER.
    • Cannot be changed after the shape is created.

    Returns number

    Number, representing the convex radius.

    Default Value

    0.05 (m)
    
  • get debugDraw(): boolean
  • Specifies, whether to debug draw the collision shape.

    Returns boolean

    Boolean, telling if the collision shape should be drawn using lines.

    Default Value

    false
    
  • set debugDraw(bool): void
  • Allows to turn on/off debug draw for this body. Only works with a debug build.

    Parameters

    • bool: boolean

      Boolean to enable/disable a debug draw.

    Returns void

  • get debugDrawDepth(): boolean
  • Returns boolean

    Default Value

    true
    
  • set debugDrawDepth(bool): void
  • If debugDraw is enabled, this will specify whether to consider scene depth or not. If set to false, the debug lines will be drawn on top of everything, through other meshes.

    Parameters

    • bool: boolean

      Boolean, telling whether to consider scene depth.

    Returns void

  • get density(): number
  • Density of the object. Affects the mass of the object, when BodyComponent.overrideMassProperties is set to OMP_CALCULATE_MASS_AND_INERTIA (default, which will auto-calculate the mass using the shape dimensions and this density value).

    Returns number

    Number, representing the density of this collision shape.

    Default Value

    1000 (kg / m^3)
    
  • get fixedIndices(): number[]
  • An array of indices that point to the vertices which will be static (e.g. attached to something in the world).

    Returns number[]

    An array with indices of static vertices.

    Default Value

    []
    
  • get friction(): number
  • Friction of the body.

    Returns number

    Number, representing friction factor.

    Default Value

    0.2
    
  • set friction(friction): void
  • Sets friction. Dimensionless number, usually between 0 and 1:

    • 0: no friction
    • 1: friction force equals force that presses the two bodies together

    Note: bodies can have negative friction, but the combined friction should never go below zero.

    Parameters

    • friction: number

      Friction scalar.

    Returns void

  • get gravityFactor(): number
  • Value to multiply gravity with for this body.

    Returns number

    Number, representing the gravity factor affecting this body.

    Default Value

    1
    
  • set gravityFactor(factor): void
  • Changes the gravity factor of a body.

    Parameters

    • factor: number

      Gravity factor to multiply.

    Returns void

  • get group(): number
  • Collision group bit of an object layer.

    Two layers can collide if object1.group and object2.mask is non-zero and object2.group and object1.mask is non-zero. The behavior is similar to that of filtering in e.g. Bullet, Rapier.

    Returns number

    Unsigned integer.

    Default Value

    0
    
  • set group(group): void
  • Updates the filtering group bit. Value is ignored, if JoltInitSettings.bitFiltering is not set.

    Parameters

    • group: number

      Unsigned integer.

    Returns void

  • get halfExtent(): Vec3
  • Half extent for a SHAPE_BOX.

    Returns Vec3

    Vec3 with half extent of a box collision shape.

    Default Value

    Vec3(0.5, 0.5, 0.5) (m per axis)
    
  • get halfHeight(): number
  • Half-height of radius based shapes.

    Note: Only used by SHAPE_CAPSULE and SHAPE_CYLINDER.

    Returns number

    Number, representing half of the total height of the collision shape.

    Default Value

    0.5 (m)
    
  • get hfActiveEdgeCosThresholdAngle(): number
  • Cosine of the threshold angle. If the angle between the two triangles in HeightField is bigger than this, the edge is active. note that a concave edge is always inactive. Setting this value too small can cause ghost collisions with edges. Setting it too big can cause depenetration artifacts (objects not depenetrating quickly). Valid ranges are between cos(0 degrees) and cos(90 degrees).

    Returns number

    Number, representing radians of the threshold angle.

    Default Value

    0.996195 (cos(5 degrees))
    
  • get hfBitsPerSample(): number
  • How many bits per sample to use to compress the HeightField. Can be in the range [1, 8]. Note that each sample is compressed relative to the min/max value of its block of hfBlockSize * hfBlockSize pixels so the effective precision is higher. Also note that increasing hfBlockSize saves more memory, than reducing the amount of bits per sample.

    Returns number

    Number, representing amount of compression bits.

    Default Value

    8
    
  • get hfBlockSize(): number
  • The HeightField is divided in blocks of hfBlockSize * hfBlockSize * 2 triangles and the acceleration structure culls blocks only, bigger block sizes reduce memory consumption, but also reduce query performance. Sensible values are [2, 8]. Does not need to be a power of 2. Note that at run-time Jolt performs one more grid subdivision, so the effective block size is half of what is provided here.

    Returns number

    Number, representing a block size.

    Default Value

    2
    
  • get hfOffset(): Vec3
  • Offsets the position of the HeightField, which is a surface defined by:

    hfOffset + hfScale * (x, hfHeightSamples[y * hfSampleCount + x], y)
    

    where x and y are integers in the range x and y e [0, hfSampleCount - 1].

    Returns Vec3

    Vec3 with position offset.

    Default Value

    Vec3(0, 0, 0) (m per axis)
    
  • get index(): number
  • Unique body index. This can change during entity lifecycle, e.g. every time entity is enabled, a new index is assigned and a new body is created. The index is used to map entity to body. Index can be re-used by another component if this component is disabled or destroyed (destroying related body as a result).

    Returns number

    Integer number, representing the unique body index.

    Default Value

    -1
    
  • get inertiaMultiplier(): number
  • When calculating the inertia the calculated inertia will be multiplied by this value. This factor is ignored when overrideMassProperties is set to OMP_MASS_AND_INERTIA_PROVIDED - you are expected to calculate inertia yourself in that case. Cannot be changed after a body is created.

    Returns number

    Number, representing inertia factor.

    Default Value

    1
    
  • get isCompoundChild(): boolean
  • Specifies if the component describes a child of a compound shape.

    Returns boolean

    Boolean, telling if this component describes a child shape of a compound shape.

    Default Value

    false
    
  • get isSensor(): boolean
  • If this body is a sensor. A sensor will receive collision callbacks, but will not cause any collision responses and can be used as a trigger volume.

    Returns boolean

    Boolean, telling if this body is a sensor.

    Default Value

    false
    
  • set isSensor(bool): void
  • Specifies if the body is a sensor or not.

    • true: changes a body into a sensor
    • false: changes a body into a rigid body

    Parameters

    • bool: boolean

      Boolean, telling if this body is a sensor.

    Returns void

  • get length(): number
  • Number of cells comprising a column. Think of a grid divided plane.

    Returns number

    Number, representing the amount of cell in a column.

    Default Value

    0
    
  • get linearDamping(): number
  • Specifies how quickly the body loses linear velocity. Uses formula:

    dv/dt = -c * v.
    

    c must be between 0 and 1 but is usually close to 0.

    Returns number

    Number, representing a linear damping factor.

    Default Value

    0
    
  • get linearVelocity(): Vec3
  • World space linear velocity of the center of mass of this body.

    Returns Vec3

    Vec3, representing the current linear velocity of this body.

    Default Value

    Vec3(0, 0, 0) (m/s)
    
  • set linearVelocity(velocity): void
  • Sets linear velocity unclamped. Can be set to be over the allowed maximum. If you want to be sure not to go over allowed max, use setLinearVelocityClamped.

    Parameters

    • velocity: Vec3

      Linear velocity Vec3 (m/s per axis) to set this body to.

    Returns void

  • get makeRotationIdentity(): boolean
  • Bake specified rotation in the vertices and set the body rotation to identity (simulation is slightly more accurate if the rotation of a soft body is kept to identity).

    Returns boolean

    Boolean, telling if the rotation is set to identity after a bake.

    Default Value

    true
    
  • get mask(): number
  • Collision mask bit of an object layer.

    Two layers can collide if object1.group and object2.mask is non-zero and object2.group and object1.mask is non-zero. The behavior is similar to that of filtering in e.g. Bullet, Rapier.

    Returns number

    Unsigned integer.

    Default Value

    0
    
  • set mask(mask): void
  • Updates the filtering mask bit. Value is ignored, if JoltInitSettings.bitFiltering is not set.

    Parameters

    • mask: number

      Unsigned integer.

    Returns void

  • get massOffset(): Vec3
  • A center of mass offset in local space of the body. Does not move the shape.

    Returns Vec3

    Vec3 with center of mass offset.

    Default Value

    Vec3(0, 0, 0) (m per axis)
    
  • get maxAngularVelocity(): number
  • Maximum angular velocity that this body can reach.

    Returns number

    Number, representing maximum angular velocity this body can reach.

    Default Value

    47.12388980384689 (0.25 * PI * 60.0, rad/s)
    
  • set maxAngularVelocity(velocity): void
  • Sets maximum angular velocity a body can reach. Use setAngularVelocityClamped to not go over this limit.

    Parameters

    • velocity: number

      Maximum angular velocity scalar (rad/s).

    Returns void

  • get maxLinearVelocity(): number
  • Maximum linear velocity that this body can reach.

    Returns number

    Number, representing maximum linear velocity this body can reach.

    Default Value

    500 (m/s)
    
  • set maxLinearVelocity(velocity): void
  • Sets maximum linear velocity a body can reach. Use setLinearVelocityClamped to not go over this limit.

    Parameters

    • velocity: number

      Maximum linear velocity scalar (m/s).

    Returns void

  • get motionQuality(): number
  • Motion quality, or how well it detects collisions when it has a high velocity.

    Returns number

    Constant number, representing the collision detection algorithm for this body.

    Default Value

    MOTION_QUALITY_DISCRETE
    
  • set motionQuality(quality): void
  • Changes the body motion quality. Following constants available:

    MOTION_QUALITY_DISCRETE
    
    MOTION_QUALITY_LINEAR_CAST
    

    Use linear cast (CCD) for fast moving objects, in other cases prefer discrete one since it is cheaper.

    Parameters

    • quality: number

      Quality constant.

    Returns void

  • get motionType(): number
  • Motion type, determines if the object is static, dynamic or kinematic. You can use the following constants:

    MOTION_TYPE_STATIC
    
    MOTION_TYPE_DYNAMIC
    
    MOTION_TYPE_KINEMATIC
    

    Returns number

    Number, representing motion type of this body.

    Default Value

    MOTION_TYPE_STATIC
    
  • set motionType(type): void
  • Parameters

    • type: number

      Number, representing motion quality constant.

    Returns void

  • get numIterations(): number
  • Number of solver iterations.

    Returns number

    Number, representing a number of solver iterations. The higher the number, the more accurate the simulation is, the more expensive it becomes to process.

    Default Value

    5
    
  • get objectLayer(): number
  • The collision layer this body belongs to (determines if two objects can collide).

    Returns number

    Number, representing the object layer this body belongs to.

    Default Value

    OBJ_LAYER_NON_MOVING
    
  • set objectLayer(layerNumber): void
  • Changes the object layer that this body belongs to. Allows cheap filtering. Not used, if JoltInitSettings.bitFiltering is provided during system initialization.

    You can use the following pre-made ones:

    OBJ_LAYER_NON_MOVING
    
    OBJ_LAYER_MOVING
    

    Where:

    • OBJ_LAYER_NON_MOVING = 0
    • OBJ_LAYER_MOVING = 1

    Parameters

    • layerNumber: number

      Layer number.

    Returns void

  • get overrideInertiaPosition(): Vec3
  • Used only if OMP_MASS_AND_INERTIA_PROVIDED is selected for overrideMassProperties. Backend will create inertia matrix from the given position.

    Returns Vec3

    Vec3 with position that is used for this body inertia calculation.

    Default Value

    Vec3(0, 0, 0) (m)
    
  • get overrideInertiaRotation(): Quat
  • Used only if OMP_MASS_AND_INERTIA_PROVIDED is selected for overrideMassProperties. Backend will create inertia matrix from the given rotation.

    Returns Quat

    Quat with rotation that is used for this body inertia calculation.

    Default Value

    Quat(0, 0, 0, 1)
    
  • get overrideMass(): number
  • Used only if OMP_CALCULATE_INERTIA or OMP_MASS_AND_INERTIA_PROVIDED is selected for overrideMassProperties.

    Returns number

    Number, representing the mass of this body, when the mass is not calculated automatically.

    Default Value

    1 (kg)
    
  • get overrideMassProperties(): number
  • Determines how a body mass and inertia is calculated. By default it uses OMP_CALCULATE_MASS_AND_INERTIA, which tells Jolt to auto-calculate those based the collider shape. You can use following constants:

    OMP_CALCULATE_INERTIA
    
    OMP_CALCULATE_MASS_AND_INERTIA
    
    OMP_MASS_AND_INERTIA_PROVIDED
    

    If you select OMP_CALCULATE_INERTIA, you must also specify overrideMass. The inertia will be automatically calculated for you.

    If you select OMP_MASS_AND_INERTIA_PROVIDED, you must also specify overrideMass, overrideInertiaPosition and overrideInertiaRotation.

    Cannot be changed after the body is created.

    Returns number

    Number, representing the mass calculation method constant.

    Default Value

    OMP_CALCULATE_MASS_AND_INERTIA (calculates automatically)
    
  • get position(): Vec3
  • Read-only. Current position of the body (not of the center of mass).

    Returns Vec3

    Vec3 with the current position of this body.

    Default Value

    Vec3(0, 0, 0) (m per axis)
    
  • get pressure(): number
  • The pressure of the soft body. Calculated from:

    n * R * T
    (amount of substance * ideal gass constant * absolute temperature)
    

    see Pressure

    Returns number

    Number, representing the pressure of the body.

    Default Value

    0
    
  • get radius(): number
  • Radius for radius based shapes, like SHAPE_CAPSULE, SHAPE_SPHERE, etc.

    Returns number

    Number, specifying the shape radius.

    Default Value

    0.5 (m)
    
  • get renderAsset(): null | number
  • This field contains the render asset ID, when a render asset is used for collision mesh or a convex hull.

    Returns null | number

    Asset or its ID number. Will be null if render asset is not used.

    Default Value

    null
    
  • set renderAsset(asset): void
  • Sets render asset as a collider. Note:

    • shape must be SHAPE_MESH or SHAPE_CONVEX_HULL in order for the render asset to be used.
    • If the render asset has multiple mesh instances, only the mesh from the first mesh instance is used. If you need multiple meshes, consider creating a compound collider.

    Parameters

    • asset: any

      Render asset or its id number.

    Returns void

  • get restitution(): number
  • Restitution of the body.

    Returns number

    Number, representing restitution factor for this body.

  • set restitution(factor): void
  • Sets body restitution. Dimensionless number, usually between 0 and 1:

    • 0: completely inelastic collision response
    • 1: completely elastic collision response

    Note: bodies can have negative restitution but the combined restitution should never go below zero.

    Parameters

    • factor: number

      Restitution scalar.

    Returns void

  • get rotation(): Quat
  • Read-only. Current rotation of the body.

    Returns Quat

    Quat, representing the current rotation of this body.

    Default Value

    Quat(0, 0, 0, 1) (identity rotation)
    
  • get shape(): number
  • Current shape type.

    Returns number

    Number, representing the shape type.

    Default Value

    SHAPE_BOX
    
  • set shape(shapeNum): void
  • Changes the shape type. Following constants available:

    SHAPE_EMPTY
    
    SHAPE_PLANE
    
    SHAPE_BOX
    
    SHAPE_CAPSULE
    
    SHAPE_TAPERED_CAPSULE
    
    SHAPE_CYLINDER
    
    SHAPE_TAPERED_CYLINDER
    
    SHAPE_SPHERE
    
    SHAPE_MESH
    
    SHAPE_CONVEX_HULL
    
    SHAPE_HEIGHTFIELD
    
    SHAPE_STATIC_COMPOUND
    
    SHAPE_MUTABLE_COMPOUND
    

    Parameters

    • shapeNum: number

      Shape type number.

    Returns void

  • get shapePosition(): Vec3
  • Local position offset of the collision shape.

    Returns Vec3

    Vec3 with local position offset.

    Default Value

    Vec3(0, 0, 0) (m per axis)
    
  • get shapeRotation(): Quat
  • Local rotation offset of the collision shape.

    Returns Quat

    Quat with local rotation offset.

    Default Value

    Quat(0, 0, 0, 1) (identity rotation)
    
  • get subGroup(): number
  • The collision sub group this body belongs to (determines if two objects can collide). Expensive, so disabled by default. Prefer to use broadphase and object layers instead for filtering.

    Returns number

    If set, will return a number, representing the sub group this body belongs to. Otherwise, will return -1;

    Default Value

    -1 (disabled)
    
  • get updatePosition(): boolean
  • Update the position of the body while simulating (set to false for something that is attached to the static world).

    Returns boolean

    Boolean, telling if the body position will be updated during simulation.

    Default Value

    true
    
  • get useEntityScale(): boolean
  • Applies entity scale on the shape. This makes it easier to adjust the size of the collision shape by simply scaling the entity.

    Note: Some shapes do not support non-uniformed scales, like SHAPE_SPHERE. Works best with SHAPE_BOX which you can scale on any axis. Others, like capsule and cone, can't have a different radius on X and Z axis, but allow scaling Y for their height.

    Returns boolean

    Boolean, telling if the entity scale is applied on this collision shape.

    Default Value

    true
    
  • get useMotionState(): boolean
  • A motion state for this body. Not used by static bodies.

    If the physcs fixed timestep is set lower than the client's browser refresh rate, then browser will have multiple frame updates per single physics simulation step. If you enable motion state for this entity, then the position and rotation will be interpolated, otherwise the entity will visually move only after physics completes a step.

    For example, say browser refreshes every 0.1 seconds, and physics step once a second. Without using motion state an entity position will update once every second, when physics update takes place. With motion state enabled, it will update the position/rotation every 0.1 seconds - once a true update (from physics) and 9 times interpolated. This will give a smooth motion of the entity, without having to do expensive physics simulation step every frame.

    Returns boolean

    Boolean, telling if motion state is enabled for this body.

    Default Value

    true
    
  • set useMotionState(bool): void
  • Enables/Disables a motion state for this body.

    Parameters

    • bool: boolean

      Boolean to enable/disable the motion state.

    Returns void

  • get width(): number
  • Number of cells comprising a row. Think of a grid divided plane.

    Returns number

    Number, representing the amount of cells in a row.

    Default Value

    0
    

Methods

  • Adds a force (unit: N) at an offset to this body for the next physics time step. Will reset after the physics completes a step.

    Parameters

    • force: Vec3

      Force to add to body.

    • Optional offset: any = Vec3.ZERO

      Offset from the body center where the force is added.

    • Optional isOffsetLocal: boolean = false

      Specifies if offset is in world or local space.

    Returns void

  • Same as addForce, but accepts scalars, instead of vectors.

    Parameters

    • forceX: number

      Force scalar value on X axis.

    • forceY: number

      Force scalar value on Y axis.

    • forceZ: number

      Force scalar value on Z axis.

    • Optional offsetX: number = 0

      Force scalar offset on X axis.

    • Optional offsetY: number = 0

      Force scalar offset on Y axis.

    • Optional offsetZ: number = 0

      Force scalar offset on Z axis.

    • Optional isOffsetLocal: number = false

      Specifies if offset is in world or local space.

    Returns void

  • Adds an impulse to the center of mass of the body (unit: kg m/s).

    Parameters

    • impulse: Vec3

      Impulse to add to body.

    • Optional offset: any = Vec3.ZERO

      Offset from the body center where the impulse is added.

    • Optional isOffsetLocal: boolean = false

      Specifies if offset is in world or local space.

    Returns void

  • Same as addImpulse, but accepts scalars, instead of vectors.

    Parameters

    • impulseX: number

      Impulse scalar value on X axis.

    • impulseY: number

      Impulse scalar value on Y axis.

    • impulseZ: number

      Impulse scalar value on Z axis.

    • Optional offsetX: number = 0

      Impulse scalar offset on X axis.

    • Optional offsetY: number = 0

      Impulse scalar offset on Y axis.

    • Optional offsetZ: number = 0

      Impulse scalar offset on Z axis.

    • Optional isOffsetLocal: number = false

      Specifies if offset is in world or local space.

    Returns void

  • Allows to add a shape to a mutable compound shape.

    Parameters

    • shapeIndex: number

      The index of a shape to add. It can be created by createShape.

    • Optional localPos: any = Vec3.ZERO

      Local position of the shape.

    • Optional localRot: any = Quat.IDENTITY

      Local rotation of the shape.

    • Optional userData: number = 0

      User defined unsigned integer.

    Returns void

  • Applies an impulse to the body that simulates fluid buoyancy and drag.

    Parameters

    • waterSurfacePosition: Vec3

      Position of the fluid surface in world space.

    • surfaceNormal: Vec3

      Normal of the fluid surface (should point up).

    • buoyancy: number

      The buoyancy factor for the body:

      • = 1: neutral body
      • < 1: sinks
      • > 1: floats
    • linearDrag: number

      Linear drag factor that slows down the body when in the fluid (approx. 0.5).

    • angularDrag: number

      Angular drag factor that slows down rotation when the body is in the fluid (approx. 0.01).

    • fluidVelocity: Vec3

      The average velocity of the fluid (in m/s) in which the body resides.

    Returns void

  • Allows to modify a child shape of a mutable compound shape.

    Parameters

    • childIndex: number

      The child shape index. Children indices are zero based and have no gaps.

    • Optional localPos: any = Vec3.ZERO

      Local position of the shape.

    • Optional localRot: any = Quat.IDENTITY

      Local rotation of the shape.

    • Optional shapeIndex: number = -1

      The index of a shape to add. It can be created by createShape.

    Returns void

  • Changes the position and rotation of a dynamic body. Unlike teleport, this method doesn't change the position/rotation instantenously, but instead calculates and sets linear and angular velocities for the body, so it can reach the target position and rotation in the specified delta time. If delta time is set to zero, the engine will use the current fixed timestep value.

    Parameters

    • pos: Vec3

      Taret position the body should reach in given dt.

    • rot: Quat

      Target rotation the body should reach in given dt.

    • Optional dt: number = 0

      Time in which the body should reach target position and rotation (seconds).

    Returns void

  • Allows to remove a child shape from a mutable compound shape. The children are indexed in order they were added. Indices are zero based and have no gaps. If you remove a child, then the next child takes its index.

    For example, if you remove child under index 0, then all children shift there indices, so that the child with index 1, becomes a child with index 0, etc.

    Parameters

    • childIndex: number

      The index of a child shape to remove.

    Returns void

  • Sets whether kinematic objects can generate contact points against other kinematic or static objects. Note that turning this on can be CPU intensive as much more collision detection work will be done without any effect on the simulation (kinematic objects are not affected by other kinematic/static objects).

    This can be used to make sensors detect static objects. Note that the sensor must be kinematic and active for it to detect static objects.

    Parameters

    • bool: boolean

      Boolean, telling if we want kinematics contactact non-dynamic bodies.

    Returns void

  • Changes the collision group and sub group this body belongs to. Using collision groups is expensive, so it is disabled by default. Prefer to use broadphase and object layers instead for filtering.

    Parameters

    • collisionGroup: number

      Collision group number. Use -1 to disable.

    • subGroup: number

      Sub group number. Use -1 to disable.

    Returns void

  • Used only when this body is dynamic and colliding. Override for the number of solver position iterations to run, 0 means use the default in settings.numPositionSteps. The number of iterations to use is the max of all contacts and constraints in the island.

    Parameters

    • count: number

      Number of velocity steps.

    Returns void

  • Used only when this body is dynamic and colliding. Override for the number of solver velocity iterations to run, 0 means use the default in settings.numVelocitySteps. The number of iterations to use is the max of all contacts and constraints in the island.

    Parameters

    • count: number

      Number of velocity steps.

    Returns void

  • Intantenous placement of a body to a new position/rotation (i.e. teleport). Will ignore any bodies between old and new position.

    Parameters

    • position: Vec3

      World space position where to place the body.

    • Optional rotation: any = Quat.IDENTITY

      World space rotation the body should assume at new position.

    Returns void

  • Same as teleport, but taking scalars, instead of vectors.

    Parameters

    • px: number

      Position scalar value on X axis.

    • py: number

      Position scalar value on Y axis.

    • pz: number

      Position scalar value on Z axis.

    • Optional rx: number = 0

      Rotation scalar value on X axis.

    • Optional ry: number = 0

      Rotation scalar value on Y axis.

    • Optional rz: number = 0

      Rotation scalar value on Z axis.

    • Optional rw: number = 1

      Rotation scalar value on W axis.

    Returns void