Disable mesh outside the created function

How do I disable the mesh outside the function of ImportMesh?
I am trying to access the function newMeshes but unfortunately its declared as private. How do I call and disable this mesh?

https://playground.babylonjs.com/#5F388W#2

Hi.

Well two things are happening. First. In your playground, the mesh is called “test” not “s” (s is the SceneLoader object you’ve created, it’s not the name of the mesh, so you cannot access that via getMeshByName).

So using scene.getMeshByName(‘test’) is the way to go.

Second thing, at the moment when you call the log method the mesh is not yet loaded. So you need to wait for the model to get loaded before you can access it outside the function.

https://playground.babylonjs.com/#5F388W#4

2 Likes

Oh sorry. I removed the part you had during some tests.

https://playground.babylonjs.com/#5F388W#7

You can leave what you had before, as the callback function is called after everything is ready. So inside the importMesh callback you can do whatever you want.

Alternatively, you can do what you did in the latest playground, it’s just not scene.getMeshByName(“skull”). As mentioned already, the mesh is called “test”, and the only way you can access it is via getMeshByName('test").

Also you DON’T NEED “.newMeshes[0]” at the end of “getMeshByName(“test”)”.

https://playground.babylonjs.com/#5F388W#9

1 Like

Yes thank you I figured it out by myself :smiley: I deleted the point. Thanks again for all your help :smiley:

1 Like