I need some light on this question I'm trying to set vertices of a geometry using a quaternion and
geometry.attributes.position.array[x].applyQuaternion(quaternion)
is not working as expected I know this implementation as changed in the passed and I suspect that the problem is that
geometry.vertices[x]
is not available anymore
some one on this ?
The method .applyQuaternion() is only available in Vector3(), not in a simple number. You cannot perform 7.applyQuaternion() with a number. In this context, it doesn't make sense to apply a 3D rotation to a 1-dimensional value.
First, make sure you create a Vector3 with the XYZ coordinates of the vertex you're trying to manipulate by using the BufferAttribute.get... method:
// Create quaternion
const quat = new THREE.Quaternion();
quat.setFromAxisAngle( /* ... */ );
// Position attribute
const posAttrib = geometry.getAttribute('position');
// Let's get the XYZ components of the 7th vertex in the geometry
const twistVec = new THREE.Vector3(
posAttrib.getX(7),
posAttrib.getY(7),
posAttrib.getZ(7)
);
// Now that you've created a Vec3, you CAN apply a quaternion
twistVec.applyQuaternion(quat);