# Best way to render many lines?

**URL:** <https://forum.babylonjs.com/t/best-way-to-render-many-lines/7919>\
**Category:** Questions\
**Created:** [January 8, 2020, 3:21pm UTC](https://forum.babylonjs.com/t/best-way-to-render-many-lines/7919 "2020-01-08T15:21:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joseph\_DeStefano](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/joseph_destefano/32/2091_2.png) [@Joseph\_DeStefano](https://forum.babylonjs.com/u/Joseph_DeStefano)\
**Post date:** [January 8, 2020, 3:21pm UTC](https://forum.babylonjs.com/t/best-way-to-render-many-lines/7919/1 "2020-01-08T15:21:12Z")

</div>

I’m rendering many lines using LinesBuilder, but after 300-400, I start to notice FPS hits.

What is the recommended way to draw hundreds (if not thousands) of straight lines (single segment) in a scene with minimal performance loss?

The only requirement is that each line needs to be individually removable.

---

<div class="post-metadata">

**Author:** ![jerome](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jerome/32/22_2.png) [@jerome](https://forum.babylonjs.com/u/jerome)\
**Post date:** [January 8, 2020, 3:23pm UTC](https://forum.babylonjs.com/t/best-way-to-render-many-lines/7919/2 "2020-01-08T15:23:44Z")

</div>

Maybe the LineSystem ? [Create Parametric Shapes - Babylon.js Documentation](https://doc.babylonjs.com/how_to/parametric_shapes#line-system)

---

<div class="post-metadata">

**Author:** ![Joseph\_DeStefano](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/joseph_destefano/32/2091_2.png) [@Joseph\_DeStefano](https://forum.babylonjs.com/u/Joseph_DeStefano)\
**Post date:** [January 8, 2020, 3:36pm UTC](https://forum.babylonjs.com/t/best-way-to-render-many-lines/7919/3 "2020-01-08T15:36:23Z")

</div>

It doesn’t appear that I can access each individual line post-creation with a `lineSystem`. The `getVerticesData()` suggests that it’s a single mesh with just a bunch of edges/lines drawn into it.

---

<div class="post-metadata">

**Author:** ![jerome](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jerome/32/22_2.png) [@jerome](https://forum.babylonjs.com/u/jerome)\
**Post date:** [January 8, 2020, 3:44pm UTC](https://forum.babylonjs.com/t/best-way-to-render-many-lines/7919/4 "2020-01-08T15:44:57Z")

</div>

Of course, you can access each line or segment (each being an array of Vector3) after creation, move them, change them, or color them if you create the system as _updatable_. Just modify the lines in the passed _lines_ array and recall the same function by passing back the already created lineSystem object with the parameter _instance_.

You can’t remove lines once created though. But if you need to remove just some of them, then reduce them to a single point in an invisible location or color, this won’t change the perfs. The LineSystem can handle dozen thousands lines (or more) in one draw call.

---

<div class="post-metadata">

**Author:** ![Joseph\_DeStefano](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/joseph_destefano/32/2091_2.png) [@Joseph\_DeStefano](https://forum.babylonjs.com/u/Joseph_DeStefano)\
**Post date:** [January 8, 2020, 4:22pm UTC](https://forum.babylonjs.com/t/best-way-to-render-many-lines/7919/5 "2020-01-08T16:22:34Z")

</div>

I see how that works now. Hmm. I’ll have to see what the the performance is like of re-initializing a new linesystem upon add/remove. Playing size tricks to “remove” lines might introduce more complexity than the performance gain is worth. This is a debug-mode tool, so taking an FPS hit is not the worst thing in the world.

Thanks
