[137] 3D-Pick: Treppengeländer, Kreise/Bögen/Texte als Flächen, importierte Netze einzeln ausblendbar
This commit is contained in:
15 files changed
+314
-13
No files matched your search
@@ -2670,11 +2670,16 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
|
||||
Hervorhebung), vitest `toWalls3d.pickSolids.test.ts` (Strahl auf Körper, truck-Netz statt Prisma, Stütze lagerichtig,
|
||||
Hervorhebung, Gelände ausgeblendet), `siteSelection.test.ts` (Nachglätten mit Undo), e2e `siteSelect.spec.ts`
|
||||
(Netz ausblenden + Undo). Linux-Container; 3D-Pick nur als Unit-Test (headless kein WebGPU), nicht in der Tauri-App.
|
||||
Offen: im 3D nicht anwählbar: Treppengeländer über der Treppen-Hülle
|
||||
(oberes Podest), 2D-Kreise/Bögen/Texte (Bäume, Symbole: keine Pick-Box), Punktwolken, Baurechts-Hüllkörper und
|
||||
Schnittbox (Hilfsdarstellung, Klick geht hindurch), Gauben nur als Teil des Dachs (keine eigene Auswahl);
|
||||
importierte Meshes nur über die Kategorie ausblendbar; Raster-Gelände nur stärker glätten (rohe Höhen nicht
|
||||
gespeichert). · M
|
||||
(6.11., 3D-Rest) **Treppengeländer:** `model3d::pick_stair_railings` (Handlauf/Pfosten aus `stairs3d::railings`) →
|
||||
`stairMeshes` der Pick-Geometrie, Treffer = Treppe (Rang wie Treppe; Explosion hebt mit). **2D-Kreise/Bögen/Ellipsen/Texte**
|
||||
(Bäume, Symbole): `pick_drawing_meshes` → `drawingMeshes` (Scheibe bzw. Bogenband ±12 cm bzw. Text-Rechteck auf Geschosshöhe),
|
||||
Treffer = Zeichnung. **Importierte Netze:** `ImportedMesh.hidden` (Rust-Modell, gen:types), Objekt-Info „Dieses Netz
|
||||
sichtbar" (`imported-mesh-visible`); wirkt in Grundriss, 3D, Pick. **Gauben:** haben kein eigenes Auswahlmodell; der Klick
|
||||
wählt das Dach, dessen Objekt-Info zeigt die Gauben-Felder (`DormersSection`) — so belassen. Tests: Rust (`pick_treppengelaender_im_3d`,
|
||||
`pick_kreis_bogen_text_im_3d`, `importiertes_netz_einzeln_ausgeblendet`), vitest `toWalls3d.pickExtras.test.ts`. Linux-Container,
|
||||
3D-Pick nur als Unit-Test (kein WebGPU), nicht in der Tauri-App; das Geländer (Rohr ~4 cm) ist schwer zu treffen.
|
||||
Offen: Punktwolken, Baurechts-Hüllkörper und Schnittbox (Hilfsdarstellung, Klick geht hindurch); Raster-Gelände nur stärker
|
||||
glätten (rohe Höhen nicht gespeichert); Texte im 3D weiterhin nur anwählbar, nicht gezeichnet. · M
|
||||
**(5.11., Plan und Blätter)** Klick-Zyklus wie in CAD üblich: ein erneuter einfacher Klick an derselben Stelle
|
||||
(≤ 5 px, kein Doppelklick < 400 ms, Auswahl unverändert) wählt das nächste Objekt darunter, Reihenfolge wie die
|
||||
Cmd/Strg+Klick-Liste; Statusleiste „2/8 Treffer — erneut klicken zum Wechseln". Gilt auch, wenn der Klick auf einen
|
||||
|
||||
@@ -189,7 +189,9 @@ pub fn drawing_line_verts(p: &Project, gap: f64) -> Vec<f32> {
|
||||
pub fn pick_geometry(p: &Project, gap: f64) -> Result<PickGeometry, String> {
|
||||
let mut g = model3d::pick_geometry(p)?;
|
||||
let Some(ex) = Explode::new(p, gap) else { return Ok(g) };
|
||||
g.drawings = model3d::pick_drawing_segs(p, &floor_offsets(p, gap));
|
||||
let offsets = floor_offsets(p, gap);
|
||||
g.drawings = model3d::pick_drawing_segs(p, &offsets);
|
||||
g.drawing_meshes = model3d::pick_drawing_meshes(p, &offsets);
|
||||
for w in &mut g.walls {
|
||||
shift_wall(w, ex.of(&w.wall_id));
|
||||
}
|
||||
@@ -211,6 +213,12 @@ pub fn pick_geometry(p: &Project, gap: f64) -> Result<PickGeometry, String> {
|
||||
v[1] += dz;
|
||||
}
|
||||
}
|
||||
for m in &mut g.stair_meshes {
|
||||
let dz = ex.of(&m.stair_id);
|
||||
for v in m.tris.iter_mut().flatten() {
|
||||
v[1] += dz;
|
||||
}
|
||||
}
|
||||
for c in &mut g.columns {
|
||||
let dz = ex.of(&c.column_id);
|
||||
for v in c.tris.iter_mut().flatten() {
|
||||
|
||||
@@ -5120,6 +5120,11 @@ pub struct ImportedMesh {
|
||||
#[serde(rename = "creaseAngle", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub crease_angle: Option<f64>,
|
||||
/// [137] Nur dieses Netz ausblenden (Grundriss, Schnitt, Ansicht, 3D, Pick); die Kategorie bleibt
|
||||
/// davon unberührt. Fehlt/false = sichtbar.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub hidden: Option<bool>,
|
||||
pub positions: Vec<f64>,
|
||||
pub indices: Vec<f64>,
|
||||
#[serde(flatten)]
|
||||
|
||||
@@ -2131,6 +2131,7 @@ pub fn emit_context_meshes(p: &Project) -> Vec<RMesh> {
|
||||
match obj {
|
||||
// [137] Einzeln ausgeblendetes Gelände.
|
||||
ContextObject::TerrainMesh(m) if m.hidden == Some(true) => {}
|
||||
ContextObject::ImportedMesh(m) if m.hidden == Some(true) => {}
|
||||
ContextObject::TerrainMesh(m) if m.positions.len() >= 9 && m.indices.len() >= 3 => {
|
||||
// [T6] Baugruben schneiden das Gelände; Höhen im Modellbezug (Luftbild-Farben auf das geänderte Netz übertragen).
|
||||
let (pos, idx, _) = crate::excavation::terrain_model_mesh(p, m);
|
||||
@@ -2357,6 +2358,24 @@ pub struct PickSolid {
|
||||
pub solid_id: String,
|
||||
}
|
||||
|
||||
/// [137] Treppen-Geländer (Handlauf, Pfosten) für den 3D-Pick: Welt-Dreiecke; ragen über die Hülle
|
||||
/// ([`PickStair`]) hinaus (oberes Podest).
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PickStairMesh {
|
||||
pub tris: Vec<Tri>,
|
||||
pub stair_id: String,
|
||||
}
|
||||
|
||||
/// [137] Flächige Pick-Form eines 2D-Elements, das im 3D keine Linie ist (Kreis, Bogen, Ellipse, Text): Welt-Dreiecke
|
||||
/// auf Geschosshöhe.
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PickDrawingMesh {
|
||||
pub tris: Vec<Tri>,
|
||||
pub drawing_id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct PickGeometry {
|
||||
pub walls: Vec<RWall>,
|
||||
@@ -2374,6 +2393,12 @@ pub struct PickGeometry {
|
||||
#[serde(rename = "openingMeshes")]
|
||||
pub opening_meshes: Vec<PickOpeningMesh>,
|
||||
pub drawings: Vec<PickDrawingSeg>,
|
||||
/// [137] Treppengeländer.
|
||||
#[serde(rename = "stairMeshes")]
|
||||
pub stair_meshes: Vec<PickStairMesh>,
|
||||
/// [137] Kreise, Bögen, Ellipsen und Texte als flache Pick-Flächen.
|
||||
#[serde(rename = "drawingMeshes")]
|
||||
pub drawing_meshes: Vec<PickDrawingMesh>,
|
||||
}
|
||||
|
||||
/// Öffnungen als Quader (Laibung zu Laibung, Wanddicke, Brüstung bis Sturz) für Pick und Hervorhebung.
|
||||
@@ -2456,7 +2481,7 @@ pub fn pick_geometry(p: &Project) -> Result<PickGeometry, String> {
|
||||
ContextObject::ImportedMesh(m) => m.category_code.as_deref(),
|
||||
_ => None,
|
||||
};
|
||||
if code.is_some_and(|c| hidden.contains(c)) || matches!(obj, ContextObject::TerrainMesh(m) if m.hidden == Some(true)) {
|
||||
if code.is_some_and(|c| hidden.contains(c)) || matches!(obj, ContextObject::TerrainMesh(m) if m.hidden == Some(true)) || matches!(obj, ContextObject::ImportedMesh(m) if m.hidden == Some(true)) {
|
||||
continue;
|
||||
}
|
||||
let (pos, idx, id) = match obj {
|
||||
@@ -2525,9 +2550,85 @@ pub fn pick_geometry(p: &Project) -> Result<PickGeometry, String> {
|
||||
solids: pick_solids(p),
|
||||
opening_meshes: pick_hosted_openings(p),
|
||||
drawings: pick_drawing_segs(p, &HashMap::new()),
|
||||
stair_meshes: pick_stair_railings(p),
|
||||
drawing_meshes: pick_drawing_meshes(p, &HashMap::new()),
|
||||
})
|
||||
}
|
||||
|
||||
/// [137] Handläufe und Pfosten der Treppen als Welt-Dreiecke je Treppe (wie [`emit_stair_railings`]).
|
||||
pub fn pick_stair_railings(p: &Project) -> Vec<PickStairMesh> {
|
||||
let Some((stairs, buf)) = stair_input(p, |s, st| matches!(s.shape, StairShape::Straight | StairShape::Spiral) && st.and_then(|t| t.railing).is_some_and(|r| r != StairTypeRailing::Keine)) else { return vec![] };
|
||||
let mut out: Vec<PickStairMesh> = Vec::new();
|
||||
for m in crate::stairs3d::railings(&buf) {
|
||||
let Some(&(_, stair)) = stairs.get(m.src) else { continue };
|
||||
let tris = extrusion_tris(&m.positions, &m.indices);
|
||||
match out.iter_mut().find(|o| o.stair_id == stair.id) {
|
||||
Some(o) => o.tris.extend(tris),
|
||||
None => out.push(PickStairMesh { tris, stair_id: stair.id.clone() }),
|
||||
}
|
||||
}
|
||||
out.retain(|o| !o.tris.is_empty());
|
||||
out
|
||||
}
|
||||
|
||||
/// [137] Kreis, Bogen, Ellipse und Text (im 3D nicht als Linie gezeichnet, z. B. Bäume und Symbole) als flache
|
||||
/// Pick-Flächen auf Geschosshöhe (+ `lift` der Explosion): Kreis/Ellipse als Scheibe, Bogen als Band der
|
||||
/// Pick-Toleranz, Text als gedrehtes Rechteck (Breite ≈ 0.6 · Höhe je Zeichen bzw. Spaltenbreite).
|
||||
pub(crate) fn pick_drawing_meshes(p: &Project, lift: &HashMap<String, f64>) -> Vec<PickDrawingMesh> {
|
||||
const N: usize = 32;
|
||||
let mut out = Vec::new();
|
||||
for d in &p.drawings2d {
|
||||
let elev = p.floor(&d.level_id).map_or(0.0, |l| l.base_elevation.unwrap_or(0.0)) + DRAWING_LINE_ELEVATION_EPS + lift.get(d.level_id.as_str()).copied().unwrap_or(0.0);
|
||||
let mut tris: Vec<Tri> = Vec::new();
|
||||
let at = |x: f64, y: f64| -> V3 { [x, elev, y] };
|
||||
let fan = |c: Vec2, rx: f64, ry: f64, rot: f64, tris: &mut Vec<Tri>| {
|
||||
let (sr, cr) = (rot.sin(), rot.cos());
|
||||
let pt = |i: usize| {
|
||||
let a = std::f64::consts::TAU * (i % N) as f64 / N as f64;
|
||||
let (x, y) = (rx * a.cos(), ry * a.sin());
|
||||
at(c.x + x * cr - y * sr, c.y + x * sr + y * cr)
|
||||
};
|
||||
for i in 0..N {
|
||||
tris.push([at(c.x, c.y), pt(i), pt(i + 1)]);
|
||||
}
|
||||
};
|
||||
match &d.geom {
|
||||
Drawing2DGeom::Circle { center, r } if r.is_finite() && *r > 0.0 => fan(*center, r.max(DRAWING_PICK_TOLERANCE), r.max(DRAWING_PICK_TOLERANCE), 0.0, &mut tris),
|
||||
Drawing2DGeom::Ellipse { center, rx, ry, rotation } if rx.is_finite() && ry.is_finite() && rotation.is_finite() && *rx > 0.0 && *ry > 0.0 => fan(*center, rx.max(DRAWING_PICK_TOLERANCE), ry.max(DRAWING_PICK_TOLERANCE), *rotation, &mut tris),
|
||||
Drawing2DGeom::Arc { center, r, a0, a1 } if [r, a0, a1].iter().all(|v| v.is_finite()) && *r > 0.0 => {
|
||||
let mut sweep = (a1 - a0) % std::f64::consts::TAU;
|
||||
if sweep <= 0.0 {
|
||||
sweep += std::f64::consts::TAU;
|
||||
}
|
||||
let (ri, ro) = ((r - DRAWING_PICK_TOLERANCE).max(0.0), r + DRAWING_PICK_TOLERANCE);
|
||||
let pt = |i: usize, rr: f64| {
|
||||
let a = a0 + sweep * i as f64 / N as f64;
|
||||
at(center.x + rr * a.cos(), center.y + rr * a.sin())
|
||||
};
|
||||
for i in 0..N {
|
||||
tris.push([pt(i, ri), pt(i, ro), pt(i + 1, ro)]);
|
||||
tris.push([pt(i, ri), pt(i + 1, ro), pt(i + 1, ri)]);
|
||||
}
|
||||
}
|
||||
Drawing2DGeom::Text { at: pos, text, height, angle, width, .. } if height.is_finite() && *height > 0.0 && angle.is_finite() => {
|
||||
let lines = text.lines().count().max(1) as f64;
|
||||
let longest = text.lines().map(|l| l.chars().count()).max().unwrap_or(0).max(1) as f64;
|
||||
let w = width.filter(|w| w.is_finite() && *w > 0.0).unwrap_or(longest * 0.6 * height).max(*height);
|
||||
let h = (lines * height * 1.2).max(*height);
|
||||
let (sa, ca) = (angle.sin(), angle.cos());
|
||||
let c = |x: f64, y: f64| at(pos.x + x * ca - y * sa, pos.y + x * sa + y * ca);
|
||||
tris.push([c(0.0, 0.0), c(w, 0.0), c(w, h)]);
|
||||
tris.push([c(0.0, 0.0), c(w, h), c(0.0, h)]);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
if !tris.is_empty() {
|
||||
out.push(PickDrawingMesh { tris, drawing_id: d.id.clone() });
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// [137] Öffnungen in Dach, Decke oder Gaube (Dachfenster, Deckenöffnung, Gaubenfenster): ihre 3D-Teile
|
||||
/// (Rahmen, Glas, Eindeckrahmen) als Welt-Dreiecke — sie haben keine Wand-Box wie [`pick_openings`].
|
||||
pub fn pick_hosted_openings(p: &Project) -> Vec<PickOpeningMesh> {
|
||||
@@ -3054,4 +3155,79 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn pick_base(extra: serde_json::Value) -> Project {
|
||||
let mut v = serde_json::json!({
|
||||
"id": "p", "name": "t", "lineStyles": [], "hatches": [], "components": [], "wallTypes": [], "layers": [], "openings": [], "walls": [],
|
||||
"drawingLevels": [{"id": "EG", "name": "EG", "kind": "floor", "visible": true, "locked": false, "floorHeight": 3.0, "baseElevation": 1.0}],
|
||||
"drawings2d": []
|
||||
});
|
||||
for (k, x) in extra.as_object().unwrap() {
|
||||
v[k] = x.clone();
|
||||
}
|
||||
serde_json::from_value(v).unwrap()
|
||||
}
|
||||
|
||||
/// [137] Treppengeländer sind im 3D anwählbar: Handlauf-Dreiecke tragen die Treppen-Id und reichen über die Hülle.
|
||||
#[test]
|
||||
fn pick_treppengelaender_im_3d() {
|
||||
let mk = |railing: &str| {
|
||||
pick_base(serde_json::json!({
|
||||
"stairTypes": [{"id": "t", "name": "T", "structure": "massiv", "closedRisers": false, "treadThickness": 0.04, "railing": railing, "defaultWidth": 1.0}],
|
||||
"stairs": [{"id": "s1", "type": "stair", "floorId": "EG", "categoryCode": "35", "shape": "straight", "start": {"x": 0, "y": 0}, "dir": {"x": 1, "y": 0},
|
||||
"runLength": 3.0, "width": 1.0, "stepCount": 16, "totalRise": 2.8, "typeId": "t"}]
|
||||
}))
|
||||
};
|
||||
assert!(pick_geometry(&mk("keine")).unwrap().stair_meshes.is_empty());
|
||||
let g = pick_geometry(&mk("beide")).unwrap();
|
||||
assert_eq!(g.stair_meshes.len(), 1);
|
||||
assert_eq!(g.stair_meshes[0].stair_id, "s1");
|
||||
assert!(!g.stair_meshes[0].tris.is_empty());
|
||||
let top = g.stair_meshes[0].tris.iter().flatten().map(|q| q[1]).fold(f64::MIN, f64::max);
|
||||
assert!(top > g.stairs[0].z_top, "Geländer über der OK der Treppe: {top} > {}", g.stairs[0].z_top);
|
||||
}
|
||||
|
||||
/// [137] Kreis, Bogen und Text (Bäume, Symbole) bekommen flache Pick-Flächen auf Geschosshöhe.
|
||||
#[test]
|
||||
fn pick_kreis_bogen_text_im_3d() {
|
||||
let d = |id: &str, geom: serde_json::Value| serde_json::json!({"id": id, "type": "drawing2d", "levelId": "EG", "categoryCode": "20", "geom": geom});
|
||||
let p = pick_base(serde_json::json!({"drawings2d": [
|
||||
d("c", serde_json::json!({"shape": "circle", "center": {"x": 2, "y": 3}, "r": 1.5})),
|
||||
d("a", serde_json::json!({"shape": "arc", "center": {"x": 10, "y": 0}, "r": 2.0, "a0": 0.0, "a1": std::f64::consts::FRAC_PI_2})),
|
||||
d("t", serde_json::json!({"shape": "text", "at": {"x": 20, "y": 0}, "text": "Baum", "height": 0.5, "angle": 0.0})),
|
||||
d("l", serde_json::json!({"shape": "line", "a": {"x": 0, "y": 0}, "b": {"x": 1, "y": 0}}))
|
||||
]}));
|
||||
let g = pick_geometry(&p).unwrap();
|
||||
let ids: Vec<&str> = g.drawing_meshes.iter().map(|m| m.drawing_id.as_str()).collect();
|
||||
assert_eq!(ids, ["c", "a", "t"]);
|
||||
for m in &g.drawing_meshes {
|
||||
assert!(m.tris.iter().flatten().all(|q| (q[1] - 1.01).abs() < 1e-9), "Geschosshöhe + EPS");
|
||||
}
|
||||
// Scheibe: Mittelpunkt (2, 3) liegt in einem Dreieck, ein Punkt ausserhalb nicht.
|
||||
let inside = |tris: &[Tri], x: f64, z: f64| {
|
||||
tris.iter().any(|t| {
|
||||
let s = |a: V3, b: V3| (b[0] - a[0]) * (z - a[2]) - (b[2] - a[2]) * (x - a[0]);
|
||||
let (d1, d2, d3) = (s(t[0], t[1]), s(t[1], t[2]), s(t[2], t[0]));
|
||||
!((d1 < 0.0 || d2 < 0.0 || d3 < 0.0) && (d1 > 0.0 || d2 > 0.0 || d3 > 0.0))
|
||||
})
|
||||
};
|
||||
assert!(inside(&g.drawing_meshes[0].tris, 2.5, 3.5) && !inside(&g.drawing_meshes[0].tris, 4.0, 3.0));
|
||||
// Bogen: auf dem Bogen ja, im Zentrum nein.
|
||||
assert!(inside(&g.drawing_meshes[1].tris, 10.0 + 2.0 * 0.5f64.sqrt(), 2.0 * 0.5f64.sqrt()) && !inside(&g.drawing_meshes[1].tris, 10.0, 0.0));
|
||||
// Text: 4 Zeichen · 0.6 · 0.5 = 1.2 m breit.
|
||||
assert!(inside(&g.drawing_meshes[2].tris, 21.0, 0.2) && !inside(&g.drawing_meshes[2].tris, 22.0, 0.2));
|
||||
}
|
||||
|
||||
/// [137] Einzeln ausgeblendetes importiertes Netz: weder im 3D noch als Pick-Dreiecke.
|
||||
#[test]
|
||||
fn importiertes_netz_einzeln_ausgeblendet() {
|
||||
let mk = |hidden: Option<bool>| Project {
|
||||
context: Some(vec![ContextObject::ImportedMesh(ImportedMesh { id: "m".into(), hidden, positions: vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0], indices: vec![0.0, 1.0, 2.0], ..Default::default() })]),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(emit_context_meshes(&mk(None)).len(), 1);
|
||||
assert_eq!(pick_geometry(&mk(None)).unwrap().context_meshes.len(), 1);
|
||||
assert!(emit_context_meshes(&mk(Some(true))).is_empty());
|
||||
assert!(pick_geometry(&mk(Some(true))).unwrap().context_meshes.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -76,8 +76,8 @@ pub fn plan_context(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
if code.is_some_and(|k| !c.shown(k)) {
|
||||
continue;
|
||||
}
|
||||
// [137] Einzeln ausgeblendetes Gelände (Kategorie bleibt sichtbar).
|
||||
if matches!(obj, ContextObject::TerrainMesh(t) if t.hidden == Some(true)) {
|
||||
// [137] Einzeln ausgeblendetes Gelände bzw. importiertes Netz (Kategorie bleibt sichtbar).
|
||||
if matches!(obj, ContextObject::TerrainMesh(t) if t.hidden == Some(true)) || matches!(obj, ContextObject::ImportedMesh(m) if m.hidden == Some(true)) {
|
||||
continue;
|
||||
}
|
||||
match obj {
|
||||
|
||||
@@ -164,6 +164,8 @@ export {
|
||||
type PickColumnMesh,
|
||||
type PickSolidMesh,
|
||||
type PickOpeningMesh,
|
||||
type PickStairMesh,
|
||||
type PickDrawingMesh,
|
||||
type PickDrawingSeg,
|
||||
type PickOpening,
|
||||
type PickRoof,
|
||||
|
||||
@@ -2111,6 +2111,8 @@ export const de = {
|
||||
"site.terrain.smooth.hint": "Gelände aus den Höhenlinien neu erzeugen (Bruchkanten bleiben, ein Undo-Schritt)",
|
||||
"site.terrain.smooth.raw": "roh (ohne Glättung)",
|
||||
"site.terrain.smooth.level": "Stufe {n}",
|
||||
"site.mesh.visible": "Dieses Netz sichtbar",
|
||||
"site.mesh.visible.hint": "Blendet nur dieses importierte Netz aus (Grundriss, 3D, Auswahl); die Kategorie bleibt eingeschaltet",
|
||||
"site.terrain.meshVisible": "Dieses Gelände sichtbar",
|
||||
"site.terrain.meshVisible.hint": "Blendet nur dieses Geländenetz aus (Grundriss, Schnitt, Ansicht, 3D); die Kategorie bleibt eingeschaltet",
|
||||
"site.terrain.resmooth.hint": "Raster-Gelände (swissALTI3D) zusätzlich glätten — wirkt auf die Höhen des Rasters, ein Undo-Schritt",
|
||||
|
||||
@@ -2097,6 +2097,8 @@ export const en: Record<TranslationKey, string> = {
|
||||
"site.terrain.smooth.hint": "Regenerate the terrain from its contour lines (breaklines kept, one undo step)",
|
||||
"site.terrain.smooth.raw": "raw (no smoothing)",
|
||||
"site.terrain.smooth.level": "Level {n}",
|
||||
"site.mesh.visible": "This mesh visible",
|
||||
"site.mesh.visible.hint": "Hides only this imported mesh (plan, 3D, selection); the category stays on",
|
||||
"site.terrain.meshVisible": "This terrain visible",
|
||||
"site.terrain.meshVisible.hint": "Hides only this terrain mesh (plan, section, elevation, 3D); the category stays on",
|
||||
"site.terrain.resmooth.hint": "Smooth grid terrain (swissALTI3D) further — acts on the grid heights, one undo step",
|
||||
|
||||
@@ -1549,6 +1549,11 @@ export type ImportedMesh = {
|
||||
smoothShading?: boolean;
|
||||
/** [T4] Knickwinkel in Grad für das glatte Schattieren (Default 30°). */
|
||||
creaseAngle?: number;
|
||||
/**
|
||||
* [137] Nur dieses Netz ausblenden (Grundriss, Schnitt, Ansicht, 3D, Pick); die Kategorie bleibt
|
||||
* davon unberührt. Fehlt/false = sichtbar.
|
||||
*/
|
||||
hidden?: boolean;
|
||||
positions: Array<number>;
|
||||
indices: Array<number>;
|
||||
};
|
||||
|
||||
@@ -75,6 +75,15 @@ export function ContextObjectProps({ obj, quantities }: { obj: ContextObject; qu
|
||||
// [T4] Glatt oder kantig schattieren, Knickwinkel je Mesh (Vorgabe 30°).
|
||||
return (
|
||||
<div className="site-props">
|
||||
<label className="site-check" title={t("site.mesh.visible.hint")}>
|
||||
<input
|
||||
type="checkbox"
|
||||
data-testid="imported-mesh-visible"
|
||||
checked={obj.hidden !== true}
|
||||
onChange={(e) => host.onPatchContextObject(obj.id, { hidden: e.target.checked ? undefined : true }, `site-${obj.id}-hidden`)}
|
||||
/>
|
||||
{t("site.mesh.visible")}
|
||||
</label>
|
||||
<label className="site-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
|
||||
@@ -114,6 +114,18 @@ export interface PickSolidMesh {
|
||||
solidId: string;
|
||||
}
|
||||
|
||||
/** [137] Treppengeländer (Handlauf, Pfosten): WORLD-Dreiecke; ragen über die Treppen-Hülle hinaus. */
|
||||
export interface PickStairMesh {
|
||||
tris: ReadonlyArray<readonly [Vec3, Vec3, Vec3]>;
|
||||
stairId: string;
|
||||
}
|
||||
|
||||
/** [137] Flache Pick-Fläche eines 2D-Elements ohne Linien-Spur (Kreis, Bogen, Ellipse, Text) auf Geschosshöhe. */
|
||||
export interface PickDrawingMesh {
|
||||
tris: ReadonlyArray<readonly [Vec3, Vec3, Vec3]>;
|
||||
drawingId: string;
|
||||
}
|
||||
|
||||
/** [137] Öffnung ohne Wand (Dachfenster, Deckenöffnung, Gaubenfenster): WORLD-Dreiecke ihrer 3D-Teile. */
|
||||
export interface PickOpeningMesh {
|
||||
tris: ReadonlyArray<readonly [Vec3, Vec3, Vec3]>;
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// [137] 3D-Pick, Rest: Treppengeländer über der Treppen-Hülle, Kreise/Bögen/Texte (Bäume, Symbole) als flache
|
||||
// Fläche, einzeln ausgeblendetes importiertes Netz (Objekt-Info-Schalter `hidden`, mit Undo).
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { ImportedMesh, Project } from "../model/types";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { pickGeometry } from "./toWalls3d";
|
||||
import { pickNearest, type Ray } from "../viewport/raycast3d";
|
||||
import { getState, setState } from "../state/appStore";
|
||||
|
||||
const base: Project = {
|
||||
...sampleProject,
|
||||
walls: [],
|
||||
openings: [],
|
||||
ceilings: [],
|
||||
roofs: [],
|
||||
columns: [],
|
||||
extrudedSolids: [],
|
||||
context: [],
|
||||
stairTypes: [{ ...sampleProject.stairTypes![0], id: "rail", railing: "beide" }],
|
||||
stairs: [
|
||||
{ id: "st1", type: "stair", floorId: "eg", categoryCode: "35", shape: "straight", start: { x: 0, y: 0 }, dir: { x: 1, y: 0 }, runLength: 3, width: 1, stepCount: 16, totalRise: 2.8, typeId: "rail" },
|
||||
],
|
||||
drawings2d: [{ id: "baum", type: "drawing2d", levelId: "eg", categoryCode: "20", geom: { shape: "circle", center: { x: 20, y: 5 }, r: 2 } }],
|
||||
} as unknown as Project;
|
||||
|
||||
const down = (x: number, z: number): Ray => ({ origin: [x, 50, z], dir: [0, -1, 0] });
|
||||
const pick = (p: Project, ray: Ray) => {
|
||||
const g = pickGeometry(p);
|
||||
return pickNearest(ray, g.walls, g.slabs, g.openings, g.stairs, g.roofs, g.contextMeshes, g.drawings, g.columns, g.solids, g.openingMeshes, g.stairMeshes, g.drawingMeshes);
|
||||
};
|
||||
|
||||
describe("[137] 3D-Pick Treppengeländer und 2D-Flächen", () => {
|
||||
it("Geländer-Dreiecke tragen die Treppen-Id und liegen über der Hülle", () => {
|
||||
const g = pickGeometry(base);
|
||||
expect(g.stairMeshes.map((m) => m.stairId)).toEqual(["st1"]);
|
||||
const top = Math.max(...g.stairMeshes[0].tris.flat().map((q) => q[1]));
|
||||
expect(top).toBeGreaterThan(g.stairs[0].zTop);
|
||||
});
|
||||
|
||||
it("Kreis (Baum) ist von oben anwählbar, daneben nicht", () => {
|
||||
const hit = pick(base, down(20.5, 5.5));
|
||||
expect(hit?.kind).toBe("drawing");
|
||||
expect(hit?.id).toBe("baum");
|
||||
expect(pick(base, down(24, 5))).toBeNull();
|
||||
});
|
||||
|
||||
it("importiertes Netz: hidden entfernt die Pick-Dreiecke, Undo bringt sie zurück", () => {
|
||||
const mesh = { type: "importedMesh", id: "im", name: "M", positions: [30, 0, 0, 32, 0, 0, 30, 2, 0], indices: [0, 1, 2] } as ImportedMesh;
|
||||
setState({ project: { ...base, stairs: [], drawings2d: [], context: [mesh] }, undoDepth: 0, redoDepth: 0, canUndo: false, canRedo: false });
|
||||
getState().clearHistory();
|
||||
expect(pickGeometry(getState().project).contextMeshes.map((m) => m.contextObjectId)).toEqual(["im"]);
|
||||
getState().patchContextObject("im", { hidden: true });
|
||||
expect((getState().project.context![0] as ImportedMesh).hidden).toBe(true);
|
||||
expect(pickGeometry(getState().project).contextMeshes).toEqual([]);
|
||||
getState().undo();
|
||||
expect(pickGeometry(getState().project).contextMeshes).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@@ -44,7 +44,7 @@ import type { Project, Vec2 } from "../model/types";
|
||||
import type { DetailLevel } from "../model/viewTypes";
|
||||
import { documentFor } from "../core/document";
|
||||
import { coreEpoch } from "../engine/coreWasm";
|
||||
import type { PickOpening, PickRoof, PickStair, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickDrawingSeg } from "./pickTypes";
|
||||
import type { PickOpening, PickRoof, PickStair, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickDrawingSeg, PickStairMesh, PickDrawingMesh } from "./pickTypes";
|
||||
import {
|
||||
type RMesh,
|
||||
type RModel3d,
|
||||
@@ -332,6 +332,8 @@ export function pickGeometry(
|
||||
solids: PickSolidMesh[];
|
||||
openingMeshes: PickOpeningMesh[];
|
||||
drawings: PickDrawingSeg[];
|
||||
stairMeshes: PickStairMesh[];
|
||||
drawingMeshes: PickDrawingMesh[];
|
||||
} {
|
||||
const g = documentFor(project).query("pickGeometry", [explodeGap(explode)]) as ReturnType<typeof pickGeometry>;
|
||||
// [137] Freie Körper: das geladene truck-Netz (Loft, Rotation, Verjüngung, Rundung) statt der Prisma-Näherung des Kerns.
|
||||
|
||||
@@ -1406,7 +1406,7 @@ export function Wasm3DViewport({
|
||||
const ndc = toNdc(clientX, clientY);
|
||||
if (!cb || !o || !ndc) return;
|
||||
const ray = cameraRay(orbitCamera(o), ndc.ndcX, ndc.ndcY, ndc.aspect);
|
||||
const { walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes } = pickGeometry(
|
||||
const { walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes, stairMeshes, drawingMeshes } = pickGeometry(
|
||||
projectRef.current,
|
||||
explodeRef.current,
|
||||
);
|
||||
@@ -1414,7 +1414,7 @@ export function Wasm3DViewport({
|
||||
// Meshes + freie 2D-Zeichnungen (Linie/Polylinie/Rechteck, s.
|
||||
// `pickDrawingSegs`) — sonst wären im WASM-Viewport 2D-Elemente NIE
|
||||
// anwählbar gewesen (Nutzer-Report).
|
||||
const hit = pickNearest(ray, walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes);
|
||||
const hit = pickNearest(ray, walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes, stairMeshes, drawingMeshes);
|
||||
cb(hit ? { kind: hit.kind, id: hit.id } : null, additive);
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
import { DRAWING_PICK_TOLERANCE } from "../core";
|
||||
import type { Vec3, PickWall, PickOpening, PickDrawingSeg, PickSlab, PickStair, PickRoof, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh } from "../core";
|
||||
import type { Vec3, PickWall, PickOpening, PickDrawingSeg, PickSlab, PickStair, PickRoof, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickStairMesh, PickDrawingMesh } from "../core";
|
||||
|
||||
/** Kamera-Parameter für den Pick-Strahl (Teilmenge von Camera3d). */
|
||||
export interface RayCamera {
|
||||
@@ -360,6 +360,8 @@ export function pickNearest(
|
||||
columns?: readonly PickColumnMesh[],
|
||||
solids?: readonly PickSolidMesh[],
|
||||
openingMeshes?: readonly PickOpeningMesh[],
|
||||
stairMeshes?: readonly PickStairMesh[],
|
||||
drawingMeshes?: readonly PickDrawingMesh[],
|
||||
): PickHit | null;
|
||||
/**
|
||||
* Nächstes getroffenes Bauteil (kleinstes t) über Wände, Decken, Öffnungen und
|
||||
@@ -382,6 +384,8 @@ export function pickNearest(
|
||||
columns: readonly PickColumnMesh[] = [],
|
||||
solids: readonly PickSolidMesh[] = [],
|
||||
openingMeshes: readonly PickOpeningMesh[] = [],
|
||||
stairMeshes: readonly PickStairMesh[] = [],
|
||||
drawingMeshes: readonly PickDrawingMesh[] = [],
|
||||
): PickHit | null {
|
||||
const TIE_EPS = 1e-6;
|
||||
let hit: PickHit | null = null;
|
||||
@@ -447,6 +451,16 @@ export function pickNearest(
|
||||
const t = rayContextMeshTris(ray, { tris: o.tris, contextObjectId: o.openingId });
|
||||
if (t !== null) consider({ kind: "opening", id: o.openingId, t, openingId: o.openingId }, 0);
|
||||
}
|
||||
// [137] Treppengeländer (über der Hülle, oberes Podest): Rang wie Treppe.
|
||||
for (const m of stairMeshes) {
|
||||
const t = rayContextMeshTris(ray, { tris: m.tris, contextObjectId: m.stairId });
|
||||
if (t !== null) consider({ kind: "stair", id: m.stairId, t, stairId: m.stairId }, 0);
|
||||
}
|
||||
// [137] Kreise/Bögen/Texte (Bäume, Symbole): flache Fläche, Rang wie die Linien-Spur.
|
||||
for (const m of drawingMeshes) {
|
||||
const t = rayContextMeshTris(ray, { tris: m.tris, contextObjectId: m.drawingId });
|
||||
if (t !== null) consider({ kind: "drawing", id: m.drawingId, t, drawingId: m.drawingId }, 0);
|
||||
}
|
||||
return hit;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user