---
title: "TriMesh"
section: "Geometry"
order: 603
description: "TriMesh — Vuer documentation"
---

# TriMesh

## Overview

`TriMesh` creates custom 3D meshes from numpy arrays, giving you complete control over vertices and faces for procedural generation, real-time updates, and scientific visualization.

## Basic Usage

```python
import numpy as np
from vuer import Vuer, VuerSession
from vuer.schemas import DefaultScene, TriMesh, OrbitControls

# Create a simple triangle
vertices = np.array([
    [0, 0, 0],
    [1, 0, 0],
    [0.5, 1, 0],
], dtype=np.float32)
faces = np.array([[0, 1, 2]], dtype=np.int32)

app = Vuer()

@app.spawn(start=True)
async def main(sess: VuerSession):
    sess.set @ DefaultScene(
        TriMesh(
            key="triangle",
            vertices=vertices,
            faces=faces,
            color="red"
        ),
        bgChildren=[
            OrbitControls(key="OrbitControls")
        ],
    )

    await sess.forever()
```

## Key Parameters

| Parameter  | Type    | Default | Description                             |
| ---------- | ------- | ------- | --------------------------------------- |
| `vertices` | ndarray | -       | (N, 3) float32 array of XYZ coordinates |
| `faces`    | ndarray | -       | (M, 3) uint32 array of triangle indices |
| `colors`   | ndarray | -       | (N, 3 or 4) array of per-vertex colors  |
| `uv`       | ndarray | -       | (N, 2) array of UV texture coordinates  |

## Learn More

- [Loading 3D Meshes](/examples/meshes/mesh_loading) - 5 ways for loading meshes and how to update the mesh in real-time.
- [Textured TriMesh](/examples/meshes/textured_trimesh) - Adding textures to triangle meshes
- [Materials and Textures](/guides/first_3d_scene/02_materials_and_textures) - Advanced materials
