Disabling a 3D model mesh from an external function

I am facing difficultly in disabling a 3D model mesh completely from an external function in the same script. How do I refer the var mesh in my external function? For example, in the below example how do I give global reference to vpMesh?

var model;
class Playground
        {
            static CreateScene(engine, canvas)
            {
             ....
             ....
             model = BABYLON.SceneLoader.ImportMesh(null, "Models/", "scene.gltf", scene, function (vpMesh)
            {
                console.log("ModelLoaded");
                vpMesh.forEach((m) =>
                {
                    m.renderingGroupId = 2;

                });
            });
            }
       }

<script>
function DisableModel()
        {
         //Disable Mesh here
        }
</script>

All the meshes are accessible from scene.meshes. You can query a particular one with scene.getMeshByName() or scene.getMeshById().

1 Like