[290] Linux-App: Plan-Schatten mit Soll-Deckkraft (Szene liess Flächen-opacity weg), 3D zeichnet nur auf Anforderung (höchstens einmal je Frame), WebGPU-Adapter in Log und Über-Dialog

This commit is contained in:
Claude committed 2026-11-18 23:09:42 +00:00
1 parent b8d2920733
commit 2485f87b88
16 files changed
+414 -26

No files matched your search

+2 -2
View File
@@ -22,7 +22,7 @@ pub const SITE_PICK_VIEW_SHADOWS: &str = "@viewShadows";
/// [140] Schatten grau (Tusche-Darstellung), nicht blau.
pub const SUN_SHADOW_FILL: &str = "#3c3c3c";
/// [140] Schatten heller (0.28 → 0.16): Bemassung und Stempel darüber bleiben lesbar.
const SUN_SHADOW_OPACITY: f64 = 0.16;
pub(crate) const SUN_SHADOW_OPACITY: f64 = 0.16;
/// Linien-Klassen und Füllfarbe des Baurechts.
pub const SITE_PARCEL_CLS: &str = "site-parcel";
pub const SITE_ALLOWED_CLS: &str = "site-allowed";
@@ -53,7 +53,7 @@ pub fn ground_floor_id(p: &Project) -> Option<&str> {
}
/// Fläche ohne Strich, mit Deckkraft (Schatten, Baurechts-Verstoss).
fn flat_polygon(pts: Vec<Vec2>, fill: &str, opacity: f64) -> Primitive {
pub(crate) fn flat_polygon(pts: Vec<Vec2>, fill: &str, opacity: f64) -> Primitive {
Primitive::Polygon {
pts,
fill: fill.into(),
+39 -4
View File
@@ -22,7 +22,7 @@
use crate::hatch::{self, v2, HatchKind, Motif, Pattern, V2, DASH_MM_TO_M};
use crate::jsnum;
use crate::plan::overrides::js_trim;
use crate::plan::buf::{js_parse_hex, whole, Rec, F_COLOR, F_DASH_LIST, F_DASH_NULL, F_MOTIF, F_NSE, F_ZIGZAG};
use crate::plan::buf::{js_parse_hex, whole, Rec, F_COLOR, F_DASH_LIST, F_DASH_NULL, F_MOTIF, F_NSE, F_OPACITY, F_ZIGZAG};
use crate::plan::buf::{T_ARC, T_CIRCLE, T_DRAWING_ARC, T_DRAWING_TEXT, T_IMAGE, T_LINE, T_POLYGON, T_TEXT};
use crate::plan::parts::{greyed_of, in_ranges, pick_id, Part};
use std::collections::HashMap;
@@ -184,6 +184,16 @@ fn with_fill_opacity(col: Rgba, greyed: bool) -> Rgba {
}
}
/// [290] Deckkraft des Objekts (`opacity` der Fläche, z. B. Schatten 0.16) auf eine Farbe: wie `opacity` im Plan-/Druck-SVG.
/// Vorher liess die Bildschirm-Szene sie weg — der Sonnenschatten (#3c3c3c) erschien unter render2d (WASM und Metal) deckend.
fn with_obj_opacity(col: Rgba, o: f64) -> Rgba {
if o.is_finite() && (0.0..1.0).contains(&o) {
[col[0], col[1], col[2], col[3] * o]
} else {
col
}
}
/// Strichfarbe einer line/arc: CSS-Klassen-Farbe > Modell-Farbe > Tinte.
fn stroke_color_for(cls: Option<&str>, color: Option<&str>) -> Rgba {
to_rgba(Some(cls_stroke(cls).or(color).unwrap_or(DEFAULT_LINE))).unwrap_or(INK)
@@ -495,10 +505,11 @@ pub fn build_scene(parts: &mut [Part], greyed_ranges: &[(usize, usize)]) -> Opti
}
// [169] Ring mit Bögen fein (Fläche, Schraffur-Beschnitt, Umriss); Kantenläufe aus `pts`.
let fine = if pts.len() >= 4 { smooth(pts.clone(), true) } else { pts.clone() };
let obj = if rec.flags & F_OPACITY != 0 { f[4] } else { 1.0 };
if let Some(fc) = color(part, f[0]) {
if pts.len() >= 3 {
let z = b.z();
b.s.fills.push(SFill { pts: fine.clone(), color: with_fill_opacity(fc, greyed), z });
b.s.fills.push(SFill { pts: fine.clone(), color: with_obj_opacity(with_fill_opacity(fc, greyed), obj), z });
}
}
if f[3] != -1.0 {
@@ -507,7 +518,7 @@ pub fn build_scene(parts: &mut [Part], greyed_ranges: &[(usize, usize)]) -> Opti
}
let (_, h, hc) = hatches.as_ref()?.get(whole(f[3])?)?.clone();
if h.kind != HatchKind::Image && h.kind != HatchKind::Gradient && h.pattern != Pattern::None && h.pattern != Pattern::Solid {
let hatch_col = with_opacity(color(part, hc as f64).unwrap_or(INK), None, greyed);
let hatch_col = with_obj_opacity(with_opacity(color(part, hc as f64).unwrap_or(INK), None, greyed), obj);
let hatch_mm = if h.line_weight > 0.0 { h.line_weight } else { 0.13 };
let runs = if pts.len() < 3 { Vec::new() } else { hatch::build_hatch_runs(&fine, &h) };
let runs = hatch::apply_dash_runs(runs, &hatch::hatch_dash(&h));
@@ -522,7 +533,7 @@ pub fn build_scene(parts: &mut [Part], greyed_ranges: &[(usize, usize)]) -> Opti
if let Some(raw) = color(part, f[1]) {
let w = f[2];
if w > 0.0 {
let sc = with_opacity(raw, None, greyed);
let sc = with_obj_opacity(with_opacity(raw, None, greyed), obj);
let nse = match (rec.flags & F_NSE != 0, rec.nse) {
(true, Some((o, n))) => part.view.pool(o, n)?,
_ => Vec::new(),
@@ -917,6 +928,30 @@ mod tests {
assert_eq!(f64::from_le_bytes(b[48..56].try_into().unwrap()), 2600000.123456);
}
/// [290] Schatten genau mit der Soll-Deckkraft des Kerns (wie Druck-SVG), nicht deckend.
#[test]
fn flaechen_deckkraft_in_szene() {
use crate::plan::buf::Writer;
use crate::plan::extras::{flat_polygon, SUN_SHADOW_FILL, SUN_SHADOW_OPACITY};
use crate::model::Vec2;
use crate::plan::prim::Primitive;
let sq = vec![Vec2 { x: 0.0, y: 0.0 }, Vec2 { x: 2.0, y: 0.0 }, Vec2 { x: 2.0, y: 2.0 }, Vec2 { x: 0.0, y: 2.0 }];
let mut p = flat_polygon(sq, SUN_SHADOW_FILL, SUN_SHADOW_OPACITY);
let mut w = Writer::new(false);
w.push(&p);
if let Primitive::Polygon { opacity, .. } = &mut p {
*opacity = None;
}
w.push(&p);
let bytes = w.finish();
let view = crate::plan::buf::View::parse(&bytes).unwrap();
let len = view.len();
let sc = build_scene(&mut [Part::new(view, 0, len).unwrap()], &[]).unwrap();
assert_eq!(sc.fills.len(), 2);
assert!((sc.fills[0].color[3] - SUN_SHADOW_OPACITY).abs() < 1e-12, "{:?}", sc.fills[0].color);
assert_eq!(sc.fills[1].color[3], 1.0);
}
#[test]
fn kantenlaeufe_und_naht() {
let sq = vec![v2(0.0, 0.0), v2(1.0, 0.0), v2(1.0, 1.0), v2(0.0, 1.0)];