小编Var*_*dey的帖子

反应三纤维阴影材料不起作用

以下是代码,旋转网格体不会在阴影材质上投射任何阴影。planBufferGeometry 似乎就在那里。-------------------------------------------------- -------------------------------------------------- -------------------------------------------------- -----------------

import React from 'react';
import './App.scss';
import {Canvas, useFrame} from 'react-three-fiber';


const SpinningMesh = ({position, args, color}) => {

  const mesh = React.useRef(null);
  useFrame(()=> (mesh.current.rotation.x = mesh.current.rotation.y += 0.01))

  return(
        <mesh castShadow ref={mesh} position={position}> 
          <boxBufferGeometry attach='geometry' args={args}/>
          <meshStandardMaterial attach='material' color={color}/>
        </mesh>
  );
}

function App() {

  return (
    <>
      <Canvas shadowMap colorManagement camera={{position:[-5,2,10], fov:60}}>
        <ambientLight intensity={0.3}/>
        <directionalLight
          castShadow
          position={[0,10,0]}
          intensity={1.5}
          shadow-mapSize-width={1024}
          shadow-mapSize-height={1024}
          shadow-camera-far={50}
          shadow-camera-left = {-10}
          shadow-camera-right = {10}
          shadow-camera-top = {10}
          shadow-camera-bottom = {-10} …
Run Code Online (Sandbox Code Playgroud)

shadow three.js reactjs react-three-fiber

2
推荐指数
1
解决办法
6298
查看次数

标签 统计

react-three-fiber ×1

reactjs ×1

shadow ×1

three.js ×1