即使我启用了castShadow和receiveShadow,3D场景也没有阴影

问题描述 投票:0回答:1

Enter image description here

嗨,

我的影子有问题。我在代码中启用了阴影,但我不知道为什么我的 3D 模型没有收到此阴影。您可以查看图片或链接Codesandbox Sunlight

模型.js

return <primitive object={scene} receiveShadow />;

场景.js


  <directionalLight
    intensity={0.5}
    castShadow // highlight-line
    shadow-mapSize-height={512}
    shadow-mapSize-width={512}
    position={calc}
  />
  <Model />
  {/* Plane just to see the shadow - I will remove it later */}
  <Plane
    receiveShadow // highlight-line
    rotation={[-Math.PI / 2, 0, 0]}
    position={[0, -10, 0]}
    args={[100, 100]}
  >
    <meshStandardMaterial attach="material" color="white" />
  </Plane>

我启用了 receiveShadow 和castShadow

javascript reactjs three.js react-three-fiber react-three-drei
1个回答
0
投票

在第 61 行的代码中,您使用了 {} 而不是“”,您也可以尝试制作另一个与原始平面大小相同的平面/对象,除了在副本上使用 ShadowMateral。我在 Three.js 构建中遇到了类似的问题,并使用 ShadowMateral 修复了它。这种材质是不可见的,仅用于显示阴影

这里是 Three.js 文档

© www.soinside.com 2019 - 2024. All rights reserved.