Mesh edge rendering doesnt update

Hello,
Iam trying to draw 3D lines … didnt want to use tubes as I would need thousands and using tubes would end up with huge amounts of unnecessary polygons.

I also need some thickness in 3D so the default line system doesnt suit my needs at all because it renders a line with constant thickness without considering its distance from camera.

So before writing whole new 3D line system myself, I tried that hack with .enableEdgesRendering()
It works exactly as I need except I cannot use textures, but luckyly I dont need them at that point … aaaaand the more important problem is that I need to invoke that .enableEdgesRendering() function every frame to make it work what has terrible performance impact.

I am new to babylon, so Id like to ask if I do something wrong or found a bug or it just doesnt work that way, why and how can I fix it ?

Here is PG which I hope clearly demonstrate the problem:
https://playground.babylonjs.com/#Y7CS4N#6

Thanks in advance for any help.

Actually, it is kind of by design and kind of a bug :slight_smile: as the code you call is valid but generating the edges is pretty slow and should not be done every frame. This is why it does not update automatically once created.

the edges here would act as planes so I wonder if using planes would work for your case. The amazing trick would be to use instances of planes or cylinder Thin Instances | Babylon.js Documentation

Hi @sebavan, thank you for reply!

So the overhead of .enableEdgesRendering() really comes from the calculations needed ? The stuttering I had with over 500 edges was kind of inconsistent … like stable 60fps for 2 seconds, then drop to around 25 for 0.5 second and so on … while there was set number of the edges, thus for every frame the same amount of calculations needed it seemed pretty weird to me, I would expect consistend framerate drop … also for 500 edges, 1000 polygons and some basic vector math should be enough, what doesnt seem so heavy in my eyes :thinking:

About that instancing I am not sure if I get you right … I would need few thousands of dynamic 3D lines, changing their rotations, lengths, transparency etc. every frame. From what I know instancing works only with identical mesh, but in my case, every line will actually be different. But if instances could be scaled non-uniformly ( and it seems they can, from a quick check of some examples ? ) then it could pretty much do the trick ! :heart_eyes:

The drop cost is also due to how it is currently not handled :slight_smile:

But yup instancing would do cause rotation/scaling/position is totally independant by instance, only the main shape (a quad or cylinder) needs to be unique as well as its material.

Thank you very much for great tip then! Sounds very promising for this particular case, Ill definitelly give it a try! :ok_hand: