/usr/share/javascript/three/examples/js/nodes/math/Math3Node.js is in libjs-three 80+dfsg2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 71 72 73 74 | /**
* @author sunag / http://www.sunag.com.br/
*/
THREE.Math3Node = function( a, b, c, method ) {
THREE.TempNode.call( this );
this.a = a;
this.b = b;
this.c = c;
this.method = method || THREE.Math3Node.MIX;
};
THREE.Math3Node.MIX = 'mix';
THREE.Math3Node.REFRACT = 'refract';
THREE.Math3Node.SMOOTHSTEP = 'smoothstep';
THREE.Math3Node.FACEFORWARD = 'faceforward';
THREE.Math3Node.prototype = Object.create( THREE.TempNode.prototype );
THREE.Math3Node.prototype.constructor = THREE.Math3Node;
THREE.Math3Node.prototype.getType = function( builder ) {
var a = builder.getFormatLength( this.a.getType( builder ) );
var b = builder.getFormatLength( this.b.getType( builder ) );
var c = builder.getFormatLength( this.c.getType( builder ) );
if ( a > b && a > c ) return this.a.getType( builder );
else if ( b > c ) return this.b.getType( builder );
return this.c.getType( builder );
};
THREE.Math3Node.prototype.generate = function( builder, output ) {
var material = builder.material;
var type = this.getType( builder );
var a, b, c,
al = builder.getFormatLength( this.a.getType( builder ) ),
bl = builder.getFormatLength( this.b.getType( builder ) ),
cl = builder.getFormatLength( this.c.getType( builder ) )
// optimzer
switch ( this.method ) {
case THREE.Math3Node.REFRACT:
a = this.a.build( builder, type );
b = this.b.build( builder, type );
c = this.c.build( builder, 'fv1' );
break;
case THREE.Math3Node.MIX:
a = this.a.build( builder, type );
b = this.b.build( builder, type );
c = this.c.build( builder, cl == 1 ? 'fv1' : type );
break;
default:
a = this.a.build( builder, type );
b = this.b.build( builder, type );
c = this.c.build( builder, type );
break;
}
return builder.format( this.method + '(' + a + ',' + b + ',' + c + ')', type, output );
};
|