Changing material of imported GLTF mesh results in backface rendered mesh

When trying to change the material of an imported GLTF mesh, the rendered faces of the mesh are flipped even though the vertex normals show the correct direction. When I don’t apply any material, the faces are rendered in the correct way.

The code to change the material after import is like this:

    import "@babylonjs/loaders/glTF/glTFFileLoader";
    SceneLoader.Append("models/", "models.gltf", scene, function (scene) {
        var mesh = scene.getMeshByName("Circle");
        var newMaterial = new StandardMaterial("testing", scene);
        newMaterial.backFaceCulling = true;
        mesh.material = newMaterial;
    });

Here a screenshot of the effect im having, with the debug option “Render vertex normals” enabeld.

Any idea what might be the cause? I’m using Typescript + Webpack for development.

Resolved this issue with newMaterial.sideOrientation = Orientation.CW;.

2 Likes

Hello and welcome @Sem

And thanks for the self fix :wink: