提交 a2646422 编写于 作者: M Mr.doob

Math: Renamed nearestPowerOfTwo() to floorPowerOfTwo() and nextPowerOfTwo() to...

Math: Renamed nearestPowerOfTwo() to floorPowerOfTwo() and nextPowerOfTwo() to ceilPowerOfTwo(). See 31e8e610
上级 7c2ebf71
......@@ -70,11 +70,11 @@
Linear mapping of [page:Float x] from range [[page:Float a1], [page:Float a2]] to range [[page:Float b1], [page:Float b2]].
</div>
<h3>[method:Integer nearestPowerOfTwo]( [page:Number n] )</h3>
<div>Returns the nearest power of 2 that is smaller or equal to [page:Number n].</div>
<h3>[method:Integer ceilPowerOfTwo]( [page:Number n] )</h3>
<div>Returns the smallest power of 2 that is greater than or equal to [page:Number n].</div>
<h3>[method:Integer nextPowerOfTwo]( [page:Number n] )</h3>
<div>Returns the nearest power of 2 that is bigger than [page:Number n].</div>
<h3>[method:Integer floorPowerOfTwo]( [page:Number n] )</h3>
<div>Returns the largest power of 2 that is less than or equal to [page:Number n].</div>
<h3>[method:Float radToDeg]( [page:Float radians] )</h3>
<div>Converts radians to degrees.</div>
......
......@@ -420,12 +420,30 @@ Line3.prototype.center = function ( optionalTarget ) {
};
_Math.random16 = function () {
Object.assign( _Math, {
console.warn( 'THREE.Math.random16() has been deprecated. Use Math.random() instead.' );
return Math.random();
random16: function () {
};
console.warn( 'THREE.Math: .random16() has been deprecated. Use Math.random() instead.' );
return Math.random();
},
nearestPowerOfTwo: function ( value ) {
console.warn( 'THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().' );
return _Math.floorPowerOfTwo( value );
},
nextPowerOfTwo: function ( value ) {
console.warn( 'THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().' );
return _Math.ceilPowerOfTwo( value );
}
} );
Object.assign( Matrix3.prototype, {
......
......@@ -142,23 +142,15 @@ var _Math = {
},
nearestPowerOfTwo: function ( value ) {
ceilPowerOfTwo: function ( value ) {
return Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );
return Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) );
},
nextPowerOfTwo: function ( value ) {
value --;
value |= value >> 1;
value |= value >> 2;
value |= value >> 4;
value |= value >> 8;
value |= value >> 16;
value ++;
floorPowerOfTwo: function ( value ) {
return value;
return Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );
}
......
......@@ -1717,7 +1717,7 @@ function WebGLRenderer( parameters ) {
var size = Math.sqrt( bones.length * 4 ); // 4 pixels needed for 1 matrix
size = _Math.nextPowerOfTwo( Math.ceil( size ) );
size = _Math.ceilPowerOfTwo( size );
size = Math.max( size, 4 );
var boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel
......
......@@ -48,8 +48,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
if ( image instanceof HTMLImageElement || image instanceof HTMLCanvasElement ) {
var canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );
canvas.width = _Math.nearestPowerOfTwo( image.width );
canvas.height = _Math.nearestPowerOfTwo( image.height );
canvas.width = _Math.floorPowerOfTwo( image.width );
canvas.height = _Math.floorPowerOfTwo( image.height );
var context = canvas.getContext( '2d' );
context.drawImage( image, 0, 0, canvas.width, canvas.height );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册