[READ-ONLY] Mirror of https://github.com/flo-bit/shapecraft.
flo-bit.dev/shapecraft/
723 B
29 lines
1# UV Projections
2
3## On a Mesh
4
5```ts
6mesh.computeUVs() // box projection (default)
7mesh.computeUVs('planar') // Y-down onto XZ plane
8mesh.computeUVs('cylindrical')
9mesh.computeUVs('spherical')
10```
11
12## Standalone
13
14Operates on a `THREE.BufferGeometry` directly (mutates in place):
15
16```ts
17import { projectUVs } from 'shapecraft'
18
19projectUVs(geometry, 'box')
20```
21
22## Projection modes
23
24| Mode | Description |
25|------|-------------|
26| `box` | Tri-planar — picks projection axis per vertex based on normal |
27| `planar` | Projects from Y axis down. `u = x`, `v = z` (normalized to bounding box) |
28| `cylindrical` | `u = atan2(z, x)`, `v = y` (normalized) |
29| `spherical` | `u = atan2(z, x)`, `v = acos(y/r)` |