[137] 3D-Pick: Treppengeländer, Kreise/Bögen/Texte als Flächen, importierte Netze einzeln ausblendbar
This commit is contained in:
15 files changed
+314
-13
No files matched your search
@@ -164,6 +164,8 @@ export {
|
||||
type PickColumnMesh,
|
||||
type PickSolidMesh,
|
||||
type PickOpeningMesh,
|
||||
type PickStairMesh,
|
||||
type PickDrawingMesh,
|
||||
type PickDrawingSeg,
|
||||
type PickOpening,
|
||||
type PickRoof,
|
||||
|
||||
@@ -2111,6 +2111,8 @@ export const de = {
|
||||
"site.terrain.smooth.hint": "Gelände aus den Höhenlinien neu erzeugen (Bruchkanten bleiben, ein Undo-Schritt)",
|
||||
"site.terrain.smooth.raw": "roh (ohne Glättung)",
|
||||
"site.terrain.smooth.level": "Stufe {n}",
|
||||
"site.mesh.visible": "Dieses Netz sichtbar",
|
||||
"site.mesh.visible.hint": "Blendet nur dieses importierte Netz aus (Grundriss, 3D, Auswahl); die Kategorie bleibt eingeschaltet",
|
||||
"site.terrain.meshVisible": "Dieses Gelände sichtbar",
|
||||
"site.terrain.meshVisible.hint": "Blendet nur dieses Geländenetz aus (Grundriss, Schnitt, Ansicht, 3D); die Kategorie bleibt eingeschaltet",
|
||||
"site.terrain.resmooth.hint": "Raster-Gelände (swissALTI3D) zusätzlich glätten — wirkt auf die Höhen des Rasters, ein Undo-Schritt",
|
||||
|
||||
@@ -2097,6 +2097,8 @@ export const en: Record<TranslationKey, string> = {
|
||||
"site.terrain.smooth.hint": "Regenerate the terrain from its contour lines (breaklines kept, one undo step)",
|
||||
"site.terrain.smooth.raw": "raw (no smoothing)",
|
||||
"site.terrain.smooth.level": "Level {n}",
|
||||
"site.mesh.visible": "This mesh visible",
|
||||
"site.mesh.visible.hint": "Hides only this imported mesh (plan, 3D, selection); the category stays on",
|
||||
"site.terrain.meshVisible": "This terrain visible",
|
||||
"site.terrain.meshVisible.hint": "Hides only this terrain mesh (plan, section, elevation, 3D); the category stays on",
|
||||
"site.terrain.resmooth.hint": "Smooth grid terrain (swissALTI3D) further — acts on the grid heights, one undo step",
|
||||
|
||||
@@ -1549,6 +1549,11 @@ export type ImportedMesh = {
|
||||
smoothShading?: boolean;
|
||||
/** [T4] Knickwinkel in Grad für das glatte Schattieren (Default 30°). */
|
||||
creaseAngle?: number;
|
||||
/**
|
||||
* [137] Nur dieses Netz ausblenden (Grundriss, Schnitt, Ansicht, 3D, Pick); die Kategorie bleibt
|
||||
* davon unberührt. Fehlt/false = sichtbar.
|
||||
*/
|
||||
hidden?: boolean;
|
||||
positions: Array<number>;
|
||||
indices: Array<number>;
|
||||
};
|
||||
|
||||
@@ -75,6 +75,15 @@ export function ContextObjectProps({ obj, quantities }: { obj: ContextObject; qu
|
||||
// [T4] Glatt oder kantig schattieren, Knickwinkel je Mesh (Vorgabe 30°).
|
||||
return (
|
||||
<div className="site-props">
|
||||
<label className="site-check" title={t("site.mesh.visible.hint")}>
|
||||
<input
|
||||
type="checkbox"
|
||||
data-testid="imported-mesh-visible"
|
||||
checked={obj.hidden !== true}
|
||||
onChange={(e) => host.onPatchContextObject(obj.id, { hidden: e.target.checked ? undefined : true }, `site-${obj.id}-hidden`)}
|
||||
/>
|
||||
{t("site.mesh.visible")}
|
||||
</label>
|
||||
<label className="site-check">
|
||||
<input
|
||||
type="checkbox"
|
||||
|
||||
@@ -114,6 +114,18 @@ export interface PickSolidMesh {
|
||||
solidId: string;
|
||||
}
|
||||
|
||||
/** [137] Treppengeländer (Handlauf, Pfosten): WORLD-Dreiecke; ragen über die Treppen-Hülle hinaus. */
|
||||
export interface PickStairMesh {
|
||||
tris: ReadonlyArray<readonly [Vec3, Vec3, Vec3]>;
|
||||
stairId: string;
|
||||
}
|
||||
|
||||
/** [137] Flache Pick-Fläche eines 2D-Elements ohne Linien-Spur (Kreis, Bogen, Ellipse, Text) auf Geschosshöhe. */
|
||||
export interface PickDrawingMesh {
|
||||
tris: ReadonlyArray<readonly [Vec3, Vec3, Vec3]>;
|
||||
drawingId: string;
|
||||
}
|
||||
|
||||
/** [137] Öffnung ohne Wand (Dachfenster, Deckenöffnung, Gaubenfenster): WORLD-Dreiecke ihrer 3D-Teile. */
|
||||
export interface PickOpeningMesh {
|
||||
tris: ReadonlyArray<readonly [Vec3, Vec3, Vec3]>;
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
// [137] 3D-Pick, Rest: Treppengeländer über der Treppen-Hülle, Kreise/Bögen/Texte (Bäume, Symbole) als flache
|
||||
// Fläche, einzeln ausgeblendetes importiertes Netz (Objekt-Info-Schalter `hidden`, mit Undo).
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { ImportedMesh, Project } from "../model/types";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { pickGeometry } from "./toWalls3d";
|
||||
import { pickNearest, type Ray } from "../viewport/raycast3d";
|
||||
import { getState, setState } from "../state/appStore";
|
||||
|
||||
const base: Project = {
|
||||
...sampleProject,
|
||||
walls: [],
|
||||
openings: [],
|
||||
ceilings: [],
|
||||
roofs: [],
|
||||
columns: [],
|
||||
extrudedSolids: [],
|
||||
context: [],
|
||||
stairTypes: [{ ...sampleProject.stairTypes![0], id: "rail", railing: "beide" }],
|
||||
stairs: [
|
||||
{ id: "st1", type: "stair", floorId: "eg", categoryCode: "35", shape: "straight", start: { x: 0, y: 0 }, dir: { x: 1, y: 0 }, runLength: 3, width: 1, stepCount: 16, totalRise: 2.8, typeId: "rail" },
|
||||
],
|
||||
drawings2d: [{ id: "baum", type: "drawing2d", levelId: "eg", categoryCode: "20", geom: { shape: "circle", center: { x: 20, y: 5 }, r: 2 } }],
|
||||
} as unknown as Project;
|
||||
|
||||
const down = (x: number, z: number): Ray => ({ origin: [x, 50, z], dir: [0, -1, 0] });
|
||||
const pick = (p: Project, ray: Ray) => {
|
||||
const g = pickGeometry(p);
|
||||
return pickNearest(ray, g.walls, g.slabs, g.openings, g.stairs, g.roofs, g.contextMeshes, g.drawings, g.columns, g.solids, g.openingMeshes, g.stairMeshes, g.drawingMeshes);
|
||||
};
|
||||
|
||||
describe("[137] 3D-Pick Treppengeländer und 2D-Flächen", () => {
|
||||
it("Geländer-Dreiecke tragen die Treppen-Id und liegen über der Hülle", () => {
|
||||
const g = pickGeometry(base);
|
||||
expect(g.stairMeshes.map((m) => m.stairId)).toEqual(["st1"]);
|
||||
const top = Math.max(...g.stairMeshes[0].tris.flat().map((q) => q[1]));
|
||||
expect(top).toBeGreaterThan(g.stairs[0].zTop);
|
||||
});
|
||||
|
||||
it("Kreis (Baum) ist von oben anwählbar, daneben nicht", () => {
|
||||
const hit = pick(base, down(20.5, 5.5));
|
||||
expect(hit?.kind).toBe("drawing");
|
||||
expect(hit?.id).toBe("baum");
|
||||
expect(pick(base, down(24, 5))).toBeNull();
|
||||
});
|
||||
|
||||
it("importiertes Netz: hidden entfernt die Pick-Dreiecke, Undo bringt sie zurück", () => {
|
||||
const mesh = { type: "importedMesh", id: "im", name: "M", positions: [30, 0, 0, 32, 0, 0, 30, 2, 0], indices: [0, 1, 2] } as ImportedMesh;
|
||||
setState({ project: { ...base, stairs: [], drawings2d: [], context: [mesh] }, undoDepth: 0, redoDepth: 0, canUndo: false, canRedo: false });
|
||||
getState().clearHistory();
|
||||
expect(pickGeometry(getState().project).contextMeshes.map((m) => m.contextObjectId)).toEqual(["im"]);
|
||||
getState().patchContextObject("im", { hidden: true });
|
||||
expect((getState().project.context![0] as ImportedMesh).hidden).toBe(true);
|
||||
expect(pickGeometry(getState().project).contextMeshes).toEqual([]);
|
||||
getState().undo();
|
||||
expect(pickGeometry(getState().project).contextMeshes).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@@ -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, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickDrawingSeg } from "./pickTypes";
|
||||
import type { PickOpening, PickRoof, PickStair, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickDrawingSeg, PickStairMesh, PickDrawingMesh } from "./pickTypes";
|
||||
import {
|
||||
type RMesh,
|
||||
type RModel3d,
|
||||
@@ -332,6 +332,8 @@ export function pickGeometry(
|
||||
solids: PickSolidMesh[];
|
||||
openingMeshes: PickOpeningMesh[];
|
||||
drawings: PickDrawingSeg[];
|
||||
stairMeshes: PickStairMesh[];
|
||||
drawingMeshes: PickDrawingMesh[];
|
||||
} {
|
||||
const g = documentFor(project).query("pickGeometry", [explodeGap(explode)]) as ReturnType<typeof pickGeometry>;
|
||||
// [137] Freie Körper: das geladene truck-Netz (Loft, Rotation, Verjüngung, Rundung) statt der Prisma-Näherung des Kerns.
|
||||
|
||||
@@ -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, columns, solids, openingMeshes } = pickGeometry(
|
||||
const { walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes, stairMeshes, drawingMeshes } = 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, columns, solids, openingMeshes);
|
||||
const hit = pickNearest(ray, walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes, stairMeshes, drawingMeshes);
|
||||
cb(hit ? { kind: hit.kind, id: hit.id } : null, additive);
|
||||
};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
import { DRAWING_PICK_TOLERANCE } from "../core";
|
||||
import type { Vec3, PickWall, PickOpening, PickDrawingSeg, PickSlab, PickStair, PickRoof, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh } from "../core";
|
||||
import type { Vec3, PickWall, PickOpening, PickDrawingSeg, PickSlab, PickStair, PickRoof, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickStairMesh, PickDrawingMesh } from "../core";
|
||||
|
||||
/** Kamera-Parameter für den Pick-Strahl (Teilmenge von Camera3d). */
|
||||
export interface RayCamera {
|
||||
@@ -360,6 +360,8 @@ export function pickNearest(
|
||||
columns?: readonly PickColumnMesh[],
|
||||
solids?: readonly PickSolidMesh[],
|
||||
openingMeshes?: readonly PickOpeningMesh[],
|
||||
stairMeshes?: readonly PickStairMesh[],
|
||||
drawingMeshes?: readonly PickDrawingMesh[],
|
||||
): PickHit | null;
|
||||
/**
|
||||
* Nächstes getroffenes Bauteil (kleinstes t) über Wände, Decken, Öffnungen und
|
||||
@@ -382,6 +384,8 @@ export function pickNearest(
|
||||
columns: readonly PickColumnMesh[] = [],
|
||||
solids: readonly PickSolidMesh[] = [],
|
||||
openingMeshes: readonly PickOpeningMesh[] = [],
|
||||
stairMeshes: readonly PickStairMesh[] = [],
|
||||
drawingMeshes: readonly PickDrawingMesh[] = [],
|
||||
): PickHit | null {
|
||||
const TIE_EPS = 1e-6;
|
||||
let hit: PickHit | null = null;
|
||||
@@ -447,6 +451,16 @@ export function pickNearest(
|
||||
const t = rayContextMeshTris(ray, { tris: o.tris, contextObjectId: o.openingId });
|
||||
if (t !== null) consider({ kind: "opening", id: o.openingId, t, openingId: o.openingId }, 0);
|
||||
}
|
||||
// [137] Treppengeländer (über der Hülle, oberes Podest): Rang wie Treppe.
|
||||
for (const m of stairMeshes) {
|
||||
const t = rayContextMeshTris(ray, { tris: m.tris, contextObjectId: m.stairId });
|
||||
if (t !== null) consider({ kind: "stair", id: m.stairId, t, stairId: m.stairId }, 0);
|
||||
}
|
||||
// [137] Kreise/Bögen/Texte (Bäume, Symbole): flache Fläche, Rang wie die Linien-Spur.
|
||||
for (const m of drawingMeshes) {
|
||||
const t = rayContextMeshTris(ray, { tris: m.tris, contextObjectId: m.drawingId });
|
||||
if (t !== null) consider({ kind: "drawing", id: m.drawingId, t, drawingId: m.drawingId }, 0);
|
||||
}
|
||||
return hit;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user