Correct UV mapping Three.js

前端 未结 1 1690
攒了一身酷
攒了一身酷 2020-12-11 12:54

I\'m trying to map the UV-texture correctly, but failing...

I\'ve got the next result in my app:

\"enter

相关标签:
1条回答
  • 2020-12-11 13:03

    You need to look at PlaneGeometry.js and understand how the UVs are set. Then you will be able to figure out how to reset them. This should work -- there are two triangles per "face".

    for(var i = 0; i < geometry.faces.length / 2; i++) {
    
        geometry.faceVertexUvs[ 0 ].push(
        [
            new THREE.Vector2( 0, 0 ),
            new THREE.Vector2( 0, 1 ),
            new THREE.Vector2( 1, 0 ),    
        ] );
    
        geometry.faces[ 2 * i ].materialIndex = i;
    
        geometry.faceVertexUvs[ 0 ].push(
        [
            new THREE.Vector2( 0, 1 ),
            new THREE.Vector2( 1, 1 ),
            new THREE.Vector2( 1, 0 ),    
        ] );
    
        geometry.faces[ 2 * i + 1 ].materialIndex = i;
    
        materials.push( createTexture( i ) );
    
    }    
    
    //geometry.computeFaceNormals(); // not needed
    //geometry.dynamic = true; // not needed
    //geometry.uvsNeedUpdate = true; // not needed since plane has not been rendered yet    
    

    three.js r.62

    0 讨论(0)
提交回复
热议问题