@selvajs/visualization 1.0.0-beta.0 → 1.0.0-beta.2

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.
Files changed (43) hide show
  1. package/README.md +11 -10
  2. package/dist/gpu-dispose-Dkj-BKt4.js +2 -0
  3. package/dist/gpu-dispose-Dkj-BKt4.js.map +1 -0
  4. package/dist/gpu-dispose-DrN-ryj5.cjs +2 -0
  5. package/dist/gpu-dispose-DrN-ryj5.cjs.map +1 -0
  6. package/dist/index.cjs +0 -1
  7. package/dist/index.d.cts +1 -2
  8. package/dist/index.d.ts +1 -2
  9. package/dist/index.js +1 -1
  10. package/dist/parse.cjs +3 -3
  11. package/dist/parse.cjs.map +1 -1
  12. package/dist/parse.d.cts +135 -142
  13. package/dist/parse.d.ts +135 -142
  14. package/dist/parse.js +3 -3
  15. package/dist/parse.js.map +1 -1
  16. package/dist/render.cjs +8 -10
  17. package/dist/render.cjs.map +1 -1
  18. package/dist/render.d.cts +335 -333
  19. package/dist/render.d.ts +335 -333
  20. package/dist/render.js +8 -10
  21. package/dist/render.js.map +1 -1
  22. package/dist/rolldown-runtime-BocRIvOZ.cjs +1 -0
  23. package/dist/scene.cjs +1 -1
  24. package/dist/scene.cjs.map +1 -1
  25. package/dist/scene.d.cts +95 -95
  26. package/dist/scene.d.ts +95 -95
  27. package/dist/scene.js +1 -1
  28. package/dist/scene.js.map +1 -1
  29. package/dist/types-Di80Y609.d.cts +34 -0
  30. package/dist/types-Di80Y609.d.ts +34 -0
  31. package/package.json +14 -10
  32. package/dist/chunk-5XGN7UAV.js +0 -2
  33. package/dist/chunk-5XGN7UAV.js.map +0 -1
  34. package/dist/chunk-AQJPVUH3.cjs +0 -2
  35. package/dist/chunk-AQJPVUH3.cjs.map +0 -1
  36. package/dist/chunk-BYLIBOAU.cjs +0 -2
  37. package/dist/chunk-BYLIBOAU.cjs.map +0 -1
  38. package/dist/chunk-EXAI6IC5.js +0 -2
  39. package/dist/chunk-EXAI6IC5.js.map +0 -1
  40. package/dist/index.cjs.map +0 -1
  41. package/dist/index.js.map +0 -1
  42. package/dist/types-CdF9R3qA.d.cts +0 -41
  43. package/dist/types-CdF9R3qA.d.ts +0 -41
package/dist/parse.d.cts CHANGED
@@ -1,16 +1,13 @@
1
- import * as THREE from 'three';
2
- import { RhinoModule } from 'rhino3dm';
3
- import { M as MaterialAppearanceOptions } from './types-CdF9R3qA.cjs';
4
-
5
- /**
6
- * Structural, not nominal: satisfies `@selvajs/solve/client`'s `MeshPolicy<THREE.Object3D>`
7
- * without this package depending on solve.
8
- */
1
+ import { i as MaterialAppearanceOptions } from "./types-Di80Y609.cjs";
2
+ import * as THREE from "three";
3
+ //#region src/parse/mesh-policy.d.ts
4
+ /** Structurally, not nominally, typed as `@selvajs/solve/client`'s `MeshPolicy<THREE.Object3D>` — avoids a dependency on solve. */
9
5
  declare const meshPolicy: {
10
- clone(meshes: THREE.Object3D[]): THREE.Object3D[];
11
- release(meshes: THREE.Object3D[]): void;
6
+ clone(meshes: THREE.Object3D[]): THREE.Object3D[];
7
+ release(meshes: THREE.Object3D[]): void;
12
8
  };
13
-
9
+ //#endregion
10
+ //#region src/parse/webdisplay/response-envelope.d.ts
14
11
  /**
15
12
  * Declared structurally rather than imported from `@selvajs/compute` — this package converts
16
13
  * meshes, it doesn't need a Rhino.Compute client dependency to describe the shape a caller hands
@@ -18,68 +15,75 @@ declare const meshPolicy: {
18
15
  * this, so {@link getThreeMeshesFromComputeResponse} keeps accepting one unchanged.
19
16
  */
20
17
  interface DisplayDataItem {
21
- /** Namespaced wire type token, e.g. `Selva.GH.Features.Display.Services.DisplayBatch`. */
22
- type: string;
23
- data: string;
18
+ /** Namespaced wire type token, e.g. `Selva.GH.Features.Display.Services.DisplayBatch`. */
19
+ type: string;
20
+ data: string;
24
21
  }
25
22
  interface DisplayResponseValue {
26
- InnerTree: {
27
- [branchPath: string]: DisplayDataItem[];
28
- };
23
+ InnerTree: {
24
+ [branchPath: string]: DisplayDataItem[];
25
+ };
29
26
  }
30
27
  interface DisplayComputeResponse {
31
- values: DisplayResponseValue[];
32
- /** Rhino `UnitSystem` name driving unit scaling (see `SCALE_FACTORS`); unrecognized/absent scales 1. */
33
- modelunits: string;
28
+ values: DisplayResponseValue[];
29
+ /** Rhino `UnitSystem` name driving unit scaling (see `SCALE_FACTORS`); unrecognized/absent scales 1. */
30
+ modelunits: string;
34
31
  }
35
-
36
- /** Shared by meshes and items so pick/filter/label code treats them uniformly. No color/material — that's per-kind. */
32
+ //#endregion
33
+ //#region src/parse/display-items/types.d.ts
37
34
  interface DisplayIdentity {
38
- /** Stable pick key: `${sourceComponentId}:${originalIndex}`. */
39
- id: string;
40
- /** Distinct from {@link id} — renaming must not change identity. */
41
- name: string;
42
- layer: string;
43
- /** Arbitrary key-value pairs from the GH Metadata input. */
44
- metadata?: Record<string, string>;
35
+ /** Stable pick key: `${sourceComponentId}:${originalIndex}`. Distinct from `name` so renaming doesn't change identity. */
36
+ id: string;
37
+ name: string;
38
+ layer: string;
39
+ /** Arbitrary key-value pairs from the GH Metadata input. */
40
+ metadata?: Record<string, string>;
45
41
  }
46
42
  interface DisplayItemBase extends DisplayIdentity {
47
- /** Hex/rgb/named color string, parsed by `parseColor`. Falls back to a viewer default. */
48
- color?: string;
49
- /** 01. Omitted means fully opaque. */
50
- opacity?: number;
43
+ /** Hex/rgb/named color string, parsed by `parseColor`. Falls back to a viewer default. */
44
+ color?: string;
45
+ /** 0-1; omitted means fully opaque. */
46
+ opacity?: number;
51
47
  }
52
48
  /** Rhino's Z-up frame and `{X,Y,Z}` casing. */
53
49
  interface DisplayPosition {
54
- X: number;
55
- Y: number;
56
- Z: number;
50
+ X: number;
51
+ Y: number;
52
+ Z: number;
57
53
  }
58
- /** Rhino-native JSON (`curve.ToNurbsCurve().ToJSON()`), tessellated to a fat `Line2` on decode. */
54
+ /** Rendered as a fat `Line2` straight from `points` — nothing decodes geometry in the browser. */
59
55
  interface DisplayCurve extends DisplayItemBase {
60
- kind: 'curve';
61
- json: string;
62
- /** Screen-space CSS px, constant regardless of zoom. Omitted viewer default. */
63
- width?: number;
56
+ kind: 'curve';
57
+ /**
58
+ * Backend-tessellated polyline, flat `[x,y,z, …]` in Rhino's Z-up frame.
59
+ *
60
+ * Typed as required even though the plugin still sends a legacy `json` field alongside it: a
61
+ * payload without `points` came from a Display component too old to render, and parsing throws
62
+ * rather than treating it as a shape this package supports.
63
+ */
64
+ points: number[];
65
+ /** Screen-space CSS px, constant regardless of zoom. Omitted uses the viewer default. */
66
+ width?: number;
64
67
  }
65
68
  interface DisplayPoint extends DisplayItemBase {
66
- kind: 'point';
67
- position: DisplayPosition;
69
+ kind: 'point';
70
+ position: DisplayPosition;
68
71
  }
69
72
  type DisplayItem = DisplayCurve | DisplayPoint;
70
-
73
+ //#endregion
74
+ //#region src/parse/webdisplay/types.d.ts
71
75
  interface SerializableMaterial {
72
- color: string;
73
- metalness: number;
74
- roughness: number;
75
- opacity: number;
76
- transparent: boolean;
77
- /**
78
- * Optional color-map texture reference: http(s) URL, data URI, or plugin asset URL
79
- * (`http://localhost:{port}/assets/{hash}`). Omitted entirely (not just empty) when untextured.
80
- * When set, the mesh blob also carries per-vertex UVs (FLAG_HAS_UVS) for meshes using it.
81
- */
82
- map?: string;
76
+ color: string;
77
+ metalness: number;
78
+ roughness: number;
79
+ opacity: number;
80
+ transparent: boolean;
81
+ /**
82
+ * Optional color-map texture reference: http(s) URL, data URI, or plugin asset URL
83
+ * (`http://localhost:{port}/assets/{hash}`). Omitted entirely (not just empty) when untextured.
84
+ * When set, the mesh blob also carries per-vertex UVs (FLAG_HAS_UVS) for meshes using it.
85
+ */
86
+ map?: string;
83
87
  }
84
88
  /**
85
89
  * `vertexStart`/`vertexCount` and `indexStart`/`indexCount` are in **element units** of the
@@ -89,24 +93,23 @@ interface SerializableMaterial {
89
93
  * vertex components are 2 bytes (int16 quantized) or 4 bytes (`FLAG_FLOAT32`).
90
94
  */
91
95
  interface MeshMetadata {
92
- name: string;
93
- /** Layer path for grouping in the scene manager, e.g. 'Structure/Walls'. */
94
- layer: string;
95
- /** Index in the GH input tree before material grouping; combined with sourceComponentId
96
- * uniquely identifies the GH source geometry. */
97
- originalIndex: number;
98
- vertexCount: number;
99
- /** 3 per triangle. */
100
- indexCount: number;
101
- vertexStart: number;
102
- indexStart: number;
103
- /** Arbitrary key-value pairs from the GH Metadata input. */
104
- metadata?: Record<string, string>;
96
+ name: string;
97
+ /** Layer path for grouping in the scene manager, e.g. 'Structure/Walls'. */
98
+ layer: string;
99
+ /** Index in the GH input tree before material grouping; combined with sourceComponentId
100
+ * uniquely identifies the GH source geometry. */
101
+ originalIndex: number;
102
+ vertexCount: number;
103
+ /** 3 per triangle. */
104
+ indexCount: number;
105
+ vertexStart: number;
106
+ indexStart: number;
107
+ /** Arbitrary key-value pairs from the GH Metadata input. */
108
+ metadata?: Record<string, string>;
105
109
  }
106
110
  interface MaterialGroup {
107
- /** Index into the batch's materials array. */
108
- materialId: number;
109
- meshes: MeshMetadata[];
111
+ materialId: number;
112
+ meshes: MeshMetadata[];
110
113
  }
111
114
  /**
112
115
  * One Display component's payload, ready for Three.js rendering.
@@ -120,59 +123,54 @@ interface MaterialGroup {
120
123
  * blob (`items`), not inside it.
121
124
  */
122
125
  interface DisplayBatch {
123
- materials: SerializableMaterial[];
124
- groups: MaterialGroup[];
125
- compressedData: string;
126
- /** InstanceGuid of the WebDisplay GH component that produced this batch; combined with
127
- * MeshMetadata.originalIndex to backtrack any mesh to its GH source. */
128
- sourceComponentId?: string;
129
- /** Non-mesh display items — see {@link DisplayItem}. Parsed by the separate `display-items`
130
- * path, not the SLVA mesh parser. Omitted when there are none. */
131
- items?: DisplayItem[];
126
+ materials: SerializableMaterial[];
127
+ groups: MaterialGroup[];
128
+ compressedData: string;
129
+ /** InstanceGuid of the WebDisplay GH component that produced this batch; combined with
130
+ * MeshMetadata.originalIndex to backtrack any mesh to its GH source. */
131
+ sourceComponentId?: string;
132
+ /** Non-mesh display items — see {@link DisplayItem}. Parsed by the separate `display-items`
133
+ * path, not the SLVA mesh parser. Omitted when there are none. */
134
+ items?: DisplayItem[];
132
135
  }
133
136
  interface MeshBatchParsingOptions {
134
- /** Merge meshes with same material into single geometry. Defaults to true. */
135
- mergeByMaterial?: boolean;
136
- debug?: boolean;
137
- /**
138
- * Appearance dials applied to every material built from this batch — set once at parse time
139
- * (materials are rebuilt per solve). Runtime restyling of an already-built scene lives in the
140
- * viewer's `setLook`.
141
- */
142
- material?: MaterialAppearanceOptions;
137
+ /** Merge meshes sharing a material into a single geometry. Defaults to true. */
138
+ mergeByMaterial?: boolean;
139
+ debug?: boolean;
140
+ /**
141
+ * Appearance dials applied to every material built from this batch — set once at parse time
142
+ * (materials are rebuilt per solve). Runtime restyling of an already-built scene lives in the
143
+ * viewer's `setLook`.
144
+ */
145
+ material?: MaterialAppearanceOptions;
143
146
  }
144
-
145
147
  interface MeshExtractionOptions {
146
- parsing?: MeshBatchParsingOptions;
147
- /** Apply scaling based on model units. Defaults to true. */
148
- allowScaling?: boolean;
149
- /**
150
- * Drop geometry so its lowest point sits on the ground plane. **Defaults to `false`** — content
151
- * renders at its true Rhino coordinates, matching the Grasshopper definition. Setting `true`
152
- * shifts objects, so anything read back out of the scene (bounds, measured/picked positions) no
153
- * longer corresponds to Rhino coordinates.
154
- */
155
- allowAutoPosition?: boolean;
156
- /** Up axis for `allowAutoPosition` grounding. Defaults to `'z'` (Rhino's frame) — only set this
157
- * if the viewer is configured with a non-default `sceneUp`. */
158
- groundAxis?: 'x' | 'y' | 'z';
159
- /** rhino3dm instance for decoding curve display items — selva-compute doesn't own the WASM
160
- * instance, the host threads it in. Omit to skip curves (points still render). */
161
- rhino?: RhinoModule;
162
- debug?: boolean;
163
- }
164
-
148
+ parsing?: MeshBatchParsingOptions;
149
+ /** Scale geometry to model units. Defaults to true. */
150
+ allowScaling?: boolean;
151
+ /**
152
+ * Drop geometry so its lowest point sits on the ground plane. **Defaults to `false`** — content
153
+ * renders at its true Rhino coordinates, matching the Grasshopper definition. Setting `true`
154
+ * shifts objects, so anything read back out of the scene (bounds, measured/picked positions) no
155
+ * longer corresponds to Rhino coordinates.
156
+ */
157
+ allowAutoPosition?: boolean;
158
+ /** Up axis for `allowAutoPosition` grounding. Defaults to `'z'` (Rhino's frame) — only set this
159
+ * if the viewer is configured with a non-default `sceneUp`. */
160
+ groundAxis?: 'x' | 'y' | 'z';
161
+ debug?: boolean;
162
+ }
163
+ //#endregion
164
+ //#region src/parse/webdisplay/webdisplay-parser.d.ts
165
165
  /**
166
166
  * Metres per model unit, keyed by Rhino `UnitSystem` name (the `modelunits` string on the compute
167
- * response). Imperial factors are the exact international definitions (1 in = 0.0254 m,
168
- * 1 ft = 0.3048 m, 1 mi = 1609.344 m). Units not in this table scale 1 and log a one-time warning
169
- * — see {@link getScaleFactor}.
167
+ * response). Imperial factors are the exact international definitions. Units missing from this
168
+ * table scale by 1 and log a one-time warning — see {@link getScaleFactor}.
170
169
  */
171
170
  declare const SCALE_FACTORS: Record<string, number>;
172
171
  /**
173
172
  * Extracts display meshes and items from a Grasshopper WebDisplay compute response: decompresses,
174
- * scales to meters, and optionally grounds them. Requires the VektorNode Rhino.Compute fork (see
175
- * root CLAUDE.md).
173
+ * scales to meters, and optionally grounds them. Requires the VektorNode Rhino.Compute fork.
176
174
  *
177
175
  * Synchronous internally (large batches block the UI for their duration); `async` only so the
178
176
  * shape can stay stable if parsing moves off-thread later.
@@ -180,56 +178,51 @@ declare const SCALE_FACTORS: Record<string, number>;
180
178
  * @throws Rethrows unexpected errors after attempting to dispose any created meshes.
181
179
  */
182
180
  declare function getThreeMeshesFromComputeResponse(data: DisplayComputeResponse, options?: MeshExtractionOptions): Promise<THREE.Object3D[]>;
183
-
184
- /** Internal telemetry only (not exposed in public options). */
181
+ //#endregion
182
+ //#region src/parse/webdisplay/batch-parser.d.ts
185
183
  interface ParseTelemetry {
186
- parseTime?: number;
187
- perfStart?: number;
184
+ parseTime?: number;
185
+ perfStart?: number;
188
186
  }
189
187
  /**
190
188
  * Parses a DisplayBatch object and creates Three.js meshes from its mesh blob.
191
189
  *
192
190
  * Synchronous internally — `parseBinaryMeshBatch` does no IO, just typed-array views over the
193
- * blob. Stays `async` so callers don't have to change shape if parsing moves into a worker later.
191
+ * blob. Stays `async` so callers don't need to change shape if parsing moves into a worker later.
194
192
  *
195
193
  * @throws {VisualizationError} On a corrupt/truncated/unsupported mesh blob or malformed group metadata.
196
194
  */
197
- declare function parseMeshBatchObject(batch: DisplayBatch, options?: MeshBatchParsingOptions,
198
- /** @internal Timings threaded from an outer entry point; not a caller option. */
195
+ declare function parseMeshBatchObject(batch: DisplayBatch, options?: MeshBatchParsingOptions,
196
+ /** @internal Timings threaded from an outer entry point not a caller option. */
199
197
  telemetry?: ParseTelemetry): Promise<THREE.Mesh[]>;
200
198
  /**
201
199
  * Parses a raw binary mesh batch blob (SLVA wire format) and creates Three.js meshes.
202
200
  *
203
201
  * Use this entry point when the blob arrives as a binary WebSocket frame rather than inside a JSON
204
- * envelope. The blob is self-describing materials, groups, and `sourceComponentId` come from its
205
- * embedded metadata header.
202
+ * envelope the blob is self-describing, with materials, groups, and `sourceComponentId` coming
203
+ * from its embedded metadata header.
206
204
  *
207
205
  * @throws {VisualizationError} On a corrupt/truncated/unsupported mesh blob or malformed group metadata.
208
206
  */
209
207
  declare function parseMeshBatchBlob(blob: ArrayBuffer | Uint8Array, options?: MeshBatchParsingOptions): Promise<THREE.Mesh[]>;
210
-
208
+ //#endregion
209
+ //#region src/parse/webdisplay/apply-texture.d.ts
211
210
  /**
212
211
  * Subscribed to the renderer's own report below, so no host wiring is needed; still exported for a
213
- * host embedding a foreign renderer that wants to set it directly.
212
+ * host embedding a foreign renderer that wants to set it directly. Applies to textures loaded from
213
+ * here on — textures already decoded keep the value they were given.
214
214
  */
215
215
  declare function setTextureAnisotropy(value: number): void;
216
-
216
+ //#endregion
217
+ //#region src/parse/display-items/display-items-parser.d.ts
217
218
  /**
218
- * Free every cross-solve GPU cache cached geometries, textures and edge segments.
219
+ * Builds THREE objects for the batch's non-mesh items.
219
220
  *
220
- * **You do not normally need this.** These caches register themselves for teardown, so the viewer's
221
- * `dispose()` already frees them once the last live viewer goes away. It is exported for the cases
222
- * that sit outside a viewer lifecycle: reclaiming memory under pressure, or a test isolating
223
- * module-level state.
224
- *
225
- * Safe to call repeatedly and with a viewer running — the caches simply repopulate on the next solve.
221
+ * @throws VisualizationError when a curve predates backend tessellation, so a stale definition
222
+ * surfaces as an actionable error instead of a scene quietly missing its curves. Every other
223
+ * unrenderable item is logged and skipped.
226
224
  */
227
- declare function releaseParseCaches(): void;
228
-
229
- interface DisplayItemParseOptions {
230
- /** Omit to skip curves; points still render. */
231
- rhino?: RhinoModule;
232
- }
233
- declare function parseDisplayItems(items: DisplayItem[] | undefined, options?: DisplayItemParseOptions): THREE.Object3D[];
234
-
235
- export { type DisplayBatch, type DisplayComputeResponse, type DisplayCurve, type DisplayDataItem, type DisplayIdentity, type DisplayItem, type DisplayItemBase, type DisplayItemParseOptions, type DisplayPoint, type DisplayPosition, type DisplayResponseValue, type MaterialGroup, type MeshBatchParsingOptions, type MeshExtractionOptions, type MeshMetadata, SCALE_FACTORS, type SerializableMaterial, getThreeMeshesFromComputeResponse, meshPolicy, parseDisplayItems, parseMeshBatchBlob, parseMeshBatchObject, releaseParseCaches, setTextureAnisotropy };
225
+ declare function parseDisplayItems(items: DisplayItem[] | undefined): THREE.Object3D[];
226
+ //#endregion
227
+ export { type DisplayBatch, type DisplayComputeResponse, type DisplayCurve, type DisplayDataItem, type DisplayIdentity, type DisplayItem, type DisplayItemBase, type DisplayPoint, type DisplayPosition, type DisplayResponseValue, type MaterialGroup, type MeshBatchParsingOptions, type MeshExtractionOptions, type MeshMetadata, SCALE_FACTORS, type SerializableMaterial, getThreeMeshesFromComputeResponse, meshPolicy, parseDisplayItems, parseMeshBatchBlob, parseMeshBatchObject, setTextureAnisotropy };
228
+ //# sourceMappingURL=parse.d.cts.map