@snaptrude/plugin-core 0.3.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +130 -48
- package/CHANGELOG.md +163 -0
- package/api-manifest.full.json +5600 -0
- package/api-manifest.json +5502 -0
- package/dist/api/analysis/heatmaps.d.ts +234 -0
- package/dist/api/analysis/heatmaps.d.ts.map +1 -0
- package/dist/api/analysis/illuminance.d.ts +145 -0
- package/dist/api/analysis/illuminance.d.ts.map +1 -0
- package/dist/api/analysis/index.d.ts +44 -0
- package/dist/api/analysis/index.d.ts.map +1 -0
- package/dist/api/analysis/shadows.d.ts +165 -0
- package/dist/api/analysis/shadows.d.ts.map +1 -0
- package/dist/api/analysis/sunlightHours.d.ts +208 -0
- package/dist/api/analysis/sunlightHours.d.ts.map +1 -0
- package/dist/api/analysis/sunpath.d.ts +80 -0
- package/dist/api/analysis/sunpath.d.ts.map +1 -0
- package/dist/api/core/buildings.d.ts +427 -0
- package/dist/api/core/buildings.d.ts.map +1 -0
- package/dist/api/core/comment/index.d.ts +230 -0
- package/dist/api/core/comment/index.d.ts.map +1 -0
- package/dist/api/core/geom/create/index.d.ts +247 -0
- package/dist/api/core/geom/create/index.d.ts.map +1 -0
- package/dist/api/core/geom/delete/index.d.ts +72 -0
- package/dist/api/core/geom/delete/index.d.ts.map +1 -0
- package/dist/api/core/geom/index.d.ts +24 -23
- package/dist/api/core/geom/index.d.ts.map +1 -1
- package/dist/api/core/geom/query/arc.d.ts +169 -0
- package/dist/api/core/geom/query/arc.d.ts.map +1 -0
- package/dist/api/core/geom/query/brep.d.ts +402 -0
- package/dist/api/core/geom/query/brep.d.ts.map +1 -0
- package/dist/api/core/geom/query/circle.d.ts +378 -0
- package/dist/api/core/geom/query/circle.d.ts.map +1 -0
- package/dist/api/core/geom/query/contour.d.ts +450 -0
- package/dist/api/core/geom/query/contour.d.ts.map +1 -0
- package/dist/api/core/geom/query/curve.d.ts +918 -0
- package/dist/api/core/geom/query/curve.d.ts.map +1 -0
- package/dist/api/core/geom/query/edge.d.ts +128 -0
- package/dist/api/core/geom/query/edge.d.ts.map +1 -0
- package/dist/api/core/geom/query/face.d.ts +363 -0
- package/dist/api/core/geom/query/face.d.ts.map +1 -0
- package/dist/api/core/geom/query/halfedge.d.ts +206 -0
- package/dist/api/core/geom/query/halfedge.d.ts.map +1 -0
- package/dist/api/core/geom/query/index.d.ts +61 -0
- package/dist/api/core/geom/query/index.d.ts.map +1 -0
- package/dist/api/core/geom/query/profile.d.ts +410 -0
- package/dist/api/core/geom/query/profile.d.ts.map +1 -0
- package/dist/api/core/geom/query/vertex.d.ts +187 -0
- package/dist/api/core/geom/query/vertex.d.ts.map +1 -0
- package/dist/api/core/geom/update/contour.d.ts +272 -0
- package/dist/api/core/geom/update/contour.d.ts.map +1 -0
- package/dist/api/core/geom/update/curve.d.ts +180 -0
- package/dist/api/core/geom/update/curve.d.ts.map +1 -0
- package/dist/api/core/geom/update/index.d.ts +27 -0
- package/dist/api/core/geom/update/index.d.ts.map +1 -0
- package/dist/api/core/geom/update/profile.d.ts +329 -0
- package/dist/api/core/geom/update/profile.d.ts.map +1 -0
- package/dist/api/core/groups.d.ts +485 -0
- package/dist/api/core/groups.d.ts.map +1 -0
- package/dist/api/core/history/index.d.ts +78 -0
- package/dist/api/core/history/index.d.ts.map +1 -0
- package/dist/api/core/index.d.ts +51 -1
- package/dist/api/core/index.d.ts.map +1 -1
- package/dist/api/core/io/import/index.d.ts +392 -0
- package/dist/api/core/io/import/index.d.ts.map +1 -0
- package/dist/api/core/io/index.d.ts +35 -0
- package/dist/api/core/io/index.d.ts.map +1 -0
- package/dist/api/core/io/job/index.d.ts +139 -0
- package/dist/api/core/io/job/index.d.ts.map +1 -0
- package/dist/api/core/io/query/index.d.ts +74 -0
- package/dist/api/core/io/query/index.d.ts.map +1 -0
- package/dist/api/core/io/terrain/index.d.ts +206 -0
- package/dist/api/core/io/terrain/index.d.ts.map +1 -0
- package/dist/api/core/io/underlay/index.d.ts +286 -0
- package/dist/api/core/io/underlay/index.d.ts.map +1 -0
- package/dist/api/core/layers.d.ts +402 -0
- package/dist/api/core/layers.d.ts.map +1 -0
- package/dist/api/core/math/quat.d.ts +111 -128
- package/dist/api/core/math/quat.d.ts.map +1 -1
- package/dist/api/core/math/vec3.d.ts +120 -102
- package/dist/api/core/math/vec3.d.ts.map +1 -1
- package/dist/api/core/project/index.d.ts +399 -0
- package/dist/api/core/project/index.d.ts.map +1 -0
- package/dist/api/core/tags.d.ts +755 -0
- package/dist/api/core/tags.d.ts.map +1 -0
- package/dist/api/core/units/index.d.ts +175 -0
- package/dist/api/core/units/index.d.ts.map +1 -0
- package/dist/api/core/zoom/index.d.ts +45 -0
- package/dist/api/core/zoom/index.d.ts.map +1 -0
- package/dist/api/design/boolean/index.d.ts +168 -0
- package/dist/api/design/boolean/index.d.ts.map +1 -0
- package/dist/api/design/create/index.d.ts +837 -0
- package/dist/api/design/create/index.d.ts.map +1 -0
- package/dist/api/design/delete/index.d.ts +63 -0
- package/dist/api/design/delete/index.d.ts.map +1 -0
- package/dist/api/design/doors/index.d.ts +268 -0
- package/dist/api/design/doors/index.d.ts.map +1 -0
- package/dist/api/design/edit/index.d.ts +49 -0
- package/dist/api/design/edit/index.d.ts.map +1 -0
- package/dist/api/design/erase/index.d.ts +160 -0
- package/dist/api/design/erase/index.d.ts.map +1 -0
- package/dist/api/design/furniture/index.d.ts +123 -0
- package/dist/api/design/furniture/index.d.ts.map +1 -0
- package/dist/api/design/index.d.ts +153 -0
- package/dist/api/design/index.d.ts.map +1 -0
- package/dist/api/design/lock.d.ts +41 -0
- package/dist/api/design/lock.d.ts.map +1 -0
- package/dist/api/design/materials/index.d.ts +297 -0
- package/dist/api/design/materials/index.d.ts.map +1 -0
- package/dist/api/design/query/geometry/index.d.ts +140 -0
- package/dist/api/design/query/geometry/index.d.ts.map +1 -0
- package/dist/api/design/query/index.d.ts +1011 -0
- package/dist/api/design/query/index.d.ts.map +1 -0
- package/dist/api/design/query/spaces.d.ts +221 -0
- package/dist/api/design/query/spaces.d.ts.map +1 -0
- package/dist/api/design/selection/index.d.ts +282 -0
- package/dist/api/design/selection/index.d.ts.map +1 -0
- package/dist/api/design/shared.d.ts +38 -0
- package/dist/api/design/shared.d.ts.map +1 -0
- package/dist/api/design/transform/index.d.ts +87 -0
- package/dist/api/design/transform/index.d.ts.map +1 -0
- package/dist/api/design/update/index.d.ts +178 -0
- package/dist/api/design/update/index.d.ts.map +1 -0
- package/dist/api/design/windows/index.d.ts +189 -0
- package/dist/api/design/windows/index.d.ts.map +1 -0
- package/dist/api/entity/buildableEnvelope.d.ts +261 -0
- package/dist/api/entity/buildableEnvelope.d.ts.map +1 -0
- package/dist/api/entity/department.d.ts +0 -98
- package/dist/api/entity/department.d.ts.map +1 -1
- package/dist/api/entity/index.d.ts +9 -9
- package/dist/api/entity/index.d.ts.map +1 -1
- package/dist/api/entity/referenceLine.d.ts +49 -106
- package/dist/api/entity/referenceLine.d.ts.map +1 -1
- package/dist/api/entity/space.d.ts +484 -251
- package/dist/api/entity/space.d.ts.map +1 -1
- package/dist/api/entity/story.d.ts +49 -39
- package/dist/api/entity/story.d.ts.map +1 -1
- package/dist/api/index.d.ts +22 -12
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/presentation/aiInspiration.d.ts +440 -0
- package/dist/api/presentation/aiInspiration.d.ts.map +1 -0
- package/dist/api/presentation/diagrams.d.ts +81 -0
- package/dist/api/presentation/diagrams.d.ts.map +1 -0
- package/dist/api/presentation/import.d.ts +113 -0
- package/dist/api/presentation/import.d.ts.map +1 -0
- package/dist/api/presentation/index.d.ts +46 -0
- package/dist/api/presentation/index.d.ts.map +1 -0
- package/dist/api/presentation/sheets.d.ts +176 -0
- package/dist/api/presentation/sheets.d.ts.map +1 -0
- package/dist/api/presentation/views.d.ts +296 -0
- package/dist/api/presentation/views.d.ts.map +1 -0
- package/dist/api/program/adjacency.d.ts +155 -0
- package/dist/api/program/adjacency.d.ts.map +1 -0
- package/dist/api/program/areas.d.ts +360 -0
- package/dist/api/program/areas.d.ts.map +1 -0
- package/dist/api/program/classification.d.ts +135 -0
- package/dist/api/program/classification.d.ts.map +1 -0
- package/dist/api/program/cores.d.ts +174 -0
- package/dist/api/program/cores.d.ts.map +1 -0
- package/dist/api/program/departments.d.ts +431 -0
- package/dist/api/program/departments.d.ts.map +1 -0
- package/dist/api/program/index.d.ts +69 -0
- package/dist/api/program/index.d.ts.map +1 -0
- package/dist/api/program/layout.d.ts +63 -0
- package/dist/api/program/layout.d.ts.map +1 -0
- package/dist/api/program/metrics.d.ts +108 -0
- package/dist/api/program/metrics.d.ts.map +1 -0
- package/dist/api/program/site.d.ts +451 -0
- package/dist/api/program/site.d.ts.map +1 -0
- package/dist/api/program/spreadsheet.d.ts +2041 -0
- package/dist/api/program/spreadsheet.d.ts.map +1 -0
- package/dist/handles.d.ts +171 -0
- package/dist/handles.d.ts.map +1 -0
- package/dist/host-utils.d.ts +7 -5
- package/dist/host-utils.d.ts.map +1 -1
- package/dist/index.cjs +4344 -899
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3682 -865
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
- package/scripts/generate-manifest.mjs +193 -0
- package/scripts/generate-manifest.test.mjs +215 -0
- package/src/api/analysis/heatmaps.ts +256 -0
- package/src/api/analysis/illuminance.ts +155 -0
- package/src/api/analysis/index.ts +46 -0
- package/src/api/analysis/shadows.ts +183 -0
- package/src/api/analysis/sunlightHours.ts +211 -0
- package/src/api/analysis/sunpath.ts +83 -0
- package/src/api/core/buildings.ts +485 -0
- package/src/api/core/comment/index.ts +258 -0
- package/src/api/core/geom/create/index.ts +293 -0
- package/src/api/core/geom/delete/index.ts +78 -0
- package/src/api/core/geom/index.ts +24 -23
- package/src/api/core/geom/query/arc.ts +169 -0
- package/src/api/core/geom/query/brep.ts +444 -0
- package/src/api/core/geom/query/circle.ts +404 -0
- package/src/api/core/geom/query/contour.ts +540 -0
- package/src/api/core/geom/query/curve.ts +1078 -0
- package/src/api/core/geom/query/edge.ts +130 -0
- package/src/api/core/geom/query/face.ts +403 -0
- package/src/api/core/geom/query/halfedge.ts +210 -0
- package/src/api/core/geom/query/index.ts +63 -0
- package/src/api/core/geom/query/profile.ts +473 -0
- package/src/api/core/geom/query/vertex.ts +205 -0
- package/src/api/core/geom/update/contour.ts +315 -0
- package/src/api/core/geom/update/curve.ts +209 -0
- package/src/api/core/geom/update/index.ts +29 -0
- package/src/api/core/geom/update/profile.ts +377 -0
- package/src/api/core/groups.ts +521 -0
- package/src/api/core/history/index.ts +84 -0
- package/src/api/core/index.ts +51 -1
- package/src/api/core/io/import/index.ts +432 -0
- package/src/api/core/io/index.ts +37 -0
- package/src/api/core/io/job/index.ts +140 -0
- package/src/api/core/io/query/index.ts +71 -0
- package/src/api/core/io/terrain/index.ts +214 -0
- package/src/api/core/io/underlay/index.ts +295 -0
- package/src/api/core/layers.ts +333 -0
- package/src/api/core/math/quat.ts +112 -235
- package/src/api/core/math/vec3.ts +124 -159
- package/src/api/core/project/index.ts +418 -0
- package/src/api/core/tags.ts +808 -0
- package/src/api/core/units/index.ts +164 -0
- package/src/api/core/zoom/index.ts +47 -0
- package/src/api/design/boolean/index.ts +179 -0
- package/src/api/design/create/index.ts +895 -0
- package/src/api/design/delete/index.ts +67 -0
- package/src/api/design/doors/index.ts +285 -0
- package/src/api/design/edit/index.ts +54 -0
- package/src/api/design/erase/index.ts +151 -0
- package/src/api/design/furniture/index.ts +130 -0
- package/src/api/design/index.ts +162 -0
- package/src/api/design/lock.ts +42 -0
- package/src/api/design/materials/index.ts +301 -0
- package/src/api/design/query/geometry/index.ts +166 -0
- package/src/api/design/query/index.ts +937 -0
- package/src/api/design/query/spaces.ts +132 -0
- package/src/api/design/selection/index.ts +273 -0
- package/src/api/design/shared.ts +40 -0
- package/src/api/design/transform/index.ts +93 -0
- package/src/api/design/update/index.ts +117 -0
- package/src/api/design/windows/index.ts +207 -0
- package/src/api/entity/buildableEnvelope.ts +318 -0
- package/src/api/entity/department.ts +0 -113
- package/src/api/entity/index.ts +9 -9
- package/src/api/entity/referenceLine.ts +50 -38
- package/src/api/entity/space.ts +285 -226
- package/src/api/entity/story.ts +53 -42
- package/src/api/index.ts +22 -12
- package/src/api/presentation/aiInspiration.ts +362 -0
- package/src/api/presentation/diagrams.ts +84 -0
- package/src/api/presentation/import.ts +112 -0
- package/src/api/presentation/index.ts +48 -0
- package/src/api/presentation/sheets.ts +198 -0
- package/src/api/presentation/views.ts +303 -0
- package/src/api/program/adjacency.ts +164 -0
- package/src/api/program/areas.ts +335 -0
- package/src/api/program/classification.ts +138 -0
- package/src/api/program/cores.ts +171 -0
- package/src/api/program/departments.ts +465 -0
- package/src/api/program/index.ts +71 -0
- package/src/api/program/layout.ts +68 -0
- package/src/api/program/metrics.ts +120 -0
- package/src/api/program/site.ts +419 -0
- package/src/api/program/spreadsheet.ts +2075 -0
- package/src/handles.ts +194 -0
- package/src/host-utils.ts +10 -6
- package/src/index.ts +1 -0
- package/dist/api/core/geom/arc.d.ts +0 -81
- package/dist/api/core/geom/arc.d.ts.map +0 -1
- package/dist/api/core/geom/curve.d.ts +0 -70
- package/dist/api/core/geom/curve.d.ts.map +0 -1
- package/dist/api/core/geom/line.d.ts +0 -56
- package/dist/api/core/geom/line.d.ts.map +0 -1
- package/dist/api/core/geom/profile.d.ts +0 -121
- package/dist/api/core/geom/profile.d.ts.map +0 -1
- package/dist/api/tools/copy.d.ts +0 -59
- package/dist/api/tools/copy.d.ts.map +0 -1
- package/dist/api/tools/index.d.ts +0 -33
- package/dist/api/tools/index.d.ts.map +0 -1
- package/dist/api/tools/material.d.ts +0 -51
- package/dist/api/tools/material.d.ts.map +0 -1
- package/dist/api/tools/offset.d.ts +0 -43
- package/dist/api/tools/offset.d.ts.map +0 -1
- package/dist/api/tools/selection.d.ts +0 -48
- package/dist/api/tools/selection.d.ts.map +0 -1
- package/dist/api/tools/transform.d.ts +0 -114
- package/dist/api/tools/transform.d.ts.map +0 -1
- package/dist/api/units/index.d.ts +0 -163
- package/dist/api/units/index.d.ts.map +0 -1
- package/src/api/core/geom/arc.ts +0 -70
- package/src/api/core/geom/curve.ts +0 -41
- package/src/api/core/geom/line.ts +0 -53
- package/src/api/core/geom/profile.ts +0 -94
- package/src/api/tools/copy.ts +0 -55
- package/src/api/tools/index.ts +0 -39
- package/src/api/tools/material.ts +0 -49
- package/src/api/tools/offset.ts +0 -43
- package/src/api/tools/selection.ts +0 -51
- package/src/api/tools/transform.ts +0 -117
- package/src/api/units/index.ts +0 -163
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { PluginApiReturn } from "../../types"
|
|
2
|
+
import {
|
|
3
|
+
PluginAnalysisComputeResult,
|
|
4
|
+
PluginAnalysisJobStateResult,
|
|
5
|
+
} from "./sunlightHours"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Analysis illuminance — the daylight illuminance (lux) heatmap study.
|
|
9
|
+
*
|
|
10
|
+
* Computes interior daylight illuminance over a date range and renders the
|
|
11
|
+
* result as a heatmap on the scene. **Pro-gated**: every method that starts
|
|
12
|
+
* a run throws when the workspace is not on a Pro plan.
|
|
13
|
+
*
|
|
14
|
+
* Like {@linkcode PluginAnalysisSunlightHoursApi} (`analysis.sunlightHours`),
|
|
15
|
+
* this is an **asynchronous backend job**:
|
|
16
|
+
*
|
|
17
|
+
* 1. {@linkcode PluginAnalysisIlluminanceApi.compute} starts the job and
|
|
18
|
+
* returns immediately.
|
|
19
|
+
* 2. Poll {@linkcode PluginAnalysisIlluminanceApi.get} until `status` is
|
|
20
|
+
* `"active"` (heatmap rendered) — a run typically takes minutes. There is
|
|
21
|
+
* no completion event; polling is the pattern.
|
|
22
|
+
* 3. {@linkcode PluginAnalysisIlluminanceApi.cancel} aborts an in-flight
|
|
23
|
+
* run; {@linkcode PluginAnalysisIlluminanceApi.reset} clears a rendered
|
|
24
|
+
* heatmap.
|
|
25
|
+
*
|
|
26
|
+
* Illuminance analyses BIM slab and roof objects (floors, roofs, …) — walls
|
|
27
|
+
* or bare Masses are not enough — and requires the 3D view. Heatmaps are invalidated by
|
|
28
|
+
* scene-mutating edits. Dates cross as ISO 8601 date strings
|
|
29
|
+
* (`"YYYY-MM-DD"`).
|
|
30
|
+
*
|
|
31
|
+
* Accessed via `snaptrude.analysis.illuminance`.
|
|
32
|
+
*/
|
|
33
|
+
export abstract class PluginAnalysisIlluminanceApi {
|
|
34
|
+
constructor() {}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Start a daylight-illuminance run for a date range.
|
|
38
|
+
*
|
|
39
|
+
* Starts the backend job and **returns immediately** — it does not wait
|
|
40
|
+
* for the heatmap. Poll {@linkcode PluginAnalysisIlluminanceApi.get} until
|
|
41
|
+
* `status` is `"active"`. Starting a new run while one is in flight
|
|
42
|
+
* replaces it. Shadows and the heatmap analyses are mutually exclusive in
|
|
43
|
+
* the product: starting a run disables real-time shadows and resets/cancels
|
|
44
|
+
* any {@linkcode PluginAnalysisSunlightHoursApi}
|
|
45
|
+
* (`analysis.sunlightHours`) study.
|
|
46
|
+
*
|
|
47
|
+
* @param startDate - Start of the study range, ISO date `"YYYY-MM-DD"`.
|
|
48
|
+
* @param endDate - End of the study range, ISO date `"YYYY-MM-DD"` (on or
|
|
49
|
+
* after `startDate`).
|
|
50
|
+
* @returns A {@linkcode PluginAnalysisComputeResult} — `{ success: true }`
|
|
51
|
+
* when the job was started. The `{ success: false, error }` arm is
|
|
52
|
+
* reserved — not yet emitted (start failures currently throw).
|
|
53
|
+
* @throws When the workspace is not on a **Pro** plan (illuminance is a
|
|
54
|
+
* Pro feature).
|
|
55
|
+
* @throws When the project has no geo-located site/terrain (no location to
|
|
56
|
+
* compute daylight for — there is no fallback location).
|
|
57
|
+
* @throws When the scene has no slab or roof BIM object to analyse (walls
|
|
58
|
+
* or bare Masses are not enough) or the editor is not in the 3D view.
|
|
59
|
+
* @throws When a date is not a parseable ISO date or the range is inverted.
|
|
60
|
+
* @throws When plugin writes are disabled.
|
|
61
|
+
*
|
|
62
|
+
* @examplePrompt Run a daylight illuminance analysis for December
|
|
63
|
+
* @examplePrompt Compute the lux levels inside the building for winter
|
|
64
|
+
* @examplePrompt How much daylight do the interior floors get?
|
|
65
|
+
*
|
|
66
|
+
* # Example
|
|
67
|
+
* ```ts
|
|
68
|
+
* const { success } = await snaptrude.analysis.illuminance.compute(
|
|
69
|
+
* "2026-12-01",
|
|
70
|
+
* "2026-12-31",
|
|
71
|
+
* )
|
|
72
|
+
* // poll until the heatmap is rendered
|
|
73
|
+
* let job = await snaptrude.analysis.illuminance.get()
|
|
74
|
+
* while (job?.status === "running") {
|
|
75
|
+
* await new Promise((r) => setTimeout(r, 5000))
|
|
76
|
+
* job = await snaptrude.analysis.illuminance.get()
|
|
77
|
+
* }
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
public abstract compute(
|
|
81
|
+
startDate: string,
|
|
82
|
+
endDate: string,
|
|
83
|
+
): PluginApiReturn<PluginAnalysisComputeResult>
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get the state of the illuminance study.
|
|
87
|
+
*
|
|
88
|
+
* The polling read for the async job started by
|
|
89
|
+
* {@linkcode PluginAnalysisIlluminanceApi.compute}. `status` values:
|
|
90
|
+
*
|
|
91
|
+
* | Status | Meaning |
|
|
92
|
+
* |---|---|
|
|
93
|
+
* | `"running"` | A run is in flight — keep polling |
|
|
94
|
+
* | `"active"` | The heatmap is rendered on the scene |
|
|
95
|
+
* | `"inactive"` | A previous run exists but its heatmap is not showing |
|
|
96
|
+
*
|
|
97
|
+
* @returns A {@linkcode PluginAnalysisJobStateResult} with the `status` and
|
|
98
|
+
* the run's ISO `startDate`/`endDate`, or `null` when no run result is
|
|
99
|
+
* available (the study never ran, was cancelled, or the last run failed).
|
|
100
|
+
*
|
|
101
|
+
* @examplePrompt Is the illuminance analysis done?
|
|
102
|
+
* @examplePrompt Check the status of the daylight lux run
|
|
103
|
+
* @examplePrompt What date range was the illuminance heatmap computed for?
|
|
104
|
+
*
|
|
105
|
+
* # Example
|
|
106
|
+
* ```ts
|
|
107
|
+
* const job = await snaptrude.analysis.illuminance.get()
|
|
108
|
+
* if (job?.status === "active") console.log(job.startDate, job.endDate)
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
public abstract get(): PluginApiReturn<PluginAnalysisJobStateResult>
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Cancel the in-flight illuminance run.
|
|
115
|
+
*
|
|
116
|
+
* Aborts the backend job. A no-op (returns `false`) when nothing is
|
|
117
|
+
* running.
|
|
118
|
+
*
|
|
119
|
+
* @returns `true` when a run was cancelled, `false` when nothing was
|
|
120
|
+
* running.
|
|
121
|
+
* @throws When plugin writes are disabled.
|
|
122
|
+
*
|
|
123
|
+
* @examplePrompt Cancel the illuminance analysis
|
|
124
|
+
* @examplePrompt Stop the running daylight computation
|
|
125
|
+
* @examplePrompt Abort the lux study
|
|
126
|
+
*
|
|
127
|
+
* # Example
|
|
128
|
+
* ```ts
|
|
129
|
+
* await snaptrude.analysis.illuminance.cancel()
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
public abstract cancel(): PluginApiReturn<boolean>
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Clear the illuminance heatmap from the scene.
|
|
136
|
+
*
|
|
137
|
+
* Un-applies the rendered heatmap and restores the normal material view.
|
|
138
|
+
* A no-op (returns `false`) when no heatmap is showing. Does not cancel an
|
|
139
|
+
* in-flight run — use {@linkcode PluginAnalysisIlluminanceApi.cancel}.
|
|
140
|
+
*
|
|
141
|
+
* @returns `true` when a heatmap was cleared, `false` when none was
|
|
142
|
+
* showing.
|
|
143
|
+
* @throws When plugin writes are disabled.
|
|
144
|
+
*
|
|
145
|
+
* @examplePrompt Clear the illuminance heatmap
|
|
146
|
+
* @examplePrompt Remove the daylight lux colours from the model
|
|
147
|
+
* @examplePrompt Reset the illuminance analysis view
|
|
148
|
+
*
|
|
149
|
+
* # Example
|
|
150
|
+
* ```ts
|
|
151
|
+
* await snaptrude.analysis.illuminance.reset()
|
|
152
|
+
* ```
|
|
153
|
+
*/
|
|
154
|
+
public abstract reset(): PluginApiReturn<boolean>
|
|
155
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { PluginAnalysisSunpathApi } from "./sunpath"
|
|
2
|
+
import { PluginAnalysisShadowsApi } from "./shadows"
|
|
3
|
+
import { PluginAnalysisSunlightHoursApi } from "./sunlightHours"
|
|
4
|
+
import { PluginAnalysisIlluminanceApi } from "./illuminance"
|
|
5
|
+
import { PluginAnalysisHeatmapsApi } from "./heatmaps"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Sustainability-analysis APIs.
|
|
9
|
+
*
|
|
10
|
+
* Analysis is the environmental-performance layer: sun and daylight studies
|
|
11
|
+
* computed for the project's geo-located site. The synchronous visual
|
|
12
|
+
* overlays (sun-path diagram, real-time shadows) toggle instantly; the
|
|
13
|
+
* heatmap studies (direct sunlight hours, daylight illuminance) are
|
|
14
|
+
* asynchronous backend jobs — start them, poll their state, and cancel or
|
|
15
|
+
* clear them. Shadows and the heatmap analyses are **mutually exclusive**
|
|
16
|
+
* (enabling one resets the other), exactly as in the sustainability sidebar.
|
|
17
|
+
* Site inputs (location, true north) are read via `program.site`.
|
|
18
|
+
*
|
|
19
|
+
* - {@linkcode PluginAnalysisApi.sunpath} — Toggle & query the sun-path diagram overlay
|
|
20
|
+
* - {@linkcode PluginAnalysisApi.shadows} — Toggle real-time shadows and scrub the sun's date-time
|
|
21
|
+
* - {@linkcode PluginAnalysisApi.sunlightHours} — Direct-sunlight-hours heatmap job (start / poll / cancel / clear)
|
|
22
|
+
* - {@linkcode PluginAnalysisApi.illuminance} — Daylight-illuminance heatmap job, Pro-gated (start / poll / cancel / clear)
|
|
23
|
+
* - {@linkcode PluginAnalysisApi.heatmaps} — Render plugin-computed scalar data as a heatmap (per-space / grid)
|
|
24
|
+
*
|
|
25
|
+
* Accessed via `snaptrude.analysis`.
|
|
26
|
+
*/
|
|
27
|
+
export abstract class PluginAnalysisApi {
|
|
28
|
+
/** Sun-path diagram overlay — enable/disable/isActive. See {@linkcode PluginAnalysisSunpathApi}. */
|
|
29
|
+
public abstract sunpath: PluginAnalysisSunpathApi
|
|
30
|
+
/** Real-time sun shadows + sun date-time. See {@linkcode PluginAnalysisShadowsApi}. */
|
|
31
|
+
public abstract shadows: PluginAnalysisShadowsApi
|
|
32
|
+
/** Direct-sunlight-hours heatmap job. See {@linkcode PluginAnalysisSunlightHoursApi}. */
|
|
33
|
+
public abstract sunlightHours: PluginAnalysisSunlightHoursApi
|
|
34
|
+
/** Daylight-illuminance heatmap job (Pro). See {@linkcode PluginAnalysisIlluminanceApi}. */
|
|
35
|
+
public abstract illuminance: PluginAnalysisIlluminanceApi
|
|
36
|
+
/** Plugin-supplied scalar-data heatmaps. See {@linkcode PluginAnalysisHeatmapsApi}. */
|
|
37
|
+
public abstract heatmaps: PluginAnalysisHeatmapsApi
|
|
38
|
+
|
|
39
|
+
constructor() {}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export * from "./sunpath"
|
|
43
|
+
export * from "./shadows"
|
|
44
|
+
export * from "./sunlightHours"
|
|
45
|
+
export * from "./illuminance"
|
|
46
|
+
export * from "./heatmaps"
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Analysis shadows — real-time sun shadows in the scene.
|
|
6
|
+
*
|
|
7
|
+
* Shadows are cast for the sun position at a specific date and time at the
|
|
8
|
+
* project's geographic location. The date-time crosses this API as an **ISO
|
|
9
|
+
* 8601 date-time string** in the project's local time (e.g.
|
|
10
|
+
* `"2026-06-21T14:30"`); the engine snaps the time **down** to its half-hour
|
|
11
|
+
* grid (`14:59` → `14:30`); seconds, if provided, are discarded. The
|
|
12
|
+
* timezone is derived from the site location by the engine — do not append
|
|
13
|
+
* a UTC offset.
|
|
14
|
+
*
|
|
15
|
+
* Methods that position the sun **throw** when the project has no geo-located
|
|
16
|
+
* site/terrain — there is no fallback location. Set the site location first;
|
|
17
|
+
* read it via `program.site.getLocation`.
|
|
18
|
+
*
|
|
19
|
+
* Accessed via `snaptrude.analysis.shadows`.
|
|
20
|
+
*/
|
|
21
|
+
export abstract class PluginAnalysisShadowsApi {
|
|
22
|
+
constructor() {}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Turn real-time sun shadows ON, optionally at a specific date and time.
|
|
26
|
+
*
|
|
27
|
+
* Without `options.dateTime` the shadows use the current stored sun
|
|
28
|
+
* position; with it, the sun is moved first (same as
|
|
29
|
+
* {@linkcode PluginAnalysisShadowsApi.setDateTime}). Enabling shadows
|
|
30
|
+
* resets any active heatmap analysis (`sunlightHours` / `illuminance`) —
|
|
31
|
+
* they are mutually exclusive in the product.
|
|
32
|
+
*
|
|
33
|
+
* @param options - Optional `dateTime`: ISO 8601 local date-time to
|
|
34
|
+
* position the sun at (snapped to the engine's half-hour grid).
|
|
35
|
+
* @returns `true` — shadows are enabled after the call.
|
|
36
|
+
* @throws When the project has no geo-located site/terrain.
|
|
37
|
+
* @throws When `options.dateTime` is not a parseable ISO date-time.
|
|
38
|
+
* @throws When plugin writes are disabled.
|
|
39
|
+
*
|
|
40
|
+
* @examplePrompt Turn on shadows
|
|
41
|
+
* @examplePrompt Show the shadows at 3pm on June 21st
|
|
42
|
+
* @examplePrompt Enable sun shadows for the summer solstice afternoon
|
|
43
|
+
*
|
|
44
|
+
* # Example
|
|
45
|
+
* ```ts
|
|
46
|
+
* await snaptrude.analysis.shadows.enable({ dateTime: "2026-06-21T15:00" })
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
public abstract enable(
|
|
50
|
+
options?: PluginAnalysisShadowsEnableOptions,
|
|
51
|
+
): PluginApiReturn<boolean>
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Turn real-time sun shadows OFF.
|
|
55
|
+
*
|
|
56
|
+
* A no-op (returns `false`) when shadows are already off. The stored sun
|
|
57
|
+
* date-time is kept for the next enable.
|
|
58
|
+
*
|
|
59
|
+
* @returns `false` — shadows are disabled after the call.
|
|
60
|
+
* @throws When plugin writes are disabled.
|
|
61
|
+
*
|
|
62
|
+
* @examplePrompt Turn off shadows
|
|
63
|
+
* @examplePrompt Hide the sun shadows
|
|
64
|
+
* @examplePrompt Disable shadow rendering in the scene
|
|
65
|
+
*
|
|
66
|
+
* # Example
|
|
67
|
+
* ```ts
|
|
68
|
+
* await snaptrude.analysis.shadows.disable()
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
public abstract disable(): PluginApiReturn<boolean>
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Whether real-time sun shadows are currently enabled.
|
|
75
|
+
*
|
|
76
|
+
* A pure read — never mutates, never throws.
|
|
77
|
+
*
|
|
78
|
+
* @returns `true` when shadows are rendering.
|
|
79
|
+
*
|
|
80
|
+
* @examplePrompt Are shadows on?
|
|
81
|
+
* @examplePrompt Check whether sun shadows are enabled
|
|
82
|
+
* @examplePrompt Is the scene showing shadows right now?
|
|
83
|
+
*
|
|
84
|
+
* # Example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const on = await snaptrude.analysis.shadows.isEnabled()
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
public abstract isEnabled(): PluginApiReturn<boolean>
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Move the sun to a specific date and time.
|
|
93
|
+
*
|
|
94
|
+
* Takes an ISO 8601 date-time string in the project's local time; the
|
|
95
|
+
* engine snaps the time down to its half-hour grid and re-renders the shadows
|
|
96
|
+
* (when they are enabled). The engine stores no year — only the month, day,
|
|
97
|
+
* and time are applied, and the returned date-time always carries the
|
|
98
|
+
* **current year** (setting `"2020-12-21T09:30"` returns
|
|
99
|
+
* `"2026-12-21T09:30"` in 2026). Paired with
|
|
100
|
+
* {@linkcode PluginAnalysisShadowsApi.getDateTime}.
|
|
101
|
+
*
|
|
102
|
+
* @param dateTime - ISO 8601 local date-time, e.g. `"2026-12-21T09:30"`.
|
|
103
|
+
* @returns A {@linkcode PluginAnalysisShadowsDateTimeResult} — the applied
|
|
104
|
+
* ISO date-time after half-hour snapping.
|
|
105
|
+
* @throws When the project has no geo-located site/terrain.
|
|
106
|
+
* @throws When `dateTime` is not a parseable ISO date-time.
|
|
107
|
+
* @throws When plugin writes are disabled.
|
|
108
|
+
*
|
|
109
|
+
* @examplePrompt Set the shadow time to 9:30 am on the winter solstice
|
|
110
|
+
* @examplePrompt Move the sun to noon on March 1st
|
|
111
|
+
* @examplePrompt Change the shadow study date to December 21
|
|
112
|
+
*
|
|
113
|
+
* # Example
|
|
114
|
+
* ```ts
|
|
115
|
+
* const applied = await snaptrude.analysis.shadows.setDateTime("2026-12-21T09:30")
|
|
116
|
+
* console.log(applied) // "2026-12-21T09:30" (snapped to the half-hour grid)
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
public abstract setDateTime(
|
|
120
|
+
dateTime: string,
|
|
121
|
+
): PluginApiReturn<PluginAnalysisShadowsDateTimeResult>
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Get the sun's current date and time.
|
|
125
|
+
*
|
|
126
|
+
* Returns the stored sun position as an ISO 8601 local date-time string —
|
|
127
|
+
* the value shadows render at (whether or not they are enabled). The engine
|
|
128
|
+
* stores no year, so the returned string always carries the **current
|
|
129
|
+
* year**, whatever year was passed to
|
|
130
|
+
* {@linkcode PluginAnalysisShadowsApi.setDateTime} (its pair).
|
|
131
|
+
*
|
|
132
|
+
* @returns A {@linkcode PluginAnalysisShadowsDateTimeResult} — the current
|
|
133
|
+
* ISO local date-time of the sun.
|
|
134
|
+
*
|
|
135
|
+
* @examplePrompt What date and time are the shadows set to?
|
|
136
|
+
* @examplePrompt Get the current sun position date
|
|
137
|
+
* @examplePrompt Which time of day is the shadow study showing?
|
|
138
|
+
*
|
|
139
|
+
* # Example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const dateTime = await snaptrude.analysis.shadows.getDateTime()
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
public abstract getDateTime(): PluginApiReturn<PluginAnalysisShadowsDateTimeResult>
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Options for {@linkcode PluginAnalysisShadowsApi.enable}.
|
|
149
|
+
*
|
|
150
|
+
* | Property | Type | Description |
|
|
151
|
+
* |---|---|---|
|
|
152
|
+
* | `dateTime` | `string \| undefined` | ISO 8601 local date-time to position the sun at (snapped to the half-hour grid) |
|
|
153
|
+
*/
|
|
154
|
+
export const PluginAnalysisShadowsEnableOptions = z.object({
|
|
155
|
+
dateTime: z.string().optional(),
|
|
156
|
+
})
|
|
157
|
+
export type PluginAnalysisShadowsEnableOptions = z.infer<
|
|
158
|
+
typeof PluginAnalysisShadowsEnableOptions
|
|
159
|
+
>
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Arguments for {@linkcode PluginAnalysisShadowsApi.setDateTime}.
|
|
163
|
+
*
|
|
164
|
+
* | Property | Type | Description |
|
|
165
|
+
* |---|---|---|
|
|
166
|
+
* | `dateTime` | `string` | ISO 8601 local date-time, e.g. `"2026-06-21T14:30"` |
|
|
167
|
+
*/
|
|
168
|
+
export const PluginAnalysisShadowsSetDateTimeArgs = z.object({
|
|
169
|
+
dateTime: z.string(),
|
|
170
|
+
})
|
|
171
|
+
export type PluginAnalysisShadowsSetDateTimeArgs = z.infer<
|
|
172
|
+
typeof PluginAnalysisShadowsSetDateTimeArgs
|
|
173
|
+
>
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Result of {@linkcode PluginAnalysisShadowsApi.setDateTime} /
|
|
177
|
+
* {@linkcode PluginAnalysisShadowsApi.getDateTime} — the sun's ISO 8601
|
|
178
|
+
* local date-time (minute precision, on the engine's half-hour grid).
|
|
179
|
+
*/
|
|
180
|
+
export const PluginAnalysisShadowsDateTimeResult = z.string()
|
|
181
|
+
export type PluginAnalysisShadowsDateTimeResult = z.infer<
|
|
182
|
+
typeof PluginAnalysisShadowsDateTimeResult
|
|
183
|
+
>
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import * as z from "zod"
|
|
2
|
+
import { PluginApiReturn } from "../../types"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Analysis sunlightHours — the direct-sunlight-hours heatmap study.
|
|
6
|
+
*
|
|
7
|
+
* Computes, for every space surface (Room or Department Mass — generic
|
|
8
|
+
* Masses are not enough), how many hours of direct sunlight
|
|
9
|
+
* it receives over a date range, and renders the result as a heatmap on the
|
|
10
|
+
* scene. The computation is an **asynchronous backend job**:
|
|
11
|
+
*
|
|
12
|
+
* 1. {@linkcode PluginAnalysisSunlightHoursApi.compute} starts the job and
|
|
13
|
+
* returns immediately.
|
|
14
|
+
* 2. Poll {@linkcode PluginAnalysisSunlightHoursApi.get} until `status` is
|
|
15
|
+
* `"active"` (heatmap rendered) — a run typically takes minutes. There is
|
|
16
|
+
* no completion event; polling is the pattern.
|
|
17
|
+
* 3. {@linkcode PluginAnalysisSunlightHoursApi.cancel} aborts an in-flight
|
|
18
|
+
* run; {@linkcode PluginAnalysisSunlightHoursApi.reset} clears a rendered
|
|
19
|
+
* heatmap.
|
|
20
|
+
*
|
|
21
|
+
* Heatmaps are invalidated by scene-mutating edits — re-run the study after
|
|
22
|
+
* changing the model. Dates cross as ISO 8601 date strings (`"YYYY-MM-DD"`).
|
|
23
|
+
*
|
|
24
|
+
* Accessed via `snaptrude.analysis.sunlightHours`.
|
|
25
|
+
*/
|
|
26
|
+
export abstract class PluginAnalysisSunlightHoursApi {
|
|
27
|
+
constructor() {}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Start a direct-sunlight-hours run for a date range.
|
|
31
|
+
*
|
|
32
|
+
* Starts the backend job and **returns immediately** — it does not wait
|
|
33
|
+
* for the heatmap. Poll {@linkcode PluginAnalysisSunlightHoursApi.get}
|
|
34
|
+
* until `status` is `"active"`. Starting a new run while one is in flight
|
|
35
|
+
* replaces it. Shadows and the heatmap analyses are mutually exclusive in
|
|
36
|
+
* the product: starting a run disables real-time shadows and resets/cancels
|
|
37
|
+
* any {@linkcode PluginAnalysisIlluminanceApi} (`analysis.illuminance`)
|
|
38
|
+
* study.
|
|
39
|
+
*
|
|
40
|
+
* @param startDate - Start of the study range, ISO date `"YYYY-MM-DD"`.
|
|
41
|
+
* @param endDate - End of the study range, ISO date `"YYYY-MM-DD"` (on or
|
|
42
|
+
* after `startDate`).
|
|
43
|
+
* @returns A {@linkcode PluginAnalysisComputeResult} — `{ success: true }`
|
|
44
|
+
* when the job was started. The `{ success: false, error }` arm is
|
|
45
|
+
* reserved — not yet emitted (start failures currently throw).
|
|
46
|
+
* @throws When the project has no geo-located site/terrain (no location to
|
|
47
|
+
* compute sun exposure for — there is no fallback location).
|
|
48
|
+
* @throws When the scene has no space (Room or Department Mass) to analyse
|
|
49
|
+
* or the editor is not in the 3D view.
|
|
50
|
+
* @throws When a date is not a parseable ISO date or the range is inverted.
|
|
51
|
+
* @throws When plugin writes are disabled.
|
|
52
|
+
*
|
|
53
|
+
* @examplePrompt Run a sunlight hours analysis for June
|
|
54
|
+
* @examplePrompt Compute direct sunlight hours between March and September
|
|
55
|
+
* @examplePrompt How much sun does my building get over the summer?
|
|
56
|
+
*
|
|
57
|
+
* # Example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const { success } = await snaptrude.analysis.sunlightHours.compute(
|
|
60
|
+
* "2026-06-01",
|
|
61
|
+
* "2026-06-30",
|
|
62
|
+
* )
|
|
63
|
+
* // poll until the heatmap is rendered
|
|
64
|
+
* let job = await snaptrude.analysis.sunlightHours.get()
|
|
65
|
+
* while (job?.status === "running") {
|
|
66
|
+
* await new Promise((r) => setTimeout(r, 5000))
|
|
67
|
+
* job = await snaptrude.analysis.sunlightHours.get()
|
|
68
|
+
* }
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
public abstract compute(
|
|
72
|
+
startDate: string,
|
|
73
|
+
endDate: string,
|
|
74
|
+
): PluginApiReturn<PluginAnalysisComputeResult>
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Get the state of the sunlight-hours study.
|
|
78
|
+
*
|
|
79
|
+
* The polling read for the async job started by
|
|
80
|
+
* {@linkcode PluginAnalysisSunlightHoursApi.compute}. `status` values:
|
|
81
|
+
*
|
|
82
|
+
* | Status | Meaning |
|
|
83
|
+
* |---|---|
|
|
84
|
+
* | `"running"` | A run is in flight — keep polling |
|
|
85
|
+
* | `"active"` | The heatmap is rendered on the scene |
|
|
86
|
+
* | `"inactive"` | A previous run exists but its heatmap is not showing |
|
|
87
|
+
*
|
|
88
|
+
* @returns A {@linkcode PluginAnalysisJobStateResult} with the `status` and
|
|
89
|
+
* the run's ISO `startDate`/`endDate`, or `null` when no run result is
|
|
90
|
+
* available (the study never ran, was cancelled, or the last run failed).
|
|
91
|
+
*
|
|
92
|
+
* @examplePrompt Is the sunlight analysis done?
|
|
93
|
+
* @examplePrompt Check the status of the sunlight hours run
|
|
94
|
+
* @examplePrompt What date range was the sunlight heatmap computed for?
|
|
95
|
+
*
|
|
96
|
+
* # Example
|
|
97
|
+
* ```ts
|
|
98
|
+
* const job = await snaptrude.analysis.sunlightHours.get()
|
|
99
|
+
* if (job?.status === "active") console.log(job.startDate, job.endDate)
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
public abstract get(): PluginApiReturn<PluginAnalysisJobStateResult>
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Cancel the in-flight sunlight-hours run.
|
|
106
|
+
*
|
|
107
|
+
* Aborts the backend job. A no-op (returns `false`) when nothing is
|
|
108
|
+
* running.
|
|
109
|
+
*
|
|
110
|
+
* @returns `true` when a run was cancelled, `false` when nothing was
|
|
111
|
+
* running.
|
|
112
|
+
* @throws When plugin writes are disabled.
|
|
113
|
+
*
|
|
114
|
+
* @examplePrompt Cancel the sunlight analysis
|
|
115
|
+
* @examplePrompt Stop the running sunlight hours computation
|
|
116
|
+
* @examplePrompt Abort the sun study
|
|
117
|
+
*
|
|
118
|
+
* # Example
|
|
119
|
+
* ```ts
|
|
120
|
+
* await snaptrude.analysis.sunlightHours.cancel()
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
public abstract cancel(): PluginApiReturn<boolean>
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Clear the sunlight-hours heatmap from the scene.
|
|
127
|
+
*
|
|
128
|
+
* Un-applies the rendered heatmap and restores the normal material view.
|
|
129
|
+
* A no-op (returns `false`) when no heatmap is showing. Does not cancel an
|
|
130
|
+
* in-flight run — use {@linkcode PluginAnalysisSunlightHoursApi.cancel}.
|
|
131
|
+
*
|
|
132
|
+
* @returns `true` when a heatmap was cleared, `false` when none was
|
|
133
|
+
* showing.
|
|
134
|
+
* @throws When plugin writes are disabled.
|
|
135
|
+
*
|
|
136
|
+
* @examplePrompt Clear the sunlight heatmap
|
|
137
|
+
* @examplePrompt Remove the sun hours colours from the model
|
|
138
|
+
* @examplePrompt Reset the sunlight analysis view
|
|
139
|
+
*
|
|
140
|
+
* # Example
|
|
141
|
+
* ```ts
|
|
142
|
+
* await snaptrude.analysis.sunlightHours.reset()
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
public abstract reset(): PluginApiReturn<boolean>
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Result of starting an analysis job
|
|
150
|
+
* ({@linkcode PluginAnalysisSunlightHoursApi.compute} /
|
|
151
|
+
* {@linkcode PluginAnalysisIlluminanceApi.compute}).
|
|
152
|
+
*
|
|
153
|
+
* The `success: false` arm is **reserved — not yet emitted**: the current
|
|
154
|
+
* host always returns `{ success: true }` (start failures throw instead); a
|
|
155
|
+
* failure indicator may be added additively later.
|
|
156
|
+
*
|
|
157
|
+
* | Property | Type | Description |
|
|
158
|
+
* |---|---|---|
|
|
159
|
+
* | `success` | `boolean` | `true` when the backend job was started |
|
|
160
|
+
* | `error` | `string \| undefined` | Failure reason when `success` is `false` (reserved — not yet emitted) |
|
|
161
|
+
*/
|
|
162
|
+
export const PluginAnalysisComputeResult = z.object({
|
|
163
|
+
success: z.boolean(),
|
|
164
|
+
error: z.string().optional(),
|
|
165
|
+
})
|
|
166
|
+
export type PluginAnalysisComputeResult = z.infer<
|
|
167
|
+
typeof PluginAnalysisComputeResult
|
|
168
|
+
>
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The status of an analysis heatmap job.
|
|
172
|
+
*
|
|
173
|
+
* | Value | Meaning |
|
|
174
|
+
* |---|---|
|
|
175
|
+
* | `"running"` | A run is in flight — keep polling |
|
|
176
|
+
* | `"active"` | The heatmap is rendered on the scene |
|
|
177
|
+
* | `"inactive"` | A previous run exists but its heatmap is not showing |
|
|
178
|
+
*/
|
|
179
|
+
export const PluginAnalysisJobStatus = z.enum([
|
|
180
|
+
"running",
|
|
181
|
+
"active",
|
|
182
|
+
"inactive",
|
|
183
|
+
])
|
|
184
|
+
export type PluginAnalysisJobStatus = z.infer<typeof PluginAnalysisJobStatus>
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* The state of an analysis heatmap job.
|
|
188
|
+
*
|
|
189
|
+
* | Property | Type | Description |
|
|
190
|
+
* |---|---|---|
|
|
191
|
+
* | `status` | {@linkcode PluginAnalysisJobStatus} | `"running"` \| `"active"` \| `"inactive"` |
|
|
192
|
+
* | `startDate` | `string` | ISO date (`"YYYY-MM-DD"`) the run was computed from |
|
|
193
|
+
* | `endDate` | `string` | ISO date (`"YYYY-MM-DD"`) the run was computed to |
|
|
194
|
+
*/
|
|
195
|
+
export const PluginAnalysisJobState = z.object({
|
|
196
|
+
status: PluginAnalysisJobStatus,
|
|
197
|
+
startDate: z.string(),
|
|
198
|
+
endDate: z.string(),
|
|
199
|
+
})
|
|
200
|
+
export type PluginAnalysisJobState = z.infer<typeof PluginAnalysisJobState>
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Result of {@linkcode PluginAnalysisSunlightHoursApi.get} /
|
|
204
|
+
* {@linkcode PluginAnalysisIlluminanceApi.get} — the job state, or `null`
|
|
205
|
+
* when no run result is available (the study never ran, was cancelled, or
|
|
206
|
+
* the last run failed).
|
|
207
|
+
*/
|
|
208
|
+
export const PluginAnalysisJobStateResult = PluginAnalysisJobState.nullable()
|
|
209
|
+
export type PluginAnalysisJobStateResult = z.infer<
|
|
210
|
+
typeof PluginAnalysisJobStateResult
|
|
211
|
+
>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { PluginApiReturn } from "../../types"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Analysis sunpath — the sun-path diagram overlay.
|
|
5
|
+
*
|
|
6
|
+
* The sun-path diagram draws the sun's annual/daily trajectory arcs over the
|
|
7
|
+
* scene for the project's geographic location, so daylight behaviour can be
|
|
8
|
+
* read directly off the model. Toggling it is an **undoable** action (it goes
|
|
9
|
+
* through the command stack, so `core.history.undo` reverts it).
|
|
10
|
+
*
|
|
11
|
+
* The overlay is computed for the project's geo-location. Enabling **throws**
|
|
12
|
+
* when the project has no geo-located site/terrain — there is no fallback
|
|
13
|
+
* location. Set the site location first (Import terrain / site context);
|
|
14
|
+
* read it via `program.site.getLocation`.
|
|
15
|
+
*
|
|
16
|
+
* Accessed via `snaptrude.analysis.sunpath`.
|
|
17
|
+
*/
|
|
18
|
+
export abstract class PluginAnalysisSunpathApi {
|
|
19
|
+
constructor() {}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Turn the sun-path diagram overlay ON.
|
|
23
|
+
*
|
|
24
|
+
* Undoable: the toggle is committed through the command stack. A no-op
|
|
25
|
+
* (returns `true`) when the overlay is already active.
|
|
26
|
+
*
|
|
27
|
+
* @returns `true` — the overlay is active after the call.
|
|
28
|
+
* @throws When the project has no geo-located site/terrain (no location to
|
|
29
|
+
* compute the sun trajectory for).
|
|
30
|
+
* @throws When plugin writes are disabled.
|
|
31
|
+
*
|
|
32
|
+
* @examplePrompt Show the sun path diagram
|
|
33
|
+
* @examplePrompt Turn on the sunpath overlay
|
|
34
|
+
* @examplePrompt Visualize the sun's trajectory over my building
|
|
35
|
+
*
|
|
36
|
+
* # Example
|
|
37
|
+
* ```ts
|
|
38
|
+
* await snaptrude.analysis.sunpath.enable()
|
|
39
|
+
* const active = await snaptrude.analysis.sunpath.isActive() // true
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
public abstract enable(): PluginApiReturn<boolean>
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Turn the sun-path diagram overlay OFF.
|
|
46
|
+
*
|
|
47
|
+
* Undoable: the toggle is committed through the command stack. A no-op
|
|
48
|
+
* (returns `false`) when the overlay is already off.
|
|
49
|
+
*
|
|
50
|
+
* @returns `false` — the overlay is inactive after the call.
|
|
51
|
+
* @throws When plugin writes are disabled.
|
|
52
|
+
*
|
|
53
|
+
* @examplePrompt Hide the sun path diagram
|
|
54
|
+
* @examplePrompt Turn off the sunpath overlay
|
|
55
|
+
* @examplePrompt Remove the sun trajectory arcs from the scene
|
|
56
|
+
*
|
|
57
|
+
* # Example
|
|
58
|
+
* ```ts
|
|
59
|
+
* await snaptrude.analysis.sunpath.disable()
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
public abstract disable(): PluginApiReturn<boolean>
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Whether the sun-path diagram overlay is currently active.
|
|
66
|
+
*
|
|
67
|
+
* A pure read — never mutates, never throws.
|
|
68
|
+
*
|
|
69
|
+
* @returns `true` when the overlay is showing.
|
|
70
|
+
*
|
|
71
|
+
* @examplePrompt Is the sun path diagram on?
|
|
72
|
+
* @examplePrompt Check whether the sunpath overlay is active
|
|
73
|
+
* @examplePrompt Am I looking at the sun trajectory right now?
|
|
74
|
+
*
|
|
75
|
+
* # Example
|
|
76
|
+
* ```ts
|
|
77
|
+
* if (!(await snaptrude.analysis.sunpath.isActive())) {
|
|
78
|
+
* await snaptrude.analysis.sunpath.enable()
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
public abstract isActive(): PluginApiReturn<boolean>
|
|
83
|
+
}
|