(i + 1 < length) is buggy behavior
Imagine if i = 0 and length = 1, this will evaluate to false, which will go to the else statement where prevKeyFrame = keyFrames[i - 1] → prevKeyFrame will be null, and therefore prevKeyFrame.value will throw an error
Noticed this after it broke a GLTF export on my side