I exported a GLB file from blender but when I import it into three js, it does not cast any shadows. I have made sure that my light has castShadow set to true, my ground has receiveShadow set to true, and I loop through all the children of my gltf scene and make sure they have castShadow set to true as well. I also made sure that my canvas has the shadows tag as well.
<Canvas shadows>...</Canvas>
.
const { nodes, scene, animations } = useGLTF(
"../../assets/full.glb",
) as GLTFResult;
useEffect(() => {
scene.traverse((child) => {
if (child.isMesh) child.castShadow = true;
});
}, [scene]);
Does anyone have any idea why this would be casting shadows? I will provide my lights code and ground as well in case that helps.
<mesh
rotation-x={-Math.PI / 2}
position-y={-0.5}
scale={new Vector3(FOV, FOV, FOV)}
receiveShadow
>
<circleGeometry />
<meshPhongMaterial>
<GradientTexture
stops={[0, 0.7]}
colors={["aquamarine", "white"]}
width={1024}
type={GradientType.Radial}
/>
</meshPhongMaterial>
</mesh>
<ambientLight args={[0xffffff]} intensity={0.5} />
<spotLight
position={[0, 2, 0]}
intensity={5}
ref={dirLight}
castShadow
/>
John Smith is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.