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

Deprecated setClearColorHex().

上级 60db8b66
......@@ -261,18 +261,22 @@ THREE.Color.prototype = {
set: function ( value ) {
switch ( typeof value ) {
if ( value instanceof THREE.Color ) {
case "number":
this.setHex( value );
break;
this.copy( value );
case "string":
this.setStyle( value );
break;
} else if ( typeof value === 'number' ) {
this.setHex( value );
} else if ( typeof value === 'string' ) {
this.setStyle( value );
}
return this;
},
setHex: function ( hex ) {
......@@ -13840,7 +13844,7 @@ THREE.CanvasRenderer = function ( parameters ) {
_context = _canvas.getContext( '2d' ),
_clearColor = new THREE.Color( 0x000000 ),
_clearOpacity = 0,
_clearAlpha = 0,
_contextGlobalAlpha = 1,
_contextGlobalCompositeOperation = 0,
......@@ -13991,10 +13995,10 @@ THREE.CanvasRenderer = function ( parameters ) {
};
this.setClearColor = function ( color, opacity ) {
this.setClearColor = function ( color, alpha ) {
_clearColor.copy( color );
_clearOpacity = opacity !== undefined ? opacity : 1;
_clearColor.set( color );
_clearAlpha = alpha !== undefined ? alpha : 1;
_clearBox.set(
new THREE.Vector2( - _canvasWidthHalf, - _canvasHeightHalf ),
......@@ -14003,15 +14007,10 @@ THREE.CanvasRenderer = function ( parameters ) {
};
this.setClearColorHex = function ( hex, opacity ) {
_clearColor.setHex( hex );
_clearOpacity = opacity !== undefined ? opacity : 1;
this.setClearColorHex = function ( hex, alpha ) {
_clearBox.set(
new THREE.Vector2( - _canvasWidthHalf, - _canvasHeightHalf ),
new THREE.Vector2( _canvasWidthHalf, _canvasHeightHalf )
);
console.warn( 'DEPRECATED: .setClearColorHex() is being removed. Use .setClearColor() instead.' );
this.setClearColor( hex, alpha );
};
......@@ -14030,7 +14029,7 @@ THREE.CanvasRenderer = function ( parameters ) {
_clearBox.intersect( _clipBox );
_clearBox.expandByScalar( 2 );
if ( _clearOpacity < 1 ) {
if ( _clearAlpha < 1 ) {
_context.clearRect(
_clearBox.min.x | 0,
......@@ -14041,12 +14040,12 @@ THREE.CanvasRenderer = function ( parameters ) {
}
if ( _clearOpacity > 0 ) {
if ( _clearAlpha > 0 ) {
setBlending( THREE.NormalBlending );
setOpacity( 1 );
setFillStyle( 'rgba(' + Math.floor( _clearColor.r * 255 ) + ',' + Math.floor( _clearColor.g * 255 ) + ',' + Math.floor( _clearColor.b * 255 ) + ',' + _clearOpacity + ')' );
setFillStyle( 'rgba(' + Math.floor( _clearColor.r * 255 ) + ',' + Math.floor( _clearColor.g * 255 ) + ',' + Math.floor( _clearColor.b * 255 ) + ',' + _clearAlpha + ')' );
_context.fillRect(
_clearBox.min.x | 0,
......@@ -18615,21 +18614,19 @@ THREE.WebGLRenderer = function ( parameters ) {
// Clearing
this.setClearColorHex = function ( hex, alpha ) {
this.setClearColor = function ( color, alpha ) {
_clearColor.setHex( hex );
_clearAlpha = alpha;
_clearColor.set( color );
_clearAlpha = alpha !== undefined ? alpha : 1;
_gl.clearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha );
};
this.setClearColor = function ( color, alpha ) {
_clearColor.copy( color );
_clearAlpha = alpha;
this.setClearColorHex = function ( hex, alpha ) {
_gl.clearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha );
console.warn( 'DEPRECATED: .setClearColorHex() is being removed. Use .setClearColor() instead.' );
this.setClearColor( hex, alpha );
};
......
此差异已折叠。
......@@ -207,23 +207,18 @@
<h3>.enableScissorTest( [page:Boolean enable] )</h3>
<div>Enable the scissor test. When this is enabled, only the pixels within the defined scissor area will be affected by further renderer actions.</div>
<h3>.setClearColor( [page:Color color], [page:Float alpha] )</h3>
<div>Sets the clear color and opacity.</div>
<h3>.setClearColorHex( [page:Integer hex], [page:Float alpha] )</h3>
<div>Sets the clear color, using hex for the color and alpha for the opacity.</div>
<code>// Creates a renderer with black background
<code>// Creates a renderer with red background
var renderer = new THREE.WebGLRenderer();
renderer.setSize(200, 100);
renderer.setClearColorHex(0x000000, 1);
renderer.setClearColor(0xff0000, 1);
</code>
<h3>.setClearColor( [page:Color color], [page:Float alpha] )</h3>
<div>Sets the clear color, using color for the color and alpha for the opacity.</div>
<h3>.getClearColor() [page:Color]</h3>
<div>Returns a [page:Color THREE.Color] instance with the current clear color.</div>
<h3>.getClearAlpha() [page:Float]</h3>
<div>Returns a [page:Float float] with the current clear alpha. Ranges from 0 to 1.</div>
......@@ -231,7 +226,6 @@
<div>Tells the renderer to clear its color, depth or stencil drawing buffer(s).</div>
<div>If no parameters are passed, no buffer will be cleared.</div>
<h3>.addPostPlugin( plugin )</h3>
<div>Initialises the postprocessing plugin, and adds it to the renderPluginsPost array.</div>
......
......@@ -18,18 +18,22 @@ THREE.Color.prototype = {
set: function ( value ) {
switch ( typeof value ) {
if ( value instanceof THREE.Color ) {
case "number":
this.setHex( value );
break;
this.copy( value );
case "string":
this.setStyle( value );
break;
} else if ( typeof value === 'number' ) {
this.setHex( value );
} else if ( typeof value === 'string' ) {
this.setStyle( value );
}
return this;
},
setHex: function ( hex ) {
......
......@@ -22,7 +22,7 @@ THREE.CanvasRenderer = function ( parameters ) {
_context = _canvas.getContext( '2d' ),
_clearColor = new THREE.Color( 0x000000 ),
_clearOpacity = 0,
_clearAlpha = 0,
_contextGlobalAlpha = 1,
_contextGlobalCompositeOperation = 0,
......@@ -173,10 +173,10 @@ THREE.CanvasRenderer = function ( parameters ) {
};
this.setClearColor = function ( color, opacity ) {
this.setClearColor = function ( color, alpha ) {
_clearColor.copy( color );
_clearOpacity = opacity !== undefined ? opacity : 1;
_clearColor.set( color );
_clearAlpha = alpha !== undefined ? alpha : 1;
_clearBox.set(
new THREE.Vector2( - _canvasWidthHalf, - _canvasHeightHalf ),
......@@ -185,15 +185,10 @@ THREE.CanvasRenderer = function ( parameters ) {
};
this.setClearColorHex = function ( hex, opacity ) {
this.setClearColorHex = function ( hex, alpha ) {
_clearColor.setHex( hex );
_clearOpacity = opacity !== undefined ? opacity : 1;
_clearBox.set(
new THREE.Vector2( - _canvasWidthHalf, - _canvasHeightHalf ),
new THREE.Vector2( _canvasWidthHalf, _canvasHeightHalf )
);
console.warn( 'DEPRECATED: .setClearColorHex() is being removed. Use .setClearColor() instead.' );
this.setClearColor( hex, alpha );
};
......@@ -212,7 +207,7 @@ THREE.CanvasRenderer = function ( parameters ) {
_clearBox.intersect( _clipBox );
_clearBox.expandByScalar( 2 );
if ( _clearOpacity < 1 ) {
if ( _clearAlpha < 1 ) {
_context.clearRect(
_clearBox.min.x | 0,
......@@ -223,12 +218,12 @@ THREE.CanvasRenderer = function ( parameters ) {
}
if ( _clearOpacity > 0 ) {
if ( _clearAlpha > 0 ) {
setBlending( THREE.NormalBlending );
setOpacity( 1 );
setFillStyle( 'rgba(' + Math.floor( _clearColor.r * 255 ) + ',' + Math.floor( _clearColor.g * 255 ) + ',' + Math.floor( _clearColor.b * 255 ) + ',' + _clearOpacity + ')' );
setFillStyle( 'rgba(' + Math.floor( _clearColor.r * 255 ) + ',' + Math.floor( _clearColor.g * 255 ) + ',' + Math.floor( _clearColor.b * 255 ) + ',' + _clearAlpha + ')' );
_context.fillRect(
_clearBox.min.x | 0,
......
......@@ -331,21 +331,19 @@ THREE.WebGLRenderer = function ( parameters ) {
// Clearing
this.setClearColorHex = function ( hex, alpha ) {
this.setClearColor = function ( color, alpha ) {
_clearColor.setHex( hex );
_clearAlpha = alpha;
_clearColor.set( color );
_clearAlpha = alpha !== undefined ? alpha : 1;
_gl.clearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha );
};
this.setClearColor = function ( color, alpha ) {
_clearColor.copy( color );
_clearAlpha = alpha;
this.setClearColorHex = function ( hex, alpha ) {
_gl.clearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearAlpha );
console.warn( 'DEPRECATED: .setClearColorHex() is being removed. Use .setClearColor() instead.' );
this.setClearColor( hex, alpha );
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册