RawNode.js 987 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. import { Node } from '../../core/Node.js';
  5. function RawNode( value ) {
  6. Node.call( this, 'v4' );
  7. this.value = value;
  8. }
  9. RawNode.prototype = Object.create( Node.prototype );
  10. RawNode.prototype.constructor = RawNode;
  11. RawNode.prototype.nodeType = "Raw";
  12. RawNode.prototype.generate = function ( builder ) {
  13. var data = this.value.parseAndBuildCode( builder, this.type ),
  14. code = data.code + '\n';
  15. if ( builder.isShader( 'vertex' ) ) {
  16. code += 'gl_Position = ' + data.result + ';';
  17. } else {
  18. code += 'gl_FragColor = ' + data.result + ';';
  19. }
  20. return code;
  21. };
  22. RawNode.prototype.copy = function ( source ) {
  23. Node.prototype.copy.call( this, source );
  24. this.value = source.value;
  25. };
  26. RawNode.prototype.toJSON = function ( meta ) {
  27. var data = this.getJSONNode( meta );
  28. if ( ! data ) {
  29. data = this.createJSONNode( meta );
  30. data.value = this.value.toJSON( meta ).uuid;
  31. }
  32. return data;
  33. };
  34. export { RawNode };
粤ICP备19079148号