ColorAdjustmentNode.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.ColorAdjustmentNode = function( rgb, adjustment, method ) {
  5. THREE.TempNode.call( this, 'v3' );
  6. this.rgb = rgb;
  7. this.adjustment = adjustment;
  8. this.method = method || THREE.ColorAdjustmentNode.SATURATION;
  9. };
  10. THREE.ColorAdjustmentNode.SATURATION = 'saturation';
  11. THREE.ColorAdjustmentNode.HUE = 'hue';
  12. THREE.ColorAdjustmentNode.VIBRANCE = 'vibrance';
  13. THREE.ColorAdjustmentNode.BRIGHTNESS = 'brightness';
  14. THREE.ColorAdjustmentNode.CONTRAST = 'contrast';
  15. THREE.ColorAdjustmentNode.prototype = Object.create( THREE.TempNode.prototype );
  16. THREE.ColorAdjustmentNode.prototype.constructor = THREE.ColorAdjustmentNode;
  17. THREE.ColorAdjustmentNode.prototype.generate = function( builder, output ) {
  18. var rgb = this.rgb.build( builder, 'v3' );
  19. var adjustment = this.adjustment.build( builder, 'fv1' );
  20. var name;
  21. switch ( this.method ) {
  22. case THREE.ColorAdjustmentNode.SATURATION:
  23. name = 'saturation_rgb';
  24. break;
  25. case THREE.ColorAdjustmentNode.HUE:
  26. name = 'hue_rgb';
  27. break;
  28. case THREE.ColorAdjustmentNode.VIBRANCE:
  29. name = 'vibrance_rgb';
  30. break;
  31. case THREE.ColorAdjustmentNode.BRIGHTNESS:
  32. return builder.format( '(' + rgb + '+' + adjustment + ')', this.getType( builder ), output );
  33. break;
  34. case THREE.ColorAdjustmentNode.CONTRAST:
  35. return builder.format( '(' + rgb + '*' + adjustment + ')', this.getType( builder ), output );
  36. break;
  37. }
  38. builder.include( name );
  39. return builder.format( name + '(' + rgb + ',' + adjustment + ')', this.getType( builder ), output );
  40. };