SoftBody2D

View source

Marks an entity with the 2D soft-body component type.

SoftBody2D is an empty marker component with no instance fields. Use its presence to identify an entity as a 2D soft body; the marker carries no additional state of its own.

Examples

import { World } from '@wimaengine/ecs'
import { SoftBody2D } from '@wimaengine/narrowphase'

const world = new World()
const entity = world.spawn([new SoftBody2D()])
const marker = world.get(entity, SoftBody2D)
console.log(marker instanceof SoftBody2D) // true

Constructor


constructor()

Methods


staticcopy(source: SoftBody2D, target?: SoftBody2D): SoftBody2D

View source

Copies an empty marker into a target component.

SoftBody2D has no instance fields, so source is not read. When target is omitted, a new marker is created; otherwise the exact target is returned unchanged.

Parameters

NameDescriptionDefault
source

Marker to copy; it has no state to read.

—
target?

Marker to return unchanged.

...

Returns

The supplied target or a new empty marker.

staticclone(target: SoftBody2D): SoftBody2D

View source

Creates a new empty marker because there is no state to clone.

This delegates to SoftBody2D.copy without a target, so the supplied marker is not read and the result is always a new instance.

Parameters

NameDescriptionDefault
target

Marker to clone; it has no state to read.

—

Returns

A new empty marker.

staticserialize(_value: SoftBody2D): object

View source

Serializes the marker as an empty object.

There is no instance state to persist, so _value is not read.

Parameters

NameDescriptionDefault
_value

Marker to serialize; it has no state to read.

—

Returns

The marker’s empty serialized representation.

staticdeserialize(_value: unknown, out?: SoftBody2D): SoftBody2D

View source

Deserializes an empty marker without reading serialized data.

The input is not validated or read. This returns out when supplied, or creates and returns a new marker.

Parameters

NameDescriptionDefault
_value

Serialized marker data; it is ignored.

—
out?

Marker to return.

...

Returns

The supplied output marker or a new empty marker.