+40
-1
src/utils/clipboard.ts
+40
-1
src/utils/clipboard.ts
···
7
7
8
8
for(let node of selectedNodes){
9
9
arr.push({
10
+
id: node.id,
10
11
type_id: node.typeId,
11
12
statics: node.statics,
12
13
x: node.x - mousePos[0],
13
-
y: node.y - mousePos[1]
14
+
y: node.y - mousePos[1],
15
+
outputs: node.outputs.map(x => {
16
+
return x.connections.map(x => {
17
+
return { node: x.parent.id, index: x.index } }) })
14
18
})
15
19
}
16
20
21
+
for(let node of arr){
22
+
for(let output of node.outputs){
23
+
for(let i in output){
24
+
let indx = arr.findIndex(x => x.id === output[i].node);
25
+
if(indx === -1)
26
+
delete output[i];
27
+
else
28
+
output[i].node = indx;
29
+
}
30
+
}
31
+
}
32
+
33
+
for(let node of arr)delete node.id;
34
+
35
+
console.log(arr);
17
36
return 'VRCMACRO' + btoa(JSON.stringify(arr));
18
37
}
19
38
···
35
54
await n.onStaticsUpdate(n);
36
55
37
56
nodes.push(n);
57
+
}
58
+
59
+
for(let i in nodes){
60
+
let outputs: { node: number, index: number }[][] = json[i].outputs;
61
+
let node = nodes[i];
62
+
63
+
for(let j in outputs){
64
+
let output = node.outputs[j];
65
+
66
+
for(let k in outputs[j]){
67
+
let connection = outputs[j][k];
68
+
if(!connection)continue;
69
+
70
+
let peerNode = nodes[connection.node];
71
+
let input = peerNode.inputs[connection.index];
72
+
73
+
output.connections.push(input);
74
+
input.connections.push(output);
75
+
}
76
+
}
38
77
}
39
78
40
79
return nodes;