Dashed Line not correctly updated


When I use CreateDashedLines function of the LineBuilder, the line is not correctly updated according to dashNb paramater.

I think the reason is this part of the function :

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,

1 Like

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.

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

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



Thank you for your attention :slight_smile:

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

Hey there! I actually found out on the documentation ( BABYLON | Babylon.js Documentation (babylonjs.com)) 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)

1 Like