perf: reuse visible room contours for PDF

Issue: #53
User-Visible: no
This commit is contained in:
Matysh
2026-09-07 04:13:10 +03:00
parent b6811ba7c7
commit c226a0adcd
41 changed files with 399 additions and 380 deletions
+6 -1
View File
@@ -10688,6 +10688,8 @@ export class HouseplanCard extends LitElement {
for (const [id, asset] of this._decorAssets) {
decorAssets.set(id, { url: this._display(asset.url), mime: asset.mime });
}
const sharedWallGeometry = this._wallUnionGeometry();
const openCuts = this._openCuts();
return runtime.render({
config: this._serverCfg,
rawSpace,
@@ -10699,7 +10701,10 @@ export class HouseplanCard extends LitElement {
hass: this.hass,
backdropUrl: space.bg ? this._display(space.bg.href) : '',
decorAssets,
sharedWallGeometry: this._wallUnionGeometry(),
sharedWallGeometry,
resolveInnerContour: (roomId) => this._innerRoomContour(
space, roomId, openCuts, sharedWallGeometry?.roomGeom, sharedWallGeometry?.multiWallNodes,
),
t: (key, vars) => this._t(key as I18nKey, vars),
toast: (message) => this._showToast(message),
close: () => { this._pdfDialog = false; this.requestUpdate(); },
+1
View File
@@ -18,6 +18,7 @@ export interface PdfDialogContext {
backdropUrl: string;
decorAssets: ReadonlyMap<string, PdfAssetReference>;
sharedWallGeometry?: PdfSharedWallGeometry | null;
resolveInnerContour?: (roomId: string) => number[][] | null | undefined;
t: (key: string, vars?: Record<string, string | number>) => string;
toast: (message: string) => void;
close: () => void;
+5 -2
View File
@@ -68,6 +68,8 @@ export interface PdfSceneInput {
rasters?: readonly PdfRasterPlacement[];
/** The exact structural pass already used by the visible card. */
sharedWallGeometry?: PdfSharedWallGeometry | null;
/** The visible card's per-room clean-floor cache, resolved only when dimensions are requested. */
resolveInnerContour?: (roomId: string) => number[][] | null | undefined;
}
const MM = 72 / 25.4;
@@ -210,10 +212,11 @@ export function buildPdfPage(input: PdfSceneInput): PdfPage & { scale: number }
if (input.options.dimensions) for (const room of input.space.rooms) {
const original = roomPoly(room);
if (!original) continue;
dimensionContours.set(room, room.id ? innerContourForRoom(
const shared = room.id ? input.resolveInnerContour?.(room.id) : undefined;
dimensionContours.set(room, room.id ? (shared === undefined ? innerContourForRoom(
input.space.rooms, room.id, built.walls, built.zero.contour, GRID_STEP_N,
built.cellCm, GRID_PITCH, NORM_W, built.geometry.roomGeom, built.geometry.multiWallNodes,
) || original : original);
) : shared) || original : original);
}
const architectureRings = built.geometry.status === 'failed-core'
? input.space.rooms.map((room) => roomPoly(room) || []).filter((ring) => ring.length)