Search code examples
c#wpfhelix-3d-toolkit

Displaying multiple Point 3D s in Helix Tool Kit


I need to display multiple 3d points in a Helix View Port.

private void DisplayPointCloud(double[] datapoints)
    {

                newTime = stopwatch.Elapsed;
                foreach (double Datapoint in datapoints)
                {

                    Point3D temp = new Point3D(Random(), Random(), Datapoint);

            Dispatcher.Invoke(() =>
                    {
                        DataList.Add(temp);
                    });
                        
                }
       
        oldTime = newTime;
    }

I am displaying data in Helix Viewport in a separate thread. I need to show multiple datapoints in the UI without showing one by one which I'm doing right now. Main reason I need to do so is minimize the lag in UI Thread.


Solution

  • HelixToolkit have a good samples on github.

    Regarind points.. you can use PointsVisual3D in your view and bind your source collection of Point3D to property Points.

    <h:HelixViewport3D x:Name="ViewPort3D" InfiniteSpin="True" ShowFrameRate="True">
                <h:DefaultLights />
                <h:PointsVisual3D Points="{Binding Points3DCollection}" Color="Red" Size="6" />
            </h:HelixViewport3D>
    

    Even if you will decide to populate Points3DCollection from different non UI thread - it will not solve issue with UI Thread. The root cause - Helix alway will repaint this collection after change camera position. Repaint performs in UI thread.

    For increase responsive for rest of controls on your form - you can try create new thread for you HelixViewPort3D (see Dwayne Need article), but it will not significant increase speed of repaint your 3D scene.