@galfus/transport-browser 0.31.0-alpha → 0.31.1-alpha

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.
@@ -0,0 +1,1805 @@
1
+ /* Automatically generated by Galfus Engine codegen. Do not edit directly. */
2
+ /* Browser/WASM public API contract for the wasm-bindgen GalfusBrowser module. */
3
+
4
+ import type {
5
+ AnimationEvent,
6
+ AnimationTarget,
7
+ AnimValue,
8
+ BufferDesc,
9
+ Camera2DDesc,
10
+ Camera3DDesc,
11
+ CameraLookAt3D,
12
+ CameraLookAt3DStateDesc,
13
+ EnvironmentRealm3DDesc,
14
+ GalfusEngine,
15
+ GamepadInfo,
16
+ GpuTextureDesc,
17
+ InstancedModel3DDesc,
18
+ InvocationDesc,
19
+ InvocationFilter,
20
+ Light2DDesc,
21
+ Light3DDesc,
22
+ Material2DDesc,
23
+ Material3DDesc,
24
+ Model3DDesc,
25
+ MultiverseSchedule,
26
+ ParticleEmitter2DDesc,
27
+ ParticleEmitter3DDesc,
28
+ PathCommand,
29
+ PathFollowConfig,
30
+ PathFollowState,
31
+ PlatformCapabilities,
32
+ PlatformEvent,
33
+ Portal3DDesc,
34
+ Shadow2DConfigDesc,
35
+ Shape2DDesc,
36
+ SpatialAudio,
37
+ Sprite2DDesc,
38
+ Svg2DDesc,
39
+ SvgElementRectResult,
40
+ SvgTextLayoutResult,
41
+ TargetDesc,
42
+ TargetTextureBinding,
43
+ TextureUpdateDesc,
44
+ Transform2D,
45
+ Transform2DDesc,
46
+ Transform3D,
47
+ Transform3DDesc,
48
+ TransitionConfig,
49
+ TransitionState,
50
+ ViewportRect,
51
+ WindowConfig
52
+ } from '@galfus/transport-types';
53
+ export type {
54
+ AnimValue,
55
+ AnimationEvent,
56
+ AnimationTarget,
57
+ BufferDesc,
58
+ Camera2DDesc,
59
+ Camera3DDesc,
60
+ CameraLookAt3D,
61
+ CameraLookAt3DStateDesc,
62
+ EnvironmentRealm3DDesc,
63
+ GalfusEngine,
64
+ GamepadInfo,
65
+ GpuTextureDesc,
66
+ InstancedModel3DDesc,
67
+ InvocationDesc,
68
+ InvocationFilter,
69
+ Light2DDesc,
70
+ Light3DDesc,
71
+ Material2DDesc,
72
+ Material3DDesc,
73
+ Model3DDesc,
74
+ MultiverseSchedule,
75
+ ParticleEmitter2DDesc,
76
+ ParticleEmitter3DDesc,
77
+ PathCommand,
78
+ PathFollowConfig,
79
+ PathFollowState,
80
+ PlatformCapabilities,
81
+ PlatformEvent,
82
+ Portal3DDesc,
83
+ Shadow2DConfigDesc,
84
+ Shape2DDesc,
85
+ SpatialAudio,
86
+ SpatialAudioConfig,
87
+ SpatialTransform,
88
+ Sprite2DDesc,
89
+ Svg2DDesc,
90
+ SvgElementRectResult,
91
+ SvgTextLayoutResult,
92
+ TargetDesc,
93
+ TargetTextureBinding,
94
+ TextureUpdateDesc,
95
+ Transform2D,
96
+ Transform2DDesc,
97
+ Transform3D,
98
+ Transform3DDesc,
99
+ TransitionConfig,
100
+ TransitionState,
101
+ ViewportRect,
102
+ WindowConfig
103
+ } from '@galfus/transport-types';
104
+ import { WasmAudio } from './audio';
105
+
106
+ /** Shape of the JavaScript module generated by wasm-bindgen with --target web. */
107
+ export interface GalfusBrowserWasmModule {
108
+ default(input?: unknown): Promise<unknown>;
109
+ [exportName: string]: unknown;
110
+ }
111
+
112
+ /** Error raised when the loaded WASM module lacks an engine method. */
113
+ export class GalfusError extends Error {
114
+ constructor(message: string) {
115
+ super(message);
116
+ this.name = 'GalfusError';
117
+ }
118
+ }
119
+
120
+ /** Full engine API (platform, multiverse, realms, animation) backed by the WASM module. */
121
+ export class GalfusBrowser implements GalfusEngine {
122
+ private _addon: any;
123
+ private _audio: WasmAudio;
124
+
125
+ constructor(module: unknown) {
126
+ this._addon = module;
127
+ this._audio = new WasmAudio();
128
+ }
129
+
130
+ /** Browser/WASM methods report failures by throwing JavaScript errors. */
131
+ getLastError(): string {
132
+ return '';
133
+ }
134
+
135
+ /** Unlocks Web Audio after a user gesture. */
136
+ enableAudio(): Promise<void> {
137
+ return this._audio.enable();
138
+ }
139
+
140
+ /** Loads raw audio data into the browser Web Audio backend. */
141
+ audioLoadSound(soundId: number, data: any, _dataLen: number): void {
142
+ this._audio.load(soundId, data);
143
+ }
144
+
145
+ /** Plays a loaded sound through Web Audio. */
146
+ audioPlaySound(
147
+ soundId: number,
148
+ volume: number,
149
+ panning: number,
150
+ speed: number,
151
+ looping: boolean
152
+ ): number {
153
+ return this._audio.play(soundId, volume, panning, speed, looping);
154
+ }
155
+
156
+ /** Plays a loaded sound with browser spatial attenuation and panning. */
157
+ audioPlaySoundSpatial(soundId: number, spatial: SpatialAudio): number {
158
+ return this._audio.playSpatial(soundId, spatial);
159
+ }
160
+
161
+ /** Updates a browser spatial voice. */
162
+ audioUpdateSoundSpatial(voiceId: number, spatial: SpatialAudio): void {
163
+ this._audio.updateSpatial(voiceId, spatial);
164
+ }
165
+
166
+ /** Pauses a browser voice. */
167
+ audioPauseSound(voiceId: number): void {
168
+ this._audio.pause(voiceId);
169
+ }
170
+ /** Resumes a browser voice. */
171
+ audioResumeSound(voiceId: number): void {
172
+ this._audio.resume(voiceId);
173
+ }
174
+ /** Stops a browser voice. */
175
+ audioStopSound(voiceId: number): void {
176
+ this._audio.stop(voiceId);
177
+ }
178
+ /** Updates a browser voice volume. */
179
+ audioSetVolume(voiceId: number, volume: number): void {
180
+ this._audio.setVolume(voiceId, volume);
181
+ }
182
+ /** Updates a browser voice panning. */
183
+ audioSetPanning(voiceId: number, panning: number): void {
184
+ this._audio.setPanning(voiceId, panning);
185
+ }
186
+ /** Unloads a browser sound and stops its voices. */
187
+ audioUnloadSound(soundId: number): void {
188
+ this._audio.unload(soundId);
189
+ }
190
+
191
+ /** Initializes the global platform coordinator. */
192
+ platformInit(): void {
193
+ if (typeof this._addon.platformInit !== 'function') {
194
+ throw new GalfusError('WASM method not implemented: platformInit');
195
+ }
196
+ this._addon.platformInit();
197
+ }
198
+
199
+ /** Initializes the global platform coordinator in headless mode. */
200
+ platformInitHeadless(): void {
201
+ if (typeof this._addon.platformInitHeadless !== 'function') {
202
+ throw new GalfusError('WASM method not implemented: platformInitHeadless');
203
+ }
204
+ this._addon.platformInitHeadless();
205
+ }
206
+
207
+ /** Shuts down and cleans up the platform coordinator. */
208
+ platformShutdown(): void {
209
+ if (typeof this._addon.platformShutdown !== 'function') {
210
+ throw new GalfusError('WASM method not implemented: platformShutdown');
211
+ }
212
+ this._addon.platformShutdown();
213
+ }
214
+
215
+ /** Retrieves platform environment capabilities as structured data. */
216
+ platformGetCapabilities(): PlatformCapabilities {
217
+ if (typeof this._addon.platformGetCapabilities !== 'function') {
218
+ throw new GalfusError('WASM method not implemented: platformGetCapabilities');
219
+ }
220
+ return this._addon.platformGetCapabilities();
221
+ }
222
+
223
+ /** Creates a new window or binds a surface from a configuration. */
224
+ windowCreate(config: WindowConfig | string): number {
225
+ if (typeof this._addon.windowCreate !== 'function') {
226
+ throw new GalfusError('WASM method not implemented: windowCreate');
227
+ }
228
+ return this._addon.windowCreate(typeof config === 'string' ? JSON.parse(config) : config);
229
+ }
230
+
231
+ /** Closes and destroys a window by its logical ID. */
232
+ windowClose(windowId: number): void {
233
+ if (typeof this._addon.windowClose !== 'function') {
234
+ throw new GalfusError('WASM method not implemented: windowClose');
235
+ }
236
+ this._addon.windowClose(windowId);
237
+ }
238
+
239
+ /** Updates the title bar of a window. */
240
+ windowSetTitle(windowId: number, title: string): void {
241
+ if (typeof this._addon.windowSetTitle !== 'function') {
242
+ throw new GalfusError('WASM method not implemented: windowSetTitle');
243
+ }
244
+ this._addon.windowSetTitle(windowId, title);
245
+ }
246
+
247
+ /** Requests keyboard focus for a window input surface. */
248
+ windowRequestInputFocus(windowId: number): void {
249
+ if (typeof this._addon.windowRequestInputFocus !== 'function') {
250
+ throw new GalfusError('WASM method not implemented: windowRequestInputFocus');
251
+ }
252
+ this._addon.windowRequestInputFocus(windowId);
253
+ }
254
+
255
+ /** Configures whether a focused browser window captures Tab key navigation. */
256
+ windowSetTabCapture(windowId: number, enabled: number): void {
257
+ if (typeof this._addon.windowSetTabCapture !== 'function') {
258
+ throw new GalfusError('WASM method not implemented: windowSetTabCapture');
259
+ }
260
+ this._addon.windowSetTabCapture(windowId, enabled);
261
+ }
262
+
263
+ /** Enables or disables input method composition for a window. */
264
+ windowSetImeAllowed(windowId: number, allowed: number): void {
265
+ if (typeof this._addon.windowSetImeAllowed !== 'function') {
266
+ throw new GalfusError('WASM method not implemented: windowSetImeAllowed');
267
+ }
268
+ this._addon.windowSetImeAllowed(windowId, allowed);
269
+ }
270
+
271
+ /** Sets the input method candidate area in physical window pixels. */
272
+ windowSetImeCursorArea(
273
+ windowId: number,
274
+ x: number,
275
+ y: number,
276
+ width: number,
277
+ height: number
278
+ ): void {
279
+ if (typeof this._addon.windowSetImeCursorArea !== 'function') {
280
+ throw new GalfusError('WASM method not implemented: windowSetImeCursorArea');
281
+ }
282
+ this._addon.windowSetImeCursorArea(windowId, x, y, width, height);
283
+ }
284
+
285
+ /** Updates the cursor grab mode (0: None, 1: Confined, 2: Locked). */
286
+ windowSetCursorGrab(windowId: number, mode: number): void {
287
+ if (typeof this._addon.windowSetCursorGrab !== 'function') {
288
+ throw new GalfusError('WASM method not implemented: windowSetCursorGrab');
289
+ }
290
+ this._addon.windowSetCursorGrab(windowId, mode);
291
+ }
292
+
293
+ /** Updates the visual appearance icon of the cursor. */
294
+ windowSetCursorIcon(windowId: number, icon: number): void {
295
+ if (typeof this._addon.windowSetCursorIcon !== 'function') {
296
+ throw new GalfusError('WASM method not implemented: windowSetCursorIcon');
297
+ }
298
+ this._addon.windowSetCursorIcon(windowId, icon);
299
+ }
300
+
301
+ /** Sets the visual application icon of a window using raw encoded image bytes (ICO, PNG, WebP, JPEG). */
302
+ windowSetIcon(windowId: number, data: any, dataLen: number): void {
303
+ if (typeof this._addon.windowSetIcon !== 'function') {
304
+ throw new GalfusError('WASM method not implemented: windowSetIcon');
305
+ }
306
+ this._addon.windowSetIcon(windowId, data, dataLen);
307
+ }
308
+
309
+ /** Pumps platform input events into a fixed-layout batch; its pointers expire on release or shutdown. */
310
+ platformPumpEvents(): PlatformEvent[] {
311
+ if (typeof this._addon.platformPumpEvents !== 'function') {
312
+ throw new GalfusError('WASM method not implemented: platformPumpEvents');
313
+ }
314
+ return this._addon.platformPumpEvents();
315
+ }
316
+
317
+ /** Releases an event batch and invalidates its native pointer ranges. */
318
+ platformReleaseEventBatch(batchId: number): void {
319
+ if (typeof this._addon.platformReleaseEventBatch !== 'function') {
320
+ throw new GalfusError('WASM method not implemented: platformReleaseEventBatch');
321
+ }
322
+ this._addon.platformReleaseEventBatch(batchId);
323
+ }
324
+
325
+ /** Retrieves all currently connected gamepads and their capabilities. */
326
+ gamepadGetConnected(): GamepadInfo[] {
327
+ if (typeof this._addon.gamepadGetConnected !== 'function') {
328
+ throw new GalfusError('WASM method not implemented: gamepadGetConnected');
329
+ }
330
+ return this._addon.gamepadGetConnected();
331
+ }
332
+
333
+ /** Triggers rumble vibration on a connected gamepad. */
334
+ gamepadSetRumble(
335
+ gamepadId: number,
336
+ strongMagnitude: number,
337
+ weakMagnitude: number,
338
+ durationMs: number
339
+ ): void {
340
+ if (typeof this._addon.gamepadSetRumble !== 'function') {
341
+ throw new GalfusError('WASM method not implemented: gamepadSetRumble');
342
+ }
343
+ this._addon.gamepadSetRumble(gamepadId, strongMagnitude, weakMagnitude, durationMs);
344
+ }
345
+
346
+ /** Reads the physical inner size (width, height) of a Platform window into two uint32 out pointers. */
347
+ platformGetWindowSizeRaw(windowId: number, outWidth: any, outHeight: any): void {
348
+ if (typeof this._addon.platformGetWindowSizeRaw !== 'function') {
349
+ throw new GalfusError('WASM method not implemented: platformGetWindowSizeRaw');
350
+ }
351
+ this._addon.platformGetWindowSizeRaw(windowId, outWidth, outHeight);
352
+ }
353
+
354
+ /** Attaches a platform window to the Multiverse context for surface rendering. */
355
+ async multiverseAttachWindow(windowId: number): Promise<void> {
356
+ if (typeof this._addon.multiverseAttachWindow !== 'function') {
357
+ throw new GalfusError('WASM method not implemented: multiverseAttachWindow');
358
+ }
359
+ await this._addon.multiverseAttachWindow(windowId);
360
+ }
361
+
362
+ /** Registers a new Target in the Multiverse using a TargetDesc descriptor. */
363
+ multiverseCreateTarget(targetId: number, desc: TargetDesc | string): void {
364
+ if (typeof this._addon.multiverseCreateTarget !== 'function') {
365
+ throw new GalfusError('WASM method not implemented: multiverseCreateTarget');
366
+ }
367
+ this._addon.multiverseCreateTarget(
368
+ targetId,
369
+ typeof desc === 'string' ? JSON.parse(desc) : desc
370
+ );
371
+ }
372
+
373
+ /** Destroys a Target in the Multiverse. */
374
+ multiverseDestroyTarget(targetId: number): void {
375
+ if (typeof this._addon.multiverseDestroyTarget !== 'function') {
376
+ throw new GalfusError('WASM method not implemented: multiverseDestroyTarget');
377
+ }
378
+ this._addon.multiverseDestroyTarget(targetId);
379
+ }
380
+
381
+ /** Registers a solid color test Realm in the Multiverse. */
382
+ multiverseRegisterColorRealm(realmId: number, r: number, g: number, b: number, a: number): void {
383
+ if (typeof this._addon.multiverseRegisterColorRealm !== 'function') {
384
+ throw new GalfusError('WASM method not implemented: multiverseRegisterColorRealm');
385
+ }
386
+ this._addon.multiverseRegisterColorRealm(realmId, r, g, b, a);
387
+ }
388
+
389
+ /** Unregisters a Realm from the Multiverse. */
390
+ multiverseUnregisterRealm(realmId: number): void {
391
+ if (typeof this._addon.multiverseUnregisterRealm !== 'function') {
392
+ throw new GalfusError('WASM method not implemented: multiverseUnregisterRealm');
393
+ }
394
+ this._addon.multiverseUnregisterRealm(realmId);
395
+ }
396
+
397
+ /** Registers a custom WGSL post-processing shader with an ID. */
398
+ multiverseRegisterShader(shaderId: number, source: string): void {
399
+ if (typeof this._addon.multiverseRegisterShader !== 'function') {
400
+ throw new GalfusError('WASM method not implemented: multiverseRegisterShader');
401
+ }
402
+ this._addon.multiverseRegisterShader(shaderId, source);
403
+ }
404
+
405
+ /** Creates an Invocation in the Multiverse linking a Realm to a Target. */
406
+ multiverseCreateInvocation(invocationId: number, desc: InvocationDesc | string): void {
407
+ if (typeof this._addon.multiverseCreateInvocation !== 'function') {
408
+ throw new GalfusError('WASM method not implemented: multiverseCreateInvocation');
409
+ }
410
+ this._addon.multiverseCreateInvocation(
411
+ invocationId,
412
+ typeof desc === 'string' ? JSON.parse(desc) : desc
413
+ );
414
+ }
415
+
416
+ /** Destroys an Invocation in the Multiverse. */
417
+ multiverseDestroyInvocation(invocationId: number): void {
418
+ if (typeof this._addon.multiverseDestroyInvocation !== 'function') {
419
+ throw new GalfusError('WASM method not implemented: multiverseDestroyInvocation');
420
+ }
421
+ this._addon.multiverseDestroyInvocation(invocationId);
422
+ }
423
+
424
+ /** Enables or disables an Invocation in the Multiverse. */
425
+ multiverseSetInvocationEnabled(invocationId: number, enabled: boolean): void {
426
+ if (typeof this._addon.multiverseSetInvocationEnabled !== 'function') {
427
+ throw new GalfusError('WASM method not implemented: multiverseSetInvocationEnabled');
428
+ }
429
+ this._addon.multiverseSetInvocationEnabled(invocationId, enabled);
430
+ }
431
+
432
+ /** Updates the presentation order of an Invocation. */
433
+ multiverseSetInvocationZIndex(invocationId: number, zIndex: number): void {
434
+ if (typeof this._addon.multiverseSetInvocationZIndex !== 'function') {
435
+ throw new GalfusError('WASM method not implemented: multiverseSetInvocationZIndex');
436
+ }
437
+ this._addon.multiverseSetInvocationZIndex(invocationId, zIndex);
438
+ }
439
+
440
+ /** Updates the viewport rectangle of an existing Invocation. */
441
+ multiverseSetInvocationViewport(invocationId: number, viewport: ViewportRect | string): void {
442
+ if (typeof this._addon.multiverseSetInvocationViewport !== 'function') {
443
+ throw new GalfusError('WASM method not implemented: multiverseSetInvocationViewport');
444
+ }
445
+ this._addon.multiverseSetInvocationViewport(
446
+ invocationId,
447
+ typeof viewport === 'string' ? JSON.parse(viewport) : viewport
448
+ );
449
+ }
450
+
451
+ /** Updates the post-process filter chain for an Invocation. */
452
+ multiverseSetInvocationFilters(invocationId: number, filters: InvocationFilter[] | string): void {
453
+ if (typeof this._addon.multiverseSetInvocationFilters !== 'function') {
454
+ throw new GalfusError('WASM method not implemented: multiverseSetInvocationFilters');
455
+ }
456
+ this._addon.multiverseSetInvocationFilters(
457
+ invocationId,
458
+ typeof filters === 'string' ? JSON.parse(filters) : filters
459
+ );
460
+ }
461
+
462
+ /** Updates the clear color of an Invocation. */
463
+ multiverseSetInvocationClearColor(
464
+ invocationId: number,
465
+ r: number,
466
+ g: number,
467
+ b: number,
468
+ a: number,
469
+ hasClear: boolean
470
+ ): void {
471
+ if (typeof this._addon.multiverseSetInvocationClearColor !== 'function') {
472
+ throw new GalfusError('WASM method not implemented: multiverseSetInvocationClearColor');
473
+ }
474
+ this._addon.multiverseSetInvocationClearColor(invocationId, r, g, b, a, hasClear);
475
+ }
476
+
477
+ /** Updates the camera slot bound to an existing Invocation. */
478
+ multiverseSetInvocationCameraSlot(
479
+ invocationId: number,
480
+ cameraSlot: number,
481
+ hasSlot: boolean
482
+ ): void {
483
+ if (typeof this._addon.multiverseSetInvocationCameraSlot !== 'function') {
484
+ throw new GalfusError('WASM method not implemented: multiverseSetInvocationCameraSlot');
485
+ }
486
+ this._addon.multiverseSetInvocationCameraSlot(invocationId, cameraSlot, hasSlot);
487
+ }
488
+
489
+ /** Binds a Target output texture to a Realm input slot. */
490
+ multiverseBindTargetTexture(binding: TargetTextureBinding | string): void {
491
+ if (typeof this._addon.multiverseBindTargetTexture !== 'function') {
492
+ throw new GalfusError('WASM method not implemented: multiverseBindTargetTexture');
493
+ }
494
+ this._addon.multiverseBindTargetTexture(
495
+ typeof binding === 'string' ? JSON.parse(binding) : binding
496
+ );
497
+ }
498
+
499
+ /** Unbinds a Target texture from a Realm input slot. */
500
+ multiverseUnbindTargetTexture(realmId: number, slot: string): void {
501
+ if (typeof this._addon.multiverseUnbindTargetTexture !== 'function') {
502
+ throw new GalfusError('WASM method not implemented: multiverseUnbindTargetTexture');
503
+ }
504
+ this._addon.multiverseUnbindTargetTexture(realmId, slot);
505
+ }
506
+
507
+ /** Updates the size of a window Target (e.g. on window resize). */
508
+ multiverseUpdateWindowSize(windowId: number, width: number, height: number): void {
509
+ if (typeof this._addon.multiverseUpdateWindowSize !== 'function') {
510
+ throw new GalfusError('WASM method not implemented: multiverseUpdateWindowSize');
511
+ }
512
+ this._addon.multiverseUpdateWindowSize(windowId, width, height);
513
+ }
514
+
515
+ /** Resolves and returns the Multiverse execution schedule as structured data. */
516
+ multiverseResolve(): MultiverseSchedule {
517
+ if (typeof this._addon.multiverseResolve !== 'function') {
518
+ throw new GalfusError('WASM method not implemented: multiverseResolve');
519
+ }
520
+ return this._addon.multiverseResolve();
521
+ }
522
+
523
+ /** Dispatches the Multiverse schedule for a frame. */
524
+ multiverseDispatch(frameId: number, deltaTime: number): void {
525
+ if (typeof this._addon.multiverseDispatch !== 'function') {
526
+ throw new GalfusError('WASM method not implemented: multiverseDispatch');
527
+ }
528
+ this._addon.multiverseDispatch(frameId, deltaTime);
529
+ }
530
+
531
+ /** Clears all entities, materials, and scene resources in a Realm without unregistering it. */
532
+ realmClear(realmId: number): void {
533
+ if (typeof this._addon.realmClear !== 'function') {
534
+ throw new GalfusError('WASM method not implemented: realmClear');
535
+ }
536
+ this._addon.realmClear(realmId);
537
+ }
538
+
539
+ /** Destroys a Realm, frees all internal GPU resources, and unregisters it from the Multiverse. */
540
+ realmDestroy(realmId: number): void {
541
+ if (typeof this._addon.realmDestroy !== 'function') {
542
+ throw new GalfusError('WASM method not implemented: realmDestroy');
543
+ }
544
+ this._addon.realmDestroy(realmId);
545
+ }
546
+
547
+ /** Reads the resolved size (width, height) of a Multiverse Target into two uint32 out pointers. */
548
+ multiverseGetTargetSizeRaw(targetId: number, outWidth: any, outHeight: any): void {
549
+ if (typeof this._addon.multiverseGetTargetSizeRaw !== 'function') {
550
+ throw new GalfusError('WASM method not implemented: multiverseGetTargetSizeRaw');
551
+ }
552
+ this._addon.multiverseGetTargetSizeRaw(targetId, outWidth, outHeight);
553
+ }
554
+
555
+ /** Sets the global Anti-Aliasing mode for the Multiverse. */
556
+ multiverseSetAntiAliasing(mode: string): void {
557
+ if (typeof this._addon.multiverseSetAntiAliasing !== 'function') {
558
+ throw new GalfusError('WASM method not implemented: multiverseSetAntiAliasing');
559
+ }
560
+ this._addon.multiverseSetAntiAliasing(mode);
561
+ }
562
+
563
+ /** Gets the current global Anti-Aliasing mode of the Multiverse. */
564
+ multiverseGetAntiAliasing(): string {
565
+ if (typeof this._addon.multiverseGetAntiAliasing !== 'function') {
566
+ throw new GalfusError('WASM method not implemented: multiverseGetAntiAliasing');
567
+ }
568
+ return this._addon.multiverseGetAntiAliasing();
569
+ }
570
+
571
+ /** Allocates and initializes a shared GPU texture under a host logical ID with raw pixel bytes. */
572
+ resourceCreateTexture(
573
+ textureId: number,
574
+ desc: GpuTextureDesc | string,
575
+ data: any,
576
+ dataLen: number
577
+ ): void {
578
+ if (typeof this._addon.resourceCreateTexture !== 'function') {
579
+ throw new GalfusError('WASM method not implemented: resourceCreateTexture');
580
+ }
581
+ this._addon.resourceCreateTexture(
582
+ textureId,
583
+ typeof desc === 'string' ? JSON.parse(desc) : desc,
584
+ data,
585
+ dataLen
586
+ );
587
+ }
588
+
589
+ /** Updates a sub-rectangle of an existing logical texture with raw pixel bytes. */
590
+ resourceUpdateTexture(
591
+ textureId: number,
592
+ rect: TextureUpdateDesc | string,
593
+ data: any,
594
+ dataLen: number
595
+ ): void {
596
+ if (typeof this._addon.resourceUpdateTexture !== 'function') {
597
+ throw new GalfusError('WASM method not implemented: resourceUpdateTexture');
598
+ }
599
+ this._addon.resourceUpdateTexture(
600
+ textureId,
601
+ typeof rect === 'string' ? JSON.parse(rect) : rect,
602
+ data,
603
+ dataLen
604
+ );
605
+ }
606
+
607
+ /** Disposes a shared logical texture from GPU memory. */
608
+ resourceDisposeTexture(textureId: number): void {
609
+ if (typeof this._addon.resourceDisposeTexture !== 'function') {
610
+ throw new GalfusError('WASM method not implemented: resourceDisposeTexture');
611
+ }
612
+ this._addon.resourceDisposeTexture(textureId);
613
+ }
614
+
615
+ /** Allocates and initializes a shared GPU buffer under a host logical ID with raw byte contents. */
616
+ resourceCreateBuffer(
617
+ bufferId: number,
618
+ desc: BufferDesc | string,
619
+ data: any,
620
+ dataLen: number
621
+ ): void {
622
+ if (typeof this._addon.resourceCreateBuffer !== 'function') {
623
+ throw new GalfusError('WASM method not implemented: resourceCreateBuffer');
624
+ }
625
+ this._addon.resourceCreateBuffer(
626
+ bufferId,
627
+ typeof desc === 'string' ? JSON.parse(desc) : desc,
628
+ data,
629
+ dataLen
630
+ );
631
+ }
632
+
633
+ /** Updates byte contents of an existing logical buffer at a given offset with raw byte contents. */
634
+ resourceUpdateBuffer(bufferId: number, offset: number, data: any, dataLen: number): void {
635
+ if (typeof this._addon.resourceUpdateBuffer !== 'function') {
636
+ throw new GalfusError('WASM method not implemented: resourceUpdateBuffer');
637
+ }
638
+ this._addon.resourceUpdateBuffer(bufferId, offset, data, dataLen);
639
+ }
640
+
641
+ /** Disposes a shared logical buffer from GPU memory. */
642
+ resourceDisposeBuffer(bufferId: number): void {
643
+ if (typeof this._addon.resourceDisposeBuffer !== 'function') {
644
+ throw new GalfusError('WASM method not implemented: resourceDisposeBuffer');
645
+ }
646
+ this._addon.resourceDisposeBuffer(bufferId);
647
+ }
648
+
649
+ /** Creates and registers a new 3D Realm in the Multiverse. */
650
+ realm3dCreate(realmId: number): void {
651
+ if (typeof this._addon.realm3dCreate !== 'function') {
652
+ throw new GalfusError('WASM method not implemented: realm3dCreate');
653
+ }
654
+ this._addon.realm3dCreate(realmId);
655
+ }
656
+
657
+ /** Destroys and unregisters a 3D Realm from the Multiverse. */
658
+ realm3dDestroy(realmId: number): void {
659
+ if (typeof this._addon.realm3dDestroy !== 'function') {
660
+ throw new GalfusError('WASM method not implemented: realm3dDestroy');
661
+ }
662
+ this._addon.realm3dDestroy(realmId);
663
+ }
664
+
665
+ /** Registers or updates a 3D Camera with its spatial Transform in the 3D Realm. */
666
+ realm3dCreateCamera(
667
+ realmId: number,
668
+ cameraId: number,
669
+ camera: Camera3DDesc | string,
670
+ transform: Transform3DDesc | string
671
+ ): void {
672
+ if (typeof this._addon.realm3dCreateCamera !== 'function') {
673
+ throw new GalfusError('WASM method not implemented: realm3dCreateCamera');
674
+ }
675
+ this._addon.realm3dCreateCamera(
676
+ realmId,
677
+ cameraId,
678
+ typeof camera === 'string' ? JSON.parse(camera) : camera,
679
+ typeof transform === 'string' ? JSON.parse(transform) : transform
680
+ );
681
+ }
682
+
683
+ /** Updates the transform of an existing Camera in the 3D Realm. */
684
+ realm3dSetCameraTransform(realmId: number, cameraId: number, transform: Transform3D): void {
685
+ if (typeof this._addon.realm3dSetCameraTransform !== 'function') {
686
+ throw new GalfusError('WASM method not implemented: realm3dSetCameraTransform');
687
+ }
688
+ this._addon.realm3dSetCameraTransform(realmId, cameraId, transform);
689
+ }
690
+
691
+ /** Sets the optional world-space look-at point and up direction of an existing 3D Camera. */
692
+ realm3dSetCameraLookAt(realmId: number, cameraId: number, lookAt: CameraLookAt3D): void {
693
+ if (typeof this._addon.realm3dSetCameraLookAt !== 'function') {
694
+ throw new GalfusError('WASM method not implemented: realm3dSetCameraLookAt');
695
+ }
696
+ this._addon.realm3dSetCameraLookAt(realmId, cameraId, lookAt);
697
+ }
698
+
699
+ /** Gets the current optional look-at configuration of an existing 3D Camera. */
700
+ realm3dGetCameraLookAt(realmId: number, cameraId: number): CameraLookAt3DStateDesc {
701
+ if (typeof this._addon.realm3dGetCameraLookAt !== 'function') {
702
+ throw new GalfusError('WASM method not implemented: realm3dGetCameraLookAt');
703
+ }
704
+ return this._addon.realm3dGetCameraLookAt(realmId, cameraId);
705
+ }
706
+
707
+ /** Clears the optional look-at configuration of an existing 3D Camera. */
708
+ realm3dClearCameraLookAt(realmId: number, cameraId: number): void {
709
+ if (typeof this._addon.realm3dClearCameraLookAt !== 'function') {
710
+ throw new GalfusError('WASM method not implemented: realm3dClearCameraLookAt');
711
+ }
712
+ this._addon.realm3dClearCameraLookAt(realmId, cameraId);
713
+ }
714
+
715
+ /** Registers or updates 3D geometry from canonical binary vertex and index buffers. */
716
+ realm3dCreateGeometry(
717
+ realmId: number,
718
+ geometryId: number,
719
+ topology: number,
720
+ vertexData: Uint8Array,
721
+ vertexDataLen: number,
722
+ indices: Uint32Array,
723
+ indexCount: number
724
+ ): void {
725
+ if (typeof this._addon.realm3dCreateGeometry !== 'function') {
726
+ throw new GalfusError('WASM method not implemented: realm3dCreateGeometry');
727
+ }
728
+ this._addon.realm3dCreateGeometry(
729
+ realmId,
730
+ geometryId,
731
+ topology,
732
+ vertexData,
733
+ vertexDataLen,
734
+ indices,
735
+ indexCount
736
+ );
737
+ }
738
+
739
+ /** Uploads target-major packed MorphVertex3D records (48 bytes each) for an existing geometry. */
740
+ realm3dSetGeometryMorphTargets(
741
+ realmId: number,
742
+ geometryId: number,
743
+ targetData: Uint8Array,
744
+ targetDataLen: number,
745
+ targetCount: number
746
+ ): void {
747
+ if (typeof this._addon.realm3dSetGeometryMorphTargets !== 'function') {
748
+ throw new GalfusError('WASM method not implemented: realm3dSetGeometryMorphTargets');
749
+ }
750
+ this._addon.realm3dSetGeometryMorphTargets(
751
+ realmId,
752
+ geometryId,
753
+ targetData,
754
+ targetDataLen,
755
+ targetCount
756
+ );
757
+ }
758
+
759
+ /** Creates a cube primitive centered at the origin. */
760
+ realm3dCreateCube(realmId: number, geometryId: number, size: number): void {
761
+ if (typeof this._addon.realm3dCreateCube !== 'function') {
762
+ throw new GalfusError('WASM method not implemented: realm3dCreateCube');
763
+ }
764
+ this._addon.realm3dCreateCube(realmId, geometryId, size);
765
+ }
766
+
767
+ /** Creates a horizontal plane primitive centered at the origin. */
768
+ realm3dCreatePlane(realmId: number, geometryId: number, width: number, depth: number): void {
769
+ if (typeof this._addon.realm3dCreatePlane !== 'function') {
770
+ throw new GalfusError('WASM method not implemented: realm3dCreatePlane');
771
+ }
772
+ this._addon.realm3dCreatePlane(realmId, geometryId, width, depth);
773
+ }
774
+
775
+ /** Creates a vertical quad primitive centered at the origin and facing +Z. */
776
+ realm3dCreateQuad(realmId: number, geometryId: number, width: number, height: number): void {
777
+ if (typeof this._addon.realm3dCreateQuad !== 'function') {
778
+ throw new GalfusError('WASM method not implemented: realm3dCreateQuad');
779
+ }
780
+ this._addon.realm3dCreateQuad(realmId, geometryId, width, height);
781
+ }
782
+
783
+ /** Creates a UV sphere primitive centered at the origin. */
784
+ realm3dCreateSphere(
785
+ realmId: number,
786
+ geometryId: number,
787
+ radius: number,
788
+ rings: number,
789
+ sectors: number
790
+ ): void {
791
+ if (typeof this._addon.realm3dCreateSphere !== 'function') {
792
+ throw new GalfusError('WASM method not implemented: realm3dCreateSphere');
793
+ }
794
+ this._addon.realm3dCreateSphere(realmId, geometryId, radius, rings, sectors);
795
+ }
796
+
797
+ /** Creates a cylinder primitive centered at the origin along the Y axis. */
798
+ realm3dCreateCylinder(
799
+ realmId: number,
800
+ geometryId: number,
801
+ radius: number,
802
+ height: number,
803
+ sectors: number
804
+ ): void {
805
+ if (typeof this._addon.realm3dCreateCylinder !== 'function') {
806
+ throw new GalfusError('WASM method not implemented: realm3dCreateCylinder');
807
+ }
808
+ this._addon.realm3dCreateCylinder(realmId, geometryId, radius, height, sectors);
809
+ }
810
+
811
+ /** Creates a capsule primitive centered at the origin along the Y axis. */
812
+ realm3dCreateCapsule(
813
+ realmId: number,
814
+ geometryId: number,
815
+ radius: number,
816
+ cylinderHeight: number,
817
+ rings: number,
818
+ sectors: number
819
+ ): void {
820
+ if (typeof this._addon.realm3dCreateCapsule !== 'function') {
821
+ throw new GalfusError('WASM method not implemented: realm3dCreateCapsule');
822
+ }
823
+ this._addon.realm3dCreateCapsule(realmId, geometryId, radius, cylinderHeight, rings, sectors);
824
+ }
825
+
826
+ /** Creates a pyramid primitive centered at the origin with its apex on +Y. */
827
+ realm3dCreatePyramid(
828
+ realmId: number,
829
+ geometryId: number,
830
+ width: number,
831
+ depth: number,
832
+ height: number
833
+ ): void {
834
+ if (typeof this._addon.realm3dCreatePyramid !== 'function') {
835
+ throw new GalfusError('WASM method not implemented: realm3dCreatePyramid');
836
+ }
837
+ this._addon.realm3dCreatePyramid(realmId, geometryId, width, depth, height);
838
+ }
839
+
840
+ /** Creates a torus primitive centered at the origin in the XZ plane. */
841
+ realm3dCreateTorus(
842
+ realmId: number,
843
+ geometryId: number,
844
+ majorRadius: number,
845
+ minorRadius: number,
846
+ majorSegments: number,
847
+ minorSegments: number
848
+ ): void {
849
+ if (typeof this._addon.realm3dCreateTorus !== 'function') {
850
+ throw new GalfusError('WASM method not implemented: realm3dCreateTorus');
851
+ }
852
+ this._addon.realm3dCreateTorus(
853
+ realmId,
854
+ geometryId,
855
+ majorRadius,
856
+ minorRadius,
857
+ majorSegments,
858
+ minorSegments
859
+ );
860
+ }
861
+
862
+ /** Registers or updates a 3D Material in the 3D Realm. */
863
+ realm3dCreateMaterial(
864
+ realmId: number,
865
+ materialId: number,
866
+ material: Material3DDesc | string
867
+ ): void {
868
+ if (typeof this._addon.realm3dCreateMaterial !== 'function') {
869
+ throw new GalfusError('WASM method not implemented: realm3dCreateMaterial');
870
+ }
871
+ this._addon.realm3dCreateMaterial(
872
+ realmId,
873
+ materialId,
874
+ typeof material === 'string' ? JSON.parse(material) : material
875
+ );
876
+ }
877
+
878
+ /** Registers or updates a 3D Model instance in the 3D Realm. */
879
+ realm3dCreateModel(
880
+ realmId: number,
881
+ modelId: number,
882
+ model: Model3DDesc | string,
883
+ transform: Transform3DDesc | string
884
+ ): void {
885
+ if (typeof this._addon.realm3dCreateModel !== 'function') {
886
+ throw new GalfusError('WASM method not implemented: realm3dCreateModel');
887
+ }
888
+ this._addon.realm3dCreateModel(
889
+ realmId,
890
+ modelId,
891
+ typeof model === 'string' ? JSON.parse(model) : model,
892
+ typeof transform === 'string' ? JSON.parse(transform) : transform
893
+ );
894
+ }
895
+
896
+ /** Updates the transform of an existing Model instance in the 3D Realm. */
897
+ realm3dSetModelTransform(realmId: number, modelId: number, transform: Transform3D): void {
898
+ if (typeof this._addon.realm3dSetModelTransform !== 'function') {
899
+ throw new GalfusError('WASM method not implemented: realm3dSetModelTransform');
900
+ }
901
+ this._addon.realm3dSetModelTransform(realmId, modelId, transform);
902
+ }
903
+
904
+ /** Registers or updates an Instanced 3D Model in the 3D Realm. */
905
+ realm3dCreateInstancedModel(
906
+ realmId: number,
907
+ instancedModelId: number,
908
+ model: InstancedModel3DDesc | string
909
+ ): void {
910
+ if (typeof this._addon.realm3dCreateInstancedModel !== 'function') {
911
+ throw new GalfusError('WASM method not implemented: realm3dCreateInstancedModel');
912
+ }
913
+ this._addon.realm3dCreateInstancedModel(
914
+ realmId,
915
+ instancedModelId,
916
+ typeof model === 'string' ? JSON.parse(model) : model
917
+ );
918
+ }
919
+
920
+ /** Uploads packed instance data: 32 f32 values per instance. */
921
+ realm3dSetInstancedModelData(
922
+ realmId: number,
923
+ instancedModelId: number,
924
+ data: Float32Array,
925
+ floatCount: number
926
+ ): void {
927
+ if (typeof this._addon.realm3dSetInstancedModelData !== 'function') {
928
+ throw new GalfusError('WASM method not implemented: realm3dSetInstancedModelData');
929
+ }
930
+ this._addon.realm3dSetInstancedModelData(realmId, instancedModelId, data, floatCount);
931
+ }
932
+
933
+ /** Uploads the current f32 blend weights for an existing model. */
934
+ realm3dSetModelMorphWeights(
935
+ realmId: number,
936
+ modelId: number,
937
+ weights: Float32Array,
938
+ weightCount: number
939
+ ): void {
940
+ if (typeof this._addon.realm3dSetModelMorphWeights !== 'function') {
941
+ throw new GalfusError('WASM method not implemented: realm3dSetModelMorphWeights');
942
+ }
943
+ this._addon.realm3dSetModelMorphWeights(realmId, modelId, weights, weightCount);
944
+ }
945
+
946
+ /** Uploads the f32 blend weights shared by every instance in an instanced model batch. */
947
+ realm3dSetInstancedModelMorphWeights(
948
+ realmId: number,
949
+ instancedModelId: number,
950
+ weights: Float32Array,
951
+ weightCount: number
952
+ ): void {
953
+ if (typeof this._addon.realm3dSetInstancedModelMorphWeights !== 'function') {
954
+ throw new GalfusError('WASM method not implemented: realm3dSetInstancedModelMorphWeights');
955
+ }
956
+ this._addon.realm3dSetInstancedModelMorphWeights(
957
+ realmId,
958
+ instancedModelId,
959
+ weights,
960
+ weightCount
961
+ );
962
+ }
963
+
964
+ /** Registers or updates a 3D Light in the 3D Realm. */
965
+ realm3dCreateLight(
966
+ realmId: number,
967
+ lightId: number,
968
+ light: Light3DDesc | string,
969
+ transform: Transform3DDesc | string
970
+ ): void {
971
+ if (typeof this._addon.realm3dCreateLight !== 'function') {
972
+ throw new GalfusError('WASM method not implemented: realm3dCreateLight');
973
+ }
974
+ this._addon.realm3dCreateLight(
975
+ realmId,
976
+ lightId,
977
+ typeof light === 'string' ? JSON.parse(light) : light,
978
+ typeof transform === 'string' ? JSON.parse(transform) : transform
979
+ );
980
+ }
981
+
982
+ /** Updates the transform of an existing Light in the 3D Realm. */
983
+ realm3dSetLightTransform(realmId: number, lightId: number, transform: Transform3D): void {
984
+ if (typeof this._addon.realm3dSetLightTransform !== 'function') {
985
+ throw new GalfusError('WASM method not implemented: realm3dSetLightTransform');
986
+ }
987
+ this._addon.realm3dSetLightTransform(realmId, lightId, transform);
988
+ }
989
+
990
+ /** Sets global atmospheric environment properties for the 3D Realm. */
991
+ realm3dSetEnvironment(realmId: number, environment: EnvironmentRealm3DDesc | string): void {
992
+ if (typeof this._addon.realm3dSetEnvironment !== 'function') {
993
+ throw new GalfusError('WASM method not implemented: realm3dSetEnvironment');
994
+ }
995
+ this._addon.realm3dSetEnvironment(
996
+ realmId,
997
+ typeof environment === 'string' ? JSON.parse(environment) : environment
998
+ );
999
+ }
1000
+
1001
+ /** Uploads packed 4x4 bone matrices for a model in the 3D Realm. */
1002
+ realm3dUpdateBones(
1003
+ realmId: number,
1004
+ modelId: number,
1005
+ data: Float32Array,
1006
+ floatCount: number
1007
+ ): void {
1008
+ if (typeof this._addon.realm3dUpdateBones !== 'function') {
1009
+ throw new GalfusError('WASM method not implemented: realm3dUpdateBones');
1010
+ }
1011
+ this._addon.realm3dUpdateBones(realmId, modelId, data, floatCount);
1012
+ }
1013
+
1014
+ /** Queues a 3D debug line segment between start and end with an RGBA color. */
1015
+ realm3dDrawLine(
1016
+ realmId: number,
1017
+ x0: number,
1018
+ y0: number,
1019
+ z0: number,
1020
+ x1: number,
1021
+ y1: number,
1022
+ z1: number,
1023
+ r: number,
1024
+ g: number,
1025
+ b: number,
1026
+ a: number
1027
+ ): void {
1028
+ if (typeof this._addon.realm3dDrawLine !== 'function') {
1029
+ throw new GalfusError('WASM method not implemented: realm3dDrawLine');
1030
+ }
1031
+ this._addon.realm3dDrawLine(realmId, x0, y0, z0, x1, y1, z1, r, g, b, a);
1032
+ }
1033
+
1034
+ /** Queues a 3D debug Axis-Aligned Bounding Box (AABB) wireframe. */
1035
+ realm3dDrawAabb(
1036
+ realmId: number,
1037
+ minX: number,
1038
+ minY: number,
1039
+ minZ: number,
1040
+ maxX: number,
1041
+ maxY: number,
1042
+ maxZ: number,
1043
+ r: number,
1044
+ g: number,
1045
+ b: number,
1046
+ a: number
1047
+ ): void {
1048
+ if (typeof this._addon.realm3dDrawAabb !== 'function') {
1049
+ throw new GalfusError('WASM method not implemented: realm3dDrawAabb');
1050
+ }
1051
+ this._addon.realm3dDrawAabb(realmId, minX, minY, minZ, maxX, maxY, maxZ, r, g, b, a);
1052
+ }
1053
+
1054
+ /** Clears any queued debug gizmos in the 3D Realm. */
1055
+ realm3dClearGizmos(realmId: number): void {
1056
+ if (typeof this._addon.realm3dClearGizmos !== 'function') {
1057
+ throw new GalfusError('WASM method not implemented: realm3dClearGizmos');
1058
+ }
1059
+ this._addon.realm3dClearGizmos(realmId);
1060
+ }
1061
+
1062
+ /** Creates or updates a 3D particle emitter entity with an initial transform. */
1063
+ realm3dCreateParticleEmitter(
1064
+ realmId: number,
1065
+ emitterId: number,
1066
+ emitter: ParticleEmitter3DDesc | string,
1067
+ transform: Transform3DDesc | string
1068
+ ): void {
1069
+ if (typeof this._addon.realm3dCreateParticleEmitter !== 'function') {
1070
+ throw new GalfusError('WASM method not implemented: realm3dCreateParticleEmitter');
1071
+ }
1072
+ this._addon.realm3dCreateParticleEmitter(
1073
+ realmId,
1074
+ emitterId,
1075
+ typeof emitter === 'string' ? JSON.parse(emitter) : emitter,
1076
+ typeof transform === 'string' ? JSON.parse(transform) : transform
1077
+ );
1078
+ }
1079
+
1080
+ /** Updates the spatial transform of an existing 3D particle emitter. */
1081
+ realm3dSetParticleEmitterTransform(
1082
+ realmId: number,
1083
+ emitterId: number,
1084
+ transform: Transform3D
1085
+ ): void {
1086
+ if (typeof this._addon.realm3dSetParticleEmitterTransform !== 'function') {
1087
+ throw new GalfusError('WASM method not implemented: realm3dSetParticleEmitterTransform');
1088
+ }
1089
+ this._addon.realm3dSetParticleEmitterTransform(realmId, emitterId, transform);
1090
+ }
1091
+
1092
+ /** Triggers an immediate burst of particles from an existing 3D emitter. */
1093
+ realm3dParticleEmitterBurst(realmId: number, emitterId: number, count: number): void {
1094
+ if (typeof this._addon.realm3dParticleEmitterBurst !== 'function') {
1095
+ throw new GalfusError('WASM method not implemented: realm3dParticleEmitterBurst');
1096
+ }
1097
+ this._addon.realm3dParticleEmitterBurst(realmId, emitterId, count);
1098
+ }
1099
+
1100
+ /** Destroys an existing 3D particle emitter entity. */
1101
+ realm3dDestroyParticleEmitter(realmId: number, emitterId: number): void {
1102
+ if (typeof this._addon.realm3dDestroyParticleEmitter !== 'function') {
1103
+ throw new GalfusError('WASM method not implemented: realm3dDestroyParticleEmitter');
1104
+ }
1105
+ this._addon.realm3dDestroyParticleEmitter(realmId, emitterId);
1106
+ }
1107
+
1108
+ /** Registers or updates a 3D optical portal or planar mirror. */
1109
+ realm3dCreatePortal(realmId: number, portalId: number, portal: Portal3DDesc | string): void {
1110
+ if (typeof this._addon.realm3dCreatePortal !== 'function') {
1111
+ throw new GalfusError('WASM method not implemented: realm3dCreatePortal');
1112
+ }
1113
+ this._addon.realm3dCreatePortal(
1114
+ realmId,
1115
+ portalId,
1116
+ typeof portal === 'string' ? JSON.parse(portal) : portal
1117
+ );
1118
+ }
1119
+
1120
+ /** Sets whether an existing 3D portal or mirror is active. */
1121
+ realm3dSetPortalActive(realmId: number, portalId: number, active: boolean): void {
1122
+ if (typeof this._addon.realm3dSetPortalActive !== 'function') {
1123
+ throw new GalfusError('WASM method not implemented: realm3dSetPortalActive');
1124
+ }
1125
+ this._addon.realm3dSetPortalActive(realmId, portalId, active);
1126
+ }
1127
+
1128
+ /** Destroys an existing 3D portal or mirror. */
1129
+ realm3dDestroyPortal(realmId: number, portalId: number): void {
1130
+ if (typeof this._addon.realm3dDestroyPortal !== 'function') {
1131
+ throw new GalfusError('WASM method not implemented: realm3dDestroyPortal');
1132
+ }
1133
+ this._addon.realm3dDestroyPortal(realmId, portalId);
1134
+ }
1135
+
1136
+ /** Destroys an existing 3D camera entity. */
1137
+ realm3dDestroyCamera(realmId: number, cameraId: number): void {
1138
+ if (typeof this._addon.realm3dDestroyCamera !== 'function') {
1139
+ throw new GalfusError('WASM method not implemented: realm3dDestroyCamera');
1140
+ }
1141
+ this._addon.realm3dDestroyCamera(realmId, cameraId);
1142
+ }
1143
+
1144
+ /** Destroys an existing 3D material entity. */
1145
+ realm3dDestroyMaterial(realmId: number, materialId: number): void {
1146
+ if (typeof this._addon.realm3dDestroyMaterial !== 'function') {
1147
+ throw new GalfusError('WASM method not implemented: realm3dDestroyMaterial');
1148
+ }
1149
+ this._addon.realm3dDestroyMaterial(realmId, materialId);
1150
+ }
1151
+
1152
+ /** Destroys an existing 3D geometry entity. */
1153
+ realm3dDestroyGeometry(realmId: number, geometryId: number): void {
1154
+ if (typeof this._addon.realm3dDestroyGeometry !== 'function') {
1155
+ throw new GalfusError('WASM method not implemented: realm3dDestroyGeometry');
1156
+ }
1157
+ this._addon.realm3dDestroyGeometry(realmId, geometryId);
1158
+ }
1159
+
1160
+ /** Destroys an existing 3D model entity. */
1161
+ realm3dDestroyModel(realmId: number, modelId: number): void {
1162
+ if (typeof this._addon.realm3dDestroyModel !== 'function') {
1163
+ throw new GalfusError('WASM method not implemented: realm3dDestroyModel');
1164
+ }
1165
+ this._addon.realm3dDestroyModel(realmId, modelId);
1166
+ }
1167
+
1168
+ /** Destroys an existing 3D instanced model entity. */
1169
+ realm3dDestroyInstancedModel(realmId: number, instancedModelId: number): void {
1170
+ if (typeof this._addon.realm3dDestroyInstancedModel !== 'function') {
1171
+ throw new GalfusError('WASM method not implemented: realm3dDestroyInstancedModel');
1172
+ }
1173
+ this._addon.realm3dDestroyInstancedModel(realmId, instancedModelId);
1174
+ }
1175
+
1176
+ /** Destroys an existing 3D light entity. */
1177
+ realm3dDestroyLight(realmId: number, lightId: number): void {
1178
+ if (typeof this._addon.realm3dDestroyLight !== 'function') {
1179
+ throw new GalfusError('WASM method not implemented: realm3dDestroyLight');
1180
+ }
1181
+ this._addon.realm3dDestroyLight(realmId, lightId);
1182
+ }
1183
+
1184
+ /** Reads the transform of an existing Model instance. */
1185
+ realm3dGetModelTransform(realmId: number, modelId: number): Transform3D {
1186
+ if (typeof this._addon.realm3dGetModelTransform !== 'function') {
1187
+ throw new GalfusError('WASM method not implemented: realm3dGetModelTransform');
1188
+ }
1189
+ return this._addon.realm3dGetModelTransform(realmId, modelId);
1190
+ }
1191
+
1192
+ /** Reads the transform of an existing Camera instance. */
1193
+ realm3dGetCameraTransform(realmId: number, cameraId: number): Transform3D {
1194
+ if (typeof this._addon.realm3dGetCameraTransform !== 'function') {
1195
+ throw new GalfusError('WASM method not implemented: realm3dGetCameraTransform');
1196
+ }
1197
+ return this._addon.realm3dGetCameraTransform(realmId, cameraId);
1198
+ }
1199
+
1200
+ /** Reads the world-space bounding box (min, max) of a 3D model into two 3-float out buffers. */
1201
+ realm3dGetModelAabbRaw(realmId: number, modelId: number, outMin: any, outMax: any): void {
1202
+ if (typeof this._addon.realm3dGetModelAabbRaw !== 'function') {
1203
+ throw new GalfusError('WASM method not implemented: realm3dGetModelAabbRaw');
1204
+ }
1205
+ this._addon.realm3dGetModelAabbRaw(realmId, modelId, outMin, outMax);
1206
+ }
1207
+
1208
+ /** Creates and registers a new 2D Realm in the Multiverse. */
1209
+ realm2dCreate(realmId: number): void {
1210
+ if (typeof this._addon.realm2dCreate !== 'function') {
1211
+ throw new GalfusError('WASM method not implemented: realm2dCreate');
1212
+ }
1213
+ this._addon.realm2dCreate(realmId);
1214
+ }
1215
+
1216
+ /** Destroys and unregisters a 2D Realm from the Multiverse. */
1217
+ realm2dDestroy(realmId: number): void {
1218
+ if (typeof this._addon.realm2dDestroy !== 'function') {
1219
+ throw new GalfusError('WASM method not implemented: realm2dDestroy');
1220
+ }
1221
+ this._addon.realm2dDestroy(realmId);
1222
+ }
1223
+
1224
+ /** Creates or updates a 2D camera with an initial transform. */
1225
+ realm2dCreateCamera(
1226
+ realmId: number,
1227
+ cameraId: number,
1228
+ camera: Camera2DDesc | string,
1229
+ transform: Transform2DDesc | string
1230
+ ): void {
1231
+ if (typeof this._addon.realm2dCreateCamera !== 'function') {
1232
+ throw new GalfusError('WASM method not implemented: realm2dCreateCamera');
1233
+ }
1234
+ this._addon.realm2dCreateCamera(
1235
+ realmId,
1236
+ cameraId,
1237
+ typeof camera === 'string' ? JSON.parse(camera) : camera,
1238
+ typeof transform === 'string' ? JSON.parse(transform) : transform
1239
+ );
1240
+ }
1241
+
1242
+ /** Updates the spatial transform of an existing 2D camera. */
1243
+ realm2dSetCameraTransform(realmId: number, cameraId: number, transform: Transform2D): void {
1244
+ if (typeof this._addon.realm2dSetCameraTransform !== 'function') {
1245
+ throw new GalfusError('WASM method not implemented: realm2dSetCameraTransform');
1246
+ }
1247
+ this._addon.realm2dSetCameraTransform(realmId, cameraId, transform);
1248
+ }
1249
+
1250
+ /** Creates or updates a 2D material definition. */
1251
+ realm2dCreateMaterial(
1252
+ realmId: number,
1253
+ materialId: number,
1254
+ material: Material2DDesc | string
1255
+ ): void {
1256
+ if (typeof this._addon.realm2dCreateMaterial !== 'function') {
1257
+ throw new GalfusError('WASM method not implemented: realm2dCreateMaterial');
1258
+ }
1259
+ this._addon.realm2dCreateMaterial(
1260
+ realmId,
1261
+ materialId,
1262
+ typeof material === 'string' ? JSON.parse(material) : material
1263
+ );
1264
+ }
1265
+
1266
+ /** Creates or updates a 2D instanced sprite with an initial transform. */
1267
+ realm2dCreateSprite(
1268
+ realmId: number,
1269
+ spriteId: number,
1270
+ sprite: Sprite2DDesc | string,
1271
+ transform: Transform2DDesc | string
1272
+ ): void {
1273
+ if (typeof this._addon.realm2dCreateSprite !== 'function') {
1274
+ throw new GalfusError('WASM method not implemented: realm2dCreateSprite');
1275
+ }
1276
+ this._addon.realm2dCreateSprite(
1277
+ realmId,
1278
+ spriteId,
1279
+ typeof sprite === 'string' ? JSON.parse(sprite) : sprite,
1280
+ typeof transform === 'string' ? JSON.parse(transform) : transform
1281
+ );
1282
+ }
1283
+
1284
+ /** Updates the spatial transform of an existing 2D sprite. */
1285
+ realm2dSetSpriteTransform(realmId: number, spriteId: number, transform: Transform2D): void {
1286
+ if (typeof this._addon.realm2dSetSpriteTransform !== 'function') {
1287
+ throw new GalfusError('WASM method not implemented: realm2dSetSpriteTransform');
1288
+ }
1289
+ this._addon.realm2dSetSpriteTransform(realmId, spriteId, transform);
1290
+ }
1291
+
1292
+ /** Creates or updates a 2D vector shape (Rectangle, Circle, Polygon) with an initial transform. */
1293
+ realm2dCreateShape(
1294
+ realmId: number,
1295
+ shapeId: number,
1296
+ shape: Shape2DDesc | string,
1297
+ transform: Transform2DDesc | string
1298
+ ): void {
1299
+ if (typeof this._addon.realm2dCreateShape !== 'function') {
1300
+ throw new GalfusError('WASM method not implemented: realm2dCreateShape');
1301
+ }
1302
+ this._addon.realm2dCreateShape(
1303
+ realmId,
1304
+ shapeId,
1305
+ typeof shape === 'string' ? JSON.parse(shape) : shape,
1306
+ typeof transform === 'string' ? JSON.parse(transform) : transform
1307
+ );
1308
+ }
1309
+
1310
+ /** Updates the spatial transform of an existing 2D shape. */
1311
+ realm2dSetShapeTransform(realmId: number, shapeId: number, transform: Transform2D): void {
1312
+ if (typeof this._addon.realm2dSetShapeTransform !== 'function') {
1313
+ throw new GalfusError('WASM method not implemented: realm2dSetShapeTransform');
1314
+ }
1315
+ this._addon.realm2dSetShapeTransform(realmId, shapeId, transform);
1316
+ }
1317
+
1318
+ /** Creates or updates a 2D point light with an initial transform. */
1319
+ realm2dCreateLight(
1320
+ realmId: number,
1321
+ lightId: number,
1322
+ light: Light2DDesc | string,
1323
+ transform: Transform2DDesc | string
1324
+ ): void {
1325
+ if (typeof this._addon.realm2dCreateLight !== 'function') {
1326
+ throw new GalfusError('WASM method not implemented: realm2dCreateLight');
1327
+ }
1328
+ this._addon.realm2dCreateLight(
1329
+ realmId,
1330
+ lightId,
1331
+ typeof light === 'string' ? JSON.parse(light) : light,
1332
+ typeof transform === 'string' ? JSON.parse(transform) : transform
1333
+ );
1334
+ }
1335
+
1336
+ /** Updates the spatial transform of an existing 2D light. */
1337
+ realm2dSetLightTransform(realmId: number, lightId: number, transform: Transform2D): void {
1338
+ if (typeof this._addon.realm2dSetLightTransform !== 'function') {
1339
+ throw new GalfusError('WASM method not implemented: realm2dSetLightTransform');
1340
+ }
1341
+ this._addon.realm2dSetLightTransform(realmId, lightId, transform);
1342
+ }
1343
+
1344
+ /** Updates global 2D polar shadow parameters. */
1345
+ realm2dSetShadowConfig(realmId: number, config: Shadow2DConfigDesc | string): void {
1346
+ if (typeof this._addon.realm2dSetShadowConfig !== 'function') {
1347
+ throw new GalfusError('WASM method not implemented: realm2dSetShadowConfig');
1348
+ }
1349
+ this._addon.realm2dSetShadowConfig(
1350
+ realmId,
1351
+ typeof config === 'string' ? JSON.parse(config) : config
1352
+ );
1353
+ }
1354
+
1355
+ /** Creates or updates a 2D particle emitter entity with an initial transform. */
1356
+ realm2dCreateParticleEmitter(
1357
+ realmId: number,
1358
+ emitterId: number,
1359
+ emitter: ParticleEmitter2DDesc | string,
1360
+ transform: Transform2DDesc | string
1361
+ ): void {
1362
+ if (typeof this._addon.realm2dCreateParticleEmitter !== 'function') {
1363
+ throw new GalfusError('WASM method not implemented: realm2dCreateParticleEmitter');
1364
+ }
1365
+ this._addon.realm2dCreateParticleEmitter(
1366
+ realmId,
1367
+ emitterId,
1368
+ typeof emitter === 'string' ? JSON.parse(emitter) : emitter,
1369
+ typeof transform === 'string' ? JSON.parse(transform) : transform
1370
+ );
1371
+ }
1372
+
1373
+ /** Updates the spatial transform of an existing 2D particle emitter. */
1374
+ realm2dSetParticleEmitterTransform(
1375
+ realmId: number,
1376
+ emitterId: number,
1377
+ transform: Transform2D
1378
+ ): void {
1379
+ if (typeof this._addon.realm2dSetParticleEmitterTransform !== 'function') {
1380
+ throw new GalfusError('WASM method not implemented: realm2dSetParticleEmitterTransform');
1381
+ }
1382
+ this._addon.realm2dSetParticleEmitterTransform(realmId, emitterId, transform);
1383
+ }
1384
+
1385
+ /** Triggers an immediate burst of particles from an existing 2D emitter. */
1386
+ realm2dParticleEmitterBurst(realmId: number, emitterId: number, count: number): void {
1387
+ if (typeof this._addon.realm2dParticleEmitterBurst !== 'function') {
1388
+ throw new GalfusError('WASM method not implemented: realm2dParticleEmitterBurst');
1389
+ }
1390
+ this._addon.realm2dParticleEmitterBurst(realmId, emitterId, count);
1391
+ }
1392
+
1393
+ /** Destroys an existing 2D particle emitter entity. */
1394
+ realm2dDestroyParticleEmitter(realmId: number, emitterId: number): void {
1395
+ if (typeof this._addon.realm2dDestroyParticleEmitter !== 'function') {
1396
+ throw new GalfusError('WASM method not implemented: realm2dDestroyParticleEmitter');
1397
+ }
1398
+ this._addon.realm2dDestroyParticleEmitter(realmId, emitterId);
1399
+ }
1400
+
1401
+ /** Destroys an existing 2D camera entity. */
1402
+ realm2dDestroyCamera(realmId: number, cameraId: number): void {
1403
+ if (typeof this._addon.realm2dDestroyCamera !== 'function') {
1404
+ throw new GalfusError('WASM method not implemented: realm2dDestroyCamera');
1405
+ }
1406
+ this._addon.realm2dDestroyCamera(realmId, cameraId);
1407
+ }
1408
+
1409
+ /** Destroys an existing 2D material entity. */
1410
+ realm2dDestroyMaterial(realmId: number, materialId: number): void {
1411
+ if (typeof this._addon.realm2dDestroyMaterial !== 'function') {
1412
+ throw new GalfusError('WASM method not implemented: realm2dDestroyMaterial');
1413
+ }
1414
+ this._addon.realm2dDestroyMaterial(realmId, materialId);
1415
+ }
1416
+
1417
+ /** Destroys an existing 2D sprite entity. */
1418
+ realm2dDestroySprite(realmId: number, spriteId: number): void {
1419
+ if (typeof this._addon.realm2dDestroySprite !== 'function') {
1420
+ throw new GalfusError('WASM method not implemented: realm2dDestroySprite');
1421
+ }
1422
+ this._addon.realm2dDestroySprite(realmId, spriteId);
1423
+ }
1424
+
1425
+ /** Destroys an existing 2D shape entity. */
1426
+ realm2dDestroyShape(realmId: number, shapeId: number): void {
1427
+ if (typeof this._addon.realm2dDestroyShape !== 'function') {
1428
+ throw new GalfusError('WASM method not implemented: realm2dDestroyShape');
1429
+ }
1430
+ this._addon.realm2dDestroyShape(realmId, shapeId);
1431
+ }
1432
+
1433
+ /** Destroys an existing 2D light entity. */
1434
+ realm2dDestroyLight(realmId: number, lightId: number): void {
1435
+ if (typeof this._addon.realm2dDestroyLight !== 'function') {
1436
+ throw new GalfusError('WASM method not implemented: realm2dDestroyLight');
1437
+ }
1438
+ this._addon.realm2dDestroyLight(realmId, lightId);
1439
+ }
1440
+
1441
+ /** Reads the transform of an existing Sprite instance. */
1442
+ realm2dGetSpriteTransform(realmId: number, spriteId: number): Transform2D {
1443
+ if (typeof this._addon.realm2dGetSpriteTransform !== 'function') {
1444
+ throw new GalfusError('WASM method not implemented: realm2dGetSpriteTransform');
1445
+ }
1446
+ return this._addon.realm2dGetSpriteTransform(realmId, spriteId);
1447
+ }
1448
+
1449
+ /** Reads the transform of an existing Camera instance. */
1450
+ realm2dGetCameraTransform(realmId: number, cameraId: number): Transform2D {
1451
+ if (typeof this._addon.realm2dGetCameraTransform !== 'function') {
1452
+ throw new GalfusError('WASM method not implemented: realm2dGetCameraTransform');
1453
+ }
1454
+ return this._addon.realm2dGetCameraTransform(realmId, cameraId);
1455
+ }
1456
+
1457
+ /** Creates or updates a 2D SVG vector entity with an initial transform. */
1458
+ realm2dCreateSvg(
1459
+ realmId: number,
1460
+ svgId: number,
1461
+ svg: Svg2DDesc | string,
1462
+ transform: Transform2DDesc | string
1463
+ ): void {
1464
+ if (typeof this._addon.realm2dCreateSvg !== 'function') {
1465
+ throw new GalfusError('WASM method not implemented: realm2dCreateSvg');
1466
+ }
1467
+ this._addon.realm2dCreateSvg(
1468
+ realmId,
1469
+ svgId,
1470
+ typeof svg === 'string' ? JSON.parse(svg) : svg,
1471
+ typeof transform === 'string' ? JSON.parse(transform) : transform
1472
+ );
1473
+ }
1474
+
1475
+ /** Reads the geometric bounds of an SVG element. */
1476
+ realm2dGetSvgElementRect(
1477
+ realmId: number,
1478
+ svgId: number,
1479
+ elementId: string
1480
+ ): SvgElementRectResult {
1481
+ if (typeof this._addon.realm2dGetSvgElementRect !== 'function') {
1482
+ throw new GalfusError('WASM method not implemented: realm2dGetSvgElementRect');
1483
+ }
1484
+ return this._addon.realm2dGetSvgElementRect(realmId, svgId, elementId);
1485
+ }
1486
+
1487
+ /** Reads the shaped text clusters of an SVG text element. */
1488
+ realm2dGetSvgTextLayout(realmId: number, svgId: number, elementId: string): SvgTextLayoutResult {
1489
+ if (typeof this._addon.realm2dGetSvgTextLayout !== 'function') {
1490
+ throw new GalfusError('WASM method not implemented: realm2dGetSvgTextLayout');
1491
+ }
1492
+ return this._addon.realm2dGetSvgTextLayout(realmId, svgId, elementId);
1493
+ }
1494
+
1495
+ /** Replaces the complete source XML markup string of an existing SVG entity. */
1496
+ realm2dSetSvgSource(realmId: number, svgId: number, source: string): void {
1497
+ if (typeof this._addon.realm2dSetSvgSource !== 'function') {
1498
+ throw new GalfusError('WASM method not implemented: realm2dSetSvgSource');
1499
+ }
1500
+ this._addon.realm2dSetSvgSource(realmId, svgId, source);
1501
+ }
1502
+
1503
+ /** Sets or overwrites an XML attribute on the matching element ID in the SVG. */
1504
+ realm2dSetSvgAttribute(
1505
+ realmId: number,
1506
+ svgId: number,
1507
+ elementId: string,
1508
+ name: string,
1509
+ value: string
1510
+ ): void {
1511
+ if (typeof this._addon.realm2dSetSvgAttribute !== 'function') {
1512
+ throw new GalfusError('WASM method not implemented: realm2dSetSvgAttribute');
1513
+ }
1514
+ this._addon.realm2dSetSvgAttribute(realmId, svgId, elementId, name, value);
1515
+ }
1516
+
1517
+ /** Removes an XML attribute from the matching element ID in the SVG. */
1518
+ realm2dRemoveSvgAttribute(realmId: number, svgId: number, elementId: string, name: string): void {
1519
+ if (typeof this._addon.realm2dRemoveSvgAttribute !== 'function') {
1520
+ throw new GalfusError('WASM method not implemented: realm2dRemoveSvgAttribute');
1521
+ }
1522
+ this._addon.realm2dRemoveSvgAttribute(realmId, svgId, elementId, name);
1523
+ }
1524
+
1525
+ /** Updates the inner text content of the matching element ID in the SVG. */
1526
+ realm2dSetSvgText(realmId: number, svgId: number, elementId: string, text: string): void {
1527
+ if (typeof this._addon.realm2dSetSvgText !== 'function') {
1528
+ throw new GalfusError('WASM method not implemented: realm2dSetSvgText');
1529
+ }
1530
+ this._addon.realm2dSetSvgText(realmId, svgId, elementId, text);
1531
+ }
1532
+
1533
+ /** Updates the spatial transform of an existing SVG entity. */
1534
+ realm2dSetSvgTransform(realmId: number, svgId: number, transform: Transform2D): void {
1535
+ if (typeof this._addon.realm2dSetSvgTransform !== 'function') {
1536
+ throw new GalfusError('WASM method not implemented: realm2dSetSvgTransform');
1537
+ }
1538
+ this._addon.realm2dSetSvgTransform(realmId, svgId, transform);
1539
+ }
1540
+
1541
+ /** Reads the transform of an existing SVG entity. */
1542
+ realm2dGetSvgTransform(realmId: number, svgId: number): Transform2D {
1543
+ if (typeof this._addon.realm2dGetSvgTransform !== 'function') {
1544
+ throw new GalfusError('WASM method not implemented: realm2dGetSvgTransform');
1545
+ }
1546
+ return this._addon.realm2dGetSvgTransform(realmId, svgId);
1547
+ }
1548
+
1549
+ /** Destroys an existing 2D SVG entity. */
1550
+ realm2dDestroySvg(realmId: number, svgId: number): void {
1551
+ if (typeof this._addon.realm2dDestroySvg !== 'function') {
1552
+ throw new GalfusError('WASM method not implemented: realm2dDestroySvg');
1553
+ }
1554
+ this._addon.realm2dDestroySvg(realmId, svgId);
1555
+ }
1556
+
1557
+ /** Registers raw TTF/OTF font binary data from memory (zero filesystem access). Returns the detected font family name. */
1558
+ realm2dLoadFontData(realmId: number, data: any, dataLen: number): string {
1559
+ if (typeof this._addon.realm2dLoadFontData !== 'function') {
1560
+ throw new GalfusError('WASM method not implemented: realm2dLoadFontData');
1561
+ }
1562
+ return this._addon.realm2dLoadFontData(realmId, data, dataLen);
1563
+ }
1564
+
1565
+ /** Creates a new property transition with an initial value and timing configuration. */
1566
+ animationCreateTransition(
1567
+ transitionId: number,
1568
+ initialValue: AnimValue | string,
1569
+ config?: TransitionConfig | string
1570
+ ): void {
1571
+ if (typeof this._addon.animationCreateTransition !== 'function') {
1572
+ throw new GalfusError('WASM method not implemented: animationCreateTransition');
1573
+ }
1574
+ this._addon.animationCreateTransition(
1575
+ transitionId,
1576
+ typeof initialValue === 'string' ? JSON.parse(initialValue) : initialValue,
1577
+ typeof config === 'string' ? JSON.parse(config) : config
1578
+ );
1579
+ }
1580
+
1581
+ /** Binds an existing transition to a realm entity or multiverse property target. */
1582
+ animationBindTarget(transitionId: number, target: AnimationTarget | string): void {
1583
+ if (typeof this._addon.animationBindTarget !== 'function') {
1584
+ throw new GalfusError('WASM method not implemented: animationBindTarget');
1585
+ }
1586
+ this._addon.animationBindTarget(
1587
+ transitionId,
1588
+ typeof target === 'string' ? JSON.parse(target) : target
1589
+ );
1590
+ }
1591
+
1592
+ /** Unbinds a target from a transition and releases its property lock. */
1593
+ animationUnbindTarget(transitionId: number): void {
1594
+ if (typeof this._addon.animationUnbindTarget !== 'function') {
1595
+ throw new GalfusError('WASM method not implemented: animationUnbindTarget');
1596
+ }
1597
+ this._addon.animationUnbindTarget(transitionId);
1598
+ }
1599
+
1600
+ /** Triggers a smooth transition from the live value towards a new target value. */
1601
+ animationTransitionTo(
1602
+ transitionId: number,
1603
+ targetValue: AnimValue | string,
1604
+ config?: TransitionConfig | string
1605
+ ): void {
1606
+ if (typeof this._addon.animationTransitionTo !== 'function') {
1607
+ throw new GalfusError('WASM method not implemented: animationTransitionTo');
1608
+ }
1609
+ this._addon.animationTransitionTo(
1610
+ transitionId,
1611
+ typeof targetValue === 'string' ? JSON.parse(targetValue) : targetValue,
1612
+ typeof config === 'string' ? JSON.parse(config) : config
1613
+ );
1614
+ }
1615
+
1616
+ /** Fast-path helper creating a scalar transition. */
1617
+ animationCreateScalarTransition(
1618
+ transitionId: number,
1619
+ initialScalar: number,
1620
+ duration: number,
1621
+ delay: number,
1622
+ easingId: number
1623
+ ): void {
1624
+ if (typeof this._addon.animationCreateScalarTransition !== 'function') {
1625
+ throw new GalfusError('WASM method not implemented: animationCreateScalarTransition');
1626
+ }
1627
+ this._addon.animationCreateScalarTransition(
1628
+ transitionId,
1629
+ initialScalar,
1630
+ duration,
1631
+ delay,
1632
+ easingId
1633
+ );
1634
+ }
1635
+
1636
+ /** Fast-path helper smoothly transitioning a scalar property. */
1637
+ animationTransitionToScalar(
1638
+ transitionId: number,
1639
+ targetScalar: number,
1640
+ duration: number,
1641
+ delay: number,
1642
+ easingId: number
1643
+ ): void {
1644
+ if (typeof this._addon.animationTransitionToScalar !== 'function') {
1645
+ throw new GalfusError('WASM method not implemented: animationTransitionToScalar');
1646
+ }
1647
+ this._addon.animationTransitionToScalar(transitionId, targetScalar, duration, delay, easingId);
1648
+ }
1649
+
1650
+ /** Fast-path transitioning a 3D Transform from 10 raw floats (pos, quat, scale). */
1651
+ animationTransitionToTransform3d(
1652
+ transitionId: number,
1653
+ floats: any,
1654
+ duration: number,
1655
+ delay: number,
1656
+ easingId: number
1657
+ ): void {
1658
+ if (typeof this._addon.animationTransitionToTransform3d !== 'function') {
1659
+ throw new GalfusError('WASM method not implemented: animationTransitionToTransform3d');
1660
+ }
1661
+ this._addon.animationTransitionToTransform3d(transitionId, floats, duration, delay, easingId);
1662
+ }
1663
+
1664
+ /** Fast-path transitioning a 2D Transform from 6 raw floats (pos, rot, scale, z_layer). */
1665
+ animationTransitionToTransform2d(
1666
+ transitionId: number,
1667
+ floats: any,
1668
+ duration: number,
1669
+ delay: number,
1670
+ easingId: number
1671
+ ): void {
1672
+ if (typeof this._addon.animationTransitionToTransform2d !== 'function') {
1673
+ throw new GalfusError('WASM method not implemented: animationTransitionToTransform2d');
1674
+ }
1675
+ this._addon.animationTransitionToTransform2d(transitionId, floats, duration, delay, easingId);
1676
+ }
1677
+
1678
+ /** Queries the current playback status and progress of a transition. */
1679
+ animationGetState(transitionId: number): TransitionState {
1680
+ if (typeof this._addon.animationGetState !== 'function') {
1681
+ throw new GalfusError('WASM method not implemented: animationGetState');
1682
+ }
1683
+ return this._addon.animationGetState(transitionId);
1684
+ }
1685
+
1686
+ /** Queries the current evaluated value of a transition. */
1687
+ animationGetValue(transitionId: number): AnimValue {
1688
+ if (typeof this._addon.animationGetValue !== 'function') {
1689
+ throw new GalfusError('WASM method not implemented: animationGetValue');
1690
+ }
1691
+ return this._addon.animationGetValue(transitionId);
1692
+ }
1693
+
1694
+ /** Destroys an animation transition by ID. */
1695
+ animationDestroyTransition(transitionId: number): void {
1696
+ if (typeof this._addon.animationDestroyTransition !== 'function') {
1697
+ throw new GalfusError('WASM method not implemented: animationDestroyTransition');
1698
+ }
1699
+ this._addon.animationDestroyTransition(transitionId);
1700
+ }
1701
+
1702
+ /** Advances all active animation transitions by dt seconds and applies updates to Multiverse. */
1703
+ animationStep(dt: number): void {
1704
+ if (typeof this._addon.animationStep !== 'function') {
1705
+ throw new GalfusError('WASM method not implemented: animationStep');
1706
+ }
1707
+ this._addon.animationStep(dt);
1708
+ }
1709
+
1710
+ /** Drains and returns all queued animation lifecycle events. */
1711
+ animationPumpEvents(): AnimationEvent[] {
1712
+ if (typeof this._addon.animationPumpEvents !== 'function') {
1713
+ throw new GalfusError('WASM method not implemented: animationPumpEvents');
1714
+ }
1715
+ return this._addon.animationPumpEvents();
1716
+ }
1717
+
1718
+ /** Writes directly to a custom animation channel. */
1719
+ animationSetCustomChannel(channelId: number, value: AnimValue | string): void {
1720
+ if (typeof this._addon.animationSetCustomChannel !== 'function') {
1721
+ throw new GalfusError('WASM method not implemented: animationSetCustomChannel');
1722
+ }
1723
+ this._addon.animationSetCustomChannel(
1724
+ channelId,
1725
+ typeof value === 'string' ? JSON.parse(value) : value
1726
+ );
1727
+ }
1728
+
1729
+ /** Reads directly from a custom animation channel. */
1730
+ animationGetCustomChannel(channelId: number): AnimValue {
1731
+ if (typeof this._addon.animationGetCustomChannel !== 'function') {
1732
+ throw new GalfusError('WASM method not implemented: animationGetCustomChannel');
1733
+ }
1734
+ return this._addon.animationGetCustomChannel(channelId);
1735
+ }
1736
+
1737
+ /** Creates a new path follower traversing a declarative SVG-like path. */
1738
+ animationCreatePathFollow(
1739
+ pathId: number,
1740
+ commands: PathCommand[] | string,
1741
+ config?: PathFollowConfig | string
1742
+ ): void {
1743
+ if (typeof this._addon.animationCreatePathFollow !== 'function') {
1744
+ throw new GalfusError('WASM method not implemented: animationCreatePathFollow');
1745
+ }
1746
+ this._addon.animationCreatePathFollow(
1747
+ pathId,
1748
+ typeof commands === 'string' ? JSON.parse(commands) : commands,
1749
+ typeof config === 'string' ? JSON.parse(config) : config
1750
+ );
1751
+ }
1752
+
1753
+ /** Binds a path follower to an entity property target with conflict locking. */
1754
+ animationBindPathFollowTarget(pathId: number, target: AnimationTarget | string): void {
1755
+ if (typeof this._addon.animationBindPathFollowTarget !== 'function') {
1756
+ throw new GalfusError('WASM method not implemented: animationBindPathFollowTarget');
1757
+ }
1758
+ this._addon.animationBindPathFollowTarget(
1759
+ pathId,
1760
+ typeof target === 'string' ? JSON.parse(target) : target
1761
+ );
1762
+ }
1763
+
1764
+ /** Unbinds a target from a path follower and releases its property lock. */
1765
+ animationUnbindPathFollowTarget(pathId: number): void {
1766
+ if (typeof this._addon.animationUnbindPathFollowTarget !== 'function') {
1767
+ throw new GalfusError('WASM method not implemented: animationUnbindPathFollowTarget');
1768
+ }
1769
+ this._addon.animationUnbindPathFollowTarget(pathId);
1770
+ }
1771
+
1772
+ /** Destroys a path follower by ID. */
1773
+ animationDestroyPathFollow(pathId: number): void {
1774
+ if (typeof this._addon.animationDestroyPathFollow !== 'function') {
1775
+ throw new GalfusError('WASM method not implemented: animationDestroyPathFollow');
1776
+ }
1777
+ this._addon.animationDestroyPathFollow(pathId);
1778
+ }
1779
+
1780
+ /** Queries the current playback status and progress of a path follower. */
1781
+ animationGetPathFollowState(pathId: number): PathFollowState {
1782
+ if (typeof this._addon.animationGetPathFollowState !== 'function') {
1783
+ throw new GalfusError('WASM method not implemented: animationGetPathFollowState');
1784
+ }
1785
+ return this._addon.animationGetPathFollowState(pathId);
1786
+ }
1787
+
1788
+ /** Reads the inner physical size [width, height] of a Platform window. */
1789
+ windowGetSize(windowId: number): [number, number] {
1790
+ return this._addon.windowGetSize(windowId);
1791
+ }
1792
+
1793
+ /** Reads the inner physical size [width, height] of a Platform window (alias for windowGetSize). */
1794
+ platformGetWindowSize(windowId: number): [number, number] {
1795
+ return this.windowGetSize(windowId);
1796
+ }
1797
+ }
1798
+
1799
+ /** Initializes the WASM module and returns the full browser engine API. */
1800
+ export async function initializeGalfusBrowser(
1801
+ module: GalfusBrowserWasmModule
1802
+ ): Promise<GalfusBrowser> {
1803
+ await module.default();
1804
+ return new GalfusBrowser(module);
1805
+ }