NodeTexture.js 854 B

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.NodeTexture = function( value, coord, bias ) {
  5. THREE.NodeInput.call( this, 'v4' );
  6. this.value = value;
  7. this.coord = coord || new THREE.NodeUV();
  8. this.bias = bias;
  9. };
  10. THREE.NodeTexture.prototype = Object.create( THREE.NodeInput.prototype );
  11. THREE.NodeTexture.prototype.constructor = THREE.NodeTexture;
  12. THREE.NodeTexture.prototype.generate = function( builder, output ) {
  13. var tex = THREE.NodeInput.prototype.generate.call( this, builder, output, this.value.uuid, 't' );
  14. var coord = this.coord.build( builder, 'v2' );
  15. var bias = this.bias ? this.bias.build( builder, 'fv1' ) : undefined;
  16. var code;
  17. if (bias) code = 'texture2D(' + tex + ',' + coord + ',' + bias + ')';
  18. else code = 'texture2D(' + tex + ',' + coord + ')';
  19. return builder.format(code, this.type, output );
  20. };