private Key [] ComputeKeys(UnityEngine.Quaternion restRotation, FbxNode node)
        {
            // Get the source pivot pre-rotation if any, so we can
            // remove it from the animation we get from Unity.
            var fbxPreRotationEuler = node.GetRotationActive()
                ? node.GetPreRotation(FbxNode.EPivotSet.eSourcePivot)
                : new FbxVector4();

            // Get the inverse of the prerotation
            var fbxPreRotationInverse = ModelExporter.EulerToQuaternion(fbxPreRotationEuler);

            fbxPreRotationInverse.Inverse();

            // Find when we have keys set.
            var keyTimes =
                (UnityEditor.Formats.Fbx.Exporter.ModelExporter.ExportSettings.BakeAnimationProperty)
                ? ModelExporter.GetSampleTimes(GetCurves(), SampleRate)
                : ModelExporter.GetKeyTimes(GetCurves());

            // Convert to the Key type.
            var keys = new Key[keyTimes.Count];
            int i    = 0;

            foreach (var seconds in keyTimes)
            {
                var fbxFinalAnimation = GetConvertedQuaternionRotation(seconds, restRotation);

                // Cancel out the pre-rotation. Order matters. FBX reads left-to-right.
                // When we run animation we will apply:
                //      pre-rotation
                //      then pre-rotation inverse
                //      then animation.
                var fbxFinalQuat = fbxPreRotationInverse * fbxFinalAnimation;

                // Store the key so we can sort them later.
                Key key = new Key();
                key.time  = FbxTime.FromSecondDouble(seconds);
                key.euler = ModelExporter.QuaternionToEuler(fbxFinalQuat);
                keys[i++] = key;
            }

            // Sort the keys by time
            System.Array.Sort(keys, (Key a, Key b) => a.time.CompareTo(b.time));

            return(keys);
        }