Thank you for providing the sample project that reproduced the issue. This significantly helped me understand the problem and find the cause of the problem.
In the last version of the libraries the initialization of the 3D lines was significantly improved. Before it may happen that the MeshGeometry3D for a 3D was initially generated on the CPU by the LinesUpdater even if the lines were shown by the DXEngine and the geometry was generated in the GPU's geometry shader (this slowed down the initialization and created unused 3D objects). This may happen when 3D lines from Visual3D are initialized before the DXEngine is fully initialized. What is more, new line objects may be created on each line property change.
Those two issue were solved by waiting until the 3D line was actually visible (added to a visible Visual3D parent) and until DXEngine is initialized (when present). After that either MeshGeometry3D for the line is generated (in case there is no DXEngine) or the line's data is passed to the DXEngine to generate the line in the geometry shader.
This worked well in all of my tests.
But I have not anticipated generating a LineVisual3D and passing it to the WpfModelVisual3DNode constructor. In this case the LineVisual3D is never actually visible and therefore the DXEngine does not get the line's data.
When working with DXEngine objects (such as WpfModelVisual3DNode) it was expected that a ScreenSpaceLineNode would be created instead of WpfModelVisual3DNode and LineVisual3D. This is much more optimal because you do not create slow WPF objects (LineVisual3D) but directly create the ScreenSpaceLineNode (which is also generated behind the scenes when passing a LineVisual3D to WpfModelVisual3DNode).
Creating ScreenSpaceLineNode objects is demonstrated in the DXEngineAdvanced/ScreenSpaceLineNodeSample sample in the Ab3d.DXEngine samples projects.
It is recommended that you update your code to create the ScreenSpaceLineNode. Here is the updated code from your sample project (the old code is commented):
Code:
//var line = new Ab3d.Visuals.LineVisual3D()
//{
// StartPosition = new Point3D(2000, 100, -300),
// EndPosition = new Point3D(1000, 500, -200),
// LineThickness = 4,
// LineColor = System.Windows.Media.Colors.Orange
//};
//var lineNode = new Ab3d.DirectX.Models.WpfModelVisual3DNode(line);
//rootNode.AddChild(lineNode);
//_Disposables.Add(lineNode);
var linePositions1 = new Vector3[]
{
new Vector3(2000, 100, -300),
new Vector3(1000, 500, -200),
};
var lineMaterial1 = new LineMaterial(System.Windows.Media.Colors.Orange.ToColor4(), lineThickness: 4);
var screenSpaceLineNode1 = new ScreenSpaceLineNode(linePositions1, isLineStrip: false, isLineClosed: false, lineMaterial1);
rootNode.AddChild(screenSpaceLineNode1);
_Disposables.Add(screenSpaceLineNode1);
_Disposables.Add(lineMaterial1);
//var pts = new Point3DCollection();
//double x = 2200, y = 100, z = -150;
//for (int i = 0; i < 3; ++i)
//{
// Point3D p2 = new Point3D(x, y, z);
// x += (i + 1) * 100;
// y += (i + 1) * 200;
// z -= 20;
// pts.Add(p2);
//}
//var pline = new Ab3d.Visuals.PolyLineVisual3D()
//{
// Positions = pts,
// LineColor = System.Windows.Media.Colors.Purple
//};
//var node = new Ab3d.DirectX.Models.WpfModelVisual3DNode(pline);
//rootNode.AddChild(node);
//_Disposables.Add(node);
var linePositions2 = new Vector3[3];
float x = 2200, y = 100, z = -150;
for (int i = 0; i < 3; ++i)
{
Vector3 p2 = new Vector3(x, y, z);
x += (i + 1) * 100;
y += (i + 1) * 200;
z -= 20;
linePositions2[i] = p2;
}
var lineMaterial2 = new LineMaterial(System.Windows.Media.Colors.Purple.ToColor4(), lineThickness: 1)
{
IsPolyLine = true
};
var screenSpaceLineNode2 = new ScreenSpaceLineNode(linePositions2, isLineStrip: true, isLineClosed: false, lineMaterial2);
rootNode.AddChild(screenSpaceLineNode2);
_Disposables.Add(screenSpaceLineNode2);
_Disposables.Add(lineMaterial2);
However, I admit that creating a WpfModelVisual3DNode from a LineVisual3D is a perfectly valid scenario. Therefore I have updated the code in DXEngine to correctly handle that use case.
Because this issue has a workaround that works better than the original code, I do not plan to release an official hotfix for that. So this fix will be published with the next version (or with a hotfix if there is a bigger issue found).
Anyway, if you want to get a fixed version, I can send you updated NuGet packages, but you will need to use a local NuGet source to use them.