createTransform2D

View sourcecreateTransform2D(dx?: number, dy?: number, a?: number, sx?: number, sy?: number): [Position2D, Orientation2D, Scale2D, GlobalTransform2D]

Creates the standard 2D transform component bundle for an entity.

The returned tuple contains Position2D, Orientation2D, Scale2D, and GlobalTransform2D in insertion order. Position defaults to (0, 0), the angle defaults to 0, and scale defaults to (1, 1). The angle is converted to the cosine/sine representation used by Orientation2D.

Examples

import { World } from '@wimaengine/ecs'
import { createTransform2D } from '@wimaengine/transform'

const world = new World()
world.spawn(createTransform2D(10, 20, Math.PI / 4))

Parameters

NameDescriptionDefault
dx?

Initial x position.

0
dy?

Initial y position.

0
a?

Initial 2D angle.

0
sx?

Initial x scale.

1
sy?

Initial y scale.

1

Returns

Ordered component bundle containing Position2D, Orientation2D, Scale2D, and GlobalTransform2D.