3D object cloned mesh shadow

Hello, i try to clone 3D imported object and add shadow to it. I don’t know how to do it properly.

Can you help me ?

Thank you

https://playground.babylonjs.com/#X36JRA

or with the 3D object inside (github)

https://github.com/Thomaseustache/jeux_voiture

Hey @thomas_e

Here’s some great documentation that talks through the basics of how to do shadows in Babylon.

https://doc.babylonjs.com/babylon101/shadows

Most simple answer is that after your assets are loaded into the scene, you need to do the following actions:

  1. add a shadow generator and attach it to the a light
    var shadowGenerator = new BABYLON.ShadowGenerator(1024, light);
  2. then you specify which objects in the scene should cast shadows from that light source:
    shadowGenerator.getShadowMap().renderList.push(torus);
  3. and finally you need to specify which objects in the scene should receive shadows (shadows cast onto these objects)
    ground.receiveShadows = true;

Hope this helps a bit!

Cheers!

I already done this thank you. But when i clone a mesh with .clone();
I can’t add shadow to the cloned mesh…

Hmm check this out.

https://playground.babylonjs.com/#MSAHKR

In this playground, I created the sphere on the left with meshbuilder, and then I the I cloned it to create the sphere on the right.

After adding both of the spheres to the shadow list, they both generate shadows.