HelixToolkit.Wpf.LightVisual3D.OnLightChanged C# (CSharp) Method

OnLightChanged() protected method

Called when the light changed.
protected OnLightChanged ( ) : void
return void
        protected virtual void OnLightChanged()
        {
            this.Children.Clear();
            if (this.Light == null)
            {
                return;
            }

            var dl = this.Light as DirectionalLight;
            if (dl != null)
            {
                var arrow = new ArrowVisual3D();
                double distance = 10;
                double length = 5;
                arrow.BeginEdit();
                arrow.Point1 = new Point3D() + dl.Direction * distance;
                arrow.Point2 = arrow.Point1 - dl.Direction * length;
                arrow.Diameter = 0.1 * length;
                arrow.Fill = new SolidColorBrush(dl.Color);
                arrow.EndEdit();
                this.Children.Add(arrow);
            }

            var sl = this.Light as SpotLight;
            if (sl != null)
            {
                var sphere = new SphereVisual3D();
                sphere.BeginEdit();
                sphere.Center = sl.Position;
                sphere.Fill = new SolidColorBrush(sl.Color);
                sphere.EndEdit();
                this.Children.Add(sphere);

                var arrow = new ArrowVisual3D();
                arrow.BeginEdit();
                arrow.Point1 = sl.Position;
                arrow.Point2 = sl.Position + sl.Direction;
                arrow.Diameter = 0.1;
                arrow.EndEdit();
                this.Children.Add(arrow);
            }

            var pl = this.Light as PointLight;
            if (pl != null)
            {
                var sphere = new SphereVisual3D();
                sphere.BeginEdit();
                sphere.Center = pl.Position;
                sphere.Fill = new SolidColorBrush(pl.Color);
                sphere.EndEdit();
                this.Children.Add(sphere);
            }

            var al = this.Light as AmbientLight;
        }