BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

MathUtils.degToRad()

The MathUtils.degToRad() function is a utility function provided by the Three.js library to convert values from degrees to radians.

Syntax

MathUtils.degToRad(degrees)

Parameters

  • degrees - input angle in degrees

Return Value

The function returns the input angle converted to radians.

Examples

Example 1

Convert 45 degrees to radians.

const angleInDeg = 45;
const angleInRad = MathUtils.degToRad(angleInDeg);
console.log(angleInRad); // Output: 0.7853981633974483

Example 2

Find the sine of an angle in degrees.

const angleInDeg = 30;
const angleInRad = MathUtils.degToRad(angleInDeg);
const sinValue = Math.sin(angleInRad);
console.log(sinValue); // Output: 0.5

Remarks

The MathUtils.degToRad() function is mainly used in graphics programming for converting angles between different systems of measurement. Since the Three.js library mainly deals with 3D graphics and animations, this function becomes essential for developers.

See Also