> For the complete documentation index, see [llms.txt](https://docs.quickclient.cc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.quickclient.cc/ui/gpu.md).

# Своя геометрия

Меши, которые собираются один раз и рисуются каждый кадр.

Если одна и та же фигура рисуется каждый кадр, вершины не нужно отправлять заново. Меш собирается один раз через `gpu()` и дальше просто рисуется, так выходит дешевле. Сами вершины хранит Quick, а у скрипта остаётся только имя меша.

```java
private final Mesh marker = gpu().mesh("marker")
        .vertex(-0.5f, 0f, 0f, -1, 0f, 0f)
        .vertex(0.5f, 0f, 0f, -1, 1f, 0f)
        .vertex(0f, 1f, 0f, -1, 0.5f, 1f)
        .build();

@Override
public void onRender3D(Render3D render) {
    Entity target = entities().target();
    if (target != null) {
        render.billboard(marker, target.x(), target.y() + target.height() + 0.3, target.z(), 0.5f, 0xFFFF3B30, true);
    }
}
```

Как это работает:

* Меш `marker` это один белый треугольник с UV, он собирается один раз прямо в поле.
* Каждый кадр он выводится над головой цели как билборд, поэтому всегда повёрнут к камере.
* Цвет задаёт `tint`: белые вершины становятся красными.

## Gpu

| Метод              | Тип           | Описание                              |
| ------------------ | ------------- | ------------------------------------- |
| `gpu().mesh(name)` | `MeshBuilder` | начать сборку меша; в конце `build()` |
| `gpu().names()`    | `String[]`    | имена загруженных мешей               |
| `gpu().drop(name)` | `boolean`     | удалить меш                           |

## MeshBuilder

Вершины идут по три: каждые три подряд образуют треугольник.

| Метод                          | Описание                                                  |
| ------------------------------ | --------------------------------------------------------- |
| `vertex(x, y, z, color)`       | вершина без текстурных координат                          |
| `vertex(x, y, z, color, u, v)` | вершина с `UV0`                                           |
| `triangle(points, color)`      | сразу три вершины одного цвета; `points` это девять чисел |
| `build()`                      | передать меш в Quick и получить `Mesh`                    |

У `Mesh` есть `name()`, `vertices()` и `triangles()`.

Если меш собран из коротких вершин, Quick сам записывает в `UV1.x` масштаб отрисовки, умноженный на 8, а в `LineWidth` время в секундах. Этого достаточно, чтобы анимировать меш в шейдере без пересборки.

## Где рисовать

| Где | Вызов                                                                                 |
| --- | ------------------------------------------------------------------------------------- |
| HUD | `render.drawMesh(mesh, shader, x, y, scale, tint)` и варианты с текстурой и семплером |
| мир | `mesh(...)` и `billboard(...)` из [3D-рендера](/ui/render-3d.md)                      |

Как написать свой шейдер для меша, описано на странице [Шейдеры](/ui/shaders.md). Если шейдер не указан, меш в мире рисуется стандартным шейдером Quick.

Меш, собранный в конструкторе, сохраняется при включении и выключении скрипта. Удаляется он только при перезагрузке скриптов.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.quickclient.cc/ui/gpu.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
