【发布时间】:2021-08-11 20:19:48
【问题描述】:
在我的应用程序中,我想为加载的 .obj 模型添加纹理。我的 .fbx 加载模型也有同样的情况。下面是我的示例代码,但这仅适用于 sphereGeometry 之类的东西,而不适用于加载的模型。
提前致谢!
import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader'
import { useTexture } from '@react-three/drei'
const OBJModel = ({ file }: { file: string }) => {
const obj = useLoader(OBJLoader, file)
const texture = useTexture(textureFile)
return (
<mesh>
<primitive object={obj} />
<meshStandardMaterial map={texture} attach="material" />
</mesh>
)
}
【问题讨论】:
标签: reactjs three.js react-three-fiber