degrees
A semantic function node that converts an input value from radians to degrees.
Core Advantages
Provides a more concise and readable interface than `new MathNode(MathNode.DEGREES, ...)`. The `degrees(angle)` syntax clearly expresses its intent, reducing code and preventing errors from manual node configuration.
Common Uses
Conditional logic based on angles, e.g., checking if an object's rotation is within a specific range.
Debugging and visualization, by converting complex radian values into intuitive degrees and mapping them to colors.
Driving conical or radial gradients, by converting the output of `atan2` to a 0-1 range for texture sampling.
Serving as the inverse operation to the `radians()` node, completing the unit conversion system in TSL.
How to adjust
This node is a pure mathematical conversion; its effect is demonstrated by how its output is used. For instance, in a 'Pac-Man' effect, the `degrees` node 'translates' the internal radian angle from `atan2` into an intuitive degree value. This output can then be compared against a uniform variable like `openingAngle` (0-360) passed from JavaScript to dynamically and interactively control the size of a radial mask on the screen.
Code Examples
1const angleRad = atan2( uv.y - 0.5, uv.x - 0.5 );
2const angleDeg = degrees( angleRad ); // Converts radians [-PI, PI] to degrees [-180, 180]