Explorar o código

Add optionalTarget argument to Color#getHSL()

Ryan Alexander %!s(int64=11) %!d(string=hai) anos
pai
achega
4e36b7b64c
Modificáronse 1 ficheiros con 8 adicións e 6 borrados
  1. 8 6
      src/math/Color.js

+ 8 - 6
src/math/Color.js

@@ -223,10 +223,12 @@ THREE.Color.prototype = {
 
 	},
 
-	getHSL: function () {
+	getHSL: function ( optionalTarget ) {
 
 		// h,s,l ranges are in 0.0 - 1.0
 
+		var hsl = optionalTarget || { h: 0, s: 0, l: 0 };
+
 		var r = this.r, g = this.g, b = this.b;
 
 		var max = Math.max( r, g, b );
@@ -258,11 +260,11 @@ THREE.Color.prototype = {
 
 		}
 
-		return {
-			h: hue,
-			s: saturation,
-			l: lightness
-		};
+		hsl.h = hue;
+		hsl.s = saturation;
+		hsl.l = lightness;
+
+		return hsl;
 
 	},