# I am not able to emulate the shadows which I did on threejs editor onto threejs code

**URL:** https://discourse.threejs.org/t/i-am-not-able-to-emulate-the-shadows-which-i-did-on-threejs-editor-onto-threejs-code/63297
**Category:** Questions
**Tags:** shadows
**Created:** [March 27, 2024, 2:55am UTC](https://discourse.threejs.org/t/i-am-not-able-to-emulate-the-shadows-which-i-did-on-threejs-editor-onto-threejs-code/63297 "2024-03-27T02:55:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![arjun\_lokesh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/arjun_lokesh/32/39767_2.png) [@arjun\_lokesh](https://discourse.threejs.org/u/arjun_lokesh)
#### Post date: [March 27, 2024, 2:55am UTC](https://discourse.threejs.org/t/i-am-not-able-to-emulate-the-shadows-which-i-did-on-threejs-editor-onto-threejs-code/63297/1 "2024-03-27T02:55:36Z")

</div>

i am trying to emulate the shadows from a window as shown below which i created in threejs editor

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/5/4/54059377a0a87c4916a99cc453f6f272ef9a62d3.jpeg)  
1 - directional light with cast shadows enabled  
2 - is the was mesh with cast and receive shadow enabled mesh name : Cube

[shadows - Google Drive](https://drive.google.com/drive/folders/15uWTe5aCS8NFxGaZxNqArK0nDlvcEruM?usp=sharing) the drive contains the threejs and the glb file.

the current output of the given file is

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/f/1/f1e699fe79a6f049fbc3428c1b9a880805fe193e.jpeg)

---

<div class="post-metadata">

### Author: ![mjurczyk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mjurczyk/32/10995_2.png) [@mjurczyk](https://discourse.threejs.org/u/mjurczyk)
#### Post date: [March 27, 2024, 4:51am UTC](https://discourse.threejs.org/t/i-am-not-able-to-emulate-the-shadows-which-i-did-on-threejs-editor-onto-threejs-code/63297/2 "2024-03-27T04:51:33Z")

</div>

Is the shadow map also enabled on the renderer?

---

<div class="post-metadata">

### Author: ![arjun\_lokesh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/arjun_lokesh/32/39767_2.png) [@arjun\_lokesh](https://discourse.threejs.org/u/arjun_lokesh)
#### Post date: [March 27, 2024, 4:56am UTC](https://discourse.threejs.org/t/i-am-not-able-to-emulate-the-shadows-which-i-did-on-threejs-editor-onto-threejs-code/63297/3 "2024-03-27T04:56:45Z")

</div>

![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/9/a/9a74b675217d06d5a1ac0c3d9ae1439040eef6c9.png)  
yes!

---

<div class="post-metadata">

### Author: ![mjurczyk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mjurczyk/32/10995_2.png) [@mjurczyk](https://discourse.threejs.org/u/mjurczyk)
#### Post date: [March 27, 2024, 5:01am UTC](https://discourse.threejs.org/t/i-am-not-able-to-emulate-the-shadows-which-i-did-on-threejs-editor-onto-threejs-code/63297/4 "2024-03-27T05:01:08Z")

</div>

1. Try first setting up the shadows with a PointLight, to make sure your bias / positioning is correct.
2. Try first setting up with default three.js values, don’t modify shadow map size.
3. Set receiveShadow and castShadow to true for all children of the scene and see if that fixes the issue. That’d suggest you’re setting these values to wrong objects.

---

<div class="post-metadata">

### Author: ![arjun\_lokesh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/arjun_lokesh/32/39767_2.png) [@arjun\_lokesh](https://discourse.threejs.org/u/arjun_lokesh)
#### Post date: [March 27, 2024, 5:18am UTC](https://discourse.threejs.org/t/i-am-not-able-to-emulate-the-shadows-which-i-did-on-threejs-editor-onto-threejs-code/63297/5 "2024-03-27T05:18:00Z")

</div>

the floor was a child mesh apparently and I had to set receive shadows for it. Thanks a ton!  
I removed all the shadow biases and set the individual mesh features!

---

<div class="post-metadata">

### Author: ![arjun\_lokesh](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/arjun_lokesh/32/39767_2.png) [@arjun\_lokesh](https://discourse.threejs.org/u/arjun_lokesh)
#### Post date: [March 27, 2024, 5:29am UTC](https://discourse.threejs.org/t/i-am-not-able-to-emulate-the-shadows-which-i-did-on-threejs-editor-onto-threejs-code/63297/6 "2024-03-27T05:29:58Z")

</div>

do you have any idea why artifact might be there

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/5/7/5790c28c95378ac74f454bc267ae1f7559e8f446.jpeg)
