private void interpolate(Object[] keyFrames, Type type) {
        int i = 0;
        while (i < totalFrames) {
            //fetching the next keyFrame index transform in the array
            int key = getNextKeyFrame(i, keyFrames);
            if (key != -1) {
                //computing the frame span to interpolate over
                int span = key - i;
                //iterating over the frames
                for (int j = i; j <= key; j++) {
                    // computing interpolation value
                    float val = (j - i) / (float) span;
                    //interpolating depending on the transform type
                    switch (type) {
                        case Translation:
                            translations[j] = FastMath.interpolateLinear(val, (Vector3f) keyFrames[i], (Vector3f) keyFrames[key]);
                            break;
                        case Rotation:
                            Quaternion rot = new Quaternion();
                            rotations[j] = rot.slerp(((Rotation) keyFrames[i]).rotation, ((Rotation) keyFrames[key]).rotation, val);
                            break;
                        case Scale:
                            scales[j] = FastMath.interpolateLinear(val, (Vector3f) keyFrames[i], (Vector3f) keyFrames[key]);
                            break;
                    }
                }
                //jumping to the next keyFrame
                i = key;
            } else {
                //No more key frame, filling the array with the last transform computed.
                for (int j = i; j < totalFrames; j++) {

                    switch (type) {
                        case Translation:
                            translations[j] = ((Vector3f) keyFrames[i]).clone();
                            break;
                        case Rotation:
                            rotations[j] = ((Rotation) keyFrames[i]).rotation.clone();
                            break;
                        case Scale:
                            scales[j] = ((Vector3f) keyFrames[i]).clone();
                            break;
                    }
                }
                //we're done
                i = totalFrames;
            }
        }
    }
Interpolates over the key frames for the given keyFrame array and the given type of transform
@param keyFrames the keyFrames array
@param type the type of transforms
jme3-core/src/main/java/com/jme3/animation/AnimationFactory.java