|
18 | 18 | const EPSILON = 1e-6; |
19 | 19 | const INSIDE = 1; |
20 | 20 | const OUTSIDE = 0; |
| 21 | + |
21 | 22 | function clipT(num, denom, c) { |
22 | 23 | /* eslint-disable one-var,no-param-reassign,prefer-destructuring,operator-linebreak */ |
23 | 24 | /* eslint-disable one-var-declaration-per-line,nonblock-statement-body-position,curly */ |
@@ -828,14 +829,90 @@ export class CircuitBoardLines { |
828 | 829 | return false; |
829 | 830 | } |
830 | 831 |
|
831 | | - this.recalcMapLinksCheck(); |
| 832 | + try { |
| 833 | + this.recalcMapLinksCheck(); |
| 834 | + |
| 835 | + this.mapLinks.drawLinks(ctx); |
832 | 836 |
|
833 | | - this.mapLinks.drawLinks(ctx); |
834 | | - this.lastDrawConnections = new Date().getTime(); |
| 837 | + if (this.canvas.subgraph) { |
| 838 | + this.drawSubgraphConnections(ctx, this.canvas.graph, this.canvas.subgraph); |
| 839 | + } |
| 840 | + } catch(e) { |
| 841 | + console.error('drawConnections crash', e); |
| 842 | + } finally { |
| 843 | + this.lastDrawConnections = new Date().getTime(); |
| 844 | + } |
835 | 845 |
|
836 | 846 | return true; |
837 | 847 | } |
838 | 848 |
|
| 849 | + drawSubgraphConnections( |
| 850 | + ctx, |
| 851 | + graph, |
| 852 | + subgraph, |
| 853 | + ) { |
| 854 | + for (const output of subgraph.inputNode.slots) { // eslint-disable-line no-restricted-syntax |
| 855 | + if (!output.linkIds.length) { |
| 856 | + continue; |
| 857 | + } |
| 858 | + |
| 859 | + // find link info |
| 860 | + for (const linkId of output.linkIds) { // eslint-disable-line no-restricted-syntax |
| 861 | + const resolved = LiteGraph.LLink.resolve(linkId, graph); |
| 862 | + if (!resolved) continue; |
| 863 | + |
| 864 | + const { link, inputNode, input } = resolved; |
| 865 | + if (!inputNode || !input) |
| 866 | + continue; |
| 867 | + |
| 868 | + const endPos = inputNode.getInputPos(link.target_slot); |
| 869 | + |
| 870 | + const startDir = input.dir || LiteGraph.RIGHT; |
| 871 | + const endDir = input.dir || LiteGraph.LEFT; |
| 872 | + |
| 873 | + this.canvas.renderLink( |
| 874 | + ctx, |
| 875 | + output.pos, |
| 876 | + endPos, |
| 877 | + link, |
| 878 | + false, |
| 879 | + 0, |
| 880 | + null, |
| 881 | + startDir, |
| 882 | + endDir, |
| 883 | + ); |
| 884 | + } |
| 885 | + } |
| 886 | + |
| 887 | + for (const input of subgraph.outputNode.slots) { // eslint-disable-line no-restricted-syntax |
| 888 | + if (!input.linkIds.length) continue; |
| 889 | + |
| 890 | + // find link info |
| 891 | + const resolved = LiteGraph.LLink.resolve(input.linkIds[0], graph); |
| 892 | + if (!resolved) continue; |
| 893 | + |
| 894 | + const { link, outputNode, output } = resolved; |
| 895 | + if (!outputNode || !output) continue; |
| 896 | + |
| 897 | + const startPos = outputNode.getOutputPos(link.origin_slot); |
| 898 | + |
| 899 | + const startDir = output.dir || LiteGraph.RIGHT; |
| 900 | + const endDir = input.dir || LiteGraph.LEFT; |
| 901 | + |
| 902 | + this.canvas.renderLink( |
| 903 | + ctx, |
| 904 | + startPos, |
| 905 | + input.pos, |
| 906 | + link, |
| 907 | + false, |
| 908 | + 0, |
| 909 | + null, |
| 910 | + startDir, |
| 911 | + endDir, |
| 912 | + ); |
| 913 | + } |
| 914 | + } |
| 915 | + |
839 | 916 | init() { |
840 | 917 | const oldDrawConnections = LGraphCanvas.prototype.drawConnections; |
841 | 918 | const t = this; |
|
0 commit comments