createBasicMesh2D

View sourcecreateBasicMesh2D(mesh?: Handle<Mesh>, material?: Handle<BasicMaterial>, x?: number, y?: number, a?: number, sx?: number, sy?: number): [Position2D, Orientation2D, Scale2D, GlobalTransform2D, Meshed, BasicMaterialInstance]

Creates an ordered 2D mesh component tuple for World#spawn.

The tuple contains, in order, the four components returned by createTransform2D: Position2D, Orientation2D, Scale2D, and GlobalTransform2D; it then appends Meshed and BasicMaterialInstance. The supplied mesh and material handles are passed directly to those components, so this helper does not create or clone either handle.

Pass the returned tuple as the component array to World#spawn, or spread it into a larger component array when adding more components.

Examples

const entity = world.spawn([
  ...createBasicMesh2D(mesh, material, 0.25, 0.1)
])

Parameters

NameDescriptionDefault
mesh?

Mesh handle passed to Meshed.

—
material?

Basic material handle passed to BasicMaterialInstance.

—
x?

2D position x-coordinate passed to createTransform2D.

0
y?

2D position y-coordinate passed to createTransform2D.

0
a?

2D orientation angle passed to createTransform2D.

0
sx?

2D x-axis scale passed to createTransform2D.

1
sy?

2D y-axis scale passed to createTransform2D.

1

Returns

Ordered 2D transform, mesh, and material components.