How add vertices polygon?

    let points_2 = polygon.getVerticesData(BABYLON.VertexBuffer.PositionKind);
    const points_3 = new Float32Array([...points_2, 22])
    polygon.updateVerticesData(BABYLON.VertexBuffer.PositionKind, points_3);

I am trying to add a vertex, but their number does not change

So far, the only solution I have come to is to destroy the old object and draw it again, but with new vertices.

Hello and welcome to the Babylon community :slight_smile:

I think you can’t change the number of vertices with updateVerticesData, let me confirm with @sebavan

Yup, update is using bufferSubData.

In the dynamic case I usually do reserve a bigger buffer than my data and grow by chunck a bit like Vectors are managing memory.

Initially, it is not known how many vertices there will be. Is there another option with adding vertices?

Could you describe the use case with more detail so we ll find the best approach ?

For example, you draw a line from a polygon and end it in another place of that polygon. The vertices of this line should become a continuation of the polygon.

At the moment I am deleting the entire polygon, adding new vertices to the past and inserting them, removing the extra ones that remain inside the polygon. And then I draw it again.

Yup one of the most efficient is something like this: Fancy Drawing in WebGL with Babylon.js | by Babylon.js | Medium (look at the draw time chapter)

You basically only change the full memory once in a while.

Never saw this demo before, I love it :rofl: can’t resist unicorn poop!