@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.
- package/README.md +11 -10
- package/dist/gpu-dispose-Dkj-BKt4.js +2 -0
- package/dist/gpu-dispose-Dkj-BKt4.js.map +1 -0
- package/dist/gpu-dispose-DrN-ryj5.cjs +2 -0
- package/dist/gpu-dispose-DrN-ryj5.cjs.map +1 -0
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- package/dist/parse.cjs +3 -3
- package/dist/parse.cjs.map +1 -1
- package/dist/parse.d.cts +135 -142
- package/dist/parse.d.ts +135 -142
- package/dist/parse.js +3 -3
- package/dist/parse.js.map +1 -1
- package/dist/render.cjs +8 -10
- package/dist/render.cjs.map +1 -1
- package/dist/render.d.cts +335 -333
- package/dist/render.d.ts +335 -333
- package/dist/render.js +8 -10
- package/dist/render.js.map +1 -1
- package/dist/rolldown-runtime-BocRIvOZ.cjs +1 -0
- package/dist/scene.cjs +1 -1
- package/dist/scene.cjs.map +1 -1
- package/dist/scene.d.cts +95 -95
- package/dist/scene.d.ts +95 -95
- package/dist/scene.js +1 -1
- package/dist/scene.js.map +1 -1
- package/dist/types-Di80Y609.d.cts +34 -0
- package/dist/types-Di80Y609.d.ts +34 -0
- package/package.json +14 -10
- package/dist/chunk-5XGN7UAV.js +0 -2
- package/dist/chunk-5XGN7UAV.js.map +0 -1
- package/dist/chunk-AQJPVUH3.cjs +0 -2
- package/dist/chunk-AQJPVUH3.cjs.map +0 -1
- package/dist/chunk-BYLIBOAU.cjs +0 -2
- package/dist/chunk-BYLIBOAU.cjs.map +0 -1
- package/dist/chunk-EXAI6IC5.js +0 -2
- package/dist/chunk-EXAI6IC5.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types-CdF9R3qA.d.cts +0 -41
- package/dist/types-CdF9R3qA.d.ts +0 -41
package/dist/parse.d.cts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
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
|
-
|
|
11
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
InnerTree: {
|
|
24
|
+
[branchPath: string]: DisplayDataItem[];
|
|
25
|
+
};
|
|
29
26
|
}
|
|
30
27
|
interface DisplayComputeResponse {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
values: DisplayResponseValue[];
|
|
29
|
+
/** Rhino `UnitSystem` name driving unit scaling (see `SCALE_FACTORS`); unrecognized/absent scales 1. */
|
|
30
|
+
modelunits: string;
|
|
34
31
|
}
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/parse/display-items/types.d.ts
|
|
37
34
|
interface DisplayIdentity {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
X: number;
|
|
51
|
+
Y: number;
|
|
52
|
+
Z: number;
|
|
57
53
|
}
|
|
58
|
-
/**
|
|
54
|
+
/** Rendered as a fat `Line2` straight from `points` — nothing decodes geometry in the browser. */
|
|
59
55
|
interface DisplayCurve extends DisplayItemBase {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
67
|
-
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
-
|
|
108
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
|
168
|
-
*
|
|
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
|
|
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
|
-
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/parse/webdisplay/batch-parser.d.ts
|
|
185
183
|
interface ParseTelemetry {
|
|
186
|
-
|
|
187
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
*
|
|
219
|
+
* Builds THREE objects for the batch's non-mesh items.
|
|
219
220
|
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
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
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
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
|