我试图用3JS(react native fiber版本)将图像渲染到平面上,我使用的是meshbasicmaterial,但平面上的颜色(图像)没有显示源中的真实颜色。形象
const geo = new THREE.Geometry();
geo.vertices.push(new THREE.Vector3(0,0,-1))
geo.vertices.push(new THREE.Vector3(width,0,-1))
geo.vertices.push(new THREE.Vector3(width,-height,-1))
geo.vertices.push(new THREE.Vector3(0,-height,-1))
geo.faces.push(new THREE.Face3(1,0,2))
geo.faces.push(new THREE.Face3(2,0,3))
geo.faceVertexUvs[0].push([
new THREE.Vector2(1,1),
new THREE.Vector2(0,1),
new THREE.Vector2(1,0),
])
geo.faceVertexUvs[0].push([
new THREE.Vector2(1,0),
new THREE.Vector2(0,1),
new THREE.Vector2(0,0),
])
geo.uvsNeedUpdate = true;
geo.computeVertexNormals();
geo.computeFaceNormals();
const loader = new THREE.TextureLoader();
const material = new THREE.MeshBasicMaterial({
map: loader.load(img),
});
return (
<mesh name='model' geometry = {geo} material = {material} >
</mesh>
)
}
暂无答案!
目前还没有任何答案,快来回答吧!