task(CAD-7): magnetic truss tool - drag placement with length options, snapTrussToDock end-to-end docking with rotation inheritance, opposite direction at start endpoints, truss rendering with belt lines
This commit is contained in:
@@ -399,6 +399,42 @@ export function elementToPrimitives(el: CADElement, attrDefs?: Array<{ tag: stri
|
||||
return [];
|
||||
}
|
||||
|
||||
case 'truss': {
|
||||
// Traverse (CAD-7): Balken als Rechteck + 2 Gurtlinien entlang
|
||||
// der Rotation (wie ein Fachwerk-Profil)
|
||||
const length = (props.length as number | undefined) ?? el.width;
|
||||
const rotDeg = (props.rotation as number | undefined) ?? 0;
|
||||
const rad = (rotDeg * Math.PI) / 180;
|
||||
const dx = Math.cos(rad) * (length / 2);
|
||||
const dy = Math.sin(rad) * (length / 2);
|
||||
const nx = -Math.sin(rad) * 10; // Normalen-Offset (halbe Hoehe)
|
||||
const ny = Math.cos(rad) * 10;
|
||||
const c = { x: el.x, y: el.y };
|
||||
return [
|
||||
{
|
||||
kind: 'rect',
|
||||
x: c.x - dx, y: c.y - dy,
|
||||
w: length, h: 20,
|
||||
fill: fillOrNull(props.fill) ?? '#6b7280',
|
||||
stroke: (props.stroke as string | undefined) ?? '#9aa0a6',
|
||||
strokeWidth: 2,
|
||||
},
|
||||
// Gurtlinien oben/unten entlang der Traverse
|
||||
{
|
||||
kind: 'line',
|
||||
from: { x: c.x - dx + nx, y: c.y - dy + ny },
|
||||
to: { x: c.x + dx + nx, y: c.y + dy + ny },
|
||||
stroke: '#4b5563', strokeWidth: 1,
|
||||
},
|
||||
{
|
||||
kind: 'line',
|
||||
from: { x: c.x - dx - nx, y: c.y - dy - ny },
|
||||
to: { x: c.x + dx - nx, y: c.y + dy - ny },
|
||||
stroke: '#4b5563', strokeWidth: 1,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
case 'barrier': {
|
||||
// Absperrung (Task E7): Kette aus Kreis-Paaren (properties.circles).
|
||||
const circles = Array.isArray(props.circles)
|
||||
|
||||
Reference in New Issue
Block a user