Skip to content

Analysis ​

Sustainability-analysis APIs — the environmental-performance layer: sun and daylight studies computed for the project's geo-located site. Accessed via snaptrude.analysis.

The synchronous visual overlays (sun-path diagram, real-time shadows) toggle instantly; the heatmap studies (direct sunlight hours, daylight illuminance) are asynchronous backend jobs — start them with compute, poll their state with get, and cancel or reset them. Site inputs are read via program.site: getLocation() for the geo-coordinates and getNorthAngle() for true north.

Site required — no fallback location

Every method that positions the sun or starts a study throws "Site is needed" when the project has no geo-located site/terrain. There is deliberately no fallback location — import a terrain/site context first, then verify with program.site.getLocation().

Sub-namespaces ​

NamespaceWhat it covers
analysis.sunpathThe sun-path diagram overlay — enable/disable (undoable) and query
analysis.shadowsReal-time sun shadows — toggle and scrub the sun's date-time (ISO strings)
analysis.sunlightHoursDirect-sunlight-hours heatmap job — compute / poll / cancel / reset
analysis.illuminanceDaylight-illuminance (lux) heatmap job — same shape, Pro-gated
analysis.heatmapsPlugin-supplied scalar heatmaps — renderSpaces / renderGrid / reset / isActive
analysis.weatherRead the site's typical-year EPW weather series (numeric, paged)
analysis.solarSample solar exposure at caller-chosen points (numeric), Pro-gated
analysis.daylightStandards-grade annual daylight metrics (IES LM-83 ASE), Pro-gated

Job polling pattern ​

The heatmap jobs run for minutes on the backend while every RPC call is capped at 30 s, so compute returns immediately and there is no completion event — polling is the pattern:

ts
const { success } = await snaptrude.analysis.sunlightHours.compute("2026-06-01", "2026-06-30");

let job = await snaptrude.analysis.sunlightHours.get();
while (job?.status === "running") {
  await new Promise((r) => setTimeout(r, 5000));
  job = await snaptrude.analysis.sunlightHours.get();
}
// job?.status === "active" → the heatmap is rendered on the scene

State coherence ​

API writes go through the same command/helper paths as the UI, so the editor and plugins never desync:

  • The sun-path toggle is undoable (core.history.undo reverts it).
  • Shadows and the heatmap analyses are mutually exclusive (enabling one resets the other), exactly as in the sustainability sidebar.
  • Heatmaps are invalidated by scene-mutating edits — re-run the study after changing the model.