# Dashed Line not correctly updated

**URL:** <https://forum.babylonjs.com/t/dashed-line-not-correctly-updated/29250>\
**Category:** Bugs\
**Tags:** mesh\
**Created:** [April 11, 2022, 12:01pm UTC](https://forum.babylonjs.com/t/dashed-line-not-correctly-updated/29250 "2022-04-11T12:01:05Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leo\_Rousseau](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/leo_rousseau/32/22652_2.png) [@Leo\_Rousseau](https://forum.babylonjs.com/u/Leo_Rousseau)\
**Post date:** [April 11, 2022, 12:01pm UTC](https://forum.babylonjs.com/t/dashed-line-not-correctly-updated/29250/1 "2022-04-11T12:01:05Z")

</div>

Hi,

When I use `CreateDashedLines` function of the [LineBuilder](https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Meshes/Builders/linesBuilder.ts), the line is not correctly updated according to dashNb paramater.

I think the reason is this part of the function :

```auto
const curvect = Vector3.Zero();
            const nbSeg = positions.length / 6;
            let lg = 0;
            let nb = 0;
            let shft = 0;
            let dashshft = 0;
            let curshft = 0;
            let p = 0;
            let i = 0;
            let j = 0;
            for (i = 0; i < points.length - 1; i++) {
                points[i + 1].subtractToRef(points[i], curvect);
                lg += curvect.length();
            }
            shft = lg / nbSeg;

```

The last line should be `shft = lg / dashNb;`

Thank you,

---

<div class="post-metadata">

**Author:** ![DarraghBurke](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/darraghburke/32/10621_2.png) [@DarraghBurke](https://forum.babylonjs.com/u/DarraghBurke)\
**Post date:** [April 11, 2022, 7:27pm UTC](https://forum.babylonjs.com/t/dashed-line-not-correctly-updated/29250/2 "2022-04-11T19:27:46Z")

</div>

Thanks so much for the report! Since you already know the fix, would you be willing to open a PR for it? It would also be great to include a playground repro that shows the broken behavior, which we can test a fix against.

---

<div class="post-metadata">

**Author:** ![Leo\_Rousseau](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/leo_rousseau/32/22652_2.png) [@Leo\_Rousseau](https://forum.babylonjs.com/u/Leo_Rousseau)\
**Post date:** [April 12, 2022, 7:09am UTC](https://forum.babylonjs.com/t/dashed-line-not-correctly-updated/29250/3 "2022-04-12T07:09:07Z")

</div>

Unfortunately, this doesn’t work in some cases, so I’m still investigating.

Sometimes, the number of dashes stays stuck and I don’t know why.

Here is a [playground](https://playground.babylonjs.com/#XKYAE#18)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 9, 2022, 7:14pm UTC](https://forum.babylonjs.com/t/dashed-line-not-correctly-updated/29250/4 "2022-05-09T19:14:42Z")

</div>

Apologies for the delay in responding, I’ll try taking a look at this now 🙂

---

<div class="post-metadata">

**Author:** ![Leo\_Rousseau](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/leo_rousseau/32/22652_2.png) [@Leo\_Rousseau](https://forum.babylonjs.com/u/Leo_Rousseau)\
**Post date:** [May 10, 2022, 7:02am UTC](https://forum.babylonjs.com/t/dashed-line-not-correctly-updated/29250/5 "2022-05-10T07:02:58Z")

</div>

Hey,

Thank you for your attention 🙂

I think the best way to solve this is to create dotted line shader to apply to LineMaterial (only in BJS 5.0). I didn’t have the time to set it up and I’m still working on 4.2 version

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 10, 2022, 4:59pm UTC](https://forum.babylonjs.com/t/dashed-line-not-correctly-updated/29250/6 "2022-05-10T16:59:20Z")

</div>

Assigned @carolhmj on May 10, 2022, 4:59pm UTC



---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 10, 2022, 8:14pm UTC](https://forum.babylonjs.com/t/dashed-line-not-correctly-updated/29250/7 "2022-05-10T20:14:11Z")

</div>

Hey there! I actually found out on the documentation ( [BABYLON | Babylon.js Documentation (babylonjs.com)](https://doc.babylonjs.com/typedoc#createdashedlines-2)) that the only parameter supported when updating an existing mesh is the `points` one, the others aren’t supported so that the existing buffer can be reutilized and performance is good. I added code so that we show a warning when another parameter is used, to make the behavior clearer: [Add a warning when using ignored options with Dashed Lines update. by carolhmj · Pull Request #12509 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/12509)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 18, 2022, 12:31pm UTC](https://forum.babylonjs.com/t/dashed-line-not-correctly-updated/29250/8 "2022-05-18T12:31:13Z")

</div>

Unassigned @carolhmj on May 18, 2022, 12:31pm UTC


