From 788f4d58caeb07cb24d78782480776f3455830ea Mon Sep 17 00:00:00 2001 From: Karim Date: Thu, 2 Jul 2026 18:58:13 +0200 Subject: [PATCH] Nativer 2D-Viewport: Schraffuren wie im Browser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit toRenderScene emittiert jetzt die aufs Polygon geclippten Musterlinien (glPlanHatch: buildHatchRuns + applyDashRuns) als Polylinien — Daemmung/Diagonal/Kreuz erscheinen im nativen wgpu-Grundriss identisch zum WebGL-Pfad. 'none'/'solid' brauchen keine Linien (solid deckt die Fuellung farbig ab). --- src/plan/toRenderScene.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/plan/toRenderScene.ts b/src/plan/toRenderScene.ts index a3bdd14..c41b4fb 100644 --- a/src/plan/toRenderScene.ts +++ b/src/plan/toRenderScene.ts @@ -8,6 +8,7 @@ // mit Point = [x,y] (Meter) und Rgba = [r,g,b,a] (0..1). import type { Plan, Primitive } from "./generatePlan"; +import { applyDashRuns, buildHatchRuns } from "./glPlan/glPlanHatch"; type LinePrim = Extract; @@ -177,6 +178,20 @@ export function planToRenderScene(plan: Plan): RScene { const fillCol = toRgba(p.fill, 1); if (fillCol && pts.length >= 3) fills.push({ pts, color: fillCol }); + // Schraffur: die aufs Polygon geclippten Musterlinien wie im Browser + // (glPlanHatch — identische Geometrie), als Polylinien. "none"/"solid" + // brauchen keine Linien (solid deckt die Füllung farbig ab). + if (p.hatch && p.hatch.pattern !== "none" && p.hatch.pattern !== "solid") { + const hatchCol = toRgba(p.hatch.color, 1) ?? [0.1, 0.1, 0.1, 1]; + const hatchMm = p.hatch.lineWeight > 0 ? p.hatch.lineWeight : 0.13; + const runs = applyDashRuns(buildHatchRuns(p.pts, p.hatch), p.hatch.dash); + for (const run of runs) { + if (run.length >= 2) { + polylines.push({ pts: run.map((v) => [v.x, v.y]), color: hatchCol, widthMm: hatchMm }); + } + } + } + // Umriss const strokeCol = toRgba(p.stroke, 1); if (strokeCol && p.strokeWidthMm > 0) {