[253] 3D-Entourage: Low-Poly-Netze für Person (stehend/gehend), Velo, Auto, Sitzbank, Stuhl, Tische mit Stühlen
Kern furniture_3d.rs: prozedurale, geschlossene Teilnetze aus den Parametern (Höhe h einstellbar), Platzierung auf Gelände/Geschoss. Im 3D (model3d::emit_entourage, Explosion, Cache-Stand), Cycles-Szene, 3D-Dokument (axo) und Schattenwurf; Klasse der Zeichnung ([180]); Grundriss bleibt 2D. Beispiel :wettbewerb: 3 Personen, Auto, Velo, Bank. Nicht im IFC, nicht in Schnitt/Ansicht (TODO).
This commit is contained in:
20 files changed
+879
-27
No files matched your search
@@ -71,7 +71,7 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC.
|
||||
- ◐ **[263]** Visuelle und UX-Prüfung des Referenz-Ablaufs (15.11., Chromium/Linux, `e2e/uxReview263.spec.ts`; Befunde 1–3, 5–10 und Statusleiste behoben). Offen: Punkt 4 Sprachumschalter ist mit [264] erledigt, aber Projektvorgaben (Namen wie „Leeres Projekt“, „Erdgeschoss“, „Süd“, „Schnitt A“, Ebenen „20 Wände“) erscheinen in englischer Oberfläche deutsch (Vorgabenamen beim Anlegen über `t()`) · M; nicht geprüft: Tauri/Mac (Nebenfenster, native Menüs, Metal; Hilfe-Einträge „Kurzanleitung“/„Fehler melden“ und System-Browser-Öffnung dort), Ansichtsleiste-Überlauf „⋯“, Dock-Einklappen und Statusleisten-Kürzung auf dem Mac, 3D-Ansicht und Zeichenfläche pixelgenau (SwiftShader), Layout-Inhalt im Druck, englisch/dunkel bei 1440, Tab-Reihenfolge/Screenreader ausserhalb der Dialoge ([249]); dunkles Thema: Plan bleibt als Papier hell (Absicht?). · S–M
|
||||
- ◐ **[261]** Version 1.0.0-beta.1 und Buildnummer `JJMMTT.N` (15.11.; `scripts/build-number.cjs`, `src/update/buildInfo.ts`). Offen: nicht in der Tauri-App/auf dem Mac geprüft (Prüfschritt 13.35); Projektdatei trägt kein Feld für schreibende App-Version/Build (Modellfeld in Rust + `KNOWN_KEYS` + Fassade); Zähler zählt Commits, nicht Builds (Abhilfe `DOSSIER_BUILD=261115.3`). · S
|
||||
- ◐ **[260]** Fenster/Türen im Grundriss symbolisch oder geschnitten (15.11.; `Opening.planMode`, `OpeningPlanMode`, `plan/walls.rs`, Feld „Im Grundriss“ in Objekteinstellungen und Typeditor). Offen: auf dem Mac nicht geprüft (Metal-Fläche, natives Objekteinstellungsfenster, PDF/DXF; `doc/RELEASE-1.0.md` 13.29). · M
|
||||
- ◐ **[253]** Standard-Objektbibliothek 2D (14.11.): 48 parametrische Objekte (`Drawing2DGeom::Libobj`, Kern `furniture_lib.rs`, Palette „Objekte“, Befehl `libobj`, DXF als Blöcke). Offen: auf dem Mac nicht geprüft (Ziehen aus der Palette mit dem nativen Metal-Renderer, `doc/RELEASE-1.0.md` 13.17; Symbole nur im CLI-SVG/Chromium angesehen); 3D nach 1.0 (Trait hat Platz für `geometry3d`); DXF-Block ohne Attribute (Id/Parameter nur im Blocknamen); Klassen-Namen („23 Sanitär“) bleiben im englischen UI deutsch (Projektdaten). · M
|
||||
- ◐ **[253]** Standard-Objektbibliothek 2D (14.11.): 48 parametrische Objekte (`Drawing2DGeom::Libobj`, Kern `furniture_lib.rs`, Palette „Objekte“, Befehl `libobj`, DXF als Blöcke). Offen: auf dem Mac nicht geprüft (Ziehen aus der Palette mit dem nativen Metal-Renderer, `doc/RELEASE-1.0.md` 13.17; Symbole nur im CLI-SVG/Chromium angesehen); 3D-Entourage 18.11. ([253] 3D: `furniture_3d.rs`, Person stehend/gehend, Velo, Auto, Sitzbank, Stuhl, Tische mit Stühlen als Low-Poly-Netz im 3D, 3D-Dokument, Cycles, Schatten; Parameter `h`; Beispiel `:wettbewerb`; offen: weitere Möbel, Entourage in Schnitt/Ansicht, nicht im IFC (IfcFurnishingElement offen), im 3D nicht pickbar, kein 3D-Netz in schiefen Projektionen des 3D-Dokuments, nur im Linux-Container als CLI-SVG/Chromium angesehen, nicht in der Tauri-App/Metal); DXF-Block ohne Attribute (Id/Parameter nur im Blocknamen); Klassen-Namen („23 Sanitär“) bleiben im englischen UI deutsch (Projektdaten). · M
|
||||
|
||||
## Phase 1 (13.–19.11.): Stabil und baubar
|
||||
Konsolen-Audit (14.11., `node scripts/console-audit.mjs [--gpu]`): Rest nur headless/SwiftShader (`[longtask]` 200–300 ms beim Laden grosser Beispiele, im Dev-Build bis 11 s); `csp.spec.ts` schlägt gegen `vite dev` erwartungsgemäss fehl. Offen: Tauri/Metal-Konsole auf dem Mac nicht geprüft.
|
||||
|
||||
@@ -461,6 +461,14 @@ sich mit starrer Geometrie nicht speichern. Aufbau in `src-tauri/core/src/furnit
|
||||
| **Zufall** | Die Unordnung der Stühle (`mess`, 0–1) nutzt nur `seed` (ganzzahliges SplitMix, plattformgleich); der Seed wird beim Setzen aus der Element-Id gebildet, „Neu würfeln" setzt ihn neu. Nie Zufall zur Plan-Zeit ⇒ Goldens und Export stabil. Stühle werden immer so weit hinausgeschoben, dass sie den Tisch nicht schneiden. |
|
||||
| **Oberfläche** | Katalog als JSON (`furniture_lib_catalog_json`, Vorschau-Linien `furniture_lib_geometry_json`) → `src/model/furnitureLib.ts`; Dock-Panel „Objekte" (`panels/ObjectLibraryPanel.tsx`), Befehl `libobj` (`commands/cmds/libobj.ts`, R = drehen, M = spiegeln; Kern `cmd_draw.rs::libobj_ops` legt die Klasse im selben Undo-Schritt an, falls sie fehlt), Objekt-Info (`panels/objectInfo/LibObjectSection.tsx`) baut ihre Felder generisch aus der Parameterliste. Namen: i18n `lib.o.<id>`, `lib.g.<gruppe>`, `lib.p.<parameter>`. |
|
||||
|
||||
**3D-Entourage** (`furniture_3d.rs`, [253]): Objekte mit `with3d(..)` in `build()` haben zusätzlich `LibObject::geometry3d` → `Vec<Mesh3>`
|
||||
(geschlossene Low-Poly-Teilnetze in Kastenkoordinaten, prozedural aus den Parametern; Parameter `h` = Höhe: Person 1.75, Auto Dach,
|
||||
Velo Lenker, Bank Sitz, Tisch Platte). Stuhl-Plätze der Tische kommen aus dem 2D-Lauf (`Sh::chairs`), also dieselbe Unordnung nach Seed.
|
||||
`furniture_3d::placed(p)` stellt jede `Libobj`-Zeichnung ins Modell (Fuss = Gelände, sonst Geschoss-UK). Verbraucher: `model3d::emit_entourage`
|
||||
(3D, Pick-frei, Explosion, Cache-Stand `entourage_stamp`), `mesh_data` (Cycles, Gruppe „entourage"), `plan/axo.rs` (über
|
||||
`with_context_meshes`, nur längentreue Projektionen), `sun.rs` (Schattenwolken). Klasse und Ausblenden = die der Zeichnung ([180]).
|
||||
Der Grundriss bleibt beim 2D-Symbol. Nicht in Schnitt/Ansicht und nicht im IFC.
|
||||
|
||||
Neues eingebautes Objekt: Eintrag in `furniture_lib.rs::build()` (Definition + Zeichenfunktion), Namen in `de.ts`/`en.ts`.
|
||||
Standards laden ergänzt die Klassen „Möbel", „Sanitär" und „Fahrzeuge & Freiflächen" (`standards.rs::merge_plan`).
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ Grösse: S ≤ 1 Tag · M ≤ 1 Woche · L ≤ 1 Monat. IDs aus `TODO.md`; **neu
|
||||
| 7 | **Geländer als eigenes Bauteil** (Balkon/Loggia/Absturzsicherung in Plan, Schnitt, Ansicht, 3D). **erledigt 17.11. ([279], Rest: Loggia-Brüstung an Wänden, Fangpunkte, Import IfcRailing)** | `railing.rs`, `plan/railings.rs`, `cmds/railing.ts` | M |
|
||||
| 8 | **Geneigte Decke / Rampe** (Tiefgarage, Terrassen mit Gefälle): `Ceiling` hat nur Ober-/Unterkante, keine Neigung; Behelf Pultdach/Körper. **neu** | `Ceiling`, `ceiling_item` (`cmd_create.rs`), `plan/section` | M |
|
||||
| 9 | **Träger/Unterzug/Fassadenträger**: kein Element (Behelf Körper/Wand), Deckenspiegel mit Unterzügen fehlt. **teilweise erledigt 17.11. ([280]: Träger/Unterzug als Bauteil in Plan, Schnitt, Ansicht, 3D, IFC; Rest: Gruppen, Deckenspiegel, Profilkatalog)**, [100] nennt die Lücke | `columns` als Muster | M |
|
||||
| 10 | **3D-Entourage** (Möbel, Menschen, Autos 3D) für Bilder: Bibliothek nur 2D; Behelf glTF/OBJ-Import | [253] („3D nach 1.0“), `furniture_lib.rs` | L |
|
||||
| 10 | **3D-Entourage** (Möbel, Menschen, Autos 3D) für Bilder. **teilweise erledigt 18.11. ([253]: Person stehend/gehend, Velo, Auto, Sitzbank, Stuhl, Tische mit Stühlen als Low-Poly-Netz im 3D, 3D-Dokument, Cycles, Schatten; Rest: weitere Möbel, Schnitt/Ansicht, IFC, Fremdmodelle per glTF/OBJ-Import)** | [253], `furniture_3d.rs`, `furniture_lib.rs` | L |
|
||||
| 11 | **GV: Studienkörper neben Wand-Haus, Bodenplatte unter unterstem Geschoss** | [266] Punkt 1 Rest; `building_volume.rs` | S–M |
|
||||
| 12 | **IFC: Dachflächen nur als Netz (IfcRoof-Aggregat seit 18.11., keine Profil-Extrusion), keine 2D/Layouts/Möbel**; IFC-Import zu Bauteilen unvollständig (Dächer, Träger) | [B4], [B5], [259] | M |
|
||||
| 13 | **Gelände weiter bearbeiten** (Modellieren, Schnitt-Gelände geprüft?): Griffe/Profile, Abtrag/Aufschüttung nur über Baugrube | [187], [T6], [68]; Spec-Schritt 1.3 „Gelände nicht im Schnitt“ | M |
|
||||
|
||||
@@ -36,6 +36,7 @@ Neues Modul: `<modul>.rs` und `mod` in `lib.rs`, Bindungen in `web/<modul>.rs` u
|
||||
| `design_options.rs` | [272] Varianten: Kombination (je Satz eine Variante), Anfragen „Satz=Variante“, Ops (Übernehmen, Löschen, Zuweisen, Kopieren, Zeichen-Variante), Vergleich der Kennzahlen/Kosten; die Sichtbarkeit selbst entscheidet `renovation.rs` (`doc/ARCHITEKTUR.md` 3.9) |
|
||||
| `standards.rs` | Standard-Bibliothek: Baustoffe mit SIA-400-Schraffur und Kennwerten, Linientypen, Standard-Aufbauten |
|
||||
| `standards_names.rs` | [264] Englische Namen der Standards nach Kennung (`Lang`, `name_in`); neue Projekte in englischer UI bekommen sie über `standardsMergeOps(lang)` |
|
||||
| `furniture_3d.rs` | Entourage 3D ([253]): Low-Poly-Netze (Person, Auto, Velo, Bank, Stuhl, Tische) der Bibliotheksobjekte, Platzierung auf Gelände/Geschoss, Schattenwolken; Netze kommen über `model3d::emit_entourage` in 3D, `mesh_data` (Cycles) und `plan/axo.rs` |
|
||||
| `furniture_lib.rs` | Objektbibliothek 2D ([253]): Katalog der Standard-Symbole mit Parametern (Definition) und Zeichenfunktionen nach Detailgrad (Erzeugung), Register, Platzhalter für unbekannte Ids; s. `doc/ARCHITEKTUR.md` 3.7 |
|
||||
| `text_layout.rs`, `rich_text.rs` | Text-Layout (Zeilen, Umbruch) und Bearbeiten von Rich-Text |
|
||||
| `woff2.rs` | WOFF2 → TTF/SFNT (nur untransformierte Pakete), `woff2_to_sfnt` für die PDF-Schriften ([208], `src/export/pdfFonts.ts`); render2d bindet dieselbe Datei per `#[path]` ein (Glyphen-Pass [226]) |
|
||||
|
||||
@@ -865,6 +865,18 @@ mod tests {
|
||||
xml.matches(&format!("<{tag} ")).count() + xml.matches(&format!("<{tag}>")).count()
|
||||
}
|
||||
|
||||
/// [253] Entourage (Person, Auto …) kommt als eigene Netze in die Szene.
|
||||
#[test]
|
||||
fn entourage_ist_in_der_szene() {
|
||||
let base = cycles_scene(&sample(), &opts("{}")).unwrap();
|
||||
let mut p = sample();
|
||||
let lv = p.drawing_levels[0].id.clone();
|
||||
p.drawings2d.push(serde_json::from_value(serde_json::json!({"id": "pers1", "type": "drawing2d", "levelId": lv, "categoryCode": "24", "geom": {"shape": "libobj", "libId": "lib:person-stehend", "at": {"x": 4.0, "y": -3.0}, "rotation": 0.5}})).unwrap());
|
||||
let s = cycles_scene(&p, &opts("{}")).unwrap();
|
||||
assert!(s.meshes > base.meshes && s.triangles > base.triangles + 100, "{} -> {} Dreiecke", base.triangles, s.triangles);
|
||||
well_formed(&s.xml);
|
||||
}
|
||||
|
||||
/// Das Beispielprojekt ergibt eine wohlgeformte XML-Szene: Zähler und Verschachtelung stimmen, alle Indizes zeigen auf Ecken.
|
||||
#[test]
|
||||
fn beispiel_ist_wohlgeformt() {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
//! 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};
|
||||
use crate::model::{Drawing2DGeom, DrawingLevelKind, Project};
|
||||
use crate::model3d::{self, Parts, PickGeometry, RMesh, RRoofLayer, RSlab, RWall};
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -185,6 +185,10 @@ pub fn parts_filtered(p: &Project, layered: bool, detail: f64, for_section: bool
|
||||
};
|
||||
out.column_meshes.extend(shifted(kept(&q, model3d::emit_columns(&q)), dz, shift_mesh));
|
||||
out.column_meshes.extend(shifted(kept(&q, model3d::emit_trees(&q)), dz, shift_mesh));
|
||||
// [253] Entourage: die Bibliotheksobjekte des Geschosses (`q.drawings2d` ist sonst leer).
|
||||
q.drawings2d = p.drawings2d.iter().filter(|d| matches!(d.geom, Drawing2DGeom::Libobj { .. }) && pick(&d.level_id)).cloned().collect();
|
||||
out.column_meshes.extend(shifted(kept(&q, model3d::emit_entourage(&q)), dz, shift_mesh));
|
||||
q.drawings2d.clear();
|
||||
out.column_meshes.extend(shifted(kept(&q, model3d::emit_railings(&q)), dz, shift_mesh));
|
||||
out.stair_meshes.extend(shifted(kept(&q, model3d::emit_stair_meshes(&q)), dz, shift_mesh));
|
||||
// Handläufe folgen der Treppe, die Absturzsicherung der Decke mit dem Loch (Geschoss `g`, [155]).
|
||||
|
||||
@@ -0,0 +1,592 @@
|
||||
//! Entourage 3D ([253], Lücke 10 in `doc/VERGLEICH-1.0.md`): einige Objekte der Bibliothek (`furniture_lib.rs`) haben neben
|
||||
//! dem 2D-Symbol ein einfaches Low-Poly-Netz, prozedural aus den Parametern (kein Fremd-Asset): Person (stehend, gehend),
|
||||
//! Velo, Auto, Sitzbank, Stuhl, Tische (mit ihren Stühlen). Der Grundriss zeigt weiter nur das 2D-Symbol.
|
||||
//!
|
||||
//! - **Netze** ([`Mesh3`]): lokal in Kastenkoordinaten (wie das 2D-Symbol, x/y in m um den Einfügepunkt, z = Höhe über dem Fuss),
|
||||
//! jedes Teil ein geschlossenes, nach aussen gewickeltes Netz (gemeinsame Eckpunkte; Test: jede Kante genau zweimal, Volumen > 0).
|
||||
//! - **Aufbau** ([`B3`]): Quader, Kegelstümpfe/Lofts aus Ringen, Rohre; mehr braucht der Entourage nicht.
|
||||
//! - **Platzierung** ([`placed`]): Instanz = `Drawing2DGeom::Libobj` einer Zeichnung; Fuss = Gelände an der Einfügestelle
|
||||
//! (wie bei Bäumen, `tree::bases`), sonst Unterkante des Geschosses der Zeichnung. Drehen, Spiegeln, Verschieben wie im 2D.
|
||||
//! Die Netze kommen als `RMesh` ins 3D (`model3d::emit_entourage`), in Schnitt/Ansicht/3D-Dokument, Cycles-Szene und
|
||||
//! Schattenwurf ([`clouds`]); die Klasse ist die der Zeichnung ([180]).
|
||||
|
||||
use crate::jsnum::{cos, sin};
|
||||
use crate::model::{Drawing2DGeom, Project};
|
||||
use std::collections::BTreeMap;
|
||||
use std::f64::consts::TAU;
|
||||
|
||||
pub type V3 = [f64; 3];
|
||||
|
||||
/// Ein geschlossenes Teilnetz mit Farbe (sRGB 0–1).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Mesh3 {
|
||||
pub positions: Vec<f64>,
|
||||
pub indices: Vec<u32>,
|
||||
pub color: [f64; 3],
|
||||
}
|
||||
|
||||
impl Mesh3 {
|
||||
/// Spiegelung an der y-Achse (x → −x), Wicklung bleibt nach aussen.
|
||||
pub fn mirrored(&self) -> Mesh3 {
|
||||
let mut m = self.clone();
|
||||
m.positions.chunks_exact_mut(3).for_each(|q| q[0] = -q[0]);
|
||||
m.indices.chunks_exact_mut(3).for_each(|t| t.swap(1, 2));
|
||||
m
|
||||
}
|
||||
}
|
||||
|
||||
/// Netz-Sammler in Kastenkoordinaten (x 0..w, y 0..d) mit Versatz zum Einfügepunkt.
|
||||
pub struct B3 {
|
||||
pub ox: f64,
|
||||
pub oy: f64,
|
||||
pub parts: Vec<Mesh3>,
|
||||
}
|
||||
|
||||
type Ring = Vec<V3>;
|
||||
|
||||
/// Ellipsenring (gegen den Uhrzeigersinn von oben) um (cx, cy) auf Höhe z.
|
||||
fn ellipse_ring(cx: f64, cy: f64, z: f64, rx: f64, ry: f64, n: usize) -> Ring {
|
||||
(0..n)
|
||||
.map(|i| {
|
||||
let t = TAU * i as f64 / n as f64;
|
||||
[cx + rx * cos(t), cy + ry * sin(t), z]
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Rechteckring (gegen den Uhrzeigersinn) auf Höhe z.
|
||||
fn rect_ring(x0: f64, y0: f64, x1: f64, y1: f64, z: f64) -> Ring {
|
||||
vec![[x0, y0, z], [x1, y0, z], [x1, y1, z], [x0, y1, z]]
|
||||
}
|
||||
|
||||
impl B3 {
|
||||
pub fn new(ox: f64, oy: f64) -> B3 {
|
||||
B3 { ox, oy, parts: Vec::new() }
|
||||
}
|
||||
|
||||
/// Körper aus Ringen gleicher Punktzahl (gegen den Uhrzeigersinn von oben, von unten nach oben), oben und unten mit
|
||||
/// einem Fächer um den Schwerpunkt geschlossen. Entartete Eingaben (< 2 Ringe, < 3 Punkte, NaN) ergeben nichts.
|
||||
fn loft(&mut self, rings: Vec<Ring>, color: [f64; 3]) {
|
||||
let n = rings.first().map_or(0, |r| r.len());
|
||||
if rings.len() < 2 || n < 3 || rings.iter().any(|r| r.len() != n || r.iter().any(|q| q.iter().any(|v| !v.is_finite()))) {
|
||||
return;
|
||||
}
|
||||
let mut positions: Vec<f64> = Vec::with_capacity((rings.len() * n + 2) * 3);
|
||||
for r in &rings {
|
||||
for q in r {
|
||||
positions.extend([q[0] + self.ox, q[1] + self.oy, q[2]]);
|
||||
}
|
||||
}
|
||||
let nn = n as u32;
|
||||
let mut indices: Vec<u32> = Vec::new();
|
||||
for i in 0..rings.len() as u32 - 1 {
|
||||
for j in 0..nn {
|
||||
let k = (j + 1) % nn;
|
||||
let (a, b, c, d) = (i * nn + j, i * nn + k, (i + 1) * nn + k, (i + 1) * nn + j);
|
||||
indices.extend([a, b, c, a, c, d]);
|
||||
}
|
||||
}
|
||||
let top = (rings.len() as u32 - 1) * nn;
|
||||
if n == 4 {
|
||||
// Rechteckringe: Deckel aus zwei Dreiecken (Quader = 12 Dreiecke).
|
||||
indices.extend([0, 2, 1, 0, 3, 2, top, top + 1, top + 2, top, top + 2, top + 3]);
|
||||
} else {
|
||||
let centre = |r: &Ring| {
|
||||
let k = r.len() as f64;
|
||||
[r.iter().map(|q| q[0]).sum::<f64>() / k + self.ox, r.iter().map(|q| q[1]).sum::<f64>() / k + self.oy, r[0][2]]
|
||||
};
|
||||
let (cb, ct) = (centre(&rings[0]), centre(&rings[rings.len() - 1]));
|
||||
let (ib, it) = ((rings.len() * n) as u32, (rings.len() * n + 1) as u32);
|
||||
positions.extend(cb);
|
||||
positions.extend(ct);
|
||||
for j in 0..nn {
|
||||
let k = (j + 1) % nn;
|
||||
indices.extend([ib, k, j]);
|
||||
indices.extend([it, top + j, top + k]);
|
||||
}
|
||||
}
|
||||
self.parts.push(Mesh3 { positions, indices, color });
|
||||
}
|
||||
|
||||
/// Quader x0..x1, y0..y1, z0..z1.
|
||||
pub fn cuboid(&mut self, x0: f64, y0: f64, z0: f64, x1: f64, y1: f64, z1: f64, color: [f64; 3]) {
|
||||
self.loft(vec![rect_ring(x0, y0, x1, y1, z0), rect_ring(x0, y0, x1, y1, z1)], color);
|
||||
}
|
||||
|
||||
/// Um (cx, cy) um `rot` verdrehter Quader; lokal lx0..lx1 × ly0..ly1 (relativ zu (cx, cy)), Höhe z0..z1.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn cuboid_rot(&mut self, cx: f64, cy: f64, rot: f64, l: [f64; 4], z0: f64, z1: f64, color: [f64; 3]) {
|
||||
let (c, s) = (cos(rot), sin(rot));
|
||||
let ring = |z: f64| -> Ring { rect_ring(l[0], l[1], l[2], l[3], z).into_iter().map(|q| [cx + q[0] * c - q[1] * s, cy + q[0] * s + q[1] * c, z]).collect() };
|
||||
self.loft(vec![ring(z0), ring(z1)], color);
|
||||
}
|
||||
|
||||
/// Rechteck-Stapel `(z, x0, y0, x1, y1)` von unten nach oben (Karosserie, Kabine).
|
||||
pub fn stack(&mut self, rings: &[(f64, f64, f64, f64, f64)], color: [f64; 3]) {
|
||||
self.loft(rings.iter().map(|r| rect_ring(r.1, r.2, r.3, r.4, r.0)).collect(), color);
|
||||
}
|
||||
|
||||
/// Körper aus Ellipsen `(z, cx, cy, rx, ry)` mit `n` Seiten (Rumpf, Beine, Kopf, runde Tischplatte).
|
||||
pub fn body(&mut self, rings: &[(f64, f64, f64, f64, f64)], n: usize, color: [f64; 3]) {
|
||||
self.loft(rings.iter().map(|r| ellipse_ring(r.1, r.2, r.0, r.3, r.4, n.max(3))).collect(), color);
|
||||
}
|
||||
|
||||
/// Rohr (Zylinder) von `a` nach `b` mit Radius `r` und `n` Seiten, beide Enden geschlossen.
|
||||
pub fn tube(&mut self, a: V3, b: V3, r: f64, n: usize, color: [f64; 3]) {
|
||||
let ax = [b[0] - a[0], b[1] - a[1], b[2] - a[2]];
|
||||
let len = (ax[0] * ax[0] + ax[1] * ax[1] + ax[2] * ax[2]).sqrt();
|
||||
if !(len > 1e-9 && r > 0.0) {
|
||||
return;
|
||||
}
|
||||
let u = [ax[0] / len, ax[1] / len, ax[2] / len];
|
||||
// u1 ⟂ u (aus der Lotrechten), u2 = u × u1, damit u1 × u2 = u: Ring gegen den Uhrzeigersinn, von `a` aus gesehen nach `b`.
|
||||
let up = if u[2].abs() < 0.9 { [0.0, 0.0, 1.0] } else { [1.0, 0.0, 0.0] };
|
||||
let cr = |p: V3, q: V3| [p[1] * q[2] - p[2] * q[1], p[2] * q[0] - p[0] * q[2], p[0] * q[1] - p[1] * q[0]];
|
||||
let u1 = cr(up, u);
|
||||
let l1 = (u1[0] * u1[0] + u1[1] * u1[1] + u1[2] * u1[2]).sqrt();
|
||||
let u1 = [u1[0] / l1, u1[1] / l1, u1[2] / l1];
|
||||
let u2 = cr(u, u1);
|
||||
let n = n.max(3);
|
||||
let ring = |c: V3| -> Ring {
|
||||
(0..n)
|
||||
.map(|i| {
|
||||
let t = TAU * i as f64 / n as f64;
|
||||
let (ct, st) = (cos(t) * r, sin(t) * r);
|
||||
[c[0] + u1[0] * ct + u2[0] * st, c[1] + u1[1] * ct + u2[1] * st, c[2] + u1[2] * ct + u2[2] * st]
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
self.loft(vec![ring(a), ring(b)], color);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Objekte ──────────────────────────────────────────────────────────────────
|
||||
|
||||
const SKIN: [f64; 3] = [0.80, 0.68, 0.58];
|
||||
const SHIRT: [f64; 3] = [0.74, 0.72, 0.68];
|
||||
const TROUSERS: [f64; 3] = [0.34, 0.36, 0.42];
|
||||
const WOOD: [f64; 3] = [0.66, 0.52, 0.36];
|
||||
const STEEL: [f64; 3] = [0.30, 0.31, 0.33];
|
||||
const CAR_BODY: [f64; 3] = [0.68, 0.70, 0.74];
|
||||
const TYRE: [f64; 3] = [0.11, 0.11, 0.12];
|
||||
/// Stuhl.
|
||||
pub const CHAIR_RGB: [f64; 3] = [0.36, 0.36, 0.39];
|
||||
/// Normhöhe der Person (m): Höhe 1.75 = Massstab 1.
|
||||
pub const PERSON_H: f64 = 1.75;
|
||||
|
||||
use crate::furniture_lib::Params;
|
||||
|
||||
/// Person, stehend oder gehend (Schritt: Fuss ±0.2 m vor/zurück, Arme gegengleich). Alles mit `k = h / 1.75` skaliert.
|
||||
pub fn person(p: &Params, walking: bool, b: &mut B3) {
|
||||
let k = (p.get("h") / PERSON_H).max(0.1);
|
||||
let (cx, cy) = (p.w / 2.0, p.d / 2.0);
|
||||
for s in [-1.0_f64, 1.0] {
|
||||
let swing = if walking { 0.2 * s * k } else { 0.0 };
|
||||
let x = cx + s * 0.095 * k;
|
||||
// Bein: Fuss (Zehen vor), Knöchel, Knie, Hüfte; die Mitte wandert mit der Höhe von `swing` nach 0.
|
||||
let leg: [(f64, f64, f64, f64); 4] = [(0.0, 0.052, 0.11, 1.0), (0.07, 0.048, 0.055, 1.0), (0.46, 0.068, 0.075, 0.5), (0.90, 0.09, 0.105, 0.0)];
|
||||
let rings: Vec<_> = leg.iter().map(|&(z, rx, ry, w)| (z * k, x, cy + swing * w + if z == 0.0 { 0.045 * k } else { 0.0 }, rx * k, ry * k)).collect();
|
||||
b.body(&rings, 10, TROUSERS);
|
||||
// Arm: Schulter → Hand, gegen das gleichseitige Bein.
|
||||
let (sh, hand) = ([cx + s * 0.235 * k, cy, 1.43 * k], [cx + s * 0.27 * k, cy - swing * 1.1, 0.80 * k]);
|
||||
b.tube(sh, hand, 0.04 * k, 8, SHIRT);
|
||||
}
|
||||
let torso: [(f64, f64, f64); 7] = [(0.84, 0.16, 0.10), (0.95, 0.165, 0.105), (1.10, 0.15, 0.10), (1.30, 0.19, 0.115), (1.45, 0.215, 0.10), (1.50, 0.17, 0.085), (1.54, 0.055, 0.055)];
|
||||
b.body(&torso.iter().map(|&(z, rx, ry)| (z * k, cx, cy, rx * k, ry * k)).collect::<Vec<_>>(), 12, SHIRT);
|
||||
let head: [(f64, f64, f64); 5] = [(1.54, 0.05, 0.05), (1.60, 0.08, 0.09), (1.67, 0.095, 0.10), (1.73, 0.07, 0.08), (PERSON_H, 0.03, 0.035)];
|
||||
b.body(&head.iter().map(|&(z, rx, ry)| (z * k, cx, cy + 0.01 * k, rx * k, ry * k)).collect::<Vec<_>>(), 10, SKIN);
|
||||
}
|
||||
|
||||
pub fn person_standing(p: &Params, _chairs: &[(f64, f64, f64)], b: &mut B3) {
|
||||
person(p, false, b);
|
||||
}
|
||||
|
||||
pub fn person_walking(p: &Params, _chairs: &[(f64, f64, f64)], b: &mut B3) {
|
||||
person(p, true, b);
|
||||
}
|
||||
|
||||
/// Stuhl mit Sitzfläche `w × d` um (cx, cy), Rückenlehne bei lokal −y (wie das 2D-Symbol), gedreht um `rot`.
|
||||
pub fn chair(b: &mut B3, cx: f64, cy: f64, rot: f64, w: f64, d: f64) {
|
||||
let (hw, hd) = (w / 2.0, d / 2.0);
|
||||
let seat = 0.45;
|
||||
b.cuboid_rot(cx, cy, rot, [-hw, -hd, hw, hd], seat - 0.04, seat, CHAIR_RGB);
|
||||
for (lx, ly) in [(-hw + 0.02, -hd + 0.02), (hw - 0.05, -hd + 0.02), (-hw + 0.02, hd - 0.05), (hw - 0.05, hd - 0.05)] {
|
||||
b.cuboid_rot(cx, cy, rot, [lx, ly, lx + 0.03, ly + 0.03], 0.0, seat - 0.04, CHAIR_RGB);
|
||||
}
|
||||
b.cuboid_rot(cx, cy, rot, [-hw, -hd, hw, -hd + 0.04], seat, 0.90, CHAIR_RGB);
|
||||
}
|
||||
|
||||
/// Einzelner Stuhl (Objekt `lib:stuhl`).
|
||||
pub fn single_chair(p: &Params, _chairs: &[(f64, f64, f64)], b: &mut B3) {
|
||||
chair(b, p.w / 2.0, p.d / 2.0, 0.0, p.w, p.d);
|
||||
}
|
||||
|
||||
/// Rechteckiger Tisch (Platte 4 cm, vier Beine) mit den Stühlen aus dem 2D-Symbol.
|
||||
pub fn rect_table(p: &Params, chairs: &[(f64, f64, f64)], b: &mut B3) {
|
||||
let (w, d, h) = (p.w, p.d, p.get("h"));
|
||||
b.cuboid(0.0, 0.0, h - 0.04, w, d, h, WOOD);
|
||||
let l = 0.06_f64.min(w / 4.0).min(d / 4.0);
|
||||
for (x, y) in [(l, l), (w - l - 0.05, l), (l, d - l - 0.05), (w - l - 0.05, d - l - 0.05)] {
|
||||
b.cuboid(x, y, 0.0, x + 0.05, y + 0.05, h - 0.04, WOOD);
|
||||
}
|
||||
for &(cx, cy, rot) in chairs {
|
||||
chair(b, cx, cy, rot, 0.45, 0.50);
|
||||
}
|
||||
}
|
||||
|
||||
/// Runder Tisch (Platte, Mittelfuss mit Teller) mit den Stühlen.
|
||||
pub fn round_table(p: &Params, chairs: &[(f64, f64, f64)], b: &mut B3) {
|
||||
let (r, h) = (p.w / 2.0, p.get("h"));
|
||||
b.body(&[(h - 0.04, r, r, r, r), (h, r, r, r, r)], 24, WOOD);
|
||||
b.body(&[(0.0, r, r, r.min(0.3), r.min(0.3)), (0.03, r, r, r.min(0.3), r.min(0.3))], 16, WOOD);
|
||||
b.body(&[(0.03, r, r, 0.05, 0.05), (h - 0.04, r, r, 0.05, 0.05)], 8, WOOD);
|
||||
for &(cx, cy, rot) in chairs {
|
||||
chair(b, cx, cy, rot, 0.45, 0.50);
|
||||
}
|
||||
}
|
||||
|
||||
/// Sitzbank: Sitz (5 cm), Rückenlehne (40 cm hoch bei y = 0), zwei Stahlfüsse. `h` = Sitzhöhe.
|
||||
pub fn bench(p: &Params, _chairs: &[(f64, f64, f64)], b: &mut B3) {
|
||||
let (w, d, h) = (p.w, p.d, p.get("h"));
|
||||
b.cuboid(0.0, 0.0, h - 0.05, w, d, h, WOOD);
|
||||
b.cuboid(0.0, 0.0, h, w, 0.05_f64.min(d / 2.0), h + 0.40, WOOD);
|
||||
let l = 0.08_f64.min(w / 4.0);
|
||||
for x in [l, w - l - 0.05] {
|
||||
b.cuboid(x, 0.05_f64.min(d / 4.0), 0.0, x + 0.05, d - 0.05_f64.min(d / 4.0), h - 0.05, STEEL);
|
||||
}
|
||||
}
|
||||
|
||||
/// Auto (Kleinwagen/Kombi): Unterbau mit Abschrägung, Kabine mit geneigten Scheiben, vier Räder; Front bei +y. `h` = Dachhöhe.
|
||||
pub fn car(p: &Params, _chairs: &[(f64, f64, f64)], b: &mut B3) {
|
||||
let (w, d, h) = (p.w, p.d, p.get("h"));
|
||||
let belt = (0.62 * h).max(0.5);
|
||||
b.stack(&[(0.18, 0.10, 0.15, w - 0.10, d - 0.15), (0.32, 0.0, 0.0, w, d), (belt - 0.05, 0.0, 0.0, w, d), (belt, 0.03, 0.05, w - 0.03, d - 0.05)], CAR_BODY);
|
||||
b.stack(&[(belt - 0.01, 0.06, d * 0.22, w - 0.06, d * 0.72), (h, 0.16, d * 0.30, w - 0.16, d * 0.62)], CAR_BODY);
|
||||
let r = 0.31_f64.min(h * 0.25);
|
||||
for y in [0.80_f64.min(d * 0.25), (d - 1.0).max(d * 0.75)] {
|
||||
for x in [0.02, w - 0.24] {
|
||||
b.tube([x, y, r], [x + 0.22, y, r], r, 14, TYRE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Velo: zwei Räder (Scheiben), Rahmen aus Rohren, Sattel, Lenker; Front bei +y. `h` = Höhe des Lenkers.
|
||||
pub fn bike(p: &Params, _chairs: &[(f64, f64, f64)], b: &mut B3) {
|
||||
let (w, d, h) = (p.w, p.d, p.get("h"));
|
||||
let cx = w / 2.0;
|
||||
let wr = 0.33_f64.min(h * 0.45);
|
||||
let (yr, yf) = (0.04 + wr, d - 0.04 - wr);
|
||||
for y in [yr, yf] {
|
||||
b.tube([cx - 0.015, y, wr], [cx + 0.015, y, wr], wr, 16, TYRE);
|
||||
}
|
||||
let fr = 0.017;
|
||||
let bb = [cx, d * 0.43, 0.30_f64.min(h * 0.4)];
|
||||
let seat = [cx, d * 0.37, 0.84 * h];
|
||||
let head_b = [cx, d - 0.55, h - 0.30_f64.min(h * 0.4)];
|
||||
let head_t = [cx, d - 0.51, h - fr];
|
||||
let seat_top = [cx, d * 0.37, 0.80 * h];
|
||||
for (a, c) in [(bb, seat), (seat_top, [head_b[0], head_b[1], head_b[2] + 0.03]), (bb, head_b), (bb, [cx, yr, wr]), (seat_top, [cx, yr, wr]), (head_b, [cx, yf, wr]), (head_b, head_t)] {
|
||||
b.tube(a, c, fr, 6, STEEL);
|
||||
}
|
||||
b.tube([cx - 0.27, head_t[1], h - fr], [cx + 0.27, head_t[1], h - fr], fr, 8, STEEL);
|
||||
b.cuboid(cx - 0.06, seat[1] - 0.12, 0.84 * h, cx + 0.06, seat[1] + 0.08, 0.84 * h + 0.04, TYRE);
|
||||
}
|
||||
|
||||
/// Alle Platzierungen einer Instanz in Weltkoordinaten (Modell-x/y, z = absolute Höhe).
|
||||
fn place(meshes: &[Mesh3], at: [f64; 2], rot: f64, base: f64) -> Vec<Mesh3> {
|
||||
let (c, s) = (cos(rot), sin(rot));
|
||||
meshes
|
||||
.iter()
|
||||
.map(|m| Mesh3 {
|
||||
positions: m.positions.chunks_exact(3).flat_map(|q| [at[0] + q[0] * c - q[1] * s, at[1] + q[0] * s + q[1] * c, base + q[2]]).collect(),
|
||||
indices: m.indices.clone(),
|
||||
color: m.color,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Netze aller Bibliotheks-Instanzen mit 3D-Netz: `(Index in Project::drawings2d, Teile in Weltkoordinaten)`.
|
||||
/// Unbekannte Ids, Objekte ohne Netz und unbrauchbare Lagen entfallen.
|
||||
pub fn placed(p: &Project) -> Vec<(usize, Vec<Mesh3>)> {
|
||||
let none = BTreeMap::new();
|
||||
let mut out = Vec::new();
|
||||
// Gelände einmal holen, wenn es Instanzen gibt (wie `tree::bases`: sichtbares Netz inkl. Baugruben).
|
||||
let mut site: Option<Option<std::rc::Rc<crate::excavation::SiteTerrain>>> = None;
|
||||
for (i, d) in p.drawings2d.iter().enumerate() {
|
||||
let Drawing2DGeom::Libobj { lib_id, at, rotation, params, seed } = &d.geom else { continue };
|
||||
if !(at.x.is_finite() && at.y.is_finite() && rotation.is_finite()) {
|
||||
continue;
|
||||
}
|
||||
let local = crate::furniture_lib::geometry3d_for(lib_id, params.as_ref().unwrap_or(&none), seed.unwrap_or(0));
|
||||
if local.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let floor = p.floor(&d.level_id).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0));
|
||||
let st = site.get_or_insert_with(|| crate::excavation::terrains(p).into_iter().next().map(|t| crate::excavation::site_terrain(p, t)).filter(|st| !st.current().tris.is_empty()));
|
||||
let ground = st.as_ref().and_then(|st| st.index_current().z_at(at.x, at.y).map(|z| z - st.datum)).filter(|z| z.is_finite());
|
||||
out.push((i, place(&local, [at.x, at.y], *rotation, ground.unwrap_or(floor))));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Kopie des Projekts für Ansichten, die nur Netze aus `Project::context` kennen (3D-Dokument, `plan/axo.rs`): die Teilnetze der
|
||||
/// Entourage als `ImportedMesh` mit Klasse und Id der Zeichnung angehängt; `context = false` lässt die übrigen Netze des Kontexts
|
||||
/// weg (nur Entourage). `None`, wenn das Projekt keine Entourage hat.
|
||||
pub fn with_context_meshes(p: &Project, context: bool) -> Option<Project> {
|
||||
let placed = placed(p);
|
||||
if placed.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let mut q = p.clone();
|
||||
let mut ctx = q.context.take().unwrap_or_default();
|
||||
if !context {
|
||||
ctx.retain(|c| !matches!(c, crate::model::ContextObject::ImportedMesh(_)));
|
||||
}
|
||||
let hex = |c: [f64; 3]| format!("#{:02x}{:02x}{:02x}", (c[0] * 255.0).round() as u8, (c[1] * 255.0).round() as u8, (c[2] * 255.0).round() as u8);
|
||||
for (i, parts) in placed {
|
||||
let d = &p.drawings2d[i];
|
||||
for m in parts {
|
||||
ctx.push(crate::model::ContextObject::ImportedMesh(crate::model::ImportedMesh {
|
||||
id: d.id.clone(),
|
||||
name: d.id.clone(),
|
||||
category_code: d.category_code.clone(),
|
||||
color: Some(hex(m.color)),
|
||||
positions: m.positions,
|
||||
indices: m.indices.iter().map(|&k| k as f64).collect(),
|
||||
..Default::default()
|
||||
}));
|
||||
}
|
||||
}
|
||||
q.context = Some(ctx);
|
||||
Some(q)
|
||||
}
|
||||
|
||||
/// Schattenwerfer: je Teilnetz die Eckpunkte als Wolke (konvexe Hülle ihres Schattens), wie die Baumkrone.
|
||||
pub fn clouds(p: &Project) -> Vec<Vec<[f64; 3]>> {
|
||||
placed(p).into_iter().flat_map(|(_, parts)| parts).map(|m| m.positions.chunks_exact(3).map(|q| [q[0], q[1], q[2]]).collect()).collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::furniture_lib::{self, all};
|
||||
use serde_json::json;
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn params(kv: &[(&str, f64)]) -> BTreeMap<String, serde_json::Value> {
|
||||
kv.iter().map(|(k, v)| (k.to_string(), json!(v))).collect()
|
||||
}
|
||||
|
||||
/// Jede Kante kommt genau einmal je Richtung vor (geschlossen, orientiert) und das Volumen ist positiv (Wicklung nach aussen).
|
||||
fn assert_closed(m: &Mesh3, what: &str) {
|
||||
let mut edges: HashMap<(u32, u32), i32> = HashMap::new();
|
||||
for t in m.indices.chunks_exact(3) {
|
||||
for (a, b) in [(t[0], t[1]), (t[1], t[2]), (t[2], t[0])] {
|
||||
*edges.entry((a, b)).or_default() += 1;
|
||||
}
|
||||
}
|
||||
for (&(a, b), &n) in &edges {
|
||||
assert_eq!(n, 1, "{what}: Kante {a}->{b} {n}x");
|
||||
assert_eq!(edges.get(&(b, a)), Some(&1), "{what}: Kante {a}->{b} ohne Gegenkante");
|
||||
}
|
||||
let q = |i: u32| {
|
||||
let i = i as usize * 3;
|
||||
[m.positions[i], m.positions[i + 1], m.positions[i + 2]]
|
||||
};
|
||||
let vol: f64 = m
|
||||
.indices
|
||||
.chunks_exact(3)
|
||||
.map(|t| {
|
||||
let (a, b, c) = (q(t[0]), q(t[1]), q(t[2]));
|
||||
(a[0] * (b[1] * c[2] - b[2] * c[1]) - a[1] * (b[0] * c[2] - b[2] * c[0]) + a[2] * (b[0] * c[1] - b[1] * c[0])) / 6.0
|
||||
})
|
||||
.sum();
|
||||
assert!(vol > 1e-7, "{what}: Volumen {vol}");
|
||||
assert!(m.positions.iter().all(|v| v.is_finite()));
|
||||
}
|
||||
|
||||
fn zrange(parts: &[Mesh3]) -> (f64, f64) {
|
||||
let z: Vec<f64> = parts.iter().flat_map(|m| m.positions.chunks_exact(3).map(|q| q[2])).collect();
|
||||
(z.iter().cloned().fold(f64::INFINITY, f64::min), z.iter().cloned().fold(f64::NEG_INFINITY, f64::max))
|
||||
}
|
||||
|
||||
fn tris(parts: &[Mesh3]) -> usize {
|
||||
parts.iter().map(|m| m.indices.len() / 3).sum()
|
||||
}
|
||||
|
||||
fn with_3d() -> Vec<&'static str> {
|
||||
all().iter().filter(|o| o.has_3d()).map(|o| o.def().id).collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn objects_with_3d_are_the_entourage_set() {
|
||||
let ids = with_3d();
|
||||
for want in ["lib:person-stehend", "lib:person-gehend", "lib:velo", "lib:auto", "lib:sitzbank", "lib:stuhl", "lib:tisch-80x140", "lib:tisch-rund-120"] {
|
||||
assert!(ids.contains(&want), "{want}");
|
||||
}
|
||||
// Sanitär, Küche, Betten … bleiben 2D.
|
||||
assert!(!ids.contains(&"lib:wc-wand") && !ids.contains(&"lib:bett-90"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_3d_part_is_closed_with_outward_winding() {
|
||||
for id in with_3d() {
|
||||
for seed in [0, 5] {
|
||||
let g = furniture_lib::geometry3d_for(id, ¶ms(&[("mess", 1.0)]), seed);
|
||||
assert!(!g.is_empty(), "{id}");
|
||||
for (i, m) in g.iter().enumerate() {
|
||||
assert_closed(m, &format!("{id}[{i}]"));
|
||||
assert_closed(&m.mirrored(), &format!("{id}[{i}] gespiegelt"));
|
||||
}
|
||||
let (lo, _) = zrange(&g);
|
||||
assert!(lo > -1e-9, "{id}: unter dem Fuss {lo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn height_follows_the_parameter() {
|
||||
let top = |id: &str, h: Option<f64>| {
|
||||
let m = h.map_or_else(BTreeMap::new, |h| params(&[("h", h)]));
|
||||
zrange(&furniture_lib::geometry3d_for(id, &m, 0)).1
|
||||
};
|
||||
// Person: Vorgabe 1.75 m, einstellbar.
|
||||
assert!((top("lib:person-stehend", None) - 1.75).abs() < 1e-9);
|
||||
assert!((top("lib:person-gehend", None) - 1.75).abs() < 1e-9);
|
||||
assert!((top("lib:person-stehend", Some(1.5)) - 1.5).abs() < 1e-9);
|
||||
assert!((top("lib:person-stehend", Some(9.0)) - 2.2).abs() < 1e-9, "auf die Grenze geklemmt");
|
||||
// Auto: Dachhöhe, Velo: Lenker, Bank: Rückenlehne = Sitzhöhe + 0.40, Tisch: Plattenhöhe.
|
||||
assert!((top("lib:auto", None) - 1.45).abs() < 1e-9);
|
||||
assert!((top("lib:velo", None) - 1.05).abs() < 1e-9, "{}", top("lib:velo", None));
|
||||
assert!((top("lib:sitzbank", None) - 0.85).abs() < 1e-9);
|
||||
assert!((top("lib:sitzbank", Some(0.5)) - 0.90).abs() < 1e-9);
|
||||
assert!((top("lib:tisch-80x140-leer", None) - 0.75).abs() < 1e-9);
|
||||
assert!((top("lib:tisch-rund-100-leer", Some(0.9)) - 0.9).abs() < 1e-9);
|
||||
// Mit Stühlen bleibt die Lehne (0.90) der höchste Punkt eines niedrigen Tischs.
|
||||
assert!((top("lib:tisch-80x140", None) - 0.90).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn part_counts_and_triangle_budget() {
|
||||
let n = |id: &str, kv: &[(&str, f64)]| furniture_lib::geometry3d_for(id, ¶ms(kv), 0).len();
|
||||
// Tisch: Platte + 4 Beine; je Stuhl Sitz + 4 Beine + Lehne = 6 Teile.
|
||||
assert_eq!(n("lib:tisch-80x140-leer", &[]), 5);
|
||||
assert_eq!(n("lib:tisch-80x140", &[]), 5 + 6 * 6);
|
||||
assert_eq!(n("lib:tisch-90x180", &[]), 5 + 8 * 6);
|
||||
assert_eq!(n("lib:tisch-80x140", &[("n", 2.0)]), 5 + 2 * 6);
|
||||
assert_eq!(n("lib:tisch-rund-100", &[]), 3 + 4 * 6);
|
||||
assert_eq!(n("lib:stuhl", &[]), 6);
|
||||
// Person: 2 Beine, 2 Arme, Rumpf, Kopf.
|
||||
assert_eq!(n("lib:person-stehend", &[]), 6);
|
||||
assert_eq!(n("lib:auto", &[]), 2 + 4);
|
||||
assert_eq!(n("lib:sitzbank", &[]), 4);
|
||||
// Wenige Dreiecke je Objekt (Low-Poly).
|
||||
for (id, max) in [("lib:person-stehend", 500), ("lib:person-gehend", 500), ("lib:auto", 300), ("lib:velo", 400), ("lib:sitzbank", 80), ("lib:tisch-90x180", 700)] {
|
||||
let t = tris(&furniture_lib::geometry3d_for(id, &BTreeMap::new(), 0));
|
||||
assert!(t > 0 && t <= max, "{id}: {t} Dreiecke");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn walking_has_a_stride_standing_has_not() {
|
||||
let ext = |id: &str| {
|
||||
let g = furniture_lib::geometry3d_for(id, &BTreeMap::new(), 0);
|
||||
let ys: Vec<f64> = g.iter().flat_map(|m| m.positions.chunks_exact(3).map(|q| q[1])).collect();
|
||||
ys.iter().cloned().fold(f64::NEG_INFINITY, f64::max) - ys.iter().cloned().fold(f64::INFINITY, f64::min)
|
||||
};
|
||||
assert!(ext("lib:person-gehend") > ext("lib:person-stehend") + 0.3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chairs_follow_the_2d_layout_and_the_seed() {
|
||||
let xs = |seed: u32| -> Vec<f64> { furniture_lib::geometry3d_for("lib:tisch-80x140", ¶ms(&[("mess", 1.0)]), seed).iter().flat_map(|m| m.positions.clone()).collect() };
|
||||
assert_eq!(xs(3), xs(3));
|
||||
assert_ne!(xs(3), xs(4));
|
||||
// Regelmässig: symmetrisch zum Einfügepunkt (Mitte), wie das 2D-Symbol.
|
||||
let g = furniture_lib::geometry3d_for("lib:tisch-80x140", &BTreeMap::new(), 0);
|
||||
let (mut x0, mut x1) = (f64::MAX, f64::MIN);
|
||||
for m in &g {
|
||||
for q in m.positions.chunks_exact(3) {
|
||||
x0 = x0.min(q[0]);
|
||||
x1 = x1.max(q[0]);
|
||||
}
|
||||
}
|
||||
assert!((x0 + x1).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mirror_flips_x_and_unknown_or_2d_objects_have_no_mesh() {
|
||||
let bx = |m: &BTreeMap<String, serde_json::Value>| {
|
||||
let g = furniture_lib::geometry3d_for("lib:person-gehend", m, 0);
|
||||
let xs: Vec<f64> = g.iter().flat_map(|m| m.positions.chunks_exact(3).map(|q| q[0])).collect();
|
||||
(xs.iter().cloned().fold(f64::INFINITY, f64::min), xs.iter().cloned().fold(f64::NEG_INFINITY, f64::max))
|
||||
};
|
||||
let (a, b) = (bx(&BTreeMap::new()), bx(¶ms(&[("mirror", 1.0)])));
|
||||
assert!((a.0 + b.1).abs() < 1e-9 && (a.1 + b.0).abs() < 1e-9);
|
||||
assert!(furniture_lib::geometry3d_for("lib:gibt-es-nicht", &BTreeMap::new(), 0).is_empty());
|
||||
assert!(furniture_lib::geometry3d_for("lib:wc-wand", &BTreeMap::new(), 0).is_empty());
|
||||
}
|
||||
|
||||
fn project(drawings: serde_json::Value) -> Project {
|
||||
serde_json::from_value(json!({
|
||||
"id": "p", "name": "t", "lineStyles": [], "hatches": [], "components": [], "wallTypes": [], "layers": [], "openings": [], "walls": [],
|
||||
"drawingLevels": [{"id": "F", "name": "EG", "kind": "floor", "visible": true, "locked": false, "floorHeight": 3.0, "baseElevation": 2.0}],
|
||||
"drawings2d": drawings
|
||||
}))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn lib(id: &str, lib_id: &str, x: f64, y: f64, rot: f64) -> serde_json::Value {
|
||||
json!({"id": id, "type": "drawing2d", "levelId": "F", "categoryCode": "24", "geom": {"shape": "libobj", "libId": lib_id, "at": {"x": x, "y": y}, "rotation": rot}})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn placement_uses_floor_height_position_and_rotation() {
|
||||
let p = project(json!([lib("a", "lib:person-stehend", 10.0, 20.0, 0.0), lib("b", "lib:person-stehend", 10.0, 20.0, std::f64::consts::FRAC_PI_2), lib("c", "lib:wc-wand", 0.0, 0.0, 0.0), lib("d", "lib:unbekannt", 0.0, 0.0, 0.0)]));
|
||||
let r = placed(&p);
|
||||
assert_eq!(r.iter().map(|x| x.0).collect::<Vec<_>>(), vec![0, 1], "nur Objekte mit Netz, Index in drawings2d");
|
||||
let (lo, hi) = zrange(&r[0].1);
|
||||
assert!((lo - 2.0).abs() < 1e-9 && (hi - 3.75).abs() < 1e-9, "{lo} {hi}");
|
||||
let bb = |parts: &[Mesh3]| {
|
||||
let (mut x0, mut x1, mut y0, mut y1) = (f64::MAX, f64::MIN, f64::MAX, f64::MIN);
|
||||
for m in parts {
|
||||
for q in m.positions.chunks_exact(3) {
|
||||
x0 = x0.min(q[0]);
|
||||
x1 = x1.max(q[0]);
|
||||
y0 = y0.min(q[1]);
|
||||
y1 = y1.max(q[1]);
|
||||
}
|
||||
}
|
||||
(x0, x1, y0, y1)
|
||||
};
|
||||
let (a, b) = (bb(&r[0].1), bb(&r[1].1));
|
||||
assert!(((a.0 + a.1) / 2.0 - 10.0).abs() < 0.05 && ((a.2 + a.3) / 2.0 - 20.0).abs() < 0.05, "um den Einfügepunkt");
|
||||
// 90° gedreht: Breite und Tiefe tauschen.
|
||||
assert!(((a.1 - a.0) - (b.3 - b.2)).abs() < 1e-9 && ((a.3 - a.2) - (b.1 - b.0)).abs() < 1e-9);
|
||||
// Schatten: je Teilnetz eine Wolke.
|
||||
assert_eq!(clouds(&p).len(), 12);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn entourage_casts_a_shadow() {
|
||||
let p = project(json!([lib("a", "lib:person-stehend", 0.0, 0.0, 0.0)]));
|
||||
let sh = crate::sun::shadow_polygons_project(&p, crate::sun::SunPosition { azimuth: 180.0, elevation: 30.0 }, None);
|
||||
let ys: Vec<f64> = sh.iter().flatten().flatten().map(|q| q[1]).collect();
|
||||
let (lo, hi) = (ys.iter().cloned().fold(f64::INFINITY, f64::min), ys.iter().cloned().fold(f64::NEG_INFINITY, f64::max));
|
||||
// Sonne im Süden, 30°: 1.75 m / tan 30° ≈ 3.03 m nach Norden (+y).
|
||||
// Der Fuss steht bei +2.0 m (Geschoss-UK): Schatten auf z = 0 beginnt 2 / tan 30° ≈ 3.46 m nördlich.
|
||||
assert!((lo - 3.46).abs() < 0.3 && (hi - lo - 3.03).abs() < 0.4, "{lo} {hi}");
|
||||
assert!(crate::sun::shadow_polygons_project(&project(json!([])), crate::sun::SunPosition { azimuth: 180.0, elevation: 30.0 }, None).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nonsense_position_gives_nothing() {
|
||||
let p = project(json!([lib("a", "lib:auto", 1.0, 2.0, 0.0)]));
|
||||
let mut q = p.clone();
|
||||
if let Drawing2DGeom::Libobj { rotation, .. } = &mut q.drawings2d[0].geom {
|
||||
*rotation = f64::NAN;
|
||||
}
|
||||
assert!(placed(&q).is_empty());
|
||||
assert_eq!(placed(&p).len(), 1);
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@
|
||||
//! - **Definition** ([`ObjectDef`]): Id (`lib:wc-wand`), Gruppe, Klasse, Einfügepunkt, Parameterliste ([`ParamDef`]:
|
||||
//! Schlüssel, Art, Vorgabe, Min, Max, Schritt) — nur Daten, daraus baut die Objekt-Info ihre Felder.
|
||||
//! - **Erzeugung** ([`LibObject::geometry`]): `(Parameter, Detailgrad, Seed) → Vec<Drawing2DGeom>`; ausgegeben werden nur
|
||||
//! allgemeine Primitive (Linie, Rechteck, Polylinie, Kreis, Bogen, Ellipse), nie objektspezifische Typen. Platz für eine
|
||||
//! spätere 3D-Erzeugung: weitere Methode am Trait (`geometry3d`), heute nicht umgesetzt.
|
||||
//! allgemeine Primitive (Linie, Rechteck, Polylinie, Kreis, Bogen, Ellipse), nie objektspezifische Typen.
|
||||
//! Einige Objekte haben zusätzlich ein Low-Poly-Netz ([`LibObject::geometry3d`], `furniture_3d.rs`): Entourage im 3D.
|
||||
//! - **Register** ([`find`], [`all`]): die eingebauten Objekte sind die ersten Einträge; eine Benutzerdefinition
|
||||
//! käme als weiterer `LibObject`-Implementierer.
|
||||
//! - **Instanz im Modell**: `Drawing2DGeom::Libobj { libId, at, rotation, params, seed }` — Parameter als offene Map
|
||||
@@ -22,6 +22,7 @@ use std::collections::BTreeMap;
|
||||
use std::f64::consts::{FRAC_PI_2, PI, TAU};
|
||||
use std::sync::OnceLock;
|
||||
|
||||
use crate::furniture_3d::{self as f3, Mesh3, B3};
|
||||
use crate::jsnum::{atan2, cos, sin};
|
||||
|
||||
/// Küchenraster (Schweizer Küchennorm): Modulbreite in m.
|
||||
@@ -153,12 +154,37 @@ pub trait LibObject: Send + Sync {
|
||||
fn def(&self) -> &ObjectDef;
|
||||
/// 2D-Geometrie in lokalen Koordinaten (Einfügepunkt = Ursprung), ohne Spiegelung.
|
||||
fn geometry(&self, p: &Params, detail: Detail, seed: u32) -> Vec<G>;
|
||||
// Später (3D nach 1.0): `fn geometry3d(&self, p: &Params) -> Option<Solid3D>`.
|
||||
/// 3D-Netz (Entourage, `furniture_3d.rs`) in denselben lokalen Koordinaten wie `geometry`, z = Höhe über dem Fuss,
|
||||
/// ohne Spiegelung. Leer = das Objekt hat nur das 2D-Symbol.
|
||||
fn geometry3d(&self, _p: &Params, _seed: u32) -> Vec<Mesh3> {
|
||||
Vec::new()
|
||||
}
|
||||
/// Das Objekt hat ein 3D-Netz.
|
||||
fn has_3d(&self) -> bool {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/// 3D-Erzeugung eines Objekts: Parameter, Stuhl-Plätze `(x, y, Drehung)` aus dem 2D-Symbol, Sammler.
|
||||
type Gen3 = fn(&Params, &[(f64, f64, f64)], &mut B3);
|
||||
|
||||
struct Builtin {
|
||||
def: ObjectDef,
|
||||
gen: fn(&Params, Detail, u32, &mut Sh),
|
||||
gen3: Option<Gen3>,
|
||||
}
|
||||
|
||||
impl Builtin {
|
||||
fn with3d(mut self, g: Gen3) -> Builtin {
|
||||
self.gen3 = Some(g);
|
||||
self
|
||||
}
|
||||
fn origin(&self, p: &Params) -> (f64, f64) {
|
||||
match self.def.anchor {
|
||||
Anchor::Wall => (-p.w / 2.0, 0.0),
|
||||
Anchor::Center => (-p.w / 2.0, -p.d / 2.0),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LibObject for Builtin {
|
||||
@@ -166,14 +192,24 @@ impl LibObject for Builtin {
|
||||
&self.def
|
||||
}
|
||||
fn geometry(&self, p: &Params, detail: Detail, seed: u32) -> Vec<G> {
|
||||
let (ox, oy) = match self.def.anchor {
|
||||
Anchor::Wall => (-p.w / 2.0, 0.0),
|
||||
Anchor::Center => (-p.w / 2.0, -p.d / 2.0),
|
||||
};
|
||||
let mut sh = Sh { out: Vec::new(), ox, oy };
|
||||
let (ox, oy) = self.origin(p);
|
||||
let mut sh = Sh { out: Vec::new(), ox, oy, chairs: Vec::new() };
|
||||
(self.gen)(p, detail, seed, &mut sh);
|
||||
sh.out
|
||||
}
|
||||
fn has_3d(&self) -> bool {
|
||||
self.gen3.is_some()
|
||||
}
|
||||
fn geometry3d(&self, p: &Params, seed: u32) -> Vec<Mesh3> {
|
||||
let Some(g3) = self.gen3 else { return Vec::new() };
|
||||
// Stuhl-Plätze (mit Unordnung nach Seed) aus dem 2D-Lauf übernehmen: ein Ort für die Anordnung.
|
||||
let (ox, oy) = self.origin(p);
|
||||
let mut sh = Sh { out: Vec::new(), ox, oy, chairs: Vec::new() };
|
||||
(self.gen)(p, Detail::Grob, seed, &mut sh);
|
||||
let mut b = B3::new(ox, oy);
|
||||
g3(p, &sh.chairs, &mut b);
|
||||
b.parts
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectDef {
|
||||
@@ -218,7 +254,7 @@ const MIRROR: &str = "mirror";
|
||||
pub fn placeholder(params: &BTreeMap<String, Value>) -> Vec<G> {
|
||||
let num = |k: &str| params.get(k).and_then(Value::as_f64).filter(|x| x.is_finite() && *x > 0.0).unwrap_or(0.5).min(50.0);
|
||||
let (w, d) = (num("w"), num("d"));
|
||||
let mut sh = Sh { out: Vec::new(), ox: -w / 2.0, oy: -d / 2.0 };
|
||||
let mut sh = Sh { out: Vec::new(), ox: -w / 2.0, oy: -d / 2.0, chairs: Vec::new() };
|
||||
sh.rect(0.0, 0.0, w, d);
|
||||
sh.line(0.0, 0.0, w, d);
|
||||
sh.line(0.0, d, w, 0.0);
|
||||
@@ -236,6 +272,17 @@ pub fn geometry_for(lib_id: &str, params: &BTreeMap<String, Value>, detail: Deta
|
||||
g
|
||||
}
|
||||
|
||||
/// 3D-Netz einer Instanz (Parameter, Spiegeln wie im 2D). Leer bei unbekannter Id und bei Objekten ohne Netz.
|
||||
pub fn geometry3d_for(lib_id: &str, params: &BTreeMap<String, Value>, seed: u32) -> Vec<Mesh3> {
|
||||
let Some(o) = find(lib_id) else { return Vec::new() };
|
||||
let p = o.def().resolve(params);
|
||||
let g = o.geometry3d(&p, seed);
|
||||
if params.get(MIRROR).is_some_and(|v| v.as_bool() == Some(true) || v.as_f64().is_some_and(|x| x >= 0.5)) {
|
||||
return g.iter().map(Mesh3::mirrored).collect();
|
||||
}
|
||||
g
|
||||
}
|
||||
|
||||
/// Spiegelung an der y-Achse (x → −x).
|
||||
fn mirror_x(g: &G) -> G {
|
||||
let m = |q: &Vec2| Vec2 { x: -q.x, y: q.y };
|
||||
@@ -270,7 +317,7 @@ pub fn catalog_json() -> Value {
|
||||
params.push(json!({"key": MIRROR, "kind": "flag", "default": 0, "min": 0, "max": 1, "step": 1}));
|
||||
json!({
|
||||
"id": d.id, "group": d.group, "category": d.cat.key(), "categoryCode": d.cat.code(), "categoryName": d.cat.name(),
|
||||
"anchor": if d.anchor == Anchor::Wall { "wall" } else { "center" }, "seeded": d.seeded, "params": params,
|
||||
"anchor": if d.anchor == Anchor::Wall { "wall" } else { "center" }, "seeded": d.seeded, "model3d": o.has_3d(), "params": params,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
@@ -285,6 +332,8 @@ struct Sh {
|
||||
out: Vec<G>,
|
||||
ox: f64,
|
||||
oy: f64,
|
||||
/// Stuhl-Plätze `(x, y, Drehung)` in Kastenkoordinaten (für das 3D-Netz).
|
||||
chairs: Vec<(f64, f64, f64)>,
|
||||
}
|
||||
|
||||
impl Sh {
|
||||
@@ -583,6 +632,7 @@ const CHAIR_GAP: f64 = 0.03;
|
||||
|
||||
/// Stuhl, lokal: Rückenlehne bei y = −d/2, Blick +y.
|
||||
fn chair_at(sh: &mut Sh, dt: Detail, cx: f64, cy: f64, rot: f64) {
|
||||
sh.chairs.push((cx, cy, rot));
|
||||
let (hw, hd) = (CHAIR_W / 2.0, CHAIR_D / 2.0);
|
||||
sh.rot_rect(cx, cy, hw, hd, rot);
|
||||
if mid(dt) {
|
||||
@@ -812,6 +862,33 @@ fn car(p: &Params, dt: Detail, sh: &mut Sh) {
|
||||
}
|
||||
}
|
||||
|
||||
fn bench_2d(p: &Params, dt: Detail, sh: &mut Sh) {
|
||||
let (w, d) = (p.w, p.d);
|
||||
sh.rect(0.0, 0.0, w, d);
|
||||
if mid(dt) {
|
||||
sh.line(0.0, d * 0.15, w, d * 0.15);
|
||||
}
|
||||
if fine(dt) {
|
||||
for i in 1..6 {
|
||||
sh.line(w * i as f64 / 6.0, d * 0.15, w * i as f64 / 6.0, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Person von oben: Schultern (Ellipse), Kopf (Kreis) in der Mitte; mittel: Nase/Blickrichtung +y.
|
||||
fn person_2d(p: &Params, dt: Detail, sh: &mut Sh) {
|
||||
let (cx, cy) = (p.w / 2.0, p.d / 2.0);
|
||||
sh.ellipse(cx, cy, p.w / 2.0, (p.d / 2.0).min(0.18));
|
||||
sh.circle(cx, cy + 0.01, 0.09);
|
||||
if mid(dt) {
|
||||
sh.line(cx, cy + 0.10, cx, cy + 0.15);
|
||||
}
|
||||
if fine(dt) {
|
||||
sh.line(cx - p.w / 2.0 + 0.02, cy, cx - p.w / 2.0 + 0.02, cy + 0.08);
|
||||
sh.line(cx + p.w / 2.0 - 0.02, cy, cx + p.w / 2.0 - 0.02, cy + 0.08);
|
||||
}
|
||||
}
|
||||
|
||||
fn parking(p: &Params, _dt: Detail, sh: &mut Sh) {
|
||||
sh.rect(0.0, 0.0, p.w, p.d);
|
||||
}
|
||||
@@ -859,7 +936,7 @@ fn wd(w: f64, d: f64) -> Vec<ParamDef> {
|
||||
}
|
||||
|
||||
fn ent(id: &'static str, group: &'static str, cat: Cat, anchor: Anchor, params: Vec<ParamDef>, gen: fn(&Params, Detail, u32, &mut Sh)) -> Builtin {
|
||||
Builtin { def: ObjectDef { id, group, cat, anchor, params, seeded: false, round: false, modular: false }, gen }
|
||||
Builtin { def: ObjectDef { id, group, cat, anchor, params, seeded: false, round: false, modular: false }, gen, gen3: None }
|
||||
}
|
||||
|
||||
fn build() -> Vec<Builtin> {
|
||||
@@ -870,7 +947,8 @@ fn build() -> Vec<Builtin> {
|
||||
let mut params = if round { vec![len("w", w, 0.4, 3.0)] } else { wd(w, d) };
|
||||
params.push(count("n", n, 0.0, 12.0));
|
||||
params.push(frac("mess", 0.0));
|
||||
let mut b = ent(id, "tables", F, Center, params, gen);
|
||||
params.push(len("h", 0.75, 0.4, 1.2));
|
||||
let mut b = ent(id, "tables", F, Center, params, gen).with3d(if round { f3::round_table } else { f3::rect_table });
|
||||
b.def.seeded = true;
|
||||
b.def.round = round;
|
||||
b
|
||||
@@ -916,7 +994,7 @@ fn build() -> Vec<Builtin> {
|
||||
v.extend(tables);
|
||||
|
||||
// Sitzen
|
||||
v.push(ent("lib:stuhl", "seating", F, Center, wd(0.45, 0.50), |p, dt, _, sh| chair(p, dt, sh)));
|
||||
v.push(ent("lib:stuhl", "seating", F, Center, wd(0.45, 0.50), |p, dt, _, sh| chair(p, dt, sh)).with3d(f3::single_chair));
|
||||
v.push(ent("lib:sofa-2", "seating", F, Wall, wd(1.60, 0.90), |p, dt, _, sh| sofa(p, dt, sh)));
|
||||
v.push(ent("lib:sofa-3", "seating", F, Wall, wd(2.10, 0.90), |p, dt, _, sh| sofa(p, dt, sh)));
|
||||
v.push(ent("lib:sessel", "seating", F, Wall, wd(0.80, 0.80), |p, dt, _, sh| armchair(p, dt, sh)));
|
||||
@@ -938,9 +1016,20 @@ fn build() -> Vec<Builtin> {
|
||||
// Aussenraum
|
||||
let mut car_params = wd(1.80, 4.70);
|
||||
car_params.push(flag("field", 1.0));
|
||||
v.push(ent("lib:auto", "outdoor", O, Center, car_params, |p, dt, _, sh| car(p, dt, sh)));
|
||||
car_params.push(len("h", 1.45, 1.0, 2.2));
|
||||
v.push(ent("lib:auto", "outdoor", O, Center, car_params, |p, dt, _, sh| car(p, dt, sh)).with3d(f3::car));
|
||||
v.push(ent("lib:parkfeld", "outdoor", O, Center, wd(2.50, 5.00), |p, dt, _, sh| parking(p, dt, sh)));
|
||||
v.push(ent("lib:velo", "outdoor", O, Center, wd(0.60, 1.80), |p, dt, _, sh| bike(p, dt, sh)));
|
||||
let mut bike_params = wd(0.60, 1.80);
|
||||
bike_params.push(len("h", 1.05, 0.7, 1.4));
|
||||
v.push(ent("lib:velo", "outdoor", O, Center, bike_params, |p, dt, _, sh| bike(p, dt, sh)).with3d(f3::bike));
|
||||
let mut bench_params = wd(1.80, 0.50);
|
||||
bench_params.push(len("h", 0.45, 0.3, 0.6));
|
||||
v.push(ent("lib:sitzbank", "outdoor", O, Center, bench_params, |p, dt, _, sh| bench_2d(p, dt, sh)).with3d(f3::bench));
|
||||
for (id, d, walking) in [("lib:person-stehend", 0.35, false), ("lib:person-gehend", 0.70, true)] {
|
||||
let mut params = wd(0.50, d);
|
||||
params.push(len("h", f3::PERSON_H, 0.5, 2.2));
|
||||
v.push(ent(id, "outdoor", O, Center, params, |p, dt, _, sh| person_2d(p, dt, sh)).with3d(if walking { f3::person_walking } else { f3::person_standing }));
|
||||
}
|
||||
let mut wc_circle = ent("lib:wendekreis", "outdoor", O, Center, vec![len("w", 1.5, 0.5, 3.0)], |p, dt, _, sh| wheelchair_circle(p, dt, sh));
|
||||
wc_circle.def.round = true;
|
||||
v.push(wc_circle);
|
||||
@@ -1023,6 +1112,9 @@ mod tests {
|
||||
for o in all() {
|
||||
let d = o.def();
|
||||
// Objekte ohne Zusatzgeometrie über das Mass hinaus (Stühle, Parkfeld, Spiegel, Scheinwerfer).
|
||||
if d.id.starts_with("lib:person-") {
|
||||
continue; // Symbol = Schultern; die Tiefe `d` ist der Schrittraum fürs 3D
|
||||
}
|
||||
if d.id.contains("tisch-") && !d.id.ends_with("-leer") && d.id != "lib:tisch-buero" || d.id == "lib:tisch-buero" {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -153,6 +153,7 @@ pub mod surface_pattern;
|
||||
pub mod surface_pattern3d;
|
||||
pub mod standards;
|
||||
pub mod standards_names;
|
||||
pub mod furniture_3d;
|
||||
pub mod furniture_lib;
|
||||
pub mod dim_assoc;
|
||||
pub mod opening_slide;
|
||||
|
||||
@@ -506,6 +506,17 @@ pub(crate) fn collect_scene(src: &Project, opt: &MeshOptions) -> Result<SceneDat
|
||||
groups.push(g);
|
||||
}
|
||||
p.trees = trees;
|
||||
// [253] Entourage: je Bibliotheksobjekt mit 3D-Netz eine Gruppe.
|
||||
let drawings = std::mem::take(&mut p.drawings2d);
|
||||
for d in drawings.iter().filter(|d| matches!(d.geom, Drawing2DGeom::Libobj { .. })) {
|
||||
let mut g = Group::new(format!("Entourage_{}", sanitize_name(&d.id)), "entourage", &d.id, level_of(Some(&d.level_id)));
|
||||
p.drawings2d = vec![d.clone()];
|
||||
add_meshes(&mut g, &mut mats, &model3d::emit_entourage(&p), "Entourage");
|
||||
if !g.prims.is_empty() {
|
||||
groups.push(g);
|
||||
}
|
||||
}
|
||||
p.drawings2d = drawings;
|
||||
// [279] Geländer: je Geländer eine Gruppe.
|
||||
let railings = p.railings.take();
|
||||
for r in railings.as_deref().unwrap_or(&[]) {
|
||||
|
||||
@@ -40,6 +40,8 @@ pub enum Owner {
|
||||
Context(usize),
|
||||
/// [115] Index in `Project::extruded_solids`.
|
||||
Solid(usize),
|
||||
/// [253] Index in `Project::drawings2d` (Entourage: Bibliotheksobjekt mit 3D-Netz).
|
||||
Drawing(usize),
|
||||
}
|
||||
|
||||
impl Owner {
|
||||
@@ -58,6 +60,7 @@ impl Owner {
|
||||
Owner::Stair(i) => at(&p.stairs, i).map(|e| e.id.as_str()),
|
||||
Owner::Context(i) => at(&p.context, i).map(|e| e.id()),
|
||||
Owner::Solid(i) => at(&p.extruded_solids, i).map(|e| e.id.as_str()),
|
||||
Owner::Drawing(i) => p.drawings2d.get(i).map(|d| d.id.as_str()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -352,6 +355,7 @@ pub fn parts_filtered(p: &Project, layered: bool, detail: f64, for_section: bool
|
||||
column_meshes: {
|
||||
let mut m = emit_columns(p);
|
||||
m.extend(emit_trees(p));
|
||||
m.extend(emit_entourage(p));
|
||||
m.extend(emit_railings(p));
|
||||
m
|
||||
},
|
||||
|
||||
@@ -192,6 +192,18 @@ pub fn emit_trees(p: &Project) -> Vec<RMesh> {
|
||||
out
|
||||
}
|
||||
|
||||
/// [253] Entourage: Bibliotheksobjekte mit 3D-Netz (Person, Auto, Velo, Bank, Tische mit Stühlen, `furniture_3d.rs`) als
|
||||
/// Meshes, je Teilnetz eines; Herkunft = die Zeichnung (Klasse und Ausblenden wie die der Zeichnung, [180]).
|
||||
pub fn emit_entourage(p: &Project) -> Vec<RMesh> {
|
||||
let mut out = Vec::new();
|
||||
for (i, parts) in crate::furniture_3d::placed(p) {
|
||||
for m in parts {
|
||||
out.push(RMesh { crease_angle: None, positions: m.positions, indices: m.indices, kind: "extrusion", color: m.color, vertex_colors: None, material_index: None, owner: Owner::Drawing(i) });
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// [149] Bäume als Welt-Dreiecke (Stamm + Krone, wie [`emit_trees`]) für den 3D-Pick.
|
||||
pub fn pick_trees(p: &Project) -> Vec<PickTree> {
|
||||
let trees = p.trees.as_deref().unwrap_or(&[]);
|
||||
|
||||
@@ -1163,3 +1163,27 @@ fn slice_x_quader_bleibt_geschlossen() {
|
||||
assert!(m.positions.chunks_exact(3).all(|c| [0.0, 0.25, 0.6, 1.0].iter().any(|x| (c[0] - x).abs() < 1e-12)));
|
||||
assert!(m.positions.chunks_exact(3).any(|c| c[0] == 0.25) && m.positions.chunks_exact(3).any(|c| c[0] == 0.6));
|
||||
}
|
||||
|
||||
/// [253] Entourage im 3D: Bibliotheksobjekte mit Netz kommen als Meshes bei den Stützen, Herkunft = Zeichnung; die Klasse
|
||||
/// der Zeichnung und das Ausblenden der Id wirken wie bei jedem Element; Objekte ohne Netz (WC) liefern nichts.
|
||||
#[test]
|
||||
fn entourage_im_3d_klasse_und_filter() {
|
||||
let mut p = sample();
|
||||
let lv = p.drawing_levels[0].id.clone();
|
||||
let n0 = parts(&p, true, 1.0, false).unwrap().column_meshes.len();
|
||||
let d = |v: serde_json::Value| -> Drawing2D { serde_json::from_value(v).unwrap() };
|
||||
p.drawings2d.push(d(serde_json::json!({"id": "pers1", "type": "drawing2d", "levelId": lv, "categoryCode": "24", "geom": {"shape": "libobj", "libId": "lib:person-stehend", "at": {"x": 4.0, "y": -3.0}, "rotation": 0.5}})));
|
||||
p.drawings2d.push(d(serde_json::json!({"id": "wc1", "type": "drawing2d", "levelId": lv, "categoryCode": "23", "geom": {"shape": "libobj", "libId": "lib:wc-wand", "at": {"x": 1.0, "y": 1.0}, "rotation": 0.0}})));
|
||||
let m = parts(&p, true, 1.0, false).unwrap().column_meshes;
|
||||
assert_eq!(m.len(), n0 + 6, "Person = Rumpf, Kopf, 2 Beine, 2 Arme; WC nur 2D");
|
||||
let idx = p.drawings2d.iter().position(|x| x.id == "pers1").unwrap();
|
||||
assert!(m[n0..].iter().all(|x| x.owner == Owner::Drawing(idx) && x.owner.id(&p) == Some("pers1")));
|
||||
let zmax = m[n0..].iter().flat_map(|x| x.positions.chunks_exact(3).map(|q| q[2])).fold(f64::NEG_INFINITY, f64::max);
|
||||
let base = p.floor(&lv).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0));
|
||||
assert!((zmax - (base + 1.75)).abs() < 1e-9, "{zmax}");
|
||||
// Klasse „24" aus: weg; Id ausgeblendet: weg.
|
||||
let f = ClassFilter::new(&p, &["24".to_string()]);
|
||||
assert_eq!(parts_filtered(&p, true, 1.0, false, &f).unwrap().column_meshes.len(), n0);
|
||||
let f = ClassFilter::from_text(&p, r#"{"hideIds": ["pers1"]}"#);
|
||||
assert_eq!(parts_filtered(&p, true, 1.0, false, &f).unwrap().column_meshes.len(), n0);
|
||||
}
|
||||
@@ -178,6 +178,22 @@ struct RestKey {
|
||||
for_section: bool,
|
||||
walls: Vec<u64>,
|
||||
openings: Vec<u64>,
|
||||
/// [253] Stand der Bibliotheksobjekte mit 3D-Netz (`drawings2d` ist sonst kein globales Feld).
|
||||
entourage: u64,
|
||||
}
|
||||
|
||||
/// [253] Inhalts-Stand der Bibliotheksobjekte (Id, Geschoss, Geometrie): ändert sich nur, wenn eines davon sich ändert.
|
||||
fn entourage_stamp(p: &Project) -> u64 {
|
||||
use std::hash::{Hash, Hasher};
|
||||
let mut h = std::collections::hash_map::DefaultHasher::new();
|
||||
for d in &p.drawings2d {
|
||||
if matches!(d.geom, crate::model::Drawing2DGeom::Libobj { .. }) {
|
||||
d.id.hash(&mut h);
|
||||
d.level_id.hash(&mut h);
|
||||
serde_json::to_string(&d.geom).unwrap_or_default().hash(&mut h);
|
||||
}
|
||||
}
|
||||
h.finish()
|
||||
}
|
||||
|
||||
/// Ergebnis: die Teile (Wände/Öffnungen nur mit `structs`) und das JSON wie `serde_json::to_string(&parts)`.
|
||||
@@ -208,7 +224,7 @@ impl Model3dCache {
|
||||
let maps = model3d::wall_material_color_maps(p);
|
||||
if self.sig != Some(sig) || self.maps != maps {
|
||||
// [214] Übrige Gruppen behalten (zum Vergleich), aber nicht als Treffer: `RestKey` ohne Stände.
|
||||
let rest = std::mem::take(&mut self.rest).map(|r| r.map(|(k, r)| (RestKey { for_section: k.for_section, walls: Vec::new(), openings: vec![u64::MAX] }, r)));
|
||||
let rest = std::mem::take(&mut self.rest).map(|r| r.map(|(k, r)| (RestKey { for_section: k.for_section, walls: Vec::new(), openings: vec![u64::MAX], entourage: 0 }, r)));
|
||||
let groups = std::mem::take(&mut self.groups);
|
||||
let tails = std::mem::take(&mut self.tails);
|
||||
*self = Model3dCache {
|
||||
@@ -404,7 +420,7 @@ impl Model3dCache {
|
||||
|
||||
// [214] Übrige Gruppen: aus `rest`, solange Stände und Variante gleich sind (sonst neu, mit den schon
|
||||
// bekannten Schnittlinien fürs Deckenauflager).
|
||||
let key = RestKey { for_section, walls: wall_stamps.to_vec(), openings: opening_stamps.to_vec() };
|
||||
let key = RestKey { for_section, walls: wall_stamps.to_vec(), openings: opening_stamps.to_vec(), entourage: entourage_stamp(p) };
|
||||
let var = for_section as usize;
|
||||
self.last_rest_hit = matches!(&self.rest[var], Some((k, _)) if *k == key);
|
||||
self.last_groups_changed = 0;
|
||||
@@ -417,7 +433,7 @@ impl Model3dCache {
|
||||
slabs,
|
||||
context_meshes: model3d::emit_context_meshes(p),
|
||||
solid_meshes: model3d::emit_solids(p),
|
||||
column_meshes: { let mut m = model3d::emit_columns(p); m.extend(model3d::emit_trees(p)); m.extend(model3d::emit_railings(p)); m },
|
||||
column_meshes: { let mut m = model3d::emit_columns(p); m.extend(model3d::emit_trees(p)); m.extend(model3d::emit_entourage(p)); m.extend(model3d::emit_railings(p)); m },
|
||||
opening_meshes: Vec::new(),
|
||||
stair_meshes: model3d::emit_stair_meshes(p),
|
||||
stair_railings: model3d::emit_stair_railings(p),
|
||||
@@ -1052,6 +1068,34 @@ mod tests {
|
||||
assert!(!d.model3d_rest_hit(), "Wand geändert");
|
||||
}
|
||||
|
||||
/// [253] Bibliotheksobjekte (`drawings2d`) sind sonst kein globales Feld: ein neues Objekt mit 3D-Netz muss die
|
||||
/// übrigen Gruppen trotzdem neu rechnen, ein Objekt ohne Netz nicht.
|
||||
#[test]
|
||||
fn entourage_im_cache() {
|
||||
let mut d = sample();
|
||||
let q = |d: &mut Document| d.model3d_parts_with(true, 2.0, false, false, None, "").unwrap().json;
|
||||
let a = q(&mut d);
|
||||
let lv = list(&d, "drawingLevels")[0]["id"].clone();
|
||||
let add = |d: &mut Document, lib: &str| {
|
||||
let it = json!({"id": "x1", "type": "drawing2d", "levelId": lv, "categoryCode": "24", "geom": {"shape": "libobj", "libId": lib, "at": {"x": 1.0, "y": -2.0}, "rotation": 0.0}});
|
||||
d.commit(vec![Op::Add { collection: "drawings2d".into(), items: vec![it], at: None }], None, 0.0, false).unwrap();
|
||||
};
|
||||
add(&mut d, "lib:wc-wand");
|
||||
assert_eq!(q(&mut d), a, "WC hat kein Netz");
|
||||
d.commit(vec![Op::Remove { collection: "drawings2d".into(), ids: vec!["x1".into()] }], None, 0.0, false).unwrap();
|
||||
add(&mut d, "lib:auto");
|
||||
let b = q(&mut d);
|
||||
assert_ne!(a, b);
|
||||
assert!(!d.model3d_rest_hit(), "neu gerechnet");
|
||||
// Verschieben: neu; unverändert: Treffer.
|
||||
let mut it = list(&d, "drawings2d").into_iter().find(|x| x["id"] == "x1").unwrap();
|
||||
it["geom"]["at"]["x"] = json!(5.0);
|
||||
d.commit(vec![Op::Replace { collection: "drawings2d".into(), entity: it }], None, 0.0, false).unwrap();
|
||||
assert_ne!(q(&mut d), b);
|
||||
q(&mut d);
|
||||
assert!(d.model3d_rest_hit());
|
||||
}
|
||||
|
||||
/// [214] Übrige Gruppen mit Laufnummer: Eine Wand-Änderung schickt nur Gruppen, deren Inhalt sich geändert hat
|
||||
/// (sonst `null`), ein zweiter Filter (Geisterschicht) im Wechsel schickt nichts noch einmal, und eine Änderung an
|
||||
/// anderer Stelle (Typen, Geschosse …: Cache verworfen) behält gleiche Gruppen. Zusammengesetzt = voll (`check`).
|
||||
|
||||
@@ -300,8 +300,14 @@ fn prepare(p: &Project, proj: &Projection, vis: &Visibility, context: bool) -> R
|
||||
let q = model_of(n);
|
||||
[dot(cof[0], q), dot(cof[1], q), dot(cof[2], q)]
|
||||
};
|
||||
let (mut vf, refs) = super::section::model_view_faces(p, vis, &view, &view_n, context && ortho)?;
|
||||
if vf.faces.len() > FACE_BUDGET && context {
|
||||
// [253] Entourage (Person, Auto …) als Netze im Kontext der Kopie; nur längentreu (nicht in schiefen Projektionen).
|
||||
let ent = if ortho { crate::furniture_3d::with_context_meshes(p, context) } else { None };
|
||||
let (pp, meshes) = match &ent {
|
||||
Some(q) => (q, true),
|
||||
None => (p, context && ortho),
|
||||
};
|
||||
let (mut vf, refs) = super::section::model_view_faces(pp, vis, &view, &view_n, meshes)?;
|
||||
if vf.faces.len() > FACE_BUDGET && (context || ent.is_some()) {
|
||||
(vf, _) = super::section::model_view_faces(p, vis, &view, &view_n, false)?;
|
||||
}
|
||||
// Modell-Normale = Mᵀ · Normale (die Normale ging über M⁻ᵀ).
|
||||
@@ -317,8 +323,13 @@ fn prepare(p: &Project, proj: &Projection, vis: &Visibility, context: bool) -> R
|
||||
let q = model_of(n);
|
||||
[dot(r, q), dot(u, q), dot(f, q)]
|
||||
};
|
||||
let (mut vf, refs) = super::section::model_view_faces(p, vis, &view, &view_n, context)?;
|
||||
if vf.faces.len() > FACE_BUDGET && context {
|
||||
let ent = crate::furniture_3d::with_context_meshes(p, context);
|
||||
let (pp, meshes) = match &ent {
|
||||
Some(q) => (q, true),
|
||||
None => (p, context),
|
||||
};
|
||||
let (mut vf, refs) = super::section::model_view_faces(pp, vis, &view, &view_n, meshes)?;
|
||||
if vf.faces.len() > FACE_BUDGET && (context || ent.is_some()) {
|
||||
(vf, _) = super::section::model_view_faces(p, vis, &view, &view_n, false)?;
|
||||
}
|
||||
let model_n: Vec<V3> = vf.faces.iter().map(|q| unit([0, 1, 2].map(|k| r[k] * q.normal[0] + u[k] * q.normal[1] + f[k] * q.normal[2])).unwrap_or([0.0, 0.0, 1.0])).collect();
|
||||
|
||||
@@ -332,3 +332,14 @@ fn testhaus_seitenrichtig_in_allen_vorgaben() {
|
||||
let (e, g) = (mid(&erker, cam.clone(), 0), mid(&garage, cam, 0));
|
||||
assert!(e > g, "Kamera Südost: Erker {e:.2}, Garage {g:.2}");
|
||||
}
|
||||
|
||||
/// [253] Entourage (Auto) erscheint im 3D-Dokument; seine Klasse schaltet es ab.
|
||||
#[test]
|
||||
fn entourage_im_3d_dokument() {
|
||||
let mut p = cubes(&[(0.0, 0.0, 0.0)]);
|
||||
let n0 = lines(&prims_of(&p, serde_json::json!({"view": "southeast"}))).len();
|
||||
p.drawings2d.push(serde_json::from_value(serde_json::json!({"id": "pers1", "type": "drawing2d", "levelId": "l0", "categoryCode": "24", "geom": {"shape": "libobj", "libId": "lib:auto", "at": {"x": 4.0, "y": -3.0}, "rotation": 0.5}})).unwrap());
|
||||
let n1 = lines(&prims_of(&p, serde_json::json!({"view": "southeast"}))).len();
|
||||
assert!(n1 > n0 + 10, "{n0} -> {n1}");
|
||||
assert_eq!(lines(&prims_of(&p, serde_json::json!({"view": "southeast", "hasVis": true, "invisible": ["24"]}))).len(), n0, "Klasse aus");
|
||||
}
|
||||
@@ -1168,6 +1168,8 @@ fn collect(p: &Project, k: [f64; 2], cut: Option<f64>, ground: Option<&Ground>)
|
||||
prisms.push((Prism { footprint: g.trunk_ring(8), z_bottom: g.base, z_top: g.trunk_top() }, vec![]));
|
||||
clouds.push(g.crown_points());
|
||||
}
|
||||
// [253] Entourage (Person, Auto, Bank …): je Teilnetz eine Wolke.
|
||||
clouds.extend(crate::furniture_3d::clouds(p));
|
||||
// Nur zur Sonne gewandte Dachflächen (Aussennormale): durch sie verlässt jeder Strahl den Körper.
|
||||
roof_faces.retain(|f| f.first().is_some_and(|r| {
|
||||
let n = newell(r);
|
||||
|
||||
@@ -4703,6 +4703,9 @@ export const de = {
|
||||
"lib.o.auto": "Auto mit Parkfeld",
|
||||
"lib.o.parkfeld": "Parkfeld 2.50×5.00",
|
||||
"lib.o.velo": "Velo",
|
||||
"lib.o.sitzbank": "Sitzbank",
|
||||
"lib.o.person-stehend": "Person stehend",
|
||||
"lib.o.person-gehend": "Person gehend",
|
||||
"lib.o.wendekreis": "Rollstuhl-Wendekreis Ø 150",
|
||||
"lib.g.sanitary": "Sanitär",
|
||||
"lib.g.kitchen": "Küche",
|
||||
@@ -4716,6 +4719,7 @@ export const de = {
|
||||
"lib.p.n": "Anzahl",
|
||||
"lib.p.mess": "Unordnung",
|
||||
"lib.p.field": "Parkfeld",
|
||||
"lib.p.h": "Höhe (3D)",
|
||||
"lib.p.mirror": "Spiegeln",
|
||||
"lib.title": "Objekte",
|
||||
"lib.hint": "Objekt wählen, dann im Plan den Einfügepunkt klicken oder das Objekt in den Plan ziehen (R = drehen, M = spiegeln; Esc = abbrechen).",
|
||||
|
||||
@@ -4689,6 +4689,9 @@ export const en: Record<TranslationKey, string> = {
|
||||
"lib.o.auto": "Car with parking bay",
|
||||
"lib.o.parkfeld": "Parking bay 2.50×5.00",
|
||||
"lib.o.velo": "Bicycle",
|
||||
"lib.o.sitzbank": "Bench",
|
||||
"lib.o.person-stehend": "Person standing",
|
||||
"lib.o.person-gehend": "Person walking",
|
||||
"lib.o.wendekreis": "Wheelchair turning circle Ø 150",
|
||||
"lib.g.sanitary": "Sanitary",
|
||||
"lib.g.kitchen": "Kitchen",
|
||||
@@ -4702,6 +4705,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"lib.p.n": "Count",
|
||||
"lib.p.mess": "Disorder",
|
||||
"lib.p.field": "Parking bay",
|
||||
"lib.p.h": "Height (3D)",
|
||||
"lib.p.mirror": "Mirror",
|
||||
"lib.title": "Objects",
|
||||
"lib.hint": "Pick an object, then click the insertion point in the plan or drag the object into it (R = rotate, M = mirror, Esc = cancel).",
|
||||
|
||||
@@ -288,6 +288,21 @@ const SITUATION_HIDDEN = ["00", "07", "20", "21", "22", "25", "30", "35", "40",
|
||||
const LEVEL_VIS: Record<string, boolean> = Object.fromEntries(LEVELS.map((l) => [l.id, true]));
|
||||
const pxPerMeterAt = (scale: number) => Math.round(((96 / 25.4) * 1000) / scale * 100) / 100;
|
||||
|
||||
/** [253] Entourage für die Bilder (3D-Netze der Objektbibliothek, Klasse „24 Fahrzeuge & Freiflächen"): drei Personen, ein Auto am Ostrand, Velo und Bank im Süden. */
|
||||
function entourage(): Drawing2D[] {
|
||||
const lib = (id: string, libId: string, at: Vec2, rotation: number, params?: Record<string, number>): Drawing2D => ({
|
||||
id, type: "drawing2d", levelId: "eg", categoryCode: "24", geom: { shape: "libobj", libId, at, rotation, ...(params ? { params } : {}), seed: 1 },
|
||||
});
|
||||
return [
|
||||
lib("ent-person-1", "lib:person-stehend", P(5.2, -3.4), 0.4),
|
||||
lib("ent-person-2", "lib:person-stehend", P(6.1, -3.0), 3.4, { h: 1.62 }),
|
||||
lib("ent-person-3", "lib:person-gehend", P(27.0, 3.4), -Math.PI / 2),
|
||||
lib("ent-auto", "lib:auto", P(25.2, 9.6), 0, { field: 0 }),
|
||||
lib("ent-velo", "lib:velo", P(12.4, -3.2), Math.PI / 2),
|
||||
lib("ent-bank", "lib:sitzbank", P(16, -3.4), 0),
|
||||
];
|
||||
}
|
||||
|
||||
/** Wettbewerb — neues Projekt (braucht den geladenen Kern). */
|
||||
export function buildWettbewerbSampleProject(): Project {
|
||||
stampSeq = 0;
|
||||
@@ -305,7 +320,7 @@ export function buildWettbewerbSampleProject(): Project {
|
||||
doorTypes: DOOR_TYPES,
|
||||
stairTypes: STAIR_TYPES,
|
||||
drawingLevels: LEVELS,
|
||||
layers: sampleProject.layers,
|
||||
layers: [...sampleProject.layers, { code: "24", name: "Fahrzeuge & Freiflächen", color: "#4a4a4a", lw: 0.13, visible: true, locked: false }],
|
||||
scaleLineWeights: true,
|
||||
walls,
|
||||
openings,
|
||||
@@ -315,7 +330,7 @@ export function buildWettbewerbSampleProject(): Project {
|
||||
railings,
|
||||
rooms: [],
|
||||
units: units(),
|
||||
drawings2d: cadastre(),
|
||||
drawings2d: [...cadastre(), ...entourage()],
|
||||
context: [neighbours()],
|
||||
// Raumprogramm des Wettbewerbs (Soll); die Räume im Modell liefern das Ist.
|
||||
roomProgram: [
|
||||
|
||||
Reference in new issue
Block a user