VarNode.js 808 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.VarNode = function ( type ) {
  5. THREE.GLNode.call( this, type );
  6. };
  7. THREE.VarNode.prototype = Object.create( THREE.GLNode.prototype );
  8. THREE.VarNode.prototype.constructor = THREE.VarNode;
  9. THREE.VarNode.prototype.nodeType = "Var";
  10. THREE.VarNode.prototype.getType = function ( builder ) {
  11. return builder.getTypeByFormat( this.type );
  12. };
  13. THREE.VarNode.prototype.generate = function ( builder, output ) {
  14. var varying = builder.material.getVar( this.uuid, this.type );
  15. return builder.format( varying.name, this.getType( builder ), output );
  16. };
  17. THREE.VarNode.prototype.toJSON = function ( meta ) {
  18. var data = this.getJSONNode( meta );
  19. if ( ! data ) {
  20. data = this.createJSONNode( meta );
  21. data.out = this.type;
  22. }
  23. return data;
  24. };