The Quaternion.random() function is a method provided by the three.js library, which generates a random quaternion.
Quaternion.random()
The function returns a new instance of Quaternion that represents a randomly generated quaternion.
A Quaternion represents an orientation in 3D space, which can be used to represent rotations in 3D applications.
The Quaternion.random() function generates a random Quaternion, which has a unit length of 1, and can be used to rotate an object randomly.
// Create a new quaternion
let quaternion = new THREE.Quaternion();
// Generate a random quaternion
quaternion.random();
// Apply the quaternion to an object
object.applyQuaternion(quaternion);
The random() method is provided as a convenience method to generate random Quaternion values.
A Quaternion can also be manually created by specifying the four components of the quaternion: .set(x, y, z, w), or by creating a quaternion from euler angles, axis-angle representation or from a matrix using .setFromEuler(euler), .setFromAxisAngle(axis, angle) and .setFromRotationMatrix(matrix) respectively.