private void buildRoadVertexPath()
        {
            var vertexList     = new List <Vector3>();
            var directionsList = new List <Vector3>();
            var rotationsList  = new List <Quaternion>();
            var distanceList   = new List <float>();

            var currentRoadElement = 0;

            for (var t = 0f; t < road.GetDistance(); t += scanStep)
            {
                var p = road.GetPosition(t, ref currentRoadElement);
                var d = road.GetLookatSmooth(t, currentRoadElement);
                var r = Quaternion.LookRotation(d);

                var isSignificantVertex = vertexList.IsNullOrEmpty() || Vector3.Angle(d, directionsList.Last()) > angleThreshold;

                if (isSignificantVertex)
                {
                    vertexList.Add(p);
                    directionsList.Add(d);
                    rotationsList.Add(r);
                    distanceList.Add(t);
                }
            }

            positions  = vertexList.ToArray();
            directions = directionsList.ToArray();
            rotations  = rotationsList.ToArray();
            distances  = distanceList.ToArray();
        }
 public void Init(ERModularRoad modularRoad)
 {
     road          = new ERRoadNetwork().GetRoadByGameObject(modularRoad.gameObject);
     totalDistance = road.GetDistance();
     buildRoadVertexPath();
 }