Created
May 13, 2016 14:16
-
-
Save spite/00b3f17734810168093eb92a12815df3 to your computer and use it in GitHub Desktop.
Standard UV map (equirectangular 2:1) to mercator (1:1)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var geometry = new THREE.IcosahedronGeometry( 2, 5 ); | |
for ( var i = 0, l = geometry.faceVertexUvs[ 0 ].length; i < l; i ++ ) { | |
for ( var j = 0, jl = geometry.faceVertexUvs[ 0 ][ i ].length; j < jl; j ++ ) { | |
var uv = geometry.faceVertexUvs[ 0 ][ i ][ j ]; | |
var a = uv.y * Math.PI - Math.PI / 2; | |
a = Math.sin(a); | |
uv.y = 0.5 - Math.log( ( 1 + a ) / ( 1 - a ) ) / ( 4 * Math.PI ); | |
uv.y = 1 - uv.y; | |
} | |
} | |
geometry.uvsNeedUpdate = true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment