UVNode.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * @author sunag / http://www.sunag.com.br/
  3. */
  4. THREE.UVNode = function ( index ) {
  5. THREE.TempNode.call( this, 'v2', { shared: false } );
  6. this.index = index || 0;
  7. };
  8. THREE.UVNode.vertexDict = [ 'uv', 'uv2' ];
  9. THREE.UVNode.fragmentDict = [ 'vUv', 'vUv2' ];
  10. THREE.UVNode.prototype = Object.create( THREE.TempNode.prototype );
  11. THREE.UVNode.prototype.constructor = THREE.UVNode;
  12. THREE.UVNode.prototype.nodeType = "UV";
  13. THREE.UVNode.prototype.generate = function ( builder, output ) {
  14. var material = builder.material;
  15. var result;
  16. material.requires.uv[ this.index ] = true;
  17. if ( builder.isShader( 'vertex' ) ) result = THREE.UVNode.vertexDict[ this.index ];
  18. else result = THREE.UVNode.fragmentDict[ this.index ];
  19. return builder.format( result, this.getType( builder ), output );
  20. };
  21. THREE.UVNode.prototype.copy = function ( source ) {
  22. THREE.GLNode.prototype.copy.call( this, source );
  23. this.index = source.index;
  24. };
  25. THREE.UVNode.prototype.toJSON = function ( meta ) {
  26. var data = this.getJSONNode( meta );
  27. if ( ! data ) {
  28. data = this.createJSONNode( meta );
  29. data.index = this.index;
  30. }
  31. return data;
  32. };