Skip to content

Instantly share code, notes, and snippets.

@spite
Created May 13, 2016 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spite/00b3f17734810168093eb92a12815df3 to your computer and use it in GitHub Desktop.
Save spite/00b3f17734810168093eb92a12815df3 to your computer and use it in GitHub Desktop.
Standard UV map (equirectangular 2:1) to mercator (1:1)
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