RawNode.js 896 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.RawNode = function ( value ) {
  5. THREE.GLNode.call( this, 'v4' );
  6. this.value = value;
  7. };
  8. THREE.RawNode.prototype = Object.create( THREE.GLNode.prototype );
  9. THREE.RawNode.prototype.constructor = THREE.RawNode;
  10. THREE.RawNode.prototype.nodeType = "Raw";
  11. THREE.RawNode.prototype.generate = function ( builder ) {
  12. var material = builder.material;
  13. var data = this.value.parseAndBuildCode( builder, this.type );
  14. var code = data.code + '\n';
  15. if ( builder.shader == 'vertex' ) {
  16. code += 'gl_Position = ' + data.result + ';';
  17. } else {
  18. code += 'gl_FragColor = ' + data.result + ';';
  19. }
  20. return code;
  21. };
  22. THREE.RawNode.prototype.toJSON = function ( meta ) {
  23. var data = this.getJSONNode( meta );
  24. if ( ! data ) {
  25. data = this.createJSONNode( meta );
  26. data.value = this.value.toJSON( meta ).uuid;
  27. }
  28. return data;
  29. };