Przeglądaj źródła

Add optionalTarget argument to Color#getHSL()

Ryan Alexander 11 lat temu
rodzic
commit
4e36b7b64c
1 zmienionych plików z 8 dodań i 6 usunięć
  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;
 
 	},