GlobalTransform2D

View source

ExtendsAffine2

Stores an entity’s resolved 2D world-space transform as an ECS component.

Use GlobalTransform2D with Position2D, Orientation2D, and Scale2D when an entity needs a computed world-space pose. A root entity’s value reflects its local transform; a child entity’s value also includes the transforms above it in the Parent/Children hierarchy. The component extends Affine2 for affine 2D transform data and operations.

Examples

import { Query, World } from '@wimaengine/ecs'
import {
  GlobalTransform2D,
  Orientation2D,
  Position2D,
  Scale2D
} from '@wimaengine/transform'

const world = new World()
world.spawn([
  new Position2D(),
  new Orientation2D(),
  new Scale2D(),
  new GlobalTransform2D()
])

// In an app with Transform2DPlugin, this value is the entity's resolved
// world-space transform once its transform has been updated.
const transforms = new Query(world, [GlobalTransform2D])
transforms.each(([transform]) => {
  console.log(transform.x, transform.y)
})

Constructor


Methods