Merge [227] Kontextgebäude aufs Gelände, Baugrube im Rendering
This commit is contained in:
29 files changed
+461
-83
No files matched your search
@@ -29,6 +29,7 @@ import {
|
||||
type RenderOptions,
|
||||
} from "./blenderRender";
|
||||
import { exportGlb } from "./exportMesh";
|
||||
import { meshSceneGroups } from "./meshScene.testutil";
|
||||
import { cameraToView } from "../viewport/cameraView";
|
||||
|
||||
const when = new Date(Date.UTC(2026, 5, 21, 10, 0, 0));
|
||||
@@ -342,3 +343,31 @@ describe("Kamera wählen ([213])", () => {
|
||||
expect(pkg.scene.sun.elevation).toBeLessThan(renderSun(mk, defaultRenderTime(mk)).elevation);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Baugrube im Rendering ausblenden ([227])", () => {
|
||||
const complex = buildComplexSampleProject();
|
||||
const lowest = (groups: ReturnType<typeof meshSceneGroups>, kind: string): number => {
|
||||
let m = Infinity;
|
||||
for (const g of groups) if (g.kind === kind) for (const p of g.prims) for (let i = 1; i < p.positions.length; i += 3) m = Math.min(m, p.positions[i]);
|
||||
return m;
|
||||
};
|
||||
|
||||
it("hinterfüllt: das Gelände ist das gewachsene, ohne Sohle bei −3.35 m; sonst bleibt die Grube", () => {
|
||||
expect(lowest(meshSceneGroups(complex), "terrain")).toBeCloseTo(-3.35, 2);
|
||||
expect(lowest(meshSceneGroups(complex, true), "terrain")).toBeGreaterThan(-3.3);
|
||||
});
|
||||
|
||||
it("Paket: Vorgabe an (scene.backfilled, kleineres/anderes GLB), mit backfilled: false bleibt die Grube", async () => {
|
||||
const on = await buildRenderPackage(complex, opts());
|
||||
const off = await buildRenderPackage(complex, opts({ backfilled: false }));
|
||||
expect(on.scene.backfilled).toBe(true);
|
||||
expect(off.scene.backfilled).toBe(false);
|
||||
const size = (p: typeof on) => p.files.find((f) => f.path === "model.glb")!.bytes.length;
|
||||
expect(size(on)).not.toBe(size(off));
|
||||
});
|
||||
|
||||
it("das normale GLB (Export, Anzeige) behält die Baugrube", () => {
|
||||
expect(exportGlb(complex).length).toBe(exportGlb(complex, { backfilled: false }).length);
|
||||
expect(exportGlb(complex).length).not.toBe(exportGlb(complex, { backfilled: true }).length);
|
||||
});
|
||||
});
|
||||
@@ -82,6 +82,11 @@ export interface RenderOptions {
|
||||
denoise?: boolean;
|
||||
/** `cpu` erzwingt die CPU, sonst GPU wenn vorhanden. */
|
||||
device?: "auto" | "cpu";
|
||||
/**
|
||||
* [227] Baugrube ausblenden: Gelände ohne Aushub, hinterfüllt bis an die Fassade (Standard: an — für Bilder). Nur das Paket;
|
||||
* die 3D-Ansicht im Modell bleibt unberührt (Klasse „07 Baugrube").
|
||||
*/
|
||||
backfilled?: boolean;
|
||||
}
|
||||
|
||||
/** Eintrag der Materialtabelle in `scene.json`. */
|
||||
@@ -124,6 +129,8 @@ export interface RenderScene {
|
||||
samples: number;
|
||||
denoise: boolean;
|
||||
device: "auto" | "cpu";
|
||||
/** [227] Gelände im Paket ohne Baugruben (hinterfüllt); nur Hinweis, der Leser setzt nichts um. */
|
||||
backfilled: boolean;
|
||||
camera: RenderCameraSpec;
|
||||
sun: { azimuth: number; elevation: number; when: string; lat: number; lon: number };
|
||||
materials: RenderMaterial[];
|
||||
@@ -334,7 +341,7 @@ function componentMaterials(project: Project): Map<string, ComponentMaterial> {
|
||||
* Kamera, Sonne. Verlangt das geladene Format-Modul (`await loadFileio()`) und den Kern.
|
||||
*/
|
||||
export async function buildRenderPackage(project: Project, opts: RenderOptions, loadTexture?: TextureLoader): Promise<RenderPackage> {
|
||||
const glb = splitRoofMaterials(exportGlb(project), project);
|
||||
const glb = splitRoofMaterials(exportGlb(project, { backfilled: opts.backfilled ?? true }), project);
|
||||
const files: RenderPackage["files"] = [{ path: "model.glb", bytes: glb }];
|
||||
const materials = glbMaterials(glb);
|
||||
const comp = componentMaterials(project);
|
||||
@@ -377,6 +384,7 @@ export async function buildRenderPackage(project: Project, opts: RenderOptions,
|
||||
samples: Math.max(1, Math.round(opts.samples)),
|
||||
denoise: opts.denoise ?? true,
|
||||
device: opts.device ?? "auto",
|
||||
backfilled: opts.backfilled ?? true,
|
||||
camera: opts.camera,
|
||||
sun: renderSun(project, opts.when),
|
||||
materials,
|
||||
|
||||
@@ -19,11 +19,13 @@ export interface MeshOptions {
|
||||
openingParts?: boolean;
|
||||
/** Gelände und importierte Kontext-Meshes (IFC/DXF) mitnehmen (Standard: ja). */
|
||||
context?: boolean;
|
||||
/** [227] Baugruben weglassen: Gelände ohne Aushub (hinterfüllt, bis an die Fassade geschlossen). Standard: nein. */
|
||||
backfilled?: boolean;
|
||||
}
|
||||
|
||||
/** Ruft eine Rust-Bindung; leeres Ergebnis (kaputter Puffer) wird zum Fehler mit dem Grund. */
|
||||
function write<T extends string | Uint8Array>(project: Project, opts: MeshOptions, byLevel: boolean, run: (m: ReturnType<typeof fileio>, buf: Float64Array, strings: string) => T): T {
|
||||
const args = [(opts.openingParts ?? true) ? 1 : 0, (opts.context ?? true) ? 1 : 0, byLevel ? 1 : 0];
|
||||
const args = [(opts.openingParts ?? true) ? 1 : 0, (opts.context ?? true) ? 1 : 0, byLevel ? 1 : 0, opts.backfilled ? 1 : 0];
|
||||
const [buf, strings] = decodeExportFlat(documentFor(project).queryBin("meshExportData", args));
|
||||
const m = fileio();
|
||||
const out = run(m, buf, strings);
|
||||
|
||||
@@ -13,8 +13,8 @@ export interface SceneGroup {
|
||||
}
|
||||
|
||||
/** Knoten der Mesh-Szene (Welt x, Höhe, y; Wicklung nach aussen im Modell). */
|
||||
export function meshSceneGroups(project: Project): SceneGroup[] {
|
||||
const [b, text] = decodeExportFlat(documentFor(project).queryBin("meshExportData", [1, 1, 0]));
|
||||
export function meshSceneGroups(project: Project, backfilled = false): SceneGroup[] {
|
||||
const [b, text] = decodeExportFlat(documentFor(project).queryBin("meshExportData", [1, 1, 0, backfilled ? 1 : 0]));
|
||||
const s = text.split("\0");
|
||||
let i = 2;
|
||||
i += 1 + b[i] * 7;
|
||||
|
||||
Reference in new issue
Block a user