Symbols in this topic
degToRad
Converts degrees to radians for custom scene math. Use it when a shader uniform, animation helper, or math API expects radians while your input is in degrees.
Import
TypeScript
1
import { degToRad } from "vgpu/scene";Signature
TypeScript
1
declare function degToRad(deg: number): number;Parameters
| Param | Type | Required | Default | Notes |
|---|---|---|---|---|
| deg | number | ✔ | — | Angle in degrees. Positive, negative, fractional, Infinity, and NaN are passed through JavaScript number arithmetic. |
Returns: number — deg * Math.PI / 180, suitable for Math.sin, Math.cos, matrix helpers, or shader uniforms that expect radians.
Throws: None.
Examples
TypeScript
1
2
3
4
5
import { degToRad } from "vgpu/scene";
const quarterTurn = degToRad(90);
const rotation = { sinAngle: Math.sin(quarterTurn), cosAngle: Math.cos(quarterTurn) };
void rotation;TypeScript
1
2
3
4
import { degToRad } from "vgpu/scene";
const clockwise = degToRad(-45);
console.log(clockwise < 0);Notes
- Public camera helpers in
vgpu/sceneaccept degrees for field-of-view values; do not convertPerspectiveCameraOptions.fovyourself. - Use
degToRadfor custom transforms and CPU-side uniform values that explicitly need radians. - See also:
perspectiveCamera,orbit.