constructor(x?: number, y?: number)
View sourceCreates a local 2D scale.
Class
ExtendsVector2
Stores an entity’s local 2D scale as an ECS component. Its coordinates
default to (1, 1) when omitted, preserving the entity’s original size on
both axes.
Use Scale2D with World and Query when an entity
needs a mutable 2D scale. It extends Vector2.
import { Query, World } from '@wimaengine/ecs'
import { Scale2D } from '@wimaengine/transform'
const world = new World()
world.spawn([new Scale2D(2, 0.5)])
const scales = new Query(world, [Scale2D])
scales.each(([scale]) => {
scale.x *= 0.5
scale.y *= 2
})default(): Scale2Dcopy(source: Scale2D, target?: Scale2D): Scale2Dclone(target: Scale2D): Scale2Dserialize(value: Scale2D): Vector2Likedeserialize(value: Vector2Like, out?: Scale2D): Scale2D