|
@@ -203,6 +203,29 @@ ColorSpaceNode.LINEAR_TO_RGBD = 'LinearToRGBD';
|
|
|
ColorSpaceNode.LINEAR_TO_LOG_LUV = 'LinearToLogLuv';
|
|
|
ColorSpaceNode.LOG_LUV_TO_LINEAR = 'LogLuvToLinear';
|
|
|
|
|
|
+ColorSpaceNode.getEncodingComponents = function ( encoding ) {
|
|
|
+
|
|
|
+ switch ( encoding ) {
|
|
|
+
|
|
|
+ case THREE.LinearEncoding:
|
|
|
+ return [ 'Linear' ];
|
|
|
+ case THREE.sRGBEncoding:
|
|
|
+ return [ 'sRGB' ];
|
|
|
+ case THREE.RGBEEncoding:
|
|
|
+ return [ 'RGBE' ];
|
|
|
+ case THREE.RGBM7Encoding:
|
|
|
+ return [ 'RGBM', new FloatNode( 7.0 ).setReadonly( true ) ];
|
|
|
+ case THREE.RGBM16Encoding:
|
|
|
+ return [ 'RGBM', new FloatNode( 16.0 ).setReadonly( true ) ];
|
|
|
+ case THREE.RGBDEncoding:
|
|
|
+ return [ 'RGBD', new FloatNode( 256.0 ).setReadonly( true ) ];
|
|
|
+ case THREE.GammaEncoding:
|
|
|
+ return [ 'Gamma', new ExpressionNode( 'float( GAMMA_FACTOR )' ) ];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+};
|
|
|
+
|
|
|
ColorSpaceNode.prototype = Object.create( TempNode.prototype );
|
|
|
ColorSpaceNode.prototype.constructor = ColorSpaceNode;
|
|
|
ColorSpaceNode.prototype.nodeType = "ColorSpace";
|
|
@@ -210,53 +233,38 @@ ColorSpaceNode.prototype.nodeType = "ColorSpace";
|
|
|
ColorSpaceNode.prototype.generate = function ( builder, output ) {
|
|
|
|
|
|
var input = this.input.build( builder, 'v4' );
|
|
|
- var method = [ this.method ];
|
|
|
- var factor = this.factor ? this.factor.build( builder, 'f' ) : method[ 1 ];
|
|
|
-
|
|
|
- method = builder.include( ColorSpaceNode.Nodes[ method[ 0 ] ] );
|
|
|
|
|
|
- if ( factor ) {
|
|
|
+ if ( this.method === ColorSpaceNode.LINEAR_TO_LINEAR ) {
|
|
|
|
|
|
- return builder.format( method + '( ' + input + ', ' + factor + ' )', this.getType( builder ), output );
|
|
|
+ return builder.format( input, this.getType( builder ), output );
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- return builder.format( method + '( ' + input + ' )', this.getType( builder ), output );
|
|
|
+ var method = [ this.method ];
|
|
|
+ var factor = this.factor ? this.factor.build( builder, 'f' ) : method[ 1 ];
|
|
|
|
|
|
- }
|
|
|
+ method = builder.include( ColorSpaceNode.Nodes[ method[ 0 ] ] );
|
|
|
|
|
|
-};
|
|
|
+ if ( factor ) {
|
|
|
|
|
|
-ColorSpaceNode.getEncodingMethodFromEncoding = function ( encoding ) {
|
|
|
+ return builder.format( method + '( ' + input + ', ' + factor + ' )', this.getType( builder ), output );
|
|
|
|
|
|
- var components = this.getEncodingComponents( encoding );
|
|
|
+ } else {
|
|
|
|
|
|
- components[ 0 ] = 'LinearTo' + components[ 0 ];
|
|
|
+ return builder.format( method + '( ' + input + ' )', this.getType( builder ), output );
|
|
|
|
|
|
- return components;
|
|
|
+ }
|
|
|
|
|
|
-};
|
|
|
+ }
|
|
|
|
|
|
-ColorSpaceNode.getEncodingComponents = function ( encoding ) {
|
|
|
+};
|
|
|
|
|
|
- switch ( encoding ) {
|
|
|
+ColorSpaceNode.prototype.fromEncoding = function ( encoding ) {
|
|
|
|
|
|
- case THREE.LinearEncoding:
|
|
|
- return [ 'Linear' ];
|
|
|
- case THREE.sRGBEncoding:
|
|
|
- return [ 'sRGB' ];
|
|
|
- case THREE.RGBEEncoding:
|
|
|
- return [ 'RGBE' ];
|
|
|
- case THREE.RGBM7Encoding:
|
|
|
- return [ 'RGBM', new FloatNode( 7.0 ).setReadonly( true ) ];
|
|
|
- case THREE.RGBM16Encoding:
|
|
|
- return [ 'RGBM', new FloatNode( 16.0 ).setReadonly( true ) ];
|
|
|
- case THREE.RGBDEncoding:
|
|
|
- return [ 'RGBD', new FloatNode( 256.0 ).setReadonly( true ) ];
|
|
|
- case THREE.GammaEncoding:
|
|
|
- return [ 'Gamma', new ExpressionNode( 'float( GAMMA_FACTOR )' ) ];
|
|
|
+ var components = ColorSpaceNode.getEncodingComponents( encoding );
|
|
|
|
|
|
- }
|
|
|
+ this.method = 'LinearTo' + components[ 0 ];
|
|
|
+ this.factor = components[ 1 ];
|
|
|
|
|
|
};
|
|
|
|
|
@@ -264,9 +272,7 @@ ColorSpaceNode.prototype.fromDecoding = function ( encoding ) {
|
|
|
|
|
|
var components = ColorSpaceNode.getEncodingComponents( encoding );
|
|
|
|
|
|
- components[ 0 ] += 'ToLinear';
|
|
|
-
|
|
|
- this.method = components[ 0 ];
|
|
|
+ this.method = components[ 0 ] + 'ToLinear';
|
|
|
this.factor = components[ 1 ];
|
|
|
|
|
|
};
|