rotateUV
`rotateUV` is a utility node that encapsulates the 2D rotation algorithm, used to easily rotate 2D vectors like UV coordinates around a specified center point.
Core Advantages
Simplifies code immensely by wrapping the complex rotation logic (translate-rotate-translate) into a single function. It allows precise control over the pivot point (defaulting to the common UV center, `vec2(0.5)`) and is ideal for creating animated effects like whirlpools by connecting dynamic nodes (e.g., `timerLocal`).
Common Uses
Whirlpool & Portal FX
Static Rotation & Decal Alignment
Gauge & Radar Scan Animations
How to adjust
Effects are adjusted by changing the `rotation` and `center` inputs. Connecting `timerLocal().mul(speed)` to `rotation` controls the animation's speed and direction. Changing the `center` value moves the pivot point. Using `sin(timerLocal())` can create a back-and-forth oscillating motion.
Code Examples
1// Rotate the original UV coordinates around their center (the default)
2// The rotation angle is driven by a time-based node (timerLocal)
3const rotatedUV = rotateUV(uv(), timerLocal());
4
5// Use the rotated UVs for texture sampling to create a dynamic rotation effect
6const sampledColor = texture(myTexture, rotatedUV);