Components
Rendering Components
MeshComponent
Attaches a mesh to an entity for rendering. References mesh and material assets by GUID.
| Property | Type | Default | Description |
|---|---|---|---|
mesh_guid | Guid | null | GUID of the mesh asset to render |
material_guid | Guid | null | GUID of the material to apply |
visible | Bool | true | Whether the mesh is rendered |
Creating a Mesh Entity
The easiest way is through CreatePrimitive, which auto-creates the entity with Transform and MeshComponent:
{
"op": "CreatePrimitive",
"params": {
"primitive_type": "Sphere",
"entity_name": "Ball",
"position": [0, 3, 0],
"segments": 32
}
}
Available primitive types: Cube, Sphere, Plane, Cylinder.
Toggling Visibility in Scripts
void OnUpdate(ScriptContext* ctx) {
// Toggle mesh visibility with V key
if (ctx->is_key_pressed(ctx, 86)) { // 86 = 'V'
bool visible;
ctx->get_mesh_visible(ctx, ctx->self, &visible);
ctx->set_mesh_visible(ctx, ctx->self, !visible);
}
}
SkinnedMeshComponent
A mesh that deforms based on a skeletal animation rig. Used for animated characters and objects.
| Property | Type | Default | Description |
|---|---|---|---|
mesh_guid | Guid | null | GUID of the skinned mesh asset |
skeleton_guid | Guid | null | GUID of the skeleton asset |
material_guid | Guid | null | GUID of the material to apply |
source_glb_path | String | "" | Path to the source glb file (for re-import) |
visible | Bool | true | Whether the mesh is rendered |
cast_shadows | Bool | true | Whether this mesh casts shadows |
Skinned meshes are typically created by importing a .glb file that contains a skeleton and skinning data.
PBRMaterialComponent
Physically-based rendering material using the metallic/roughness workflow. Supports albedo, normal, and ambient occlusion textures.
| Property | Type | Default | Description |
|---|---|---|---|
guid | Guid | null | Material asset GUID |
name | String | "" | Display name |
base_color | Vec4 | {x:1, y:1, z:1, w:1} | RGBA base color in sRGB space (0-1 range) |
metallic | Float | 0.0 | Metallic factor. 0 = dielectric (plastic, wood), 1 = metal (gold, iron) |
roughness | Float | 0.5 | Roughness factor. 0 = mirror-smooth, 1 = fully rough/matte |
albedo_texture_guid | Guid? | null | Optional albedo texture (sRGB). base_color modulates the texture |
normal_texture_guid | Guid? | null | Optional normal map (tangent-space, linear) |
ao_texture_guid | Guid? | null | Optional ambient occlusion texture (linear, red channel) |
Common Material Presets
| Material | base_color | metallic | roughness |
|---|---|---|---|
| Plastic (red) | [0.8, 0.1, 0.1, 1] | 0.0 | 0.4 |
| Polished metal | [0.9, 0.9, 0.9, 1] | 1.0 | 0.1 |
| Rough wood | [0.5, 0.3, 0.15, 1] | 0.0 | 0.8 |
| Gold | [1.0, 0.76, 0.33, 1] | 1.0 | 0.3 |
| Glass | [0.9, 0.95, 1.0, 0.3] | 0.0 | 0.05 |
Example: Apply PBR Material
{
"op": "CreatePBRMaterial",
"params": {
"entity_name": "Floor",
"base_color": [0.5, 0.3, 0.15, 1.0],
"metallic": 0.0,
"roughness": 0.8,
"material_name": "WoodFloor"
}
}
UnlitMaterial
A flat-color material that ignores scene lighting. Useful for UI elements, debug visualization, wireframes, and stylized rendering.
| Property | Type | Default | Description |
|---|---|---|---|
guid | Guid | null | Material asset GUID |
name | String | "" | Display name |
color | Vec4 | {x:1, y:1, z:1, w:1} | RGBA color (0-1 range) |
albedo_texture_guid | Guid? | null | Optional texture. Color modulates the texture |