如何反转在​​对象CylinderGeometry中应用纹理的方向?

var obj = new THREE.Mesh(
    new THREE.CylinderGeometry(20, 15, 1, 20),
    new THREE.MeshLambertMaterial({color: 0x000000}) //the material is later changed to the correct
);


预先感谢您的帮助 :)

最佳答案

此功能有效:

        var invertTextureOnCylinderGeometry = function(obj) {
            var faceVertexes = obj.geometry.faceVertexUvs[0];
            var faceVertexesLength = faceVertexes.length;
            var divisionT = 1 / (faceVertexesLength * 0.25);
            faceVertexes.map(function(face, index) {
                if (index < 0.5*faceVertexesLength) {
                    var thisIndexDivision = [
                        Math.floor(index/2) * divisionT,
                        Math.ceil((index+divisionT)/2) * divisionT
                    ];
                    if (index % 2) {
                        face[0].set(1, thisIndexDivision[0]);
                        face[1].set(1, thisIndexDivision[1]);
                        face[2].set(0, thisIndexDivision[1]);
                    } else {
                        face[0].set(0, thisIndexDivision[0]);
                        face[1].set(1, thisIndexDivision[0]);
                        face[2].set(0, thisIndexDivision[1]);
                    }
                }
            });
            obj.geometry.uvsNeedUpdate = true;
        };

07-24 17:20