vgpu/scene1 symbolView source ↗

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

ParamTypeRequiredDefaultNotes
degnumberAngle in degrees. Positive, negative, fractional, Infinity, and NaN are passed through JavaScript number arithmetic.

Returns: numberdeg * 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/scene accept degrees for field-of-view values; do not convert PerspectiveCameraOptions.fov yourself.
  • Use degToRad for custom transforms and CPU-side uniform values that explicitly need radians.
  • See also: perspectiveCamera, orbit.