constructor(cos?: number, sin?: number)
View sourceCreates a rotary from cosine and sine.
Class
ExtendsRotary
Stores an entity’s local 2D orientation as an ECS component.
A new orientation has the identity value (1, 0), representing zero
rotation. Keep the value normalized when it represents a pure rotation.
Use Position2D, Scale2D, and GlobalTransform2D
for an entity’s local 2D transform. It extends Rotary.
import { Query, World } from '@wimaengine/ecs'
import { Orientation2D } from '@wimaengine/transform'
const world = new World()
world.spawn([
new Orientation2D(Math.cos(Math.PI / 4), Math.sin(Math.PI / 4))
])
const orientations = new Query(world, [Orientation2D])
orientations.each(([orientation]) => {
// Rotary.rotate returns a rotary result; copy it into the component.
orientation.copy(orientation.rotate(0.1))
})copy(source: Orientation2D, target?: Orientation2D): Orientation2Ddefault(): Orientation2Dclone(target: Orientation2D): Orientation2Dserialize(value: Orientation2D): RotaryLikedeserialize(value: RotaryLike, out?: Orientation2D): Orientation2D