|
@@ -7814,19 +7814,6 @@
|
|
|
var _hslA = { h: 0, s: 0, l: 0 };
|
|
|
var _hslB = { h: 0, s: 0, l: 0 };
|
|
|
|
|
|
- function Color( r, g, b ) {
|
|
|
-
|
|
|
- if ( g === undefined && b === undefined ) {
|
|
|
-
|
|
|
- // r is THREE.Color, hex or string
|
|
|
- return this.set( r );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return this.setRGB( r, g, b );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
function hue2rgb( p, q, t ) {
|
|
|
|
|
|
if ( t < 0 ) { t += 1; }
|
|
@@ -7850,547 +7837,556 @@
|
|
|
|
|
|
}
|
|
|
|
|
|
- Object.assign( Color.prototype, {
|
|
|
+ var Color = function Color( r, g, b ) {
|
|
|
|
|
|
- isColor: true,
|
|
|
+ if ( g === undefined && b === undefined ) {
|
|
|
|
|
|
- r: 1, g: 1, b: 1,
|
|
|
+ // r is THREE.Color, hex or string
|
|
|
+ return this.set( r );
|
|
|
|
|
|
- set: function ( value ) {
|
|
|
+ }
|
|
|
|
|
|
- if ( value && value.isColor ) {
|
|
|
+ return this.setRGB( r, g, b );
|
|
|
|
|
|
- this.copy( value );
|
|
|
+ };
|
|
|
|
|
|
- } else if ( typeof value === 'number' ) {
|
|
|
+ Color.prototype.set = function set ( value ) {
|
|
|
|
|
|
- this.setHex( value );
|
|
|
+ if ( value && value.isColor ) {
|
|
|
|
|
|
- } else if ( typeof value === 'string' ) {
|
|
|
+ this.copy( value );
|
|
|
|
|
|
- this.setStyle( value );
|
|
|
+ } else if ( typeof value === 'number' ) {
|
|
|
|
|
|
- }
|
|
|
+ this.setHex( value );
|
|
|
|
|
|
- return this;
|
|
|
+ } else if ( typeof value === 'string' ) {
|
|
|
|
|
|
- },
|
|
|
+ this.setStyle( value );
|
|
|
|
|
|
- setScalar: function ( scalar ) {
|
|
|
+ }
|
|
|
|
|
|
- this.r = scalar;
|
|
|
- this.g = scalar;
|
|
|
- this.b = scalar;
|
|
|
+ return this;
|
|
|
|
|
|
- return this;
|
|
|
+ };
|
|
|
|
|
|
- },
|
|
|
+ Color.prototype.setScalar = function setScalar ( scalar ) {
|
|
|
|
|
|
- setHex: function ( hex ) {
|
|
|
+ this.r = scalar;
|
|
|
+ this.g = scalar;
|
|
|
+ this.b = scalar;
|
|
|
|
|
|
- hex = Math.floor( hex );
|
|
|
+ return this;
|
|
|
|
|
|
- this.r = ( hex >> 16 & 255 ) / 255;
|
|
|
- this.g = ( hex >> 8 & 255 ) / 255;
|
|
|
- this.b = ( hex & 255 ) / 255;
|
|
|
+ };
|
|
|
|
|
|
- return this;
|
|
|
+ Color.prototype.setHex = function setHex ( hex ) {
|
|
|
|
|
|
- },
|
|
|
+ hex = Math.floor( hex );
|
|
|
|
|
|
- setRGB: function ( r, g, b ) {
|
|
|
+ this.r = ( hex >> 16 & 255 ) / 255;
|
|
|
+ this.g = ( hex >> 8 & 255 ) / 255;
|
|
|
+ this.b = ( hex & 255 ) / 255;
|
|
|
|
|
|
- this.r = r;
|
|
|
- this.g = g;
|
|
|
- this.b = b;
|
|
|
+ return this;
|
|
|
|
|
|
- return this;
|
|
|
+ };
|
|
|
|
|
|
- },
|
|
|
+ Color.prototype.setRGB = function setRGB ( r, g, b ) {
|
|
|
|
|
|
- setHSL: function ( h, s, l ) {
|
|
|
+ this.r = r;
|
|
|
+ this.g = g;
|
|
|
+ this.b = b;
|
|
|
|
|
|
- // h,s,l ranges are in 0.0 - 1.0
|
|
|
- h = MathUtils.euclideanModulo( h, 1 );
|
|
|
- s = MathUtils.clamp( s, 0, 1 );
|
|
|
- l = MathUtils.clamp( l, 0, 1 );
|
|
|
+ return this;
|
|
|
|
|
|
- if ( s === 0 ) {
|
|
|
+ };
|
|
|
|
|
|
- this.r = this.g = this.b = l;
|
|
|
+ Color.prototype.setHSL = function setHSL ( h, s, l ) {
|
|
|
|
|
|
- } else {
|
|
|
+ // h,s,l ranges are in 0.0 - 1.0
|
|
|
+ h = MathUtils.euclideanModulo( h, 1 );
|
|
|
+ s = MathUtils.clamp( s, 0, 1 );
|
|
|
+ l = MathUtils.clamp( l, 0, 1 );
|
|
|
|
|
|
- var p = l <= 0.5 ? l * ( 1 + s ) : l + s - ( l * s );
|
|
|
- var q = ( 2 * l ) - p;
|
|
|
+ if ( s === 0 ) {
|
|
|
|
|
|
- this.r = hue2rgb( q, p, h + 1 / 3 );
|
|
|
- this.g = hue2rgb( q, p, h );
|
|
|
- this.b = hue2rgb( q, p, h - 1 / 3 );
|
|
|
+ this.r = this.g = this.b = l;
|
|
|
|
|
|
- }
|
|
|
+ } else {
|
|
|
|
|
|
- return this;
|
|
|
+ var p = l <= 0.5 ? l * ( 1 + s ) : l + s - ( l * s );
|
|
|
+ var q = ( 2 * l ) - p;
|
|
|
|
|
|
- },
|
|
|
+ this.r = hue2rgb( q, p, h + 1 / 3 );
|
|
|
+ this.g = hue2rgb( q, p, h );
|
|
|
+ this.b = hue2rgb( q, p, h - 1 / 3 );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return this;
|
|
|
|
|
|
- setStyle: function ( style ) {
|
|
|
+ };
|
|
|
|
|
|
- function handleAlpha( string ) {
|
|
|
+ Color.prototype.setStyle = function setStyle ( style ) {
|
|
|
|
|
|
- if ( string === undefined ) { return; }
|
|
|
+ function handleAlpha( string ) {
|
|
|
|
|
|
- if ( parseFloat( string ) < 1 ) {
|
|
|
+ if ( string === undefined ) { return; }
|
|
|
|
|
|
- console.warn( 'THREE.Color: Alpha component of ' + style + ' will be ignored.' );
|
|
|
+ if ( parseFloat( string ) < 1 ) {
|
|
|
|
|
|
- }
|
|
|
+ console.warn( 'THREE.Color: Alpha component of ' + style + ' will be ignored.' );
|
|
|
|
|
|
}
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- var m;
|
|
|
|
|
|
- if ( m = /^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec( style ) ) {
|
|
|
+ var m;
|
|
|
|
|
|
- // rgb / hsl
|
|
|
+ if ( m = /^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec( style ) ) {
|
|
|
|
|
|
- var color;
|
|
|
- var name = m[ 1 ];
|
|
|
- var components = m[ 2 ];
|
|
|
+ // rgb / hsl
|
|
|
|
|
|
- switch ( name ) {
|
|
|
+ var color;
|
|
|
+ var name = m[ 1 ];
|
|
|
+ var components = m[ 2 ];
|
|
|
|
|
|
- case 'rgb':
|
|
|
- case 'rgba':
|
|
|
+ switch ( name ) {
|
|
|
|
|
|
- if ( color = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
|
|
|
+ case 'rgb':
|
|
|
+ case 'rgba':
|
|
|
|
|
|
- // rgb(255,0,0) rgba(255,0,0,0.5)
|
|
|
- this.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;
|
|
|
- this.g = Math.min( 255, parseInt( color[ 2 ], 10 ) ) / 255;
|
|
|
- this.b = Math.min( 255, parseInt( color[ 3 ], 10 ) ) / 255;
|
|
|
+ if ( color = /^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
|
|
|
|
|
|
- handleAlpha( color[ 5 ] );
|
|
|
+ // rgb(255,0,0) rgba(255,0,0,0.5)
|
|
|
+ this.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;
|
|
|
+ this.g = Math.min( 255, parseInt( color[ 2 ], 10 ) ) / 255;
|
|
|
+ this.b = Math.min( 255, parseInt( color[ 3 ], 10 ) ) / 255;
|
|
|
|
|
|
- return this;
|
|
|
+ handleAlpha( color[ 5 ] );
|
|
|
|
|
|
- }
|
|
|
+ return this;
|
|
|
|
|
|
- if ( color = /^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
|
|
|
+ }
|
|
|
|
|
|
- // rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)
|
|
|
- this.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;
|
|
|
- this.g = Math.min( 100, parseInt( color[ 2 ], 10 ) ) / 100;
|
|
|
- this.b = Math.min( 100, parseInt( color[ 3 ], 10 ) ) / 100;
|
|
|
+ if ( color = /^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
|
|
|
|
|
|
- handleAlpha( color[ 5 ] );
|
|
|
+ // rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)
|
|
|
+ this.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;
|
|
|
+ this.g = Math.min( 100, parseInt( color[ 2 ], 10 ) ) / 100;
|
|
|
+ this.b = Math.min( 100, parseInt( color[ 3 ], 10 ) ) / 100;
|
|
|
|
|
|
- return this;
|
|
|
+ handleAlpha( color[ 5 ] );
|
|
|
|
|
|
- }
|
|
|
+ return this;
|
|
|
|
|
|
- break;
|
|
|
+ }
|
|
|
|
|
|
- case 'hsl':
|
|
|
- case 'hsla':
|
|
|
+ break;
|
|
|
|
|
|
- if ( color = /^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
|
|
|
+ case 'hsl':
|
|
|
+ case 'hsla':
|
|
|
|
|
|
- // hsl(120,50%,50%) hsla(120,50%,50%,0.5)
|
|
|
- var h = parseFloat( color[ 1 ] ) / 360;
|
|
|
- var s = parseInt( color[ 2 ], 10 ) / 100;
|
|
|
- var l = parseInt( color[ 3 ], 10 ) / 100;
|
|
|
+ if ( color = /^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec( components ) ) {
|
|
|
|
|
|
- handleAlpha( color[ 5 ] );
|
|
|
+ // hsl(120,50%,50%) hsla(120,50%,50%,0.5)
|
|
|
+ var h = parseFloat( color[ 1 ] ) / 360;
|
|
|
+ var s = parseInt( color[ 2 ], 10 ) / 100;
|
|
|
+ var l = parseInt( color[ 3 ], 10 ) / 100;
|
|
|
|
|
|
- return this.setHSL( h, s, l );
|
|
|
+ handleAlpha( color[ 5 ] );
|
|
|
|
|
|
- }
|
|
|
+ return this.setHSL( h, s, l );
|
|
|
|
|
|
- break;
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ break;
|
|
|
|
|
|
- } else if ( m = /^\#([A-Fa-f0-9]+)$/.exec( style ) ) {
|
|
|
+ }
|
|
|
|
|
|
- // hex color
|
|
|
+ } else if ( m = /^\#([A-Fa-f0-9]+)$/.exec( style ) ) {
|
|
|
|
|
|
- var hex = m[ 1 ];
|
|
|
- var size = hex.length;
|
|
|
+ // hex color
|
|
|
|
|
|
- if ( size === 3 ) {
|
|
|
+ var hex = m[ 1 ];
|
|
|
+ var size = hex.length;
|
|
|
|
|
|
- // #ff0
|
|
|
- this.r = parseInt( hex.charAt( 0 ) + hex.charAt( 0 ), 16 ) / 255;
|
|
|
- this.g = parseInt( hex.charAt( 1 ) + hex.charAt( 1 ), 16 ) / 255;
|
|
|
- this.b = parseInt( hex.charAt( 2 ) + hex.charAt( 2 ), 16 ) / 255;
|
|
|
+ if ( size === 3 ) {
|
|
|
|
|
|
- return this;
|
|
|
+ // #ff0
|
|
|
+ this.r = parseInt( hex.charAt( 0 ) + hex.charAt( 0 ), 16 ) / 255;
|
|
|
+ this.g = parseInt( hex.charAt( 1 ) + hex.charAt( 1 ), 16 ) / 255;
|
|
|
+ this.b = parseInt( hex.charAt( 2 ) + hex.charAt( 2 ), 16 ) / 255;
|
|
|
|
|
|
- } else if ( size === 6 ) {
|
|
|
+ return this;
|
|
|
|
|
|
- // #ff0000
|
|
|
- this.r = parseInt( hex.charAt( 0 ) + hex.charAt( 1 ), 16 ) / 255;
|
|
|
- this.g = parseInt( hex.charAt( 2 ) + hex.charAt( 3 ), 16 ) / 255;
|
|
|
- this.b = parseInt( hex.charAt( 4 ) + hex.charAt( 5 ), 16 ) / 255;
|
|
|
+ } else if ( size === 6 ) {
|
|
|
|
|
|
- return this;
|
|
|
+ // #ff0000
|
|
|
+ this.r = parseInt( hex.charAt( 0 ) + hex.charAt( 1 ), 16 ) / 255;
|
|
|
+ this.g = parseInt( hex.charAt( 2 ) + hex.charAt( 3 ), 16 ) / 255;
|
|
|
+ this.b = parseInt( hex.charAt( 4 ) + hex.charAt( 5 ), 16 ) / 255;
|
|
|
|
|
|
- }
|
|
|
+ return this;
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( style && style.length > 0 ) {
|
|
|
-
|
|
|
- return this.setColorName( style );
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ if ( style && style.length > 0 ) {
|
|
|
|
|
|
- return this;
|
|
|
+ return this.setColorName( style );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- setColorName: function ( style ) {
|
|
|
+ return this;
|
|
|
|
|
|
- // color keywords
|
|
|
- var hex = _colorKeywords[ style ];
|
|
|
+ };
|
|
|
|
|
|
- if ( hex !== undefined ) {
|
|
|
+ Color.prototype.setColorName = function setColorName ( style ) {
|
|
|
|
|
|
- // red
|
|
|
- this.setHex( hex );
|
|
|
+ // color keywords
|
|
|
+ var hex = _colorKeywords[ style ];
|
|
|
|
|
|
- } else {
|
|
|
+ if ( hex !== undefined ) {
|
|
|
|
|
|
- // unknown color
|
|
|
- console.warn( 'THREE.Color: Unknown color ' + style );
|
|
|
+ // red
|
|
|
+ this.setHex( hex );
|
|
|
|
|
|
- }
|
|
|
+ } else {
|
|
|
|
|
|
- return this;
|
|
|
+ // unknown color
|
|
|
+ console.warn( 'THREE.Color: Unknown color ' + style );
|
|
|
|
|
|
- },
|
|
|
+ }
|
|
|
|
|
|
- clone: function () {
|
|
|
+ return this;
|
|
|
|
|
|
- return new this.constructor( this.r, this.g, this.b );
|
|
|
+ };
|
|
|
|
|
|
- },
|
|
|
+ Color.prototype.clone = function clone () {
|
|
|
|
|
|
- copy: function ( color ) {
|
|
|
+ return new this.constructor( this.r, this.g, this.b );
|
|
|
|
|
|
- this.r = color.r;
|
|
|
- this.g = color.g;
|
|
|
- this.b = color.b;
|
|
|
+ };
|
|
|
|
|
|
- return this;
|
|
|
+ Color.prototype.copy = function copy ( color ) {
|
|
|
|
|
|
- },
|
|
|
+ this.r = color.r;
|
|
|
+ this.g = color.g;
|
|
|
+ this.b = color.b;
|
|
|
|
|
|
- copyGammaToLinear: function ( color, gammaFactor ) {
|
|
|
+ return this;
|
|
|
|
|
|
- if ( gammaFactor === undefined ) { gammaFactor = 2.0; }
|
|
|
+ };
|
|
|
|
|
|
- this.r = Math.pow( color.r, gammaFactor );
|
|
|
- this.g = Math.pow( color.g, gammaFactor );
|
|
|
- this.b = Math.pow( color.b, gammaFactor );
|
|
|
+ Color.prototype.copyGammaToLinear = function copyGammaToLinear ( color, gammaFactor ) {
|
|
|
|
|
|
- return this;
|
|
|
+ if ( gammaFactor === undefined ) { gammaFactor = 2.0; }
|
|
|
|
|
|
- },
|
|
|
+ this.r = Math.pow( color.r, gammaFactor );
|
|
|
+ this.g = Math.pow( color.g, gammaFactor );
|
|
|
+ this.b = Math.pow( color.b, gammaFactor );
|
|
|
|
|
|
- copyLinearToGamma: function ( color, gammaFactor ) {
|
|
|
+ return this;
|
|
|
|
|
|
- if ( gammaFactor === undefined ) { gammaFactor = 2.0; }
|
|
|
+ };
|
|
|
|
|
|
- var safeInverse = ( gammaFactor > 0 ) ? ( 1.0 / gammaFactor ) : 1.0;
|
|
|
+ Color.prototype.copyLinearToGamma = function copyLinearToGamma ( color, gammaFactor ) {
|
|
|
|
|
|
- this.r = Math.pow( color.r, safeInverse );
|
|
|
- this.g = Math.pow( color.g, safeInverse );
|
|
|
- this.b = Math.pow( color.b, safeInverse );
|
|
|
+ if ( gammaFactor === undefined ) { gammaFactor = 2.0; }
|
|
|
|
|
|
- return this;
|
|
|
+ var safeInverse = ( gammaFactor > 0 ) ? ( 1.0 / gammaFactor ) : 1.0;
|
|
|
|
|
|
- },
|
|
|
+ this.r = Math.pow( color.r, safeInverse );
|
|
|
+ this.g = Math.pow( color.g, safeInverse );
|
|
|
+ this.b = Math.pow( color.b, safeInverse );
|
|
|
|
|
|
- convertGammaToLinear: function ( gammaFactor ) {
|
|
|
+ return this;
|
|
|
|
|
|
- this.copyGammaToLinear( this, gammaFactor );
|
|
|
+ };
|
|
|
|
|
|
- return this;
|
|
|
+ Color.prototype.convertGammaToLinear = function convertGammaToLinear ( gammaFactor ) {
|
|
|
|
|
|
- },
|
|
|
+ this.copyGammaToLinear( this, gammaFactor );
|
|
|
|
|
|
- convertLinearToGamma: function ( gammaFactor ) {
|
|
|
+ return this;
|
|
|
|
|
|
- this.copyLinearToGamma( this, gammaFactor );
|
|
|
+ };
|
|
|
|
|
|
- return this;
|
|
|
+ Color.prototype.convertLinearToGamma = function convertLinearToGamma ( gammaFactor ) {
|
|
|
|
|
|
- },
|
|
|
+ this.copyLinearToGamma( this, gammaFactor );
|
|
|
|
|
|
- copySRGBToLinear: function ( color ) {
|
|
|
+ return this;
|
|
|
|
|
|
- this.r = SRGBToLinear( color.r );
|
|
|
- this.g = SRGBToLinear( color.g );
|
|
|
- this.b = SRGBToLinear( color.b );
|
|
|
+ };
|
|
|
|
|
|
- return this;
|
|
|
+ Color.prototype.copySRGBToLinear = function copySRGBToLinear ( color ) {
|
|
|
|
|
|
- },
|
|
|
+ this.r = SRGBToLinear( color.r );
|
|
|
+ this.g = SRGBToLinear( color.g );
|
|
|
+ this.b = SRGBToLinear( color.b );
|
|
|
|
|
|
- copyLinearToSRGB: function ( color ) {
|
|
|
+ return this;
|
|
|
|
|
|
- this.r = LinearToSRGB( color.r );
|
|
|
- this.g = LinearToSRGB( color.g );
|
|
|
- this.b = LinearToSRGB( color.b );
|
|
|
+ };
|
|
|
|
|
|
- return this;
|
|
|
+ Color.prototype.copyLinearToSRGB = function copyLinearToSRGB ( color ) {
|
|
|
|
|
|
- },
|
|
|
+ this.r = LinearToSRGB( color.r );
|
|
|
+ this.g = LinearToSRGB( color.g );
|
|
|
+ this.b = LinearToSRGB( color.b );
|
|
|
|
|
|
- convertSRGBToLinear: function () {
|
|
|
+ return this;
|
|
|
|
|
|
- this.copySRGBToLinear( this );
|
|
|
+ };
|
|
|
|
|
|
- return this;
|
|
|
+ Color.prototype.convertSRGBToLinear = function convertSRGBToLinear () {
|
|
|
|
|
|
- },
|
|
|
+ this.copySRGBToLinear( this );
|
|
|
|
|
|
- convertLinearToSRGB: function () {
|
|
|
+ return this;
|
|
|
|
|
|
- this.copyLinearToSRGB( this );
|
|
|
+ };
|
|
|
|
|
|
- return this;
|
|
|
+ Color.prototype.convertLinearToSRGB = function convertLinearToSRGB () {
|
|
|
|
|
|
- },
|
|
|
+ this.copyLinearToSRGB( this );
|
|
|
|
|
|
- getHex: function () {
|
|
|
+ return this;
|
|
|
|
|
|
- return ( this.r * 255 ) << 16 ^ ( this.g * 255 ) << 8 ^ ( this.b * 255 ) << 0;
|
|
|
+ };
|
|
|
|
|
|
- },
|
|
|
+ Color.prototype.getHex = function getHex () {
|
|
|
|
|
|
- getHexString: function () {
|
|
|
+ return ( this.r * 255 ) << 16 ^ ( this.g * 255 ) << 8 ^ ( this.b * 255 ) << 0;
|
|
|
|
|
|
- return ( '000000' + this.getHex().toString( 16 ) ).slice( - 6 );
|
|
|
+ };
|
|
|
|
|
|
- },
|
|
|
+ Color.prototype.getHexString = function getHexString () {
|
|
|
|
|
|
- getHSL: function ( target ) {
|
|
|
+ return ( '000000' + this.getHex().toString( 16 ) ).slice( - 6 );
|
|
|
|
|
|
- // h,s,l ranges are in 0.0 - 1.0
|
|
|
+ };
|
|
|
|
|
|
- if ( target === undefined ) {
|
|
|
+ Color.prototype.getHSL = function getHSL ( target ) {
|
|
|
|
|
|
- console.warn( 'THREE.Color: .getHSL() target is now required' );
|
|
|
- target = { h: 0, s: 0, l: 0 };
|
|
|
+ // h,s,l ranges are in 0.0 - 1.0
|
|
|
|
|
|
- }
|
|
|
+ if ( target === undefined ) {
|
|
|
|
|
|
- var r = this.r, g = this.g, b = this.b;
|
|
|
+ console.warn( 'THREE.Color: .getHSL() target is now required' );
|
|
|
+ target = { h: 0, s: 0, l: 0 };
|
|
|
|
|
|
- var max = Math.max( r, g, b );
|
|
|
- var min = Math.min( r, g, b );
|
|
|
+ }
|
|
|
|
|
|
- var hue, saturation;
|
|
|
- var lightness = ( min + max ) / 2.0;
|
|
|
+ var r = this.r, g = this.g, b = this.b;
|
|
|
|
|
|
- if ( min === max ) {
|
|
|
+ var max = Math.max( r, g, b );
|
|
|
+ var min = Math.min( r, g, b );
|
|
|
|
|
|
- hue = 0;
|
|
|
- saturation = 0;
|
|
|
+ var hue, saturation;
|
|
|
+ var lightness = ( min + max ) / 2.0;
|
|
|
|
|
|
- } else {
|
|
|
+ if ( min === max ) {
|
|
|
|
|
|
- var delta = max - min;
|
|
|
+ hue = 0;
|
|
|
+ saturation = 0;
|
|
|
|
|
|
- saturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min );
|
|
|
+ } else {
|
|
|
|
|
|
- switch ( max ) {
|
|
|
+ var delta = max - min;
|
|
|
|
|
|
- case r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break;
|
|
|
- case g: hue = ( b - r ) / delta + 2; break;
|
|
|
- case b: hue = ( r - g ) / delta + 4; break;
|
|
|
+ saturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min );
|
|
|
|
|
|
- }
|
|
|
+ switch ( max ) {
|
|
|
|
|
|
- hue /= 6;
|
|
|
+ case r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break;
|
|
|
+ case g: hue = ( b - r ) / delta + 2; break;
|
|
|
+ case b: hue = ( r - g ) / delta + 4; break;
|
|
|
|
|
|
}
|
|
|
|
|
|
- target.h = hue;
|
|
|
- target.s = saturation;
|
|
|
- target.l = lightness;
|
|
|
+ hue /= 6;
|
|
|
|
|
|
- return target;
|
|
|
+ }
|
|
|
|
|
|
- },
|
|
|
+ target.h = hue;
|
|
|
+ target.s = saturation;
|
|
|
+ target.l = lightness;
|
|
|
|
|
|
- getStyle: function () {
|
|
|
+ return target;
|
|
|
|
|
|
- return 'rgb(' + ( ( this.r * 255 ) | 0 ) + ',' + ( ( this.g * 255 ) | 0 ) + ',' + ( ( this.b * 255 ) | 0 ) + ')';
|
|
|
+ };
|
|
|
|
|
|
- },
|
|
|
+ Color.prototype.getStyle = function getStyle () {
|
|
|
|
|
|
- offsetHSL: function ( h, s, l ) {
|
|
|
+ return 'rgb(' + ( ( this.r * 255 ) | 0 ) + ',' + ( ( this.g * 255 ) | 0 ) + ',' + ( ( this.b * 255 ) | 0 ) + ')';
|
|
|
|
|
|
- this.getHSL( _hslA );
|
|
|
+ };
|
|
|
|
|
|
- _hslA.h += h; _hslA.s += s; _hslA.l += l;
|
|
|
+ Color.prototype.offsetHSL = function offsetHSL ( h, s, l ) {
|
|
|
|
|
|
- this.setHSL( _hslA.h, _hslA.s, _hslA.l );
|
|
|
+ this.getHSL( _hslA );
|
|
|
|
|
|
- return this;
|
|
|
+ _hslA.h += h; _hslA.s += s; _hslA.l += l;
|
|
|
|
|
|
- },
|
|
|
+ this.setHSL( _hslA.h, _hslA.s, _hslA.l );
|
|
|
|
|
|
- add: function ( color ) {
|
|
|
+ return this;
|
|
|
|
|
|
- this.r += color.r;
|
|
|
- this.g += color.g;
|
|
|
- this.b += color.b;
|
|
|
+ };
|
|
|
|
|
|
- return this;
|
|
|
+ Color.prototype.add = function add ( color ) {
|
|
|
|
|
|
- },
|
|
|
+ this.r += color.r;
|
|
|
+ this.g += color.g;
|
|
|
+ this.b += color.b;
|
|
|
+
|
|
|
+ return this;
|
|
|
|
|
|
- addColors: function ( color1, color2 ) {
|
|
|
+ };
|
|
|
|
|
|
- this.r = color1.r + color2.r;
|
|
|
- this.g = color1.g + color2.g;
|
|
|
- this.b = color1.b + color2.b;
|
|
|
+ Color.prototype.addColors = function addColors ( color1, color2 ) {
|
|
|
|
|
|
- return this;
|
|
|
+ this.r = color1.r + color2.r;
|
|
|
+ this.g = color1.g + color2.g;
|
|
|
+ this.b = color1.b + color2.b;
|
|
|
|
|
|
- },
|
|
|
+ return this;
|
|
|
|
|
|
- addScalar: function ( s ) {
|
|
|
+ };
|
|
|
|
|
|
- this.r += s;
|
|
|
- this.g += s;
|
|
|
- this.b += s;
|
|
|
+ Color.prototype.addScalar = function addScalar ( s ) {
|
|
|
|
|
|
- return this;
|
|
|
+ this.r += s;
|
|
|
+ this.g += s;
|
|
|
+ this.b += s;
|
|
|
|
|
|
- },
|
|
|
+ return this;
|
|
|
|
|
|
- sub: function ( color ) {
|
|
|
+ };
|
|
|
|
|
|
- this.r = Math.max( 0, this.r - color.r );
|
|
|
- this.g = Math.max( 0, this.g - color.g );
|
|
|
- this.b = Math.max( 0, this.b - color.b );
|
|
|
+ Color.prototype.sub = function sub ( color ) {
|
|
|
|
|
|
- return this;
|
|
|
+ this.r = Math.max( 0, this.r - color.r );
|
|
|
+ this.g = Math.max( 0, this.g - color.g );
|
|
|
+ this.b = Math.max( 0, this.b - color.b );
|
|
|
|
|
|
- },
|
|
|
+ return this;
|
|
|
|
|
|
- multiply: function ( color ) {
|
|
|
+ };
|
|
|
|
|
|
- this.r *= color.r;
|
|
|
- this.g *= color.g;
|
|
|
- this.b *= color.b;
|
|
|
+ Color.prototype.multiply = function multiply ( color ) {
|
|
|
|
|
|
- return this;
|
|
|
+ this.r *= color.r;
|
|
|
+ this.g *= color.g;
|
|
|
+ this.b *= color.b;
|
|
|
|
|
|
- },
|
|
|
+ return this;
|
|
|
|
|
|
- multiplyScalar: function ( s ) {
|
|
|
+ };
|
|
|
|
|
|
- this.r *= s;
|
|
|
- this.g *= s;
|
|
|
- this.b *= s;
|
|
|
+ Color.prototype.multiplyScalar = function multiplyScalar ( s ) {
|
|
|
|
|
|
- return this;
|
|
|
+ this.r *= s;
|
|
|
+ this.g *= s;
|
|
|
+ this.b *= s;
|
|
|
|
|
|
- },
|
|
|
+ return this;
|
|
|
|
|
|
- lerp: function ( color, alpha ) {
|
|
|
+ };
|
|
|
|
|
|
- this.r += ( color.r - this.r ) * alpha;
|
|
|
- this.g += ( color.g - this.g ) * alpha;
|
|
|
- this.b += ( color.b - this.b ) * alpha;
|
|
|
+ Color.prototype.lerp = function lerp ( color, alpha ) {
|
|
|
|
|
|
- return this;
|
|
|
+ this.r += ( color.r - this.r ) * alpha;
|
|
|
+ this.g += ( color.g - this.g ) * alpha;
|
|
|
+ this.b += ( color.b - this.b ) * alpha;
|
|
|
|
|
|
- },
|
|
|
+ return this;
|
|
|
|
|
|
- lerpHSL: function ( color, alpha ) {
|
|
|
+ };
|
|
|
|
|
|
- this.getHSL( _hslA );
|
|
|
- color.getHSL( _hslB );
|
|
|
+ Color.prototype.lerpHSL = function lerpHSL ( color, alpha ) {
|
|
|
|
|
|
- var h = MathUtils.lerp( _hslA.h, _hslB.h, alpha );
|
|
|
- var s = MathUtils.lerp( _hslA.s, _hslB.s, alpha );
|
|
|
- var l = MathUtils.lerp( _hslA.l, _hslB.l, alpha );
|
|
|
+ this.getHSL( _hslA );
|
|
|
+ color.getHSL( _hslB );
|
|
|
|
|
|
- this.setHSL( h, s, l );
|
|
|
+ var h = MathUtils.lerp( _hslA.h, _hslB.h, alpha );
|
|
|
+ var s = MathUtils.lerp( _hslA.s, _hslB.s, alpha );
|
|
|
+ var l = MathUtils.lerp( _hslA.l, _hslB.l, alpha );
|
|
|
|
|
|
- return this;
|
|
|
+ this.setHSL( h, s, l );
|
|
|
|
|
|
- },
|
|
|
+ return this;
|
|
|
|
|
|
- equals: function ( c ) {
|
|
|
+ };
|
|
|
|
|
|
- return ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b );
|
|
|
+ Color.prototype.equals = function equals ( c ) {
|
|
|
|
|
|
- },
|
|
|
+ return ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b );
|
|
|
|
|
|
- fromArray: function ( array, offset ) {
|
|
|
+ };
|
|
|
|
|
|
- if ( offset === undefined ) { offset = 0; }
|
|
|
+ Color.prototype.fromArray = function fromArray ( array, offset ) {
|
|
|
|
|
|
- this.r = array[ offset ];
|
|
|
- this.g = array[ offset + 1 ];
|
|
|
- this.b = array[ offset + 2 ];
|
|
|
+ if ( offset === undefined ) { offset = 0; }
|
|
|
|
|
|
- return this;
|
|
|
+ this.r = array[ offset ];
|
|
|
+ this.g = array[ offset + 1 ];
|
|
|
+ this.b = array[ offset + 2 ];
|
|
|
|
|
|
- },
|
|
|
+ return this;
|
|
|
|
|
|
- toArray: function ( array, offset ) {
|
|
|
+ };
|
|
|
|
|
|
- if ( array === undefined ) { array = []; }
|
|
|
- if ( offset === undefined ) { offset = 0; }
|
|
|
+ Color.prototype.toArray = function toArray ( array, offset ) {
|
|
|
|
|
|
- array[ offset ] = this.r;
|
|
|
- array[ offset + 1 ] = this.g;
|
|
|
- array[ offset + 2 ] = this.b;
|
|
|
+ if ( array === undefined ) { array = []; }
|
|
|
+ if ( offset === undefined ) { offset = 0; }
|
|
|
|
|
|
- return array;
|
|
|
+ array[ offset ] = this.r;
|
|
|
+ array[ offset + 1 ] = this.g;
|
|
|
+ array[ offset + 2 ] = this.b;
|
|
|
|
|
|
- },
|
|
|
+ return array;
|
|
|
|
|
|
- fromBufferAttribute: function ( attribute, index ) {
|
|
|
+ };
|
|
|
|
|
|
- this.r = attribute.getX( index );
|
|
|
- this.g = attribute.getY( index );
|
|
|
- this.b = attribute.getZ( index );
|
|
|
+ Color.prototype.fromBufferAttribute = function fromBufferAttribute ( attribute, index ) {
|
|
|
|
|
|
- if ( attribute.normalized === true ) {
|
|
|
+ this.r = attribute.getX( index );
|
|
|
+ this.g = attribute.getY( index );
|
|
|
+ this.b = attribute.getZ( index );
|
|
|
|
|
|
- // assuming Uint8Array
|
|
|
+ if ( attribute.normalized === true ) {
|
|
|
|
|
|
- this.r /= 255;
|
|
|
- this.g /= 255;
|
|
|
- this.b /= 255;
|
|
|
+ // assuming Uint8Array
|
|
|
|
|
|
- }
|
|
|
+ this.r /= 255;
|
|
|
+ this.g /= 255;
|
|
|
+ this.b /= 255;
|
|
|
|
|
|
- return this;
|
|
|
+ }
|
|
|
|
|
|
- },
|
|
|
+ return this;
|
|
|
|
|
|
- toJSON: function () {
|
|
|
+ };
|
|
|
|
|
|
- return this.getHex();
|
|
|
+ Color.prototype.toJSON = function toJSON () {
|
|
|
|
|
|
- }
|
|
|
+ return this.getHex();
|
|
|
|
|
|
- } );
|
|
|
+ };
|
|
|
|
|
|
Color.NAMES = _colorKeywords;
|
|
|
+ Color.prototype.isColor = true;
|
|
|
+ Color.prototype.r = 1;
|
|
|
+ Color.prototype.g = 1;
|
|
|
+ Color.prototype.b = 1;
|
|
|
|
|
|
var Face3 = function Face3( a, b, c, normal, color, materialIndex ) {
|
|
|
|