void UpdateDisplay()
    {
        bool displayActive = false;

        Vector3 newDirection = new Vector3();

        float sign = 1f;

        if (pheromoneType == EPheromoneTypes.Repellant)
        {
            sign = -1f;
        }

        // Aggregate pheromones to calculate direction
        foreach (Pheromone pheromone in _nearbyPheromones)
        {
            if (!pheromone)
            {
                continue;
            }

            if (pheromone.type != pheromoneType)
            {
                continue;
            }

            displayActive = true;
            newDirection += (pheromone.transform.position - transform.position) * pheromone.currentConcentration;
        }

        // Deactivate display, if no pheromones of type pheromoneType are nearby.
        if (!displayActive)
        {
            _display.SetActive(false);
            return;
        }
        _display.SetActive(true);

        // Fix newDirection vector
        newDirection.y  = 0f;
        newDirection.z *= -1;

        newDirection *= sign;

        // Set new rotation of display
        float rotation = MathHelper.AngleSigned(newDirection, new Vector3(1f, 0f, 0f), new Vector3(0f, 1f, 0f)) * Mathf.Rad2Deg;

        _display.transform.rotation = Quaternion.Euler(90f, rotation + 90f, 0f);
    }
        public void CalculateStartBinormal(bool hasToBeconnected)
        {
            var previousSegment = GetPreviousSegment(true);

            if (previousSegment != null)
            {
                var nextSegment = GetNextSegment(true);

                _biNormalField.SetValue(TrackSegment,
                                        TrackSegment.transform.InverseTransformDirection(Vector3.Cross(
                                                                                             previousSegment.TrackSegment.getNormal(1f), previousSegment.TrackSegment.getTangentPoint(1f))));

                if (nextSegment != null)
                {
                    //try to match the curve
                    for (var x = 0; x < 10; x++)
                    {
                        TrackSegment.deltaRotation -= MathHelper.AngleSigned(
                            Quaternion.AngleAxis(0, nextSegment.TrackSegment.getTangentPoint(0.0f)) *
                            nextSegment.TrackSegment.getNormalPoint(0.0f),
                            Quaternion.AngleAxis(TrackSegment.deltaRotation, TrackSegment.getTangentPoint(1.0f)) *
                            TrackSegment.getNormalPoint(1.0f), TrackSegment.getTangentPoint(1.0f));
                        TrackSegment.totalRotation =
                            previousSegment.TrackSegment.totalRotation +
                            TrackSegment.deltaRotation; // + TrackSegment.getAdditionalRotation ();
                        TrackSegment.calculateLengthAndNormals(previousSegment.TrackSegment);
                        if (previousSegment.TrackSegment.isConnectedTo(nextSegment.TrackSegment))
                        {
                            break;
                        }
                    }
                }
                else
                {
                    TrackSegment.totalRotation =
                        previousSegment.TrackSegment.totalRotation +
                        TrackSegment.deltaRotation; // + TrackSegment.getAdditionalRotation ();
                    TrackSegment.calculateLengthAndNormals(previousSegment.TrackSegment);
                }
            }
        }