Angular2DDamping

View source

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.

Examples

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.

Constructor


constructor(value?: number)

View source

Creates a 2D angular damping resource.

Parameters

NameDescriptionDefault
value?

Fraction removed from each matching 2D rotation.

0

Properties


value: number

View source

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.

Methods


staticdeserialize(value: Angular2DDampingSerial, out?: Angular2DDamping): Angular2DDamping

View source

Restores 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.

Parameters

NameDescriptionDefault
value——
out?—...

staticvalidateSerial(value: unknown): value is Angular2DDampingSerial

View source

Checks 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.

Parameters

NameDescriptionDefault
value——