[65] Explosion: 3D-Griffe, Arbeitsebene, Boden-Spuren und natives 3D-Fenster folgen dem Versatz (WIP)
This commit is contained in:
10 files changed
+133
-22
No files matched your search
@@ -91,6 +91,7 @@ export type QueryName =
|
||||
| "scheduleRows"
|
||||
| "scheduleCsv"
|
||||
| "pickGeometry"
|
||||
| "explodeOffsets"
|
||||
| "model3dParts"
|
||||
| "projectSolidSpecs"
|
||||
| "planDomains"
|
||||
@@ -219,8 +220,8 @@ export class ProjectDocument {
|
||||
}
|
||||
|
||||
/** Boden-Spuren der 2D-Zeichnungen als LineList-Vertices `[px, py, pz, r, g, b]`. */
|
||||
drawingLineVerts(): Float32Array {
|
||||
return this.handle ? core().doc_drawing_line_verts(this.handle) : new Float32Array(0);
|
||||
drawingLineVerts(explode = 0): Float32Array {
|
||||
return this.handle ? core().doc_drawing_line_verts(this.handle, explode) : new Float32Array(0);
|
||||
}
|
||||
|
||||
/** Ansichtsschraffur auf den Flächen (Wände, Decken, Dächer) für render3d `set_pattern_lines`. */
|
||||
|
||||
@@ -246,6 +246,7 @@ export {
|
||||
draftWorldLines,
|
||||
emitDrawingLineVerts,
|
||||
emitSurfacePatternLines,
|
||||
explodeFloorOffsets,
|
||||
pickGeometry,
|
||||
projectToModel3d,
|
||||
selectionHighlightLines,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { projectToModel3d, pickGeometry, selectionHighlightLines } from "./toWalls3d";
|
||||
import { projectToModel3d, pickGeometry, selectionHighlightLines, explodeFloorOffsets, emitDrawingLineVerts } from "./toWalls3d";
|
||||
|
||||
const floors = sampleProject.drawingLevels
|
||||
.filter((l) => l.kind === "floor")
|
||||
@@ -41,4 +41,28 @@ describe("Explosionsaxonometrie", () => {
|
||||
expect(b.length).toBe(a.length);
|
||||
expect(b[1] - a[1]).toBeCloseTo(2 * wallIndex(w.id), 4);
|
||||
});
|
||||
|
||||
it("Versatz je Geschoss (3D-Griffe, Arbeitsebene)", () => {
|
||||
expect(explodeFloorOffsets(sampleProject, 0)).toEqual({});
|
||||
expect(explodeFloorOffsets(sampleProject, Number.NaN)).toEqual({});
|
||||
const off = explodeFloorOffsets(sampleProject, 2.5);
|
||||
floors.forEach((f, i) => expect(off[f.id]).toBeCloseTo(i * 2.5, 9));
|
||||
});
|
||||
|
||||
it("2D-Boden-Spuren heben sich mit ihrem Geschoss", () => {
|
||||
const top = floors[floors.length - 1];
|
||||
const p = {
|
||||
...sampleProject,
|
||||
drawings2d: [
|
||||
{ id: "dx", type: "drawing2d", levelId: top.id, categoryCode: "", geom: { shape: "line", a: { x: 0, y: 0 }, b: { x: 3, y: 0 } } },
|
||||
],
|
||||
} as unknown as typeof sampleProject;
|
||||
const a = emitDrawingLineVerts(p);
|
||||
const b = emitDrawingLineVerts(p, 2);
|
||||
expect(a.length).toBeGreaterThan(0);
|
||||
expect(b.length).toBe(a.length);
|
||||
const dz = (floors.length - 1) * 2;
|
||||
for (let i = 1; i < a.length; i += 6) expect(b[i] - a[i]).toBeCloseTo(dz, 4);
|
||||
expect(pickGeometry(p, 2).drawings[0].baseElevation - pickGeometry(p).drawings[0].baseElevation).toBeCloseTo(dz, 9);
|
||||
});
|
||||
});
|
||||
+18
-5
@@ -67,8 +67,21 @@ export type { RVec2, RRgb, RWall, RSlab, RModel3d };
|
||||
* Kataster-DXF kann Millionen Segmente liefern, als JSON-Mesh sprengte das Speicher und
|
||||
* String-Länge). Rechnet der Kern (`model3d.rs`, Chargen).
|
||||
*/
|
||||
export function emitDrawingLineVerts(project: Project): Float32Array {
|
||||
return documentFor(project).drawingLineVerts();
|
||||
export function emitDrawingLineVerts(
|
||||
project: Project,
|
||||
/** Explosionsabstand ([65]): Spuren heben sich mit ihrem Geschoss; 0 = aus. */
|
||||
explode = 0,
|
||||
): Float32Array {
|
||||
return documentFor(project).drawingLineVerts(explodeGap(explode));
|
||||
}
|
||||
|
||||
/**
|
||||
* Explosionsaxonometrie ([65]): Versatz (m) je Geschoss-id (Kern `explode3d.rs::floor_offsets`),
|
||||
* für 3D-Griffe und Arbeitsebene. Abstand ≤ 0 → leer (= nirgends Versatz).
|
||||
*/
|
||||
export function explodeFloorOffsets(project: Project, explode: number): Record<string, number> {
|
||||
const gap = explodeGap(explode);
|
||||
return gap === 0 ? {} : documentFor(project).query<Record<string, number>>("explodeOffsets", [gap]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,8 +152,8 @@ export interface Model3dOptions {
|
||||
voids?: boolean;
|
||||
/**
|
||||
* Explosionsaxonometrie ([65]): Abstand (m) zwischen den Geschossen; 0/fehlt = aus. Jedes
|
||||
* Geschoss hebt sich um Index × Abstand (Kern `explode3d.rs`); Kontext bleibt stehen.
|
||||
* Mit Explosion keine Abzugskörper (die truck-Ergebnisse lägen am alten Ort).
|
||||
* Geschoss hebt sich um Index × Abstand (Kern `explode3d.rs`); Kontext bleibt stehen,
|
||||
* Abzugskörper wandern mit dem getroffenen Bauteil.
|
||||
*/
|
||||
explode?: number;
|
||||
}
|
||||
@@ -151,7 +164,7 @@ export function projectToModel3d(project: Project, opts: Model3dOptions = {}): R
|
||||
const detail = opts.detail ?? "fein";
|
||||
// Mit `voids` liefert der Kern zusätzlich die getroffenen Wände/Decken als truck-Spezifikationen.
|
||||
const explode = explodeGap(opts.explode);
|
||||
const voids = !!opts.voids && typeof window !== "undefined" && explode === 0;
|
||||
const voids = !!opts.voids && typeof window !== "undefined";
|
||||
const parts = documentFor(project).query<Model3dParts>(
|
||||
"model3dParts",
|
||||
[layered ? 1 : 0, DETAIL_CODE[detail] ?? 3, opts.forSection ? 1 : 0, voids ? 1 : 0, explode],
|
||||
|
||||
@@ -42,10 +42,10 @@
|
||||
// Die Orbit-/Pan-Mathematik folgt den OrbitControls-Konventionen (Winkel je
|
||||
// Pixel an der Viewport-Höhe normiert), damit sich beide Pfade gleich anfühlen.
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import type { Project, Wall, Drawing2D, Ceiling, Roof, Vec2 } from "../model/types";
|
||||
import { roofBaseElevation, roofGeometry, verticalExtents } from "../core";
|
||||
import { projectToModel3d, pickGeometry, draftWorldLines, TRUCK_MESH_READY_EVENT } from "../core";
|
||||
import { projectToModel3d, pickGeometry, draftWorldLines, explodeFloorOffsets, TRUCK_MESH_READY_EVENT } from "../core";
|
||||
import type { DetailLevel, RenderMode, View3d } from "../model/viewTypes";
|
||||
import type { ToolDraft } from "../tools/types";
|
||||
import { hudSegments, type HudFieldsState } from "../tools/hudFormat";
|
||||
@@ -55,6 +55,7 @@ import {
|
||||
neighbor3dVertex,
|
||||
findCoincidentVertices,
|
||||
findMoveCoincidentVertices,
|
||||
explodeGripDz,
|
||||
type CoincidentVertex,
|
||||
type MoveCoincidentVertex,
|
||||
} from "./grip3dHud";
|
||||
@@ -182,6 +183,25 @@ function computeGrips(
|
||||
ceilings: readonly Ceiling[],
|
||||
roofs: readonly Roof[],
|
||||
drawingElevation: number,
|
||||
/** Explosionsaxonometrie ([65]): Versatz je Geschoss-id; Griffe sitzen auf den gehobenen Bauteilen. */
|
||||
floorOffsets: Readonly<Record<string, number>> = {},
|
||||
): Grip[] {
|
||||
const out = computeGripsAt(project, walls, drawings, ceilings, roofs, drawingElevation);
|
||||
for (const g of out) {
|
||||
const dz = explodeGripDz(project, floorOffsets, g.target);
|
||||
if (dz !== 0) g.pos = [g.pos[0], g.pos[1] + dz, g.pos[2]];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Griffe am unversetzten Modell (s. {@link computeGrips}). */
|
||||
function computeGripsAt(
|
||||
project: Project,
|
||||
walls: readonly Wall[],
|
||||
drawings: readonly Drawing2D[],
|
||||
ceilings: readonly Ceiling[],
|
||||
roofs: readonly Roof[],
|
||||
drawingElevation: number,
|
||||
): Grip[] {
|
||||
const out: Grip[] = [];
|
||||
const ext = verticalExtents(project, walls, ceilings);
|
||||
@@ -571,6 +591,12 @@ export function Wasm3DViewport({
|
||||
const explode = explodeOn ? explodeGap : 0;
|
||||
const explodeRef = useRef(explode);
|
||||
explodeRef.current = explode;
|
||||
// Versatz je Geschoss ([65]) für Griffe und gezogene Höhen (Modell bleibt unversetzt).
|
||||
const floorOffsets = useMemo(() => explodeFloorOffsets(project, explode), [project, explode]);
|
||||
const floorOffsetsRef = useRef(floorOffsets);
|
||||
floorOffsetsRef.current = floorOffsets;
|
||||
const gripDz = (target: { wallId?: string; ceilingId?: string; roofId?: string; drawingId?: string }) =>
|
||||
explodeGripDz(projectRef.current, floorOffsetsRef.current, target);
|
||||
const {
|
||||
render,
|
||||
updateModel,
|
||||
@@ -839,6 +865,7 @@ export function Wasm3DViewport({
|
||||
editCeilingsRef.current,
|
||||
editRoofsRef.current,
|
||||
groundElevationRef.current,
|
||||
floorOffsetsRef.current,
|
||||
);
|
||||
const next: { grip: Grip; x: number; y: number }[] = [];
|
||||
for (const g of grips) {
|
||||
@@ -993,15 +1020,15 @@ export function Wasm3DViewport({
|
||||
const gripPlaneY = (target: GripTarget): number | null => {
|
||||
if (target.wallId) {
|
||||
const wall = editWallsRef.current.find((w) => w.id === target.wallId);
|
||||
return wall ? verticalExtents(projectRef.current, [wall]).walls[0].zBottom : null;
|
||||
return wall ? verticalExtents(projectRef.current, [wall]).walls[0].zBottom + gripDz(target) : null;
|
||||
}
|
||||
if (target.ceilingId) {
|
||||
const c = editCeilingsRef.current.find((x) => x.id === target.ceilingId);
|
||||
return c ? verticalExtents(projectRef.current, [], [c]).ceilings[0].zTop : null;
|
||||
return c ? verticalExtents(projectRef.current, [], [c]).ceilings[0].zTop + gripDz(target) : null;
|
||||
}
|
||||
if (target.roofId) {
|
||||
const r = editRoofsRef.current.find((x) => x.id === target.roofId);
|
||||
return r ? roofBaseElevation(projectRef.current, r) : null;
|
||||
return r ? roofBaseElevation(projectRef.current, r) + gripDz(target) : null;
|
||||
}
|
||||
return groundElevationRef.current;
|
||||
};
|
||||
@@ -1110,7 +1137,8 @@ export function Wasm3DViewport({
|
||||
nz /= nlen;
|
||||
const hit = rayPlane(ray, [midX, 0, midY], [nx, 0, nz]);
|
||||
if (!hit) return;
|
||||
onEditWallTopRef.current?.(drag.wallId, hit[1]);
|
||||
// Explosion ([65]): Griff sitzt gehoben, das Modell bekommt die unversetzte Höhe.
|
||||
onEditWallTopRef.current?.(drag.wallId, hit[1] - gripDz({ wallId: drag.wallId }));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1126,7 +1154,7 @@ export function Wasm3DViewport({
|
||||
nz /= nlen;
|
||||
const hitR = rayPlane(ray, [drag.apexXZ[0], 0, drag.apexXZ[1]], [nx, 0, nz]);
|
||||
if (!hitR) return;
|
||||
onEditRoofPitchRef.current?.(drag.roofId, hitR[1]);
|
||||
onEditRoofPitchRef.current?.(drag.roofId, hitR[1] - gripDz({ roofId: drag.roofId }));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
grip3dEditFields,
|
||||
findCoincidentVertices,
|
||||
findMoveCoincidentVertices,
|
||||
explodeGripDz,
|
||||
type Grip3dEditState,
|
||||
} from "./grip3dHud";
|
||||
|
||||
@@ -311,3 +312,18 @@ describe("findMoveCoincidentVertices", () => {
|
||||
expect(findMoveCoincidentVertices(sampleProject, {})).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("explodeGripDz ([65])", () => {
|
||||
const w = sampleProject.walls[0];
|
||||
const offsets = { [w.floorId]: 2.5 };
|
||||
it("Versatz über das Geschoss des Ziels", () => {
|
||||
expect(explodeGripDz(sampleProject, offsets, { wallId: w.id })).toBe(2.5);
|
||||
const c = (sampleProject.ceilings ?? []).find((x) => x.floorId === w.floorId);
|
||||
if (c) expect(explodeGripDz(sampleProject, offsets, { ceilingId: c.id })).toBe(2.5);
|
||||
});
|
||||
it("ohne Explosion, unbekannt oder Zeichnung: 0", () => {
|
||||
expect(explodeGripDz(sampleProject, {}, { wallId: w.id })).toBe(0);
|
||||
expect(explodeGripDz(sampleProject, offsets, { wallId: "fehlt" })).toBe(0);
|
||||
expect(explodeGripDz(sampleProject, offsets, { drawingId: "d" })).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -324,3 +324,17 @@ export function findMoveCoincidentVertices(project: Project, self: Grip3dTarget)
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Explosionsaxonometrie ([65]): Höhenversatz (m), um den das Ziel eines 3D-Griffs im
|
||||
* auseinandergezogenen Modell liegt (`offsets` = Versatz je Geschoss-id, s. `explodeFloorOffsets`).
|
||||
* Griffe sitzen um diesen Betrag höher; gezogene Höhen ziehen ihn wieder ab (Modell bleibt
|
||||
* unversetzt). Zeichnungen: 0 — ihre Ebene ist die (bereits versetzte) Arbeitsebene.
|
||||
*/
|
||||
export function explodeGripDz(project: Project, offsets: Readonly<Record<string, number>>, target: Grip3dTarget): number {
|
||||
let floorId: string | undefined;
|
||||
if (target.wallId) floorId = project.walls.find((w) => w.id === target.wallId)?.floorId;
|
||||
else if (target.ceilingId) floorId = (project.ceilings ?? []).find((c) => c.id === target.ceilingId)?.floorId;
|
||||
else if (target.roofId) floorId = (project.roofs ?? []).find((r) => r.id === target.roofId)?.floorId;
|
||||
return (floorId && offsets[floorId]) || 0;
|
||||
}
|
||||
@@ -246,7 +246,7 @@ export function useWasm3dRenderer(
|
||||
// Fehler hier das bereits gesetzte Modell nicht mit wegreisst.
|
||||
if (typeof r.set_drawing_lines === "function") {
|
||||
try {
|
||||
r.set_drawing_lines(emitDrawingLineVerts(project));
|
||||
r.set_drawing_lines(emitDrawingLineVerts(project, explode));
|
||||
} catch (e) {
|
||||
console.warn("render3d set_drawing_lines fehlgeschlagen:", e);
|
||||
}
|
||||
|
||||
@@ -82,18 +82,25 @@ export function pushNativeScene(plan: Plan): void {
|
||||
* Öffnungs-Teilquadern plus Deckenplatten — ans native 3D-Fenster schieben.
|
||||
* No-op ohne Tauri.
|
||||
*/
|
||||
export function pushNativeWalls(project: Project): void {
|
||||
export function pushNativeWalls(
|
||||
project: Project,
|
||||
/** Explosionsabstand ([65], 0 = aus): dasselbe Modell wie im WASM-Viewport (`projectToModel3d`). */
|
||||
explode = lastExplode,
|
||||
): void {
|
||||
if (!isTauri()) return;
|
||||
lastProject = project;
|
||||
lastExplode = explode;
|
||||
clearTimeout(wallsTimer);
|
||||
wallsTimer = setTimeout(async () => {
|
||||
if (!(await isNativeEnabled())) return;
|
||||
void invokeNative("push_native_walls", { walls: projectToModel3d(project, { voids: true }) });
|
||||
void invokeNative("push_native_walls", { walls: projectToModel3d(project, { voids: true, explode }) });
|
||||
}, DEBOUNCE_MS);
|
||||
}
|
||||
|
||||
/** Letztes an {@link pushNativeWalls} übergebenes Projekt (für den Re-Push unten). */
|
||||
let lastProject: Project | null = null;
|
||||
/** Letzter Explosionsabstand (Re-Push nach truck-Ergebnis behält ihn). */
|
||||
let lastExplode = 0;
|
||||
|
||||
// truck-Extrusionen (s. toWalls3d.ts emitExtrudedSolids) laden WASM asynchron;
|
||||
// ohne diesen Re-Push nach Abschluss bliebe eine fertige Extrusion im nativen
|
||||
|
||||
@@ -36,7 +36,7 @@ import { levelMarkerPrimitives, levelMarksEnabled } from "../core";
|
||||
import { unitsForLevel } from "../tools/displayUnits";
|
||||
import { setSheetOwnerOutlines, setSheetSnapSegments, snapSegmentsFromPrimitives } from "../tools/sheetSnapGeometry";
|
||||
import { pushNativeScene, pushNativeWalls } from "./plan/nativeSync";
|
||||
import { selectionHighlightLines } from "../core";
|
||||
import { explodeFloorOffsets, selectionHighlightLines } from "../core";
|
||||
import { clashHighlightLines } from "../analysis/clash";
|
||||
import { useClashSession } from "../panels/clashSession";
|
||||
import { applyGroupDimmingToPlan } from "../state/groupActions";
|
||||
@@ -274,6 +274,11 @@ export const Content = memo(function Content({
|
||||
const clashes = useClashSession().clashes;
|
||||
// Explosionsaxonometrie ([65]): Hervorhebung folgt dem auseinandergezogenen 3D-Modell.
|
||||
const explode = useStore((s) => (s.explode3d ? s.explode3dGap : 0));
|
||||
// Arbeitsebene/Raster/Zeichnen-Vorschau auf dem gehobenen aktiven Geschoss.
|
||||
const explodeLift = useMemo(
|
||||
() => (explode > 0 ? (explodeFloorOffsets(project, explode)[level.id] ?? 0) : 0),
|
||||
[project, explode, level.id],
|
||||
);
|
||||
const { walls, ceilings, openings, stairs, roofs, contextObjects } = selection;
|
||||
const selectionLines = useMemo(
|
||||
() =>
|
||||
@@ -310,7 +315,7 @@ export const Content = memo(function Content({
|
||||
renderMode={renderMode}
|
||||
detail={detail}
|
||||
view3d={view3d}
|
||||
groundElevation={level.baseElevation ?? 0}
|
||||
groundElevation={(level.baseElevation ?? 0) + explodeLift}
|
||||
gridVisible={grid3dVisible}
|
||||
onToggleGrid={onToggleGrid3d}
|
||||
section3d={section3d}
|
||||
@@ -828,9 +833,11 @@ function LevelPlanView({
|
||||
useEffect(() => {
|
||||
pushNativeScene(plan);
|
||||
}, [plan]);
|
||||
// Explosionsaxonometrie ([65]) auch im nativen 3D-Fenster.
|
||||
const explode = useStore((s) => (s.explode3d ? s.explode3dGap : 0));
|
||||
useEffect(() => {
|
||||
pushNativeWalls(project);
|
||||
}, [project]);
|
||||
pushNativeWalls(project, explode);
|
||||
}, [project, explode]);
|
||||
|
||||
return (
|
||||
<section className="pane">
|
||||
|
||||
Reference in new issue
Block a user