Scale2D

View source

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.

Examples

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
})

Constructor


constructor(x?: number, y?: number)

View source

Creates a local 2D scale.

Parameters

NameDescriptionDefault
x?

Scale along the local x-axis.

1
y?

Scale along the local y-axis.

1

Methods


staticserialize(value: Scale2D): Vector2Like

View source

Parameters

NameDescriptionDefault
value——
  • @inheritDoc

staticdeserialize(value: Vector2Like, out?: Scale2D): Scale2D

View source

Parameters

NameDescriptionDefault
value——
out?—...
  • @inheritDoc