using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; namespace SC.XR.Unity { public class SmoothnessVector3 { int pool1Size; public List dataPool1 = new List(); public Vector3 pool1OutVector3 = Vector3.zero; int currentItem = 0; private SmoothnessVector3() { } //const int pool2Size = 50; //public List dataPool2 = new List(pool2Size); //public Vector3 pool2OutVector3 = Vector3.zero; public SmoothnessVector3(Vector3 initValue, int size = 50) { pool1Size = size; for(int i = 0; i < pool1Size; i++) { dataPool1.Add(initValue); } } //int j = 0; //float timer = 0; //void Update() { // timer += Time.deltaTime; // if (timer < 0.5f) // return; // timer = 0; // //pool1OutVector3 = GetSmoothnessValue(Vector3.one*(j++)); // pool1OutVector3 = Smaoothness(); //} void UpdatePool(Vector3 item) { if(currentItem >= pool1Size) { currentItem = 0; } dataPool1[currentItem++] = item; //for (int i=0;i< pool1Size; i++) { // //Debug.Log(i+":"+ dataPool1[i]); //} } Vector3 Smaoothness() { Vector3 sum = Vector3.zero; foreach(var item in dataPool1) { sum += item; } return sum = sum / pool1Size; } public Vector3 GetSmoothnessValue(Vector3 item) { UpdatePool(item); return pool1OutVector3 = Smaoothness(); } } }