Spaces:
Running
Running
File size: 1,218 Bytes
6cd9596 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
/**
* @author sunag / http://www.sunag.com.br/
*/
import { TempNode } from '../core/TempNode.js';
import { NodeLib } from '../core/NodeLib.js';
var vertexDict = [ 'uv', 'uv2' ],
fragmentDict = [ 'vUv', 'vUv2' ];
function UVNode( index ) {
TempNode.call( this, 'v2', { shared: false } );
this.index = index || 0;
}
UVNode.prototype = Object.create( TempNode.prototype );
UVNode.prototype.constructor = UVNode;
UVNode.prototype.nodeType = "UV";
UVNode.prototype.generate = function ( builder, output ) {
builder.requires.uv[ this.index ] = true;
var result = builder.isShader( 'vertex' ) ? vertexDict[ this.index ] : fragmentDict[ this.index ];
return builder.format( result, this.getType( builder ), output );
};
UVNode.prototype.copy = function ( source ) {
TempNode.prototype.copy.call( this, source );
this.index = source.index;
};
UVNode.prototype.toJSON = function ( meta ) {
var data = this.getJSONNode( meta );
if ( ! data ) {
data = this.createJSONNode( meta );
data.index = this.index;
}
return data;
};
NodeLib.addKeyword( 'uv', function () {
return new UVNode();
} );
NodeLib.addKeyword( 'uv2', function () {
return new UVNode( 1 );
} );
export { UVNode };
|