[137] Stützen im 3D anwählbar; Goldens EG (unsichtbare Baurechts-Bänder)

This commit is contained in:
Claude committed 2026-11-05 12:24:16 +00:00
1 parent 056043c421
commit 608c4ab1e9
10 files changed
+88 -12

No files matched your search

+6
View File
@@ -207,6 +207,12 @@ pub fn pick_geometry(p: &Project, gap: f64) -> Result<PickGeometry, String> {
v[1] += dz;
}
}
for c in &mut g.columns {
let dz = ex.of(&c.column_id);
for v in c.tris.iter_mut().flatten() {
v[1] += dz;
}
}
Ok(g)
}
+51
View File
@@ -2331,6 +2331,14 @@ pub struct PickContextMesh {
pub context_object_id: String,
}
/// [137] Stütze für den 3D-Pick: Welt-Dreiecke ihres Prismas.
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PickColumn {
pub tris: Vec<Tri>,
pub column_id: String,
}
#[derive(Debug, Serialize)]
pub struct PickGeometry {
pub walls: Vec<RWall>,
@@ -2340,6 +2348,8 @@ pub struct PickGeometry {
pub roofs: Vec<PickRoof>,
#[serde(rename = "contextMeshes")]
pub context_meshes: Vec<PickContextMesh>,
/// [137] Stützen (vorher im 3D nicht anwählbar).
pub columns: Vec<PickColumn>,
pub drawings: Vec<PickDrawingSeg>,
}
@@ -2476,10 +2486,33 @@ pub fn pick_geometry(p: &Project) -> Result<PickGeometry, String> {
stairs,
roofs,
context_meshes,
columns: pick_columns(p),
drawings: pick_drawing_segs(p, &HashMap::new()),
})
}
/// [137] Stützen als Welt-Dreiecke (Prisma aus Querschnitt und Höhenlage, wie [`emit_columns`]).
fn pick_columns(p: &Project) -> Vec<PickColumn> {
let mut out = Vec::new();
for col in p.columns.as_deref().unwrap_or(&[]) {
if !(col.height > 0.0) {
continue;
}
let (z0, z1) = p.column_vertical_extent(col);
let foot: Vec<[f64; 2]> = column_footprint(col).iter().map(|q| [q.x, q.y]).collect();
if foot.len() < 3 || !(z0.is_finite() && z1.is_finite()) {
continue;
}
let (pos, idx) = crate::columns3d::prism(&foot, z0, z1);
let at = |i: u32| -> V3 { let i = i as usize * 3; [pos[i], pos[i + 2], -pos[i + 1]] };
let tris: Vec<Tri> = idx.chunks_exact(3).filter(|t| t.iter().all(|&i| (i as usize) * 3 + 2 < pos.len())).map(|t| [at(t[0]), at(t[1]), at(t[2])]).collect();
if !tris.is_empty() {
out.push(PickColumn { tris, column_id: col.id.clone() });
}
}
out
}
#[cfg(test)]
mod tests {
use super::*;
@@ -2557,6 +2590,24 @@ mod tests {
assert!(bg.iter().any(|tri| tri.iter().all(|q| (q[1] - 1.0).abs() < 1e-6)));
}
/// [137] Stützen sind im 3D anwählbar: ihr Prisma kommt mit Id in die Pick-Geometrie (Welt: x, Höhe, −y).
#[test]
fn pick_stuetzen_im_3d() {
let p: Project = serde_json::from_value(serde_json::json!({
"id": "p", "name": "t", "lineStyles": [], "hatches": [], "components": [], "wallTypes": [], "layers": [], "openings": [], "walls": [],
"drawingLevels": [{"id": "EG", "name": "EG", "kind": "floor", "visible": true, "locked": false, "floorHeight": 3.0, "baseElevation": 0.0}],
"columns": [{"id": "k1", "type": "column", "floorId": "EG", "categoryCode": "25", "position": {"x": 2, "y": 3}, "profile": {"kind": "rect", "width": 0.3, "depth": 0.3}, "rotation": 0, "height": 2.5}],
"drawings2d": []
}))
.unwrap();
let g = pick_geometry(&p).unwrap();
assert_eq!(g.columns.len(), 1);
assert_eq!(g.columns[0].column_id, "k1");
let v: Vec<&V3> = g.columns[0].tris.iter().flatten().collect();
assert!(v.iter().all(|q| (q[0] - 2.0).abs() <= 0.15 + 1e-9 && (q[2] + 3.0).abs() <= 0.15 + 1e-9 && q[1] >= -1e-9 && q[1] <= 2.5 + 1e-9));
assert!(v.iter().any(|q| (q[1] - 2.5).abs() < 1e-9));
}
/// [T4] Import-Mesh glatt: Knickwinkel geht ans 3D (Vorgabe 30°), kantig ohne; JSON `creaseAngle`.
#[test]
fn import_mesh_glatt_mit_knickwinkel() {
+1
View File
@@ -161,6 +161,7 @@ export {
export {
DRAWING_PICK_TOLERANCE,
type PickContextMesh,
type PickColumnMesh,
type PickDrawingSeg,
type PickOpening,
type PickRoof,
@@ -1,10 +1,10 @@
viewBox -41.5 0 95 63.6
bytes 146250
bytes 147364
circle 16
line 832
path 68
polygon 249
polygon 257
rect 1
svg 1
text 121
hash 51b01852d2618ab4
hash 45e68ce965a49c5d
@@ -1,10 +1,10 @@
viewBox -41.5 0 95 63.6
bytes 146660
bytes 147796
circle 16
line 832
path 68
polygon 249
polygon 257
rect 1
svg 1
text 121
hash d9e3d1d506de326b
hash dea353f151ea1cc1
+6
View File
@@ -96,3 +96,9 @@ export interface PickContextMesh {
tris: ReadonlyArray<readonly [Vec3, Vec3, Vec3]>;
contextObjectId: string;
}
/** [137] Stütze für den Raycast: WORLD-Dreiecke ihres Prismas (Konvention wie {@link PickContextMesh}). */
export interface PickColumnMesh {
tris: ReadonlyArray<readonly [Vec3, Vec3, Vec3]>;
columnId: string;
}
+2 -1
View File
@@ -44,7 +44,7 @@ import type { Project, Vec2 } from "../model/types";
import type { DetailLevel } from "../model/viewTypes";
import { documentFor } from "../core/document";
import { coreEpoch } from "../engine/coreWasm";
import type { PickOpening, PickRoof, PickStair, PickContextMesh, PickDrawingSeg } from "./pickTypes";
import type { PickOpening, PickRoof, PickStair, PickContextMesh, PickColumnMesh, PickDrawingSeg } from "./pickTypes";
import {
type RMesh,
type RModel3d,
@@ -328,6 +328,7 @@ export function pickGeometry(
stairs: PickStair[];
roofs: PickRoof[];
contextMeshes: PickContextMesh[];
columns: PickColumnMesh[];
drawings: PickDrawingSeg[];
} {
return documentFor(project).query("pickGeometry", [explodeGap(explode)]);
+4
View File
@@ -383,6 +383,10 @@ export function useMouseSelectionHandlers(opts: {
setSelection({ ...clearKinds(), stairs: [hit.id] });
return;
}
if (hit.kind === "column") {
setSelection({ ...clearKinds(), columns: [hit.id] });
return;
}
if (hit.kind === "roof") {
// Schnittlinien bleiben hier (wie bisher) gewählt.
setSelection({ ...clearKinds(...ELEMENT_KINDS.filter((k) => k !== "sectionLines")), roofs: [hit.id] });
+3 -3
View File
@@ -81,7 +81,7 @@ import {
/** Ein per 3D-Klick getroffenes Bauteil, oder null (Leerraum). */
export type Pick3dHit =
| { kind: "wall" | "ceiling" | "opening" | "stair" | "roof" | "contextObject" | "drawing"; id: string }
| { kind: "wall" | "ceiling" | "opening" | "stair" | "roof" | "contextObject" | "drawing" | "column"; id: string }
| null;
/** Klick-vs-Drag-Schwelle (Pixel): bleibt die Maus zwischen pointerdown und
@@ -1406,7 +1406,7 @@ export function Wasm3DViewport({
const ndc = toNdc(clientX, clientY);
if (!cb || !o || !ndc) return;
const ray = cameraRay(orbitCamera(o), ndc.ndcX, ndc.ndcY, ndc.aspect);
const { walls, slabs, openings, stairs, roofs, contextMeshes, drawings } = pickGeometry(
const { walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns } = pickGeometry(
projectRef.current,
explodeRef.current,
);
@@ -1414,7 +1414,7 @@ export function Wasm3DViewport({
// Meshes + freie 2D-Zeichnungen (Linie/Polylinie/Rechteck, s.
// `pickDrawingSegs`) — sonst wären im WASM-Viewport 2D-Elemente NIE
// anwählbar gewesen (Nutzer-Report).
const hit = pickNearest(ray, walls, slabs, openings, stairs, roofs, contextMeshes, drawings);
const hit = pickNearest(ray, walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns);
cb(hit ? { kind: hit.kind, id: hit.id } : null, additive);
};
+9 -2
View File
@@ -18,7 +18,7 @@
import { DRAWING_PICK_TOLERANCE } from "../core";
import type { Vec3, PickWall, PickOpening, PickDrawingSeg, PickSlab, PickStair, PickRoof, PickContextMesh } from "../core";
import type { Vec3, PickWall, PickOpening, PickDrawingSeg, PickSlab, PickStair, PickRoof, PickContextMesh, PickColumnMesh } from "../core";
/** Kamera-Parameter für den Pick-Strahl (Teilmenge von Camera3d). */
export interface RayCamera {
@@ -42,7 +42,7 @@ export interface Ray {
/** Ergebnis eines Picks: getroffenes Bauteil + Distanz entlang des Strahls. */
export interface PickHit {
kind: "wall" | "ceiling" | "opening" | "stair" | "roof" | "contextObject" | "drawing";
kind: "wall" | "ceiling" | "opening" | "stair" | "roof" | "contextObject" | "drawing" | "column";
id: string;
t: number;
/** Bei `kind:"opening"` dieselbe Id wie `id` (ausdrucksstärkerer Zugriff). */
@@ -357,6 +357,7 @@ export function pickNearest(
roofs?: readonly PickRoof[],
contextMeshes?: readonly PickContextMesh[],
drawings?: readonly PickDrawingSeg[],
columns?: readonly PickColumnMesh[],
): PickHit | null;
/**
* Nächstes getroffenes Bauteil (kleinstes t) über Wände, Decken, Öffnungen und
@@ -376,6 +377,7 @@ export function pickNearest(
roofs: readonly PickRoof[] = [],
contextMeshes: readonly PickContextMesh[] = [],
drawings: readonly PickDrawingSeg[] = [],
columns: readonly PickColumnMesh[] = [],
): PickHit | null {
const TIE_EPS = 1e-6;
let hit: PickHit | null = null;
@@ -426,6 +428,11 @@ export function pickNearest(
consider({ kind: "contextObject", id: m.contextObjectId, t, contextObjectId: m.contextObjectId }, 1);
}
}
// [137] Stützen: Prisma-Dreiecke, Rang wie Wand/Decke.
for (const c of columns) {
const t = rayContextMeshTris(ray, { tris: c.tris, contextObjectId: c.columnId });
if (t !== null) consider({ kind: "column", id: c.columnId, t }, 1);
}
return hit;
}