Browse Source

Remove: ColorSpaceNode.fromDecoding() (#23217)

sunag 3 years ago
parent
commit
e2aec1b0e5

+ 8 - 28
examples/jsm/renderers/nodes/display/ColorSpaceNode.js

@@ -33,19 +33,6 @@ const EncodingLib = {
 	LinearTosRGB
 };
 
-function getEncodingComponents( encoding ) {
-
-	switch ( encoding ) {
-
-		case LinearEncoding:
-			return [ 'Linear' ];
-		case sRGBEncoding:
-			return [ 'sRGB' ];
-
-	}
-
-}
-
 class ColorSpaceNode extends TempNode {
 
 	static LINEAR_TO_LINEAR = 'LinearToLinear';
@@ -58,29 +45,24 @@ class ColorSpaceNode extends TempNode {
 		this.method = method;
 
 		this.node = node;
-		this.factor = null;
 
 	}
 
 	fromEncoding( encoding ) {
 
-		const components = getEncodingComponents( encoding );
+		let method = null;
 
-		this.method = 'LinearTo' + components[ 0 ];
-		this.factor = components[ 1 ];
+		if ( encoding === LinearEncoding ) {
 
-		return this;
+			method = 'Linear';
 
-	}
+		} else if ( encoding === sRGBEncoding ) {
 
-	fromDecoding() {
+			method = 'sRGB';
 
-		// TODO: Remove fromDecoding()
-
-		const components = getEncodingComponents( LinearEncoding );
+		}
 
-		this.method = components[ 0 ] + 'ToLinear';
-		this.factor = components[ 1 ];
+		this.method = 'LinearTo' + method;
 
 		return this;
 
@@ -96,11 +78,9 @@ class ColorSpaceNode extends TempNode {
 		if ( method !== ColorSpaceNode.LINEAR_TO_LINEAR ) {
 
 			const encodingFunctionNode = EncodingLib[ method ];
-			const factor = this.factor;
 
 			return encodingFunctionNode( {
-				value: node,
-				factor
+				value: node
 			} ).build( builder, type );
 
 		} else {

+ 5 - 10
examples/jsm/renderers/nodes/inputs/TextureNode.js

@@ -1,7 +1,6 @@
 import InputNode from '../core/InputNode.js';
 import ExpressionNode from '../core/ExpressionNode.js';
 import UVNode from '../accessors/UVNode.js';
-import ColorSpaceNode from '../display/ColorSpaceNode.js';
 
 class TextureNode extends InputNode {
 
@@ -41,9 +40,9 @@ class TextureNode extends InputNode {
 
 			const nodeData = builder.getDataFromNode( this );
 
-			let colorSpace = nodeData.colorSpace;
+			let snippet = nodeData.snippet;
 
-			if ( colorSpace === undefined ) {
+			if ( snippet === undefined ) {
 
 				const uvSnippet = this.uv.build( builder, 'vec2' );
 				const bias = this.bias;
@@ -56,17 +55,13 @@ class TextureNode extends InputNode {
 
 				}
 
-				const textureCallSnippet = builder.getTexture( textureProperty, uvSnippet, biasSnippet );
+				snippet = builder.getTexture( textureProperty, uvSnippet, biasSnippet );
 
-				colorSpace = new ColorSpaceNode();
-				colorSpace.node = new ExpressionNode( textureCallSnippet, 'vec4' );
-				colorSpace.fromDecoding( builder.getTextureEncodingFromMap( texture ) );
-
-				nodeData.colorSpace = colorSpace;
+				nodeData.snippet = snippet;
 
 			}
 
-			return colorSpace.build( builder, output );
+			return builder.format( snippet, 'vec4', output );
 
 		}