RawNode.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.isShader( 'vertex' ) ) {
  16. code += 'gl_Position = ' + data.result + ';';
  17. } else {
  18. code += 'gl_FragColor = ' + data.result + ';';
  19. }
  20. return code;
  21. };
  22. THREE.RawNode.prototype.copy = function ( source ) {
  23. THREE.GLNode.prototype.copy.call( this, source );
  24. this.value = source.value;
  25. };
  26. THREE.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. };