Update an updatable lines object with more points

Hi,

I am attempting to update a lines object returned by MeshBuilder.CreateLines with both updatable and instance set. This works fine if the number of points stays the same. If I attempt to insert more points though, everything falls apart. The new points are not taken into account at all.

It’s easy to reproduce: https://www.babylonjs-playground.com/#165IV6#2361
I inserted a second loop from line 42 to line 46 and it has absolutely no effect. It’s like the object stops processing points once it has reached the quantity it’s “accustomed to”.

I have to dispose the old mesh and create a new one ATM, which is pretty slow compared to the update (although bearable for my use case). Is this a bug or just a “working-as-designed” limitation? edit: and if so, why not just check the length of the array and regenerate the mesh only if it differs?

Thanks in advance!

Hey!

it is a constraint of the update mode (to be fast, you must provide the same vertex size. Automatically switching to a regeneration could hide a problem for you. You could get slow rendering without understanding why.

More info: Parametric Shapes - Babylon.js Documentation

1 Like

Thanks for the info. I figured as much, so I implemented the logic myself. Maybe we could add that to the docs… I haven’t seen an explanation for that phenomenon on the Paramteric Shapes page, only here (Update Vertices - Babylon.js Documentation), but even there it’s not clear how it interacts with instances.

1 Like