constructor(rad?: number)
View sourceCreates an angle in radians.
Class
ExtendsAngle
Represents an entity’s angular motion in 2D as an ECS component.
Store the angular rate in radians, using positive and negative values for
opposite directions. Use it with Orientation2D when an entity
needs both angular motion and a current orientation. The component follows
the radian representation and default value supplied by Angle.
import { Query, World } from '@wimaengine/ecs'
import { Rotation2D } from '@wimaengine/movable'
const world = new World()
world.spawn([new Rotation2D(Math.PI / 2)])
const rotations = new Query(world, [Rotation2D])
rotations.each(([rotation]) => {
// Set the entity's angular rate to one quarter turn per second.
rotation.value = Math.PI / 2
})copy(source: Rotation2D, target?: Rotation2D): Rotation2DCopies the angular motion value from one Rotation2D to another.
clone(target: Rotation2D): Rotation2DCreates a new Rotation2D with the same angular motion value as
the supplied component.
default(): Rotation2Dserialize(value: Rotation2D): numberSerializes a Rotation2D to its scalar radian representation.
deserialize(value: number, out?: Rotation2D): Rotation2DCreates or updates a Rotation2D from a serialized radian value.