VertexColor broken, why?

Hi there, i have a problem figuring out what the issue might be:

i have a mesh here wich is generated like this:

          // Create a new mesh for the area.
          const siteMesh = MeshBuilder.CreatePolygon(
            `temp_siteMesh${siteData.id}`,
            {
              shape: boundary.map((position) => {
                console.log(position)
                return new Vector3(position[0], position[1], position[2])
              }), // y-Value is ignored anyways
              holes: holes.map((hole) =>
                hole.map((position) => new Vector3(position[0], position[1], position[2]))
              ),
              wrap: true,
            },
            scene,
            earcut
          )

          console.log('SITES MESH total vertices', siteMesh.getTotalVertices())
          // siteMesh.setVerticesBuffer(colorBuffer)
          siteMesh.increaseVertices(20)

coloring is done entirely by vertexcolor, not a material.

the result is for example this:

now sometimes when i change the vertices (for example by adding a handle to the outline) the vertexcolors seem to be broken.

so my question to the more experienced: how does that error look like? are the vertexcolors broken? or is the mesh broken? where would i start to look for the problem?

i did expect the increaseVertices to make the problems, but also without it it sometimes shows this problem.

Any idea where to start looking for the issue?

Thanks a lot!

PG PG PG! :smiley: Come on! drop in a PG!

1 Like

:wink: i thought this would be the first reply - but i cannot upload this to PG.
i am more expecting some kind of hint how that problem looks like. Any chance?
PS.: can i get earcut in the PG?

Because of the “sometimes” the chances are near to zer. “Sometimes” tells us that the potential source of the issue is somewhere in your code we have no access to.

Anyway, it’s working. Creating a mesh, increasing vertices, setting vertex colors :wink:

You don’t need to inject earcut into the PG. It’s already there/everywhere :smiley: :smiley:

https://doc.babylonjs.com/features/introductionToFeatures/chap3/polycar

Hi, just copying the boundary data and generating the mesh https://playground.babylonjs.com/#ZRZIIZ#114
looks exactly as expected.
but again. does that problem look like wrong uv data? wrong normals? vertexdata?

Cheers

Ok, i (think) i have found the problem: i did merge the mesh after creating with another mesh - and updated the new mesh with the old vertexdata… stupid.

Thanks anyways for your help!!!

3 Likes