提交 b3ea0d5f 编写于 作者: A alteredq

Changed a bit clear color API.

Renamed: setClearColor( hex, opacity ) => setClearColorHex( hex, opacity )

New: setClearColor( color, opacity )

In this way it's a bit cheaper to animate clear color.

Hope I didn't break examples - I searched for "setClearColor" and changed it in one place where it was used.
上级 a8ab2336
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -260,7 +260,7 @@
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setClearColor( result.bgColor.hex, result.bgAlpha );
renderer.setClearColor( result.bgColor, result.bgAlpha );
*/
......@@ -322,7 +322,7 @@
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setClearColor( loaded.bgColor.hex, loaded.bgAlpha );
renderer.setClearColor( loaded.bgColor, loaded.bgAlpha );
}
......
......@@ -80,6 +80,7 @@
<script type="text/javascript" src="../src/extras/primitives/Cube.js"></script>
<script type="text/javascript" src="../src/extras/primitives/Plane.js"></script>
<script type="text/javascript" src="../src/extras/primitives/Cylinder.js"></script>
<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
<script type="text/javascript" src="js/Stats.js"></script>
......
......@@ -95,7 +95,19 @@ THREE.CanvasRenderer = function () {
};
this.setClearColor = function( hex, opacity ) {
this.setClearColor = function( color, opacity ) {
_clearColor = color;
_clearOpacity = opacity;
_clearRect.set( - _canvasWidthHalf, - _canvasHeightHalf, _canvasWidthHalf, _canvasHeightHalf );
_context.setTransform( 1, 0, 0, - 1, _canvasWidthHalf, _canvasHeightHalf );
this.clear();
};
this.setClearColorHex = function( hex, opacity ) {
_clearColor.setHex( hex );
_clearOpacity = opacity;
......
......@@ -74,13 +74,19 @@ THREE.WebGLRenderer = function ( parameters ) {
};
this.setClearColor = function( hex, alpha ) {
this.setClearColorHex = function( hex, alpha ) {
var color = new THREE.Color( hex );
_gl.clearColor( color.r, color.g, color.b, alpha );
};
this.setClearColor = function( color, alpha ) {
_gl.clearColor( color.r, color.g, color.b, alpha );
};
this.clear = function () {
_gl.clear( _gl.COLOR_BUFFER_BIT | _gl.DEPTH_BUFFER_BIT );
......
......@@ -67,9 +67,18 @@ THREE.WebGLRenderer2 = function ( antialias ) {
};
this.setClearColor = function( hex, opacity ) {
this.setClearColor = function( color, opacity ) {
_clearColor = hex.setHex( hex );
_clearColor = color;
_clearOpacity = opacity;
_gl.clearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearOpacity );
};
this.setClearColorHex = function( hex, opacity ) {
_clearColor.setHex( hex );
_clearOpacity = opacity;
_gl.clearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearOpacity );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册