Im making a button that twists a little when you press it. The below code, a deform function, is called from an update that flips a bool that tells the deform either to twist or untwist. My problem is that while it twists and returns, it is growing! Here is my approach:
if (firstPartOfAnimation) {
for (const v in originalVertices) {
if (timer === 1) {
const upVec = new THREE.Vector3(0, 15, 0);
const yPos = originalVertices[v].y
quaternion.setFromAxisAngle(
upVec,
yPos / 180
);
geometry.vertices[v].applyQuaternion(quaternion);
geometry.verticesNeedUpdate = true;
}
}
} else {
for (const v in originalVertices) {
if (timer === 1) {
const d = new THREE.Vector3(0, -15, 0);
const yPos = originalVertices[v].y
quaternion.setFromAxisAngle(
d,
(yPos / 180)
);
geometry.vertices[v].applyQuaternion(quaternion);
geometry.verticesNeedUpdate = true;
}
}
}
Im open to doing this in a totally different way, this is just what I came up with, but im very new.