Skip to content

Instantly share code, notes, and snippets.

@mrdoob
Created September 18, 2011 03:23
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 mrdoob/1224685 to your computer and use it in GitHub Desktop.
Save mrdoob/1224685 to your computer and use it in GitHub Desktop.
Create POT texture from a nonPOT
var texture = THREE.ImageUtils.loadTexture( 'nonPOT.png', new THREE.UVMapping(), function () {
var nextPOT = function ( value ) { var pot = 1; while ( pot < value ) pot <<= 1; return pot; };
var canvas = document.createElement( 'canvas' );
canvas.width = nextPOT( texture.image.width );
canvas.height = nextPOT( texture.image.height );
canvas.getContext( '2d' ).drawImage( texture.image, 0, 0, texture.image.width, texture.image.height, 0, 0, canvas.width, canvas.height );
texture.image = canvas;
} );
@ankunix
Copy link

ankunix commented Feb 14, 2016

Getting Error: UVMApping() is not a function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment