diff --git a/docs/api/math/Color.html b/docs/api/math/Color.html
index 982799fa1a931f8e72457d04d9d1d6c44db9d445..48ed5f01f6323c1310c16f698796a9fc91312ad9 100644
--- a/docs/api/math/Color.html
+++ b/docs/api/math/Color.html
@@ -18,6 +18,7 @@
var color = new THREE.Color();
var color = new THREE.Color( 0xff0000 );
var color = new THREE.Color("rgb(255,0,0)");
+ var color = new THREE.Color( 1, 0, 0 );
Constructor
@@ -25,7 +26,7 @@
[name]( value )
- value — optional argument that sets initial color. Can be a hexadecimal or a CSS-style string, for example, "rgb(250, 0,0)", "rgb(100%,0%,0%)", "#ff0000", "#f00", or "red"
+ value — optional argument that sets initial color. Can be a hexadecimal or a CSS-style string, for example, "rgb(250, 0,0)", "rgb(100%,0%,0%)", "#ff0000", "#f00", or "red", or three arguments that represent color channels.
Properties
diff --git a/src/math/Color.js b/src/math/Color.js
index 1428986f3e61b03b29a684fd3db317d40384882e..4c31d93fa6975e9bed9ca780aae74cd0c6439363 100644
--- a/src/math/Color.js
+++ b/src/math/Color.js
@@ -2,9 +2,9 @@
* @author mrdoob / http://mrdoob.com/
*/
-THREE.Color = function ( value ) {
+THREE.Color = function () {
- if ( value !== undefined ) this.set( value );
+ if ( arguments.length ) this.set( arguments.length === 1 ? arguments[0] : arguments );
return this;
@@ -30,7 +30,11 @@ THREE.Color.prototype = {
this.setStyle( value );
- }
+ } else if ( value.length ) {
+
+ this.setRGB.apply( this, value );
+
+ }
return this;
diff --git a/test/unit/math/Color.js b/test/unit/math/Color.js
index 9ed602388ac1e52d964356811e6221ae5aece077..4229b2f4154a90abe4f4119f0909572f6b29a315 100644
--- a/test/unit/math/Color.js
+++ b/test/unit/math/Color.js
@@ -7,6 +7,13 @@ test( "constructor", function(){
ok( c.b, "Blue: " + c.g );
});
+test( "rgb constructor", function(){
+ var c = new THREE.Color( 1, 1, 1 );
+ ok( c.r == 1, "Passed" );
+ ok( c.g == 1, "Passed" );
+ ok( c.b == 1, "Passed" );
+});
+
test( "copyHex", function(){
var c = new THREE.Color();
var c2 = new THREE.Color(0xF5FFFA);