فهرست منبع

Warn more specifically on bad color specification (#25476)

Dan Rose 2 سال پیش
والد
کامیت
7cfd4702b6
1فایلهای تغییر یافته به همراه10 افزوده شده و 4 حذف شده
  1. 10 4
      src/math/Color.js

+ 10 - 4
src/math/Color.js

@@ -174,7 +174,7 @@ class Color {
 
 		let m;
 
-		if ( m = /^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec( style ) ) {
+		if ( m = /^(\w+)\(([^\)]*)\)/.exec( style ) ) {
 
 			// rgb / hsl
 
@@ -237,6 +237,10 @@ class Color {
 
 					break;
 
+				default:
+
+					console.warn( 'THREE.Color: Unknown color model ' + style );
+
 			}
 
 		} else if ( m = /^\#([A-Fa-f\d]+)$/.exec( style ) ) {
@@ -268,11 +272,13 @@ class Color {
 
 				return this;
 
-			}
+			} else {
 
-		}
+				console.warn( 'THREE.Color: Invalid hex color ' + style );
+
+			}
 
-		if ( style && style.length > 0 ) {
+		} else if ( style && style.length > 0 ) {
 
 			return this.setColorName( style, colorSpace );