I am writing a visualisation tool for viewing CNC machine cutting paths. I realise this is an incredibly basic use of BABYLON, but it is very useful as an interactive visualisation aid.
This approach worked very well when viewing an overall cutting path split into a limited number of groups with a Mesh for each group. However, I now want users to be able to interactively select a subsection of the cutting path. To do this, I am drawing a line between each point along the path where the machine head travels, creating a new mesh for each step with the Mesh.CreateLines method. I then use a jquery slider to define the visible range, toggling the mesh enabled status to hide it.
I am running into performance issues with more complex examples. The read-world scenarios which I am looking at have >200k steps, hence I need to add 200k meshes with this approach. With increased numbers of meshes, the creation of the scene appears to get exponentially slower; with 1.5k meshes the creation time is approximately .5 seconds, with 15k meshes it’s approximately 15 seconds and it gets worse from there.
I have put a simplified example of the code here: https://playground.babylonjs.com/#W3YSHN#2
I have tried a range of different performance improvement steps like setting blockfreeActiveMeshesAndRenderingGroups, blockMaterialDirtyMechanism and freezeActiveMeshes with no luck; enabling BABYLON.ScenePerformancePriority.Aggressive seems to lead to redrawing issues.
Can anyone suggest any which I could try to deal with this problem? I suspect if I could stop the markAsDirty being called until after my initialisation it would resolve this bottleneck.
I have some other ideas about how I could structure this problem but they end up a lot more complex to code, and I would like to avoid this if I can.