From e2aec1b0e502ffd7822214e4e720a00cdccefa0a Mon Sep 17 00:00:00 2001 From: sunag Date: Thu, 13 Jan 2022 12:34:33 -0300 Subject: [PATCH] Remove: ColorSpaceNode.fromDecoding() (#23217) --- .../renderers/nodes/display/ColorSpaceNode.js | 36 +++++-------------- .../jsm/renderers/nodes/inputs/TextureNode.js | 15 +++----- 2 files changed, 13 insertions(+), 38 deletions(-) diff --git a/examples/jsm/renderers/nodes/display/ColorSpaceNode.js b/examples/jsm/renderers/nodes/display/ColorSpaceNode.js index 4015ad12e41cdb..a012bfcaf0c0f7 100644 --- a/examples/jsm/renderers/nodes/display/ColorSpaceNode.js +++ b/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 { diff --git a/examples/jsm/renderers/nodes/inputs/TextureNode.js b/examples/jsm/renderers/nodes/inputs/TextureNode.js index 675d80dd4658c4..36b8f97986d94b 100644 --- a/examples/jsm/renderers/nodes/inputs/TextureNode.js +++ b/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 ); }