constructor(value?: number)
View sourceCreates a 2D angular damping resource.
Class
Stores the scalar damping value for 2D angular motion.
Register Damping2DPlugin to add this resource to an app’s world.
Set value to control how strongly matching Rotation2D values are
damped. New instances default to 0, while the plugin-provided resource
starts at 0.01.
The damping multiplier is 1 - value: 0 leaves a matching rotation
unchanged, and 0.01 retains 99 percent of it. 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 or finiteness check is required.
import { Angular2DDamping } from '@wimaengine/damping'
const damping = new Angular2DDamping(0.02)
const serial = Angular2DDamping.serialize(damping)
const restored = Angular2DDamping.deserialize(serial)
console.log(restored.value) // 0.02
// Damping2DPlugin installs its own resource with a default value of 0.01.Scalar damping value for matching 2D rotations.
The damping multiplier is 1 - value; 0 leaves a matching rotation
unchanged and 0.01 retains 99 percent of it.
default(): Angular2DDampingserialize(value: Angular2DDamping): Angular2DDampingSerialConverts a 2D angular damping resource to {value}.
deserialize(value: Angular2DDampingSerial, out?: Angular2DDamping): Angular2DDampingRestores a 2D angular damping resource from its serialized value.
The method copies value.value without applying a range or finiteness
check. When out is supplied, it updates and returns that instance;
otherwise it creates a new resource.
validateSerial(value: unknown): value is Angular2DDampingSerialChecks whether a value has the serialized 2D 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 or finite.