Ara
Download

Search or run a command

Jump to a section or open an Ara link.

Component · twoD

Camera2d

Orthographic view. Pixel mode uses integer zoom and nearest texel sampling.

Fields

centre

vec2
View centre in world metres.
default [0,0]

pixelsPerMetre

f32
Art pixels per world metre.
default 16≥ 0.001

zoom

f32
Screen pixels per art pixel, rounded to an integer in pixel mode.
default 2≥ 0.001

pixelPerfect

bool
Snap view and sprite geometry to art pixels and sample nearest texels.
default true

ambient

vec3
Linear scene ambient illumination.
default [0.2,0.2,0.25]

background

vec3
Linear clear color behind every layer.
default [0.012,0.018,0.032]

Usage

Every edit is an undoable command: from the CLI as below, or the same JSON from an agent over MCP. See component.add and property.set.

Add it

ara do component.add -p entity=name:Crate -p component=Camera2d --why "Add Camera2d"

Set a field

ara do property.set -p entity=name:Crate -p path=Camera2d.centre -p value=[0,0] --why "Tune Camera2d"

In a scene document

{
  "Camera2d": {
    "centre": [
      0,
      0
    ]
  }
}

From C#

/// <summary>Zoom in on a 2D room.</summary>
public static void UseCamera2d(Entity entity, in Tick tick)
{
    ref var component = ref World.Get<Camera2d>(entity);
    component.Zoom = 1.5f;
}

From C#

Scripts read and write it with Get<Camera2d>(); see the Camera2d struct.

Used by