How to add shadows to imported child meshes?

The issue was solved by @mawa in Shadow for an whole building - Questions - Babylon.js (babylonjs.com)

These lines from that topic solved the issue I was having here:

let parent = scene.getMeshByName(“_ root _);

// shadows handling
var shadowGenerator = new BABYLON.ShadowGenerator(2048, light);

let mymesh = parent.getChildMeshes();
for (var i = 0; i < mymesh.length; i++) {
mymesh[i].receiveShadows = true;
shadowGenerator.addShadowCaster(mymesh[i]);
}

2 Likes