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.randFloatSpread()

The MathUtils.randFloatSpread() method is a static method of the THREE library's MathUtils module. It generates a random floating-point number within a specified range.

Syntax

THREE.MathUtils.randFloatSpread(range)

Parameters

  • range (Number): The range of the random number generation. The generated random number will be in the range -range/2 to range/2.

Return Value

  • (Number): The generated random number within the specified range.

Example Usage

const randomNum = THREE.MathUtils.randFloatSpread(10);
console.log(randomNum); // returns a random number between -5 and 5

Remarks

This method is useful when you need to generate random numbers within a specified range. The generated number will always be a floating-point number.

Related methods

  • MathUtils.clamp(value, min, max): Clamps a value between a minimum and maximum range.
  • MathUtils.degToRad(degrees): Converts an angle from degrees to radians.
  • MathUtils.radToDeg(radians): Converts an angle from radians to degrees.