Skip to content

Commit bc6bc54

Browse files
gero3mrdoob
authored andcommitted
Remove arguments to allow optimalisations
* Remove arguments to allow optimalisations * Change constructor based on @mrdoob's argument * Fix issue with renaming of argument * convert space to tabs * cleanup docs * don't forget the linefeed in docs * docs cleanup * Update Color.html
1 parent c184493 commit bc6bc54

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

docs/api/math/Color.html

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,31 @@ <h2>Example</h2>
2727
<h2>Constructor</h2>
2828

2929

30-
<h3>[name]( value )</h3>
31-
<div>
32-
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%)", "hsl(0, 100%, 50%)", "#ff0000", "#f00", or "red", or three arguments that represent color channels.
30+
<h3>[name]( r, g, b )</h3>
31+
<div>
32+
r - the red component of the color if arguments g and b are defined. If they are not defined, it can be a hexadecimal or a CSS-style string or a Color instance.<br />
33+
g - The green component of the color if it is defined.<br />
34+
b - The blue component of the color if it is defined.
35+
</div>
36+
<div>
37+
All arguments are optional. The default color is White.<br />
38+
When all arguments are defined then r is the red component, g is the green component and b is the blue component of the color.<br />
39+
When only r is defined:<br />
40+
<ul>
41+
<li>It can be a hexadecimal of the color.</li>
42+
<li>It can be an another color instance.</li>
43+
<li>It can be a CSS style. For Instance:
44+
<ul>
45+
<li>rgb(250, 0,0)</li>
46+
<li>rgb(100%,0%,0%)</li>
47+
<li>hsl(0, 100%, 50%)</li>
48+
<li>#ff0000</li>
49+
<li>#f00</li>
50+
<li>red</li>
51+
</ul>
52+
53+
</li>
54+
</ul>
3355
</div>
3456

3557
<h2>Properties</h2>

src/math/Color.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
* @author mrdoob / http://mrdoob.com/
33
*/
44

5-
THREE.Color = function ( color ) {
5+
THREE.Color = function ( r, g, b ) {
66

7-
if ( arguments.length === 3 ) {
7+
if ( g === undefined && b === undefined ) {
88

9-
return this.fromArray( arguments );
9+
// r is THREE.Color, hex or string
10+
return this.set( r );
1011

1112
}
1213

13-
return this.set( color );
14+
return this.setRGB( r, g, b );
1415

1516
};
1617

0 commit comments

Comments
 (0)