Exemple #1
0
 public static float Abs(this float v) => Mathfs.Abs(v);
Exemple #2
0
 public static float Min(this Vector2 v) => Mathfs.Min(v.x, v.y);
Exemple #3
0
 public static float Min(this Vector4 v) => Mathfs.Min(v.x, v.y, v.z, v.w);
    void Update()
    {
        if (!followTarget)
        {
            TrackPlayer();

            return;
        }

        ResetCamWeights();

        _trackingPos =
            Mathfs.MoveTowards(_trackingPos, followTarget.transform.position.y, smoothTime * Time.deltaTime);

        // We're above the topmost breakpoint, show topcam only
        if (_trackingPos > breakpoints[0])
        {
            _virtualCam.m_Weight0 = 1.0f;

            return;
        }

        // Between cam1 and cam2, lerp.
        if (_trackingPos > breakpoints[1])
        {
            var camWeights = BlendCameras(breakpoints[0], breakpoints[1], _trackingPos);
            _virtualCam.m_Weight0 = camWeights.Item1;
            _virtualCam.m_Weight4 = camWeights.Item2;
            _virtualCam.m_Weight1 = camWeights.Item3;

            return;
        }

        // In cam2.
        if (_trackingPos > breakpoints[2])
        {
            _virtualCam.m_Weight1 = 1.0f;

            return;
        }

        // Between cam2 and cam3, lerp.
        if (_trackingPos > breakpoints[3])
        {
            float t = Mathfs.Smoother01(Mathfs.InverseLerp(breakpoints[2], breakpoints[3], _trackingPos));
            _virtualCam.m_Weight1 = 1.0f - t;
            _virtualCam.m_Weight2 = t;

            return;
        }

        // In cam3.
        if (_trackingPos > breakpoints[4])
        {
            _virtualCam.m_Weight2 = 1.0f;

            return;
        }

        // Between cam3 and cam4, lerp.
        if (_trackingPos > breakpoints[5])
        {
            var camWeights = BlendCameras(breakpoints[4], breakpoints[5], _trackingPos);
            _virtualCam.m_Weight2 = camWeights.Item1;
            _virtualCam.m_Weight4 = camWeights.Item2;
            _virtualCam.m_Weight3 = camWeights.Item3;

            return;
        }

        // We're below the bottommost breakpoint, show botcam only
        _virtualCam.m_Weight3 = 1.0f;
    }
Exemple #5
0
 public static Vector3 Clamp01(this Vector3 v) => new Vector3(Mathfs.Clamp01(v.x), Mathfs.Clamp01(v.y), Mathfs.Clamp01(v.z));
Exemple #6
0
 public static Vector3 Round(this Vector3 v) => new Vector3(Mathfs.Round(v.x), Mathfs.Round(v.y), Mathfs.Round(v.z));
 private void Update()
 {
     _currentMoonPhase = Mathfs.SmoothDamp(_currentMoonPhase, _targetPhase, ref _moonPhaseVel, 1.0f, 0.7f);
     RenderSettings.skybox.SetFloat(MoonPhase, _currentMoonPhase);
 }
Exemple #8
0
 public static int FloorToInt(this float v) => Mathfs.FloorToInt(v);
Exemple #9
0
 public static int CeilToInt(this float v) => Mathfs.CeilToInt(v);
Exemple #10
0
 public static float Repeat(this float v, float length) => Mathfs.Repeat(v, length);
Exemple #11
0
 public static int Mod(this int value, int length) => (value % length + length) % length;         // modulo
 public static int RoundToInt(this float v) => Mathfs.RoundToInt(v);
Exemple #12
0
 public static float Remap(this float v, float iMin, float iMax, float oMin, float oMax) => Mathfs.Remap(iMin, iMax, oMin, oMax, v);
Exemple #13
0
 public static float Clamp(this float v, float min, float max) => Mathfs.Clamp(v, min, max);
Exemple #14
0
 public static float Magnitude(this float v) => Mathfs.Abs(v);
Exemple #15
0
 public static Vector4 Ceil(this Vector4 v) => new Vector4(Mathfs.Ceil(v.x), Mathfs.Ceil(v.y), Mathfs.Ceil(v.z), Mathfs.Ceil(v.w));
Exemple #16
0
 public static float Frac(this float v) => v - Mathfs.Floor(v);
Exemple #17
0
 public static Vector2 Round(this Vector2 v) => new Vector2(Mathfs.Round(v.x), Mathfs.Round(v.y));
Exemple #18
0
 public static float Clamp01(this float v) => Mathfs.Clamp01(v);
Exemple #19
0
 public static Vector4 Round(this Vector4 v) => new Vector4(Mathfs.Round(v.x), Mathfs.Round(v.y), Mathfs.Round(v.z), Mathfs.Round(v.w));
Exemple #20
0
 public static Vector2 Floor(this Vector2 v) => new Vector2(Mathfs.Floor(v.x), Mathfs.Floor(v.y));
    // Update is called once per frame
    void Update()
    {
        var elapsed = Time.time - startTime;

        text.text = $"{Mathfs.Floor(elapsed / 60)}:{Mathfs.Floor(elapsed % 60):00}:{Mathfs.Floor((elapsed % 1) * 1000):000}";
    }
Exemple #22
0
 public static Vector3 Floor(this Vector3 v) => new Vector3(Mathfs.Floor(v.x), Mathfs.Floor(v.y), Mathfs.Floor(v.z));
Exemple #23
0
 public static Vector2 Clamp01(this Vector2 v) => new Vector2(Mathfs.Clamp01(v.x), Mathfs.Clamp01(v.y));
Exemple #24
0
 public static Vector4 Floor(this Vector4 v) => new Vector4(Mathfs.Floor(v.x), Mathfs.Floor(v.y), Mathfs.Floor(v.z), Mathfs.Floor(v.w));
Exemple #25
0
 public static Vector4 Clamp01(this Vector4 v) => new Vector4(Mathfs.Clamp01(v.x), Mathfs.Clamp01(v.y), Mathfs.Clamp01(v.z), Mathfs.Clamp01(v.w));
Exemple #26
0
 public static Vector2 Ceil(this Vector2 v) => new Vector2(Mathfs.Ceil(v.x), Mathfs.Ceil(v.y));
Exemple #27
0
 public static float Min(this Vector3 v) => Mathfs.Min(v.x, v.y, v.z);
Exemple #28
0
 public static Vector3 Ceil(this Vector3 v) => new Vector3(Mathfs.Ceil(v.x), Mathfs.Ceil(v.y), Mathfs.Ceil(v.z));
Exemple #29
0
 public static float Max(this Vector2 v) => Mathfs.Max(v.x, v.y);
Exemple #30
0
 public static float AtMost(this float v, float max) => Mathfs.Min(v, max);