# Model not showing castShadow. How to fix the problem?

**URL:** <https://discourse.threejs.org/t/model-not-showing-castshadow-how-to-fix-the-problem/74170>\
**Category:** Questions\
**Tags:** threejs, react-three-fiber\
**Created:** [November 19, 2024, 9:33am UTC](https://discourse.threejs.org/t/model-not-showing-castshadow-how-to-fix-the-problem/74170 "2024-11-19T09:33:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![thebharat](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/thebharat/32/53754_2.png) [@thebharat](https://discourse.threejs.org/u/thebharat)\
**Post date:** [November 19, 2024, 9:33am UTC](https://discourse.threejs.org/t/model-not-showing-castshadow-how-to-fix-the-problem/74170/1 "2024-11-19T09:33:16Z")

</div>

import { useGLTF, ContactShadows } from ‘@react-three/drei’;  
import { useEffect, useRef } from “react”;  
import { Environment, OrbitControls, useHelper } from ‘@react-three/drei’;  
import { Group,PerspectiveCamera, SpotLight ,DirectionalLight} from “three”;  
const Model = () =\> {  
console.log(“mainscene”)  
const gltf = useGLTF(‘src/assets/model/GirlLoop.glb’);  
const group = useRef()  
gltf.scene.traverse( function( node ) {  
if ( node.isMesh ) { node.castShadow = true; }  
} );

const camera = new PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)

useEffect(() =\> {  
gltf.scene.traverse((child) =\> {  
if (child.isMesh) {  
child.castShadow = true;  
}  
});  
}, [gltf.scene]);

useEffect(() =\> {  
camera.position.set(5,5,5)  
camera.lookAt(0,-3.5,-0.2)

}, [camera]);

return (\<\>  
\<OrbitControls  
enableZoom={true}  
maxDistance={15}  
minDistance={1}  
minAzimuthAngle={-Math.PI / 8} // Limit to 45 degrees to the left  
maxAzimuthAngle={Math.PI / 8}  
/\>  
\<primitive object={gltf.scene} ref={group} scale={[0.8, 0.8, 0.8]} position={[0,-2,-0.16]} rotation={[0, -Math.PI / 2, 0]} castShadow/\>

```
   <directionalLight position={[2,3,-0.16]} intensity={5} castShadow shadow-mapSize-width={1024}
   shadow-mapSize-height={1024}
  />
   <ambientLight intensity={1}/>
   <ContactShadows position={[0,-2,-0.16]} rotation={[0,-Math.PI/2,0]} scale={0.8} opacity={0.1} blur={0.5} color='black'/>
   
</>

```

);  
}

export default Model;

---

<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:** [November 19, 2024, 9:37am UTC](https://discourse.threejs.org/t/model-not-showing-castshadow-how-to-fix-the-problem/74170/2 "2024-11-19T09:37:32Z")

</div>

Is there anything in the scene that also has [.receiveShadow](https://threejs.org/docs/index.html?q=mesh#api/en/core/Object3D.receiveShadow) set to true? Otherwise the model may be casting shadows, but there’s nothing to show them on

---

<div class="post-metadata">

**Author:** ![thebharat](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/thebharat/32/53754_2.png) [@thebharat](https://discourse.threejs.org/u/thebharat)\
**Post date:** [November 19, 2024, 10:15am UTC](https://discourse.threejs.org/t/model-not-showing-castshadow-how-to-fix-the-problem/74170/3 "2024-11-19T10:15:17Z")

</div>

![3d-cartoon-woman-sitting-chair-with-laptop-illustration-isolated-white-background_604472-912](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/9/8/984ef3be0699c19036fd624b7aa9c84b3a51d399.jpeg)

the whole model shadow is showing on the floor. But i want girl shadow on the table. both of the part of same model.

---

<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:** [November 19, 2024, 10:27am UTC](https://discourse.threejs.org/t/model-not-showing-castshadow-how-to-fix-the-problem/74170/4 "2024-11-19T10:27:01Z")

</div>

Aren’t these (both floor and under the girl sitting on the chair) shadows baked?

They don’t seem consistent with that a single DirectionalLight would produce (let alone that reflection underneath her feet.)

---

<div class="post-metadata">

**Author:** ![thebharat](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/thebharat/32/53754_2.png) [@thebharat](https://discourse.threejs.org/u/thebharat)\
**Post date:** [November 19, 2024, 10:29am UTC](https://discourse.threejs.org/t/model-not-showing-castshadow-how-to-fix-the-problem/74170/5 "2024-11-19T10:29:37Z")

</div>

the shadow of her thumb is not showing on the table.

---

<div class="post-metadata">

**Author:** ![Chaser\_Code](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/chaser_code/32/20199_2.png) [@Chaser\_Code](https://discourse.threejs.org/u/Chaser_Code)\
**Post date:** [November 19, 2024, 10:31am UTC](https://discourse.threejs.org/t/model-not-showing-castshadow-how-to-fix-the-problem/74170/6 "2024-11-19T10:31:09Z")

</div>

I dont know, but maybe i see shadow under left hand on table and its very bright.  
Try move camera to table hand.

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/6/4/6465d3040091a18be45c5d4147c194f7431d0970.png)

---

<div class="post-metadata">

**Author:** ![phil\_crowther](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/phil_crowther/32/64202_2.png) [@phil\_crowther](https://discourse.threejs.org/u/phil_crowther)\
**Post date:** [November 19, 2024, 3:29pm UTC](https://discourse.threejs.org/t/model-not-showing-castshadow-how-to-fix-the-problem/74170/7 "2024-11-19T15:29:59Z")

</div>

Is your ambientLight overwhelming the directionalLight?

---

<div class="post-metadata">

**Author:** ![dubois](https://avatars.discourse-cdn.com/v4/letter/d/e9c0ed/32.png) [@dubois](https://discourse.threejs.org/u/dubois)\
**Post date:** [November 19, 2024, 6:36pm UTC](https://discourse.threejs.org/t/model-not-showing-castshadow-how-to-fix-the-problem/74170/8 "2024-11-19T18:36:59Z")

</div>

The light is coming from the front, i think her hand is casting a shadow on the chair or on the floor. If you put the light behind her, she should cast the shadow on the desk. If you have a spotlight on your phone you can try this in the real world.
