【发布时间】:2022-01-09 06:06:38
【问题描述】:
我正在尝试为我的网格添加颜色过渡,但无法使用 react-spring 这样做
Scene.js
import { useSpring, animated } from '@react-spring/three'
const Cell = () => {
const [hovered, hover] = useState(false);
const springs = useSpring({ color: hovered ? 'hotpink' : 'orange'})
<animated.mesh
onPointerEnter={(e) => {
e.stopPropagation();
hover(true);
}}
onPointerLeave={(e) => {
e.stopPropagation();
hover(false);
}}
>
<planeGeometry args={[1, 1, 1]} />
<meshBasicMaterial color={springs.color} />
</animated.mesh
}
这只会让我的网格变成白色/灰色。
在here 提供的示例中,他们以类似的方式使用它,我不确定它为什么不起作用。我已经通过在网格本身上更改 scale 对此进行了测试,然后它就可以工作了。
【问题讨论】:
标签: javascript reactjs three.js react-three-fiber