/usr/share/javascript/three/examples/js/nodes/math/Math2Node.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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | /**
* @author sunag / http://www.sunag.com.br/
*/
THREE.Math2Node = function( a, b, method ) {
THREE.TempNode.call( this );
this.a = a;
this.b = b;
this.method = method || THREE.Math2Node.DISTANCE;
};
THREE.Math2Node.MIN = 'min';
THREE.Math2Node.MAX = 'max';
THREE.Math2Node.MOD = 'mod';
THREE.Math2Node.STEP = 'step';
THREE.Math2Node.REFLECT = 'reflect';
THREE.Math2Node.DISTANCE = 'distance';
THREE.Math2Node.DOT = 'dot';
THREE.Math2Node.CROSS = 'cross';
THREE.Math2Node.POW = 'pow';
THREE.Math2Node.prototype = Object.create( THREE.TempNode.prototype );
THREE.Math2Node.prototype.constructor = THREE.Math2Node;
THREE.Math2Node.prototype.getInputType = function( builder ) {
// use the greater length vector
if ( builder.getFormatLength( this.b.getType( builder ) ) > builder.getFormatLength( this.a.getType( builder ) ) ) {
return this.b.getType( builder );
}
return this.a.getType( builder );
};
THREE.Math2Node.prototype.getType = function( builder ) {
switch ( this.method ) {
case THREE.Math2Node.DISTANCE:
case THREE.Math2Node.DOT:
return 'fv1';
case THREE.Math2Node.CROSS:
return 'v3';
}
return this.getInputType( builder );
};
THREE.Math2Node.prototype.generate = function( builder, output ) {
var material = builder.material;
var type = this.getInputType( builder );
var a, b,
al = builder.getFormatLength( this.a.getType( builder ) ),
bl = builder.getFormatLength( this.b.getType( builder ) );
// optimzer
switch ( this.method ) {
case THREE.Math2Node.CROSS:
a = this.a.build( builder, 'v3' );
b = this.b.build( builder, 'v3' );
break;
case THREE.Math2Node.STEP:
a = this.a.build( builder, al == 1 ? 'fv1' : type );
b = this.b.build( builder, type );
break;
case THREE.Math2Node.MIN:
case THREE.Math2Node.MAX:
case THREE.Math2Node.MOD:
a = this.a.build( builder, type );
b = this.b.build( builder, bl == 1 ? 'fv1' : type );
break;
default:
a = this.a.build( builder, type );
b = this.b.build( builder, type );
break;
}
return builder.format( this.method + '(' + a + ',' + b + ')', this.getType( builder ), output );
};
|