From 27d854ec5e80ed20b1be820b215b32e48a712e70 Mon Sep 17 00:00:00 2001 From: SUNAG Date: Sat, 26 Dec 2015 03:23:29 -0200 Subject: [PATCH] new ColorAdjustmentNode --- .../js/nodes/utils/ColorAdjustmentNode.js | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 examples/js/nodes/utils/ColorAdjustmentNode.js diff --git a/examples/js/nodes/utils/ColorAdjustmentNode.js b/examples/js/nodes/utils/ColorAdjustmentNode.js new file mode 100644 index 0000000000..590d1ca995 --- /dev/null +++ b/examples/js/nodes/utils/ColorAdjustmentNode.js @@ -0,0 +1,70 @@ +/** + * @author sunag / http://www.sunag.com.br/ + */ + +THREE.ColorAdjustmentNode = function( rgb, adjustment, method ) { + + THREE.TempNode.call( this, 'v3' ); + + this.rgb = rgb; + this.adjustment = adjustment; + + this.method = method || THREE.ColorAdjustmentNode.SATURATION; + +}; + +THREE.ColorAdjustmentNode.SATURATION = 'saturation'; +THREE.ColorAdjustmentNode.HUE = 'hue'; +THREE.ColorAdjustmentNode.VIBRANCE = 'vibrance'; +THREE.ColorAdjustmentNode.BRIGHTNESS = 'brightness'; +THREE.ColorAdjustmentNode.CONTRAST = 'contrast'; + +THREE.ColorAdjustmentNode.prototype = Object.create( THREE.TempNode.prototype ); +THREE.ColorAdjustmentNode.prototype.constructor = THREE.ColorAdjustmentNode; + +THREE.ColorAdjustmentNode.prototype.generate = function( builder, output ) { + + var rgb = this.rgb.build( builder, 'v3' ); + var adjustment = this.adjustment.build( builder, 'fv1' ); + + var name; + + switch ( this.method ) { + + case THREE.ColorAdjustmentNode.SATURATION: + + name = 'saturation_rgb'; + + break; + + case THREE.ColorAdjustmentNode.HUE: + + name = 'hue_rgb'; + + break; + + case THREE.ColorAdjustmentNode.VIBRANCE: + + name = 'vibrance_rgb'; + + break; + + case THREE.ColorAdjustmentNode.BRIGHTNESS: + + return builder.format( '(' + rgb + '+' + adjustment + ')', this.getType( builder ), output ); + + break; + + case THREE.ColorAdjustmentNode.CONTRAST: + + return builder.format( '(' + rgb + '*' + adjustment + ')', this.getType( builder ), output ); + + break; + + } + + builder.include( name ); + + return builder.format( name + '(' + rgb + ',' + adjustment + ')', this.getType( builder ), output ); + +}; -- GitLab