提交 9410acc9 编写于 作者: C Christopher Probst

#4289 Move isPowerOfTwo to THREE.Math and update all references

上级 bf3a221f
......@@ -57,10 +57,6 @@ THREE.Mirror = function ( renderer, camera, options ) {
this.name = 'mirror_' + this.id;
function isPowerOfTwo ( value ) {
return ( value & ( value - 1 ) ) === 0;
};
options = options || {};
this.matrixNeedsUpdate = true;
......@@ -133,7 +129,7 @@ THREE.Mirror = function ( renderer, camera, options ) {
this.material.uniforms.mirrorColor.value = mirrorColor;
this.material.uniforms.textureMatrix.value = this.textureMatrix;
if ( !isPowerOfTwo(width) || !isPowerOfTwo( height ) ) {
if ( !THREE.Math.isPowerOfTwo(width) || !THREE.Math.isPowerOfTwo( height ) ) {
this.texture.generateMipmaps = false;
this.tempTexture.generateMipmaps = false;
......
......@@ -107,9 +107,6 @@ THREE.Water = function ( renderer, camera, scene, options ) {
THREE.Object3D.call( this );
this.name = 'water_' + this.id;
function isPowerOfTwo ( value ) {
return ( value & ( value - 1 ) ) === 0;
};
function optionalParameter ( value, defaultValue ) {
return value !== undefined ? value : defaultValue;
};
......@@ -177,7 +174,7 @@ THREE.Water = function ( renderer, camera, scene, options ) {
this.material.uniforms.eye.value = this.eye;
if ( !isPowerOfTwo(width) || !isPowerOfTwo(height) )
if ( !THREE.Math.isPowerOfTwo(width) || !THREE.Math.isPowerOfTwo(height) )
{
this.texture.generateMipmaps = false;
this.tempTexture.generateMipmaps = false;
......
......@@ -395,7 +395,7 @@ THREE.MTLLoader.MaterialCreator.prototype = {
THREE.MTLLoader.ensurePowerOfTwo_ = function ( image ) {
if ( ! THREE.MTLLoader.isPowerOfTwo_( image.width ) || ! THREE.MTLLoader.isPowerOfTwo_( image.height ) ) {
if ( ! THREE.Math.isPowerOfTwo_( image.width ) || ! THREE.Math.isPowerOfTwo_( image.height ) ) {
var canvas = document.createElement( "canvas" );
canvas.width = THREE.MTLLoader.nextHighestPowerOfTwo_( image.width );
......@@ -411,12 +411,6 @@ THREE.MTLLoader.ensurePowerOfTwo_ = function ( image ) {
};
THREE.MTLLoader.isPowerOfTwo_ = function ( x ) {
return ( x & ( x - 1 ) ) === 0;
};
THREE.MTLLoader.nextHighestPowerOfTwo_ = function( x ) {
--x;
......
......@@ -152,6 +152,10 @@ THREE.Math = {
};
}()
}(),
isPowerOfTwo: function ( value ) {
return ( value & ( value - 1 ) ) === 0 && value !== 0;
}
};
......@@ -5822,13 +5822,6 @@ THREE.WebGLRenderer = function ( parameters ) {
// Textures
function isPowerOfTwo ( value ) {
return ( value & ( value - 1 ) ) === 0;
};
function setTextureParameters ( textureType, texture, isImagePowerOfTwo ) {
if ( isImagePowerOfTwo ) {
......@@ -5886,7 +5879,7 @@ THREE.WebGLRenderer = function ( parameters ) {
_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );
var image = texture.image,
isImagePowerOfTwo = isPowerOfTwo( image.width ) && isPowerOfTwo( image.height ),
isImagePowerOfTwo = THREE.Math.isPowerOfTwo( image.width ) && THREE.Math.isPowerOfTwo( image.height ),
glFormat = paramThreeToGL( texture.format ),
glType = paramThreeToGL( texture.type );
......@@ -6036,7 +6029,7 @@ THREE.WebGLRenderer = function ( parameters ) {
}
var image = cubeImage[ 0 ],
isImagePowerOfTwo = isPowerOfTwo( image.width ) && isPowerOfTwo( image.height ),
isImagePowerOfTwo = THREE.Math.isPowerOfTwo( image.width ) && THREE.Math.isPowerOfTwo( image.height ),
glFormat = paramThreeToGL( texture.format ),
glType = paramThreeToGL( texture.type );
......@@ -6149,7 +6142,7 @@ THREE.WebGLRenderer = function ( parameters ) {
// Setup texture, create render and frame buffers
var isTargetPowerOfTwo = isPowerOfTwo( renderTarget.width ) && isPowerOfTwo( renderTarget.height ),
var isTargetPowerOfTwo = THREE.Math.isPowerOfTwo( renderTarget.width ) && THREE.Math.isPowerOfTwo( renderTarget.height ),
glFormat = paramThreeToGL( renderTarget.format ),
glType = paramThreeToGL( renderTarget.type );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册