Created
September 18, 2011 03:23
-
-
Save mrdoob/1224685 to your computer and use it in GitHub Desktop.
Create POT texture from a nonPOT
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 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; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Getting Error: UVMApping() is not a function.