Quaternion keyframe track did not work until this trick

I was manually create a clip made of multiple quaternion keyframe tracks. The animation was badly broken until I accidentally added a slerp to a random quaternion by a minimal margin, as in:

let q = methodToGetQuaternion()
q.slerp(new THREE.Quaternion().random(), Math.random() * 0.00001)
values.push(q.x, q.y, q.z, q.w);

I had been pulling my hair foe the last few days. Can anyone shed light on this? Grateful.

the trick was really the new THREE.Quaternion().random() part. This worked too:

q.slerp(new THREE.Quaternion().random(), 0.00001)

It did not work if I had slerped toward a fixed quaternion such as an identity quaternion.

Honestly, I’m struggling to understand what does this mean and how it got resolved by such a minimal change of the quaternion. Any chance to make CodePen, CodeSandbox or jsFiddle demo?

I have coded a hand animator that uses hand-made animation clips to drive hand gestures. I’ll try to recreate the issue with a simple demo.