# Line in XoZ Plane utility function rendering twisted lines

**URL:** <https://forum.babylonjs.com/t/line-in-xoz-plane-utility-function-rendering-twisted-lines/56056>\
**Category:** Questions\
**Created:** [January 20, 2025, 12:13am UTC](https://forum.babylonjs.com/t/line-in-xoz-plane-utility-function-rendering-twisted-lines/56056 "2025-01-20T00:13:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lfcourtney](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lfcourtney/32/44255_2.png) [@lfcourtney](https://forum.babylonjs.com/u/lfcourtney)\
**Post date:** [January 20, 2025, 12:13am UTC](https://forum.babylonjs.com/t/line-in-xoz-plane-utility-function-rendering-twisted-lines/56056/1 "2025-01-20T00:13:21Z")

</div>

I have been following the Babylon.js official documentation page on [drawing lines of a set width](https://doc.babylonjs.com/toolsAndResources/utilities/Line2D#line-in-xoz-plane-formed-from-central-path), using the Line2D utility functions provided. In particular, I have been using the Line2D function to draw a Line in XoZ Plane.

For the most part, such function has satisfied my user requirements. One problem persists however, and it is to do with using the function to draw lines that increase on the Y axis, specifically lines that may, for instance, by travelling up a slope.

Here are a few screenshots of what I am talking about, capturing the problematic line at different angles.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/8/d8e70b90ff3827bbe34fd4465e7888f8ed95a3a2.png)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/9/a993ef4b55886b0d2f10fc1b0b4ac03e23deaf0a.png)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/e/8/e86efdf4ae60241f50db03621f235a9716c48eb8.png)

As can be seen, the line renders just fine with the desired texture. Yet there is this odd twisting of the line that occurs when the line increases on the Y axis.

Playground link: [https://playground.babylonjs.com/#FJO3RO](https://playground.babylonjs.com/#FJO3RO)

Any further information on this would be greatly appreciated. Even better an alternative approach I can use to render the exact line that I want, which is a straightened version of the same line without any twists.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [January 20, 2025, 9:11am UTC](https://forum.babylonjs.com/t/line-in-xoz-plane-utility-function-rendering-twisted-lines/56056/2 "2025-01-20T09:11:00Z")

</div>

This tutorial is an external contribution, but I don’t know who contributed it in the first place… cc @RaananW in case he would remember, as this page already existed when it was first committed in 2020.

---

<div class="post-metadata">

**Author:** ![lfcourtney](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lfcourtney/32/44255_2.png) [@lfcourtney](https://forum.babylonjs.com/u/lfcourtney)\
**Post date:** [January 20, 2025, 1:29pm UTC](https://forum.babylonjs.com/t/line-in-xoz-plane-utility-function-rendering-twisted-lines/56056/3 "2025-01-20T13:29:45Z")

</div>

Thanks for your reply.

That is unfortunate. I understand why the Line2D functions are needed: because the OpenGL specifications are limited when it comes to creating lines of fixed widths. Yet the issue is so minor that I would try fixing it myself if I had any clue how the Line2D function actually worked (the particular one I am using being ‘Line in XoZ Plane Formed from Central Path’).

Alas, I am at a loss with trying to understand it. There are not even any comments explaining it from the code given in the official documentation.

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [January 20, 2025, 1:37pm UTC](https://forum.babylonjs.com/t/line-in-xoz-plane-utility-function-rendering-twisted-lines/56056/4 "2025-01-20T13:37:41Z")

</div>

If I remember correctly, this guide was written by @JohnK , which is sadly no longer with us.

The twist happens because of the way the edge lines are computed. You can avoid it like this, if it helps:

> **[Babylon.js Playground](https://playground.babylonjs.com/#FJO3RO%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [January 20, 2025, 1:38pm UTC](https://forum.babylonjs.com/t/line-in-xoz-plane-utility-function-rendering-twisted-lines/56056/5 "2025-01-20T13:38:19Z")

</div>

Sorry, this - [https://playground.babylonjs.com/#FJO3RO#2](https://playground.babylonjs.com/#FJO3RO#2) 🙂

---

<div class="post-metadata">

**Author:** ![lfcourtney](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/lfcourtney/32/44255_2.png) [@lfcourtney](https://forum.babylonjs.com/u/lfcourtney)\
**Post date:** [January 20, 2025, 2:33pm UTC](https://forum.babylonjs.com/t/line-in-xoz-plane-utility-function-rendering-twisted-lines/56056/6 "2025-01-20T14:33:33Z")

</div>

Thank you! I didn’t expect the solution to be so straightforward. This was really helpful 😃.
