[65] Merge: Explosion – 3D-Griffe, Abzugskörper, Boden-Spuren, natives Fenster folgen dem Versatz
This commit is contained in:
16 files changed
+237
-43
No files matched your search
@@ -1930,8 +1930,13 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
|
||||
`levelId`; Kontext bleibt. Modell (`model3dParts` `args[4]`), Pick-Geometrie und Auswahl-Hervorhebung gleich versetzt;
|
||||
Plan/Schnitt/Ansicht unberührt. Bedienung: Knopf unten rechts im 3D-Viewport (neben Raster) + Abstandsfeld
|
||||
(Ansichtszustand, nicht im Projekt). CLI `model3d --explode 3`; macOS-Rauchtest `smoke/explode.png`.
|
||||
Offen: nur im Linux-Container geprüft (Zahlen, kein Bild); mit Explosion keine Abzugskörper, 2D-Boden-Spuren
|
||||
und 3D-Griffe/Zeichnen-Vorschau bleiben unversetzt; natives Metal-3D-Fenster (`nativeSync`) ohne Explosion.
|
||||
5.11.: Abzugskörper wirken am ursprünglichen Ort und wandern mit dem Bauteil (`explode3d::void_cuts`,
|
||||
`solid_specs::void_cuts_lifted`); 2D-Boden-Spuren und ihre Pick-Strecken heben sich mit `levelId`; 3D-Griffe
|
||||
sitzen auf den gehobenen Bauteilen (`explodeGripDz`, Abfrage `explodeOffsets`), Höhen-/First-Drag schreiben
|
||||
unversetzte Höhen; Arbeitsebene/Raster/Zeichnen-Vorschau auf dem gehobenen aktiven Geschoss; natives
|
||||
3D-Fenster bekommt dasselbe Modell (`pushNativeWalls(project, explode)`, Rust unverändert).
|
||||
Offen: nur im Linux-Container geprüft (Zahlen, kein Bild, kein Metal/Tauri); Ansichtsschraffur auf Flächen
|
||||
(`emitSurfacePatternLines`) bleibt unversetzt.
|
||||
- ◐ **[66] Präsentationspläne mit einem Klick.** · M — 4.11.: Standard-Ansichtsvorlagen (neue Projekte, „Standards
|
||||
laden/aktualisieren"): „Präsentation" (farbig, Schatten, ohne Referenzen/Konstruktion), „Eingabeplan 1:100" und
|
||||
„Ausführungsplan 1:50" (schwarz-weiss, fein, Strichstärken nach Massstab) — an Geschoss/Schnitt/Ansicht binden ([34]).
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
//!
|
||||
//! Jedes Geschoss (nach `baseElevation` sortiert, Index ab dem tiefsten) wird um `Index × Abstand`
|
||||
//! angehoben; jedes Bauteil folgt seinem Geschoss (`floorId`), Öffnungen ihrem Wirt (Wand, Dach,
|
||||
//! Decke). Kontext (Gelände, Importe) und 2D-Boden-Spuren bleiben stehen. Nur das 3D-Modell, die
|
||||
//! Decke), 2D-Boden-Spuren ihrem Geschoss (`levelId`), Abzugskörper wirken am ursprünglichen Ort
|
||||
//! und wandern mit dem Bauteil. Kontext (Gelände, Importe) bleibt stehen. Nur das 3D-Modell, die
|
||||
//! Pick-Geometrie und die Hervorhebung verschieben sich — Plan, Schnitt und Ansicht nie.
|
||||
|
||||
use crate::model::{DrawingLevelKind, Project};
|
||||
@@ -166,10 +167,25 @@ pub fn floor_offsets(p: &Project, gap: f64) -> HashMap<String, f64> {
|
||||
Explode::new(p, gap).map(|ex| ex.by_floor.iter().map(|(k, v)| (k.to_string(), *v)).collect()).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Pick-Geometrie passend zu [`parts`]; 2D-Spuren und Kontext bleiben stehen wie im Modell.
|
||||
/// Abzugskörper ([`crate::solid_specs::void_cuts`]) für die Teile aus [`parts`] mit demselben Abstand.
|
||||
pub fn void_cuts(p: &Project, parts: &Parts, gap: f64) -> crate::solid_specs::VoidCuts {
|
||||
let ex = Explode::new(p, gap);
|
||||
let of = |id: &str| ex.as_ref().map_or(0.0, |e| e.of(id));
|
||||
let wall_dz = |i: usize| of(&parts.walls[i].wall_id);
|
||||
let slab_dz = |i: usize| of(&parts.slabs[i].ceiling_id);
|
||||
crate::solid_specs::void_cuts_lifted(p, &parts.walls, &parts.slabs, &wall_dz, &slab_dz)
|
||||
}
|
||||
|
||||
/// Boden-Spuren der 2D-Zeichnungen, je Geschoss angehoben (`gap` ≤ 0: wie `drawing_line_verts`).
|
||||
pub fn drawing_line_verts(p: &Project, gap: f64) -> Vec<f32> {
|
||||
model3d::drawing_line_verts_lifted(p, &floor_offsets(p, gap))
|
||||
}
|
||||
|
||||
/// Pick-Geometrie passend zu [`parts`]; Kontext bleibt stehen wie im Modell.
|
||||
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));
|
||||
for w in &mut g.walls {
|
||||
shift_wall(w, ex.of(&w.wall_id));
|
||||
}
|
||||
@@ -220,11 +236,53 @@ mod tests {
|
||||
],
|
||||
"context": [
|
||||
{"type": "importedMesh", "id": "m", "name": "M", "positions": [0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0], "indices": [0.0, 1.0, 2.0]}
|
||||
],
|
||||
"drawings2d": [
|
||||
{"id": "d2", "type": "drawing2d", "levelId": "OG", "categoryCode": "", "geom": {"shape": "line", "a": {"x": 0, "y": 1}, "b": {"x": 4, "y": 1}}}
|
||||
],
|
||||
"extrudedSolids": [
|
||||
{"id": "v1", "type": "extrudedSolid", "levelId": "EG", "operation": "subtract", "points": [{"x": 1, "y": -1}, {"x": 2, "y": -1}, {"x": 2, "y": 1}, {"x": 1, "y": 1}], "height": 10.0}
|
||||
]
|
||||
}))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn abzugskoerper_wandern_mit_dem_geschoss() {
|
||||
let p = project();
|
||||
let parts = parts(&p, true, 2.0, false, 3.0).unwrap();
|
||||
let cuts = void_cuts(&p, &parts, 3.0);
|
||||
// Körper (EG, 0–10 m) trifft beide Wände; die OG-Wand liegt 3 m höher, ihr Körper ebenso.
|
||||
let z0 = |i: usize| -> f64 {
|
||||
let (_, spec) = cuts.walls.iter().find(|(j, _)| *j == i).expect("Wand getroffen");
|
||||
spec["b"]["z0"].as_f64().unwrap()
|
||||
};
|
||||
let idx = |id: &str| parts.walls.iter().position(|w| w.wall_id == id).unwrap();
|
||||
assert!((z0(idx("w1")) - 0.0).abs() < 1e-9);
|
||||
assert!((z0(idx("w2")) - 3.0).abs() < 1e-9);
|
||||
let base = model3d::parts(&p, true, 2.0, false).unwrap();
|
||||
let plain = crate::solid_specs::void_cuts(&p, &base.walls, &base.slabs);
|
||||
assert_eq!(plain.walls.len(), cuts.walls.len());
|
||||
assert_eq!(serde_json::to_string(&void_cuts(&p, &base, 0.0)).unwrap(), serde_json::to_string(&plain).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn boden_spuren_folgen_dem_geschoss() {
|
||||
let p = project();
|
||||
let a = drawing_line_verts(&p, 0.0);
|
||||
let b = drawing_line_verts(&p, 2.0);
|
||||
assert_eq!(a, model3d::drawing_line_verts(&p));
|
||||
assert_eq!(a.len(), b.len());
|
||||
assert!(!a.is_empty());
|
||||
// Welt (x, Höhe, y): Höhe = Index 1.
|
||||
for (x, y) in a.chunks_exact(6).zip(b.chunks_exact(6)) {
|
||||
assert!((y[1] - x[1] - 2.0).abs() < 1e-5);
|
||||
}
|
||||
let pa = model3d::pick_geometry(&p).unwrap();
|
||||
let pb = pick_geometry(&p, 2.0).unwrap();
|
||||
assert!((pb.drawings[0].base_elevation - pa.drawings[0].base_elevation - 2.0).abs() < 1e-9);
|
||||
}
|
||||
|
||||
fn min_z(meshes: &[RMesh]) -> f64 {
|
||||
meshes.iter().flat_map(|m| m.positions.chunks_exact(3).map(|c| c[2])).fold(f64::INFINITY, f64::min)
|
||||
}
|
||||
|
||||
@@ -2066,7 +2066,8 @@ fn drawing_color(
|
||||
}
|
||||
|
||||
/// Packt die darstellbaren Zeichnungen (Linie, Polylinie, Rechteck) in Chargen für `drawing2d_3d`.
|
||||
fn for_each_drawing_chunk(p: &Project, with_color: bool, mut f: impl FnMut(&[f64], &[&Drawing2D])) {
|
||||
/// `lift`: zusätzliche Höhe je Geschoss-id (Explosionsaxonometrie [65], `explode3d.rs`; leer = keine).
|
||||
fn for_each_drawing_chunk(p: &Project, with_color: bool, lift: &HashMap<String, f64>, mut f: impl FnMut(&[f64], &[&Drawing2D])) {
|
||||
if p.drawings2d.is_empty() {
|
||||
return;
|
||||
}
|
||||
@@ -2095,7 +2096,7 @@ fn for_each_drawing_chunk(p: &Project, with_color: bool, mut f: impl FnMut(&[f64
|
||||
_ => continue,
|
||||
};
|
||||
let closed = matches!(&d.geom, Drawing2DGeom::Polyline { closed: true, .. });
|
||||
let elev = *elevations.entry(d.level_id.as_str()).or_insert_with(|| p.floor(&d.level_id).map_or(0.0, |l| l.base_elevation.unwrap_or(0.0)) + DRAWING_LINE_ELEVATION_EPS);
|
||||
let elev = *elevations.entry(d.level_id.as_str()).or_insert_with(|| 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 rgb = if with_color { drawing_color(d, &by_category, &by_line_style) } else { [0.0; 3] };
|
||||
for (kind, pts) in parts {
|
||||
let need = 7 + 2 * pts.len();
|
||||
@@ -2114,8 +2115,13 @@ fn for_each_drawing_chunk(p: &Project, with_color: bool, mut f: impl FnMut(&[f64
|
||||
|
||||
/// Boden-Spuren aller Zeichnungen als LineList-Vertices `[px, py, pz, r, g, b]` (`emitDrawingLineVerts`).
|
||||
pub fn drawing_line_verts(p: &Project) -> Vec<f32> {
|
||||
drawing_line_verts_lifted(p, &HashMap::new())
|
||||
}
|
||||
|
||||
/// Wie [`drawing_line_verts`], jede Spur um `lift[level_id]` angehoben (Explosion [65]).
|
||||
pub fn drawing_line_verts_lifted(p: &Project, lift: &HashMap<String, f64>) -> Vec<f32> {
|
||||
let mut out = Vec::new();
|
||||
for_each_drawing_chunk(p, true, |buf, _| out.extend(crate::drawing2d_3d::line_verts(buf)));
|
||||
for_each_drawing_chunk(p, true, lift, |buf, _| out.extend(crate::drawing2d_3d::line_verts(buf)));
|
||||
out
|
||||
}
|
||||
|
||||
@@ -2129,9 +2135,9 @@ pub struct PickDrawingSeg {
|
||||
pub drawing_id: String,
|
||||
}
|
||||
|
||||
fn pick_drawing_segs(p: &Project) -> Vec<PickDrawingSeg> {
|
||||
pub(crate) fn pick_drawing_segs(p: &Project, lift: &HashMap<String, f64>) -> Vec<PickDrawingSeg> {
|
||||
let mut out = Vec::new();
|
||||
for_each_drawing_chunk(p, false, |buf, drawings| {
|
||||
for_each_drawing_chunk(p, false, lift, |buf, drawings| {
|
||||
let f = crate::drawing2d_3d::pick_segs(buf, DRAWING_PICK_TOLERANCE);
|
||||
for c in f.chunks_exact(6) {
|
||||
out.push(PickDrawingSeg { start: [c[0], c[1]], end: [c[2], c[3]], base_elevation: c[4], drawing_id: drawings[c[5] as usize].id.clone() });
|
||||
@@ -2291,7 +2297,7 @@ pub fn pick_geometry(p: &Project) -> Result<PickGeometry, String> {
|
||||
stairs,
|
||||
roofs,
|
||||
context_meshes,
|
||||
drawings: pick_drawing_segs(p),
|
||||
drawings: pick_drawing_segs(p, &HashMap::new()),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -48,17 +48,22 @@ pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String,
|
||||
("openingPreview", _) => json(&crate::opening_preview::opening_preview(p, text)),
|
||||
("scheduleCsv", 1) => Ok(export_schedule::export_schedule_csv(p, text, args[0] != 0.0)),
|
||||
// `args[0]`: Explosionsabstand ([65], fehlt/0 = aus).
|
||||
// Versatz je Geschoss-id ([65]; `args[0]` = Abstand, ≤ 0 = leer): 3D-Griffe und Arbeitsebene.
|
||||
("explodeOffsets", _) => json(&crate::explode3d::floor_offsets(p, args.first().copied().unwrap_or(0.0))),
|
||||
("pickGeometry", _) => json(&crate::explode3d::pick_geometry(p, args.first().copied().unwrap_or(0.0))?),
|
||||
("modelJson", _) => crate::model::to_value_typed_only(p).map(|v| v.to_string()).map_err(|e| e.to_string()),
|
||||
// Mit Abzugskörpern (`args[3]` ≠ 0) zusätzlich `voidCuts`: die getroffenen Wände/Decken als
|
||||
// truck-Spezifikationen (`solid_specs.rs`).
|
||||
// `args[4]`: Explosionsabstand ([65], `explode3d.rs`; > 0 zusätzlich `floorOffsets`, ohne Abzugskörper).
|
||||
// `args[4]`: Explosionsabstand ([65], `explode3d.rs`; > 0 zusätzlich `floorOffsets`, Abzugskörper wandern mit).
|
||||
("model3dParts", n) if n >= 3 => {
|
||||
let explode = args.get(4).copied().filter(|g| g.is_finite() && *g > 0.0);
|
||||
if let Some(gap) = explode {
|
||||
let parts = crate::explode3d::parts(p, args[0] != 0.0, args[1], args[2] != 0.0, gap)?;
|
||||
let mut v = serde_json::to_value(&parts).map_err(|e| e.to_string())?;
|
||||
v["floorOffsets"] = serde_json::to_value(crate::explode3d::floor_offsets(p, gap)).map_err(|e| e.to_string())?;
|
||||
if args.get(3).is_some_and(|v| *v != 0.0) {
|
||||
v["voidCuts"] = serde_json::to_value(crate::explode3d::void_cuts(p, &parts, gap)).map_err(|e| e.to_string())?;
|
||||
}
|
||||
return Ok(v.to_string());
|
||||
}
|
||||
let parts = model3d::parts(p, args[0] != 0.0, args[1], args[2] != 0.0)?;
|
||||
|
||||
@@ -144,11 +144,11 @@ fn hitting<'a>(voids: &'a [VoidPrism], foot: &[f64; 4], z0: f64, z1: f64) -> Vec
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Bauteil minus alle Körper (verkettete Differenzen).
|
||||
fn subtract(base: Value, voids: &[&VoidPrism]) -> Value {
|
||||
/// Bauteil minus alle Körper (verkettete Differenzen); Körper um `dz` angehoben (Explosion [65]).
|
||||
fn subtract(base: Value, voids: &[&VoidPrism], dz: f64) -> Value {
|
||||
voids.iter().fold(base, |acc, v| {
|
||||
let pts: Vec<f64> = v.pts.iter().flat_map(|p| [p.x, p.y]).collect();
|
||||
json!({"kind": "boolean", "op": "difference", "a": acc, "b": {"kind": "extrude", "points": pts, "height": v.z1 - v.z0, "z0": v.z0}})
|
||||
json!({"kind": "boolean", "op": "difference", "a": acc, "b": {"kind": "extrude", "points": pts, "height": v.z1 - v.z0, "z0": v.z0 + dz}})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -162,31 +162,40 @@ pub struct VoidCuts {
|
||||
|
||||
/// Abzugskörper auf Wände und Decken des Modells anwenden (früher `applyVoids3d`, Spezifikationsteil).
|
||||
pub fn void_cuts(p: &Project, walls: &[RWall], slabs: &[RSlab]) -> VoidCuts {
|
||||
void_cuts_lifted(p, walls, slabs, &|_| 0.0, &|_| 0.0)
|
||||
}
|
||||
|
||||
/// Wie [`void_cuts`] für ein auseinandergezogenes Modell ([65], `explode3d.rs`): Bauteil `i` liegt um
|
||||
/// `wall_dz(i)` bzw. `slab_dz(i)` höher als im Modell. Getroffen wird am ursprünglichen Ort, der Körper
|
||||
/// wandert mit dem Bauteil (ein geschossübergreifender Körper schneidet so jedes Geschoss für sich).
|
||||
pub fn void_cuts_lifted(p: &Project, walls: &[RWall], slabs: &[RSlab], wall_dz: &dyn Fn(usize) -> f64, slab_dz: &dyn Fn(usize) -> f64) -> VoidCuts {
|
||||
let voids = void_prisms(p);
|
||||
let mut out = VoidCuts::default();
|
||||
if voids.is_empty() {
|
||||
return out;
|
||||
}
|
||||
for (i, w) in walls.iter().enumerate() {
|
||||
let hits = hitting(&voids, &bbox(wall_corners(w).into_iter()), w.base_elevation, w.base_elevation + w.height);
|
||||
let dz = wall_dz(i);
|
||||
let hits = hitting(&voids, &bbox(wall_corners(w).into_iter()), w.base_elevation - dz, w.base_elevation + w.height - dz);
|
||||
if hits.is_empty() {
|
||||
continue;
|
||||
}
|
||||
if let Some(base) = wall_spec(&WallIn::of(w)) {
|
||||
out.walls.push((i, subtract(base, &hits)));
|
||||
out.walls.push((i, subtract(base, &hits, dz)));
|
||||
}
|
||||
}
|
||||
for (i, s) in slabs.iter().enumerate() {
|
||||
if s.outline.len() < 3 {
|
||||
continue;
|
||||
}
|
||||
let hits = hitting(&voids, &bbox(s.outline.iter().map(|q| (q[0], q[1]))), s.z_bottom, s.z_top);
|
||||
let dz = slab_dz(i);
|
||||
let hits = hitting(&voids, &bbox(s.outline.iter().map(|q| (q[0], q[1]))), s.z_bottom - dz, s.z_top - dz);
|
||||
if hits.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let pts: Vec<f64> = s.outline.iter().flat_map(|q| [q[0], q[1]]).collect();
|
||||
let base = json!({"kind": "extrude", "points": pts, "height": s.z_top - s.z_bottom, "z0": s.z_bottom});
|
||||
out.slabs.push((i, subtract(base, &hits)));
|
||||
out.slabs.push((i, subtract(base, &hits, dz)));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
@@ -262,10 +262,10 @@ pub fn doc_query_root(h: u32, name: &str, text: &str) -> String {
|
||||
}
|
||||
|
||||
/// Boden-Spuren aller 2D-Zeichnungen als LineList-Vertices `[px, py, pz, r, g, b]` (Float32);
|
||||
/// leer bei Fehler oder ohne Zeichnungen.
|
||||
/// leer bei Fehler oder ohne Zeichnungen. `explode`: Explosionsabstand ([65], ≤ 0/NaN = aus).
|
||||
#[wasm_bindgen]
|
||||
pub fn doc_drawing_line_verts(h: u32) -> Vec<f32> {
|
||||
with_doc(h, |d| d.project().ok().map(|p| crate::model3d::drawing_line_verts(&p))).flatten().unwrap_or_default()
|
||||
pub fn doc_drawing_line_verts(h: u32, explode: f64) -> Vec<f32> {
|
||||
with_doc(h, |d| d.project().ok().map(|p| crate::explode3d::drawing_line_verts(&p, explode))).flatten().unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Ansichtsschraffur auf den Flächen für render3d (`surface_pattern3d`, je Linie `ax ay az bx by bz r g b
|
||||
|
||||
@@ -91,6 +91,7 @@ export type QueryName =
|
||||
| "scheduleRows"
|
||||
| "scheduleCsv"
|
||||
| "pickGeometry"
|
||||
| "explodeOffsets"
|
||||
| "model3dParts"
|
||||
| "projectSolidSpecs"
|
||||
| "planDomains"
|
||||
@@ -219,8 +220,8 @@ export class ProjectDocument {
|
||||
}
|
||||
|
||||
/** Boden-Spuren der 2D-Zeichnungen als LineList-Vertices `[px, py, pz, r, g, b]`. */
|
||||
drawingLineVerts(): Float32Array {
|
||||
return this.handle ? core().doc_drawing_line_verts(this.handle) : new Float32Array(0);
|
||||
drawingLineVerts(explode = 0): Float32Array {
|
||||
return this.handle ? core().doc_drawing_line_verts(this.handle, explode) : new Float32Array(0);
|
||||
}
|
||||
|
||||
/** Ansichtsschraffur auf den Flächen (Wände, Decken, Dächer) für render3d `set_pattern_lines`. */
|
||||
|
||||
@@ -246,6 +246,7 @@ export {
|
||||
draftWorldLines,
|
||||
emitDrawingLineVerts,
|
||||
emitSurfacePatternLines,
|
||||
explodeFloorOffsets,
|
||||
pickGeometry,
|
||||
projectToModel3d,
|
||||
selectionHighlightLines,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { projectToModel3d, pickGeometry, selectionHighlightLines } from "./toWalls3d";
|
||||
import { projectToModel3d, pickGeometry, selectionHighlightLines, explodeFloorOffsets, emitDrawingLineVerts } from "./toWalls3d";
|
||||
|
||||
const floors = sampleProject.drawingLevels
|
||||
.filter((l) => l.kind === "floor")
|
||||
@@ -41,4 +41,28 @@ describe("Explosionsaxonometrie", () => {
|
||||
expect(b.length).toBe(a.length);
|
||||
expect(b[1] - a[1]).toBeCloseTo(2 * wallIndex(w.id), 4);
|
||||
});
|
||||
|
||||
it("Versatz je Geschoss (3D-Griffe, Arbeitsebene)", () => {
|
||||
expect(explodeFloorOffsets(sampleProject, 0)).toEqual({});
|
||||
expect(explodeFloorOffsets(sampleProject, Number.NaN)).toEqual({});
|
||||
const off = explodeFloorOffsets(sampleProject, 2.5);
|
||||
floors.forEach((f, i) => expect(off[f.id]).toBeCloseTo(i * 2.5, 9));
|
||||
});
|
||||
|
||||
it("2D-Boden-Spuren heben sich mit ihrem Geschoss", () => {
|
||||
const top = floors[floors.length - 1];
|
||||
const p = {
|
||||
...sampleProject,
|
||||
drawings2d: [
|
||||
{ id: "dx", type: "drawing2d", levelId: top.id, categoryCode: "", geom: { shape: "line", a: { x: 0, y: 0 }, b: { x: 3, y: 0 } } },
|
||||
],
|
||||
} as unknown as typeof sampleProject;
|
||||
const a = emitDrawingLineVerts(p);
|
||||
const b = emitDrawingLineVerts(p, 2);
|
||||
expect(a.length).toBeGreaterThan(0);
|
||||
expect(b.length).toBe(a.length);
|
||||
const dz = (floors.length - 1) * 2;
|
||||
for (let i = 1; i < a.length; i += 6) expect(b[i] - a[i]).toBeCloseTo(dz, 4);
|
||||
expect(pickGeometry(p, 2).drawings[0].baseElevation - pickGeometry(p).drawings[0].baseElevation).toBeCloseTo(dz, 9);
|
||||
});
|
||||
});
|
||||
+18
-5
@@ -67,8 +67,21 @@ export type { RVec2, RRgb, RWall, RSlab, RModel3d };
|
||||
* Kataster-DXF kann Millionen Segmente liefern, als JSON-Mesh sprengte das Speicher und
|
||||
* String-Länge). Rechnet der Kern (`model3d.rs`, Chargen).
|
||||
*/
|
||||
export function emitDrawingLineVerts(project: Project): Float32Array {
|
||||
return documentFor(project).drawingLineVerts();
|
||||
export function emitDrawingLineVerts(
|
||||
project: Project,
|
||||
/** Explosionsabstand ([65]): Spuren heben sich mit ihrem Geschoss; 0 = aus. */
|
||||
explode = 0,
|
||||
): Float32Array {
|
||||
return documentFor(project).drawingLineVerts(explodeGap(explode));
|
||||
}
|
||||
|
||||
/**
|
||||
* Explosionsaxonometrie ([65]): Versatz (m) je Geschoss-id (Kern `explode3d.rs::floor_offsets`),
|
||||
* für 3D-Griffe und Arbeitsebene. Abstand ≤ 0 → leer (= nirgends Versatz).
|
||||
*/
|
||||
export function explodeFloorOffsets(project: Project, explode: number): Record<string, number> {
|
||||
const gap = explodeGap(explode);
|
||||
return gap === 0 ? {} : documentFor(project).query<Record<string, number>>("explodeOffsets", [gap]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,8 +152,8 @@ export interface Model3dOptions {
|
||||
voids?: boolean;
|
||||
/**
|
||||
* Explosionsaxonometrie ([65]): Abstand (m) zwischen den Geschossen; 0/fehlt = aus. Jedes
|
||||
* Geschoss hebt sich um Index × Abstand (Kern `explode3d.rs`); Kontext bleibt stehen.
|
||||
* Mit Explosion keine Abzugskörper (die truck-Ergebnisse lägen am alten Ort).
|
||||
* Geschoss hebt sich um Index × Abstand (Kern `explode3d.rs`); Kontext bleibt stehen,
|
||||
* Abzugskörper wandern mit dem getroffenen Bauteil.
|
||||
*/
|
||||
explode?: number;
|
||||
}
|
||||
@@ -151,7 +164,7 @@ export function projectToModel3d(project: Project, opts: Model3dOptions = {}): R
|
||||
const detail = opts.detail ?? "fein";
|
||||
// Mit `voids` liefert der Kern zusätzlich die getroffenen Wände/Decken als truck-Spezifikationen.
|
||||
const explode = explodeGap(opts.explode);
|
||||
const voids = !!opts.voids && typeof window !== "undefined" && explode === 0;
|
||||
const voids = !!opts.voids && typeof window !== "undefined";
|
||||
const parts = documentFor(project).query<Model3dParts>(
|
||||
"model3dParts",
|
||||
[layered ? 1 : 0, DETAIL_CODE[detail] ?? 3, opts.forSection ? 1 : 0, voids ? 1 : 0, explode],
|
||||
|
||||
@@ -42,10 +42,10 @@
|
||||
// Die Orbit-/Pan-Mathematik folgt den OrbitControls-Konventionen (Winkel je
|
||||
// Pixel an der Viewport-Höhe normiert), damit sich beide Pfade gleich anfühlen.
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import type { Project, Wall, Drawing2D, Ceiling, Roof, Vec2 } from "../model/types";
|
||||
import { roofBaseElevation, roofGeometry, verticalExtents } from "../core";
|
||||
import { projectToModel3d, pickGeometry, draftWorldLines, TRUCK_MESH_READY_EVENT } from "../core";
|
||||
import { projectToModel3d, pickGeometry, draftWorldLines, explodeFloorOffsets, TRUCK_MESH_READY_EVENT } from "../core";
|
||||
import type { DetailLevel, RenderMode, View3d } from "../model/viewTypes";
|
||||
import type { ToolDraft } from "../tools/types";
|
||||
import { hudSegments, type HudFieldsState } from "../tools/hudFormat";
|
||||
@@ -55,6 +55,7 @@ import {
|
||||
neighbor3dVertex,
|
||||
findCoincidentVertices,
|
||||
findMoveCoincidentVertices,
|
||||
explodeGripDz,
|
||||
type CoincidentVertex,
|
||||
type MoveCoincidentVertex,
|
||||
} from "./grip3dHud";
|
||||
@@ -182,6 +183,25 @@ function computeGrips(
|
||||
ceilings: readonly Ceiling[],
|
||||
roofs: readonly Roof[],
|
||||
drawingElevation: number,
|
||||
/** Explosionsaxonometrie ([65]): Versatz je Geschoss-id; Griffe sitzen auf den gehobenen Bauteilen. */
|
||||
floorOffsets: Readonly<Record<string, number>> = {},
|
||||
): Grip[] {
|
||||
const out = computeGripsAt(project, walls, drawings, ceilings, roofs, drawingElevation);
|
||||
for (const g of out) {
|
||||
const dz = explodeGripDz(project, floorOffsets, g.target);
|
||||
if (dz !== 0) g.pos = [g.pos[0], g.pos[1] + dz, g.pos[2]];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Griffe am unversetzten Modell (s. {@link computeGrips}). */
|
||||
function computeGripsAt(
|
||||
project: Project,
|
||||
walls: readonly Wall[],
|
||||
drawings: readonly Drawing2D[],
|
||||
ceilings: readonly Ceiling[],
|
||||
roofs: readonly Roof[],
|
||||
drawingElevation: number,
|
||||
): Grip[] {
|
||||
const out: Grip[] = [];
|
||||
const ext = verticalExtents(project, walls, ceilings);
|
||||
@@ -571,6 +591,12 @@ export function Wasm3DViewport({
|
||||
const explode = explodeOn ? explodeGap : 0;
|
||||
const explodeRef = useRef(explode);
|
||||
explodeRef.current = explode;
|
||||
// Versatz je Geschoss ([65]) für Griffe und gezogene Höhen (Modell bleibt unversetzt).
|
||||
const floorOffsets = useMemo(() => explodeFloorOffsets(project, explode), [project, explode]);
|
||||
const floorOffsetsRef = useRef(floorOffsets);
|
||||
floorOffsetsRef.current = floorOffsets;
|
||||
const gripDz = (target: { wallId?: string; ceilingId?: string; roofId?: string; drawingId?: string }) =>
|
||||
explodeGripDz(projectRef.current, floorOffsetsRef.current, target);
|
||||
const {
|
||||
render,
|
||||
updateModel,
|
||||
@@ -839,6 +865,7 @@ export function Wasm3DViewport({
|
||||
editCeilingsRef.current,
|
||||
editRoofsRef.current,
|
||||
groundElevationRef.current,
|
||||
floorOffsetsRef.current,
|
||||
);
|
||||
const next: { grip: Grip; x: number; y: number }[] = [];
|
||||
for (const g of grips) {
|
||||
@@ -993,15 +1020,15 @@ export function Wasm3DViewport({
|
||||
const gripPlaneY = (target: GripTarget): number | null => {
|
||||
if (target.wallId) {
|
||||
const wall = editWallsRef.current.find((w) => w.id === target.wallId);
|
||||
return wall ? verticalExtents(projectRef.current, [wall]).walls[0].zBottom : null;
|
||||
return wall ? verticalExtents(projectRef.current, [wall]).walls[0].zBottom + gripDz(target) : null;
|
||||
}
|
||||
if (target.ceilingId) {
|
||||
const c = editCeilingsRef.current.find((x) => x.id === target.ceilingId);
|
||||
return c ? verticalExtents(projectRef.current, [], [c]).ceilings[0].zTop : null;
|
||||
return c ? verticalExtents(projectRef.current, [], [c]).ceilings[0].zTop + gripDz(target) : null;
|
||||
}
|
||||
if (target.roofId) {
|
||||
const r = editRoofsRef.current.find((x) => x.id === target.roofId);
|
||||
return r ? roofBaseElevation(projectRef.current, r) : null;
|
||||
return r ? roofBaseElevation(projectRef.current, r) + gripDz(target) : null;
|
||||
}
|
||||
return groundElevationRef.current;
|
||||
};
|
||||
@@ -1110,7 +1137,8 @@ export function Wasm3DViewport({
|
||||
nz /= nlen;
|
||||
const hit = rayPlane(ray, [midX, 0, midY], [nx, 0, nz]);
|
||||
if (!hit) return;
|
||||
onEditWallTopRef.current?.(drag.wallId, hit[1]);
|
||||
// Explosion ([65]): Griff sitzt gehoben, das Modell bekommt die unversetzte Höhe.
|
||||
onEditWallTopRef.current?.(drag.wallId, hit[1] - gripDz({ wallId: drag.wallId }));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1126,7 +1154,7 @@ export function Wasm3DViewport({
|
||||
nz /= nlen;
|
||||
const hitR = rayPlane(ray, [drag.apexXZ[0], 0, drag.apexXZ[1]], [nx, 0, nz]);
|
||||
if (!hitR) return;
|
||||
onEditRoofPitchRef.current?.(drag.roofId, hitR[1]);
|
||||
onEditRoofPitchRef.current?.(drag.roofId, hitR[1] - gripDz({ roofId: drag.roofId }));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
grip3dEditFields,
|
||||
findCoincidentVertices,
|
||||
findMoveCoincidentVertices,
|
||||
explodeGripDz,
|
||||
type Grip3dEditState,
|
||||
} from "./grip3dHud";
|
||||
|
||||
@@ -311,3 +312,18 @@ describe("findMoveCoincidentVertices", () => {
|
||||
expect(findMoveCoincidentVertices(sampleProject, {})).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("explodeGripDz ([65])", () => {
|
||||
const w = sampleProject.walls[0];
|
||||
const offsets = { [w.floorId]: 2.5 };
|
||||
it("Versatz über das Geschoss des Ziels", () => {
|
||||
expect(explodeGripDz(sampleProject, offsets, { wallId: w.id })).toBe(2.5);
|
||||
const c = (sampleProject.ceilings ?? []).find((x) => x.floorId === w.floorId);
|
||||
if (c) expect(explodeGripDz(sampleProject, offsets, { ceilingId: c.id })).toBe(2.5);
|
||||
});
|
||||
it("ohne Explosion, unbekannt oder Zeichnung: 0", () => {
|
||||
expect(explodeGripDz(sampleProject, {}, { wallId: w.id })).toBe(0);
|
||||
expect(explodeGripDz(sampleProject, offsets, { wallId: "fehlt" })).toBe(0);
|
||||
expect(explodeGripDz(sampleProject, offsets, { drawingId: "d" })).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -324,3 +324,17 @@ export function findMoveCoincidentVertices(project: Project, self: Grip3dTarget)
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Explosionsaxonometrie ([65]): Höhenversatz (m), um den das Ziel eines 3D-Griffs im
|
||||
* auseinandergezogenen Modell liegt (`offsets` = Versatz je Geschoss-id, s. `explodeFloorOffsets`).
|
||||
* Griffe sitzen um diesen Betrag höher; gezogene Höhen ziehen ihn wieder ab (Modell bleibt
|
||||
* unversetzt). Zeichnungen: 0 — ihre Ebene ist die (bereits versetzte) Arbeitsebene.
|
||||
*/
|
||||
export function explodeGripDz(project: Project, offsets: Readonly<Record<string, number>>, target: Grip3dTarget): number {
|
||||
let floorId: string | undefined;
|
||||
if (target.wallId) floorId = project.walls.find((w) => w.id === target.wallId)?.floorId;
|
||||
else if (target.ceilingId) floorId = (project.ceilings ?? []).find((c) => c.id === target.ceilingId)?.floorId;
|
||||
else if (target.roofId) floorId = (project.roofs ?? []).find((r) => r.id === target.roofId)?.floorId;
|
||||
return (floorId && offsets[floorId]) || 0;
|
||||
}
|
||||
@@ -246,7 +246,7 @@ export function useWasm3dRenderer(
|
||||
// Fehler hier das bereits gesetzte Modell nicht mit wegreisst.
|
||||
if (typeof r.set_drawing_lines === "function") {
|
||||
try {
|
||||
r.set_drawing_lines(emitDrawingLineVerts(project));
|
||||
r.set_drawing_lines(emitDrawingLineVerts(project, explode));
|
||||
} catch (e) {
|
||||
console.warn("render3d set_drawing_lines fehlgeschlagen:", e);
|
||||
}
|
||||
|
||||
@@ -82,18 +82,25 @@ export function pushNativeScene(plan: Plan): void {
|
||||
* Öffnungs-Teilquadern plus Deckenplatten — ans native 3D-Fenster schieben.
|
||||
* No-op ohne Tauri.
|
||||
*/
|
||||
export function pushNativeWalls(project: Project): void {
|
||||
export function pushNativeWalls(
|
||||
project: Project,
|
||||
/** Explosionsabstand ([65], 0 = aus): dasselbe Modell wie im WASM-Viewport (`projectToModel3d`). */
|
||||
explode = lastExplode,
|
||||
): void {
|
||||
if (!isTauri()) return;
|
||||
lastProject = project;
|
||||
lastExplode = explode;
|
||||
clearTimeout(wallsTimer);
|
||||
wallsTimer = setTimeout(async () => {
|
||||
if (!(await isNativeEnabled())) return;
|
||||
void invokeNative("push_native_walls", { walls: projectToModel3d(project, { voids: true }) });
|
||||
void invokeNative("push_native_walls", { walls: projectToModel3d(project, { voids: true, explode }) });
|
||||
}, DEBOUNCE_MS);
|
||||
}
|
||||
|
||||
/** Letztes an {@link pushNativeWalls} übergebenes Projekt (für den Re-Push unten). */
|
||||
let lastProject: Project | null = null;
|
||||
/** Letzter Explosionsabstand (Re-Push nach truck-Ergebnis behält ihn). */
|
||||
let lastExplode = 0;
|
||||
|
||||
// truck-Extrusionen (s. toWalls3d.ts emitExtrudedSolids) laden WASM asynchron;
|
||||
// ohne diesen Re-Push nach Abschluss bliebe eine fertige Extrusion im nativen
|
||||
|
||||
@@ -36,7 +36,7 @@ import { levelMarkerPrimitives, levelMarksEnabled } from "../core";
|
||||
import { unitsForLevel } from "../tools/displayUnits";
|
||||
import { setSheetOwnerOutlines, setSheetSnapSegments, snapSegmentsFromPrimitives } from "../tools/sheetSnapGeometry";
|
||||
import { pushNativeScene, pushNativeWalls } from "./plan/nativeSync";
|
||||
import { selectionHighlightLines } from "../core";
|
||||
import { explodeFloorOffsets, selectionHighlightLines } from "../core";
|
||||
import { clashHighlightLines } from "../analysis/clash";
|
||||
import { useClashSession } from "../panels/clashSession";
|
||||
import { applyGroupDimmingToPlan } from "../state/groupActions";
|
||||
@@ -274,6 +274,11 @@ export const Content = memo(function Content({
|
||||
const clashes = useClashSession().clashes;
|
||||
// Explosionsaxonometrie ([65]): Hervorhebung folgt dem auseinandergezogenen 3D-Modell.
|
||||
const explode = useStore((s) => (s.explode3d ? s.explode3dGap : 0));
|
||||
// Arbeitsebene/Raster/Zeichnen-Vorschau auf dem gehobenen aktiven Geschoss.
|
||||
const explodeLift = useMemo(
|
||||
() => (explode > 0 ? (explodeFloorOffsets(project, explode)[level.id] ?? 0) : 0),
|
||||
[project, explode, level.id],
|
||||
);
|
||||
const { walls, ceilings, openings, stairs, roofs, contextObjects } = selection;
|
||||
const selectionLines = useMemo(
|
||||
() =>
|
||||
@@ -310,7 +315,7 @@ export const Content = memo(function Content({
|
||||
renderMode={renderMode}
|
||||
detail={detail}
|
||||
view3d={view3d}
|
||||
groundElevation={level.baseElevation ?? 0}
|
||||
groundElevation={(level.baseElevation ?? 0) + explodeLift}
|
||||
gridVisible={grid3dVisible}
|
||||
onToggleGrid={onToggleGrid3d}
|
||||
section3d={section3d}
|
||||
@@ -828,9 +833,11 @@ function LevelPlanView({
|
||||
useEffect(() => {
|
||||
pushNativeScene(plan);
|
||||
}, [plan]);
|
||||
// Explosionsaxonometrie ([65]) auch im nativen 3D-Fenster.
|
||||
const explode = useStore((s) => (s.explode3d ? s.explode3dGap : 0));
|
||||
useEffect(() => {
|
||||
pushNativeWalls(project);
|
||||
}, [project]);
|
||||
pushNativeWalls(project, explode);
|
||||
}, [project, explode]);
|
||||
|
||||
return (
|
||||
<section className="pane">
|
||||
|
||||
Reference in new issue
Block a user