[227] Kontextgebäude aufs Gelände setzen, Baugrube im Rendering ausblenden

Kern context_ground.rs: Gebäude eines Netzes auf den tiefsten Geländepunkt unter dem Fussabdruck
(Befehl contextToTerrain, Knopf in der Objekt-Info, automatisch beim Geo-Import). Musterhaus komplex:
Nachbarn auf dem Gelände, Höhenlinien bis unter die Nachbarn. Rendering: Option "Baugrube ausblenden
(hinterfüllt)", Vorgabe an: Paket mit gewachsenem Gelände (meshExportData, 4. Argument); CLI --excavation.
This commit is contained in:
Claude committed 2026-11-12 23:19:26 +00:00
1 parent c032aef394
commit 840727ff22
29 files changed
+441 -37

No files matched your search

+14
View File
@@ -93,6 +93,20 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC.
(Fassade, Dach) im 3D nicht auf die Fläche beschnitten — Linien ragen über Giebel/Ortgang hinaus in die Luft; (3) Rundbogen-Öffnung:
Leibungs-/Sturzflächen mit Streifen-/Backsteinmuster, Bogen-Leibung nicht sauber geschnitten; (4) Dachfenster in der Darstellung
„ohne Material“ als offener Schlitz ohne Glas. · M
- ◐ **[227]** Kontextgebäude auf dem Gelände, Baugrube im Rendering ausblenden (12.11., Befunde der Mac-Gegenprobe [211]). (1) Kern
`context_ground.rs`: jedes zusammenhängende Gebäude eines Netzes (`importedMesh`, auch mehrere Häuser in einem Netz) wird senkrecht auf den
tiefsten Punkt des gewachsenen Geländes unter dem Fussabdruck gesetzt (Fusspunkte, Fusskanten, Raster innen; Sockel reicht bis dorthin, kein
Spalt talseitig); Befehl `contextToTerrain {ids}` (`cmd_context.rs`, ein `Replace` je Netz); Store `groundContextObjects`; Knopf „Aufs
Gelände setzen“ in der Objekt-Info der Netze (`ContextObjectProps`); beim Hinzufügen eines Geo-Imports (Kataster/swisstopo/OSM,
`isGeoBuildingMesh`) automatisch im selben Undo-Schritt wie der Import (`siteSlice.addToContext`). Musterhaus komplex: Nachbarn ruhen auf dem
Gelände; die Höhenlinien reichen dafür bis x −44 … 54 (vorher −16 … 32, Nachbarn lagen ausserhalb des Netzes; Goldens `komplex-*` neu). (2)
Rendering: Option „Baugrube ausblenden (hinterfüllt)“ (Vorgabe an; `RenderOptions.backfilled`, `scene.backfilled`, CLI `--excavation` lässt
sie stehen): das Paket enthält das gewachsene Gelände ohne Aushub (`MeshOptions.backfilled`, Kern `mesh_data.rs`, 4. Argument von
`meshExportData`, `excavation::terrain_original_mesh`), das normale 3D und die Klasse „07 Baugrube“ bleiben unberührt. Geprüft: Rust-Tests
(`context_ground`, `mesh_data`), vitest (Paket, Szene, Store, Beispielprojekt), echter Cycles-Lauf mit `bpy` (CPU) vorher/nachher.
**Offen:** Nachbarn ausserhalb des Geländenetzes (Musterhaus: Nordhäuser, ≤ 0.3 m über dem Hang) bleiben auf z = 0; Gelände im Rendering ist das
gewachsene Terrain, auch innerhalb des Grundrisses (steigt es dort über die Bodenplatte, schneidet es durch); nicht in der Tauri-App/auf dem
Mac, Dialog nicht im Browser geklickt. · S
- ◐ **[207]** Schwarzplan / Situationsplan 1:500 (12.11.): Modelldarstellung mit `situation` (`ModelViewOption.situation`, Kern
`plan/situation.rs`) ersetzt im Grundriss die Bauteile durch den gefüllten Umriss des eigenen Gebäudes (Wände/Decken/Körper ab
Erdgeschoss + Dächer mit Überstand, Klasse „83 Situation Gebäude"), gefüllte Grundfläche der Kontextnetze ([181], auf ihrer Klasse;
+2
View File
@@ -20,6 +20,8 @@ nach z-oben zurück, `scene.json` braucht keine Umrechnung.
- `model`, `output`: Dateinamen (`model.glb`, `render.png`).
- `resolution {width, height}` in Pixeln; `samples` je Pixel; `denoise` (bool); `device` `"auto"` oder `"cpu"`.
- `backfilled` (bool, nur Hinweis): das Gelände im `model.glb` ist das gewachsene, ohne Baugruben (hinterfüllt, bis an die Fassade geschlossen);
false = mit Aushub wie im 3D. Der Leser setzt dazu nichts um, die Geometrie steckt im GLB.
- `camera`: entweder `{preset}` (`iso`, `perspective`, `front`, `back`, `left`, `right`, `side`, `top`; der Leser
rahmt das Gebäude ein, ohne Gelände/Kontext) oder explizit `{kind: "perspective"|"orthogonal", position[3],
direction[3] (normiert), up[3], fovDeg (vertikal), orthoHeight (volle Sichthöhe, m)}`.
+1
View File
@@ -74,6 +74,7 @@ Neues Modul: `<modul>.rs` und `mod` in `lib.rs`, Bindungen in `web/<modul>.rs` u
| `cmd_draw.rs`, `cmd_edit.rs`, `cmd_split.rs`, `cmd_paste.rs` | 2D zeichnen und bemassen, bearbeiten, teilen, einfügen |
| `cmd_transform.rs`, `cmd_wall_edit.rs`, `cmd_solid.rs` | Transformieren; Wände bearbeiten; Körper, Gelände, Sonderbefehle |
| `cmd_context.rs` | [193] Höhenversatz und Höhe je Höhenlinie von Gelände-/Umgebungs-Elementen (`contextOffset`, `contourZ`) |
| `context_ground.rs` | [227] Kontextgebäude aufs Gelände setzen (Befehl `contextToTerrain`): je Gebäude des Netzes auf den tiefsten Geländepunkt unter dem Fussabdruck |
| `grips.rs`, `grip_drag.rs` | Griffe: Geometrie und Rechnung je Mausschritt |
| `sheet_height.rs` | [187] Höhen-Griffe im Schnitt/in der Ansicht (Wand, Öffnung, Decke): Vorschau-Kanten, Fang an Koten, Änderung am Bauteil (Griff-Anfrage `sheetHeight`) |
| `snap.rs`, `snap_model.rs` | Objektfang |
+14 -4
View File
@@ -213,8 +213,18 @@ pub fn mesh_point_delete(e: &Value, index: usize) -> Option<Value> {
}
/// Ops der Höhen-/Netz-Befehle (`None` = fremder Befehl).
pub fn ops(root: &Map<String, Value>, v: &Value) -> Option<Vec<Op>> {
pub fn ops(root: &Map<String, Value>, p: &crate::model::Project, v: &Value) -> Option<Vec<Op>> {
let cmd = v.get("cmd").and_then(Value::as_str)?;
// [227] Kontextgebäude aufs Gelände setzen: ein Befehl für mehrere Netze (`ids`).
if cmd == "contextToTerrain" {
let ids: Vec<&str> = v.get("ids").and_then(Value::as_array).map(|a| a.iter().filter_map(Value::as_str).collect()).unwrap_or_default();
return Some(
ids.into_iter()
.filter_map(|id| element(root, id).and_then(|e| crate::context_ground::ground_element(p, e)))
.map(|entity| Op::Replace { collection: "context".into(), entity })
.collect(),
);
}
if !matches!(cmd, "contextOffset" | "contourZ" | "meshPointZ" | "meshCrop" | "meshPointDelete") {
return None;
}
@@ -253,7 +263,7 @@ mod tests {
}
fn run(v: Value) -> Vec<Value> {
ops(&root(), &v).unwrap().iter().map(|o| o.to_json()).collect()
ops(&root(), &Default::default(), &v).unwrap().iter().map(|o| o.to_json()).collect()
}
#[test]
@@ -287,7 +297,7 @@ mod tests {
// Zwei Dreiecke (Quadrat 0..2); Zuschnitt auf die linke Hälfte behält eines, verwirft Punkte und Farben.
let mut r = root();
r.insert("context".into(), json!([{"id":"q","type":"terrainMesh","positions":[0,0,1, 2,0,2, 2,2,3, 0,2,4],"indices":[0,1,2, 0,2,3],"vertexColors":[0,0,0, 1,1,1, 2,2,2, 3,3,3]}]));
let cut = |poly: Value| ops(&r, &json!({"cmd":"meshCrop","id":"q","poly":poly})).unwrap().iter().map(|o| o.to_json()).collect::<Vec<_>>();
let cut = |poly: Value| ops(&r, &Default::default(), &json!({"cmd":"meshCrop","id":"q","poly":poly})).unwrap().iter().map(|o| o.to_json()).collect::<Vec<_>>();
let o = cut(json!([-1.0, -1.0, 1.5, -1.0, 1.5, 3.0, -1.0, 3.0]));
// Schwerpunkte: (4/3, 2/3) und (2/3, 4/3) -> beide liegen links von 1.5: nichts abgeschnitten.
assert!(o.is_empty());
@@ -308,7 +318,7 @@ mod tests {
r.insert("context".into(), json!([{"id":"q","type":"terrainMesh",
"positions":[0,0,0, 2,0,0, 2,2,0, 0,2,0, 1,1,9],
"indices":[0,1,4, 1,2,4, 2,3,4, 3,0,4], "vertexColors":[0,0,0, 1,1,1, 2,2,2, 3,3,3, 4,4,4]}]));
let del = |r: &Map<String, Value>, i: usize| ops(r, &json!({"cmd":"meshPointDelete","id":"q","index":i})).unwrap().iter().map(|o| o.to_json()).collect::<Vec<_>>();
let del = |r: &Map<String, Value>, i: usize| ops(r, &Default::default(), &json!({"cmd":"meshPointDelete","id":"q","index":i})).unwrap().iter().map(|o| o.to_json()).collect::<Vec<_>>();
let o = del(&r, 4);
let e = &o[0]["entity"];
assert_eq!(e["positions"].as_array().unwrap().len(), 12);
+1 -1
View File
@@ -35,7 +35,7 @@ pub fn ops(root: &Map<String, Value>, p: &Project, text: &str) -> Result<Vec<Op>
if let Some(ops) = crate::cmd_create::ops(root, p, &v) {
return Ok(ops);
}
if let Some(ops) = crate::cmd_context::ops(root, &v) {
if let Some(ops) = crate::cmd_context::ops(root, p, &v) {
return Ok(ops);
}
Ok(match cmd {
+191
View File
@@ -0,0 +1,191 @@
//! [227] Kontextgebäude aufs Gelände setzen: jedes zusammenhängende Gebäude eines Netzes (Kataster-Extrusion,
//! swisstopo/OSM, importierte Körper) wird senkrecht so verschoben, dass sein Fuss auf dem tiefsten Geländepunkt
//! unter dem Grundriss liegt. Auf der Hangseite verschwindet der Sockel im Boden, talseitig bleibt kein Spalt.
//! Gelände = gewachsenes Terrain im Modellbezug (`excavation::terrain_z_many`), Baugruben zählen nicht.
use crate::excavation::terrain_z_many;
use crate::model::Project;
use crate::terrain::P2;
use serde_json::Value;
use std::collections::HashMap;
/// Höchstens so viele Rasterschritte je Richtung unter dem Grundriss.
const MAX_GRID: f64 = 40.0;
/// Fusshöhe: Punkte höchstens so viel über dem tiefsten Punkt gehören zum Fuss.
const FOOT_TOL: f64 = 0.05;
fn find(parent: &mut [usize], mut a: usize) -> usize {
while parent[a] != a {
parent[a] = parent[parent[a]];
a = parent[a];
}
a
}
fn in_tri(p: P2, a: P2, b: P2, c: P2) -> bool {
let s = |p: P2, q: P2, r: P2| (p[0] - r[0]) * (q[1] - r[1]) - (q[0] - r[0]) * (p[1] - r[1]);
let (d1, d2, d3) = (s(p, a, b), s(p, b, c), s(p, c, a));
!((d1 < 0.0 || d2 < 0.0 || d3 < 0.0) && (d1 > 0.0 || d2 > 0.0 || d3 > 0.0))
}
/// Höhenversatz je Vertex: Gebäude (Komponenten, Vertices auf 1 mm verschweisst) auf den tiefsten Geländepunkt unter
/// ihrem Grundriss. `0.0` für Gebäude ohne Gelände darunter. Leer bei unbrauchbarem Netz.
pub fn ground_offsets(p: &Project, pos: &[f64], idx: &[f64]) -> Vec<f64> {
let n = pos.len() / 3;
if n == 0 || idx.len() < 3 || pos.iter().any(|v| !v.is_finite()) {
return Vec::new();
}
let tris: Vec<[usize; 3]> = idx
.chunks_exact(3)
.filter(|c| c.iter().all(|v| v.is_finite() && *v >= 0.0 && (*v as usize) < n))
.map(|c| [c[0] as usize, c[1] as usize, c[2] as usize])
.collect();
let mut parent: Vec<usize> = (0..n).collect();
let mut seen: HashMap<(i64, i64, i64), usize> = HashMap::new();
for i in 0..n {
let k = ((pos[3 * i] * 1000.0).round() as i64, (pos[3 * i + 1] * 1000.0).round() as i64, (pos[3 * i + 2] * 1000.0).round() as i64);
let first = *seen.entry(k).or_insert(i);
let (a, b) = (find(&mut parent, first), find(&mut parent, i));
parent[b] = a;
}
for t in &tris {
let (a, b) = (find(&mut parent, t[0]), find(&mut parent, t[1]));
parent[b] = a;
let (a, c) = (find(&mut parent, t[0]), find(&mut parent, t[2]));
parent[c] = a;
}
let comp: Vec<usize> = (0..n).map(|i| find(&mut parent, i)).collect();
let mut groups: HashMap<usize, (Vec<usize>, Vec<usize>)> = HashMap::new();
for (i, &c) in comp.iter().enumerate() {
groups.entry(c).or_default().0.push(i);
}
for (ti, t) in tris.iter().enumerate() {
groups.entry(comp[t[0]]).or_default().1.push(ti);
}
let xy = |i: usize| -> P2 { [pos[3 * i], pos[3 * i + 1]] };
let mut out = vec![0.0; n];
for (verts, tri_ids) in groups.values() {
let zmin = verts.iter().map(|&i| pos[3 * i + 2]).fold(f64::INFINITY, f64::min);
let foot = |i: usize| pos[3 * i + 2] <= zmin + FOOT_TOL;
// Abfragepunkte: Fusspunkte, Fusskanten (alle <= 1 m) und ein Raster innerhalb des Grundrisses.
let mut q: Vec<P2> = verts.iter().filter(|&&i| foot(i)).map(|&i| xy(i)).collect();
for &ti in tri_ids {
let t = tris[ti];
for k in 0..3 {
let (a, b) = (t[k], t[(k + 1) % 3]);
if foot(a) && foot(b) {
let (pa, pb) = (xy(a), xy(b));
let steps = (pa[0] - pb[0]).hypot(pa[1] - pb[1]).ceil().clamp(1.0, 200.0) as usize;
for s in 1..steps {
let f = s as f64 / steps as f64;
q.push([pa[0] + (pb[0] - pa[0]) * f, pa[1] + (pb[1] - pa[1]) * f]);
}
}
}
}
let (mut lo, mut hi) = ([f64::INFINITY; 2], [f64::NEG_INFINITY; 2]);
for &i in verts {
for k in 0..2 {
lo[k] = lo[k].min(pos[3 * i + k]);
hi[k] = hi[k].max(pos[3 * i + k]);
}
}
let step = ((hi[0] - lo[0]).max(hi[1] - lo[1]) / MAX_GRID).max(1.0);
let mut x = lo[0] + step / 2.0;
while x < hi[0] {
let mut y = lo[1] + step / 2.0;
while y < hi[1] {
let g = [x, y];
if tri_ids.iter().any(|&ti| in_tri(g, xy(tris[ti][0]), xy(tris[ti][1]), xy(tris[ti][2]))) {
q.push(g);
}
y += step;
}
x += step;
}
let zt = terrain_z_many(p, &q).iter().filter_map(|(orig, _)| *orig).fold(f64::INFINITY, f64::min);
if zt.is_finite() {
let dz = zt - zmin;
for &i in verts {
out[i] = dz;
}
}
}
out
}
/// Das Netz-Element `e` (`importedMesh`) aufs Gelände gesetzt; `None` ohne Änderung (keine Netzart, kein Gelände,
/// schon aufgesetzt).
pub fn ground_element(p: &Project, e: &Value) -> Option<Value> {
if e.get("type").and_then(Value::as_str) != Some("importedMesh") {
return None;
}
let num = |v: &Value| v.as_f64().unwrap_or(f64::NAN);
let pos: Vec<f64> = e.get("positions")?.as_array()?.iter().map(num).collect();
let idx: Vec<f64> = e.get("indices")?.as_array()?.iter().map(num).collect();
let dz = ground_offsets(p, &pos, &idx);
if dz.iter().all(|d| d.abs() < 1e-6) {
return None;
}
let moved: Vec<Value> = pos.iter().enumerate().map(|(i, &v)| crate::json_util::js_num(if i % 3 == 2 { v + dz[i / 3] } else { v })).collect();
Some(crate::json_util::with(e, "positions", Value::Array(moved)))
}
#[cfg(test)]
mod tests {
use super::*;
use crate::model::{ContextObject, TerrainMesh};
/// Gelände 100 × 100 m, steigt nach +x um 0.1 m/m (z = 0.1·x).
fn sloped() -> Project {
let pos = vec![-50.0, -50.0, -5.0, 50.0, -50.0, 5.0, 50.0, 50.0, 5.0, -50.0, 50.0, -5.0];
let t = TerrainMesh { id: "g".into(), positions: pos, indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], ..Default::default() };
Project { context: Some(vec![ContextObject::TerrainMesh(t)]), ..Default::default() }
}
fn house(x0: f64, x1: f64, h: f64) -> Value {
let (y0, y1) = (0.0, 6.0);
let mut pos = vec![];
for z in [0.0, h] {
for (x, y) in [(x0, y0), (x1, y0), (x1, y1), (x0, y1)] {
pos.extend([x, y, z]);
}
}
let idx: Vec<f64> = vec![0., 1., 2., 0., 2., 3., 4., 6., 5., 4., 7., 6., 0., 1., 5., 0., 5., 4., 1., 2., 6., 1., 6., 5.];
serde_json::json!({"type":"importedMesh","id":"h","positions":pos,"indices":idx})
}
fn zs(e: &Value) -> Vec<f64> {
e["positions"].as_array().unwrap().chunks(3).map(|c| c[2].as_f64().unwrap()).collect()
}
#[test]
fn haus_steht_auf_dem_tiefsten_punkt() {
// 10 m breit am Hang: tiefster Punkt bei x = 10, dort liegt das Gelände auf z = 1.0.
let e = ground_element(&sloped(), &house(10.0, 20.0, 8.0)).unwrap();
let z = zs(&e);
assert!((z.iter().cloned().fold(f64::INFINITY, f64::min) - 1.0).abs() < 1e-9, "{z:?}");
assert!((z.iter().cloned().fold(f64::NEG_INFINITY, f64::max) - 9.0).abs() < 1e-9);
// zweites Mal: nichts mehr zu tun.
assert!(ground_element(&sloped(), &e).is_none());
}
#[test]
fn zwei_haeuser_unabhaengig() {
let (a, b) = (house(-30.0, -20.0, 5.0), house(20.0, 30.0, 5.0));
let mut pos = a["positions"].as_array().unwrap().clone();
pos.extend(b["positions"].as_array().unwrap().clone());
let mut idx = a["indices"].as_array().unwrap().clone();
idx.extend(b["indices"].as_array().unwrap().iter().map(|v| serde_json::json!(v.as_f64().unwrap() + 8.0)));
let e = serde_json::json!({"type":"importedMesh","id":"n","positions":pos,"indices":idx});
let z = zs(&ground_element(&sloped(), &e).unwrap());
// Westhaus auf x = -30 (z = -3), Osthaus auf x = 20 (z = 2).
assert!((z[0] + 3.0).abs() < 1e-9 && (z[8] - 2.0).abs() < 1e-9, "{z:?}");
}
#[test]
fn ohne_gelaende_oder_art_keine_aenderung() {
assert!(ground_element(&Project::default(), &house(0.0, 5.0, 3.0)).is_none());
assert!(ground_element(&sloped(), &serde_json::json!({"type":"terrainMesh","id":"g"})).is_none());
}
}
+7
View File
@@ -928,6 +928,13 @@ pub fn terrain_model_mesh<'a>(p: &Project, t: &'a TerrainMesh) -> (std::borrow::
(Cow::Owned(pos), Cow::Owned(idx), st.modified.is_some())
}
/// [227] Das gewachsene Gelände-Netz im Modellbezug, ohne Baugruben (hinterfüllt, z. B. für Bilder).
pub fn terrain_original_mesh(p: &Project, t: &TerrainMesh) -> (std::borrow::Cow<'static, [f64]>, std::borrow::Cow<'static, [f64]>, bool) {
let st = site_terrain(p, t);
let (pos, idx) = st.orig.to_flat(-st.datum);
(std::borrow::Cow::Owned(pos), std::borrow::Cow::Owned(idx), false)
}
/// [T6] Luftbild-Farben (flach r,g,b je Eckpunkt des Original-Netzes) auf das geänderte Gelände übertragen:
/// jeder neue Eckpunkt erhält die in der Grundrissprojektion (x, y) des Originals interpolierte Farbe
/// (Böschungen und Sohle bekommen so die Farbe des Bildes darüber); ausserhalb der nächste Eckpunkt.
+1
View File
@@ -129,6 +129,7 @@ pub mod import_ifc;
pub mod cmd_paste;
pub mod cmd_split;
pub mod cmd_context;
pub mod context_ground;
pub mod cmd_wall_edit;
pub mod snap_model;
pub mod solid_specs;
+24 -2
View File
@@ -37,11 +37,13 @@ pub struct MeshOptions {
pub context: bool,
/// Geschoss als Eltern-Knoten (nur glTF; OBJ/STL: aus).
pub by_level: bool,
/// [227] Baugruben weglassen: das Gelände ist das gewachsene (hinterfüllt, bis an die Fassade geschlossen).
pub backfilled: bool,
}
impl Default for MeshOptions {
fn default() -> Self {
MeshOptions { opening_parts: true, context: true, by_level: true }
MeshOptions { opening_parts: true, context: true, by_level: true, backfilled: false }
}
}
@@ -508,7 +510,7 @@ pub fn mesh_export_data(src: &Project, opt: &MeshOptions) -> Result<Flat, String
for obj in p.context.as_deref().unwrap_or(&[]) {
let (terrain, id, name, color, positions, indices) = match obj {
ContextObject::TerrainMesh(m) => {
let (pos, idx, _) = crate::excavation::terrain_model_mesh(&p, m);
let (pos, idx, _) = if opt.backfilled { crate::excavation::terrain_original_mesh(&p, m) } else { crate::excavation::terrain_model_mesh(&p, m) };
(true, &m.id, &m.name, None, pos, idx)
}
ContextObject::ImportedMesh(m) => (false, &m.id, &m.name, m.color.as_deref(), std::borrow::Cow::Borrowed(m.positions.as_slice()), std::borrow::Cow::Borrowed(m.indices.as_slice())),
@@ -567,6 +569,26 @@ mod tests {
serde_json::from_str(include_str!("../tests/fixtures/sample_project.json")).unwrap()
}
#[test]
fn hinterfuellt_laesst_die_baugrube_weg() {
let mut p = sample();
let t = TerrainMesh { id: "g".into(), positions: vec![-50.0, -50.0, 0.0, 50.0, -50.0, 0.0, 50.0, 50.0, 0.0, -50.0, 50.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], ..Default::default() };
let pit = Excavation {
id: "bg".into(),
outline: vec![Vec2 { x: -5.0, y: -5.0 }, Vec2 { x: 5.0, y: -5.0 }, Vec2 { x: 5.0, y: 5.0 }, Vec2 { x: -5.0, y: 5.0 }],
bottom: -3.0,
slope: Some(45.0),
..Default::default()
};
p.context = Some(vec![ContextObject::TerrainMesh(t), ContextObject::Excavation(pit)]);
// Die Sohle (z = -3) steht nur im Netz mit Baugrube.
let has_floor = |f: &Flat| f.nums.iter().any(|v| *v == -3.0);
let with = mesh_export_data(&p, &MeshOptions::default()).unwrap();
let back = mesh_export_data(&p, &MeshOptions { backfilled: true, ..Default::default() }).unwrap();
assert!(has_floor(&with) && !has_floor(&back));
assert_ne!(with.nums.len(), back.nums.len());
}
#[test]
fn namen_wie_js() {
assert_eq!(sanitize_name("W 1/ä"), "W_1__");
+3 -2
View File
@@ -290,8 +290,9 @@ pub fn run_bin(p: &Project, name: &str, args: &[f64], text: &str) -> Result<Vec<
let opt = crate::ifc_data::IfcOptions { now: args[0], ifc2x3: args[1] != 0.0, ebkph: args[2] != 0.0, layer_codes: args[3] != 0.0, iso: text.to_string() };
crate::ifc_data::ifc_export_data(p, &opt).map(|f| f.to_bytes())
}
("meshExportData", 3) => {
let opt = crate::mesh_data::MeshOptions { opening_parts: args[0] != 0.0, context: args[1] != 0.0, by_level: args[2] != 0.0 };
("meshExportData", 3 | 4) => {
// 4. Argument [227]: Baugruben weglassen (hinterfüllt).
let opt = crate::mesh_data::MeshOptions { opening_parts: args[0] != 0.0, context: args[1] != 0.0, by_level: args[2] != 0.0, backfilled: args.get(3).is_some_and(|v| *v != 0.0) };
crate::mesh_data::mesh_export_data(p, &opt).map(|f| f.to_bytes())
}
// Gruppen der kompakten Linien-Unterlage (gleiche Argumente wie `planDomains`), als f64.
+2 -2
View File
@@ -37,7 +37,7 @@
// [154] Bauteile aus 2D-Zeichnung erkennen (Wände, Öffnungen, Räume
// ins Geschoss); Bericht als JSON. Z. B. convert plan.dxf p.obp --cmd "erkennen --out e.obp"
// dossier-cli <projekt.obp> render --out bild.png [--view iso|perspective|front|back|left|right|top] [--when 2026-06-21T10:00Z]
// [--camera Name|id] [--samples 128] [--size 1920x1080] [--cpu] [--blender pfad] [--keep] [211] Rendering mit Blender/Cycles
// [--camera Name|id] [--samples 128] [--size 1920x1080] [--cpu] [--excavation] [--blender pfad] [--keep] [211] [227] (--excavation: Baugrube im Bild lassen) Rendering mit Blender/Cycles
// dossier-cli <projekt.obp> model3d [--explode 3] [--hide …] [--grey …] [--out modell.json] 3D-Modell fürs Headless-Rendern (render_png)
// dossier-cli pointcloud-info <datei.las|laz|e57|ply|xyz|pts> [--voxel 0.05] [--max 2000000]
// Punktwolke lesen ([B9]) und Bericht als JSON (ohne Projekt)
@@ -784,7 +784,7 @@ async function runRender(project: Project, args: Args): Promise<number> {
await loadFileio();
const pkg = await buildRenderPackage(
project,
{ width: Number(m[1]), height: Number(m[2]), samples, when, camera: choice ? choice.camera : { preset: view }, device: args.flags.has("cpu") ? "cpu" : "auto" },
{ width: Number(m[1]), height: Number(m[2]), samples, when, camera: choice ? choice.camera : { preset: view }, device: args.flags.has("cpu") ? "cpu" : "auto", backfilled: !args.flags.has("excavation") },
localTextureLoader(),
);
if (pkg.missingTextures.length > 0) process.stderr.write(`Hinweis: ${pkg.missingTextures.length} Bildkarten nicht lesbar (Material erscheint einfarbig)\n`);
+29
View File
@@ -29,6 +29,7 @@ import {
type RenderOptions,
} from "./blenderRender";
import { exportGlb } from "./exportMesh";
import { meshSceneGroups } from "./meshScene.testutil";
import { cameraToView } from "../viewport/cameraView";
const when = new Date(Date.UTC(2026, 5, 21, 10, 0, 0));
@@ -342,3 +343,31 @@ describe("Kamera wählen ([213])", () => {
expect(pkg.scene.sun.elevation).toBeLessThan(renderSun(mk, defaultRenderTime(mk)).elevation);
});
});
describe("Baugrube im Rendering ausblenden ([227])", () => {
const complex = buildComplexSampleProject();
const lowest = (groups: ReturnType<typeof meshSceneGroups>, kind: string): number => {
let m = Infinity;
for (const g of groups) if (g.kind === kind) for (const p of g.prims) for (let i = 1; i < p.positions.length; i += 3) m = Math.min(m, p.positions[i]);
return m;
};
it("hinterfüllt: das Gelände ist das gewachsene, ohne Sohle bei −3.35 m; sonst bleibt die Grube", () => {
expect(lowest(meshSceneGroups(complex), "terrain")).toBeCloseTo(-3.35, 2);
expect(lowest(meshSceneGroups(complex, true), "terrain")).toBeGreaterThan(-3.3);
});
it("Paket: Vorgabe an (scene.backfilled, kleineres/anderes GLB), mit backfilled: false bleibt die Grube", async () => {
const on = await buildRenderPackage(complex, opts());
const off = await buildRenderPackage(complex, opts({ backfilled: false }));
expect(on.scene.backfilled).toBe(true);
expect(off.scene.backfilled).toBe(false);
const size = (p: typeof on) => p.files.find((f) => f.path === "model.glb")!.bytes.length;
expect(size(on)).not.toBe(size(off));
});
it("das normale GLB (Export, Anzeige) behält die Baugrube", () => {
expect(exportGlb(complex).length).toBe(exportGlb(complex, { backfilled: false }).length);
expect(exportGlb(complex).length).not.toBe(exportGlb(complex, { backfilled: true }).length);
});
});
+9 -1
View File
@@ -82,6 +82,11 @@ export interface RenderOptions {
denoise?: boolean;
/** `cpu` erzwingt die CPU, sonst GPU wenn vorhanden. */
device?: "auto" | "cpu";
/**
* [227] Baugrube ausblenden: Gelände ohne Aushub, hinterfüllt bis an die Fassade (Standard: an — für Bilder). Nur das Paket;
* die 3D-Ansicht im Modell bleibt unberührt (Klasse „07 Baugrube").
*/
backfilled?: boolean;
}
/** Eintrag der Materialtabelle in `scene.json`. */
@@ -124,6 +129,8 @@ export interface RenderScene {
samples: number;
denoise: boolean;
device: "auto" | "cpu";
/** [227] Gelände im Paket ohne Baugruben (hinterfüllt); nur Hinweis, der Leser setzt nichts um. */
backfilled: boolean;
camera: RenderCameraSpec;
sun: { azimuth: number; elevation: number; when: string; lat: number; lon: number };
materials: RenderMaterial[];
@@ -334,7 +341,7 @@ function componentMaterials(project: Project): Map<string, ComponentMaterial> {
* Kamera, Sonne. Verlangt das geladene Format-Modul (`await loadFileio()`) und den Kern.
*/
export async function buildRenderPackage(project: Project, opts: RenderOptions, loadTexture?: TextureLoader): Promise<RenderPackage> {
const glb = splitRoofMaterials(exportGlb(project), project);
const glb = splitRoofMaterials(exportGlb(project, { backfilled: opts.backfilled ?? true }), project);
const files: RenderPackage["files"] = [{ path: "model.glb", bytes: glb }];
const materials = glbMaterials(glb);
const comp = componentMaterials(project);
@@ -377,6 +384,7 @@ export async function buildRenderPackage(project: Project, opts: RenderOptions,
samples: Math.max(1, Math.round(opts.samples)),
denoise: opts.denoise ?? true,
device: opts.device ?? "auto",
backfilled: opts.backfilled ?? true,
camera: opts.camera,
sun: renderSun(project, opts.when),
materials,
+3 -1
View File
@@ -19,11 +19,13 @@ export interface MeshOptions {
openingParts?: boolean;
/** Gelände und importierte Kontext-Meshes (IFC/DXF) mitnehmen (Standard: ja). */
context?: boolean;
/** [227] Baugruben weglassen: Gelände ohne Aushub (hinterfüllt, bis an die Fassade geschlossen). Standard: nein. */
backfilled?: boolean;
}
/** Ruft eine Rust-Bindung; leeres Ergebnis (kaputter Puffer) wird zum Fehler mit dem Grund. */
function write<T extends string | Uint8Array>(project: Project, opts: MeshOptions, byLevel: boolean, run: (m: ReturnType<typeof fileio>, buf: Float64Array, strings: string) => T): T {
const args = [(opts.openingParts ?? true) ? 1 : 0, (opts.context ?? true) ? 1 : 0, byLevel ? 1 : 0];
const args = [(opts.openingParts ?? true) ? 1 : 0, (opts.context ?? true) ? 1 : 0, byLevel ? 1 : 0, opts.backfilled ? 1 : 0];
const [buf, strings] = decodeExportFlat(documentFor(project).queryBin("meshExportData", args));
const m = fileio();
const out = run(m, buf, strings);
+2 -2
View File
@@ -13,8 +13,8 @@ export interface SceneGroup {
}
/** Knoten der Mesh-Szene (Welt x, Höhe, y; Wicklung nach aussen im Modell). */
export function meshSceneGroups(project: Project): SceneGroup[] {
const [b, text] = decodeExportFlat(documentFor(project).queryBin("meshExportData", [1, 1, 0]));
export function meshSceneGroups(project: Project, backfilled = false): SceneGroup[] {
const [b, text] = decodeExportFlat(documentFor(project).queryBin("meshExportData", [1, 1, 0, backfilled ? 1 : 0]));
const s = text.split("\0");
let i = 2;
i += 1 + b[i] * 7;
+6
View File
@@ -2541,6 +2541,10 @@ export const de = {
"site.meshPoint": "Netzpunkt Nr.",
"site.meshPoint.hint": "Nummer des Netzpunkts (1 bis {n}); seine Lage ziehst du im Grundriss am Griff",
"site.meshPoint.z": "Höhe des Punkts (m)",
"site.ground": "Aufs Gelände setzen",
"site.ground.hint": "Setzt jedes Gebäude dieses Netzes auf den tiefsten Geländepunkt unter seinem Grundriss",
"site.ground.noTerrain": "Kein Gelände im Projekt",
"site.ground.nothing": "Nichts zu versetzen: die Gebäude stehen schon auf dem Gelände oder liegen ausserhalb davon",
"site.meshCrop": "Auf Grundstück zuschneiden",
"site.meshCrop.hint": "Entfernt alle Dreiecke, deren Schwerpunkt ausserhalb der Parzelle liegt",
"site.meshCrop.noParcel": "Zuerst die Parzelle im Baurecht erfassen",
@@ -3944,6 +3948,8 @@ export const de = {
"render.quality.normal": "Normal (128 Samples)",
"render.quality.high": "Hoch (512 Samples)",
"render.quality.final": "Final (1536 Samples)",
"render.backfilled": "Baugrube ausblenden (hinterfüllt)",
"render.backfilled.hint": "Das Gelände im Bild ist ohne Aushub gerechnet und reicht bis an die Fassade. Das 3D im Modell bleibt unverändert (Klasse «07 Baugrube»).",
"render.time": "Datum und Uhrzeit der Sonne",
"render.sun": "Sonne: Azimut {az}°, Höhe {el}°",
"render.sun.night": "Die Sonne steht dann unter dem Horizont; gerendert wird bei Dämmerung (Sonnenhöhe 1°).",
+6
View File
@@ -2529,6 +2529,10 @@ export const en: Record<TranslationKey, string> = {
"site.meshPoint": "Mesh point no.",
"site.meshPoint.hint": "Number of the mesh point (1 to {n}); drag its position in the plan by its grip",
"site.meshPoint.z": "Point height (m)",
"site.ground": "Place on terrain",
"site.ground.hint": "Places every building of this mesh on the lowest terrain point under its footprint",
"site.ground.noTerrain": "No terrain in the project",
"site.ground.nothing": "Nothing to move: the buildings already stand on the terrain or lie outside it",
"site.meshCrop": "Crop to parcel",
"site.meshCrop.hint": "Removes all triangles whose centroid lies outside the parcel",
"site.meshCrop.noParcel": "Enter the parcel under building regulations first",
@@ -3930,6 +3934,8 @@ export const en: Record<TranslationKey, string> = {
"render.quality.normal": "Normal (128 samples)",
"render.quality.high": "High (512 samples)",
"render.quality.final": "Final (1536 samples)",
"render.backfilled": "Hide excavation (backfilled)",
"render.backfilled.hint": "The terrain in the image is computed without the excavation and reaches the facade. The 3D view in the model is unchanged (class \"07 Baugrube\").",
"render.time": "Date and time of the sun",
"render.sun": "Sun: azimuth {az}°, elevation {el}°",
"render.sun.night": "The sun is below the horizon then; the image is rendered at twilight (sun elevation 1°).",
+9 -1
View File
@@ -41,6 +41,14 @@ export interface GeoFeature {
/** Default-Gebäudehöhe (m), wenn keine Höhe aus der Quelle vorliegt. */
export const DEFAULT_BUILDING_HEIGHT = 9;
/** Id-Präfix des extrudierten Gebäudenetzes eines Geo-Imports ([227]: wird beim Hinzufügen aufs Gelände gesetzt). */
const GEO_BUILDING_MESH_PREFIX = "geo-building3d";
/** Ist `o` das Gebäudenetz eines Geo-Imports (Kataster, swisstopo, OSM; {@link buildingsToMesh})? */
export function isGeoBuildingMesh(o: ContextObject): boolean {
return o.type === "importedMesh" && o.id.startsWith(GEO_BUILDING_MESH_PREFIX);
}
/** Erzeugt eine (kollisionsarme) ID für ein neues Kontext-Objekt. */
function contextId(prefix: string): string {
return `${prefix}-${Date.now().toString(36)}-${Math.random()
@@ -118,7 +126,7 @@ export function buildingsToMesh(
const indices = Array.from(r.subarray(1 + nPos));
if (positions.length < 9 || indices.length < 3) return null;
return {
id: contextId("geo-building3d"),
id: contextId(GEO_BUILDING_MESH_PREFIX),
type: "importedMesh",
name: `Gebäude 3D (${sourceLabel})`,
categoryCode: GEO_CATEGORY_DEFS.building.code,
+9
View File
@@ -20,6 +20,15 @@ const p = buildComplexSampleProject();
const codes = collectVisibleCodes(p.layers);
describe("Musterhaus komplex", () => {
it("[227] Nachbargebäude stehen auf dem Gelände, nicht auf z = 0", () => {
const n = p.context?.find((c) => c.id === "nachbarn");
if (n?.type !== "importedMesh") throw new Error("Nachbarn fehlen");
const zs = n.positions.filter((_, i) => i % 3 === 2);
// Die Höhenlinien reichen bis unter die West- und Ostnachbarn; deren Fuss liegt auf dem Hang (−2.5 … −0.9 m).
expect(Math.min(...zs)).toBeLessThan(-1);
expect(Math.min(...zs)).toBeGreaterThan(-3.3);
});
it("ist gültig und deterministisch; Datei-Rundreise", () => {
expect(validateProject(p)).toEqual([]);
const warnings = projectWarnings(p);
+3 -1
View File
@@ -519,7 +519,7 @@ const terrainZ = (x: number, y: number) => -1.8 + 1.5 * Math.tanh((y - 4 - 0.8 *
/** Höhenlinie z als Polylinie y(x) über x = −16 … 32. */
function contourAt(z: number): Vec2[] {
const pts: Vec2[] = [];
for (let x = -16; x <= 32; x += 2) pts.push(P(x, r3(4 + 0.8 * Math.sin(x / 9) + 8 * Math.atanh((z + 1.8) / 1.5))));
for (let x = -44; x <= 54; x += 2) pts.push(P(x, r3(4 + 0.8 * Math.sin(x / 9) + 8 * Math.atanh((z + 1.8) / 1.5))));
return pts;
}
const CONTOUR_Z = [-3.25, -3.2, -2.95, -2.7, -2.45, -2.2, -1.95, -1.7, -1.45, -1.2, -0.95, -0.7, -0.45, -0.35];
@@ -912,6 +912,8 @@ export function buildComplexSampleProject(): Project {
// Gelände aus den Höhenlinien (Kern: geglättetes TIN mit Bruchkanten).
p = runCmd(p, "ug", "terrain", {}).project;
// [227] Nachbargebäude stehen auf dem Gelände (tiefster Punkt unter dem Grundriss), nicht auf z = 0.
p = runCmd(p, "ug", "contextToTerrain", { ids: ["nachbarn"] }).project;
// Freie Körper im Garten: Loft (Pflanzgefäss, quadratisch → gedreht) und Rotationskörper (Sitzrolle).
const profiles: Drawing2D[] = [
+17
View File
@@ -136,6 +136,9 @@ function MeshPointFields({ obj }: { obj: Extract<ContextObject, { positions: num
function HeightFields({ obj }: { obj: ContextObject }) {
const offsetContextHeight = useStore((s) => s.offsetContextHeight);
const setContourHeight = useStore((s) => s.setContourHeight);
const groundContextObjects = useStore((s) => s.groundContextObjects);
const hasTerrain = useStore((s) => s.project.context?.some((c) => c.type === "terrainMesh") ?? false);
const notify = useStore((s) => s.notify);
const [dz, setDz] = useState("");
if (obj.type === "image") return null;
const apply = () => {
@@ -157,6 +160,20 @@ function HeightFields({ obj }: { obj: ContextObject }) {
onBlur={apply}
/>
</label>
{obj.type === "importedMesh" && (
// [227] Kontextgebäude auf den tiefsten Geländepunkt unter dem Grundriss setzen.
<button
type="button"
data-testid="context-ground"
disabled={!hasTerrain}
title={hasTerrain ? t("site.ground.hint") : t("site.ground.noTerrain")}
onClick={() => {
if (!groundContextObjects([obj.id])) notify(t("site.ground.nothing"), "info");
}}
>
{t("site.ground")}
</button>
)}
{(obj.type === "terrainMesh" || obj.type === "importedMesh") && <MeshPointFields obj={obj} />}
{obj.type === "contourSet" && (
<div className="site-prop" data-testid="contour-heights" style={{ display: "block", maxHeight: 180, overflowY: "auto" }}>
@@ -1,12 +1,12 @@
viewBox -25.5 0 81 18.478
bytes 209902
viewBox -31.5 0 93 18.478
bytes 217404
circle 4
g 1
line 503
line 505
path 3
polygon 1031
polyline 184
polygon 1046
polyline 186
rect 1
svg 1
text 4
hash d3224b3989291365
hash 66efb99a2b49d507
@@ -1,5 +1,5 @@
viewBox -41.5 0 95 63.6
bytes 68382
bytes 68330
circle 16
g 1
line 141
@@ -10,4 +10,4 @@ rect 1
svg 1
text 116
tspan 25
hash daf3fc044edd6954
hash 4ff6f95d0f8fb3dd
@@ -1,5 +1,5 @@
viewBox -41.5 0 95 63.6
bytes 108906
bytes 108854
circle 16
g 1
line 365
@@ -10,4 +10,4 @@ rect 1
svg 1
text 116
tspan 25
hash c0d58c87e618c222
hash 816aec413091c777
+3 -3
View File
@@ -5,8 +5,8 @@ meshes[].indices [1152]
meshes[].indices [1248] x3
meshes[].indices [12960]
meshes[].indices [144] x55
meshes[].indices [154014]
meshes[].indices [1584]
meshes[].indices [168450]
meshes[].indices [1716]
meshes[].indices [180]
meshes[].indices [204]
@@ -41,9 +41,9 @@ meshes[].positions [4746]
meshes[].positions [576]
meshes[].positions [7050]
meshes[].positions [72] x2
meshes[].positions [77523]
meshes[].positions [78] x55
meshes[].positions [798]
meshes[].positions [84735]
meshes[].positions [864]
roofLayers [59]
roofLayers[].color [3] x59
@@ -75,4 +75,4 @@ walls[].start [2] x1273
walls[].startCut [4] x873
walls[].topDrop [2] x115
walls[].topPlane [3] x271
hash 32750c509c57a271
hash 6747cdef6a78d1e0
+1
View File
@@ -56,6 +56,7 @@ const store = createStore<RootState>((api) => ({
project: ProjectSlice["project"];
activeLevelId: string;
applyChange: ProjectSlice["applyChange"];
groupChanges: HistorySlice["groupChanges"];
}
>,
),
+41
View File
@@ -175,3 +175,44 @@ describe("Zufallsfolgen der umgestellten Aktionen", () => {
}
});
});
// [227] Gebäude eines Geo-Imports (Kataster/swisstopo/OSM) stehen nach dem Hinzufügen auf dem Gelände — ein Undo-Schritt.
describe("Geo-Import setzt Gebäude aufs Gelände", () => {
const terrain = {
type: "terrainMesh" as const,
id: "gel",
categoryCode: "02",
name: "Gelände",
positions: [-50, -50, -5, 50, -50, 5, 50, 50, 5, -50, 50, -5],
indices: [0, 1, 2, 0, 2, 3],
};
const building = (id: string) => ({
type: "importedMesh" as const,
id,
categoryCode: "12",
name: "Gebäude",
positions: [10, 0, 0, 20, 0, 0, 20, 6, 0, 10, 6, 0, 10, 0, 8, 20, 0, 8, 20, 6, 8, 10, 6, 8],
indices: [0, 1, 2, 0, 2, 3, 4, 6, 5, 4, 7, 6, 0, 1, 5, 0, 5, 4, 1, 2, 6, 1, 6, 5],
});
const minZ = (id: string) => {
const m = st().project.context?.find((c) => c.id === id);
if (m?.type !== "importedMesh") throw new Error("kein Netz");
return Math.min(...m.positions.filter((_, i) => i % 3 === 2));
};
it("geo-building3d wird versetzt, ein anderer importierter Körper nicht; Undo stellt alles zurück", () => {
st().addContextObjects([terrain]);
st().clearHistory();
st().addContextObjects([building("geo-building3d-x"), building("ifc-koerper")]);
expect(minZ("geo-building3d-x")).toBeCloseTo(1, 9);
expect(minZ("ifc-koerper")).toBe(0);
expect(st().undoDepth).toBe(1);
// Knopf "Aufs Gelände setzen" für das andere Netz.
expect(st().groundContextObjects(["ifc-koerper"])).toBe(true);
expect(minZ("ifc-koerper")).toBeCloseTo(1, 9);
expect(st().groundContextObjects(["ifc-koerper"])).toBe(false);
st().undo();
st().undo();
expect(st().project.context?.some((c) => c.id.startsWith("geo-building3d"))).toBe(false);
});
});
+24 -6
View File
@@ -10,7 +10,7 @@
import { generateTerrainFromContours, resmoothGridTerrain, type TerrainOptions } from "../model/terrain";
import type { ContextObject, Drawing2D, Project, Vec2 } from "../model/types";
import type { ImportedLine } from "../io/geoContext";
import { isGeoBuildingMesh, type ImportedLine } from "../io/geoContext";
import { documentFor } from "../core/document";
import { transformOps } from "../tools/transform";
import { addItems, fieldOps, patchItem, removeItems } from "../core/opsBuild";
@@ -28,6 +28,11 @@ export interface SiteSlice {
* Umrisse des Standort-Imports) als einzelne 2D-Zeichnungen auf der aktiven Ebene; ein Undo-Schritt.
*/
addContextObjects: (objs: ContextObject[], lines?: ImportedLine[]) => void;
/**
* [227] Setzt Kontextgebäude (importierte Netze) aufs Gelände: jedes Gebäude des Netzes auf den tiefsten Geländepunkt
* unter seinem Grundriss (Kern `context_ground.rs`). true = mindestens ein Netz wurde versetzt.
*/
groundContextObjects: (ids: string[]) => boolean;
/** Entfernt ein Kontext-Objekt per ID (No-op bei unbekannter ID). */
removeContextObject: (id: string) => void;
/** Entfernt mehrere Kontext-Objekte in EINEM Schritt (z. B. eine ganze
@@ -83,6 +88,7 @@ type SiteSliceDeps = {
project: Project;
activeLevelId: string;
applyChange: (ops: readonly CoreOp[] | ((p: Project) => readonly CoreOp[]), coalesceKey?: string) => void;
groupChanges: (fn: () => void, key?: string) => void;
};
export function createSiteSlice(
@@ -103,11 +109,16 @@ export function createSiteSlice(
const codes = [...added, ...drawings]
.map((o) => o.categoryCode)
.filter((c): c is string => !!c);
get().applyChange((p) => [
...addItems("context", added),
...addItems("drawings2d", drawings),
...fieldOps(p, "layers", ensureContextCategories(p.layers, codes)),
]);
// [227] Importierte Gebäude (Kataster/swisstopo/OSM) stehen auf dem Gelände, nicht auf z = 0 — im selben Undo-Schritt.
const buildings = added.filter(isGeoBuildingMesh).map((o) => o.id);
get().groupChanges(() => {
get().applyChange((p) => [
...addItems("context", added),
...addItems("drawings2d", drawings),
...fieldOps(p, "layers", ensureContextCategories(p.layers, codes)),
]);
if (buildings.length) get().groundContextObjects(buildings);
});
};
return {
@@ -115,6 +126,13 @@ export function createSiteSlice(
addContextObjects: (objs, lines) => addToContext(objs, lines),
groundContextObjects: (ids) => {
const ops = documentFor(get().project).cmdOps({ cmd: "contextToTerrain", ids });
if (ops.length === 0) return false;
get().applyChange(ops);
return true;
},
removeContextObject: (id) => get().applyChange((p) => removeItems(p, "context", [id])),
removeContextObjects: (ids) => {
+9 -1
View File
@@ -56,6 +56,8 @@ export const RenderDialogHost = memo(function RenderDialogHost() {
// [213] "live" = aktuelle 3D-Ansicht, sonst die Id einer gespeicherten Kamera.
const [cameraKey, setCameraKey] = useState("live");
const [cameras, setCameras] = useState<RenderCameraChoice[]>([]);
// [227] Baugrube im Bild ausblenden (Gelände hinterfüllt); das 3D im Modell bleibt wie es ist.
const [backfilled, setBackfilled] = useState(true);
const [blenderPath, setPath] = useState("");
// Letzte Ausgabezeile von Blender (zeigt z. B. das erstmalige Übersetzen der Metal-Kernel, das Minuten dauern kann).
const [lastLine, setLastLine] = useState("");
@@ -142,7 +144,7 @@ export const RenderDialogHost = memo(function RenderDialogHost() {
// Sonnenzeit der Kamera übernehmen (änderbar).
if (choice.sunWhen) setWhen(toInputValue(choice.sunWhen));
};
const request = () => ({ width: dims.width, height: dims.height, samples, when: date!, camera });
const request = () => ({ width: dims.width, height: dims.height, samples, when: date!, camera, backfilled });
const start = async () => {
if (!canStart) return;
@@ -303,6 +305,12 @@ export const RenderDialogHost = memo(function RenderDialogHost() {
</div>
)}
</section>
<section className="imp-section">
<label>
<input type="checkbox" data-testid="render-backfilled" checked={backfilled} disabled={busy} onChange={(e) => setBackfilled(e.target.checked)} /> {t("render.backfilled")}
</label>
<div className="imp-note">{t("render.backfilled.hint")}</div>
</section>
{!browserOnly && (
<section className="imp-section">
<div className="imp-section-title">{t("render.blenderPath")}</div>