@snaptrude/plugin-core 0.5.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/CHANGELOG.md +52 -0
- package/api-manifest.full.json +2044 -443
- package/api-manifest.json +2051 -394
- 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/index.d.ts +5 -0
- 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 +7 -7
- package/dist/api/design/create/index.d.ts +9 -0
- package/dist/api/design/create/index.d.ts.map +1 -1
- package/dist/api/design/query/spaces.d.ts +3 -3
- package/dist/api/design/selection/index.d.ts +144 -0
- package/dist/api/design/selection/index.d.ts.map +1 -1
- package/dist/api/entity/space.d.ts +2 -2
- package/dist/api/index.d.ts +5 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/program/site.d.ts +84 -0
- package/dist/api/program/site.d.ts.map +1 -1
- package/dist/handles.d.ts +33 -0
- package/dist/handles.d.ts.map +1 -1
- package/dist/index.cjs +1335 -987
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1278 -983
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/scripts/generate-manifest.test.mjs +26 -4
- 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/index.ts +5 -0
- 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/design/create/index.ts +9 -0
- package/src/api/design/erase/index.ts +1 -1
- package/src/api/design/selection/index.ts +129 -0
- package/src/api/index.ts +5 -0
- package/src/api/program/site.ts +93 -0
- package/src/handles.ts +46 -0
package/src/api/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { PluginDesignApi } from "./design"
|
|
|
3
3
|
import { PluginEntityApi } from "./entity"
|
|
4
4
|
import { PluginProgramApi } from "./program"
|
|
5
5
|
import { PluginPresentationApi } from "./presentation"
|
|
6
|
+
import { PluginAnalysisApi } from "./analysis"
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Root API surface for Snaptrude plugins.
|
|
@@ -14,6 +15,7 @@ import { PluginPresentationApi } from "./presentation"
|
|
|
14
15
|
* - {@linkcode PluginApi.entity} — CRUD operations on Snaptrude entities (spaces, stories)
|
|
15
16
|
* - {@linkcode PluginApi.program} — Program-mode planning reads (departments, metrics)
|
|
16
17
|
* - {@linkcode PluginApi.presentation} — Presentation preparation (views, AI Inspiration)
|
|
18
|
+
* - {@linkcode PluginApi.analysis} — Sustainability analysis (sunpath, shadows, sunlight/illuminance heatmaps)
|
|
17
19
|
*/
|
|
18
20
|
export abstract class PluginApi {
|
|
19
21
|
/** Core math, geometry, history, and units primitives. See {@linkcode PluginCoreApi}. */
|
|
@@ -26,6 +28,8 @@ export abstract class PluginApi {
|
|
|
26
28
|
public abstract program: PluginProgramApi
|
|
27
29
|
/** Presentation preparation reads — saved views. See {@linkcode PluginPresentationApi}. */
|
|
28
30
|
public abstract presentation: PluginPresentationApi
|
|
31
|
+
/** Sustainability analysis — sun & daylight studies. See {@linkcode PluginAnalysisApi}. */
|
|
32
|
+
public abstract analysis: PluginAnalysisApi
|
|
29
33
|
|
|
30
34
|
constructor() {}
|
|
31
35
|
}
|
|
@@ -35,3 +39,4 @@ export * from "./design"
|
|
|
35
39
|
export * from "./entity"
|
|
36
40
|
export * from "./program"
|
|
37
41
|
export * from "./presentation"
|
|
42
|
+
export * from "./analysis"
|
package/src/api/program/site.ts
CHANGED
|
@@ -127,6 +127,63 @@ export abstract class PluginProgramSiteApi {
|
|
|
127
127
|
* ```
|
|
128
128
|
*/
|
|
129
129
|
public abstract getContext(): PluginApiReturn<PluginProgramSiteContextResult>
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Get the project's geographic location.
|
|
133
|
+
*
|
|
134
|
+
* The latitude/longitude the site is geo-located at — the location the
|
|
135
|
+
* `analysis.*` sun and daylight studies compute against. Returns `null`
|
|
136
|
+
* when the project is not geo-located on terrain (there is no fallback
|
|
137
|
+
* location).
|
|
138
|
+
*
|
|
139
|
+
* Note the spelling: this result uses the full `{ latitude, longitude }`
|
|
140
|
+
* keys, while the older site reads
|
|
141
|
+
* ({@linkcode PluginProgramSiteApi.getContext},
|
|
142
|
+
* {@linkcode PluginProgramSiteApi.listGeoPolygons}) use the abbreviated
|
|
143
|
+
* `{ lat, lng }`.
|
|
144
|
+
*
|
|
145
|
+
* @returns A {@linkcode PluginProgramSiteLocationResult} —
|
|
146
|
+
* `{ latitude, longitude }`, or `null` when the project has no
|
|
147
|
+
* geo-located site.
|
|
148
|
+
*
|
|
149
|
+
* @examplePrompt What's the project's latitude and longitude?
|
|
150
|
+
* @examplePrompt Where is this site located?
|
|
151
|
+
* @examplePrompt Get the geographic coordinates of the project
|
|
152
|
+
*
|
|
153
|
+
* # Example
|
|
154
|
+
* ```ts
|
|
155
|
+
* const location = await snaptrude.program.site.getLocation()
|
|
156
|
+
* if (location) console.log(location.latitude, location.longitude)
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
public abstract getLocation(): PluginApiReturn<PluginProgramSiteLocationResult>
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Get the site's true-north angle.
|
|
163
|
+
*
|
|
164
|
+
* The angle in degrees the model's north (the scene's +Z axis) is rotated
|
|
165
|
+
* from true north, derived from the terrain's rotation. `0` means the
|
|
166
|
+
* model is aligned to true north. Reported in `[0, 360)`,
|
|
167
|
+
* **clockwise-positive** viewed from above (Babylon's +Y rotation sign) —
|
|
168
|
+
* note this is the opposite sign convention to `design.transform.rotate`,
|
|
169
|
+
* where positive = CCW. Returns `null` when the project is not
|
|
170
|
+
* geo-located on terrain.
|
|
171
|
+
*
|
|
172
|
+
* @returns A {@linkcode PluginProgramSiteNorthAngleResult} — the angle in
|
|
173
|
+
* degrees (`[0, 360)`, clockwise-positive), or `null` when the project
|
|
174
|
+
* has no geo-located site.
|
|
175
|
+
*
|
|
176
|
+
* @examplePrompt What's the north angle of the site?
|
|
177
|
+
* @examplePrompt How far is the model rotated from true north?
|
|
178
|
+
* @examplePrompt Get the project's true north direction
|
|
179
|
+
*
|
|
180
|
+
* # Example
|
|
181
|
+
* ```ts
|
|
182
|
+
* const northAngle = await snaptrude.program.site.getNorthAngle()
|
|
183
|
+
* if (northAngle !== null) console.log(`${northAngle}° from true north`)
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
public abstract getNorthAngle(): PluginApiReturn<PluginProgramSiteNorthAngleResult>
|
|
130
187
|
}
|
|
131
188
|
|
|
132
189
|
/**
|
|
@@ -324,3 +381,39 @@ export const PluginProgramSiteContextResult =
|
|
|
324
381
|
export type PluginProgramSiteContextResult = z.infer<
|
|
325
382
|
typeof PluginProgramSiteContextResult
|
|
326
383
|
>
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* The project's geographic location (WGS84).
|
|
387
|
+
*
|
|
388
|
+
* | Property | Type | Description |
|
|
389
|
+
* |---|---|---|
|
|
390
|
+
* | `latitude` | `number` | Latitude (degrees) |
|
|
391
|
+
* | `longitude` | `number` | Longitude (degrees) |
|
|
392
|
+
*/
|
|
393
|
+
export const PluginProgramSiteLocation = z.object({
|
|
394
|
+
latitude: z.number(),
|
|
395
|
+
longitude: z.number(),
|
|
396
|
+
})
|
|
397
|
+
export type PluginProgramSiteLocation = z.infer<
|
|
398
|
+
typeof PluginProgramSiteLocation
|
|
399
|
+
>
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Result of {@linkcode PluginProgramSiteApi.getLocation} — the location, or
|
|
403
|
+
* `null` when the project is not geo-located.
|
|
404
|
+
*/
|
|
405
|
+
export const PluginProgramSiteLocationResult =
|
|
406
|
+
PluginProgramSiteLocation.nullable()
|
|
407
|
+
export type PluginProgramSiteLocationResult = z.infer<
|
|
408
|
+
typeof PluginProgramSiteLocationResult
|
|
409
|
+
>
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Result of {@linkcode PluginProgramSiteApi.getNorthAngle} — the true-north
|
|
413
|
+
* angle in degrees (`[0, 360)`, clockwise-positive), or `null` when the
|
|
414
|
+
* project is not geo-located.
|
|
415
|
+
*/
|
|
416
|
+
export const PluginProgramSiteNorthAngleResult = z.number().nullable()
|
|
417
|
+
export type PluginProgramSiteNorthAngleResult = z.infer<
|
|
418
|
+
typeof PluginProgramSiteNorthAngleResult
|
|
419
|
+
>
|
package/src/handles.ts
CHANGED
|
@@ -46,6 +46,34 @@ export type ComponentHandle = EntityId<"component">
|
|
|
46
46
|
*/
|
|
47
47
|
export type MaterialHandle = EntityId<"material">
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* A placed **scene underlay** — an imported reference plane the user traces over:
|
|
51
|
+
* an image `FloorPlan`, a `PDF` overlay, or a `CAD` sketch. Entity-style: the token
|
|
52
|
+
* IS the raw `Component.id` (`fp_…` / a pdf id / `cad_…`). Resolved live host-side
|
|
53
|
+
* via the import-order layer walk (`collectStoreyImportItems`) — NOT via
|
|
54
|
+
* `ComponentUtility.FindComponentById`, which does not index underlays. No arena, no
|
|
55
|
+
* quota, stable across undo/redo. Returned by `core.io.import.{image,pdf,cadJson}`
|
|
56
|
+
* and consumed by every `core.io.underlay.*` method.
|
|
57
|
+
*/
|
|
58
|
+
export type UnderlayHandle = EntityId<"underlay">
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The project's **site terrain** — a Mapbox-derived topography mesh. Entity-style
|
|
62
|
+
* and a project **singleton** (one terrain per project): the token is the terrain
|
|
63
|
+
* `Component.id` (`terrain-…`), resolved live via `TerrainOperations.getTerrain()`
|
|
64
|
+
* (absent from the level component collections, so NOT `FindComponentById`).
|
|
65
|
+
* Returned by `core.io.import.terrain`.
|
|
66
|
+
*/
|
|
67
|
+
export type TerrainHandle = EntityId<"terrain">
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A handle to an **asynchronous import job** (today: a DWG → Forge conversion, which
|
|
71
|
+
* can take minutes). Returned immediately by `core.io.import.dwg`; poll it via
|
|
72
|
+
* `core.io.job.*` (`getStatus` / `isComplete` / `getResult` / `getError`). The token
|
|
73
|
+
* is the engine's import request id; job state lives in a host-side registry.
|
|
74
|
+
*/
|
|
75
|
+
export type ImportJobHandle = EntityId<"importJob">
|
|
76
|
+
|
|
49
77
|
// ── Value-kind handles (all-handle model, §11) ──────────────────────────────
|
|
50
78
|
// Under the all-handle decision every structured type is a handle. The only
|
|
51
79
|
// non-handles crossing the boundary are JS primitives (number/string/boolean)
|
|
@@ -123,6 +151,24 @@ export const MaterialHandle = z
|
|
|
123
151
|
.min(1)
|
|
124
152
|
.transform((s) => s as MaterialHandle)
|
|
125
153
|
|
|
154
|
+
/**
|
|
155
|
+
* {@linkcode UnderlayHandle} / {@linkcode TerrainHandle} / {@linkcode ImportJobHandle}
|
|
156
|
+
* are entity-style handles — raw host ids, validated only as a non-empty string
|
|
157
|
+
* (no `"<kind>_"` prefix), resolved live host-side (existence enforced there).
|
|
158
|
+
*/
|
|
159
|
+
export const UnderlayHandle = z
|
|
160
|
+
.string()
|
|
161
|
+
.min(1)
|
|
162
|
+
.transform((s) => s as UnderlayHandle)
|
|
163
|
+
export const TerrainHandle = z
|
|
164
|
+
.string()
|
|
165
|
+
.min(1)
|
|
166
|
+
.transform((s) => s as TerrainHandle)
|
|
167
|
+
export const ImportJobHandle = z
|
|
168
|
+
.string()
|
|
169
|
+
.min(1)
|
|
170
|
+
.transform((s) => s as ImportJobHandle)
|
|
171
|
+
|
|
126
172
|
// Value-kind handle schemas (all-handle model, §11).
|
|
127
173
|
export const Vec3Handle = handleSchema("vec3")
|
|
128
174
|
export const QuatHandle = handleSchema("quat")
|