Hi, guys, I’ve seen this question asked numerous times, and the answer always appears to be simple. However, none of the solutions I have tried have had any effect.
The problem is, I am loading a model but none of the shadows appear to be working. I have included the image I am using from the source (), along with how it looks within my react project:
All the smart people on this forum, but this seems to have stumped everyone. Or maybe I didn’t provide enough info? Any help or suggestions would be greatly appreciated.
That stadium looks amazing. I would also be interested in the answer as I have been unable to get a GLTF model to cast/receive shadows. Perhaps this tutorial will help?
EDIT: I think my problem is that I did not properly declare a shadowmap with my light.
isLoaded does nothing, it renders the component twice for no reason
useGLTF (from drei) is better than useLoader because it takes care of draco/meshopt
scenes don’t have castShadow and receiveShadow props
canvas has a short access shadows prop
using gltf raw on the web is no good, check out gltf.report which compresses them
your light doesn’t cast shadows, that’s the root issue most likely
if you have lights properly set up and they are at the right spot you will see shadows with the above.
you can also look at https://github.com/pmndrs/gltfjsx this is a formidable tool for gltf workflow on the web. there’s no traverse and mutation with this, and the models now become re-usable.
pps if you do face further issues, there’s poimandres discord which is usually a better place for react + three since most people on here will just ignore if they spot a pair of < >.
Hey thanks! This is great! I even got a free PR review ( lol – had I known this was going to happen, I would have cleaned up my code and gotten rid of my isLoading stuff, which I was using to debug ).
I hadn’t heard of useGltf, that was very helpful. I’ve tried several different lighting examples, none have worked. But at least my code is cleaner, so thanks again.
it works but the windows are blocking light. i’ve used gltfjsx and removed everything that said “glassShader” and now the light comes in Basic demo (forked) - CodeSandbox
@drcmda , your demo looks amazing! Nice clean code, too.
I am now using your demo code verbatim, but oddly enough, it looks slightly different from mine. I’m going to mess with it a bit more to see if I can’t get it looking more like yours.
Thanks so much for your help!
I’m glad you found an answer that works. It’s looking really great. Be sure to showcase the final result in time for March Madness!
My inability to get shadows to work was a case of simple stupidity - I had the directional light positioned far beyond the far view of the shadow camera.