Merge a1b43ac3239dc79ca

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-10-30 01:06:23 +00:00
commit cb2edd5044
38 files changed
+879 -60

No files matched your search

+5
View File
@@ -233,6 +233,11 @@ export class ProjectDocument {
return this.handle ? core().doc_drawing_line_verts(this.handle) : new Float32Array(0);
}
/** Ansichtsschraffur auf den Flächen (Wände, Decken, Dächer) für render3d `set_pattern_lines`. */
surfacePatternLines(): Float32Array {
return this.handle ? core().doc_surface_pattern_lines(this.handle) : new Float32Array(0);
}
/** Das Dokument als JSON-Text (Test, Export). */
json(): string {
return this.handle ? core().doc_json(this.handle) : "";
+2
View File
@@ -198,6 +198,7 @@ export {
viewForScale,
visibleEdgeRuns,
} from "../plan/planView/geometry";
export { PLAN_DASH_VAR, dashArrayCss, fitDashToPeriod, hatchDashVb, lineDashVb } from "../plan/planView/dashVb";
export {
type ClientMap,
@@ -241,6 +242,7 @@ export {
TRUCK_MESH_READY_EVENT,
draftWorldLines,
emitDrawingLineVerts,
emitSurfacePatternLines,
pickGeometry,
projectToModel3d,
selectionHighlightLines,
+8
View File
@@ -1242,6 +1242,14 @@ export const de = {
"material.fetchAmbient.hint": "Lädt die Texturkarten dieses ambientCG-Materials (CC0) herunter.",
"resources.loadStandards": "Standards laden",
"resources.loadStandards.hint": "Ergänzt die SIA-400-Standards (Baustoffe mit Schraffur, Ansichtsschraffur, Textur und Kennwerten, Linientypen, Wand-/Decken-/Dachaufbauten). Vorhandene Einträge (gleiche id oder gleicher Name) bleiben unverändert.",
"resources.loadStandards.added": "{list} hinzugefügt",
"resources.loadStandards.none": "Standards: alles schon vorhanden",
"resources.loadStandards.n.components": "{n} Baustoffe",
"resources.loadStandards.n.wallTypes": "{n} Wandaufbauten",
"resources.loadStandards.n.ceilingTypes": "{n} Deckenaufbauten",
"resources.loadStandards.n.roofTypes": "{n} Dachaufbauten",
"resources.loadStandards.n.hatches": "{n} Schraffuren",
"resources.loadStandards.n.lineStyles": "{n} Linientypen",
"resources.col.lambda": "Wärmeleitfähigkeit λ [W/mK]",
"resources.col.density": "Rohdichte [kg/m³]",
"resources.col.fireClass": "Brandverhalten (VKF)",
+8
View File
@@ -1235,6 +1235,14 @@ export const en: Record<TranslationKey, string> = {
"material.fetchAmbient.hint": "Downloads the texture maps of this ambientCG material (CC0).",
"resources.loadStandards": "Load standards",
"resources.loadStandards.hint": "Adds the SIA 400 standards (materials with hatch, surface pattern, texture and physical values, line types, wall/ceiling/roof build-ups). Existing entries (same id or same name) stay unchanged.",
"resources.loadStandards.added": "Added {list}",
"resources.loadStandards.none": "Standards: everything already present",
"resources.loadStandards.n.components": "{n} materials",
"resources.loadStandards.n.wallTypes": "{n} wall build-ups",
"resources.loadStandards.n.ceilingTypes": "{n} ceiling build-ups",
"resources.loadStandards.n.roofTypes": "{n} roof build-ups",
"resources.loadStandards.n.hatches": "{n} hatches",
"resources.loadStandards.n.lineStyles": "{n} line types",
"resources.col.lambda": "Thermal conductivity λ [W/mK]",
"resources.col.density": "Density [kg/m³]",
"resources.col.fireClass": "Reaction to fire (VKF)",
+10 -1
View File
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import { emptyProject, sampleProject } from "./sampleProject";
import { standardsMergeOps, withStandards } from "./standards";
import { standardsMergeCounts, standardsMergeOps, withStandards } from "./standards";
describe("Standard-Bibliothek ([100]–[102])", () => {
it("bringt Baustoffe, Linientypen und Aufbauten in ein neues Projekt", () => {
@@ -27,4 +27,13 @@ describe("Standard-Bibliothek ([100]–[102])", () => {
expect(p.components.length).toBeGreaterThan(sampleProject.components.length);
expect(standardsMergeOps(p)).toEqual([]);
});
it("zählt, was „Standards laden“ hinzufügt (Rückmeldung)", () => {
const empty = { ...emptyProject, components: [], hatches: [], lineStyles: [], wallTypes: [], ceilingTypes: [], roofTypes: [] };
const c = standardsMergeCounts(standardsMergeOps(empty));
expect(c.components).toBe(34);
expect(c.lineStyles).toBeGreaterThan(5);
expect(c.wallTypes + c.ceilingTypes + c.roofTypes).toBe(5);
expect(standardsMergeCounts(standardsMergeOps(withStandards(empty)))).toEqual({ lineStyles: 0, hatches: 0, components: 0, wallTypes: 0, ceilingTypes: 0, roofTypes: 0 });
});
});
+20
View File
@@ -17,3 +17,23 @@ export function standardsMergeOps(project: Project): CoreOp[] {
export function withStandards(project: Project): Project {
return applyOps(project, standardsMergeOps(project));
}
/** Was „Standards laden" anhängt: Anzahl neuer Einträge je Projekt-Liste (für die Rückmeldung). */
export interface StandardsMergeCounts {
lineStyles: number;
hatches: number;
components: number;
wallTypes: number;
ceilingTypes: number;
roofTypes: number;
}
export function standardsMergeCounts(ops: readonly CoreOp[]): StandardsMergeCounts {
const out: StandardsMergeCounts = { lineStyles: 0, hatches: 0, components: 0, wallTypes: 0, ceilingTypes: 0, roofTypes: 0 };
for (const op of ops) {
const key = op.kind === "add" ? op.collection : op.kind === "setField" ? op.key : null;
const n = op.kind === "add" ? op.items.length : op.kind === "setField" && Array.isArray(op.value) ? op.value.length : 0;
if (key && key in out) out[key as keyof StandardsMergeCounts] += n;
}
return out;
}
+12 -4
View File
@@ -139,10 +139,18 @@ describe("generatePlan — Dächer (Dachaufsicht)", () => {
],
roofTypes: [{ id: "rt1", name: "Dach", layers: [{ componentId: "tile", thickness: 0.05 }] }],
};
const polys = generatePlan(p, "eg", visible).primitives.filter(
(pr): pr is Extract<typeof pr, { kind: "polygon" }> =>
pr.kind === "polygon" && (pr as { roofId?: string }).roofId === "R9",
);
const roofPolys = (proj: Project) =>
generatePlan(proj, "eg", visible).primitives.filter(
(pr): pr is Extract<typeof pr, { kind: "polygon" }> =>
pr.kind === "polygon" && (pr as { roofId?: string }).roofId === "R9",
);
// Dach über der Schnittebene (Schnitt 1 m, Traufe 2.6 m): nicht von oben gesehen → ohne Schraffur.
const over = roofPolys(p);
expect(over.length).toBe(1);
expect(over[0].hatch.pattern).toBe("none");
// Schnitt über dem First: Dachaufsicht mit Ansichtsschraffur.
const seen = { ...p, drawingLevels: p.drawingLevels.map((l) => (l.id === "eg" ? { ...l, cutHeight: 20 } : l)) };
const polys = roofPolys(seen);
expect(polys.length).toBe(1);
expect(polys[0].hatch.pattern).toBe("diagonal");
+30
View File
@@ -0,0 +1,30 @@
import { describe, it, expect } from "vitest";
import { dashArrayCss, fitDashToPeriod, hatchDashVb, lineDashVb } from "./dashVb";
import { PX_PER_M } from "./geometry";
describe("Strichmuster im Modell-Raum (SVG-Pfad)", () => {
it("Linientyp: Papier-mm im Plot-Massstab, unabhängig vom Zoom = Druck-SVG", () => {
// 6 mm bei 1:50 = 0.3 m Modell — wie sceneToPrintSvg (mm auf dem Blatt bei 1:50).
const vb = lineDashVb([6, 2], 50);
expect(vb[0] / PX_PER_M).toBeCloseTo(0.3, 9);
// Unter non-scaling-stroke: Bildschirm-px = vb · meet (CSS-Variable), bei zwei Zoomstufen
// dieselbe Modell-Länge.
for (const meet of [0.5, 7]) {
const px = parseFloat(dashArrayCss(vb, true)!.match(/\* ([\d.]+)px/)![1]) * meet;
expect(px / meet / PX_PER_M).toBeCloseTo(0.3, 4);
}
expect(dashArrayCss(vb, false)).toBe("27 9");
});
it("Schraffur-Strich skaliert mit der Musterskala (wie hatch::hatch_dash)", () => {
const a = hatchDashVb([1, 0.7], 0.35);
expect(a[0]).toBeCloseTo((0.35 / 0.13), 9);
expect(hatchDashVb([1], 0.35, true)[0]).toBeCloseTo(1 / 0.13, 9);
});
it("Kachel-Anpassung: ganze Perioden je Kachel", () => {
const f = fitDashToPeriod([3, 2], 8);
expect(f[0] + f[1]).toBeCloseTo(8 / 2, 9);
expect(fitDashToPeriod([], 8)).toEqual([]);
});
});
+46
View File
@@ -0,0 +1,46 @@
// Strichmuster des SVG-Plan-Pfads in viewBox-Einheiten (Modell-Raum) — wie die Engines: Linientypen in
// Papier-mm im PLOT-Massstab (render2d `ortho::dash_scale`), Schraffur-Striche gekoppelt an die
// Musterskala (Kern `hatch::hatch_dash` × `DASH_MM_TO_M`). So bleibt der Rhythmus beim Zoomen fest und
// gleicht der Druckansicht.
import { PX_PER_M } from "./geometry";
import { DASH_MM_TO_M } from "../glPlan/glPlanHatch";
/** CSS-Variable am Plan-SVG: CSS-px je viewBox-Einheit (meet), für Muster unter `non-scaling-stroke`. */
export const PLAN_DASH_VAR = "--plan-dash-k";
const clean = (v: number): number => (Number.isFinite(v) ? Math.max(0, v) : 0);
/** Linienmuster (Papier-mm) → viewBox-Einheiten im Plot-Massstab 1:`plotN` (ohne gültiges N: 1:100). */
export function lineDashVb(dash: readonly number[], plotN: number): number[] {
const n = Number.isFinite(plotN) && plotN > 0 ? plotN : 100;
return dash.map((mm) => ((clean(mm) * n) / 1000) * PX_PER_M);
}
/** Schraffur-Strichmuster (Papier-mm des Linienstils) → viewBox-Einheiten im Musterraum. */
export function hatchDashVb(dash: readonly number[], scale: number, random = false): number[] {
const k = !random && Number.isFinite(scale) && scale > 0 ? scale : 1;
return dash.map((mm) => clean(mm) * k * DASH_MM_TO_M * PX_PER_M);
}
/**
* Muster so strecken, dass eine ganze Zahl Perioden in `period` passt (SVG-`<pattern>`-Kachel: das
* Muster beginnt in jeder Kachel neu). Leeres/entartetes Muster bleibt unverändert.
*/
export function fitDashToPeriod(vb: readonly number[], period: number): number[] {
const cycle = (vb.length % 2 ? 2 : 1) * vb.reduce((s, v) => s + v, 0);
if (!(cycle > 1e-9) || !(period > 1e-9)) return [...vb];
const k = Math.max(1, Math.round(period / cycle));
const f = period / (k * cycle);
return vb.map((v) => v * f);
}
/**
* `stroke-dasharray` als CSS-Wert. Unter `non-scaling-stroke` gilt das Muster in Bildschirm-px — dann
* über die meet-Variable am SVG zurück in den Modell-Raum (`calc(var(--plan-dash-k) * Xpx)`).
*/
export function dashArrayCss(vb: readonly number[], nonScaling: boolean): string | undefined {
if (!vb.length) return undefined;
const r = (v: number) => Math.round(v * 1e4) / 1e4;
return vb.map((v) => (nonScaling ? `calc(var(${PLAN_DASH_VAR}, 1) * ${r(v)}px)` : `${r(v)}`)).join(" ");
}
+8
View File
@@ -71,6 +71,14 @@ export function emitDrawingLineVerts(project: Project): Float32Array {
return documentFor(project).drawingLineVerts();
}
/**
* Ansichtsschraffur ([100]) auf den Flächen als Linien für render3d (`set_pattern_lines`): je Linie
* `ax ay az bx by bz r g b maske` (Welt-Meter); die Maske wählt die Ausdünnung nach Abstand.
*/
export function emitSurfacePatternLines(project: Project): Float32Array {
return documentFor(project).surfacePatternLines();
}
/**
* Nur die Wände (Rückwärts-Kompatibilität / bestehende Aufrufer). Zerlegt Wände mit Öffnungen in
* Teilquader bzw. (layered) in Schicht-Bänder. Rechnet der Kern auf dem Projekt-Dokument
+11 -2
View File
@@ -57,7 +57,7 @@ import {
PEN_FALLBACK_COLOR,
PEN_FALLBACK_WEIGHT,
} from "../model/penSets";
import { standardsMergeOps } from "../model/standards";
import { standardsMergeCounts, standardsMergeOps } from "../model/standards";
import { reorderByIds } from "../model/reorder";
import { transformMutation } from "../tools/transform";
import type { CopyMode, TransformOp, TransformSelection } from "../tools/transform";
@@ -1025,7 +1025,16 @@ export function createProjectSlice(
}),
seedStandardPenSet: () => applyChange((p) => seedStandardPenSetOps(p)),
loadStandards: () => applyChange((p) => standardsMergeOps(p)),
loadStandards: () => {
// Rückmeldung, was hinzukam ([101]); ein Undo-Schritt.
const ops = standardsMergeOps(get().project);
const c = standardsMergeCounts(ops);
const parts = (["components", "wallTypes", "ceilingTypes", "roofTypes", "hatches", "lineStyles"] as const)
.filter((k) => c[k] > 0)
.map((k) => t(`resources.loadStandards.n.${k}`, { n: c[k] }));
if (ops.length) applyChange(ops);
get().notify(parts.length ? t("resources.loadStandards.added", { list: parts.join(", ") }) : t("resources.loadStandards.none"), "info");
},
addCustomPalette: () =>
applyChange(
+10 -1
View File
@@ -18,7 +18,7 @@
import { useCallback, useEffect, useRef, useState } from "react";
import type { ContextImage, Project } from "../model/types";
import { emitDrawingLineVerts, projectToModel3d } from "../core";
import { emitDrawingLineVerts, emitSurfacePatternLines, projectToModel3d } from "../core";
import type { DetailLevel } from "../model/viewTypes";
import { loadEngine3d } from "../engine/engine3d";
import { decodeMaterialTextures } from "./materialTextures";
@@ -94,6 +94,8 @@ interface WebModelRendererLike {
* `toWalls3d/drawing2d.ts::emitDrawingLineVerts`. Optional — ältere
* WASM-Builds ohne diesen Export lassen den Aufrufer still zurückfallen. */
set_drawing_lines?(vertices: Float32Array): void;
/** Ansichtsschraffur auf den Flächen (`web::set_pattern_lines`), in den Kanten-Stilen gezeichnet. */
set_pattern_lines?(data: Float32Array): void;
/** Material-Farbkarten (Stil „textured") als Textur-Array hochladen
* (`web::set_material_textures`). `rgba` = gepackte RGBA8-Bytes von
* `layerCount` 256×256-Ebenen; Ebene 0 bleibt intern das Fallback-Schachbrett,
@@ -249,6 +251,13 @@ export function useWasm3dRenderer(
console.warn("render3d set_drawing_lines fehlgeschlagen:", e);
}
}
if (typeof r.set_pattern_lines === "function") {
try {
r.set_pattern_lines(emitSurfacePatternLines(project));
} catch (e) {
console.warn("render3d set_pattern_lines fehlgeschlagen:", e);
}
}
// Material-Farbkarten (Stil „textured") ASYNCHRON dekodieren + hochladen.
// Fire-and-forget: bis die Texturen ankommen, zeigt render3d für die
// betroffenen Bänder das Fallback-Schachbrett (graceful). Nur neu laden,
+14
View File
@@ -10,6 +10,7 @@ import {
forwardRef,
useEffect,
useImperativeHandle,
useLayoutEffect,
useMemo,
useRef,
useState,
@@ -31,6 +32,7 @@ import { isGpuText } from "../../core";
import { LiveMeet, LiveValue, createMeetStore, createValueStore } from "./planView/liveMeet";
import { useWasmPlanRenderer } from "./useWasmPlanRenderer";
import { DEFAULT_MARQUEE_COLOR, DEFAULT_SNAP_COLOR } from "../../theme/accents";
import { PLAN_DASH_VAR } from "../../core";
import { type ViewBox__plan_planView_geometry as ViewBox, PX_PER_M, PAD, toScreen, clamp, meetScale, scaleFromView, viewForScale, viewForCamera, fitBoxFor, type ModelRect } from "../../core";
import {
polyUsesPattern,
@@ -938,6 +940,17 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
const [paperScale, setPaperScale] = useState<number | null>(null);
const paperScaleRef = useRef(paperScale);
paperScaleRef.current = paperScale;
// Strichmuster (Linientypen) im PLOT-Massstab: fest im Modell-Raum, auch im Anzeigemodus, wo der
// Strich-Massstab dem Zoom folgt — so gleicht der Rhythmus bei jedem Zoom der Druckansicht.
activeEngine.setDashScale(paperScale ?? 0);
// SVG-Pfad: Strichmuster unter non-scaling-stroke über die meet-Variable im Modell-Raum halten
// (`dashArrayCss`); bei jedem festgeschriebenen Ausschnitt nachgeführt, ohne React-Neuaufbau.
const syncDashVar = (v: ViewBox) => {
const el = svgRef.current;
const m = meetScale(v, canvasRef.current ?? el);
if (el && m != null && m > 0) el.style.setProperty(PLAN_DASH_VAR, String(m));
};
useLayoutEffect(() => syncDashVar(view));
// Frische Werte in Refs spiegeln, damit das (stabile) imperative Handle und
// der Resize-Beobachter stets den aktuellen Stand lesen (Handle hat leere Deps).
const viewRef = useRef(view);
@@ -1907,6 +1920,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
if (panPending.current !== v) return; // überholt oder bereits festgeschrieben
applySvgTransform(v0, v); // SVG: echter viewBox (scharf) bzw. CSS-Transform
meetStore.set(meetScale(v, canvasRef.current ?? svgRef.current));
syncDashVar(v);
viewStore.set(v);
};
if (wantNative) {
+22 -25
View File
@@ -11,6 +11,7 @@ import { quantizePen } from "../../../export/sceneToPrintSvg";
import { buildRandomHatchRuns, zigzagPoints, motifPoints, DASH_MM_TO_M } from "../../../core";
import { dashHasDot } from "../../../core";
import { HAIRLINE_PX, PX_PER_M, mmToPx, printStrokeVb, visibleEdgeRuns } from "../../../core";
import { dashArrayCss, fitDashToPeriod, hatchDashVb, lineDashVb } from "../../../core";
/** Basis-Kachelmaß (viewBox-Einheiten) einer Bild-Schraffur bei scaleX/scaleY = 1. */
const IMG_TILE_VB = 40;
@@ -68,11 +69,10 @@ export function HatchPattern({
? printStrokeVb(quantizePen(hatch.lineWeight), paperScale!)
: mmToPx(hatch.lineWeight);
const vfx = print ? undefined : ("non-scaling-stroke" as const);
const dashes = hatch.dash?.length
? hatch.dash
.map((mm) => (print ? printStrokeVb(mm, paperScale!) : mmToPx(mm)))
.join(" ")
: undefined;
// Strichmuster im Musterraum (wie Kern `hatch::hatch_dash`): fest im Modell, je Kachel ganze Perioden.
const dashVb = hatch.dash?.length ? hatchDashVb(hatch.dash, hatch.scale, hatch.lines === "random") : [];
const dashStyle = (period: number) =>
dashVb.length ? { strokeDasharray: dashArrayCss(fitDashToPeriod(dashVb, period), !print) } : undefined;
// Punktmuster in den Musterlinien: runde Kappe → Dots (Punkt/Strich-Punkt).
const dashCap = dashHasDot(hatch.dash) ? ("round" as const) : undefined;
@@ -145,7 +145,7 @@ export function HatchPattern({
fill="none"
stroke={hatch.color}
strokeWidth={sw}
strokeDasharray={dashes}
style={dashStyle(w)}
strokeLinecap={dashCap}
vectorEffect={vfx}
/>
@@ -182,7 +182,7 @@ export function HatchPattern({
fill="none"
stroke={hatch.color}
strokeWidth={sw}
strokeDasharray={dashes}
style={dashStyle(period)}
strokeLinecap={dashCap}
vectorEffect={vfx}
/>
@@ -210,7 +210,7 @@ export function HatchPattern({
y2={tile}
stroke={hatch.color}
strokeWidth={sw}
strokeDasharray={dashes}
style={dashStyle(tile)}
strokeLinecap={dashCap}
vectorEffect={vfx}
/>
@@ -222,7 +222,7 @@ export function HatchPattern({
y2={0}
stroke={hatch.color}
strokeWidth={sw}
strokeDasharray={dashes}
style={dashStyle(tile)}
strokeLinecap={dashCap}
vectorEffect={vfx}
/>
@@ -403,12 +403,8 @@ export function DrawingRunShape({
? printStrokeVb(quantizePen(run.weightMm), paperScale!)
: mmToPx(run.weightMm);
const vfx = print ? undefined : ("non-scaling-stroke" as const);
const dashStr =
run.dash && run.dash.length
? run.dash
.map((mm) => (print ? printStrokeVb(mm, paperScale!) : mmToPx(mm)))
.join(" ")
: undefined;
// Linientyp in Papier-mm im Plot-Massstab: fest im Modell-Raum (Bildschirm = Druckansicht).
const dashStr = run.dash && run.dash.length ? dashArrayCss(lineDashVb(run.dash, paperScale ?? 100), !print) : undefined;
// Zickzack-/Custom-Motiv-Lauf: im MODELL-Raum tessellieren (Papier-mm →
// Modell-Meter via DASH_MM_TO_M), dann toScreen. Sonst die Roh-Stützpunkte.
const modelPts = run.zigzag
@@ -433,7 +429,7 @@ export function DrawingRunShape({
fill="none"
stroke={stroke}
strokeWidth={sw}
strokeDasharray={dashStr}
style={dashStr ? { strokeDasharray: dashStr } : undefined}
strokeLinecap={cap}
vectorEffect={vfx}
/>
@@ -444,7 +440,7 @@ export function DrawingRunShape({
fill="none"
stroke={stroke}
strokeWidth={sw}
strokeDasharray={dashStr}
style={dashStr ? { strokeDasharray: dashStr } : undefined}
strokeLinecap={cap}
vectorEffect={vfx}
/>
@@ -508,11 +504,12 @@ export function renderPrimitive(
const vfx = print ? undefined : ("non-scaling-stroke" as const);
// Strichmuster: im Print-Modus ebenfalls in viewBox-Einheiten (skaliert mit),
// sonst wie bisher in Bildschirm-px (non-scaling).
const dashOf = (dash: number[] | null | undefined): string | undefined => {
// Linientypen in Papier-mm im Plot-Massstab: fest im Modell-Raum, auch unter non-scaling-stroke
// (über die meet-Variable am SVG) — der Rhythmus gleicht bei jedem Zoom der Druckansicht.
const dashOf = (dash: number[] | null | undefined): { strokeDasharray: string } | undefined => {
if (!dash || !dash.length) return undefined;
return dash
.map((mm) => (print ? printStrokeVb(mm, paperScale!) : mmToPx(mm)))
.join(" ");
const css = dashArrayCss(lineDashVb(dash, paperScale ?? 100), !print);
return css ? { strokeDasharray: css } : undefined;
};
switch (p.kind) {
case "polygon": {
@@ -670,7 +667,7 @@ export function renderPrimitive(
className={p.cls}
stroke={p.color}
strokeWidth={weight(p.weightMm)}
strokeDasharray={dashOf(p.dash)}
style={dashOf(p.dash)}
strokeLinecap={dashHasDot(p.dash) ? "round" : undefined}
vectorEffect={vfx}
/>
@@ -693,7 +690,7 @@ export function renderPrimitive(
d={d}
className={p.cls}
strokeWidth={weight(p.weightMm)}
strokeDasharray={dashOf(p.dash)}
style={dashOf(p.dash)}
strokeLinecap={dashHasDot(p.dash) ? "round" : undefined}
vectorEffect={vfx}
/>
@@ -892,7 +889,7 @@ export function renderPrimitive(
fill={p.fill}
stroke={p.stroke}
strokeWidth={weight(p.weightMm)}
strokeDasharray={dashOf(p.dash)}
style={dashOf(p.dash)}
vectorEffect={vfx}
/>
);
@@ -920,7 +917,7 @@ export function renderPrimitive(
fill="none"
stroke={p.stroke}
strokeWidth={weight(p.weightMm)}
strokeDasharray={dashOf(p.dash)}
style={dashOf(p.dash)}
strokeLinecap={dashHasDot(p.dash) ? "round" : undefined}
vectorEffect={vfx}
/>
+7 -1
View File
@@ -297,6 +297,11 @@ export function useNativePlanRenderer(
pushTexts(plan);
}, [pushTexts, takeFullLayout]);
// Plot-Massstab der Strichmuster (`setDashScale`), mit jedem Frame gesendet.
const dashScaleRef = useRef(0);
const setDashScale = useCallback((n: number) => {
dashScaleRef.current = n > 0 && isFinite(n) ? n : 0;
}, []);
const render = useCallback(
(viewBox: ViewBox, paperScaleN = 100, _textScale?: number, onApplied?: () => void) => {
const invoke = invokeRef.current;
@@ -310,6 +315,7 @@ export function useNativePlanRenderer(
invoke('native2d_frame', {
view: viewBox,
paperScale: paperScaleN,
dashScale: dashScaleRef.current || null,
clear: sheet ? [sheet[0], sheet[1], sheet[2]] : null,
}).then(
(r) => {
@@ -326,5 +332,5 @@ export function useNativePlanRenderer(
[sendFrame, syncRect],
);
return { render, updateGeometry, ready, gpuTexts, setExcludedText, setHighlight };
return { render, updateGeometry, ready, gpuTexts, setExcludedText, setHighlight, setDashScale };
}
+8 -3
View File
@@ -13,7 +13,7 @@
* „letzte Szene gewinnt" regelt `WasmPlanRendererSession` (wasmRendererSession.ts).
*/
import { useCallback, useEffect, useState } from "react";
import { useCallback, useEffect, useRef, useState } from "react";
import type { Plan } from "../../core";
import { planSceneBin } from "../../core";
import { type WebPlanRendererLike, WasmPlanRendererSession } from "./wasmRendererSession";
@@ -125,6 +125,11 @@ export function useWasmPlanRenderer(
* Anzeigemodus, siehe PlanView.tsx `textScaleForGl`), während `paperScaleN`
* weiter die echten Papier-mm-Strichbreiten der Geometrie treibt.
*/
// Plot-Massstab der Strichmuster (`setDashScale`), beim nächsten Frame übernommen.
const dashScaleRef = useRef(0);
const setDashScale = useCallback((n: number) => {
dashScaleRef.current = n > 0 && isFinite(n) ? n : 0;
}, []);
const render = useCallback(
(viewBox: ViewBox, paperScaleN = 100, textScaleN = 100) => {
const canvas = canvasRef.current;
@@ -137,10 +142,10 @@ export function useWasmPlanRenderer(
canvas.width = width;
canvas.height = height;
}
session.draw({ viewBox, paperScaleN, textScaleN, width, height });
session.draw({ viewBox, paperScaleN, textScaleN, dashScaleN: dashScaleRef.current, width, height });
},
[canvasRef, session],
);
return { render, updateGeometry, ready };
return { render, updateGeometry, ready, setDashScale };
}
+5
View File
@@ -28,6 +28,8 @@ export interface WebPlanRendererLike {
set_view_box(x: number, y: number, w: number, h: number): void;
set_paper_scale(n: number): void;
set_text_scale(n: number): void;
/** Plot-Massstab der Strichmuster (fest im Modell-Raum; 0 = wie `set_paper_scale`). */
set_dash_scale?(n: number): void;
resize(w: number, h: number): void;
render(): void;
/** true, sobald das WebGPU-Gerät verloren ist (dann zeichnet der Renderer nichts mehr). */
@@ -42,6 +44,8 @@ export interface PlanFrame {
viewBox: { x: number; y: number; w: number; h: number };
paperScaleN: number;
textScaleN: number;
/** Plot-Massstab (1:N) der Strichmuster, unabhängig vom Zoom; 0/fehlend = wie `paperScaleN`. */
dashScaleN?: number;
width: number;
height: number;
}
@@ -215,6 +219,7 @@ export class WasmPlanRendererSession<S> {
r.resize(f.width, f.height);
r.set_paper_scale(f.paperScaleN);
r.set_text_scale(f.textScaleN);
r.set_dash_scale?.(f.dashScaleN ?? 0);
r.set_view_box(f.viewBox.x, f.viewBox.y, f.viewBox.w, f.viewBox.h);
r.render();
}