webvr js meetup initial commit
This commit is contained in:
79
node_modules/three/examples/js/nodes/math/Math1Node.js
generated
vendored
Normal file
79
node_modules/three/examples/js/nodes/math/Math1Node.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.Math1Node = function( a, method ) {
|
||||
|
||||
THREE.TempNode.call( this );
|
||||
|
||||
this.a = a;
|
||||
|
||||
this.method = method || THREE.Math1Node.SIN;
|
||||
|
||||
};
|
||||
|
||||
THREE.Math1Node.RAD = 'radians';
|
||||
THREE.Math1Node.DEG = 'degrees';
|
||||
THREE.Math1Node.EXP = 'exp';
|
||||
THREE.Math1Node.EXP2 = 'exp2';
|
||||
THREE.Math1Node.LOG = 'log';
|
||||
THREE.Math1Node.LOG2 = 'log2';
|
||||
THREE.Math1Node.SQRT = 'sqrt';
|
||||
THREE.Math1Node.INV_SQRT = 'inversesqrt';
|
||||
THREE.Math1Node.FLOOR = 'floor';
|
||||
THREE.Math1Node.CEIL = 'ceil';
|
||||
THREE.Math1Node.NORMALIZE = 'normalize';
|
||||
THREE.Math1Node.FRACT = 'fract';
|
||||
THREE.Math1Node.SAT = 'saturate';
|
||||
THREE.Math1Node.SIN = 'sin';
|
||||
THREE.Math1Node.COS = 'cos';
|
||||
THREE.Math1Node.TAN = 'tan';
|
||||
THREE.Math1Node.ASIN = 'asin';
|
||||
THREE.Math1Node.ACOS = 'acos';
|
||||
THREE.Math1Node.ARCTAN = 'atan';
|
||||
THREE.Math1Node.ABS = 'abs';
|
||||
THREE.Math1Node.SIGN = 'sign';
|
||||
THREE.Math1Node.LENGTH = 'length';
|
||||
THREE.Math1Node.NEGATE = 'negate';
|
||||
THREE.Math1Node.INVERT = 'invert';
|
||||
|
||||
THREE.Math1Node.prototype = Object.create( THREE.TempNode.prototype );
|
||||
THREE.Math1Node.prototype.constructor = THREE.Math1Node;
|
||||
|
||||
THREE.Math1Node.prototype.getType = function( builder ) {
|
||||
|
||||
switch ( this.method ) {
|
||||
case THREE.Math1Node.LENGTH:
|
||||
return 'fv1';
|
||||
}
|
||||
|
||||
return this.a.getType( builder );
|
||||
|
||||
};
|
||||
|
||||
THREE.Math1Node.prototype.generate = function( builder, output ) {
|
||||
|
||||
var material = builder.material;
|
||||
|
||||
var type = this.getType( builder );
|
||||
|
||||
var result = this.a.build( builder, type );
|
||||
|
||||
switch ( this.method ) {
|
||||
|
||||
case THREE.Math1Node.NEGATE:
|
||||
result = '(-' + result + ')';
|
||||
break;
|
||||
|
||||
case THREE.Math1Node.INVERT:
|
||||
result = '(1.0-' + result + ')';
|
||||
break;
|
||||
|
||||
default:
|
||||
result = this.method + '(' + result + ')';
|
||||
break;
|
||||
}
|
||||
|
||||
return builder.format( result, type, output );
|
||||
|
||||
};
|
||||
96
node_modules/three/examples/js/nodes/math/Math2Node.js
generated
vendored
Normal file
96
node_modules/three/examples/js/nodes/math/Math2Node.js
generated
vendored
Normal file
@@ -0,0 +1,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 );
|
||||
|
||||
};
|
||||
74
node_modules/three/examples/js/nodes/math/Math3Node.js
generated
vendored
Normal file
74
node_modules/three/examples/js/nodes/math/Math3Node.js
generated
vendored
Normal file
@@ -0,0 +1,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 );
|
||||
|
||||
};
|
||||
56
node_modules/three/examples/js/nodes/math/OperatorNode.js
generated
vendored
Normal file
56
node_modules/three/examples/js/nodes/math/OperatorNode.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @author sunag / http://www.sunag.com.br/
|
||||
*/
|
||||
|
||||
THREE.OperatorNode = function( a, b, op ) {
|
||||
|
||||
THREE.TempNode.call( this );
|
||||
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
this.op = op || THREE.OperatorNode.ADD;
|
||||
|
||||
};
|
||||
|
||||
THREE.OperatorNode.ADD = '+';
|
||||
THREE.OperatorNode.SUB = '-';
|
||||
THREE.OperatorNode.MUL = '*';
|
||||
THREE.OperatorNode.DIV = '/';
|
||||
|
||||
THREE.OperatorNode.prototype = Object.create( THREE.TempNode.prototype );
|
||||
THREE.OperatorNode.prototype.constructor = THREE.OperatorNode;
|
||||
|
||||
THREE.OperatorNode.prototype.getType = function( builder ) {
|
||||
|
||||
var a = this.a.getType( builder );
|
||||
var b = this.b.getType( builder );
|
||||
|
||||
if ( builder.isFormatMatrix( a ) ) {
|
||||
|
||||
return 'v4';
|
||||
|
||||
} else if ( builder.getFormatLength( b ) > builder.getFormatLength( a ) ) {
|
||||
|
||||
// use the greater length vector
|
||||
|
||||
return b;
|
||||
|
||||
}
|
||||
|
||||
return a;
|
||||
|
||||
};
|
||||
|
||||
THREE.OperatorNode.prototype.generate = function( builder, output ) {
|
||||
|
||||
var material = builder.material,
|
||||
data = material.getDataNode( this.uuid );
|
||||
|
||||
var type = this.getType( builder );
|
||||
|
||||
var a = this.a.build( builder, type );
|
||||
var b = this.b.build( builder, type );
|
||||
|
||||
return builder.format( '(' + a + this.op + b + ')', type, output );
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user