[K4] Aufräumen: tote TS-Funktionen und Bindungen gelöscht, Höhenregeln/JS-Helfer im Kern zusammengelegt

Gelöscht: vertikale Ausdehnungen in model/wall.ts und geometry/opening.ts (ohne Aufrufer seit dem
Schnitt-Port), weitere ungenutzte Exporte (types.ts, ceiling.ts, glPlan, toWalls3d, truckSolid,
meshImport, bulge, planView) und die Bindungen doc_query, core_version, drawing3d_*,
bulge_between_angles, scatter_strokes_flat. Rust: model/helpers.rs::heights für typisierte Sicht
und rohe Wurzel, truthy/or_zero/js_string/arr je einmal.
This commit is contained in:
Claude committed 2026-10-29 13:08:08 +00:00
1 parent 24ab554c2e
commit 8b94abd854
38 files changed
+125 -505

No files matched your search

+19
View File
@@ -701,6 +701,25 @@ truck (`trucksolid`) bleibt eigenes WASM-Modul (Panic-Isolation), wird vom Kern
~1 ms → 0,2–0,5 ms, 5000 Punkte 18–22 → 9–16 ms; Auswahl (300 Wände) verschieben unverändert (5–11 ms). Bleibt:
die Kopie der Liste in TS je Änderung (`slice` von 20 000 Elementen ≈ 0,14 ms) — Preis der unveränderlichen
Leseansicht. Nicht in der Tauri-App geprüft.
**Aufräumen nach den parallelen Ports (29.10.):** Suche nach toten Exporten (Skript über alle `src/**/*.ts`:
Export ohne Nutzer ausser Tests/Fassade) und toten Bindungen (`#[wasm_bindgen]` ohne TS-Aufrufer), dazu
`cargo clippy` (dead_code, auch Web-Build). Gelöscht (TS): `wallVerticalExtent`/`ceilingVerticalExtent`/
`columnVerticalExtent` (`model/wall.ts`, Aufrufer `toSection`/`voids`/`sectionOpenings`/`toElevation` gab es
nicht mehr; Tests über die Kern-Abfrage `verticalExtents` bzw. Rust-Tests), `openingVerticalExtent`/
`wallAxisFrame`/`openingCenter` (`geometry/opening.ts`), `isValidOutline`/`outlineCentroid`, `getStairType`/
`openingsOfWall`/`openingLabel`/`columnLabel`/`getComponent` (`types.ts`), `MONO_INK`/`WALL_FALLBACK_MM`,
`scatterStrokes`, `ShaderProgram`, `SLAB_RGB`/`DRAWING_LINE_FALLBACK_RGB`, `booleanMesh` samt Typen,
`meshBytesToImportedMeshes`, `IDEAL_RISER`, `bulgeBetweenAngles`, `pointSegDistPx`, `coreReady`. Bindungen:
`doc_query`, `core_version`, `drawing3d_line_verts`/`drawing3d_pick_segs` (`web/drawing2d_3d.rs`),
`bulge_between_angles`, `scatter_strokes_flat`. Rust zusammengelegt: Höhenregeln (UK/OK von Wand/Stütze/Decke,
Geschoss-Bindung) einmal in `model/helpers.rs::heights` für typisierte Sicht und rohe Wurzel (`selection_info.rs`);
JS-Wahrheitswert `truthy` (vorher je eine Kopie in `geo_translate`/`layers`/`pens`) aus `grips`; `finite` →
`jsnum::or_zero` (Kopien in `kennzahlen`/`flaechen`/`room_program`); JS-`String(v)` einmal in
`js_fmt::js_string` (vorher `project_format` und `selection_info`, letztere ohne Listen); `arr` aus `grips`.
Bleibt bewusst: `geometry/geomTransform.ts` (Werkzeuge, zieht mit [K4] S3 Werkzeuge in den Kern), TS-Fassaden,
die nur Tests nutzen (`solidVolume`, `withoutHoles`, `straightSkeleton`, `stairCut`, `triangulate`,
Schraffur-Clipping in `glPlanHatch.ts`, `subtractRings` — prüfen Kern-Bindungen von TS aus), mehrere
`signed_area`/`bbox`-Varianten in Rust (verschiedene Punkt-Typen, teils mit JS-Semantik `jsnum::min`).
- ◐ **S4 Typen aus Rust**: `types.ts` wird aus den Rust-Strukturen erzeugt (ts-rs); Datei-I/O (`projectFormat`, Migration, IFC/DXF/
STEP-Ex- und -Import) im Kern.
**Typen (28.10.):** Das Rust-Modell (`core/src/model/generated.rs`, `manual.rs`) ist die Quelle; ts-rs 12 (MIT, nur
+1 -7
View File
@@ -81,13 +81,7 @@ fn area_kind(r: &Room) -> usize {
kennzahlen::category_index(r.sia_category)
}
fn finite(v: f64) -> f64 {
if v.is_finite() {
v
} else {
0.0
}
}
use crate::jsnum::or_zero as finite;
/// Woher das Gebäudevolumen kommt.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
+1 -9
View File
@@ -20,15 +20,7 @@ fn shift_all(v: Option<&Value>, dx: f64, dy: f64) -> Value {
Value::Array(v.and_then(Value::as_array).map(|a| a.iter().map(|p| shift(p, dx, dy)).collect()).unwrap_or_default())
}
fn truthy(v: Option<&Value>) -> bool {
match v {
None | Some(Value::Null) => false,
Some(Value::Bool(b)) => *b,
Some(Value::Number(n)) => n.as_f64().is_some_and(|f| f != 0.0 && !f.is_nan()),
Some(Value::String(s)) => !s.is_empty(),
Some(_) => true,
}
}
use crate::grips::truthy;
/// `{...m, key: v}` — ein vorhandener Schlüssel behält seine Stelle; `None` = `undefined` (Feld entfällt).
fn set(m: &mut Map<String, Value>, key: &str, v: Option<Value>) {
+1 -1
View File
@@ -161,7 +161,7 @@ fn calc(f: f64) -> Pass {
Pass { f, v: Some(js_num(f)) }
}
fn arr(v: Option<&Value>) -> &[Value] {
pub fn arr(v: Option<&Value>) -> &[Value] {
v.and_then(Value::as_array).map(Vec::as_slice).unwrap_or(&[])
}
+13
View File
@@ -109,6 +109,19 @@ pub fn js_number(x: f64) -> String {
format!("{sign}{body}")
}
/// JS-`String(v)` eines JSON-Werts (Meldungen, Anzeige-Texte).
pub fn js_string(v: &serde_json::Value) -> String {
use serde_json::Value;
match v {
Value::Null => "null".into(),
Value::Bool(b) => b.to_string(),
Value::Number(n) => n.as_f64().map_or(n.to_string(), js_number),
Value::String(s) => s.clone(),
Value::Array(a) => a.iter().map(|x| if x.is_null() { String::new() } else { js_string(x) }).collect::<Vec<_>>().join(","),
Value::Object(_) => "[object Object]".into(),
}
}
#[cfg(test)]
mod tests {
use super::*;
+10
View File
@@ -85,6 +85,16 @@ mod trig {
pub use trig::{acos, atan2, cos, pow, sin, tan};
/// Endliche Zahl oder 0 (NaN/±∞ → 0; Summen der Kennzahlen/Flächen).
#[inline]
pub fn or_zero(v: f64) -> f64 {
if v.is_finite() {
v
} else {
0.0
}
}
/// `Math.min(a, b)` (NaN gewinnt; −0 < +0).
#[inline]
pub fn min(a: f64, b: f64) -> f64 {
+1 -7
View File
@@ -11,13 +11,7 @@ use crate::flat_read::signed_area;
/// Anzahl der SIA-416-Blattkategorien (Reihenfolge: `room_area::CATEGORIES`).
pub const CATEGORIES: usize = crate::room_area::CATEGORIES.len();
fn finite(v: f64) -> f64 {
if v.is_finite() {
v
} else {
0.0
}
}
use crate::jsnum::or_zero as finite;
/// Volumen (m³): Grundfläche (Polygon `points` oder Kreis mit Radius `circle_r`, NaN = kein
/// Kreis), Höhe, Verjüngung `taper` (0 = Prisma, 1 = Spitze; ausserhalb geklemmt, NaN = 0).
+1 -10
View File
@@ -11,16 +11,7 @@ use std::collections::HashSet;
type Tree = Vec<Value>;
/// JS-Wahrheitswert eines JSON-Werts (`if (c.visible)`).
fn truthy(v: Option<&Value>) -> bool {
match v {
None | Some(Value::Null) => false,
Some(Value::Bool(b)) => *b,
Some(Value::Number(n)) => n.as_f64().is_some_and(|f| f != 0.0 && !f.is_nan()),
Some(Value::String(s)) => !s.is_empty(),
Some(_) => true,
}
}
use crate::grips::truthy;
fn code_of(c: &Value) -> Option<&str> {
c.get("code").and_then(Value::as_str)
+44 -10
View File
@@ -118,7 +118,7 @@ impl Project {
VerticalAnchor::Custom { z } => Some(*z),
VerticalAnchor::Floor { floor_id, offset } => {
let f = self.floor(floor_id)?;
Some(f.base_elevation.unwrap_or(0.0) + offset.unwrap_or(0.0))
Some(heights::floor_anchor(f.base_elevation.unwrap_or(0.0), offset.unwrap_or(0.0)))
}
}
}
@@ -126,16 +126,12 @@ impl Project {
/// (UK, OK) einer Wand in Metern (`wallVerticalExtent`).
pub fn wall_vertical_extent(&self, w: &Wall) -> (f64, f64) {
let floor_base = self.floor(&w.floor_id).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0));
let bottom = self.resolve_anchor(w.bottom.as_ref()).unwrap_or(floor_base);
let top = self.resolve_anchor(w.top.as_ref()).unwrap_or(bottom + w.height);
(bottom, top)
heights::element(floor_base, self.resolve_anchor(w.bottom.as_ref()), self.resolve_anchor(w.top.as_ref()), w.height)
}
pub fn ceiling_vertical_extent(&self, c: &Ceiling) -> (f64, f64) {
let floor_top = self.floor(&c.floor_id).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0) + f.floor_height.unwrap_or(0.0));
let top = self.resolve_anchor(c.top.as_ref()).unwrap_or(floor_top);
let bottom = self.resolve_anchor(c.bottom.as_ref()).unwrap_or(top - self.ceiling_thickness(c));
(bottom, top)
heights::ceiling(floor_top, self.resolve_anchor(c.bottom.as_ref()), self.resolve_anchor(c.top.as_ref()), || self.ceiling_thickness(c))
}
pub fn stair_vertical_extent(&self, s: &Stair) -> (f64, f64) {
@@ -150,9 +146,7 @@ impl Project {
pub fn column_vertical_extent(&self, c: &Column) -> (f64, f64) {
let floor_base = self.floor(&c.floor_id).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0));
let bottom = self.resolve_anchor(c.bottom.as_ref()).unwrap_or(floor_base);
let top = self.resolve_anchor(c.top.as_ref()).unwrap_or(bottom + c.height);
(bottom, top)
heights::element(floor_base, self.resolve_anchor(c.bottom.as_ref()), self.resolve_anchor(c.top.as_ref()), c.height)
}
/// Traufhöhe (absolutes Z): `baseElevation`, sonst Oberkante des Geschosses (`roofBaseElevation`).
@@ -227,3 +221,43 @@ impl Stair {
]
}
}
/// Höhenregeln (UK/OK) — eine Fassung für die typisierte Sicht (oben) und die rohe Projekt-Wurzel
/// (`selection_info.rs`: Objekt-Info, 3D-Griffe); die Aufrufer lösen nur ihre Eingaben auf.
pub mod heights {
/// Bindung „Geschoss“: Basis des Geschosses + Versatz.
pub fn floor_anchor(base: f64, offset: f64) -> f64 {
base + offset
}
/// Wand/Stütze: UK aus der Bindung `bottom`, sonst Geschoss-Basis; OK aus `top`, sonst UK + Höhe.
pub fn element(floor_base: f64, bottom: Option<f64>, top: Option<f64>, height: f64) -> (f64, f64) {
let zb = bottom.unwrap_or(floor_base);
(zb, top.unwrap_or(zb + height))
}
/// Decke: OK aus `top`, sonst Geschoss-Oberkante; UK aus `bottom`, sonst OK − Dicke (die Decke wächst
/// nach unten; die Dicke wird nur dann bestimmt).
pub fn ceiling(floor_top: f64, bottom: Option<f64>, top: Option<f64>, thickness: impl FnOnce() -> f64) -> (f64, f64) {
let zt = top.unwrap_or(floor_top);
(bottom.unwrap_or_else(|| zt - thickness()), zt)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn wand_stuetze_und_decke() {
// Geschoss-Basis + Höhe; Bindungen übersteuern UK/OK unabhängig.
assert_eq!(element(0.0, None, None, 3.0), (0.0, 3.0));
assert_eq!(element(0.0, Some(0.5), Some(floor_anchor(3.0, 0.0)), 3.0), (0.5, 3.0));
assert_eq!(element(2.8, Some(1.0), None, 2.0), (1.0, 3.0));
// Decke: OK = Geschoss-Oberkante, UK = OK − Dicke; die Dicke nur ohne UK-Bindung.
assert_eq!(ceiling(2.6, None, None, || 0.25), (2.35, 2.6));
assert_eq!(ceiling(2.6, Some(2.2), None, || panic!("Dicke nicht gebraucht")), (2.2, 2.6));
assert_eq!(ceiling(2.6, None, Some(3.0), || 0.2), (2.8, 3.0));
assert_eq!(floor_anchor(2.8, 0.1), 2.8 + 0.1);
}
}
}
+1 -10
View File
@@ -12,16 +12,7 @@ pub const PEN_FALLBACK_COLOR: &str = "#9aa0a6";
/// Strichstärke (mm) eines Stifts ohne Eintrag.
pub const PEN_FALLBACK_WEIGHT: f64 = 0.18;
/// JS-Wahrheitswert (`if (x.colorPenId)`).
fn truthy(v: Option<&Value>) -> bool {
match v {
None | Some(Value::Null) => false,
Some(Value::Bool(b)) => *b,
Some(Value::Number(n)) => n.as_f64().is_some_and(|f| f != 0.0 && !f.is_nan()),
Some(Value::String(s)) => !s.is_empty(),
Some(_) => true,
}
}
use crate::grips::truthy;
/// Schlüssel des Stifts als Objekt-Schlüssel (JS: `pens[penId]`, eine Zahl wird zu Text).
fn key_of(v: &Value) -> Option<String> {
+1 -11
View File
@@ -32,17 +32,7 @@ pub enum Parsed {
Err(String),
}
/// JS-`String(v)` für die Meldungen.
fn js_string(v: &Value) -> String {
match v {
Value::Null => "null".into(),
Value::Bool(b) => b.to_string(),
Value::Number(n) => n.as_f64().map_or(n.to_string(), crate::js_fmt::js_number),
Value::String(s) => s.clone(),
Value::Array(a) => a.iter().map(|x| if x.is_null() { String::new() } else { js_string(x) }).collect::<Vec<_>>().join(","),
Value::Object(_) => "[object Object]".into(),
}
}
use crate::js_fmt::js_string;
/// 1 → 2: Legacy-Türen (`doors`) werden zu Öffnungen (`openings`, kind `door`).
fn migrate_doors(mut raw: Map<String, Value>) -> Map<String, Value> {
+1 -7
View File
@@ -30,13 +30,7 @@ use crate::model::{Project, SiaCategory};
pub const DEFAULT_TOLERANCE: f64 = 0.05;
fn finite(v: f64) -> f64 {
if v.is_finite() {
v
} else {
0.0
}
}
use crate::jsnum::or_zero as finite;
fn cat_name(c: SiaCategory) -> &'static str {
match c {
+6 -27
View File
@@ -15,7 +15,8 @@
//! Der B-Rep-Körper einer Extrusion (`spec`) bleibt in TS (truck-Pipeline, `plan/extrudedSolidSpec.ts`).
use crate::document::Lookup;
use crate::grips::{field, js_num, num_of, truthy, xy};
use crate::model::helpers::heights;
use crate::grips::{arr, field, js_num, num_of, truthy, xy};
use crate::jsmath::hypot2;
use crate::jsnum;
use crate::ops::id_of;
@@ -134,10 +135,6 @@ impl O {
}
}
fn arr(v: Option<&Value>) -> &[Value] {
v.and_then(Value::as_array).map(Vec::as_slice).unwrap_or(&[])
}
/// Erstes Element, dessen Feld `key` gleich `val` ist (`===`; fehlend gleich fehlend).
fn find_by<'a>(list: &'a [Value], key: &str, val: Option<&Value>) -> Option<&'a Value> {
list.iter().find(|e| field(e, key) == val)
@@ -152,17 +149,6 @@ fn str_of(v: Option<&Value>) -> Option<&str> {
v.and_then(Value::as_str)
}
/// `String(v)` für die Anzeige (Name eines Geschosses).
fn js_string(v: &Value) -> Value {
match v {
Value::String(_) => v.clone(),
Value::Number(n) => Value::from(crate::js_fmt::js_number(n.as_f64().unwrap_or(f64::NAN))),
Value::Null => Value::from("null"),
Value::Bool(b) => Value::from(if *b { "true" } else { "false" }),
_ => Value::from("[object Object]"),
}
}
/// Kategorie (Ebene) per Code: erster Treffer der Tiefensuche (`findCategory`).
fn category<'a>(root: &'a Map<String, Value>, code: Option<&Value>) -> Option<&'a Value> {
fn walk<'a>(list: &'a [Value], code: Option<&Value>) -> Option<&'a Value> {
@@ -186,10 +172,7 @@ fn component<'a>(root: &'a Map<String, Value>, id: Option<&Value>) -> Result<&'a
/// Wert in einer Template-Zeichenkette (`${v}`).
fn js_text(v: &Value) -> String {
match js_string(v) {
Value::String(s) => s,
_ => String::new(),
}
crate::js_fmt::js_string(v)
}
/// `x.color ?? cat?.color ?? fallback`.
@@ -305,7 +288,7 @@ fn anchor(root: &Map<String, Value>, a: Option<&Value>) -> Option<f64> {
return nn(field(a, "z")).map(|z| num_of(Some(z)));
}
let f = level(root, field(a, "floorId"))?;
Some(num_or(field(f, "baseElevation"), 0.0) + num_or(field(a, "offset"), 0.0))
Some(heights::floor_anchor(num_or(field(f, "baseElevation"), 0.0), num_or(field(a, "offset"), 0.0)))
}
fn num_or(v: Option<&Value>, d: f64) -> f64 {
@@ -319,18 +302,14 @@ fn num_or(v: Option<&Value>, d: f64) -> f64 {
/// (UK, OK) einer Wand oder Stütze: UK aus `bottom` sonst Geschoss-Basis, OK aus `top` sonst UK + Höhe.
fn vertical_extent(root: &Map<String, Value>, el: &Value) -> (f64, f64) {
let floor_base = level(root, field(el, "floorId")).map_or(0.0, |f| num_or(field(f, "baseElevation"), 0.0));
let zb = anchor(root, field(el, "bottom")).unwrap_or(floor_base);
let zt = anchor(root, field(el, "top")).unwrap_or(zb + num_of(field(el, "height")));
(zb, zt)
heights::element(floor_base, anchor(root, field(el, "bottom")), anchor(root, field(el, "top")), num_of(field(el, "height")))
}
/// (UK, OK) einer Decke (`ceilingVerticalExtent`): OK aus `top` sonst Geschoss-Oberkante (Basis + Höhe), UK aus
/// `bottom` sonst OK − `thickness` (die Decke wächst nach unten).
fn ceiling_extent(root: &Map<String, Value>, c: &Value, thickness: f64) -> (f64, f64) {
let floor_top = level(root, field(c, "floorId")).map_or(0.0, |f| num_or(field(f, "baseElevation"), 0.0) + num_or(field(f, "floorHeight"), 0.0));
let zt = anchor(root, field(c, "top")).unwrap_or(floor_top);
let zb = anchor(root, field(c, "bottom")).unwrap_or(zt - thickness);
(zb, zt)
heights::ceiling(floor_top, anchor(root, field(c, "bottom")), anchor(root, field(c, "top")), || thickness)
}
/// Anfrage `verticalExtents`: Wände und Decken als ganze Elemente (die 3D-Griffe zeigen auch gerade gezogene,
-5
View File
@@ -27,11 +27,6 @@ pub fn bulge_from_sagitta_point(ax: f64, ay: f64, bx: f64, by: f64, px: f64, py:
b::from_sagitta_point(ax, ay, bx, by, px, py)
}
#[wasm_bindgen]
pub fn bulge_between_angles(cx: f64, cy: f64, r: f64, a_from: f64, a_to: f64, sweep_sign: f64) -> f64 {
b::between_angles(cx, cy, r, a_from, a_to, sweep_sign)
}
/// `[x, y]` auf dem Bogen bei t∈[0,1].
#[wasm_bindgen]
pub fn bulge_point_at(ax: f64, ay: f64, bx: f64, by: f64, bulge: f64, t: f64) -> Vec<f64> {
+4 -10
View File
@@ -174,15 +174,9 @@ pub fn doc_json(h: u32) -> String {
with_doc(h, |d| d.to_json()).unwrap_or_default()
}
/// Abfrage auf dem typisierten Projekt; Ergebnis als JSON. Fehler (Dokument nicht offen, Modell
/// passt nicht, unbekannte Abfrage, Rechenfehler) kommen als Text mit vorangestelltem `\u{1}`.
/// Abfragen s. `crate::queries`.
#[wasm_bindgen]
pub fn doc_query(h: u32, name: &str) -> String {
doc_query_args(h, name, &[], "")
}
/// Wie [`doc_query`] mit Zahlen- und Textargument.
/// Abfrage auf dem typisierten Projekt mit Zahlen- und Textargument; Ergebnis als JSON. Fehler (Dokument
/// nicht offen, Modell passt nicht, unbekannte Abfrage, Rechenfehler) kommen als Text mit vorangestelltem
/// `\u{1}`. Abfragen s. `crate::queries`.
#[wasm_bindgen]
pub fn doc_query_args(h: u32, name: &str, args: &[f64], text: &str) -> String {
let result = with_doc(h, |d| {
@@ -196,7 +190,7 @@ pub fn doc_query_args(h: u32, name: &str, args: &[f64], text: &str) -> String {
}
}
/// Abfrage auf der rohen Projekt-Wurzel (`crate::queries::run_root`); Fehler wie bei [`doc_query`].
/// Abfrage auf der rohen Projekt-Wurzel (`crate::queries::run_root`); Fehler wie bei [`doc_query_args`].
#[wasm_bindgen]
pub fn doc_query_root(h: u32, name: &str, text: &str) -> String {
let result = with_doc(h, |d| crate::queries::run_root(&d.lookup(), name, text)).unwrap_or_else(|| Err("Dokument nicht offen".to_string()));
-16
View File
@@ -1,16 +0,0 @@
//! Bindungen der 2D-Zeichnungen im 3D (`crate::drawing2d_3d`). Kodierung s. dort.
use crate::drawing2d_3d as d;
use wasm_bindgen::prelude::wasm_bindgen;
/// LineList-Vertices `[px, höhe, py, r, g, b]` (zwei je Segment) einer Charge.
#[wasm_bindgen]
pub fn drawing3d_line_verts(drawings: &[f64]) -> Vec<f32> {
d::line_verts(drawings)
}
/// Pick-Strecken `[ax, ay, bx, by, baseElevation, zeichnung]` einer Charge.
#[wasm_bindgen]
pub fn drawing3d_pick_segs(drawings: &[f64], tolerance: f64) -> Vec<f64> {
d::pick_segs(drawings, tolerance)
}
-13
View File
@@ -75,16 +75,3 @@ pub fn hatch_line_family_flat(poly: &[f64], angle_rad: f64, spacing_m: f64, offs
segs_out(&hatch::hatch_line_family(&pts(poly), angle_rad, spacing_m, offset_m, v2(ax, ay)))
}
/// `len_min`/`len_max` NaN = nicht gesetzt.
#[wasm_bindgen]
pub fn scatter_strokes_flat(
poly: &[f64],
cell: f64,
base_angle_rad: f64,
seed: f64,
stroke_len: f64,
len_min: f64,
len_max: f64,
) -> Vec<f64> {
runs_out(&hatch::scatter_strokes(&pts(poly), cell, base_angle_rad, seed, stroke_len, opt(len_min), opt(len_max)))
}
-7
View File
@@ -15,7 +15,6 @@ mod stair;
mod room_area;
mod room_boundary;
mod polygon_holes;
mod drawing2d_3d;
mod plan_buf;
mod project_format;
mod gpu_compile;
@@ -46,9 +45,3 @@ use wasm_bindgen::prelude::wasm_bindgen;
pub fn start() {
console_error_panic_hook::set_once();
}
/// Version des Kern-Moduls (für Diagnose/Startprotokoll).
#[wasm_bindgen]
pub fn core_version() -> String {
env!("CARGO_PKG_VERSION").to_string()
}
+1 -1
View File
@@ -18,7 +18,7 @@ export { exportObj, exportStl, exportGlb, exportGltf } from "../export/exportMes
export { exportProjectStep } from "../export/exportStep";
export { planToSvgString } from "../export/planToSvgString";
export { setWasmBytesProvider } from "../engine/wasmSource";
export { initCore, coreReady } from "../engine/coreWasm";
export { initCore } from "../engine/coreWasm";
export { applyOps, validateProject, validateOps } from "./ops";
export type { CoreOp } from "./ops";
export type { Project, DrawingLevel } from "../model/types";
-3
View File
@@ -9,7 +9,6 @@ export {
bulgeArc,
bulgeArcPoints,
bulgePolylinePoints,
bulgeBetweenAngles,
bulgeFromSagittaPoint,
bulgePointAt,
bulgeThroughPoint,
@@ -97,7 +96,6 @@ export {
} from "../geometry/lineSegments";
export {
openingVerticalExtent,
} from "../geometry/opening";
export { autoExteriorDimensions } from "../geometry/autoDimensions";
export * as polygonBool from "../geometry/polygonBool";
@@ -255,7 +253,6 @@ export {
meetScale,
mmToPx,
pointInPolygon,
pointSegDistPx,
printStrokeVb,
scaleFromView,
toScreen,
-4
View File
@@ -24,10 +24,6 @@ export function initCoreSync(bytes: BufferSource): void {
ready = true;
}
export function coreReady(): boolean {
return ready;
}
/** Der geladene Kern; wirft, wenn `initCore()` noch nicht gelaufen ist (Programmierfehler). */
export function core(): CoreModule {
if (!ready) throw new Error("Rust-Kern nicht geladen: initCore() muss vor der ersten Kern-Funktion laufen.");
-31
View File
@@ -70,37 +70,6 @@ export async function extrudeCircle(
return JSON.parse(json) as ExtrudedMesh;
}
export type BooleanOp = "union" | "difference" | "intersection";
export interface BooleanMeshResult {
positions: number[];
indices: number[];
empty: boolean;
}
/** Boolesche Operation zweier Dreiecks-Meshes (Mesh-Ebenen-CSG via csgrs,
* truck-Integration Phase 4). Beide Meshes müssen konsistent nach außen
* gewundene Dreiecke haben (Rechte-Hand-Regel) — sonst liefert csgrs ein
* falsches Ergebnis, ohne das zu erkennen. */
export async function booleanMesh(
a: ExtrudedMesh,
b: ExtrudedMesh,
op: BooleanOp,
): Promise<BooleanMeshResult> {
const json = await guarded((m) =>
m.boolean_mesh(
JSON.stringify({
a_positions: a.positions,
a_indices: a.indices,
b_positions: b.positions,
b_indices: b.indices,
op,
}),
),
);
return JSON.parse(json) as BooleanMeshResult;
}
// ── B-Rep-Körper (truck 0.6): Spezifikation → Mesh / STEP ────────────────────
/** Ein Loft-Schnitt: Höhe + geschlossener Ring [x0,y0,x1,y1,…]. */
-15
View File
@@ -120,21 +120,6 @@ export function arcThroughPoints(a: Vec2, through: Vec2, b: Vec2): ArcParams | n
return toArcParams(core().arc_through_points(a.x, a.y, through.x, through.y, b.x, b.y));
}
/**
* Bulge-Wert für den Teilbogen desselben Kreises (center, r) von Winkel `aFrom` zu `aTo`, in der
* durch `sweepSign` vorgegebenen Schwenkrichtung (+1 = CCW, −1 = CW), z. B. beim Zuschneiden/
* Offsetten eines Bogen-Segments.
*/
export function bulgeBetweenAngles(
center: Vec2,
r: number,
aFrom: number,
aTo: number,
sweepSign: 1 | -1,
): number {
return core().bulge_between_angles(center.x, center.y, r, aFrom, aTo, sweepSign);
}
/**
* Kreisbogen durch zwei Endpunkte `a`→`b` mit vorgegebenem Radius `r` (Methode „Start-Ende-
* Radius"). `near` (typischerweise der Cursor) wählt die Seite der Sehne; es entsteht immer der
-33
View File
@@ -32,44 +32,11 @@ export function normalizeOutline(pts: Vec2[]): Vec2[] | null {
return isCCW(clean) ? clean : clean.slice().reverse();
}
/** Ob ein Umriss ein gültiges (nicht entartetes) Deckenpolygon bildet. */
export function isValidOutline(pts: Vec2[]): boolean {
const norm = normalizeOutline(pts);
return norm != null && ceilingArea(norm) >= MIN_CEILING_AREA;
}
/** Fläche eines Deckenumrisses in m² (immer positiv). */
export function ceilingArea(pts: Vec2[]): number {
return Math.abs(signedArea(pts));
}
/** Schwerpunkt (Zentroid) des Umriss-Polygons (für HUD/Beschriftung). */
export function outlineCentroid(pts: Vec2[]): Vec2 {
const a = signedArea(pts);
if (Math.abs(a) < 1e-12) {
// Entartet: einfacher Mittelwert der Punkte.
let sx = 0,
sy = 0;
for (const p of pts) {
sx += p.x;
sy += p.y;
}
const n = pts.length || 1;
return { x: sx / n, y: sy / n };
}
let cx = 0,
cy = 0;
for (let i = 0; i < pts.length; i++) {
const p = pts[i];
const q = pts[(i + 1) % pts.length];
const cr = p.x * q.y - q.x * p.y;
cx += (p.x + q.x) * cr;
cy += (p.y + q.y) * cr;
}
const f = 1 / (6 * a);
return { x: cx * f, y: cy * f };
}
/**
* Punkt-in-Polygon-Test (Ray-Casting) für einen geschlossenen Umriss — dient dem
* Body-Select einer Decke im Grundriss/3D. Randpunkte gelten als innen genug.
+2 -2
View File
@@ -113,8 +113,8 @@ export interface VerticalExtent {
}
/**
* UK/OK von Wänden und Decken aus dem Kern (`selection_info.rs::vertical_extents`, Regeln wie
* `wallVerticalExtent`/`ceilingVerticalExtent`): Geschoss-Bindungen und Deckentypen aus `project`, die
* UK/OK von Wänden und Decken aus dem Kern (`selection_info.rs::vertical_extents`, Regeln
* `model/helpers.rs::heights`): Geschoss-Bindungen und Deckentypen aus `project`, die
* Elemente selbst als ganze Fassung (auch gerade gezogene, noch nicht übernommene — 3D-Griffe).
*/
export function verticalExtents(
+4 -34
View File
@@ -1,7 +1,7 @@
// Geometrie-Helfer für Öffnungen (Fenster/Türen) — reine Funktionen, die eine
// `Opening` relativ zu ihrer Wirts-Wand in konkrete Welt-Geometrie auflösen:
// • die Öffnungs-Lücke entlang der Wandachse (from/to in Metern),
// • die vertikale Lage (UK/OK der Öffnung, absolut in Metern).
// • die Öffnungs-Lücke entlang der Wandachse (from/to in Metern), die Pfosten.
// (Die vertikale Lage rechnet der Kern: `model3d.rs`/`plan/section.rs`, UK/OK der Wand: `model/helpers.rs::heights`.)
//
// Da JEDE Größe aus der aktuellen Wandachse (`wall.start`/`wall.end`) abgeleitet
// wird, folgt eine Öffnung ihrer Wand automatisch, sobald die Wand bewegt wird —
@@ -9,9 +9,8 @@
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import type { Opening, Project, Vec2, Wall } from "../model/types";
import { along, leftNormal, normalize, sub } from "../model/geometry";
import { wallVerticalExtent } from "../model/wall";
import type { Opening, Vec2, Wall } from "../model/types";
import { along } from "../model/geometry";
/** Achslänge einer Wand (Meter). */
export function wallAxisLength(wall: Wall): number {
@@ -34,29 +33,6 @@ export function openingInterval(
return { from, to };
}
/**
* Vertikale Lage einer Öffnung (absolute Z-Werte in Metern) relativ zur Wand-UK.
* Türen sitzen am Boden (sillHeight 0); Fenster ab Brüstung. Die OK wird auf die
* Wand-OK geklemmt, damit die Öffnung nie über den Wandkopf hinausragt.
*/
export function openingVerticalExtent(
project: Project,
wall: Wall,
o: Opening,
): { zBottom: number; zTop: number } {
const { zBottom, zTop } = wallVerticalExtent(project, wall);
const sill = Math.max(0, o.sillHeight);
const oBottom = zBottom + sill;
const oTop = Math.min(zTop, oBottom + o.height);
return { zBottom: oBottom, zTop: oTop };
}
/** Einheits-Laufrichtung (u) und linke Normale (n) der Wandachse. */
export function wallAxisFrame(wall: Wall): { u: Vec2; n: Vec2 } {
const u = normalize(sub(wall.end, wall.start));
return { u, n: leftNormal(u) };
}
/** Die beiden Pfosten-Punkte (auf der Achse) einer Öffnung im Grundriss. */
export function openingJambs(
wall: Wall,
@@ -70,9 +46,3 @@ export function openingJambs(
};
}
/** Mittelpunkt einer Öffnung im Grundriss (Achse) — für HUD/Auswahl-Anker. */
export function openingCenter(wall: Wall, o: Opening): Vec2 | null {
const iv = openingInterval(wall, o);
if (!iv) return null;
return along(wall.start, wall.end, (iv.from + iv.to) / 2);
}
-2
View File
@@ -19,8 +19,6 @@
import type { Stair, Vec2 } from "../model/types";
import { core } from "../engine/coreWasm";
/** SIA-nahe Schrittregel: gute Steigungshöhe ≈ 0.17 m, Auftritt ≈ 0.29 m. */
export const IDEAL_RISER = 0.17;
export const IDEAL_TREAD = 0.29;
export const MIN_STEPS = 2;
+2 -2
View File
@@ -14,7 +14,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import { exportIfcSpf, ifcGuid } from "../export/exportIfc";
import { sampleProject } from "../model/sampleProject";
import { ceilingVerticalExtent } from "../model/wall";
import { verticalExtents } from "../geometry/grips";
import { polygonArea } from "../geometry/roomArea";
import { wallMeshVolumes } from "../export/meshScene.testutil";
import { formatIfcReport, handleIfcWorkerRequest, ifcToImportedMeshes, readIfc, type IfcProduct, type IfcWorkerRequest } from "./ifcImport";
@@ -100,7 +100,7 @@ describe("IFC-Import: Rundreise mit dem eigenen Export", () => {
const slabsExpected = (sampleProject.ceilings ?? [])
.filter((c) => c.outline.length >= 3)
.map((c) => {
const { zBottom, zTop } = ceilingVerticalExtent(sampleProject, c);
const { zBottom, zTop } = verticalExtents(sampleProject, [], [c]).ceilings[0];
return Math.abs(polygonArea(c.outline)) * Math.max(zTop - zBottom, 0.001);
})
.sort((a, b) => a - b);
-11
View File
@@ -346,17 +346,6 @@ export function meshObjectsToImportedMeshes(objects: readonly MeshObject[], file
});
}
/** Datei-Bytes → Kontext-Meshes + Bericht. */
export async function meshBytesToImportedMeshes(
bytes: Uint8Array,
fileName: string,
read?: MeshReadOptions,
place?: MeshToContextOptions,
): Promise<{ meshes: ImportedMesh[]; report: MeshImportReport }> {
const { objects, report } = await readMesh(bytes, fileName, read);
return { meshes: meshObjectsToImportedMeshes(objects, fileName, place), report };
}
/** Bericht als kurzer Text; `tr` übersetzt (Kern kennt kein i18n, die Hülle reicht `t` herein). */
export function formatMeshReport(
r: MeshImportReport,
-32
View File
@@ -18,7 +18,6 @@ import type {
BuiltinPaletteBanks,
Ceiling,
CeilingType,
Column,
Component,
DoorType,
DrawingLevel,
@@ -30,8 +29,6 @@ import type {
RichTextDoc,
Roof,
SashDef,
Stair,
StairType,
Vec2,
Wall,
WallType,
@@ -204,35 +201,6 @@ export const glazingPanesOf = (wt: WindowType): 1 | 2 | 3 => {
return wt.glazing === "dreifach" ? 3 : wt.glazing === "zweifach" ? 2 : 1;
};
/** Löst den {@link StairType} einer Treppe auf, oder `undefined`. */
export const getStairType = (project: Project, stair: Stair): StairType | undefined =>
stair.typeId ? (project.stairTypes ?? []).find((t) => t.id === stair.typeId) : undefined;
/** Alle Öffnungen einer Wand (leere Liste, wenn keine oder `openings` fehlt). */
export const openingsOfWall = (project: Project, wallId: string): Opening[] =>
(project.openings ?? []).filter((o) => o.hostWallId === wallId);
/** Menschenlesbarer Standardname einer Öffnung (Fenster/Tür + Breite×Höhe). */
export const openingLabel = (o: Opening): string =>
`${o.kind === "door" ? "Tür" : "Fenster"} ${(o.width * 100).toFixed(0)}×${(
o.height * 100
).toFixed(0)}`;
/** Menschenlesbarer Standardname einer Stütze (Profil + Masse in cm). */
export const columnLabel = (c: Column): string => {
if (c.profile.kind === "round") {
return `Stütze Ø${(c.profile.radius * 200).toFixed(0)}`;
}
return `Stütze ${(c.profile.width * 100).toFixed(0)}×${(c.profile.depth * 100).toFixed(0)}`;
};
/** Liefert ein Bauteil-Material (Component) per ID oder wirft. */
export const getComponent = (project: Project, id: string): Component => {
const c = project.components.find((co) => co.id === id);
if (!c) throw new Error(`Unbekanntes Bauteil-Material: ${id}`);
return c;
};
/** Liefert eine Schraffur (HatchStyle) per ID oder wirft. */
export const getHatch = (project: Project, id: string): HatchStyle => {
const h = project.hatches.find((ht) => ht.id === id);
+8 -4
View File
@@ -1,8 +1,9 @@
// Unit-Tests für die Wand-/Decken-Resolver (wallVerticalExtent /
// ceilingVerticalExtent): reine Datenschicht, kein React/Store.
// Unit-Tests für die Wand-/Decken-Resolver: Referenzlinie (`wallReferenceOffset`) und die UK/OK der
// Decken über den Kern (`verticalExtents`, Regeln `model/helpers.rs::heights`).
import { describe, it, expect } from "vitest";
import { ceilingVerticalExtent, wallReferenceOffset } from "./wall";
import { wallReferenceOffset } from "./wall";
import { verticalExtents } from "../geometry/grips";
import type { Ceiling, Project, Wall } from "./types";
/** Minimalprojekt mit einem Geschoss (baseElevation 0, floorHeight 2.6) und
@@ -68,7 +69,10 @@ function makeCeiling(overrides?: Partial<Ceiling>): Ceiling {
};
}
describe("ceilingVerticalExtent", () => {
/** UK/OK einer Decke (Kern-Abfrage). */
const ceilingVerticalExtent = (p: Project, c: Ceiling) => verticalExtents(p, [], [c]).ceilings[0];
describe("UK/OK einer Decke", () => {
it("ohne top/bottom: OK = Geschoss-Oberkante, UK = OK − Dicke (heutiges Verhalten)", () => {
const project = makeProject();
const ceiling = makeCeiling();
+3 -92
View File
@@ -1,12 +1,9 @@
// Wand-Resolver: leitet aus den (optionalen) Wand-Attributen die konkreten
// geometrischen Größen ab — Versatz der Achse über die Dicke (Referenzlinie)
// und die vertikale Ausdehnung (UK..OK). Alle Defaults entsprechen exakt dem
// bisherigen Verhalten, sodass bestehende Wände unverändert rendern.
// Wand-Resolver: Versatz der Achse über die Dicke (Referenzlinie). Die vertikale Ausdehnung (UK/OK)
// rechnet der Kern (`model/helpers.rs::heights`; TS: Abfrage `verticalExtents`, `geometry/grips.ts`).
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import type { Ceiling, Column, Project, VerticalAnchor, Wall } from "./types";
import { ceilingThickness, getFloor } from "./types";
import type { Wall } from "./types";
/**
* Versatz der Schichtstapelung entlang der linken Normalen `+n` (leftNormal),
@@ -38,89 +35,3 @@ export function wallReferenceOffset(
if (ref === "right") return -half;
return 0;
}
/** Löst einen VerticalAnchor zu einem absoluten Z (Meter) auf oder `null`. */
function resolveAnchor(
project: Project,
anchor: VerticalAnchor | undefined,
): number | null {
if (!anchor) return null;
if (anchor.mode === "custom") return anchor.z;
// "floor": baseElevation des gebundenen Geschosses (+ optionalem Offset).
const floor = project.drawingLevels.find((z) => z.id === anchor.floorId);
if (!floor) return null;
return (floor.baseElevation ?? 0) + (anchor.offset ?? 0);
}
/**
* Vertikale Ausdehnung der Wand (absolute Z-Werte in Metern).
* • zBottom: aus `wall.bottom`, sonst baseElevation des Wand-Geschosses
* (= heutiges Verhalten).
* • zTop: aus `wall.top`, sonst `zBottom + wall.height` (= heute).
* Sind beide UK/OK ungesetzt, liefert dies exakt `[baseElevation, base+height]`.
*/
export function wallVerticalExtent(
project: Project,
wall: Wall,
): { zBottom: number; zTop: number } {
// Geschoss-baseElevation als Default-UK (heutiges Verhalten). Fehlt das
// Geschoss, 0 als sicherer Rückfall.
let floorBase = 0;
try {
floorBase = getFloor(project, wall.floorId).baseElevation ?? 0;
} catch {
floorBase = 0;
}
const zBottom = resolveAnchor(project, wall.bottom) ?? floorBase;
const zTop = resolveAnchor(project, wall.top) ?? zBottom + wall.height;
return { zBottom, zTop };
}
/**
* Vertikale Ausdehnung einer Decke (absolute Z-Werte in Metern).
* • zTop: aus `ceiling.top`, sonst Oberkante des Geschosses
* (baseElevation + floorHeight) — also bündig mit dem Wandkopf.
* • zBottom: aus `ceiling.bottom`, sonst zTop − Deckendicke (die Decke
* wächst nach UNTEN — heutiges Verhalten). Die `thickness` bleibt bei
* gesetztem `bottom` rein informativ (dient nicht mehr der UK-Ableitung).
* Fehlt das Geschoss, dient 0 als sicherer Rückfall für die Oberkante.
*/
export function ceilingVerticalExtent(
project: Project,
ceiling: Ceiling,
): { zBottom: number; zTop: number } {
let floorTop = 0;
try {
const floor = getFloor(project, ceiling.floorId);
floorTop = (floor.baseElevation ?? 0) + (floor.floorHeight ?? 0);
} catch {
floorTop = 0;
}
const zTop = resolveAnchor(project, ceiling.top) ?? floorTop;
const zBottom =
resolveAnchor(project, ceiling.bottom) ??
zTop - ceilingThickness(project, ceiling);
return { zBottom, zTop };
}
/**
* Vertikale Ausdehnung einer Stütze (absolute Z-Werte in Metern) — dieselbe
* Regel wie {@link wallVerticalExtent}:
* • zBottom: aus `column.bottom`, sonst baseElevation des Geschosses.
* • zTop: aus `column.top`, sonst `zBottom + column.height`.
* Fehlt das Geschoss, dient 0 als sicherer Rückfall für die Unterkante.
*/
export function columnVerticalExtent(
project: Project,
column: Column,
): { zBottom: number; zTop: number } {
let floorBase = 0;
try {
floorBase = getFloor(project, column.floorId).baseElevation ?? 0;
} catch {
floorBase = 0;
}
const zBottom = resolveAnchor(project, column.bottom) ?? floorBase;
const zTop = resolveAnchor(project, column.top) ?? zBottom + column.height;
return { zBottom, zTop };
}
+1 -24
View File
@@ -5,13 +5,12 @@
* Querschnitt.
* • 3D (projectToModel3d/emitColumns): eine Stütze wird zu einem Prisma-Mesh
* (Rechteck-Box bzw. Kreis-Prisma) mit der erwarteten vertikalen Ausdehnung.
* • Vertikale Lage (columnVerticalExtent): Geschoss-Default sowie UK/OK-Anker.
* (Vertikale Lage: Rust-Tests `model/helpers.rs::heights`.)
*/
import { describe, it, expect } from "vitest";
import { generatePlan } from "./generatePlan";
import { projectToModel3d } from "./toWalls3d";
import { columnVerticalExtent } from "../model/wall";
import { columnFootprint } from "../geometry/column";
import type { Column, Project } from "../model/types";
@@ -125,28 +124,6 @@ describe("Stütze — 3D (projectToModel3d / emitColumns)", () => {
});
});
describe("Stütze — vertikale Lage (columnVerticalExtent)", () => {
it("nutzt Geschoss-UK + Höhe als Default", () => {
const { zBottom, zTop } = columnVerticalExtent(
projectWithColumn(rectColumn),
rectColumn,
);
expect(zBottom).toBeCloseTo(0, 6);
expect(zTop).toBeCloseTo(3, 6);
});
it("bindet UK/OK an Anker (custom + floor)", () => {
const anchored: Column = {
...rectColumn,
bottom: { mode: "custom", z: 0.5 },
top: { mode: "floor", floorId: "og" }, // baseElevation OG = 3
};
const { zBottom, zTop } = columnVerticalExtent(projectWithColumn(anchored), anchored);
expect(zBottom).toBeCloseTo(0.5, 6);
expect(zTop).toBeCloseTo(3, 6);
});
});
describe("Stütze — Footprint-Helfer (columnFootprint)", () => {
it("tesselliert ein rundes Profil als 32-Eck um die Position", () => {
const round: Column = { ...rectColumn, profile: { kind: "round", radius: 0.15 } };
-4
View File
@@ -42,9 +42,6 @@ export type DetailLevel = "grob" | "mittel" | "fein";
/** Stroke-Farbe der Schicht-Polygone (neutrales Schwarz, geteilte Tinte mit der Schraffur). */
export const POCHE_STROKE = "#1a1a1a";
/** Tinte für den Schwarz-Weiss-Modus: einheitliches Dunkel für alle Striche. */
export const MONO_INK = "#111111";
// ── Linienstärken in PAPIER-Millimeter (vgl. docs/design/plans-output.md §3.2) ──
// Alle Stricharten sind in mm Papier definiert; die PlanView rechnet sie über
// dpi = 96 in konstante Bildschirm-Pixel um (non-scaling-stroke), damit Linien
@@ -58,7 +55,6 @@ export const LAYER_LINE_MM = 0.02;
// seit [K3d] im Kern (`src-tauri/core/src/plan/style.rs`).
/** Default-Umrandungs-Strichstärke (mm), falls die Kategorie keine lw trägt
(Grundeinstellung für „normale Elemente"). */
export const WALL_FALLBACK_MM = 0.18;
/**
* Aufgelöste Schraffur eines Polygons — alle Werte stammen aus einer
-18
View File
@@ -144,24 +144,6 @@ export function buildHatchRuns(poly: Vec2[], hatch: HatchRender): HatchRun[] {
return toRuns(core().hatch_runs_flat(flat(poly), encodeHatch(hatch)));
}
/**
* Streut kurze Striche deterministisch und MODELLRAUM-STABIL über ein Polygon (eine Zelle des
* absoluten Gitters je Strich, Lage/Winkel/Länge aus `hash(ix, iy, seed)`), aufs Polygon geclippt.
*/
export function scatterStrokes(
poly: Vec2[],
cell: number,
baseAngleRad: number,
seed: number,
strokeLen: number,
lenMin?: number,
lenMax?: number,
): HatchRun[] {
return toRuns(
core().scatter_strokes_flat(flat(poly), cell, baseAngleRad, seed, strokeLen, lenMin ?? NaN, lenMax ?? NaN),
);
}
/**
* Random-Vektor-Schraffur eines Polygons (Kies/Splitt): Dichte und Strichlänge an die Kachel
* (8·scale px) gekoppelt, Seed nur aus Muster-Parametern + `hatch.seed`.
-24
View File
@@ -16,30 +16,6 @@
/** RGBA-Farbe, Komponenten in [0,1]. */
export type Rgba = [number, number, number, number];
/** Shader-Programm mit kompiliertem Programm + Attribut-/Uniform-Orten. */
export interface ShaderProgram {
program: WebGLProgram;
attribs: {
position?: GLint;
/** Bildschirm-Raum-Miter-Bisektor (Einheits-Versatzrichtung) für Linien. */
normal?: GLint;
/** Seite der Linie: +1 oder -1. */
side?: GLint;
/** Miter-Längenfaktor 1/cos(θ/2) (1 = gerade). */
miter?: GLint;
};
uniforms: {
viewProj?: WebGLUniformLocation | null;
color?: WebGLUniformLocation | null;
/** Basis-Strichbreite in Geräte-Pixeln (bei strokeScale=1). */
strokePx?: WebGLUniformLocation | null;
/** Zoom-Skalierung der Strichbreite (>1 = reingezoomt → dicker, Papier). */
strokeScale?: WebGLUniformLocation | null;
/** Zeichenpuffer-Größe in Geräte-Pixeln [w,h] (px→Clip-Umrechnung). */
viewportPx?: WebGLUniformLocation | null;
};
}
/** Ein Zeichen-Batch: zusammenhängender Index-Bereich mit einer Farbe. */
export interface FillBatch {
startIndex: number;
-15
View File
@@ -207,21 +207,6 @@ export function pointInPolygon(pt: Vec2, poly: Vec2[]): boolean {
return inside;
}
/** Abstand Punkt→Strecke (alle in denselben Koordinaten, hier Client-Pixel). */
export function pointSegDistPx(
p: { x: number; y: number },
a: { x: number; y: number },
b: { x: number; y: number },
): number {
const dx = b.x - a.x;
const dy = b.y - a.y;
const len2 = dx * dx + dy * dy;
if (len2 < 1e-9) return Math.hypot(p.x - a.x, p.y - a.y);
let t = ((p.x - a.x) * dx + (p.y - a.y) * dy) / len2;
t = Math.max(0, Math.min(1, t));
return Math.hypot(p.x - (a.x + dx * t), p.y - (a.y + dy * t));
}
/** Achsenparalleles Rechteck in Modell-Metern (Auswahl-Marquee). */
export interface ModelRect {
minX: number;
-4
View File
@@ -243,10 +243,6 @@ export interface RModel3d {
/** Warmer, neutraler Wand-Grundton (wie render3d default). */
export const WALL_RGB: RRgb = [0.82, 0.8, 0.76];
/** Etwas hellerer, kühlerer Ton für Deckenplatten (heben sich von Wänden ab). */
export const SLAB_RGB: RRgb = [0.86, 0.86, 0.88];
/** Fallback-Farbe für 2D-Zeichnungen ohne color/lineStyle/Kategorie (wie drawing2DColor in Viewport3D.tsx, "#888888"). */
export const DRAWING_LINE_FALLBACK_RGB: RRgb = [0x88 / 255, 0x88 / 255, 0x88 / 255];
/** Ignoriere entartete vertikale Ausschnitte (Rundungsrauschen). */
export const EPS = 1e-4;