The applyQuaternion()
method of BufferGeometry
rotates the geometry's vertices by a given quaternion.
geometry.applyQuaternion(quaternion)
quaternion
- a Quaternion
object that represents the rotation to be applied to the vertices.This method applies the given quaternion to the geometry's vertices, effectively rotating the geometry in 3D space. The vertices are updated in place, so no new vertex data is generated.
Rotate a geometry by a quaternion:
const geometry = new THREE.BoxBufferGeometry(1, 1, 1);
const quaternion = new THREE.Quaternion().setFromEuler(new THREE.Euler(Math.PI / 4, 0, 0));
geometry.applyQuaternion(quaternion);
The above code rotates a box geometry by 45 degrees around the x-axis.
BufferGeometry
, including custom geometries.