BypassNode.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.BypassNode = function ( code, value ) {
  5. THREE.GLNode.call( this );
  6. this.code = code;
  7. this.value = value;
  8. };
  9. THREE.BypassNode.prototype = Object.create( THREE.GLNode.prototype );
  10. THREE.BypassNode.prototype.constructor = THREE.BypassNode;
  11. THREE.BypassNode.prototype.nodeType = "Bypass";
  12. THREE.BypassNode.prototype.getType = function ( builder ) {
  13. return this.value ? this.value.getType( builder ) : 'void';
  14. };
  15. THREE.BypassNode.prototype.generate = function ( builder, output ) {
  16. var code = this.code.build( builder, output ) + ';';
  17. if ( builder.isShader( 'fragment' ) ) {
  18. builder.material.addFragmentNode( code );
  19. } else {
  20. builder.material.addVertexNode( code );
  21. }
  22. if (this.value) {
  23. return this.value.build( builder, output );
  24. }
  25. };
  26. THREE.BypassNode.prototype.copy = function ( source ) {
  27. THREE.GLNode.prototype.copy.call( this, source );
  28. this.code = source.code;
  29. this.value = source.value;
  30. };
  31. THREE.BypassNode.prototype.toJSON = function ( meta ) {
  32. var data = this.getJSONNode( meta );
  33. if ( ! data ) {
  34. data = this.createJSONNode( meta );
  35. data.code = this.code.toJSON( meta ).uuid;
  36. if (this.value) data.value = this.value.toJSON( meta ).uuid;
  37. }
  38. return data;
  39. };