Components
Core Components
Transform
Every entity that exists in 3D space has a Transform component. It defines position, rotation, and scale.
| Property | Type | Default | Description |
|---|---|---|---|
position | Vec3 | {x: 0, y: 0, z: 0} | World-space position |
rotation | Quaternion | {w: 1, x: 0, y: 0, z: 0} | World-space rotation as quaternion (w, x, y, z) |
scale | Vec3 | {x: 1, y: 1, z: 1} | Scale on each axis |
Setting Transform via Operations
{
"op": "SetProperty",
"params": {
"entity_name": "MyCube",
"component_type": "Transform",
"property_path": "/position",
"value": { "x": 0, "y": 5, "z": -3 }
}
}
Accessing Transform in Scripts
void OnUpdate(ScriptContext* ctx) {
float pos[3];
ctx->get_position(ctx->self, pos);
// Move forward
pos[2] += ctx->get_delta_time() * 5.0f;
ctx->set_position(ctx->self, pos);
}
CameraComponent
Defines how the scene is viewed. Supports perspective and orthographic projection.
| Property | Type | Default | Description |
|---|---|---|---|
projection | Enum | perspective | Projection type: perspective or orthographic |
fov | Float | 60 | Field of view in degrees (perspective only) |
near_plane | Float | 0.1 | Near clipping plane distance |
far_plane | Float | 1000 | Far clipping plane distance |
ortho_size | Float | 5 | Half-height of orthographic view (orthographic only) |
Example: Security Camera Setup
[
{
"op": "CreateEntity",
"params": { "name": "SecurityCam" }
},
{
"op": "AddComponent",
"params": {
"entity_name": "SecurityCam",
"component_type": "Transform",
"data": {
"position": { "x": 10, "y": 8, "z": -5 },
"rotation": { "w": 0.924, "x": -0.383, "y": 0, "z": 0 }
}
}
},
{
"op": "AddComponent",
"params": {
"entity_name": "SecurityCam",
"component_type": "CameraComponent",
"data": {
"projection": "perspective",
"fov": 45,
"near_plane": 0.5,
"far_plane": 200
}
}
}
]
Scripting: Switch Active Camera
void OnUpdate(ScriptContext* ctx) {
// Press C to switch to this camera
if (ctx->is_key_pressed(ctx, 67)) { // 67 = 'C'
ctx->set_active_camera(ctx, ctx->self);
}
}