mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-30 19:21:54 +00:00
fix builds
This commit is contained in:
@@ -6772,6 +6772,9 @@ LGraphCanvas.prototype.prompt = function( title, value, callback, event )
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
LGraphCanvas.search_filter = false;
|
||||
LGraphCanvas.search_limit = -1;
|
||||
LGraphCanvas.prototype.showSearchBox = function(event)
|
||||
{
|
||||
var that = this;
|
||||
@@ -6900,30 +6903,48 @@ LGraphCanvas.prototype.showSearchBox = function(event)
|
||||
selected.scrollIntoView();
|
||||
}
|
||||
|
||||
function refreshHelper()
|
||||
{
|
||||
timeout = null;
|
||||
var str = input.value;
|
||||
first = null;
|
||||
helper.innerHTML = "";
|
||||
if(!str)
|
||||
return;
|
||||
function refreshHelper() {
|
||||
timeout = null;
|
||||
var str = input.value;
|
||||
first = null;
|
||||
helper.innerHTML = "";
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
if( that.onSearchBox )
|
||||
that.onSearchBox( help, str, graphcanvas );
|
||||
else
|
||||
for( var i in LiteGraph.registered_node_types )
|
||||
if(i.indexOf(str) != -1)
|
||||
{
|
||||
var help = document.createElement("div");
|
||||
if(!first) first = i;
|
||||
help.innerText = i;
|
||||
help.className = "litegraph lite-search-item";
|
||||
help.addEventListener("click", function(e){
|
||||
select( this.innerText );
|
||||
});
|
||||
helper.appendChild(help);
|
||||
if (that.onSearchBox){
|
||||
that.onSearchBox(help, str, graphcanvas);
|
||||
} else {
|
||||
function addResult(result) {
|
||||
var help = document.createElement("div");
|
||||
if (!first) first = result;
|
||||
help.innerText = result;
|
||||
help.className = "litegraph lite-search-item";
|
||||
help.addEventListener("click", function (e) {
|
||||
select(this.innerText);
|
||||
});
|
||||
helper.appendChild(help);
|
||||
}
|
||||
let c = 0;
|
||||
if(LGraphCanvas.search_filter) {
|
||||
str = str.toLowerCase();
|
||||
|
||||
var keys = Object.keys(LiteGraph.registered_node_types);
|
||||
var filtered = keys.filter(function (item) {
|
||||
return item.toLowerCase().indexOf(str) !== -1;
|
||||
});
|
||||
for(var i = 0; i < filtered.length; i++) {
|
||||
addResult(filtered[i]);
|
||||
if(LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit) break;
|
||||
}
|
||||
} else {
|
||||
for (var i in LiteGraph.registered_node_types) {
|
||||
if (i.indexOf(str) != -1) {
|
||||
addResult(i);
|
||||
if(LGraphCanvas.search_limit !== -1 && c++ > LGraphCanvas.search_limit) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dialog;
|
||||
@@ -9765,7 +9786,7 @@ MathRand.prototype.onExecute = function()
|
||||
this.properties[input.name] = v;
|
||||
}
|
||||
|
||||
var min = this.properties.min;
|
||||
var min = this.properties.min;
|
||||
var max = this.properties.max;
|
||||
this._last_v = Math.random() * (max-min) + min;
|
||||
this.setOutputData(0, this._last_v );
|
||||
@@ -10321,634 +10342,6 @@ LiteGraph.registerNodeType("math/trigonometry", MathTrigonometry );
|
||||
|
||||
|
||||
|
||||
//math library for safe math operations without eval
|
||||
if(typeof(math) != undefined)
|
||||
{
|
||||
function MathFormula()
|
||||
{
|
||||
this.addInputs("x","number");
|
||||
this.addInputs("y","number");
|
||||
this.addOutputs("","number");
|
||||
this.properties = {x:1.0, y:1.0, formula:"x+y"};
|
||||
}
|
||||
|
||||
MathFormula.title = "Formula";
|
||||
MathFormula.desc = "Compute safe formula";
|
||||
|
||||
MathFormula.prototype.onExecute = function()
|
||||
{
|
||||
var x = this.getInputData(0);
|
||||
var y = this.getInputData(1);
|
||||
if(x != null)
|
||||
this.properties["x"] = x;
|
||||
else
|
||||
x = this.properties["x"];
|
||||
|
||||
if(y!=null)
|
||||
this.properties["y"] = y;
|
||||
else
|
||||
y = this.properties["y"];
|
||||
|
||||
var f = this.properties["formula"];
|
||||
var value = math.eval(f,{x:x,y:y,T: this.graph.globaltime });
|
||||
this.setOutputData(0, value );
|
||||
}
|
||||
|
||||
MathFormula.prototype.onDrawBackground = function()
|
||||
{
|
||||
var f = this.properties["formula"];
|
||||
this.outputs[0].label = f;
|
||||
}
|
||||
|
||||
MathFormula.prototype.onGetOutputs = function()
|
||||
{
|
||||
return [["A-B","number"],["A*B","number"],["A/B","number"]];
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/formula", MathFormula );
|
||||
}
|
||||
|
||||
|
||||
function Math3DVec2ToXYZ()
|
||||
{
|
||||
this.addInput("vec2","vec2");
|
||||
this.addOutput("x","number");
|
||||
this.addOutput("y","number");
|
||||
}
|
||||
|
||||
Math3DVec2ToXYZ.title = "Vec2->XY";
|
||||
Math3DVec2ToXYZ.desc = "vector 2 to components";
|
||||
|
||||
Math3DVec2ToXYZ.prototype.onExecute = function()
|
||||
{
|
||||
var v = this.getInputData(0);
|
||||
if(v == null) return;
|
||||
|
||||
this.setOutputData( 0, v[0] );
|
||||
this.setOutputData( 1, v[1] );
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math3d/vec2-to-xyz", Math3DVec2ToXYZ );
|
||||
|
||||
|
||||
function Math3DXYToVec2()
|
||||
{
|
||||
this.addInputs([["x","number"],["y","number"]]);
|
||||
this.addOutput("vec2","vec2");
|
||||
this.properties = {x:0, y:0};
|
||||
this._data = new Float32Array(2);
|
||||
}
|
||||
|
||||
MathRand.prototype.onDrawBackground = function(ctx)
|
||||
{
|
||||
//show the current value
|
||||
if(this._last_v)
|
||||
this.outputs[0].label = this._last_v.toFixed(3);
|
||||
else
|
||||
this.outputs[0].label = "?";
|
||||
}
|
||||
|
||||
MathRand.prototype.onGetInputs = function() {
|
||||
return [["min","number"],["max","number"]];
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/rand", MathRand);
|
||||
|
||||
//Math clamp
|
||||
function MathClamp()
|
||||
{
|
||||
this.addInput("in","number");
|
||||
this.addOutput("out","number");
|
||||
this.size = [60,20];
|
||||
this.addProperty( "min", 0 );
|
||||
this.addProperty( "max", 1 );
|
||||
}
|
||||
|
||||
MathClamp.title = "Clamp";
|
||||
MathClamp.desc = "Clamp number between min and max";
|
||||
MathClamp.filter = "shader";
|
||||
|
||||
MathClamp.prototype.onExecute = function()
|
||||
{
|
||||
var v = this.getInputData(0);
|
||||
if(v == null) return;
|
||||
v = Math.max(this.properties.min,v);
|
||||
v = Math.min(this.properties.max,v);
|
||||
this.setOutputData(0, v );
|
||||
}
|
||||
|
||||
MathClamp.prototype.getCode = function(lang)
|
||||
{
|
||||
var code = "";
|
||||
if(this.isInputConnected(0))
|
||||
code += "clamp({{0}}," + this.properties.min + "," + this.properties.max + ")";
|
||||
return code;
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/clamp", MathClamp );
|
||||
|
||||
|
||||
|
||||
//Math ABS
|
||||
function MathLerp()
|
||||
{
|
||||
this.properties = { f: 0.5 };
|
||||
this.addInput("A","number");
|
||||
this.addInput("B","number");
|
||||
|
||||
this.addOutput("out","number");
|
||||
}
|
||||
|
||||
MathLerp.title = "Lerp";
|
||||
MathLerp.desc = "Linear Interpolation";
|
||||
|
||||
MathLerp.prototype.onExecute = function()
|
||||
{
|
||||
var v1 = this.getInputData(0);
|
||||
if(v1 == null)
|
||||
v1 = 0;
|
||||
var v2 = this.getInputData(1);
|
||||
if(v2 == null)
|
||||
v2 = 0;
|
||||
|
||||
var f = this.properties.f;
|
||||
|
||||
var _f = this.getInputData(2);
|
||||
if(_f !== undefined)
|
||||
f = _f;
|
||||
|
||||
this.setOutputData(0, v1 * (1-f) + v2 * f );
|
||||
}
|
||||
|
||||
MathLerp.prototype.onGetInputs = function()
|
||||
{
|
||||
return [["f","number"]];
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/lerp", MathLerp);
|
||||
|
||||
|
||||
|
||||
//Math ABS
|
||||
function MathAbs()
|
||||
{
|
||||
this.addInput("in","number");
|
||||
this.addOutput("out","number");
|
||||
this.size = [60,20];
|
||||
}
|
||||
|
||||
MathAbs.title = "Abs";
|
||||
MathAbs.desc = "Absolute";
|
||||
|
||||
MathAbs.prototype.onExecute = function()
|
||||
{
|
||||
var v = this.getInputData(0);
|
||||
if(v == null) return;
|
||||
this.setOutputData(0, Math.abs(v) );
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/abs", MathAbs);
|
||||
|
||||
|
||||
//Math Floor
|
||||
function MathFloor()
|
||||
{
|
||||
this.addInput("in","number");
|
||||
this.addOutput("out","number");
|
||||
this.size = [60,20];
|
||||
}
|
||||
|
||||
MathFloor.title = "Floor";
|
||||
MathFloor.desc = "Floor number to remove fractional part";
|
||||
|
||||
MathFloor.prototype.onExecute = function()
|
||||
{
|
||||
var v = this.getInputData(0);
|
||||
if(v == null) return;
|
||||
this.setOutputData(0, Math.floor(v) );
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/floor", MathFloor );
|
||||
|
||||
|
||||
//Math frac
|
||||
function MathFrac()
|
||||
{
|
||||
this.addInput("in","number");
|
||||
this.addOutput("out","number");
|
||||
this.size = [60,20];
|
||||
}
|
||||
|
||||
MathFrac.title = "Frac";
|
||||
MathFrac.desc = "Returns fractional part";
|
||||
|
||||
MathFrac.prototype.onExecute = function()
|
||||
{
|
||||
var v = this.getInputData(0);
|
||||
if(v == null)
|
||||
return;
|
||||
this.setOutputData(0, v%1 );
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/frac",MathFrac);
|
||||
|
||||
|
||||
//Math Floor
|
||||
function MathSmoothStep()
|
||||
{
|
||||
this.addInput("in","number");
|
||||
this.addOutput("out","number");
|
||||
this.size = [60,20];
|
||||
this.properties = { A: 0, B: 1 };
|
||||
}
|
||||
|
||||
MathSmoothStep.title = "Smoothstep";
|
||||
MathSmoothStep.desc = "Smoothstep";
|
||||
|
||||
MathSmoothStep.prototype.onExecute = function()
|
||||
{
|
||||
var v = this.getInputData(0);
|
||||
if(v === undefined)
|
||||
return;
|
||||
|
||||
var edge0 = this.properties.A;
|
||||
var edge1 = this.properties.B;
|
||||
|
||||
// Scale, bias and saturate x to 0..1 range
|
||||
v = Math.clamp((v - edge0)/(edge1 - edge0), 0.0, 1.0);
|
||||
// Evaluate polynomial
|
||||
v = v*v*(3 - 2*v);
|
||||
|
||||
this.setOutputData(0, v );
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/smoothstep", MathSmoothStep );
|
||||
|
||||
//Math scale
|
||||
function MathScale()
|
||||
{
|
||||
this.addInput("in","number",{label:""});
|
||||
this.addOutput("out","number",{label:""});
|
||||
this.size = [60,20];
|
||||
this.addProperty( "factor", 1 );
|
||||
}
|
||||
|
||||
MathScale.title = "Scale";
|
||||
MathScale.desc = "v * factor";
|
||||
|
||||
MathScale.prototype.onExecute = function()
|
||||
{
|
||||
var value = this.getInputData(0);
|
||||
if(value != null)
|
||||
this.setOutputData(0, value * this.properties.factor );
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/scale", MathScale );
|
||||
|
||||
|
||||
//Math Average
|
||||
function MathAverageFilter()
|
||||
{
|
||||
this.addInput("in","number");
|
||||
this.addOutput("out","number");
|
||||
this.size = [60,20];
|
||||
this.addProperty( "samples", 10 );
|
||||
this._values = new Float32Array(10);
|
||||
this._current = 0;
|
||||
}
|
||||
|
||||
MathAverageFilter.title = "Average";
|
||||
MathAverageFilter.desc = "Average Filter";
|
||||
|
||||
MathAverageFilter.prototype.onExecute = function()
|
||||
{
|
||||
var v = this.getInputData(0);
|
||||
if(v == null)
|
||||
v = 0;
|
||||
|
||||
var num_samples = this._values.length;
|
||||
|
||||
this._values[ this._current % num_samples ] = v;
|
||||
this._current += 1;
|
||||
if(this._current > num_samples)
|
||||
this._current = 0;
|
||||
|
||||
var avr = 0;
|
||||
for(var i = 0; i < num_samples; ++i)
|
||||
avr += this._values[i];
|
||||
|
||||
this.setOutputData( 0, avr / num_samples );
|
||||
}
|
||||
|
||||
MathAverageFilter.prototype.onPropertyChanged = function( name, value )
|
||||
{
|
||||
if(value < 1)
|
||||
value = 1;
|
||||
this.properties.samples = Math.round(value);
|
||||
var old = this._values;
|
||||
|
||||
this._values = new Float32Array( this.properties.samples );
|
||||
if(old.length <= this._values.length )
|
||||
this._values.set(old);
|
||||
else
|
||||
this._values.set( old.subarray( 0, this._values.length ) );
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/average", MathAverageFilter );
|
||||
|
||||
|
||||
//Math
|
||||
function MathTendTo()
|
||||
{
|
||||
this.addInput("in","number");
|
||||
this.addOutput("out","number");
|
||||
this.addProperty( "factor", 0.1 );
|
||||
this.size = [60,20];
|
||||
this._value = null;
|
||||
}
|
||||
|
||||
MathTendTo.title = "TendTo";
|
||||
MathTendTo.desc = "moves the output value always closer to the input";
|
||||
|
||||
MathTendTo.prototype.onExecute = function()
|
||||
{
|
||||
var v = this.getInputData(0);
|
||||
if(v == null)
|
||||
v = 0;
|
||||
var f = this.properties.factor;
|
||||
if(this._value == null)
|
||||
this._value = v;
|
||||
else
|
||||
this._value = this._value * (1 - f) + v * f;
|
||||
this.setOutputData( 0, this._value );
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/tendTo", MathTendTo );
|
||||
|
||||
|
||||
//Math operation
|
||||
function MathOperation()
|
||||
{
|
||||
this.addInput("A","number");
|
||||
this.addInput("B","number");
|
||||
this.addOutput("=","number");
|
||||
this.addProperty( "A", 1 );
|
||||
this.addProperty( "B", 1 );
|
||||
this.addProperty( "OP", "+", "enum", { values: MathOperation.values } );
|
||||
}
|
||||
|
||||
MathOperation.values = ["+","-","*","/","%","^"];
|
||||
|
||||
MathOperation.title = "Operation";
|
||||
MathOperation.desc = "Easy math operators";
|
||||
MathOperation["@OP"] = { type:"enum", title: "operation", values: MathOperation.values };
|
||||
|
||||
MathOperation.prototype.getTitle = function()
|
||||
{
|
||||
return "A " + this.properties.OP + " B";
|
||||
}
|
||||
|
||||
MathOperation.prototype.setValue = function(v)
|
||||
{
|
||||
if( typeof(v) == "string") v = parseFloat(v);
|
||||
this.properties["value"] = v;
|
||||
}
|
||||
|
||||
MathOperation.prototype.onExecute = function()
|
||||
{
|
||||
var A = this.getInputData(0);
|
||||
var B = this.getInputData(1);
|
||||
if(A!=null)
|
||||
this.properties["A"] = A;
|
||||
else
|
||||
A = this.properties["A"];
|
||||
|
||||
if(B!=null)
|
||||
this.properties["B"] = B;
|
||||
else
|
||||
B = this.properties["B"];
|
||||
|
||||
var result = 0;
|
||||
switch(this.properties.OP)
|
||||
{
|
||||
case '+': result = A+B; break;
|
||||
case '-': result = A-B; break;
|
||||
case 'x':
|
||||
case 'X':
|
||||
case '*': result = A*B; break;
|
||||
case '/': result = A/B; break;
|
||||
case '%': result = A%B; break;
|
||||
case '^': result = Math.pow(A,B); break;
|
||||
default:
|
||||
console.warn("Unknown operation: " + this.properties.OP);
|
||||
}
|
||||
this.setOutputData(0, result );
|
||||
}
|
||||
|
||||
MathOperation.prototype.onDrawBackground = function(ctx)
|
||||
{
|
||||
if(this.flags.collapsed)
|
||||
return;
|
||||
|
||||
ctx.font = "40px Arial";
|
||||
ctx.fillStyle = "#CCC";
|
||||
ctx.textAlign = "center";
|
||||
ctx.fillText(this.properties.OP, this.size[0] * 0.5, this.size[1] * 0.35 + LiteGraph.NODE_TITLE_HEIGHT );
|
||||
ctx.textAlign = "left";
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/operation", MathOperation );
|
||||
|
||||
|
||||
//Math compare
|
||||
function MathCompare()
|
||||
{
|
||||
this.addInput( "A","number" );
|
||||
this.addInput( "B","number" );
|
||||
this.addOutput("A==B","boolean");
|
||||
this.addOutput("A!=B","boolean");
|
||||
this.addProperty( "A", 0 );
|
||||
this.addProperty( "B", 0 );
|
||||
}
|
||||
|
||||
MathCompare.title = "Compare";
|
||||
MathCompare.desc = "compares between two values";
|
||||
|
||||
MathCompare.prototype.onExecute = function()
|
||||
{
|
||||
var A = this.getInputData(0);
|
||||
var B = this.getInputData(1);
|
||||
if(A !== undefined)
|
||||
this.properties["A"] = A;
|
||||
else
|
||||
A = this.properties["A"];
|
||||
|
||||
if(B !== undefined)
|
||||
this.properties["B"] = B;
|
||||
else
|
||||
B = this.properties["B"];
|
||||
|
||||
for(var i = 0, l = this.outputs.length; i < l; ++i)
|
||||
{
|
||||
var output = this.outputs[i];
|
||||
if(!output.links || !output.links.length)
|
||||
continue;
|
||||
switch( output.name )
|
||||
{
|
||||
case "A==B": value = A==B; break;
|
||||
case "A!=B": value = A!=B; break;
|
||||
case "A>B": value = A>B; break;
|
||||
case "A<B": value = A<B; break;
|
||||
case "A<=B": value = A<=B; break;
|
||||
case "A>=B": value = A>=B; break;
|
||||
}
|
||||
this.setOutputData(i, value );
|
||||
}
|
||||
};
|
||||
|
||||
MathCompare.prototype.onGetOutputs = function()
|
||||
{
|
||||
return [["A==B","boolean"],["A!=B","boolean"],["A>B","boolean"],["A<B","boolean"],["A>=B","boolean"],["A<=B","boolean"]];
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/compare",MathCompare);
|
||||
|
||||
function MathCondition()
|
||||
{
|
||||
this.addInput("A","number");
|
||||
this.addInput("B","number");
|
||||
this.addOutput("out","boolean");
|
||||
this.addProperty( "A", 1 );
|
||||
this.addProperty( "B", 1 );
|
||||
this.addProperty( "OP", ">", "string", { values: MathCondition.values } );
|
||||
|
||||
this.size = [60,40];
|
||||
}
|
||||
|
||||
MathCondition.values = [">","<","==","!=","<=",">="];
|
||||
MathCondition["@OP"] = { type:"enum", title: "operation", values: MathCondition.values };
|
||||
|
||||
MathCondition.title = "Condition";
|
||||
MathCondition.desc = "evaluates condition between A and B";
|
||||
|
||||
MathCondition.prototype.onExecute = function()
|
||||
{
|
||||
var A = this.getInputData(0);
|
||||
if(A === undefined)
|
||||
A = this.properties.A;
|
||||
else
|
||||
this.properties.A = A;
|
||||
|
||||
var B = this.getInputData(1);
|
||||
if(B === undefined)
|
||||
B = this.properties.B;
|
||||
else
|
||||
this.properties.B = B;
|
||||
|
||||
var result = true;
|
||||
switch(this.properties.OP)
|
||||
{
|
||||
case ">": result = A>B; break;
|
||||
case "<": result = A<B; break;
|
||||
case "==": result = A==B; break;
|
||||
case "!=": result = A!=B; break;
|
||||
case "<=": result = A<=B; break;
|
||||
case ">=": result = A>=B; break;
|
||||
}
|
||||
|
||||
this.setOutputData(0, result );
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/condition", MathCondition);
|
||||
|
||||
|
||||
function MathAccumulate()
|
||||
{
|
||||
this.addInput("inc","number");
|
||||
this.addOutput("total","number");
|
||||
this.addProperty( "increment", 1 );
|
||||
this.addProperty( "value", 0 );
|
||||
}
|
||||
|
||||
MathAccumulate.title = "Accumulate";
|
||||
MathAccumulate.desc = "Increments a value every time";
|
||||
|
||||
MathAccumulate.prototype.onExecute = function()
|
||||
{
|
||||
if(this.properties.value === null)
|
||||
this.properties.value = 0;
|
||||
|
||||
var inc = this.getInputData(0);
|
||||
if(inc !== null)
|
||||
this.properties.value += inc;
|
||||
else
|
||||
this.properties.value += this.properties.increment;
|
||||
this.setOutputData(0, this.properties.value );
|
||||
}
|
||||
|
||||
LiteGraph.registerNodeType("math/accumulate", MathAccumulate);
|
||||
|
||||
//Math Trigonometry
|
||||
function MathTrigonometry()
|
||||
{
|
||||
this.addInput("v","number");
|
||||
this.addOutput("sin","number");
|
||||
|
||||
this.addProperty( "amplitude", 1 );
|
||||
this.addProperty( "offset", 0 );
|
||||
this.bgImageUrl = "nodes/imgs/icon-sin.png";
|
||||
}
|
||||
|
||||
MathTrigonometry.title = "Trigonometry";
|
||||
MathTrigonometry.desc = "Sin Cos Tan";
|
||||
MathTrigonometry.filter = "shader";
|
||||
|
||||
MathTrigonometry.prototype.onExecute = function()
|
||||
{
|
||||
var v = this.getInputData(0);
|
||||
if(v == null)
|
||||
v = 0;
|
||||
var amplitude = this.properties["amplitude"];
|
||||
var slot = this.findInputSlot("amplitude");
|
||||
if(slot != -1)
|
||||
amplitude = this.getInputData(slot);
|
||||
var offset = this.properties["offset"];
|
||||
slot = this.findInputSlot("offset");
|
||||
if(slot != -1)
|
||||
offset = this.getInputData(slot);
|
||||
|
||||
for(var i = 0, l = this.outputs.length; i < l; ++i)
|
||||
{
|
||||
var output = this.outputs[i];
|
||||
switch( output.name )
|
||||
{
|
||||
case "sin": value = Math.sin(v); break;
|
||||
case "cos": value = Math.cos(v); break;
|
||||
case "tan": value = Math.tan(v); break;
|
||||
case "asin": value = Math.asin(v); break;
|
||||
case "acos": value = Math.acos(v); break;
|
||||
case "atan": value = Math.atan(v); break;
|
||||
}
|
||||
this.setOutputData(i, amplitude * value + offset);
|
||||
}
|
||||
}
|
||||
|
||||
MathTrigonometry.prototype.onGetInputs = function()
|
||||
{
|
||||
return [["v","number"],["amplitude","number"],["offset","number"]];
|
||||
}
|
||||
|
||||
|
||||
MathTrigonometry.prototype.onGetOutputs = function()
|
||||
{
|
||||
return [["sin","number"],["cos","number"],["tan","number"],["asin","number"],["acos","number"],["atan","number"]];
|
||||
}
|
||||
|
||||
|
||||
LiteGraph.registerNodeType("math/trigonometry", MathTrigonometry );
|
||||
|
||||
|
||||
|
||||
//math library for safe math operations without eval
|
||||
if(typeof(math) != undefined)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user