@nuflo/engine 0.1.1
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/nf_wasm.d.ts +656 -0
- package/nf_wasm.js +2864 -0
- package/nf_wasm_bg.wasm +0 -0
- package/package.json +20 -0
package/nf_wasm.d.ts
ADDED
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The graph engine exposed to JavaScript.
|
|
6
|
+
*/
|
|
7
|
+
export class Engine {
|
|
8
|
+
free(): void;
|
|
9
|
+
[Symbol.dispose](): void;
|
|
10
|
+
/**
|
|
11
|
+
* Number of assets currently resolved (for diagnostics / the host loader).
|
|
12
|
+
*/
|
|
13
|
+
asset_count(): number;
|
|
14
|
+
/**
|
|
15
|
+
* Keyframe-bake the current scene along the scroll axis (#4): evaluate the graph at
|
|
16
|
+
* `samples` scroll positions and store the geometry so `tick` interpolates it instead
|
|
17
|
+
* of re-evaluating the graph every frame ("bake the function"). Returns `false` (no
|
|
18
|
+
* bake) when there's no document, no mesh, or the topology changes across scroll.
|
|
19
|
+
* PRECONDITION: lighting/camera/materials must be static (only geometry animates
|
|
20
|
+
* along scroll) — the bake captures the render config once at scroll 0.
|
|
21
|
+
*/
|
|
22
|
+
bake_scroll(samples: number): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The active scene camera as a flat float array for
|
|
25
|
+
* [`Viewport::set_scene_camera`](crate::Viewport::set_scene_camera):
|
|
26
|
+
* `[eye.xyz(3), target.xyz(3), up.xyz(3), fov_y_deg, projection(0 persp/1 ortho),
|
|
27
|
+
* ortho_height, znear, zfar]` (14 floats).
|
|
28
|
+
*
|
|
29
|
+
* When no `camera` node ran this returns `SceneCamera::default()` — the framing
|
|
30
|
+
* the editor viewport hardcoded before the camera became a node — so existing
|
|
31
|
+
* scenes look unchanged.
|
|
32
|
+
*/
|
|
33
|
+
camera(): Float32Array;
|
|
34
|
+
/**
|
|
35
|
+
* `[view_proj | inverse(view_proj)]` (32 column-major f32) for the live editor
|
|
36
|
+
* camera, built with the renderer's own [`nf_render::Camera`] so editor
|
|
37
|
+
* overlays project against the EXACT matrix the renderer draws with (no TS
|
|
38
|
+
* re-derivation of the camera math — the source of the old +Y/+Z drift).
|
|
39
|
+
* `cam` is the flat camera ABI ([`Engine::camera`] layout); `aspect` = w/h.
|
|
40
|
+
*/
|
|
41
|
+
camera_matrices(cam: Float32Array, aspect: number): Float32Array;
|
|
42
|
+
/**
|
|
43
|
+
* The node catalog as a JSON array of node definitions, for the editor
|
|
44
|
+
* palette and the AI layer. Serialization of the catalog cannot realistically
|
|
45
|
+
* fail; on the off chance it does we return an empty JSON array.
|
|
46
|
+
*/
|
|
47
|
+
catalog(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Drop every provided asset. The host calls this when switching to an
|
|
50
|
+
* unrelated scene; document edits do NOT need it (handles are content-stable).
|
|
51
|
+
*/
|
|
52
|
+
clear_assets(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Drop the scroll bake; `tick` returns to live graph evaluation.
|
|
55
|
+
*/
|
|
56
|
+
clear_bake(): void;
|
|
57
|
+
/**
|
|
58
|
+
* Drop a host-injected external signal by name. Subsequent reads on
|
|
59
|
+
* nodes referencing `name` fall back to their literal default.
|
|
60
|
+
*/
|
|
61
|
+
clear_external_signal(name: string): void;
|
|
62
|
+
/**
|
|
63
|
+
* Flattened `r, g, b, a` per-vertex linear colors of the cached mesh, read
|
|
64
|
+
* from the `color` point attribute (empty if absent or not vertex-aligned).
|
|
65
|
+
* This is the glTF `COLOR_0` channel: an imported `.glb`'s vertex colors land
|
|
66
|
+
* here and survive a re-export. Returned to JS as a `Float32Array`.
|
|
67
|
+
*/
|
|
68
|
+
colors(): Float32Array;
|
|
69
|
+
/**
|
|
70
|
+
* Flattened `r, g, b, a` per-vertex HDR emission colors of the cached mesh
|
|
71
|
+
* (empty if no point-domain emission attribute is present).
|
|
72
|
+
*/
|
|
73
|
+
emissions(): Float32Array;
|
|
74
|
+
/**
|
|
75
|
+
* The most recently evaluated environment as a flat float array for
|
|
76
|
+
* [`Viewport::set_environment`](crate::Viewport::set_environment):
|
|
77
|
+
* `[floor_rgb(3), zenith_rgb(3), intensity(1), softbox_count(1),
|
|
78
|
+
* fog_color_rgb(3), fog_near(1), fog_far(1), fog_density(1), fog_mode(1),
|
|
79
|
+
* bg_rgba(4), bg_enabled(1), then per softbox: dir_xyz(3), color_rgb(3),
|
|
80
|
+
* sharpness(1)]` (20-float header).
|
|
81
|
+
* Prefers an `environment` node's value; falls back to the evaluated `LookSpec`
|
|
82
|
+
* environment when the graph has none. Disabled softboxes are already dropped.
|
|
83
|
+
*/
|
|
84
|
+
environment(): Float32Array;
|
|
85
|
+
/**
|
|
86
|
+
* Parse and evaluate a [`GraphDocument`] (as JSON), caching the resulting
|
|
87
|
+
* geometry for the buffer accessors.
|
|
88
|
+
*
|
|
89
|
+
* Returns a JSON status string and never panics on bad input:
|
|
90
|
+
* - success: `{"ok":true,"verts":N,"faces":M,"tris":T}`
|
|
91
|
+
* - parse/eval failure: `{"ok":false,"error":"<message>"}`
|
|
92
|
+
*/
|
|
93
|
+
evaluate(document_json: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Current host-injected external signals as a typed JSON array, for the
|
|
96
|
+
* inspector's live-values panel. Each entry: `{kind, name, value}`. `value`
|
|
97
|
+
* shape varies by kind (number for float, bool for bool, `[x,y,z]` for vec3).
|
|
98
|
+
* Inline-typed so we can carry the kind tag without `serde_json::Value`.
|
|
99
|
+
*/
|
|
100
|
+
external_signals_json(): string;
|
|
101
|
+
/**
|
|
102
|
+
* Per-TRIANGLE source-node indices of the cached mesh, aligned 1:1 with the
|
|
103
|
+
* triangles emitted by [`Engine::indices`] (`indices().len() / 3` entries). Each
|
|
104
|
+
* value indexes [`Engine::source_node_ids`]; the sentinel `u32::MAX` means "no
|
|
105
|
+
* node". Empty if there is no cached mesh. Returned to JS as a `Uint32Array`.
|
|
106
|
+
*/
|
|
107
|
+
face_source_nodes(): Uint32Array;
|
|
108
|
+
/**
|
|
109
|
+
* Read a boolean state variable (false if unset).
|
|
110
|
+
*/
|
|
111
|
+
get_var_bool(name: string): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Read a color state variable as `[r, g, b, a]` (opaque black if unset).
|
|
114
|
+
*/
|
|
115
|
+
get_var_color(name: string): Float32Array;
|
|
116
|
+
/**
|
|
117
|
+
* Read a numeric state variable (0.0 if unset).
|
|
118
|
+
*/
|
|
119
|
+
get_var_number(name: string): number;
|
|
120
|
+
/**
|
|
121
|
+
* Read a vector state variable as `[x, y, z]` (zeros if unset). This is the
|
|
122
|
+
* host→3D binding path for positions/rotations/scales.
|
|
123
|
+
*/
|
|
124
|
+
get_var_vector(name: string): Float32Array;
|
|
125
|
+
/**
|
|
126
|
+
* The cached GPU-SDF field's compiled-shader description, as the strings/floats
|
|
127
|
+
* the viewport reconstructs a render request from (the `Field` itself can't
|
|
128
|
+
* cross the JS boundary). Layout:
|
|
129
|
+
* `[result_type, needs_noise, needs_op_lib, center_x, center_y, center_z, size,
|
|
130
|
+
* resolution]` (all `f32`; booleans are 0/1, `resolution` rounds to `u32`),
|
|
131
|
+
* returned alongside the WGSL `body`/`result` strings via
|
|
132
|
+
* [`Engine::gpu_sdf_program_body`]/[`Engine::gpu_sdf_program_result`]. Empty if
|
|
133
|
+
* there is no `gpu_sdf` or its field doesn't compile to WGSL.
|
|
134
|
+
*/
|
|
135
|
+
gpu_sdf_descriptor(): Float32Array;
|
|
136
|
+
/**
|
|
137
|
+
* The WGSL `body` (SSA statements) of the cached GPU-SDF field's compiled
|
|
138
|
+
* program; empty if there is no `gpu_sdf` or it doesn't compile.
|
|
139
|
+
*/
|
|
140
|
+
gpu_sdf_program_body(): string;
|
|
141
|
+
/**
|
|
142
|
+
* The WGSL `result` expression of the cached GPU-SDF field's compiled program;
|
|
143
|
+
* empty if there is no `gpu_sdf` or it doesn't compile.
|
|
144
|
+
*/
|
|
145
|
+
gpu_sdf_program_result(): string;
|
|
146
|
+
/**
|
|
147
|
+
* The most recent `tick`'s signals (8 floats, `SignalKind` order) for the
|
|
148
|
+
* GPU-SDF density shader's uniform, so the field animates per frame.
|
|
149
|
+
*/
|
|
150
|
+
gpu_sdf_signals(): Float32Array;
|
|
151
|
+
/**
|
|
152
|
+
* Whether the cached geometry carries a GPU-polygonized SDF (`sdf_to_mesh` in
|
|
153
|
+
* GPU mode). When true, the frontend should drive the viewport's GPU-SDF glass
|
|
154
|
+
* path (`render_gpu_sdf`) instead of `set_mesh` — the field is polygonized on
|
|
155
|
+
* the GPU every frame rather than carried as a CPU mesh.
|
|
156
|
+
*/
|
|
157
|
+
has_gpu_sdf(): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Triangulated triangle indices of the cached mesh (empty if none).
|
|
160
|
+
* Returned to JS as a `Uint32Array`.
|
|
161
|
+
*/
|
|
162
|
+
indices(): Uint32Array;
|
|
163
|
+
/**
|
|
164
|
+
* Whether a scroll bake is currently active.
|
|
165
|
+
*/
|
|
166
|
+
is_baked(): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* The scene lights from the most recent evaluation, flattened to
|
|
169
|
+
* [`LIGHT_STRIDE`] floats each for
|
|
170
|
+
* [`Viewport::set_lights`](crate::Viewport::set_lights):
|
|
171
|
+
* `[kind(0 dir/1 point/2 spot), pos.x,pos.y,pos.z, dir.x,dir.y,dir.z,
|
|
172
|
+
* color.r,color.g,color.b, intensity, range, cos_inner, cos_outer]`.
|
|
173
|
+
*
|
|
174
|
+
* When the graph emitted no light nodes the array is a single default
|
|
175
|
+
* directional light (a soft key from above-front) so lightless scenes still
|
|
176
|
+
* render instead of going black. The frontend infers the light count as
|
|
177
|
+
* `len / LIGHT_STRIDE`.
|
|
178
|
+
*/
|
|
179
|
+
lights_flat(): Float32Array;
|
|
180
|
+
/**
|
|
181
|
+
* Load a `scene.wasm` (or its raw `nf-scene` section payload): decode the
|
|
182
|
+
* bundle, install the document, register any Embedded assets into the store,
|
|
183
|
+
* and return a JSON status listing the External assets the host must still
|
|
184
|
+
* fetch and `provide_asset`. Shape:
|
|
185
|
+
* `{"ok":true,"external":[{"handle","mime","sha256","url"}]}` or
|
|
186
|
+
* `{"ok":false,"error":...}`.
|
|
187
|
+
*/
|
|
188
|
+
load_scene_wasm(scene_wasm: Uint8Array): string;
|
|
189
|
+
/**
|
|
190
|
+
* The cached geometry's PBR material as the full 32-float ABI documented on
|
|
191
|
+
* [`nf_core::geometry::Material::from_engine_slice`]: the 24-float core
|
|
192
|
+
* (`base_color.rgba`, metallic, roughness, emission, iridescence, matcap,
|
|
193
|
+
* texture controls, map strengths, video_texture_mix) followed by the glass
|
|
194
|
+
* block `[transmission, ior, thickness, attenuation_color.rgb,
|
|
195
|
+
* attenuation_distance, dispersion]`. `Viewport::set_material` and the GLB
|
|
196
|
+
* exporter decode it with the same constructor. Defaults if no geometry yet.
|
|
197
|
+
*/
|
|
198
|
+
material(): Float32Array;
|
|
199
|
+
/**
|
|
200
|
+
* Build an engine with all built-in node types registered.
|
|
201
|
+
*/
|
|
202
|
+
constructor();
|
|
203
|
+
/**
|
|
204
|
+
* Flattened `x, y, z` vertex normals of the cached mesh (empty if none).
|
|
205
|
+
* Returned to JS as a `Float32Array`.
|
|
206
|
+
*/
|
|
207
|
+
normals(): Float32Array;
|
|
208
|
+
/**
|
|
209
|
+
* Export the current document as a `scene.wasm`: the graph (MessagePack) plus
|
|
210
|
+
* an asset table baked into the `nf-scene` custom section. `embedded` selects
|
|
211
|
+
* the asset mode:
|
|
212
|
+
* - `true` — every provided asset's bytes ride inside the section (a single
|
|
213
|
+
* self-contained download; re-ships on every edit, no cross-scene dedup).
|
|
214
|
+
* - `false` — only a content-addressed manifest rides in the section (handle,
|
|
215
|
+
* MIME, sha256); the bytes are fetched separately at load (cached, shared,
|
|
216
|
+
* parallel). The host hosts the bytes by sha256 / the loader's configured base.
|
|
217
|
+
*
|
|
218
|
+
* Returns the `scene.wasm` bytes, or an error if no document is loaded.
|
|
219
|
+
*/
|
|
220
|
+
pack_scene_wasm(embedded: boolean): Uint8Array;
|
|
221
|
+
/**
|
|
222
|
+
* Drain the host-bound runtime actions queued since the last call,
|
|
223
|
+
* returning them as a JSON array of tagged objects (the same shape as
|
|
224
|
+
* [`RuntimeAction`]'s `#[serde(tag = "kind")]` representation). The
|
|
225
|
+
* frontend parses this once per frame as a typed discriminated union
|
|
226
|
+
* (`{ kind: "open_link", url, new_tab } | { kind: "play_sound", ... }
|
|
227
|
+
* | ...`) and dispatches each intent to its host handler.
|
|
228
|
+
*
|
|
229
|
+
* Engine-local intents (variable resets) are dispatched inside `tick`
|
|
230
|
+
* and never appear here. Calling this method clears the queue, so back-
|
|
231
|
+
* to-back calls in the same frame will return `[]` for the second one.
|
|
232
|
+
*/
|
|
233
|
+
pending_actions_json(): string;
|
|
234
|
+
/**
|
|
235
|
+
* The source-node id of the geometry under a viewport point, or `None` on a
|
|
236
|
+
* miss. `ndc_x`/`ndc_y` are normalized device coords in `[-1, 1]` (+Y up).
|
|
237
|
+
* Raycasts the cached mesh (Möller–Trumbore) using a ray unprojected from the
|
|
238
|
+
* live camera — the picking compute lives here in Rust, not TS.
|
|
239
|
+
*/
|
|
240
|
+
pick(cam: Float32Array, aspect: number, ndc_x: number, ndc_y: number): string | undefined;
|
|
241
|
+
/**
|
|
242
|
+
* Source-node ids whose geometry falls inside a screen-rect marquee (NDC, +Y
|
|
243
|
+
* up). A node is included when any of its triangles' centroids project inside
|
|
244
|
+
* the rect. The box-select compute lives here in Rust, not TS.
|
|
245
|
+
*/
|
|
246
|
+
pick_rect(cam: Float32Array, aspect: number, min_x: number, min_y: number, max_x: number, max_y: number): string[];
|
|
247
|
+
/**
|
|
248
|
+
* Flattened `x, y, z` vertex positions of the cached mesh (empty if none).
|
|
249
|
+
* Returned to JS as a `Float32Array`.
|
|
250
|
+
*/
|
|
251
|
+
positions(): Float32Array;
|
|
252
|
+
/**
|
|
253
|
+
* The most recently evaluated post-process settings as a flat float
|
|
254
|
+
* array for [`Viewport::set_post`](crate::Viewport::set_post):
|
|
255
|
+
* `[bloom_threshold, bloom_knee, bloom_strength, vignette_intensity,
|
|
256
|
+
* vignette_radius, vignette_smoothness, vignette_roundness,
|
|
257
|
+
* film_grain_intensity, film_grain_size, film_grain_time,
|
|
258
|
+
* color_grade_exposure, color_grade_contrast, color_grade_saturation,
|
|
259
|
+
* color_grade_hue]`.
|
|
260
|
+
*/
|
|
261
|
+
post(): Float32Array;
|
|
262
|
+
/**
|
|
263
|
+
* Provide (or replace) an asset's bytes under its handle. The host calls this
|
|
264
|
+
* for each External asset it has fetched (keyed by the handle the scene's
|
|
265
|
+
* nodes reference); the next `tick`/`evaluate` resolves it. Copy-on-write:
|
|
266
|
+
* cheap when the store isn't currently borrowed by an in-flight eval.
|
|
267
|
+
*/
|
|
268
|
+
provide_asset(handle: string, mime: string, bytes: Uint8Array): void;
|
|
269
|
+
/**
|
|
270
|
+
* Clear transient and held input state, useful when the host loses focus.
|
|
271
|
+
*/
|
|
272
|
+
reset_input_state(): void;
|
|
273
|
+
/**
|
|
274
|
+
* Reset the cached scene runtime to the current document defaults.
|
|
275
|
+
*
|
|
276
|
+
* This keeps the loaded document and cached geometry, but re-seeds declared
|
|
277
|
+
* variables, clears keyboard/pointer/drag state, resets the first-frame start
|
|
278
|
+
* pulse, and restores the evaluated look cache to the current spec defaults.
|
|
279
|
+
*/
|
|
280
|
+
reset_scene(): string;
|
|
281
|
+
/**
|
|
282
|
+
* Cache a [`GraphDocument`] (as JSON) for per-frame evaluation via [`tick`].
|
|
283
|
+
*
|
|
284
|
+
* Returns a JSON status: `{"ok":true}` or `{"ok":false,"error":...}`. Parsing
|
|
285
|
+
* happens once here, not every frame.
|
|
286
|
+
*
|
|
287
|
+
* [`tick`]: Engine::tick
|
|
288
|
+
*/
|
|
289
|
+
set_document(document_json: string): string;
|
|
290
|
+
/**
|
|
291
|
+
* Cache a [`GraphDocument`] from its binary (MessagePack) wire form — the
|
|
292
|
+
* payload an exported `scene.wasm` carries. The authoring path stays JSON
|
|
293
|
+
* ([`Engine::set_document`]); this is the runtime path for a binary scene
|
|
294
|
+
* with no embedded assets (or after assets were provided separately).
|
|
295
|
+
*/
|
|
296
|
+
set_document_bin(document_bin: Uint8Array): string;
|
|
297
|
+
/**
|
|
298
|
+
* Set a host-injected external signal bool by name. Read by
|
|
299
|
+
* `input_external_bool` nodes next tick.
|
|
300
|
+
*/
|
|
301
|
+
set_external_signal_bool(name: string, value: boolean): void;
|
|
302
|
+
/**
|
|
303
|
+
* Set a host-injected external signal float by name. Read by
|
|
304
|
+
* `input_external_float` nodes next tick; absent keys fall back to the
|
|
305
|
+
* node's literal default. Use `clear_external_signal` to drop a key.
|
|
306
|
+
*/
|
|
307
|
+
set_external_signal_float(name: string, value: number): void;
|
|
308
|
+
/**
|
|
309
|
+
* Set a host-injected external signal vec3 by name. Read by
|
|
310
|
+
* `input_external_vec3` nodes next tick.
|
|
311
|
+
*/
|
|
312
|
+
set_external_signal_vec3(name: string, x: number, y: number, z: number): void;
|
|
313
|
+
/**
|
|
314
|
+
* Update keyboard state from a host `keydown`/`keyup` listener.
|
|
315
|
+
*
|
|
316
|
+
* `key` may be either `KeyboardEvent.key` (`"Space"`, `"a"`, `"ArrowLeft"`)
|
|
317
|
+
* or `KeyboardEvent.code` (`"KeyA"`, `"Digit1"`). The next `tick` exposes
|
|
318
|
+
* key-down/key-up pulses; held state remains true until released.
|
|
319
|
+
*/
|
|
320
|
+
set_key_state(key: string, pressed: boolean): string;
|
|
321
|
+
/**
|
|
322
|
+
* Set the declarative, signal-driven render Look (as a JSON [`LookSpec`]).
|
|
323
|
+
*
|
|
324
|
+
* Every numeric field of the spec is a `ParamValue` — a constant or a driver
|
|
325
|
+
* expression evaluated each `tick` against the live browser signals (exactly
|
|
326
|
+
* like node params). Parsing happens once here, not per frame. Returns the same
|
|
327
|
+
* JSON status shape as [`evaluate`](Engine::evaluate); on parse failure the
|
|
328
|
+
* previous Look spec is kept.
|
|
329
|
+
*/
|
|
330
|
+
set_look_spec(spec_json: string): string;
|
|
331
|
+
/**
|
|
332
|
+
* Set a boolean state variable.
|
|
333
|
+
*/
|
|
334
|
+
set_var_bool(name: string, value: boolean): void;
|
|
335
|
+
/**
|
|
336
|
+
* Set an RGBA color state variable (coerced to its declared type). The host→3D
|
|
337
|
+
* color-binding path — e.g. push the current product variant's accent color.
|
|
338
|
+
*/
|
|
339
|
+
set_var_color(name: string, r: number, g: number, b: number, a: number): void;
|
|
340
|
+
/**
|
|
341
|
+
* Set a numeric state variable (coerced to its declared type). No-op if the
|
|
342
|
+
* value can't coerce to the declared type.
|
|
343
|
+
*/
|
|
344
|
+
set_var_number(name: string, value: number): void;
|
|
345
|
+
/**
|
|
346
|
+
* Set a 3-component vector state variable (coerced to its declared type).
|
|
347
|
+
*/
|
|
348
|
+
set_var_vector(name: string, x: number, y: number, z: number): void;
|
|
349
|
+
/**
|
|
350
|
+
* The ordered provenance table as a JSON array of node-instance-id strings, e.g.
|
|
351
|
+
* `["cube_abc","sphere_def"]`. Index `i` returned by [`Engine::face_source_nodes`]
|
|
352
|
+
* refers to entry `i` here. This is a return value (not a struct field), so
|
|
353
|
+
* serializing a `Vec<String>` with `serde_json` is permitted.
|
|
354
|
+
*/
|
|
355
|
+
source_node_ids(): string;
|
|
356
|
+
/**
|
|
357
|
+
* Active scene-wide image bindings, as JSON `[{ "slot": ..., "url": ... }]`.
|
|
358
|
+
*
|
|
359
|
+
* Scans the currently loaded document for `image_texture` nodes (not hidden,
|
|
360
|
+
* with a non-empty `asset_url` literal). The frontend reads this each frame
|
|
361
|
+
* and lazy-loads each URL into RGBA, binding into `Viewport::set_*_map`
|
|
362
|
+
* slots. A later collision (two `image_texture` nodes targeting the same
|
|
363
|
+
* slot) is resolved last-wins, mirroring how the renderer accepts one
|
|
364
|
+
* texture per slot today.
|
|
365
|
+
*/
|
|
366
|
+
texture_bindings_json(): string;
|
|
367
|
+
/**
|
|
368
|
+
* Evaluate the cached document with the current frame's browser signals.
|
|
369
|
+
*
|
|
370
|
+
* `time` is seconds since the scene started; the frame delta is derived from
|
|
371
|
+
* the previous `tick`. `mouse_x`/`mouse_y` are pixel coordinates (origin
|
|
372
|
+
* top-left). `scroll` is `0..1`. The result is cached for the buffer accessors.
|
|
373
|
+
* Returns the same JSON status shape as [`evaluate`](Engine::evaluate).
|
|
374
|
+
*/
|
|
375
|
+
tick(time: number, mouse_x: number, mouse_y: number, scroll: number, viewport_w: number, viewport_h: number, click: boolean, section_index: number, section_progress: number, dark_mode: boolean, reduced_motion: boolean): string;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* A canvas-bound fila renderer.
|
|
380
|
+
*/
|
|
381
|
+
export class Viewport {
|
|
382
|
+
private constructor();
|
|
383
|
+
free(): void;
|
|
384
|
+
[Symbol.dispose](): void;
|
|
385
|
+
/**
|
|
386
|
+
* Create a viewport for `canvas`, asynchronously acquiring a wgpu adapter and device and
|
|
387
|
+
* configuring the surface. Rejects (throws a `JsError`) if no adapter/device is available or the
|
|
388
|
+
* surface can't be created.
|
|
389
|
+
*/
|
|
390
|
+
static create(canvas: HTMLCanvasElement): Promise<Viewport>;
|
|
391
|
+
/**
|
|
392
|
+
* Per-frame render instrumentation for the LAST `render_fila`, as a flat float vector:
|
|
393
|
+
* `[scene_lowering_ms, fila_passes_ms, present_ms, buffers_created, bytes_uploaded,
|
|
394
|
+
* bind_groups_created, render_passes, programs_total, pipelines_total, textures_created,
|
|
395
|
+
* submits, t_create_buffer_ms, t_create_bind_group_ms, t_texture_ms, t_end_pass_ms]`. CPU
|
|
396
|
+
* wall-clock for the timing fields (browser `performance.now()`); driver counters for the rest.
|
|
397
|
+
* The editor reads this into `globalThis.__perf` to attribute the frame cost (mesh rebuild vs GPU
|
|
398
|
+
* encode vs present, and per-frame buffer/bind-group/texture churn) and pin what to make persistent.
|
|
399
|
+
*/
|
|
400
|
+
prof(): Float64Array;
|
|
401
|
+
/**
|
|
402
|
+
* Render the engine's last-evaluated scene through fila and present it to the canvas. The graph is
|
|
403
|
+
* lowered to fila's scene IR by [`crate::Engine::fila_scene`]; the viewport's interactive camera
|
|
404
|
+
* overrides the graph camera so orbit/zoom work. With no geometry yet, the frame is cleared.
|
|
405
|
+
*/
|
|
406
|
+
render_fila(engine: Engine): void;
|
|
407
|
+
/**
|
|
408
|
+
* GPU-polygonized SDF (metaballs) is parked: fila has no GPU marching-cubes path yet, so an SDF
|
|
409
|
+
* scene clears to the backdrop instead of rendering (tracked: a compute-MC bridge into fila). The
|
|
410
|
+
* arguments mirror the old nf-render signature so the JS hand-off is unchanged.
|
|
411
|
+
*/
|
|
412
|
+
render_gpu_sdf(_body: string, _result: string, _descriptor: Float32Array, _signals: Float32Array): void;
|
|
413
|
+
/**
|
|
414
|
+
* Resize the surface to `w` x `h` pixels and update the camera aspect.
|
|
415
|
+
*/
|
|
416
|
+
resize(w: number, h: number): void;
|
|
417
|
+
/**
|
|
418
|
+
* Set the camera from eye/target positions and a vertical field of view (deg).
|
|
419
|
+
*/
|
|
420
|
+
set_camera(eye_x: number, eye_y: number, eye_z: number, target_x: number, target_y: number, target_z: number, fov_deg: number): void;
|
|
421
|
+
/**
|
|
422
|
+
* Switch the camera projection. `mode` accepts `perspective`, `orthographic`, `ortho`, or
|
|
423
|
+
* `orthographic2d`; `orthographic_height` is the vertical world-space size for orthographic mode.
|
|
424
|
+
*/
|
|
425
|
+
set_camera_projection(mode: string, orthographic_height: number): void;
|
|
426
|
+
/**
|
|
427
|
+
* Enable/configure the EDITOR ground grid (a depth-composited pass on the world z=0 plane —
|
|
428
|
+
* geometry occludes the grid). `cell` is the minor cell size (world units); `fade_distance` is
|
|
429
|
+
* where the grid fades to nothing (also the quad's half-extent). EDITOR-ONLY.
|
|
430
|
+
*/
|
|
431
|
+
set_grid(enabled: boolean, cell: number, fade_distance: number): void;
|
|
432
|
+
/**
|
|
433
|
+
* Set the camera from the flat float layout that [`crate::Engine::camera`] emits:
|
|
434
|
+
* `[eye.xyz(3), target.xyz(3), up.xyz(3), fov_y_deg, projection(0 persp/1 ortho),
|
|
435
|
+
* ortho_height, znear, zfar]` (14 floats, + optional pinned aspect at 14). A short slice is
|
|
436
|
+
* ignored. This is the graph-driven camera path; the editor overrides it interactively.
|
|
437
|
+
*/
|
|
438
|
+
set_scene_camera(c: Float32Array): void;
|
|
439
|
+
/**
|
|
440
|
+
* Upload the selected geometry's triangles for the EDITOR selection outline — tightly-packed
|
|
441
|
+
* world-space xyz positions + triangle indices into them. Empty input clears the selection. The
|
|
442
|
+
* data is held CPU-side; fila-render's selection pass uploads + draws it. EDITOR-ONLY.
|
|
443
|
+
*/
|
|
444
|
+
set_selection_mesh(positions: Float32Array, indices: Uint32Array): void;
|
|
445
|
+
/**
|
|
446
|
+
* Enable/configure the EDITOR selection outline (linear RGBA halo color + pixel thickness). Only
|
|
447
|
+
* draws when enabled AND a selection mesh has been uploaded. EDITOR-ONLY.
|
|
448
|
+
*/
|
|
449
|
+
set_selection_outline(enabled: boolean, r: number, g: number, b: number, a: number, thickness: number): void;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Apply a high-level [`GraphCommand`] to a document.
|
|
454
|
+
*
|
|
455
|
+
* `document_json` is a serialized `GraphDocument`; `command_json` is a
|
|
456
|
+
* serialized `GraphCommand`. Returns a JSON-stringified `CommandResult` —
|
|
457
|
+
* either `{ ok: true, doc, outcome }` or `{ ok: false, error }`.
|
|
458
|
+
*
|
|
459
|
+
* This is a standalone function (NOT a method on [`crate::Engine`]) so the
|
|
460
|
+
* editor's React state doesn't have to round-trip through any engine handle
|
|
461
|
+
* just to perform a mutation. The renderer's `Engine::evaluate` is unchanged.
|
|
462
|
+
*/
|
|
463
|
+
export function apply_command(document_json: string, command_json: string): string;
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Compute the structural diff between `prev_json` and `next_json`.
|
|
467
|
+
* Returns a JSON-stringified `DiffResult` — either `{ ok: true, diff }` or
|
|
468
|
+
* `{ ok: false, error }`.
|
|
469
|
+
*/
|
|
470
|
+
export function diff_graph(prev_json: string, next_json: string): string;
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* Compute the downstream closure of `root` in `doc_json`. Mirror of
|
|
474
|
+
* [`upstream_closure`] but walks consumers; used by the workspace "Isolate"
|
|
475
|
+
* gesture to compute the visible-while-isolated set.
|
|
476
|
+
*/
|
|
477
|
+
export function downstream_closure(doc_json: string, root: string): string;
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* Serialize the evaluated mesh to a self-contained glTF 2.0 GLB with its PBR
|
|
481
|
+
* material and per-vertex colors.
|
|
482
|
+
*
|
|
483
|
+
* * `positions`/`normals` are packed xyz, vertex-aligned. Empty `normals` is fine
|
|
484
|
+
* (omitted from the output — the recomputed shading normals are baked into the
|
|
485
|
+
* frame anyway).
|
|
486
|
+
* * `colors` is packed rgba (linear), vertex-aligned, or empty for none → written
|
|
487
|
+
* as the `COLOR_0` attribute.
|
|
488
|
+
* * `indices` are triangle indices.
|
|
489
|
+
* * `material` is the 32-float ABI from `Engine::material` (decoded by
|
|
490
|
+
* [`Material::from_engine_slice`]); base color, metalness/roughness, emission,
|
|
491
|
+
* and the glass/finish KHR extensions are written into the glTF material.
|
|
492
|
+
*/
|
|
493
|
+
export function export_glb(positions: Float32Array, normals: Float32Array, colors: Float32Array, indices: Uint32Array, material: Float32Array): Uint8Array;
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Serialize flat geometry to Wavefront OBJ text. `positions`/`normals` are packed
|
|
497
|
+
* xyz; `indices` are triangle indices. Normals are emitted only when present and
|
|
498
|
+
* vertex-aligned. OBJ is 1-indexed.
|
|
499
|
+
*/
|
|
500
|
+
export function export_obj(positions: Float32Array, normals: Float32Array, indices: Uint32Array): string;
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Wrap the selected `node_ids` from `doc_json` into a fresh `NodePackage`.
|
|
504
|
+
* `category_str` is the snake_case `NodeCategory` (e.g. `"generator"`).
|
|
505
|
+
*/
|
|
506
|
+
export function extract_component(doc_json: string, node_ids_json: string, type_id: string, label: string, category_str: string): string;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Append a fresh promoted input. `promoted_json` is the current
|
|
510
|
+
* `Vec<PromotedInput>` JSON; `target_json` is a `SocketPath` JSON.
|
|
511
|
+
*/
|
|
512
|
+
export function promote_input(promoted_json: string, doc_json: string, target_json: string, public_id: string, label: string): string;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Update the label of the promoted input whose `socket.id == public_id`.
|
|
516
|
+
*/
|
|
517
|
+
export function relabel_promoted_input(promoted_json: string, public_id: string, new_label: string): string;
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Wasm entry point: install the renderer panic hook (readable console
|
|
521
|
+
* backtrace + a `globalThis.__nfRendererPanic` flag the `<nf-scene>` host
|
|
522
|
+
* reads to degrade gracefully on a fatal panic). Marked `#[wasm_bindgen(start)]`
|
|
523
|
+
* so it runs automatically when the module is instantiated.
|
|
524
|
+
*/
|
|
525
|
+
export function start(): void;
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* Remove the promoted input with `public_id`. Idempotent.
|
|
529
|
+
*/
|
|
530
|
+
export function unpromote_input(promoted_json: string, public_id: string): string;
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* Compute the upstream closure of `root` in `doc_json`. Returns the result
|
|
534
|
+
* as a JSON array of node ids (sorted) OR a JSON `{ ok: false, error }`
|
|
535
|
+
* envelope on parse failure. The closure itself can't fail; missing roots
|
|
536
|
+
* just return a single-element vec containing `root`.
|
|
537
|
+
*/
|
|
538
|
+
export function upstream_closure(doc_json: string, root: string): string;
|
|
539
|
+
|
|
540
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
541
|
+
|
|
542
|
+
export interface InitOutput {
|
|
543
|
+
readonly memory: WebAssembly.Memory;
|
|
544
|
+
readonly __wbg_engine_free: (a: number, b: number) => void;
|
|
545
|
+
readonly __wbg_viewport_free: (a: number, b: number) => void;
|
|
546
|
+
readonly apply_command: (a: number, b: number, c: number, d: number) => [number, number];
|
|
547
|
+
readonly diff_graph: (a: number, b: number, c: number, d: number) => [number, number];
|
|
548
|
+
readonly downstream_closure: (a: number, b: number, c: number, d: number) => [number, number];
|
|
549
|
+
readonly engine_asset_count: (a: number) => number;
|
|
550
|
+
readonly engine_bake_scroll: (a: number, b: number) => number;
|
|
551
|
+
readonly engine_camera: (a: number) => [number, number];
|
|
552
|
+
readonly engine_camera_matrices: (a: number, b: number, c: number, d: number) => [number, number];
|
|
553
|
+
readonly engine_catalog: (a: number) => [number, number];
|
|
554
|
+
readonly engine_clear_assets: (a: number) => void;
|
|
555
|
+
readonly engine_clear_bake: (a: number) => void;
|
|
556
|
+
readonly engine_clear_external_signal: (a: number, b: number, c: number) => void;
|
|
557
|
+
readonly engine_colors: (a: number) => [number, number];
|
|
558
|
+
readonly engine_emissions: (a: number) => [number, number];
|
|
559
|
+
readonly engine_environment: (a: number) => [number, number];
|
|
560
|
+
readonly engine_evaluate: (a: number, b: number, c: number) => [number, number];
|
|
561
|
+
readonly engine_external_signals_json: (a: number) => [number, number];
|
|
562
|
+
readonly engine_face_source_nodes: (a: number) => [number, number];
|
|
563
|
+
readonly engine_get_var_bool: (a: number, b: number, c: number) => number;
|
|
564
|
+
readonly engine_get_var_color: (a: number, b: number, c: number) => [number, number];
|
|
565
|
+
readonly engine_get_var_number: (a: number, b: number, c: number) => number;
|
|
566
|
+
readonly engine_get_var_vector: (a: number, b: number, c: number) => [number, number];
|
|
567
|
+
readonly engine_gpu_sdf_descriptor: (a: number) => [number, number];
|
|
568
|
+
readonly engine_gpu_sdf_program_body: (a: number) => [number, number];
|
|
569
|
+
readonly engine_gpu_sdf_program_result: (a: number) => [number, number];
|
|
570
|
+
readonly engine_gpu_sdf_signals: (a: number) => [number, number];
|
|
571
|
+
readonly engine_has_gpu_sdf: (a: number) => number;
|
|
572
|
+
readonly engine_indices: (a: number) => [number, number];
|
|
573
|
+
readonly engine_is_baked: (a: number) => number;
|
|
574
|
+
readonly engine_lights_flat: (a: number) => [number, number];
|
|
575
|
+
readonly engine_load_scene_wasm: (a: number, b: number, c: number) => [number, number];
|
|
576
|
+
readonly engine_material: (a: number) => [number, number];
|
|
577
|
+
readonly engine_new: () => number;
|
|
578
|
+
readonly engine_normals: (a: number) => [number, number];
|
|
579
|
+
readonly engine_pack_scene_wasm: (a: number, b: number) => [number, number, number, number];
|
|
580
|
+
readonly engine_pending_actions_json: (a: number) => [number, number];
|
|
581
|
+
readonly engine_pick: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
582
|
+
readonly engine_pick_rect: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
|
|
583
|
+
readonly engine_positions: (a: number) => [number, number];
|
|
584
|
+
readonly engine_post: (a: number) => [number, number];
|
|
585
|
+
readonly engine_provide_asset: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
586
|
+
readonly engine_reset_input_state: (a: number) => void;
|
|
587
|
+
readonly engine_reset_scene: (a: number) => [number, number];
|
|
588
|
+
readonly engine_set_document: (a: number, b: number, c: number) => [number, number];
|
|
589
|
+
readonly engine_set_document_bin: (a: number, b: number, c: number) => [number, number];
|
|
590
|
+
readonly engine_set_external_signal_bool: (a: number, b: number, c: number, d: number) => void;
|
|
591
|
+
readonly engine_set_external_signal_float: (a: number, b: number, c: number, d: number) => void;
|
|
592
|
+
readonly engine_set_external_signal_vec3: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
593
|
+
readonly engine_set_key_state: (a: number, b: number, c: number, d: number) => [number, number];
|
|
594
|
+
readonly engine_set_look_spec: (a: number, b: number, c: number) => [number, number];
|
|
595
|
+
readonly engine_set_var_bool: (a: number, b: number, c: number, d: number) => void;
|
|
596
|
+
readonly engine_set_var_color: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
597
|
+
readonly engine_set_var_number: (a: number, b: number, c: number, d: number) => void;
|
|
598
|
+
readonly engine_set_var_vector: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
599
|
+
readonly engine_source_node_ids: (a: number) => [number, number];
|
|
600
|
+
readonly engine_texture_bindings_json: (a: number) => [number, number];
|
|
601
|
+
readonly engine_tick: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => [number, number];
|
|
602
|
+
readonly export_glb: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
|
|
603
|
+
readonly export_obj: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
604
|
+
readonly extract_component: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
|
|
605
|
+
readonly promote_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => [number, number];
|
|
606
|
+
readonly relabel_promoted_input: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number];
|
|
607
|
+
readonly unpromote_input: (a: number, b: number, c: number, d: number) => [number, number];
|
|
608
|
+
readonly upstream_closure: (a: number, b: number, c: number, d: number) => [number, number];
|
|
609
|
+
readonly viewport_create: (a: any) => any;
|
|
610
|
+
readonly viewport_prof: (a: number) => [number, number];
|
|
611
|
+
readonly viewport_render_fila: (a: number, b: number) => [number, number];
|
|
612
|
+
readonly viewport_render_gpu_sdf: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
|
|
613
|
+
readonly viewport_resize: (a: number, b: number, c: number) => void;
|
|
614
|
+
readonly viewport_set_camera: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
615
|
+
readonly viewport_set_camera_projection: (a: number, b: number, c: number, d: number) => [number, number];
|
|
616
|
+
readonly viewport_set_grid: (a: number, b: number, c: number, d: number) => void;
|
|
617
|
+
readonly viewport_set_scene_camera: (a: number, b: number, c: number) => void;
|
|
618
|
+
readonly viewport_set_selection_mesh: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
619
|
+
readonly viewport_set_selection_outline: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
620
|
+
readonly start: () => void;
|
|
621
|
+
readonly wasm_bindgen__convert__closures_____invoke__h70a5e17d363fcdff: (a: number, b: number, c: any) => [number, number];
|
|
622
|
+
readonly wasm_bindgen__convert__closures_____invoke__h1ef02cf0d1d48747: (a: number, b: number, c: any, d: any) => void;
|
|
623
|
+
readonly wasm_bindgen__convert__closures_____invoke__hc9b514610e2ea6ee: (a: number, b: number, c: any) => void;
|
|
624
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
625
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
626
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
627
|
+
readonly __externref_table_alloc: () => number;
|
|
628
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
629
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
630
|
+
readonly __wbindgen_destroy_closure: (a: number, b: number) => void;
|
|
631
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
632
|
+
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
633
|
+
readonly __wbindgen_start: () => void;
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
640
|
+
* a precompiled `WebAssembly.Module`.
|
|
641
|
+
*
|
|
642
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
643
|
+
*
|
|
644
|
+
* @returns {InitOutput}
|
|
645
|
+
*/
|
|
646
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
650
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
651
|
+
*
|
|
652
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
653
|
+
*
|
|
654
|
+
* @returns {Promise<InitOutput>}
|
|
655
|
+
*/
|
|
656
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|