| 82 | const bridgeSet = new Set(); |
| 83 | |
| 84 | const addBridge = (x, y, r, rotation) => { |
| 85 | let offsetY = 0; |
| 86 | if (rotation === 0 || rotation === 90) { |
| 87 | offsetY = -r; |
| 88 | } else if (rotation === 180 || rotation === 270) { |
| 89 | offsetY = r; |
| 90 | } |
| 91 | |
| 92 | const finalX = x; |
| 93 | const finalY = y + offsetY; |
| 94 | const key = `${Math.round(finalX)},${Math.round(finalY)},${rotation}`; |
| 95 | if (!bridgeSet.has(key)) { |
| 96 | bridgeSet.add(key); |
| 97 | bridges.push({ id: `bridge-${bridges.length}`, x: finalX, y: finalY, r, rotation }); |
| 98 | } |
| 99 | }; |
| 100 | |
| 101 | for (let i = 0; i < shapes.length; i++) { |
| 102 | for (let j = 0; j < shapes.length; j++) { |