NodeCubeTexture.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.NodeCubeTexture = function( value, coord, bias ) {
  5. THREE.NodeInput.call( this, 'v4' );
  6. this.value = value;
  7. this.coord = coord || new THREE.NodeReflect();
  8. this.bias = bias;
  9. };
  10. THREE.NodeCubeTexture.prototype = Object.create( THREE.NodeInput.prototype );
  11. THREE.NodeCubeTexture.prototype.constructor = THREE.NodeCubeTexture;
  12. THREE.NodeCubeTexture.prototype.generate = function( builder, output ) {
  13. var cubetex = THREE.NodeInput.prototype.generate.call( this, builder, output, this.value.uuid, 't' );
  14. var coord = this.coord.build( builder, 'v3' );
  15. var bias = this.bias ? this.bias.build( builder, 'fv1' ) : undefined;;
  16. if (bias == undefined && builder.require.cubeTextureBias) {
  17. bias = builder.require.cubeTextureBias.build( builder, 'fv1' );
  18. }
  19. var code;
  20. if (bias) code = 'textureCube(' + cubetex + ',' + coord + ',' + bias + ')';
  21. else code = 'textureCube(' + cubetex + ',' + coord + ')';
  22. return builder.format(code, this.type, output );
  23. };