constructor(value?: number)
View sourceCreates a 3D linear damping resource.
Class
Stores the scalar damping value for 3D linear motion.
Add Damping3DPlugin to an app’s world to provide this resource.
Set value to control how strongly matching Velocity3D values are
damped. The damping multiplier is 1 - value: 0 leaves velocity unchanged
and 0.01 retains 99 percent of it. New instances default to 0, while the
plugin-provided resource starts at 0.01.
The resource serializes to an object with one numeric value field and can
be restored from that form. Serialized data must be a non-null object with a
numeric value; no damping range is required.
Use the resource directly when an app needs to tune linear damping or save and restore its configuration.
import { Linear3DDamping } from '@wimaengine/damping'
import { World } from '@wimaengine/ecs'
const world = new World()
world.setResource(new Linear3DDamping(0.02))
const damping = world.getResource(Linear3DDamping)
damping.value = 0.01Scalar damping value for matching 3D velocities.
The damping multiplier is 1 - value; for example, 0.01 retains 99
percent of the velocity.
default(): Linear3DDampingserialize(value: Linear3DDamping): Linear3DDampingSerialConverts a 3D linear damping resource to {value}.
deserialize(value: Linear3DDampingSerial, out?: Linear3DDamping): Linear3DDampingRestores a 3D linear damping resource from its serialized value.
The method copies value.value without applying a range check. When
out is supplied it is mutated and returned; otherwise a new resource is
created.
validateSerial(value: unknown): value is Linear3DDampingSerialChecks whether a value has the serialized 3D damping shape.
This guard requires a non-null object with a value property whose type
is number; it does not check whether the number is within a damping
range.