getDirection
getDirection
Converts a 2D UV coordinate on a specific face of a cube into a 3D direction vector from the cube's center.
Core Advantages
Encapsulates the complex and error-prone logic of converting cube face coordinates to a direction vector into a single reliable node, forming the basis for procedural cube map generation.
Common Uses
Procedural Skybox Generation
Equirectangular to Cube Map Conversion
Procedural Geometry Generation (e.g., spheres)
Debugging Cube Maps
How to adjust
Adjusting the `face` input (an index from 0-5) switches to a different face of the cube, changing the output direction vector. Modifying the `uv` input, for instance by multiplying it with a `timer` node, can create dynamic scaling or tiling effects on the output direction pattern when visualized as color.
Code Examples
1// Get the 3D direction based on the current face and UV coordinate
2const direction = getDirection( uv(), face );
3
4// Use the direction to calculate a sky color
5const skyColor = proceduralSky( direction );