scene.getMeshByName is not a function

Hello guys,
Here is my palyground https://www.babylonjs-playground.com/#LCKHB2#5
I want to define a blender mesh inside BJS so I callled the function scene.getMeshByName(), but it doesn’t work (I use it in local and it works fine but when I call it inside playground it tells me that it is not a function)
is there a solution

thank you

Anes

Hi.
ImportMesh callback parameters are list of imported meshes, particleSystems, and skeletons, and not ‘the scene’
https://doc.babylonjs.com/api/classes/babylon.sceneloader#importmesh
Console scene variable from callback and you’ll see it is an array. because of this clearColor is not working too.
https://www.babylonjs-playground.com/#LCKHB2#6
Cheers!

@MarianG thank you for your answer, so for that I’ll test BABYLON.SceneLoader.Append() but I don’t know if it can load my blender mesh from gitHub

https://www.babylonjs-playground.com/#LCKHB2#7

clearColor() works fine but stairMesh is not defined and there is no error in local I test it and it works but in playground no error and stairMesh not defined !, I confirm it in my coffrage_ventilateur. babylon and the mesh exists with “group_75” as a name !

Capture

thanks

But if you console the variable stairMesh in this playground you can see it exist
https://www.babylonjs-playground.com/#LCKHB2#7
where is it undefined?

I tried to display it in the console

Capture

Ok. Got it.
here is a playground, and I’ll try to explain what is happening here
https://www.babylonjs-playground.com/#LCKHB2#8
So if you console it inside of callback function then everithing good, but if you console it outside, you have to make sure that the scene was completely loaded before, you can use a setTimeout, executeWhenReady function or you can use async/await functions.Cheers!

2 Likes