Rendering shadows for multiple gltf models

Hi, I am developing a scene where I am using glb models. I need my models to render shadows upon subjecting to light.
I achieved shadows for model. But, the problem I am facing is shadows are not being rendered when I am using the same code for two or more models.

This is what I have achieved so far…

I am using

  1. const shadowGenerator = new BABYLON.ShadowGenerator(1024, light);
  2. ground.receiveShadows= true;
  3. shadowGenerator.addShadowCaster(meshes[0], true);
    3rd line I used to which model I want the shadows to be displayed.

I am using the same method for other models in my scene. But, only one of them is working fine. Means, if I write the same code for two models, only one model’s shadow is being displayed.

Note: I am using directionalLight.

Any help is appreciated. Thanks in advance :slightly_smiling_face:

Hello! Can you provide us with a playground with your models and setup?

1 Like