[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
@@ -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],
|
||||
|
||||
Reference in new issue
Block a user