Hi there !
I have seen multiple posts about this problematic and have tried lot of solutions mentioned but I still do not manage to cast shadow on my model from SketchFab. Model is:
and this is the rendering in my project:
As you can see there is quite the difference. Here is my canvas and lighting:
<Canvas shadows style={{ background: "black" }}>
<directionalLight
position={[0, 5, 0]}
intensity={5}
castShadow
shadow-camera-near={0.1}
shadow-camera-far={20}
shadow-camera-left={-10}
shadow-camera-right={10}
shadow-camera-top={10}
shadow-camera-bottom={-10}
shadow-mapSize-width={1024}
shadow-mapSize-height={1024}
/>
<City />
<PerspectiveCamera makeDefault ref={cameraRef} />
<OrbitControls ref={controlsRef} />
</Canvas>
I have generated the city component using:
npx gltfjsx
and I have added for any and in the component generated the props receiveShadow and castShadow, so the code looks like this:
<group castShadow receiveShadow ref={group} {...props} dispose={null}>
<group castShadow receiveShadow name="Sketchfab_Scene">
<group
castShadow
receiveShadow
name="Sketchfab_model"
rotation={[-Math.PI / 2, 0, 0]}
>
<group castShadow receiveShadow name="root">
<group
castShadow
receiveShadow
name="GLTF_SceneRootNode"
rotation={[Math.PI / 2, 0, 0]}
>
<group
castShadow
receiveShadow
name="Cube004_3"
position={[14.019, 7.064, -10.751]}
>
<mesh
castShadow
receiveShadow
name="Object_10"
geometry={nodes.Object_10.geometry}
material={materials.TRAIN}
/>
and so on, so on
I added another model, also from sketchfab, in the middle of my scene and I can see the light working on it. For the city it’s different, even without light I can see it all and lightning doesn’t seem to affect it whatsoever.
Any idea on how to tackle this problem ? I just want my imported model to look like the one on Sketchlab.
Thanks in advance.