# Shadow not working

**URL:** <https://discourse.threejs.org/t/shadow-not-working/44769>\
**Category:** Questions\
**Tags:** shadows\
**Created:** [November 16, 2022, 10:05am UTC](https://discourse.threejs.org/t/shadow-not-working/44769 "2022-11-16T10:05:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![binoy\_t](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/binoy_t/32/24330_2.png) [@binoy\_t](https://discourse.threejs.org/u/binoy_t)\
**Post date:** [November 16, 2022, 10:05am UTC](https://discourse.threejs.org/t/shadow-not-working/44769/1 "2022-11-16T10:05:08Z")

</div>

I am trying to add shadows to gltf model, I’ve tried some solutions that I saw in the forum.

```javascript
renderer.shadowMap = true
scene.traverse( function( child ) { 
    if ( child.isMesh ) {
        child.castShadow = true;
        child.receiveShadow = true;
    }
} );

```

But it doesn’t seem to work. Is there anything else that i should’ve done?

Thanks,  
Binoy

---

<div class="post-metadata">

**Author:** ![seanwasere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/seanwasere/32/75911_2.png) [@seanwasere](https://discourse.threejs.org/u/seanwasere)\
**Post date:** [November 16, 2022, 10:12am UTC](https://discourse.threejs.org/t/shadow-not-working/44769/2 "2022-11-16T10:12:15Z")

</div>

what kind of lights do you have in your scene?  
and what kind of materials is your model using?  
you need to show more code.

---

<div class="post-metadata">

**Author:** ![binoy\_t](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/binoy_t/32/24330_2.png) [@binoy\_t](https://discourse.threejs.org/u/binoy_t)\
**Post date:** [November 16, 2022, 10:13am UTC](https://discourse.threejs.org/t/shadow-not-working/44769/3 "2022-11-16T10:13:31Z")

</div>

I use `THREE.DirectionalLights`, materials are `THREE.MeshStandardMaterial`

---

<div class="post-metadata">

**Author:** ![seanwasere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/seanwasere/32/75911_2.png) [@seanwasere](https://discourse.threejs.org/u/seanwasere)\
**Post date:** [November 16, 2022, 10:14am UTC](https://discourse.threejs.org/t/shadow-not-working/44769/4 "2022-11-16T10:14:50Z")

</div>

here is a directional ligh shadow example that shows that directional light shadows do work.  
[Directional Light Shadow - Three.js Tutorials (sbcode.net)](https://sbcode.net/threejs/directional-light-shadow/)

---

<div class="post-metadata">

**Author:** ![binoy\_t](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/binoy_t/32/24330_2.png) [@binoy\_t](https://discourse.threejs.org/u/binoy_t)\
**Post date:** [November 16, 2022, 11:34am UTC](https://discourse.threejs.org/t/shadow-not-working/44769/5 "2022-11-16T11:34:55Z")

</div>

What is this plane your shadows are appearing on ? I think mine doesn’t have anything like that

---

<div class="post-metadata">

**Author:** ![seanwasere](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/seanwasere/32/75911_2.png) [@seanwasere](https://discourse.threejs.org/u/seanwasere)\
**Post date:** [November 16, 2022, 12:04pm UTC](https://discourse.threejs.org/t/shadow-not-working/44769/6 "2022-11-16T12:04:28Z")

</div>

the code for the plane is in the source code of the example I linked earlier.  
Press the **\<\>** in the working example to see the un obfuscated inline JavaScript.  
or look at lines 40-45 in the TypeScript example.  
Nothing is hidden from you.  
And also, in the TypeScript version there actually isn’t any TypeScript in there, since all the types are auto inferred by the usage of each variable as they are declared or instantiated.

Also, check this example.  
[Raycaster Measurements - Three.js Tutorials (sbcode.net)](https://sbcode.net/threejs/measurements/)  
It loads a glTF into the scene with the plane already included in the model.  
The model is traversed, and shadows are set to receive and cast appropriately
