UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

57 lines 2.95 kB
import { Box } from '@expofp/geometry'; import type { SceneDef } from '@expofp/renderer'; /** * Bounding box (in local SVG units) of all drawn scene content, excluding the * background "areamap" layer. This is the real venue extent and the rect that * Fit-to-screen should target — the full SVG area (`svgArea`) instead spans the * whole surrounding map (e.g. an entire city), which makes the fit zoom out far * too much. * * Uses the same name-based areamap exclusion as MaplibreWrapper, so it needs no * layer flags and degrades to "all content" for venue-only floorplans. */ export declare function getSceneVenueRect(sceneDef: SceneDef | null | undefined): Box | null; /** * Margin to leave around the venue when fitting, as a fraction of the venue * size. Mirrors the legacy renderer's adaptive rule: a venue that is tiny * relative to its surroundings gets more breathing room than one that already * fills most of the available area. */ export declare function getVenueFitMarginPercent(venueRect: Box, baseRect: Box): number; /** Grow a rect outward by `pct` of its size on each side. */ export declare function expandRectByPercent(rect: Box, pct: number): Box; /** * Canonical Fit-to-screen target: the venue extent grown by its adaptive margin. * `baseRect` is the surrounding map area (`svgArea`) used to scale the margin. * Returns null when the scene has no fittable content. */ export declare function getVenueFitRect(sceneDef: SceneDef | null | undefined, baseRect: Box): Box | null; /** Where a resolved Fit-to-screen rectangle came from (most → least specific). */ export type VenueFitSource = 'layer-viewbox' | 'explicit-viewbox' | 'layer-rectangle' | 'scene-derived' | 'svg-area'; export interface VenueFitInputs { /** Union of authored per-layer viewboxes (`LayerStore.viewboxRectangle`). */ layerViewbox?: Box | null; /** `svgArea` when it was explicitly authored (`__viewbox` / `rect#VIEWBOX`). */ explicitArea?: Box | null; /** Current-level geometry rect in radio mode (`LayerStore.rectangle`). */ layerRectangle?: Box | null; /** Scene to derive the venue extent from when nothing above is authored. */ sceneDef?: SceneDef | null; /** Whole-canvas fallback and margin base. */ svgArea: Box; } /** * Single source of truth for the Fit-to-screen / initial-view target. Picks the * most specific available reference in priority order. This is the seam a future * multi-venue model plugs into: it would resolve the *active* venue's box here, * leaving every call site unchanged. * * Authored boxes (`layer-viewbox`, `explicit-viewbox`) are returned as-is — the * caller's fit already adds viewport padding. Geometry-derived boxes * (`scene-derived`) carry their adaptive breathing-room margin. */ export declare function resolveVenueFitRect(inputs: VenueFitInputs): { rect: Box; source: VenueFitSource; }; //# sourceMappingURL=scene-bounds.d.ts.map