// Use this for initialization void Start() { TidesJSONReader reader = GetComponent <TidesJSONReader>(); plotPoints = reader.Points; Debug.Log(plotPoints[0].y); controlPoints = new Vector3[plotPoints.Length]; for (int i = 0; i < plotPoints.Length; i++) { controlPoints[i] = new Vector3( origin.transform.position.x + plotPoints[i].step * 19f, origin.transform.position.y + plotPoints[i].y / 100f, 0f ); } if (spline == null) { spline = new PlotCatmullRom(controlPoints, resolution); } cube.GetComponent <Renderer>().material = new Material(Shader.Find("Unlit/Color")); }
// Update is called once per frame void Update() { if (spline != null) { spline.Update(resolution); spline.Update(controlPoints); UpdateLinePoints(); spline.DrawSpline(Color.magenta); lineRenderer.positionCount = linePoints.Length; lineRenderer.SetPositions(linePoints); //if (drawNormal) // spline.DrawNormals(normalExtrusion, Color.red); //if (drawTangent) // spline.DrawTangents(tangentExtrusion, Color.cyan); } else { spline = new PlotCatmullRom(controlPoints, resolution); } if (progress < 1) { progress += Time.deltaTime * GetTimeScale(); } else { progress = .01f; } UpdatePosition(progress); }