Checking collisions with GLTF meshes

Hello,

I’m rather new to babylon and I’m sure I’ll be asking around a lot here…

My problem is this:
I import a gltf file with this function:
BABYLON.SceneLoader.Load("./BuildingSet/blender/", “building7.gltf”, engine, function (newScene) {

Now I want to iterate through all the objects in this file and set their checkCollisions properties.

How should I go about this?

Hi @Mengu_Gulmen and welcome to the forum

in the

BABYLON.SceneLoader.Load("./BuildingSet/blender/", “building7.gltf”, engine, function (newScene) {

you can iterate on every mesh that’s part of new scene like this:

var meshes = newScene.meshes; 		 
meshes.forEach(function(item) {
    item.isPickable = true;   
    ...
}
2 Likes

If you want to be slightly more precise in the exact meshes that were loaded, use ImportMesh with null or “” as the first parameter instead of Load which will return the list of meshes that were created.

1 Like