# Geometry

Ten procedural shapes, plus glTF models, drawn with a material.

A mesh is a `geometry` and a `material`. Geometries are single-key variants: `{"sphere": {"radius": 1}}`.

```json title="apps/docs/examples/geometry.json"
{
  "camera": { "position": [0, 0, 10], "target": [0, 0, 0], "fov": 40 },
  "lighting": { "rig": "three_point" },
  "environment": {
    "background": {
      "radial_gradient": { "inner": "#1b2233", "outer": "#07090f" }
    }
  },
  "materials": { "clay": { "preset": "matte_clay", "color": "#d9d4cc" } },
  "nodes": {
    "box": {
      "transform": { "position": [-3.8, 1, 0], "rotation": [20, 30, 0] },
      "mesh": {
        "geometry": { "box": { "size": [1, 1, 1] } },
        "material": "clay"
      }
    },
    "rounded_box": {
      "transform": { "position": [-1.9, 1, 0], "rotation": [20, 30, 0] },
      "mesh": {
        "geometry": { "rounded_box": { "size": [1, 1, 1], "radius": 0.2 } },
        "material": "clay"
      }
    },
    "sphere": {
      "transform": { "position": [0, 1, 0], "rotation": [20, 30, 0] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.6 } },
        "material": "clay"
      }
    },
    "cylinder": {
      "transform": { "position": [1.9, 1, 0], "rotation": [20, 30, 0] },
      "mesh": {
        "geometry": { "cylinder": { "radius": 0.5, "height": 1.1 } },
        "material": "clay"
      }
    },
    "cone": {
      "transform": { "position": [3.8, 1, 0], "rotation": [20, 30, 0] },
      "mesh": {
        "geometry": { "cone": { "radius": 0.5, "height": 1.1 } },
        "material": "clay"
      }
    },
    "capsule": {
      "transform": { "position": [-3.8, -1, 0], "rotation": [20, 30, 0] },
      "mesh": {
        "geometry": { "capsule": { "radius": 0.35, "length": 0.6 } },
        "material": "clay"
      }
    },
    "torus": {
      "transform": { "position": [-1.9, -1, 0], "rotation": [20, 30, 0] },
      "mesh": {
        "geometry": { "torus": { "radius": 0.5, "tube": 0.18 } },
        "material": "clay"
      }
    },
    "torus_knot": {
      "transform": { "position": [0, -1, 0], "rotation": [20, 30, 0] },
      "mesh": {
        "geometry": { "torus_knot": { "radius": 0.45, "tube": 0.15 } },
        "material": "clay"
      }
    },
    "icosahedron": {
      "transform": { "position": [1.9, -1, 0], "rotation": [20, 30, 0] },
      "mesh": {
        "geometry": { "icosahedron": { "radius": 0.6 } },
        "material": "clay"
      }
    },
    "plane": {
      "transform": { "position": [3.8, -1, 0], "rotation": [70, 0, 0] },
      "mesh": {
        "geometry": { "plane": { "size": [1.6, 1.6] } },
        "material": "clay"
      }
    }
  }
}
```

![Render of geometry](/renders/geometry.jpg)

## Shapes

`box`, `rounded_box`, `sphere`, `plane`, `cylinder`, `cone`, `capsule`, `torus`, `torus_knot` and `icosahedron`. Every size has a default, so `{"sphere": {}}` works. Cylinders, cones, capsules and spheres stand along +y. A plane faces +z: rotate it `[-90, 0, 0]` to make a floor.

For imported meshes use `{"model": {...}}`; see [Models](/docs/features/models). For a heightfield use `{"terrain": {...}}`; see [Terrain](/docs/features/terrain).

## Tips

- For thousands of thin copies, like stems or posts, give cylinders and cones `"segments": 5` to `8`.
- Geometry that differs per copy, like a different cylinder height, can't be instanced. Scale a unit mesh instead.
- `cast_shadows` and `receive_shadows` are on by default. Turn them off for sky domes, glows and distant scenery.

## API Reference

### Mesh

A primitive mesh with a material.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `cast_shadows` | `boolean` | `true` | Whether the mesh casts shadows. |
| `geometry` (required) | `Geometry` | — | The shape: a procedural geometry or a glTF model. |
| `instances` | `Instances` | — | Draw many copies with a single instanced draw call. |
| `material` | `string` | — | Name of an entry in `materials`, or `"preset:<name>"` (e.g. `"preset:chrome"`). Omit for the default material. |
| `receive_shadows` | `boolean` | `true` | Whether shadows fall on the mesh. |
| `skin` | `Skin` | — | Bend the mesh with a procedural rig: other nodes act as bones. |
### Geometry

Built-in procedural geometry. Written as `{"sphere": {"radius": 1}}`.

- `{"box": { … }}`: A box.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `[x, y, z]` | `[1,1,1]` | Full size `[x, y, z]`. |

- `{"rounded_box": { … }}`: A box with rounded edges.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `radius` | `number` | `0.1` | Edge radius. |
| `size` | `[x, y, z]` | `[1,1,1]` | Full size `[x, y, z]`. |

- `{"sphere": { … }}`: A UV sphere.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `radius` | `number` | `1` | Radius. |
| `segments` | `integer` | `48` | Segments around the equator. More is smoother. |

- `{"plane": { … }}`: A flat rectangle facing +z. Rotate it `[-90, 0, 0]` to lay it flat as a floor or water.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `[x, y]` | `[1,1]` | Size `[width, height]`. |

- `{"cylinder": { … }}`: A capped cylinder along y.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `height` | `number` | `1` | Height along y. |
| `radius` | `number` | `0.5` | Radius. |
| `segments` | `integer` | — | Sides around the axis (3..=64). Use 5-8 for thin stems and scattered copies: far fewer triangles. |

- `{"cone": { … }}`: A cone along y.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `height` | `number` | `1` | Height along y. |
| `radius` | `number` | `0.5` | Base radius. |
| `segments` | `integer` | — | Sides around the axis (3..=64). Use 5-8 for thin stems and scattered copies: far fewer triangles. |

- `{"capsule": { … }}`: A cylinder with hemispherical ends, along y.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `length` | `number` | `1` | Length of the straight middle part. |
| `radius` | `number` | `0.25` | Radius. |

- `{"torus": { … }}`: A ring.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `radius` | `number` | `1` | Distance from the centre to the middle of the tube. |
| `tube` | `number` | `0.3` | Tube radius. |

- `{"torus_knot": { … }}`: A (p, q) torus knot.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `p` | `integer` | `2` | Times the knot winds around its axis. |
| `q` | `integer` | `3` | Times the knot winds through the hole. |
| `radius` | `number` | `1` | Overall radius. |
| `tube` | `number` | `0.3` | Tube radius. |

- `{"icosahedron": { … }}`: A 20-sided solid. Good for low-poly rocks.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `detail` | `integer` | `0` | Subdivision level, 0 = faceted. |
| `radius` | `number` | `1` | Radius. |

- `{"terrain": Terrain}`: Seeded noise heightfield on the XZ plane: rolling ground, or ridged mountains with `"ridged": true`. Scatter rocks on it with the `on_terrain` instance layout.

- `{"shape": Shape}`: A flat 2D vector shape in the XY plane (rect, circle, ellipse, polygon or Bézier; filled, or stroked with `stroke`). Authoring builds only (the browser loads the authoring bundle for it).

- `{"model": Model}`: A glTF 2.0 model (`.glb`, or `.gltf` with embedded buffers). Nothing draws until it loads.
