@vulfram/engine 0.14.8-alpha → 0.17.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.
Files changed (54) hide show
  1. package/README.md +106 -0
  2. package/package.json +55 -4
  3. package/src/core.ts +14 -0
  4. package/src/ecs.ts +1 -0
  5. package/src/engine/api.ts +234 -23
  6. package/src/engine/bridge/dispatch.ts +265 -40
  7. package/src/engine/bridge/guards.ts +4 -1
  8. package/src/engine/bridge/protocol.ts +69 -52
  9. package/src/engine/ecs/index.ts +185 -42
  10. package/src/engine/state.ts +133 -2
  11. package/src/engine/systems/command-intent.ts +153 -3
  12. package/src/engine/systems/constraint-solve.ts +167 -0
  13. package/src/engine/systems/core-command-builder.ts +9 -268
  14. package/src/engine/systems/diagnostics.ts +20 -19
  15. package/src/engine/systems/index.ts +3 -1
  16. package/src/engine/systems/input-mirror.ts +101 -3
  17. package/src/engine/systems/resource-upload.ts +96 -44
  18. package/src/engine/systems/response-decode.ts +69 -15
  19. package/src/engine/systems/scene-sync.ts +306 -0
  20. package/src/engine/systems/ui-bridge.ts +360 -0
  21. package/src/engine/systems/utils.ts +43 -1
  22. package/src/engine/systems/world-lifecycle.ts +37 -102
  23. package/src/engine/window/manager.ts +168 -0
  24. package/src/engine/world/entities.ts +821 -78
  25. package/src/engine/world/mount.ts +174 -0
  26. package/src/engine/world/types.ts +71 -0
  27. package/src/engine/world/world-ui.ts +266 -0
  28. package/src/engine/world/world3d.ts +280 -0
  29. package/src/index.ts +30 -1
  30. package/src/mount.ts +2 -0
  31. package/src/types/cmds/audio.ts +73 -48
  32. package/src/types/cmds/camera.ts +12 -8
  33. package/src/types/cmds/environment.ts +9 -3
  34. package/src/types/cmds/geometry.ts +13 -14
  35. package/src/types/cmds/index.ts +198 -168
  36. package/src/types/cmds/light.ts +12 -11
  37. package/src/types/cmds/material.ts +9 -11
  38. package/src/types/cmds/model.ts +17 -15
  39. package/src/types/cmds/realm.ts +25 -0
  40. package/src/types/cmds/system.ts +19 -0
  41. package/src/types/cmds/target.ts +82 -0
  42. package/src/types/cmds/texture.ts +13 -3
  43. package/src/types/cmds/ui.ts +220 -0
  44. package/src/types/cmds/window.ts +41 -204
  45. package/src/types/events/index.ts +4 -1
  46. package/src/types/events/pointer.ts +42 -13
  47. package/src/types/events/system.ts +144 -30
  48. package/src/types/events/ui.ts +21 -0
  49. package/src/types/index.ts +1 -0
  50. package/src/types/json.ts +15 -0
  51. package/src/window.ts +8 -0
  52. package/src/world-ui.ts +2 -0
  53. package/src/world3d.ts +10 -0
  54. package/tsconfig.json +0 -29
@@ -1,130 +1,157 @@
1
- import * as Sys from './system';
2
- import * as Win from './window';
1
+ import * as Audio from './audio';
3
2
  import * as Cam from './camera';
4
- import * as Mod from './model';
3
+ import * as Env from './environment';
4
+ import * as Geo from './geometry';
5
+ import * as Giz from './gizmo';
5
6
  import * as Lite from './light';
6
7
  import * as Mat from './material';
8
+ import * as Mod from './model';
9
+ import * as Realm from './realm';
10
+ import * as Sys from './system';
11
+ import * as Target from './target';
7
12
  import * as Tex from './texture';
8
- import * as Geo from './geometry';
9
- import * as Shad from './shadow';
10
- import * as Giz from './gizmo';
11
- import * as Env from './environment';
12
- import * as Audio from './audio';
13
- import * as RenderGraph from './render-graph';
13
+ import * as Ui from './ui';
14
+ import * as Win from './window';
14
15
 
15
- export * from './system';
16
- export * from './window';
16
+ export * from './audio';
17
17
  export * from './camera';
18
- export * from './model';
19
- export * from './light';
20
- export * from './material';
21
- export * from './texture';
18
+ export * from './environment';
22
19
  export * from './geometry';
23
- export * from './shadow';
24
20
  export * from './gizmo';
25
- export * from './environment';
26
- export * from './audio';
21
+ export * from './light';
22
+ export * from './material';
23
+ export * from './model';
24
+ export * from './realm';
27
25
  export * from './render-graph';
28
26
  export * from './resources';
27
+ export * from './shadow';
28
+ export * from './system';
29
+ export * from './target';
30
+ export * from './texture';
31
+ export * from './ui';
32
+ export * from './window';
29
33
 
30
- /** Discriminated union of all core commands. */
34
+ /**
35
+ * Discriminated union of all commands accepted by core.
36
+ *
37
+ * Routing convention:
38
+ * - world-scoped commands are dispatched through the world command queue
39
+ * - global commands are dispatched through the global command queue
40
+ */
31
41
  export type EngineCmd =
32
42
  | { type: 'cmd-notification-send'; content: Sys.CmdNotificationSendArgs }
33
43
  | {
34
- type: 'cmd-upload-buffer-discard-all';
35
- content: Sys.CmdUploadBufferDiscardAllArgs;
44
+ type: 'cmd-system-diagnostics-set';
45
+ content: Sys.CmdSystemDiagnosticsSetArgs;
36
46
  }
37
47
  | { type: 'cmd-window-create'; content: Win.CmdWindowCreateArgs }
38
48
  | { type: 'cmd-window-close'; content: Win.CmdWindowCloseArgs }
39
- | { type: 'cmd-window-set-title'; content: Win.CmdWindowSetTitleArgs }
40
- | { type: 'cmd-window-set-position'; content: Win.CmdWindowSetPositionArgs }
41
- | { type: 'cmd-window-get-position'; content: Win.CmdWindowGetPositionArgs }
42
- | { type: 'cmd-window-set-size'; content: Win.CmdWindowSetSizeArgs }
43
- | { type: 'cmd-window-get-size'; content: Win.CmdWindowGetSizeArgs }
49
+ | { type: 'cmd-window-measurement'; content: Win.CmdWindowMeasurementArgs }
50
+ | { type: 'cmd-window-cursor'; content: Win.CmdWindowCursorArgs }
51
+ | { type: 'cmd-window-state'; content: Win.CmdWindowStateArgs }
44
52
  | {
45
- type: 'cmd-window-get-outer-size';
46
- content: Win.CmdWindowGetOuterSizeArgs;
53
+ type: 'cmd-upload-buffer-discard-all';
54
+ content: Sys.CmdUploadBufferDiscardAllArgs;
47
55
  }
56
+ | { type: 'cmd-camera-upsert'; content: Cam.CmdCameraUpsertArgs }
57
+ | { type: 'cmd-camera-dispose'; content: Cam.CmdCameraDisposeArgs }
58
+ | { type: 'cmd-model-upsert'; content: Mod.CmdModelUpsertArgs }
59
+ | { type: 'cmd-pose-update'; content: Mod.CmdPoseUpdateArgs }
60
+ | { type: 'cmd-model-dispose'; content: Mod.CmdModelDisposeArgs }
61
+ | { type: 'cmd-light-upsert'; content: Lite.CmdLightUpsertArgs }
62
+ | { type: 'cmd-light-dispose'; content: Lite.CmdLightDisposeArgs }
63
+ | { type: 'cmd-material-upsert'; content: Mat.CmdMaterialUpsertArgs }
64
+ | { type: 'cmd-material-dispose'; content: Mat.CmdMaterialDisposeArgs }
48
65
  | {
49
- type: 'cmd-window-get-surface-size';
50
- content: Win.CmdWindowGetSurfaceSizeArgs;
66
+ type: 'cmd-texture-create-from-buffer';
67
+ content: Tex.CmdTextureCreateFromBufferArgs;
51
68
  }
52
- | { type: 'cmd-window-set-state'; content: Win.CmdWindowSetStateArgs }
53
- | { type: 'cmd-window-get-state'; content: Win.CmdWindowGetStateArgs }
54
- | { type: 'cmd-window-set-icon'; content: Win.CmdWindowSetIconArgs }
55
69
  | {
56
- type: 'cmd-window-set-decorations';
57
- content: Win.CmdWindowSetDecorationsArgs;
70
+ type: 'cmd-texture-create-solid-color';
71
+ content: Tex.CmdTextureCreateSolidColorArgs;
58
72
  }
73
+ | { type: 'cmd-texture-dispose'; content: Tex.CmdTextureDisposeArgs }
74
+ | { type: 'cmd-texture-bind-target'; content: Tex.CmdTextureBindTargetArgs }
59
75
  | {
60
- type: 'cmd-window-has-decorations';
61
- content: Win.CmdWindowHasDecorationsArgs;
76
+ type: 'cmd-audio-listener-upsert';
77
+ content: Audio.CmdAudioListenerUpsertArgs;
62
78
  }
63
- | { type: 'cmd-window-set-resizable'; content: Win.CmdWindowSetResizableArgs }
64
- | { type: 'cmd-window-is-resizable'; content: Win.CmdWindowIsResizableArgs }
65
79
  | {
66
- type: 'cmd-window-request-attention';
67
- content: Win.CmdWindowRequestAttentionArgs;
80
+ type: 'cmd-audio-listener-dispose';
81
+ content: Audio.CmdAudioListenerDisposeArgs;
68
82
  }
69
- | { type: 'cmd-window-focus'; content: Win.CmdWindowFocusArgs }
70
83
  | {
71
- type: 'cmd-window-set-cursor-visible';
72
- content: Win.CmdWindowSetCursorVisibleArgs;
84
+ type: 'cmd-audio-source-upsert';
85
+ content: Audio.CmdAudioSourceUpsertArgs;
73
86
  }
74
87
  | {
75
- type: 'cmd-window-set-cursor-grab';
76
- content: Win.CmdWindowSetCursorGrabArgs;
88
+ type: 'cmd-audio-resource-upsert';
89
+ content: Audio.CmdAudioResourceUpsertArgs;
77
90
  }
78
91
  | {
79
- type: 'cmd-window-set-cursor-icon';
80
- content: Win.CmdWindowSetCursorIconArgs;
92
+ type: 'cmd-audio-source-transport';
93
+ content: Audio.CmdAudioSourceTransportArgs;
81
94
  }
82
- | { type: 'cmd-camera-create'; content: Cam.CmdCameraCreateArgs }
83
- | { type: 'cmd-camera-update'; content: Cam.CmdCameraUpdateArgs }
84
- | { type: 'cmd-camera-dispose'; content: Cam.CmdCameraDisposeArgs }
85
- | { type: 'cmd-pose-update'; content: Mod.CmdPoseUpdateArgs }
86
- | { type: 'cmd-audio-listener-update'; content: Audio.CmdAudioListenerUpdateArgs }
87
- | { type: 'cmd-audio-listener-create'; content: Audio.CmdAudioListenerCreateArgs }
88
- | { type: 'cmd-audio-listener-dispose'; content: Audio.CmdAudioListenerDisposeArgs }
89
- | { type: 'cmd-audio-resource-create'; content: Audio.CmdAudioResourceCreateArgs }
90
- | { type: 'cmd-audio-resource-push'; content: Audio.CmdAudioResourcePushArgs }
91
- | { type: 'cmd-audio-resource-dispose'; content: Audio.CmdAudioResourceDisposeArgs }
92
- | { type: 'cmd-audio-source-create'; content: Audio.CmdAudioSourceCreateArgs }
93
- | { type: 'cmd-audio-source-update'; content: Audio.CmdAudioSourceUpdateArgs }
94
- | { type: 'cmd-audio-source-play'; content: Audio.CmdAudioSourcePlayArgs }
95
- | { type: 'cmd-audio-source-pause'; content: Audio.CmdAudioSourcePauseArgs }
96
- | { type: 'cmd-audio-source-stop'; content: Audio.CmdAudioSourceStopArgs }
97
- | { type: 'cmd-audio-source-dispose'; content: Audio.CmdAudioSourceDisposeArgs }
98
- | { type: 'cmd-model-create'; content: Mod.CmdModelCreateArgs }
99
- | { type: 'cmd-model-update'; content: Mod.CmdModelUpdateArgs }
100
- | { type: 'cmd-model-dispose'; content: Mod.CmdModelDisposeArgs }
101
- | { type: 'cmd-light-create'; content: Lite.CmdLightCreateArgs }
102
- | { type: 'cmd-light-update'; content: Lite.CmdLightUpdateArgs }
103
- | { type: 'cmd-light-dispose'; content: Lite.CmdLightDisposeArgs }
104
- | { type: 'cmd-material-create'; content: Mat.CmdMaterialCreateArgs }
105
- | { type: 'cmd-material-update'; content: Mat.CmdMaterialUpdateArgs }
106
- | { type: 'cmd-material-dispose'; content: Mat.CmdMaterialDisposeArgs }
95
+ | { type: 'cmd-audio-state-get'; content: Audio.CmdAudioStateGetArgs }
107
96
  | {
108
- type: 'cmd-texture-create-from-buffer';
109
- content: Tex.CmdTextureCreateFromBufferArgs;
97
+ type: 'cmd-audio-source-dispose';
98
+ content: Audio.CmdAudioSourceDisposeArgs;
110
99
  }
111
100
  | {
112
- type: 'cmd-texture-create-solid-color';
113
- content: Tex.CmdTextureCreateSolidColorArgs;
101
+ type: 'cmd-audio-resource-dispose';
102
+ content: Audio.CmdAudioResourceDisposeArgs;
114
103
  }
115
- | { type: 'cmd-texture-dispose'; content: Tex.CmdTextureDisposeArgs }
116
- | { type: 'cmd-geometry-create'; content: Geo.CmdGeometryCreateArgs }
117
- | { type: 'cmd-geometry-update'; content: Geo.CmdGeometryUpdateArgs }
104
+ | { type: 'cmd-geometry-upsert'; content: Geo.CmdGeometryUpsertArgs }
118
105
  | { type: 'cmd-geometry-dispose'; content: Geo.CmdGeometryDisposeArgs }
119
106
  | {
120
107
  type: 'cmd-primitive-geometry-create';
121
108
  content: Geo.CmdPrimitiveGeometryCreateArgs;
122
109
  }
123
- | { type: 'cmd-environment-create'; content: Env.CmdEnvironmentCreateArgs }
124
- | { type: 'cmd-environment-update'; content: Env.CmdEnvironmentUpdateArgs }
125
- | { type: 'cmd-environment-dispose'; content: Env.CmdEnvironmentDisposeArgs }
126
- | { type: 'cmd-shadow-configure'; content: Shad.CmdShadowConfigureArgs }
127
- | { type: 'cmd-render-graph-set'; content: RenderGraph.CmdRenderGraphSetArgs }
110
+ | { type: 'cmd-environment-upsert'; content: Env.CmdEnvironmentUpsertArgs }
111
+ | {
112
+ type: 'cmd-environment-dispose';
113
+ content: Env.CmdEnvironmentDisposeArgs;
114
+ }
115
+ | { type: 'cmd-shadow-configure'; content: import('./shadow').CmdShadowConfigureArgs }
116
+ | { type: 'cmd-realm-create'; content: Realm.CmdRealmCreateArgs }
117
+ | { type: 'cmd-realm-dispose'; content: Realm.CmdRealmDisposeArgs }
118
+ | { type: 'cmd-target-upsert'; content: Target.CmdTargetUpsertArgs }
119
+ | { type: 'cmd-target-dispose'; content: Target.CmdTargetDisposeArgs }
120
+ | {
121
+ type: 'cmd-target-layer-upsert';
122
+ content: Target.CmdTargetLayerUpsertArgs;
123
+ }
124
+ | {
125
+ type: 'cmd-target-layer-dispose';
126
+ content: Target.CmdTargetLayerDisposeArgs;
127
+ }
128
+ | { type: 'cmd-ui-theme-define'; content: Ui.CmdUiThemeDefineArgs }
129
+ | { type: 'cmd-ui-theme-dispose'; content: Ui.CmdUiThemeDisposeArgs }
130
+ | { type: 'cmd-ui-document-create'; content: Ui.CmdUiDocumentCreateArgs }
131
+ | { type: 'cmd-ui-document-dispose'; content: Ui.CmdUiDocumentDisposeArgs }
132
+ | { type: 'cmd-ui-document-set-rect'; content: Ui.CmdUiDocumentSetRectArgs }
133
+ | { type: 'cmd-ui-document-set-theme'; content: Ui.CmdUiDocumentSetThemeArgs }
134
+ | { type: 'cmd-ui-document-get-tree'; content: Ui.CmdUiDocumentGetTreeArgs }
135
+ | {
136
+ type: 'cmd-ui-document-get-layout-rects';
137
+ content: Ui.CmdUiDocumentGetLayoutRectsArgs;
138
+ }
139
+ | { type: 'cmd-ui-apply-ops'; content: Ui.CmdUiApplyOpsArgs }
140
+ | { type: 'cmd-ui-debug-set'; content: Ui.CmdUiDebugSetArgs }
141
+ | { type: 'cmd-ui-focus-set'; content: Ui.CmdUiFocusSetArgs }
142
+ | { type: 'cmd-ui-focus-get'; content: Ui.CmdUiFocusGetArgs }
143
+ | { type: 'cmd-ui-event-trace-set'; content: Ui.CmdUiEventTraceSetArgs }
144
+ | {
145
+ type: 'cmd-ui-image-create-from-buffer';
146
+ content: Ui.CmdUiImageCreateFromBufferArgs;
147
+ }
148
+ | { type: 'cmd-ui-image-dispose'; content: Ui.CmdUiImageDisposeArgs }
149
+ | { type: 'cmd-ui-clipboard-paste'; content: Ui.CmdUiClipboardPasteArgs }
150
+ | { type: 'cmd-ui-screenshot-reply'; content: Ui.CmdUiScreenshotReplyArgs }
151
+ | {
152
+ type: 'cmd-ui-access-kit-action-request';
153
+ content: Ui.CmdUiAccessKitActionRequestArgs;
154
+ }
128
155
  | { type: 'cmd-model-list'; content: Mod.CmdModelListArgs }
129
156
  | { type: 'cmd-material-list'; content: Mat.CmdMaterialListArgs }
130
157
  | { type: 'cmd-texture-list'; content: Tex.CmdTextureListArgs }
@@ -134,101 +161,118 @@ export type EngineCmd =
134
161
  | { type: 'cmd-gizmo-draw-line'; content: Giz.CmdGizmoDrawLineArgs }
135
162
  | { type: 'cmd-gizmo-draw-aabb'; content: Giz.CmdGizmoDrawAabbArgs };
136
163
 
137
- /** Discriminated union of all core command responses. */
164
+ /** Discriminated union of all command responses returned by core. */
138
165
  export type CommandResponse =
139
166
  | { type: 'notification-send'; content: Sys.CmdResultNotificationSend }
140
167
  | {
141
- type: 'upload-buffer-discard-all';
142
- content: Sys.CmdResultUploadBufferDiscardAll;
168
+ type: 'system-diagnostics-set';
169
+ content: Sys.CmdResultSystemDiagnosticsSet;
143
170
  }
144
171
  | { type: 'window-create'; content: Win.CmdResultWindowCreate }
145
172
  | { type: 'window-close'; content: Win.CmdResultWindowClose }
146
- | { type: 'window-set-title'; content: Win.CmdResultWindowSetTitle }
147
- | { type: 'window-set-position'; content: Win.CmdResultWindowSetPosition }
148
- | { type: 'window-get-position'; content: Win.CmdResultWindowGetPosition }
149
- | { type: 'window-set-size'; content: Win.CmdResultWindowSetSize }
150
- | { type: 'window-get-size'; content: Win.CmdResultWindowGetSize }
151
- | { type: 'window-get-outer-size'; content: Win.CmdResultWindowGetOuterSize }
173
+ | { type: 'window-measurement'; content: Win.CmdResultWindowMeasurement }
174
+ | { type: 'window-cursor'; content: Win.CmdResultWindowCursor }
175
+ | { type: 'window-state'; content: Win.CmdResultWindowState }
152
176
  | {
153
- type: 'window-get-surface-size';
154
- content: Win.CmdResultWindowGetSurfaceSize;
177
+ type: 'upload-buffer-discard-all';
178
+ content: Sys.CmdResultUploadBufferDiscardAll;
155
179
  }
156
- | { type: 'window-set-state'; content: Win.CmdResultWindowSetState }
157
- | { type: 'window-get-state'; content: Win.CmdResultWindowGetState }
158
- | { type: 'window-set-icon'; content: Win.CmdResultWindowSetIcon }
180
+ | { type: 'camera-upsert'; content: Cam.CmdResultCameraUpsert }
181
+ | { type: 'camera-dispose'; content: Cam.CmdResultCameraDispose }
182
+ | { type: 'model-upsert'; content: Mod.CmdResultModelUpsert }
183
+ | { type: 'pose-update'; content: Mod.CmdResultPoseUpdate }
184
+ | { type: 'model-dispose'; content: Mod.CmdResultModelDispose }
185
+ | { type: 'light-upsert'; content: Lite.CmdResultLightUpsert }
186
+ | { type: 'light-dispose'; content: Lite.CmdResultLightDispose }
187
+ | { type: 'material-upsert'; content: Mat.CmdResultMaterialUpsert }
188
+ | { type: 'material-dispose'; content: Mat.CmdResultMaterialDispose }
159
189
  | {
160
- type: 'window-set-decorations';
161
- content: Win.CmdResultWindowSetDecorations;
190
+ type: 'texture-create-from-buffer';
191
+ content: Tex.CmdResultTextureCreateFromBuffer;
162
192
  }
163
193
  | {
164
- type: 'window-has-decorations';
165
- content: Win.CmdResultWindowHasDecorations;
194
+ type: 'texture-create-solid-color';
195
+ content: Tex.CmdResultTextureCreateSolidColor;
166
196
  }
167
- | { type: 'window-set-resizable'; content: Win.CmdResultWindowSetResizable }
168
- | { type: 'window-is-resizable'; content: Win.CmdResultWindowIsResizable }
197
+ | { type: 'texture-dispose'; content: Tex.CmdResultTextureDispose }
198
+ | { type: 'texture-bind-target'; content: Tex.CmdResultTextureBindTarget }
169
199
  | {
170
- type: 'window-request-attention';
171
- content: Win.CmdResultWindowRequestAttention;
200
+ type: 'audio-listener-upsert';
201
+ content: Audio.CmdResultAudioListenerUpsert;
172
202
  }
173
- | { type: 'window-focus'; content: Win.CmdResultWindowFocus }
174
203
  | {
175
- type: 'window-set-cursor-visible';
176
- content: Win.CmdResultWindowSetCursorVisible;
204
+ type: 'audio-listener-dispose';
205
+ content: Audio.CmdResultAudioListenerDispose;
177
206
  }
178
207
  | {
179
- type: 'window-set-cursor-grab';
180
- content: Win.CmdResultWindowSetCursorGrab;
208
+ type: 'audio-source-upsert';
209
+ content: Audio.CmdResultAudioSourceUpsert;
181
210
  }
182
211
  | {
183
- type: 'window-set-cursor-icon';
184
- content: Win.CmdResultWindowSetCursorIcon;
212
+ type: 'audio-resource-upsert';
213
+ content: Audio.CmdResultAudioResourceUpsert;
185
214
  }
186
- | { type: 'camera-create'; content: Cam.CmdResultCameraCreate }
187
- | { type: 'camera-update'; content: Cam.CmdResultCameraUpdate }
188
- | { type: 'camera-dispose'; content: Cam.CmdResultCameraDispose }
189
- | { type: 'pose-update'; content: Mod.CmdResultPoseUpdate }
190
- | { type: 'audio-listener-update'; content: Audio.CmdResultAudioListenerUpdate }
191
- | { type: 'audio-listener-create'; content: Audio.CmdResultAudioListenerCreate }
192
- | { type: 'audio-listener-dispose'; content: Audio.CmdResultAudioListenerDispose }
193
- | { type: 'audio-resource-create'; content: Audio.CmdResultAudioResourceCreate }
194
- | { type: 'audio-resource-push'; content: Audio.CmdResultAudioResourcePush }
195
- | { type: 'audio-resource-dispose'; content: Audio.CmdResultAudioResourceDispose }
196
- | { type: 'audio-source-create'; content: Audio.CmdResultAudioSourceCreate }
197
- | { type: 'audio-source-update'; content: Audio.CmdResultAudioSourceUpdate }
198
- | { type: 'audio-source-play'; content: Audio.CmdResultAudioSourcePlay }
199
- | { type: 'audio-source-pause'; content: Audio.CmdResultAudioSourcePause }
200
- | { type: 'audio-source-stop'; content: Audio.CmdResultAudioSourceStop }
201
- | { type: 'audio-source-dispose'; content: Audio.CmdResultAudioSourceDispose }
202
- | { type: 'model-create'; content: Mod.CmdResultModelCreate }
203
- | { type: 'model-update'; content: Mod.CmdResultModelUpdate }
204
- | { type: 'model-dispose'; content: Mod.CmdResultModelDispose }
205
- | { type: 'light-create'; content: Lite.CmdResultLightCreate }
206
- | { type: 'light-update'; content: Lite.CmdResultLightUpdate }
207
- | { type: 'light-dispose'; content: Lite.CmdResultLightDispose }
208
- | { type: 'material-create'; content: Mat.CmdResultMaterialCreate }
209
- | { type: 'material-update'; content: Mat.CmdResultMaterialUpdate }
210
- | { type: 'material-dispose'; content: Mat.CmdResultMaterialDispose }
211
215
  | {
212
- type: 'texture-create-from-buffer';
213
- content: Tex.CmdResultTextureCreateFromBuffer;
216
+ type: 'audio-source-transport';
217
+ content: Audio.CmdResultAudioSourceTransport;
214
218
  }
219
+ | { type: 'audio-state-get'; content: Audio.CmdResultAudioStateGet }
215
220
  | {
216
- type: 'texture-create-solid-color';
217
- content: Tex.CmdResultTextureCreateSolidColor;
221
+ type: 'audio-source-dispose';
222
+ content: Audio.CmdResultAudioSourceDispose;
218
223
  }
219
- | { type: 'texture-dispose'; content: Tex.CmdResultTextureDispose }
220
- | { type: 'geometry-create'; content: Geo.CmdResultGeometryCreate }
221
- | { type: 'geometry-update'; content: Geo.CmdResultGeometryUpdate }
224
+ | {
225
+ type: 'audio-resource-dispose';
226
+ content: Audio.CmdResultAudioResourceDispose;
227
+ }
228
+ | { type: 'geometry-upsert'; content: Geo.CmdResultGeometryUpsert }
222
229
  | { type: 'geometry-dispose'; content: Geo.CmdResultGeometryDispose }
223
230
  | {
224
231
  type: 'primitive-geometry-create';
225
232
  content: Geo.CmdResultPrimitiveGeometryCreate;
226
233
  }
227
- | { type: 'environment-create'; content: Env.CmdResultEnvironment }
228
- | { type: 'environment-update'; content: Env.CmdResultEnvironment }
234
+ | { type: 'environment-upsert'; content: Env.CmdResultEnvironment }
229
235
  | { type: 'environment-dispose'; content: Env.CmdResultEnvironment }
230
- | { type: 'shadow-configure'; content: Shad.CmdResultShadowConfigure }
231
- | { type: 'render-graph-set'; content: RenderGraph.CmdResultRenderGraphSet }
236
+ | {
237
+ type: 'shadow-configure';
238
+ content: import('./shadow').CmdResultShadowConfigure;
239
+ }
240
+ | { type: 'realm-create'; content: Realm.CmdResultRealmCreate }
241
+ | { type: 'realm-dispose'; content: Realm.CmdResultRealmDispose }
242
+ | { type: 'target-upsert'; content: Target.CmdResultTargetUpsert }
243
+ | { type: 'target-dispose'; content: Target.CmdResultTargetDispose }
244
+ | {
245
+ type: 'target-layer-upsert';
246
+ content: Target.CmdResultTargetLayerUpsert;
247
+ }
248
+ | {
249
+ type: 'target-layer-dispose';
250
+ content: Target.CmdResultTargetLayerDispose;
251
+ }
252
+ | { type: 'ui-theme-define'; content: Ui.CmdResultUiThemeDefine }
253
+ | { type: 'ui-theme-dispose'; content: Ui.CmdResultUiThemeDispose }
254
+ | { type: 'ui-document-create'; content: Ui.CmdResultUiDocumentCreate }
255
+ | { type: 'ui-document-dispose'; content: Ui.CmdResultUiDocumentDispose }
256
+ | { type: 'ui-document-set-rect'; content: Ui.CmdResultUiDocumentSetRect }
257
+ | { type: 'ui-document-set-theme'; content: Ui.CmdResultUiDocumentSetTheme }
258
+ | { type: 'ui-document-get-tree'; content: Ui.CmdResultUiDocumentGetTree }
259
+ | {
260
+ type: 'ui-document-get-layout-rects';
261
+ content: Ui.CmdResultUiDocumentGetLayoutRects;
262
+ }
263
+ | { type: 'ui-apply-ops'; content: Ui.CmdResultUiApplyOps }
264
+ | { type: 'ui-debug-set'; content: Ui.CmdResultUiDebugSet }
265
+ | { type: 'ui-focus-set'; content: Ui.CmdResultUiFocusSet }
266
+ | { type: 'ui-focus-get'; content: Ui.CmdResultUiFocusGet }
267
+ | { type: 'ui-event-trace-set'; content: Ui.CmdResultUiEventTraceSet }
268
+ | {
269
+ type: 'ui-image-create-from-buffer';
270
+ content: Ui.CmdResultUiImageCreateFromBuffer;
271
+ }
272
+ | { type: 'ui-image-dispose'; content: Ui.CmdResultUiImageDispose }
273
+ | { type: 'ui-clipboard-paste'; content: Ui.CmdResultUiInputEvent }
274
+ | { type: 'ui-screenshot-reply'; content: Ui.CmdResultUiInputEvent }
275
+ | { type: 'ui-access-kit-action-request'; content: Ui.CmdResultUiInputEvent }
232
276
  | { type: 'model-list'; content: Mod.CmdResultModelList }
233
277
  | { type: 'material-list'; content: Mat.CmdResultMaterialList }
234
278
  | { type: 'texture-list'; content: Tex.CmdResultTextureList }
@@ -238,35 +282,21 @@ export type CommandResponse =
238
282
  | { type: 'gizmo-draw-line'; content: Giz.CmdResultGizmoDraw }
239
283
  | { type: 'gizmo-draw-aabb'; content: Giz.CmdResultGizmoDraw };
240
284
 
241
- /** Envelope used when batching commands to the core. */
285
+ /** Command envelope used in batched transport payloads. */
242
286
  export interface EngineCmdEnvelope {
243
287
  id: number;
244
288
  type: EngineCmd['type'];
245
289
  content: EngineCmd['content'];
246
290
  }
247
291
 
248
- /** Envelope used when decoding responses from the core. */
292
+ /** Response envelope returned by queue polling and routed by command id. */
249
293
  export interface CommandResponseEnvelope {
250
294
  id: number;
251
295
  type: CommandResponse['type'];
252
296
  content: CommandResponse['content'];
253
297
  }
254
298
 
255
- /** Batch of commands sent in a single tick. */
299
+ /** Batched commands payload sent to transport. */
256
300
  export type EngineBatchCmds = EngineCmdEnvelope[];
257
-
258
- /** Batch of responses received from the core. */
301
+ /** Batched responses payload decoded from transport. */
259
302
  export type EngineBatchResponses = CommandResponseEnvelope[];
260
-
261
- /** Result codes returned by core entrypoints. */
262
- export enum VulframResult {
263
- Success = 0,
264
- UnknownError = 1,
265
- NotInitialized = 2,
266
- AlreadyInitialized = 3,
267
- WrongThread = 4,
268
- CmdInvalidMessagePackError = 5,
269
- BufferNotFound = 6,
270
- BufferIdCollision = 7,
271
- InvalidUploadType = 8,
272
- }
@@ -3,7 +3,7 @@ import type { ResourceEntry } from './resources';
3
3
 
4
4
  /** Command payload for creating a light. */
5
5
  export interface CmdLightCreateArgs {
6
- windowId: number;
6
+ realmId: number;
7
7
  lightId: number;
8
8
  label?: string;
9
9
  kind?: LightKind;
@@ -18,15 +18,9 @@ export interface CmdLightCreateArgs {
18
18
  castShadow?: boolean;
19
19
  }
20
20
 
21
- /** Result payload for light create. */
22
- export interface CmdResultLightCreate {
23
- success: boolean;
24
- message: string;
25
- }
26
-
27
21
  /** Command payload for updating a light. */
28
22
  export interface CmdLightUpdateArgs {
29
- windowId: number;
23
+ realmId: number;
30
24
  lightId: number;
31
25
  label?: string;
32
26
  kind?: LightKind;
@@ -41,15 +35,22 @@ export interface CmdLightUpdateArgs {
41
35
  castShadow?: boolean;
42
36
  }
43
37
 
44
- /** Result payload for light update. */
45
- export interface CmdResultLightUpdate {
38
+ /** Result payload for light upsert. */
39
+ export interface CmdResultLightUpsert {
46
40
  success: boolean;
47
41
  message: string;
48
42
  }
49
43
 
44
+ /** Upsert payload accepted by the core (`create` or `update`). */
45
+ export type CmdLightUpsertArgs = CmdLightCreateArgs | CmdLightUpdateArgs;
46
+
47
+ /** Backward-compatible aliases. */
48
+ export type CmdResultLightCreate = CmdResultLightUpsert;
49
+ export type CmdResultLightUpdate = CmdResultLightUpsert;
50
+
50
51
  /** Command payload for disposing a light. */
51
52
  export interface CmdLightDisposeArgs {
52
- windowId: number;
53
+ realmId: number;
53
54
  lightId: number;
54
55
  }
55
56
 
@@ -48,37 +48,35 @@ export type MaterialOptions =
48
48
 
49
49
  /** Command payload for creating a material. */
50
50
  export interface CmdMaterialCreateArgs {
51
- windowId: number;
52
51
  materialId: number;
53
52
  label?: string;
54
53
  kind: MaterialKind;
55
54
  options?: MaterialOptions;
56
55
  }
57
56
 
58
- /** Result payload for material create. */
59
- export interface CmdResultMaterialCreate {
60
- success: boolean;
61
- message: string;
62
- }
63
-
64
57
  /** Command payload for updating a material. */
65
58
  export interface CmdMaterialUpdateArgs {
66
- windowId: number;
67
59
  materialId: number;
68
60
  label?: string;
69
61
  kind?: MaterialKind;
70
62
  options?: MaterialOptions;
71
63
  }
72
64
 
73
- /** Result payload for material update. */
74
- export interface CmdResultMaterialUpdate {
65
+ /** Result payload for material upsert. */
66
+ export interface CmdResultMaterialUpsert {
75
67
  success: boolean;
76
68
  message: string;
77
69
  }
78
70
 
71
+ /** Upsert payload accepted by the core (`create` or `update`). */
72
+ export type CmdMaterialUpsertArgs = CmdMaterialCreateArgs | CmdMaterialUpdateArgs;
73
+
74
+ /** Backward-compatible aliases. */
75
+ export type CmdResultMaterialCreate = CmdResultMaterialUpsert;
76
+ export type CmdResultMaterialUpdate = CmdResultMaterialUpsert;
77
+
79
78
  /** Command payload for disposing a material. */
80
79
  export interface CmdMaterialDisposeArgs {
81
- windowId: number;
82
80
  materialId: number;
83
81
  }
84
82
 
@@ -2,8 +2,8 @@ import type { ResourceEntry } from './resources';
2
2
 
3
3
  /** Command payload for creating a model. */
4
4
  export interface CmdModelCreateArgs {
5
- windowId: number ;
6
- modelId: number ;
5
+ realmId: number;
6
+ modelId: number;
7
7
  label?: string;
8
8
  geometryId: number;
9
9
  materialId?: number;
@@ -15,16 +15,10 @@ export interface CmdModelCreateArgs {
15
15
  outlineColor: [number, number, number, number];
16
16
  }
17
17
 
18
- /** Result payload for model create. */
19
- export interface CmdResultModelCreate {
20
- success: boolean;
21
- message: string;
22
- }
23
-
24
18
  /** Command payload for updating a model. */
25
19
  export interface CmdModelUpdateArgs {
26
- windowId: number ;
27
- modelId: number ;
20
+ realmId: number;
21
+ modelId: number;
28
22
  label?: string;
29
23
  geometryId?: number;
30
24
  materialId?: number;
@@ -36,18 +30,26 @@ export interface CmdModelUpdateArgs {
36
30
  outlineColor?: [number, number, number, number];
37
31
  }
38
32
 
39
- /** Result payload for model update. */
40
- export interface CmdResultModelUpdate {
33
+ /** Result payload for model upsert. */
34
+ export interface CmdResultModelUpsert {
41
35
  success: boolean;
42
36
  message: string;
43
37
  }
44
38
 
39
+ /** Upsert payload accepted by the core (`create` or `update`). */
40
+ export type CmdModelUpsertArgs = CmdModelCreateArgs | CmdModelUpdateArgs;
41
+
42
+ /** Backward-compatible aliases. */
43
+ export type CmdResultModelCreate = CmdResultModelUpsert;
44
+ export type CmdResultModelUpdate = CmdResultModelUpsert;
45
+
45
46
  /** Command payload for updating a model pose (skinning). */
46
47
  export interface CmdPoseUpdateArgs {
47
- windowId: number;
48
+ realmId: number;
48
49
  modelId: number;
49
50
  boneCount: number;
50
51
  matricesBufferId: number;
52
+ windowId?: number;
51
53
  }
52
54
 
53
55
  /** Result payload for pose update. */
@@ -58,8 +60,8 @@ export interface CmdResultPoseUpdate {
58
60
 
59
61
  /** Command payload for disposing a model. */
60
62
  export interface CmdModelDisposeArgs {
61
- windowId: number ;
62
- modelId: number ;
63
+ realmId: number;
64
+ modelId: number;
63
65
  }
64
66
 
65
67
  /** Result payload for model dispose. */
@@ -0,0 +1,25 @@
1
+ export type RealmKind = 'three-d' | 'two-d';
2
+
3
+ export interface CmdRealmCreateArgs {
4
+ kind: RealmKind;
5
+ outputSurfaceId?: number;
6
+ hostWindowId?: number;
7
+ importance?: number;
8
+ cachePolicy?: number;
9
+ flags?: number;
10
+ }
11
+
12
+ export interface CmdResultRealmCreate {
13
+ success: boolean;
14
+ message: string;
15
+ realmId?: number;
16
+ }
17
+
18
+ export interface CmdRealmDisposeArgs {
19
+ realmId: number;
20
+ }
21
+
22
+ export interface CmdResultRealmDispose {
23
+ success: boolean;
24
+ message: string;
25
+ }