Updatable Merged Meshes

Hey there,
im stuck at updating the VertexData of a Merged Mesh. The following example is not updating the normals at all…

var bufferCube = BABYLON.Mesh.MergeMeshes(meshArray, true, true, undefined, false, true); </br> bufferCube.updateVerticesData(BABYLON.VertexBuffer.NormalKind, normals);

In a custom mesh there is a boolean called “updatable”:
vertexData.applyToMesh(mesh, **true**)

Is there some sort of similar approach for Merged Meshes?

I think you will find this method interesting:

markVerticesDataAsUpdatable(kind: string, updatable = true).

Just call it with the kind of vertex data you want to be updatable. For normals:

mergedMesh.markVerticesDataAsUpdatable(BABYLON.VertexBuffer.NormalKind, true).

1 Like

Thanks a lot, i was missing that one!

As an alternative you can use setVertices to make a kind updatable

https://www.babylonjs-playground.com/#6F1XTM

1 Like

That’s what markVerticesDataAsUpdatable() is doing:

    public markVerticesDataAsUpdatable(kind: string, updatable = true) {
        let vb = this.getVertexBuffer(kind);

        if (!vb || vb.isUpdatable() === updatable) {
            return;
        }

        this.setVerticesData(kind, (<FloatArray>this.getVerticesData(kind)), updatable);
2 Likes