react中有一个组件,它使用useGLTF渲染.glb模型,我们称之为3DComponent
但每次执行到的链接时,组件都会重新加载模型
3DComponent是否有方法使用在上一次渲染中加载的相同模型?
该组件的声明方式为:
export default function Model({ ...props }) {
==> const { nodes, materials, animations } = useGLTF('/studio.glb');
const group = useRef();
const { actions } = useAnimations(animations, group);
...
...
每次渲染时,它都会执行useGLTB,但我不能对useGLTB进行调节,因为它是一个钩子,如果没有编译错误,就无法对其进行调节
我该怎么做才能避免为其他渲染重新加载模型?
提前感谢
Rafael
我相信这个钩子是这样使用的,重新渲染不应该影响您的性能。