【发布时间】:2022-02-01 09:11:31
【问题描述】:
我正在努力将纹理贴图应用于加载的对象。
(从magica体素导出的.obj)。
我将它的子几何用于网格。
加载对象并应用任何材料都可以正常工作。
但是贴图(在这种情况下是法线,粗糙度)被完全忽略了。
import { useLoader } from '@react-three/fiber'
import { useTexture } from '@react-three/drei'
import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader'
import CaseObject from '../object/case.obj'
import texture from '../texture/plastic/color.jpg'
import roughnessMap from '../texture/plastic/roughness_map.jpg'
import normalMap from '../texture/plastic/normal_map.jpg'
function Case (props) {
const object = useLoader(OBJLoader, CaseObject)
const geometry = object.children[0].geometry
const matProps = useTexture({
map: texture,
roughnessMap: roughnessMap,
normalMap: normalMap,
})
return <mesh
castShadow={true}
receiveShadow={true}
>
<bufferGeometry {...geometry} />
<meshStandardMaterial
{...matProps}
/>
</mesh>
}
export default Case
【问题讨论】:
标签: three.js 3d textures mesh react-three-fiber