AttributeNode.js 948 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.AttributeNode = function( name, type ) {
  5. THREE.GLNode.call( this, type );
  6. this.name = name;
  7. };
  8. THREE.AttributeNode.prototype = Object.create( THREE.GLNode.prototype );
  9. THREE.AttributeNode.prototype.constructor = THREE.AttributeNode;
  10. THREE.AttributeNode.prototype.getAttributeType = function( builder ) {
  11. return typeof this.type === 'number' ? builder.getConstructorFromLength( this.type ) : this.type;
  12. };
  13. THREE.AttributeNode.prototype.getType = function( builder ) {
  14. var type = this.getAttributeType( builder );
  15. return builder.getTypeByFormat( type );
  16. };
  17. THREE.AttributeNode.prototype.generate = function( builder, output ) {
  18. var type = this.getAttributeType( builder );
  19. var attribute = builder.material.getAttribute( this.name, type );
  20. return builder.format( builder.isShader( 'vertex' ) ? this.name : attribute.varying.name, this.getType( builder ), output );
  21. };