Spaces:
Running
Running
File size: 1,259 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 |
/**
* @author sunag / http://www.sunag.com.br/
*/
import { TempNode } from '../core/TempNode.js';
import { ResolutionNode } from './ResolutionNode.js';
function ScreenUVNode( resolution ) {
TempNode.call( this, 'v2' );
this.resolution = resolution || new ResolutionNode();
}
ScreenUVNode.prototype = Object.create( TempNode.prototype );
ScreenUVNode.prototype.constructor = ScreenUVNode;
ScreenUVNode.prototype.nodeType = "ScreenUV";
ScreenUVNode.prototype.generate = function ( builder, output ) {
var result;
if ( builder.isShader( 'fragment' ) ) {
result = '( gl_FragCoord.xy / ' + this.resolution.build( builder, 'v2' ) + ')';
} else {
console.warn( "THREE.ScreenUVNode is not compatible with " + builder.shader + " shader." );
result = 'vec2( 0.0 )';
}
return builder.format( result, this.getType( builder ), output );
};
ScreenUVNode.prototype.copy = function ( source ) {
TempNode.prototype.copy.call( this, source );
this.resolution = source.resolution;
};
ScreenUVNode.prototype.toJSON = function ( meta ) {
var data = this.getJSONNode( meta );
if ( ! data ) {
data = this.createJSONNode( meta );
data.resolution = this.resolution.toJSON( meta ).uuid;
}
return data;
};
export { ScreenUVNode };
|