123456789101112131415161718192021222324252627282930313233343536 |
- using System;
- using UnityEngine;
- namespace Leap.Unity
- {
- [Serializable]
- public class SmoothedQuaternion
- {
- public void SetBlend(float blend, float deltaTime = 1f)
- {
- this.delay = deltaTime * blend / (1f - blend);
- }
- public Quaternion Update(Quaternion input, float deltaTime = 1f)
- {
- if (deltaTime > 0f && !this.reset)
- {
- float num = this.delay / deltaTime;
- float num2 = num / (1f + num);
- this.value = Quaternion.Slerp(this.value, input, 1f - num2);
- }
- else
- {
- this.value = input;
- this.reset = false;
- }
- return this.value;
- }
- public Quaternion value = Quaternion.identity;
- public float delay;
- public bool reset = true;
- }
- }
|