gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-27 22:56:20 26 4
gpt4 key购买 nike

如何反转在​​ 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;
};

关于javascript - 如何反转在​​ CylinderGeometry 对象中应用纹理的方向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37583866/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com