ThreeJS 更新UV

481 阅读1分钟
  • 更新uv的方式
let uvResult = [];
mesh.geometry.setAttribute( 'uv', new THREE.BufferAttribute( new Float32Array(uvResult), 2, true ) );
mesh.geometry.attributes.uv.isPacked = true;
mesh.geometry.attributes.uv.needsUpdate = true;
mesh.geometry.attributes.uv.bytes = uvResult.length * 2;
  • 基本是0-1,只不过x轴为 [-1-0] ,y轴为[0-1]
{
    "0": -0.5,
    "1": 0.5,
    
    "2": -0.5,
    "3": 0.25,
    
    "4": -0.5,
    "5": 0.75,
    
    "6": 0,
    "7": 0,
    
    "8": -0.5,
    "9": 0,
    
    "10": -1,
    "11": 0,
    
    "12": -1,
    "13": 0.25,
    
    "14": -1,
    "15": 0.5,
    
    "16": -1,
    "17": 0.75,
    
    "18": -1,
    "19": 1,
    
    "20": -0.5,
    "21": 1,
    
    "22": 0,
    "23": 1,
    
    "24": 0,
    "25": 0.75,
    
    "26": 0,
    "27": 0.5,
    
    "28": 0,
    "29": 0.25
}