2016-06-02 6 views
1

オブジェクトのテクスチャを適用する方向を逆にする方法CylinderGeometry?オブジェクトのテクスチャを適用する方向を逆にする方法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 
); 

あなたの助けのために事前にありがとうございます:)

+0

あなたは何を意味するのですか?あなたはもっと具体的になりますか? – Wilt

+0

それは私たちが以下に示すものだった。ありがとう:) –

+0

@JarosławOsmólskiこれはあなたが "方向を逆にする"という意味ですか? 'texture.wrapS = texture.wrapT = THREE.RepeatWrapping; texture.repeat.set( - 1,1); ' – WestLangley

答えて

1

この機能は動作します:

 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; 
     }; 
+0

ただ受け入れる..... –

+0

'nieparzyste'と' parzyste'?言語はSOで英語にする必要があります。 – Wilt

+0

私にとって一時的なほうが簡単でした。私は削除しました。ここにコメントする必要はありません。 –

関連する問題