我正在尝试使用NEXT JS将一个全景图像转换为立方体贴图格式。场景被渲染出来,但背景没有应用。同时,我没有收到任何错误提示!
import { useLoader, useThree } from "@react-three/fiber";
import * as THREE from "three";
const Background = (props) => {
const texture = useLoader(THREE.TextureLoader, "/autoshop.jpg");
const { gl } = useThree();
const formatted = new THREE.WebGLCubeRenderTarget(
texture.image.height
).fromEquirectangularTexture(gl, texture);
console.log("formatted", formatted);
return <primitive attach="background" object={formatted} />;
};
export default Background;
我称其为Suspense包裹:
<Suspense fallback={null}>
<Background />
</Suspense>