fixes in replicated nodes

This commit is contained in:
tamat
2019-09-02 23:33:59 +02:00
parent c80a66eb8a
commit 91d082cace
5 changed files with 140 additions and 221 deletions

View File

@@ -97,182 +97,6 @@
LiteGraph.registerNodeType("math3d/operation", Math3DOperation);
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);
}
Math3DXYToVec2.title = "XY->Vec2";
Math3DXYToVec2.desc = "components to vector2";
Math3DXYToVec2.prototype.onExecute = function() {
var x = this.getInputData(0);
if (x == null) {
x = this.properties.x;
}
var y = this.getInputData(1);
if (y == null) {
y = this.properties.y;
}
var data = this._data;
data[0] = x;
data[1] = y;
this.setOutputData(0, data);
};
LiteGraph.registerNodeType("math3d/xy-to-vec2", Math3DXYToVec2);
function Math3DVec3ToXYZ() {
this.addInput("vec3", "vec3");
this.addOutput("x", "number");
this.addOutput("y", "number");
this.addOutput("z", "number");
}
Math3DVec3ToXYZ.title = "Vec3->XYZ";
Math3DVec3ToXYZ.desc = "vector 3 to components";
Math3DVec3ToXYZ.prototype.onExecute = function() {
var v = this.getInputData(0);
if (v == null) {
return;
}
this.setOutputData(0, v[0]);
this.setOutputData(1, v[1]);
this.setOutputData(2, v[2]);
};
LiteGraph.registerNodeType("math3d/vec3-to-xyz", Math3DVec3ToXYZ);
function Math3DXYZToVec3() {
this.addInputs([["x", "number"], ["y", "number"], ["z", "number"]]);
this.addOutput("vec3", "vec3");
this.properties = { x: 0, y: 0, z: 0 };
this._data = new Float32Array(3);
}
Math3DXYZToVec3.title = "XYZ->Vec3";
Math3DXYZToVec3.desc = "components to vector3";
Math3DXYZToVec3.prototype.onExecute = function() {
var x = this.getInputData(0);
if (x == null) {
x = this.properties.x;
}
var y = this.getInputData(1);
if (y == null) {
y = this.properties.y;
}
var z = this.getInputData(2);
if (z == null) {
z = this.properties.z;
}
var data = this._data;
data[0] = x;
data[1] = y;
data[2] = z;
this.setOutputData(0, data);
};
LiteGraph.registerNodeType("math3d/xyz-to-vec3", Math3DXYZToVec3);
function Math3DVec4ToXYZW() {
this.addInput("vec4", "vec4");
this.addOutput("x", "number");
this.addOutput("y", "number");
this.addOutput("z", "number");
this.addOutput("w", "number");
}
Math3DVec4ToXYZW.title = "Vec4->XYZW";
Math3DVec4ToXYZW.desc = "vector 4 to components";
Math3DVec4ToXYZW.prototype.onExecute = function() {
var v = this.getInputData(0);
if (v == null) {
return;
}
this.setOutputData(0, v[0]);
this.setOutputData(1, v[1]);
this.setOutputData(2, v[2]);
this.setOutputData(3, v[3]);
};
LiteGraph.registerNodeType("math3d/vec4-to-xyzw", Math3DVec4ToXYZW);
function Math3DXYZWToVec4() {
this.addInputs([
["x", "number"],
["y", "number"],
["z", "number"],
["w", "number"]
]);
this.addOutput("vec4", "vec4");
this.properties = { x: 0, y: 0, z: 0, w: 0 };
this._data = new Float32Array(4);
}
Math3DXYZWToVec4.title = "XYZW->Vec4";
Math3DXYZWToVec4.desc = "components to vector4";
Math3DXYZWToVec4.prototype.onExecute = function() {
var x = this.getInputData(0);
if (x == null) {
x = this.properties.x;
}
var y = this.getInputData(1);
if (y == null) {
y = this.properties.y;
}
var z = this.getInputData(2);
if (z == null) {
z = this.properties.z;
}
var w = this.getInputData(3);
if (w == null) {
w = this.properties.w;
}
var data = this._data;
data[0] = x;
data[1] = y;
data[2] = z;
data[3] = w;
this.setOutputData(0, data);
};
LiteGraph.registerNodeType("math3d/xyzw-to-vec4", Math3DXYZWToVec4);
function Math3DVec3Scale() {
this.addInput("in", "vec3");
this.addInput("f", "number");