Skip to content

Commit

Permalink
fix distance3d
Browse files Browse the repository at this point in the history
  • Loading branch information
pandrr committed Nov 8, 2023
1 parent b946205 commit dfa658a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 33 deletions.
Binary file modified src/ops/base/Ops.Gl.Matrix.CameraPosition/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 2 additions & 19 deletions src/ops/base/Ops.Math.Distance3d_v2/Ops.Math.Distance3d_v2.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,22 @@
const
calc = op.inTriggerButton("Calc"),

x1 = op.inValueFloat("x1"),
y1 = op.inValueFloat("y1"),
z1 = op.inValueFloat("z1"),

x2 = op.inValueFloat("x2"),
y2 = op.inValueFloat("y2"),
z2 = op.inValueFloat("z2"),

inMin = op.inValue("Min", 0);
next = op.outTrigger("Next"),
dist = op.addOutPort(new CABLES.Port(op, "distance"));

op.setPortGroup("Point 1", [x1, y1, z1]);
op.setPortGroup("Point 2", [x2, y2, z2]);

const next = op.outTrigger("Next");
const dist = op.addOutPort(new CABLES.Port(op, "distance"));

let min = inMin.get();

inMin.onChange = function ()
{
min = inMin.get();
};

calc.onTriggered = function ()
{
const xd = x2.get() - x1.get();
if (Math.abs(xd) > min) return;

const yd = y2.get() - y1.get();
if (Math.abs(yd) > min) return;

const zd = z2.get() - z1.get();
if (Math.abs(zd) > min) return;

dist.set(Math.sqrt(xd * xd + yd * yd + zd * zd));

Expand Down
23 changes: 9 additions & 14 deletions src/ops/base/Ops.Math.Distance3d_v2/Ops.Math.Distance3d_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,53 @@
"layout": {
"portsIn": [
{
"type": "1",
"type": 1,
"name": "Calc"
},
{
"type": "0",
"type": 0,
"name": "x1",
"group": "Point 1",
"subType": "number"
},
{
"type": "0",
"type": 0,
"name": "y1",
"group": "Point 1",
"subType": "number"
},
{
"type": "0",
"type": 0,
"name": "z1",
"group": "Point 1",
"subType": "number"
},
{
"type": "0",
"type": 0,
"name": "x2",
"group": "Point 2",
"subType": "number"
},
{
"type": "0",
"type": 0,
"name": "y2",
"group": "Point 2",
"subType": "number"
},
{
"type": "0",
"type": 0,
"name": "z2",
"group": "Point 2",
"subType": "number"
},
{
"type": "0",
"name": "Min",
"subType": "number"
}
],
"portsOut": [
{
"type": "1",
"type": 1,
"name": "Next"
},
{
"type": "0",
"type": 0,
"name": "distance",
"subType": "number"
}
Expand Down
Binary file modified src/ops/base/Ops.Value.Boolean/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dfa658a

Please sign in to comment.