SceneBuilder Module
Builds declarative Scene trees from game snapshots.
Functions and values
| Function or value |
Description
|
Full Usage:
buildScene snapshot config viewState
Parameters:
GameSnapshot
config : VizConfig
viewState : ViewState
Returns: Scene
|
Builds a complete Scene from a game snapshot, viz config, and view state.
|
|
Builds a `Scene` for an embedded / headless viewer (feature 035-central-gui-hub R8). Converts a live `GameState` + optional `MapGrid` into a minimal `GameSnapshot` and calls `buildScene` with `VizDefaults.defaultViewState`. Unlike `GameViz.start`, this opens no window — the caller owns the `SkiaViewer.Window` and composes the returned scene into its own frame loop. When `map` is `None` a tiny synthetic 16x16 heightmap stand-in is used so early frames during session start-up render without crashing; replace once the real `MapGrid` is available. This is a stateless, pure-ish function (the pulse-phase clock remains module-level). Cheap enough to call every frame.
|
Full Usage:
buildSceneHeadlessSized state map metalSpots defCache config viewportWidth viewportHeight
Parameters:
GameState
map : MapGrid option
metalSpots : (float32 * float32 * float32 * float32) array
defCache : UnitDefCache option
config : VizConfig
viewportWidth : int
viewportHeight : int
Returns: Scene
|
Variant of `buildSceneHeadless` that lets the embedder pin the viewport window dimensions AND supply the engine's metal-spot list. The hub uses this so the scene auto-fits to the Viewer tab's content rectangle instead of `VizDefaults.defaultViewState`'s 1024x640 default, and so metal-spot markers render when `OverlayKind.MetalSpots` is active. `defCache` is consumed by feature 038's `UnitDisplayAdapter` to populate `GameSnapshot.DisplayUnits` with correctly-classified glyph data. `None` keeps the pre-038 legacy placeholder path so tests and preview-only callers without a live `BarClient` continue to work.
|
Variant of `buildSceneHeadlessSized` that composes with a caller- supplied `ViewState` instead of auto-fitting. Used by embedders that want user zoom/pan control (e.g. the hub's Viewer tab) — they keep a mutable `ViewState`, adjust `Scale` / `OriginX/Y` on scroll-wheel + drag events, and pass the current value each frame. `defCache` — see `buildSceneHeadlessSized`.
|
|
Full Usage:
computeFitScale map viewportWidth viewportHeight
Parameters:
MapGrid option
viewportWidth : int
viewportHeight : int
Returns: float32
|
Returns the `Scale` value that would letterbox `map` into a viewport of the given dimensions. Callers use this to initialise their `ViewState` or re-fit after a window resize when `AutoFit = true`. Returns `1.0f` if the map is empty.
|
Full Usage:
computePulseAlpha elapsed periodSeconds
Parameters:
float
periodSeconds : float
Returns: byte
|
Computes a clamped pulse alpha byte in [60, 220] from elapsed seconds and period.
|
Full Usage:
resetPulsePhase ()
Parameters:
unit
|
Resets the pulse clock to zero. Call on session start/stop.
|
Full Usage:
updatePulsePhase deltaSeconds
Parameters:
float
|
Advances the pulse clock by one FrameTick's delta seconds and recomputes the shared phase used by metal-spot markers. Call once per FrameTick.
|
FSBarV1_Archived