UVNode.js 1000 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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.toJSON = function ( meta ) {
  22. var data = this.getJSONNode( meta );
  23. if ( ! data ) {
  24. data = this.createJSONNode( meta );
  25. data.index = this.index;
  26. }
  27. return data;
  28. };