babylon.quarks-editor 0.27.0 → 0.28.0

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 (138) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +31 -4
  3. package/dist/core/assetTree.d.ts +5 -0
  4. package/dist/core/assets.d.ts +7 -0
  5. package/dist/core/assets.js +11 -7
  6. package/dist/core/binding.d.ts +9 -0
  7. package/dist/core/binding.js +8 -0
  8. package/dist/core/collision.d.ts +4 -0
  9. package/dist/core/collision.js +4 -0
  10. package/dist/core/colors.d.ts +16 -0
  11. package/dist/core/colors.js +8 -0
  12. package/dist/core/defaultEffect.d.ts +3 -2
  13. package/dist/core/defaultEffect.js +1 -1
  14. package/dist/core/editorSession.d.ts +229 -0
  15. package/dist/core/editorSession.js +983 -0
  16. package/dist/core/effectTree.d.ts +5 -0
  17. package/dist/core/galleryPlayback.js +2 -1
  18. package/dist/core/history.d.ts +6 -0
  19. package/dist/core/history.js +4 -0
  20. package/dist/core/indexedDbProjectStore.d.ts +13 -0
  21. package/dist/core/indexedDbProjectStore.js +13 -0
  22. package/dist/core/material.d.ts +12 -2
  23. package/dist/core/playback.d.ts +6 -0
  24. package/dist/core/projectStore.d.ts +26 -0
  25. package/dist/core/projectStore.js +1 -0
  26. package/dist/core/sceneEntries.d.ts +3 -0
  27. package/dist/core/scrub.d.ts +1 -1
  28. package/dist/core/scrub.js +2 -2
  29. package/dist/core/shapes.d.ts +24 -0
  30. package/dist/core/shapes.js +5 -0
  31. package/dist/core/systems.d.ts +2 -0
  32. package/dist/core/systems.js +3 -1
  33. package/dist/core/timeline.d.ts +23 -3
  34. package/dist/core/values.d.ts +21 -4
  35. package/dist/core/values.js +5 -0
  36. package/dist/index.d.ts +5 -1
  37. package/dist/react/AssetsPanel.d.ts +7 -0
  38. package/dist/react/ChoiceDialog.d.ts +7 -0
  39. package/dist/react/ContextMenu.d.ts +10 -1
  40. package/dist/react/EditorWorkspace.d.ts +7 -0
  41. package/dist/react/EditorWorkspace.js +6 -3
  42. package/dist/react/EffectEditor.d.ts +8 -2
  43. package/dist/react/EffectEditorHost.d.ts +32 -28
  44. package/dist/react/EffectEditorHost.js +241 -1665
  45. package/dist/react/EffectTreeView.d.ts +3 -0
  46. package/dist/react/MessageDialog.d.ts +5 -0
  47. package/dist/react/ModuleSection.d.ts +10 -0
  48. package/dist/react/ModuleSection.js +4 -1
  49. package/dist/react/ProjectsPage.d.ts +6 -0
  50. package/dist/react/ProjectsPage.js +27 -11
  51. package/dist/react/PromptDialog.d.ts +7 -0
  52. package/dist/react/ScenePanel.d.ts +7 -0
  53. package/dist/react/ScenePanel.js +7 -5
  54. package/dist/react/TextureSelect.d.ts +5 -5
  55. package/dist/react/TimelinePanel.d.ts +13 -0
  56. package/dist/react/TimelinePanel.js +10 -6
  57. package/dist/react/TimelineTrackRow.d.ts +10 -0
  58. package/dist/react/TransportBar.d.ts +9 -0
  59. package/dist/react/ValueField.d.ts +32 -5
  60. package/dist/react/ValueField.js +20 -9
  61. package/dist/react/behaviorModules.d.ts +16 -5
  62. package/dist/react/behaviorModules.js +16 -1
  63. package/dist/react/fields.d.ts +8 -0
  64. package/dist/react/fields.js +3 -0
  65. package/dist/react/host/BottomDocks.d.ts +36 -0
  66. package/dist/react/host/BottomDocks.js +63 -0
  67. package/dist/react/host/HostDialogs.d.ts +50 -0
  68. package/dist/react/host/HostDialogs.js +113 -0
  69. package/dist/react/host/InspectorSidebar.d.ts +32 -0
  70. package/dist/react/host/InspectorSidebar.js +59 -0
  71. package/dist/react/host/SceneSidebar.d.ts +53 -0
  72. package/dist/react/host/SceneSidebar.js +62 -0
  73. package/dist/react/host/ViewportPane.d.ts +56 -0
  74. package/dist/react/host/ViewportPane.js +91 -0
  75. package/dist/react/host/hostHooks.d.ts +44 -0
  76. package/dist/react/host/hostHooks.js +164 -0
  77. package/dist/react/host/hostStyles.d.ts +21 -0
  78. package/dist/react/host/hostStyles.js +57 -0
  79. package/dist/react/index.d.ts +3 -1
  80. package/dist/react/modules.d.ts +17 -6
  81. package/dist/react/modules.js +38 -20
  82. package/dist/react/theme.d.ts +15 -0
  83. package/dist/react/theme.js +15 -0
  84. package/dist/session.d.ts +9 -0
  85. package/dist/session.js +8 -0
  86. package/package.json +17 -11
  87. package/src/core/assetTree.ts +14 -1
  88. package/src/core/assets.ts +25 -10
  89. package/src/core/binding.ts +9 -0
  90. package/src/core/collision.ts +4 -0
  91. package/src/core/colors.ts +21 -1
  92. package/src/core/defaultEffect.ts +4 -3
  93. package/src/core/editorSession.ts +1299 -0
  94. package/src/core/effectTree.ts +5 -0
  95. package/src/core/galleryPlayback.ts +2 -1
  96. package/src/core/history.ts +6 -0
  97. package/src/core/indexedDbProjectStore.ts +13 -0
  98. package/src/core/loadEffect.ts +1 -1
  99. package/src/core/material.ts +14 -4
  100. package/src/core/playback.ts +6 -0
  101. package/src/core/projectStore.ts +26 -0
  102. package/src/core/sceneEntries.ts +3 -0
  103. package/src/core/scrub.ts +2 -2
  104. package/src/core/shapes.ts +28 -1
  105. package/src/core/systems.ts +9 -2
  106. package/src/core/timeline.ts +40 -15
  107. package/src/core/values.ts +20 -4
  108. package/src/index.ts +5 -1
  109. package/src/react/AssetsPanel.tsx +7 -0
  110. package/src/react/ChoiceDialog.tsx +7 -0
  111. package/src/react/ContextMenu.tsx +10 -1
  112. package/src/react/EditorWorkspace.tsx +11 -5
  113. package/src/react/EffectEditor.tsx +7 -1
  114. package/src/react/EffectEditorHost.tsx +406 -2340
  115. package/src/react/EffectTreeView.tsx +3 -0
  116. package/src/react/MessageDialog.tsx +5 -0
  117. package/src/react/ModuleSection.tsx +11 -0
  118. package/src/react/ProjectsPage.tsx +38 -11
  119. package/src/react/PromptDialog.tsx +7 -0
  120. package/src/react/ScenePanel.tsx +14 -5
  121. package/src/react/TextureSelect.tsx +6 -6
  122. package/src/react/TimelinePanel.tsx +23 -6
  123. package/src/react/TimelineTrackRow.tsx +10 -0
  124. package/src/react/TransportBar.tsx +9 -0
  125. package/src/react/ValueField.tsx +58 -14
  126. package/src/react/behaviorModules.tsx +34 -32
  127. package/src/react/fields.tsx +12 -1
  128. package/src/react/host/BottomDocks.tsx +178 -0
  129. package/src/react/host/HostDialogs.tsx +228 -0
  130. package/src/react/host/InspectorSidebar.tsx +147 -0
  131. package/src/react/host/SceneSidebar.tsx +227 -0
  132. package/src/react/host/ViewportPane.tsx +300 -0
  133. package/src/react/host/hostHooks.ts +198 -0
  134. package/src/react/host/hostStyles.ts +65 -0
  135. package/src/react/index.ts +3 -1
  136. package/src/react/modules.tsx +70 -44
  137. package/src/react/theme.ts +15 -0
  138. package/src/session.ts +17 -0
@@ -1,12 +1,17 @@
1
1
  import { TransformNode } from '@babylonjs/core/Meshes/transformNode.js';
2
2
  import type { ParticleSystem } from 'babylon.quarks';
3
3
  /** A node in the editor's effect hierarchy: a Group (organizational) or a ParticleEmitter. */
4
+ /** One node of an effect's tree: a group, or an emitter with its system. */
4
5
  export interface EffectTreeNode {
6
+ /** The node. */
5
7
  node: TransformNode;
8
+ /** The node's name, or a readable stand-in when it has none. */
6
9
  name: string;
7
10
  /** Present when the node is a ParticleEmitter. */
8
11
  system?: ParticleSystem;
12
+ /** How deep the node sits; the root is 0. */
9
13
  depth: number;
14
+ /** The node's child groups and emitters. */
10
15
  children: EffectTreeNode[];
11
16
  }
12
17
  /** Walks a loaded root TransformNode into the editor tree (groups + emitters). */
@@ -20,7 +20,8 @@ export function applyGalleryPlayback(entries, previewRootIds, transportPlaying,
20
20
  continue;
21
21
  }
22
22
  for (const system of entry.systems) {
23
- system.play();
23
+ // Undoes the pause above; a finished effect stays finished.
24
+ system.resume();
24
25
  }
25
26
  }
26
27
  }
@@ -1,7 +1,9 @@
1
1
  import type { EffectBinding } from './binding.js';
2
2
  /** Undo/redo stacks of one effect, kept by the host while another effect is focused. */
3
3
  export interface HistoryStacks {
4
+ /** Snapshots to undo to, oldest first. */
4
5
  undo: string[];
6
+ /** Snapshots to redo to, most recent undo last. */
5
7
  redo: string[];
6
8
  }
7
9
  /**
@@ -18,11 +20,15 @@ export declare class EffectHistory {
18
20
  private binding;
19
21
  /** Points the history at the active binding and hooks snapshot capture. */
20
22
  attach(binding: EffectBinding): void;
23
+ /** There is a change to undo. */
21
24
  get canUndo(): boolean;
25
+ /** There is an undone change to redo. */
22
26
  get canRedo(): boolean;
27
+ /** Forgets every snapshot. */
23
28
  clear(): void;
24
29
  /** The current stacks, to hand back to `restoreStacks` when this effect is focused again. */
25
30
  saveStacks(): HistoryStacks;
31
+ /** Puts back stacks from `saveStacks`; undefined starts empty. */
26
32
  restoreStacks(stacks: HistoryStacks | undefined): void;
27
33
  /**
28
34
  * Pushes an undo snapshot. A burst of edits — typing a number, dragging a curve handle or a
@@ -19,12 +19,15 @@ export class EffectHistory {
19
19
  this.binding = binding;
20
20
  binding.onBeforeChange = () => this.capture();
21
21
  }
22
+ /** There is a change to undo. */
22
23
  get canUndo() {
23
24
  return this.undoStack.length > 0;
24
25
  }
26
+ /** There is an undone change to redo. */
25
27
  get canRedo() {
26
28
  return this.redoStack.length > 0;
27
29
  }
30
+ /** Forgets every snapshot. */
28
31
  clear() {
29
32
  this.undoStack = [];
30
33
  this.redoStack = [];
@@ -34,6 +37,7 @@ export class EffectHistory {
34
37
  saveStacks() {
35
38
  return { undo: this.undoStack, redo: this.redoStack };
36
39
  }
40
+ /** Puts back stacks from `saveStacks`; undefined starts empty. */
37
41
  restoreStacks(stacks) {
38
42
  this.undoStack = stacks?.undo ?? [];
39
43
  this.redoStack = stacks?.redo ?? [];
@@ -11,18 +11,31 @@ export declare class IndexedDbProjectStore implements ProjectStore {
11
11
  /** `${projectId}/${hash}` → data URI, so every effect sharing a file gets the same string. */
12
12
  private readonly dataUrlByFile;
13
13
  private db;
14
+ /** {@inheritDoc ProjectStore.listProjects} */
14
15
  listProjects(): Promise<ProjectMeta[]>;
16
+ /** {@inheritDoc ProjectStore.getProject} */
15
17
  getProject(id: string): Promise<ProjectMeta | null>;
18
+ /** {@inheritDoc ProjectStore.createProject} */
16
19
  createProject(name: string): Promise<ProjectMeta>;
20
+ /** {@inheritDoc ProjectStore.renameProject} */
17
21
  renameProject(id: string, name: string): Promise<void>;
22
+ /** {@inheritDoc ProjectStore.duplicateProject} */
18
23
  duplicateProject(id: string, name: string): Promise<ProjectMeta>;
24
+ /** {@inheritDoc ProjectStore.deleteProject} */
19
25
  deleteProject(id: string): Promise<void>;
26
+ /** {@inheritDoc ProjectStore.loadAssets} */
20
27
  loadAssets(projectId: string): Promise<StoredAsset[]>;
28
+ /** {@inheritDoc ProjectStore.putAssets} */
21
29
  putAssets(projectId: string, assets: StoredAsset[]): Promise<void>;
30
+ /** {@inheritDoc ProjectStore.deleteAssets} */
22
31
  deleteAssets(projectId: string, paths: string[]): Promise<void>;
32
+ /** {@inheritDoc ProjectStore.loadScene} */
23
33
  loadScene(projectId: string): Promise<StoredScene | null>;
34
+ /** {@inheritDoc ProjectStore.saveScene} */
24
35
  saveScene(projectId: string, scene: StoredScene): Promise<void>;
36
+ /** {@inheritDoc ProjectStore.estimate} */
25
37
  estimate(): Promise<StorageEstimate>;
38
+ /** {@inheritDoc ProjectStore.requestPersistence} */
26
39
  requestPersistence(): Promise<boolean>;
27
40
  /** Clones `json` with each texture data URI replaced by a `quarks-file:<hash>` reference. */
28
41
  private pack;
@@ -84,15 +84,18 @@ export class IndexedDbProjectStore {
84
84
  return this.dbPromise;
85
85
  }
86
86
  // ---- projects -------------------------------------------------------------------------
87
+ /** {@inheritDoc ProjectStore.listProjects} */
87
88
  async listProjects() {
88
89
  const db = await this.db();
89
90
  const all = await request(db.transaction('projects').objectStore('projects').getAll());
90
91
  return all.sort((a, b) => b.updatedAt - a.updatedAt);
91
92
  }
93
+ /** {@inheritDoc ProjectStore.getProject} */
92
94
  async getProject(id) {
93
95
  const db = await this.db();
94
96
  return ((await request(db.transaction('projects').objectStore('projects').get(id))) ?? null);
95
97
  }
98
+ /** {@inheritDoc ProjectStore.createProject} */
96
99
  async createProject(name) {
97
100
  const now = Date.now();
98
101
  const meta = { id: newId(), name, createdAt: now, updatedAt: now, assetCount: 0, sizeBytes: 0 };
@@ -102,6 +105,7 @@ export class IndexedDbProjectStore {
102
105
  await done(tx);
103
106
  return meta;
104
107
  }
108
+ /** {@inheritDoc ProjectStore.renameProject} */
105
109
  async renameProject(id, name) {
106
110
  const meta = await this.getProject(id);
107
111
  if (!meta)
@@ -111,6 +115,7 @@ export class IndexedDbProjectStore {
111
115
  tx.objectStore('projects').put({ ...meta, name, updatedAt: Date.now() });
112
116
  await done(tx);
113
117
  }
118
+ /** {@inheritDoc ProjectStore.duplicateProject} */
114
119
  async duplicateProject(id, name) {
115
120
  const source = await this.getProject(id);
116
121
  if (!source)
@@ -135,6 +140,7 @@ export class IndexedDbProjectStore {
135
140
  await done(tx);
136
141
  return meta;
137
142
  }
143
+ /** {@inheritDoc ProjectStore.deleteProject} */
138
144
  async deleteProject(id) {
139
145
  const db = await this.db();
140
146
  const tx = db.transaction(['projects', 'assets', 'files', 'scenes'], 'readwrite');
@@ -152,6 +158,7 @@ export class IndexedDbProjectStore {
152
158
  }
153
159
  }
154
160
  // ---- assets ---------------------------------------------------------------------------
161
+ /** {@inheritDoc ProjectStore.loadAssets} */
155
162
  async loadAssets(projectId) {
156
163
  const db = await this.db();
157
164
  const records = await request(db.transaction('assets').objectStore('assets').index('projectId').getAll(projectId));
@@ -162,6 +169,7 @@ export class IndexedDbProjectStore {
162
169
  missingFiles,
163
170
  })));
164
171
  }
172
+ /** {@inheritDoc ProjectStore.putAssets} */
165
173
  async putAssets(projectId, assets) {
166
174
  const files = new Map();
167
175
  const packed = await Promise.all(assets.map(async (asset) => ({ ...asset, projectId, json: await this.pack(asset.json, files) })));
@@ -173,6 +181,7 @@ export class IndexedDbProjectStore {
173
181
  await done(tx);
174
182
  await this.refresh(projectId);
175
183
  }
184
+ /** {@inheritDoc ProjectStore.deleteAssets} */
176
185
  async deleteAssets(projectId, paths) {
177
186
  const db = await this.db();
178
187
  const tx = db.transaction('assets', 'readwrite');
@@ -182,6 +191,7 @@ export class IndexedDbProjectStore {
182
191
  await this.refresh(projectId);
183
192
  }
184
193
  // ---- scene ----------------------------------------------------------------------------
194
+ /** {@inheritDoc ProjectStore.loadScene} */
185
195
  async loadScene(projectId) {
186
196
  const db = await this.db();
187
197
  const record = await request(db.transaction('scenes').objectStore('scenes').get(projectId));
@@ -190,6 +200,7 @@ export class IndexedDbProjectStore {
190
200
  const entries = await Promise.all(record.entries.map(async (entry) => ({ ...entry, json: await this.unpack(projectId, entry.json) })));
191
201
  return { entries, savedAt: record.savedAt };
192
202
  }
203
+ /** {@inheritDoc ProjectStore.saveScene} */
193
204
  async saveScene(projectId, scene) {
194
205
  const files = new Map();
195
206
  const entries = await Promise.all(scene.entries.map(async (entry) => ({ ...entry, json: await this.pack(entry.json, files) })));
@@ -201,12 +212,14 @@ export class IndexedDbProjectStore {
201
212
  await this.refresh(projectId);
202
213
  }
203
214
  // ---- storage ----------------------------------------------------------------------------
215
+ /** {@inheritDoc ProjectStore.estimate} */
204
216
  async estimate() {
205
217
  const storage = typeof navigator !== 'undefined' ? navigator.storage : undefined;
206
218
  const estimate = storage?.estimate ? await storage.estimate() : undefined;
207
219
  const persisted = storage?.persisted ? await storage.persisted() : false;
208
220
  return { usage: estimate?.usage ?? null, quota: estimate?.quota ?? null, persisted };
209
221
  }
222
+ /** {@inheritDoc ProjectStore.requestPersistence} */
210
223
  async requestPersistence() {
211
224
  const storage = typeof navigator !== 'undefined' ? navigator.storage : undefined;
212
225
  return storage?.persist ? storage.persist() : false;
@@ -1,13 +1,23 @@
1
+ import type { BaseTexture } from '@babylonjs/core/Materials/Textures/baseTexture.js';
2
+ import type { Texture } from '@babylonjs/core/Materials/Textures/texture.js';
1
3
  import type { ParticleSystem } from 'babylon.quarks';
4
+ /** Material settings the Renderer module changes; fields left out keep their value. */
2
5
  export interface RendererMaterialPatch {
6
+ /** The blend mode, see `ParticleSystem.blending`. */
3
7
  blendMode?: number;
8
+ /** Draws with alpha blending. */
4
9
  transparent?: boolean;
10
+ /** Tests against the depth buffer. */
5
11
  depthTest?: boolean;
12
+ /** Writes to the depth buffer. */
6
13
  depthWrite?: boolean;
14
+ /** Discards pixels whose alpha is below this. */
7
15
  alphaTest?: number;
8
- texture?: unknown;
16
+ /** The main texture, or null for none. */
17
+ texture?: Texture | null;
9
18
  /** A 3×2 cube-face atlas mesh particles reflect, or null for none. */
10
- reflectionAtlas?: unknown;
19
+ reflectionAtlas?: BaseTexture | null;
20
+ /** How strongly mesh particles reflect the atlas, 0..1. */
11
21
  reflectionLevel?: number;
12
22
  }
13
23
  /** Applies renderer material settings and keeps imported QuarksMaterial JSON in sync for export. */
@@ -2,11 +2,17 @@
2
2
  export interface PlaybackState {
3
3
  /** When true, all in-scene preview effects simulate. */
4
4
  stagePlaying: boolean;
5
+ /** Root `uniqueId` of the focused effect, whose time the timeline shows. */
5
6
  focusRootId: number | null;
7
+ /** Each effect's timeline time, in seconds, by root `uniqueId`. */
6
8
  focusElapsedByRoot: Map<number, number>;
9
+ /** Effects parked at their end, by root `uniqueId`; Play restarts them. */
7
10
  focusFinishedByRoot: Set<number>;
11
+ /** Playback speed, 1 for real time. */
8
12
  speed: number;
13
+ /** While paused: advance one frame on the next render. */
9
14
  stepQueued: boolean;
15
+ /** The timeline is being scrubbed; the render loop does not simulate. */
10
16
  scrubbing: boolean;
11
17
  }
12
18
  /** Default playback state for a new editor session. */
@@ -1,9 +1,14 @@
1
1
  /** One editor project: a library of effect assets plus the scene built from them. */
2
2
  export interface ProjectMeta {
3
+ /** The project's key in its store. */
3
4
  id: string;
5
+ /** The project's display name. */
4
6
  name: string;
7
+ /** When the project was created, in milliseconds since the epoch. */
5
8
  createdAt: number;
9
+ /** When the project last changed, in milliseconds since the epoch. */
6
10
  updatedAt: number;
11
+ /** How many effect assets the project holds. */
7
12
  assetCount: number;
8
13
  /** Approximate bytes the project takes in storage (JSON + texture files). */
9
14
  sizeBytes: number;
@@ -12,23 +17,32 @@ export interface ProjectMeta {
12
17
  export interface StoredAsset {
13
18
  /** Relative path inside the project (`Fire/Explosion.json`) — the asset's key. */
14
19
  path: string;
20
+ /** The asset's display name, its file name without `.json`. */
15
21
  name: string;
22
+ /** The effect, as quarks JSON with its textures inlined. */
16
23
  json: unknown;
24
+ /** Files the effect referenced that were not imported with it. */
17
25
  missingFiles: string[];
18
26
  }
19
27
  /** One effect instance in a saved scene. */
20
28
  export interface StoredSceneEntry {
29
+ /** The instance's name in the Scene list. */
21
30
  name: string;
22
31
  /** Path of the asset it was made from, if any. */
23
32
  assetPath: string | null;
24
33
  /** The instance's own (possibly edited) effect, root transform included. */
25
34
  json: unknown;
35
+ /** Whether the instance was shown. */
26
36
  visible: boolean;
27
37
  }
38
+ /** A project's saved scene: the effects placed in it, in Scene list order. */
28
39
  export interface StoredScene {
40
+ /** The scene's effect instances. */
29
41
  entries: StoredSceneEntry[];
42
+ /** When it was saved, in milliseconds since the epoch. */
30
43
  savedAt: number;
31
44
  }
45
+ /** How much storage projects use, as far as the browser tells. */
32
46
  export interface StorageEstimate {
33
47
  /** Bytes the whole site uses (all projects), when the browser reports it. */
34
48
  usage: number | null;
@@ -42,20 +56,32 @@ export interface StorageEstimate {
42
56
  * everything in the browser, and an embedding host can supply its own (e.g. on disk).
43
57
  */
44
58
  export interface ProjectStore {
59
+ /** Every project, most recently changed first. */
45
60
  listProjects(): Promise<ProjectMeta[]>;
61
+ /** One project, or null when there is none with that id. */
46
62
  getProject(id: string): Promise<ProjectMeta | null>;
63
+ /** Creates an empty project. */
47
64
  createProject(name: string): Promise<ProjectMeta>;
65
+ /** Renames a project. */
48
66
  renameProject(id: string, name: string): Promise<void>;
67
+ /** Copies a project, its assets and its scene, under a new name. */
49
68
  duplicateProject(id: string, name: string): Promise<ProjectMeta>;
69
+ /** Deletes a project, its assets and its scene. */
50
70
  deleteProject(id: string): Promise<void>;
71
+ /** A project's assets. */
51
72
  loadAssets(projectId: string): Promise<StoredAsset[]>;
52
73
  /** Adds or replaces assets by path. */
53
74
  putAssets(projectId: string, assets: StoredAsset[]): Promise<void>;
75
+ /** Deletes assets by path; paths it does not have are ignored. */
54
76
  deleteAssets(projectId: string, paths: string[]): Promise<void>;
77
+ /** A project's saved scene, or null when it was never saved. */
55
78
  loadScene(projectId: string): Promise<StoredScene | null>;
79
+ /** Replaces a project's saved scene. */
56
80
  saveScene(projectId: string, scene: StoredScene): Promise<void>;
81
+ /** How much storage projects use. */
57
82
  estimate(): Promise<StorageEstimate>;
58
83
  /** Asks the browser to keep the data even under storage pressure; resolves to the result. */
59
84
  requestPersistence(): Promise<boolean>;
60
85
  }
86
+ /** A byte count for people: `512 B`, `1.5 KB`, `20 MB`; `—` when unknown. */
61
87
  export declare function formatBytes(bytes: number | null | undefined): string;
@@ -1,3 +1,4 @@
1
+ /** A byte count for people: `512 B`, `1.5 KB`, `20 MB`; `—` when unknown. */
1
2
  export function formatBytes(bytes) {
2
3
  if (bytes == null)
3
4
  return '—';
@@ -9,12 +9,15 @@ import { EffectBinding } from './binding.js';
9
9
  * that are edited separately.
10
10
  */
11
11
  export interface SceneEntry {
12
+ /** The instance's name in the Scene list, unique in the scene. */
12
13
  name: string;
13
14
  /** Path of the asset it came from, or a synthetic `_created/…` path for new effects. */
14
15
  path: string;
15
16
  /** Asset this instance was made from, if any. */
16
17
  assetId: number | null;
18
+ /** The instance's root node. */
17
19
  root: TransformNode;
20
+ /** Every particle system of the instance. */
18
21
  systems: ParticleSystem[];
19
22
  }
20
23
  /** `name`, or `name (2)`, `name (3)`… when an entry already uses it. */
@@ -1,6 +1,6 @@
1
1
  import type { BatchedRenderer } from 'babylon.quarks';
2
2
  import type { EffectBinding } from './binding.js';
3
- /** Unpauses every system in the focused effect. */
3
+ /** Unpauses every system in the focused effect; one that has finished stays finished. */
4
4
  export declare function playFocus(binding: EffectBinding): void;
5
5
  /** Freezes the focused effect at its current simulation state. */
6
6
  export declare function pauseFocus(binding: EffectBinding): void;
@@ -2,10 +2,10 @@ const WIDE_STEP_THRESHOLD = 8;
2
2
  function bindingSystems(binding) {
3
3
  return [binding.system, ...binding.subSystems];
4
4
  }
5
- /** Unpauses every system in the focused effect. */
5
+ /** Unpauses every system in the focused effect; one that has finished stays finished. */
6
6
  export function playFocus(binding) {
7
7
  for (const system of bindingSystems(binding)) {
8
- system.play();
8
+ system.resume();
9
9
  }
10
10
  }
11
11
  /** Freezes the focused effect at its current simulation state. */
@@ -1,22 +1,41 @@
1
1
  import type { Mesh } from '@babylonjs/core/Meshes/mesh.js';
2
2
  import type { EmitterShape } from 'babylon.quarks';
3
3
  import { BoxEmitFrom, EmitterMode } from 'babylon.quarks';
4
+ /** The emitter shapes the Shape module offers, by the `type` they serialise with. */
4
5
  export type ShapeType = 'point' | 'sphere' | 'hemisphere' | 'cone' | 'circle' | 'donut' | 'rectangle' | 'grid' | 'box' | 'edge' | 'mesh_surface';
6
+ /** The Shape module's shape list, in menu order, with the label each shows. */
5
7
  export declare const SHAPE_TYPES: Array<{
8
+ /** The shape's type. */
6
9
  value: ShapeType;
10
+ /** Its label in the menu. */
7
11
  label: string;
8
12
  }>;
13
+ /**
14
+ * Every shape's settings in one flat record, so switching shapes keeps what the shapes share
15
+ * (a cone's radius becomes the sphere's). Each shape reads the fields it has.
16
+ */
9
17
  export interface ShapeParams {
18
+ /** Radius of a sphere, hemisphere, cone, circle or donut. */
10
19
  radius: number;
20
+ /** The part of the circle emitted from, in radians (2π: all of it). */
11
21
  arc: number;
22
+ /** 0 emits from the surface only, 1 from the whole volume. */
12
23
  thickness: number;
24
+ /** A cone's half angle, in radians. */
13
25
  angle: number;
26
+ /** The radius of a donut's tube. */
14
27
  donutRadius: number;
28
+ /** Width of a rectangle, grid or box (X). */
15
29
  width: number;
30
+ /** Height of a rectangle, grid or box (Y). */
16
31
  height: number;
32
+ /** How points around the arc are picked: at random, in a loop, back and forth or in bursts. */
17
33
  mode: EmitterMode;
34
+ /** Snaps the arc position to steps of this fraction; 0 for none. */
18
35
  spread: number;
36
+ /** A grid's column count. */
19
37
  column: number;
38
+ /** A grid's row count. */
20
39
  row: number;
21
40
  /** Box depth (Z). */
22
41
  depth: number;
@@ -24,14 +43,19 @@ export interface ShapeParams {
24
43
  emitFrom: BoxEmitFrom;
25
44
  /** How fast an edge emitter's loop / ping-pong point travels, in lengths per second. */
26
45
  speed: number;
46
+ /** The mesh a mesh surface emitter emits from. */
27
47
  mesh?: Mesh;
28
48
  }
49
+ /** The settings a new shape starts from. */
29
50
  export declare const DEFAULT_SHAPE_PARAMS: ShapeParams;
51
+ /** The type of a shape, as the Shape module lists it. */
30
52
  export declare function getShapeType(shape: EmitterShape): ShapeType;
53
+ /** A shape's settings, the fields it does not have taken from {@link DEFAULT_SHAPE_PARAMS}. */
31
54
  export declare function readShapeParams(shape: EmitterShape): ShapeParams;
32
55
  /** Which parameters are relevant per shape type (drives the UI). `mesh_surface`'s mesh
33
56
  * reference isn't a NumberField, so it's handled separately by the Shape module. */
34
57
  export declare const SHAPE_PARAM_KEYS: {
35
58
  [K in ShapeType]: Array<keyof ShapeParams>;
36
59
  };
60
+ /** A new shape of `type`, built from the fields of `params` it has. */
37
61
  export declare function createShape(type: ShapeType, params: ShapeParams): EmitterShape;
@@ -1,4 +1,5 @@
1
1
  import { BoxEmitFrom, BoxEmitter, CircleEmitter, ConeEmitter, ConstantValue, DonutEmitter, EdgeEmitter, EmitterMode, GridEmitter, HemisphereEmitter, MeshSurfaceEmitter, PointEmitter, RectangleEmitter, SphereEmitter, } from 'babylon.quarks';
2
+ /** The Shape module's shape list, in menu order, with the label each shows. */
2
3
  export const SHAPE_TYPES = [
3
4
  { value: 'cone', label: 'Cone' },
4
5
  { value: 'sphere', label: 'Sphere' },
@@ -12,6 +13,7 @@ export const SHAPE_TYPES = [
12
13
  { value: 'mesh_surface', label: 'Mesh surface' },
13
14
  { value: 'point', label: 'Point' },
14
15
  ];
16
+ /** The settings a new shape starts from. */
15
17
  export const DEFAULT_SHAPE_PARAMS = {
16
18
  radius: 0.3,
17
19
  arc: Math.PI * 2,
@@ -29,10 +31,12 @@ export const DEFAULT_SHAPE_PARAMS = {
29
31
  speed: 1,
30
32
  mesh: undefined,
31
33
  };
34
+ /** The type of a shape, as the Shape module lists it. */
32
35
  export function getShapeType(shape) {
33
36
  const type = shape.type ?? 'point';
34
37
  return (SHAPE_TYPES.some((s) => s.value === type) ? type : 'point');
35
38
  }
39
+ /** A shape's settings, the fields it does not have taken from {@link DEFAULT_SHAPE_PARAMS}. */
36
40
  export function readShapeParams(shape) {
37
41
  const anyShape = shape;
38
42
  const num = (key, fallback) => typeof anyShape[key] === 'number' ? anyShape[key] : fallback;
@@ -69,6 +73,7 @@ export const SHAPE_PARAM_KEYS = {
69
73
  edge: ['radius', 'speed'],
70
74
  mesh_surface: [],
71
75
  };
76
+ /** A new shape of `type`, built from the fields of `params` it has. */
72
77
  export function createShape(type, params) {
73
78
  switch (type) {
74
79
  case 'point':
@@ -1,7 +1,9 @@
1
1
  import type { TransformNode } from '@babylonjs/core/Meshes/transformNode.js';
2
2
  import { ParticleSystem } from 'babylon.quarks';
3
3
  import type { EffectBinding } from './binding.js';
4
+ /** How {@link createChildSystem} builds a new system. */
4
5
  export interface ChildSystemOptions {
6
+ /** The new emitter's name. */
5
7
  name?: string;
6
8
  /** One-shot burst (sub-emitter target) instead of a looping stream. */
7
9
  oneShot?: boolean;
@@ -43,7 +43,9 @@ export function unlinkSubEmitterReferences(systems, removed) {
43
43
  const behaviors = system.behaviors;
44
44
  for (let i = behaviors.length - 1; i >= 0; i--) {
45
45
  const behavior = behaviors[i];
46
- if (behavior.type === 'EmitSubParticleSystem' && removedEmitters.has(behavior.subParticleSystem)) {
46
+ if (behavior.type === 'EmitSubParticleSystem' &&
47
+ behavior.subParticleSystem &&
48
+ removedEmitters.has(behavior.subParticleSystem)) {
47
49
  behaviors.splice(i, 1);
48
50
  }
49
51
  }
@@ -1,24 +1,44 @@
1
1
  import type { TransformNode } from '@babylonjs/core/Meshes/transformNode.js';
2
2
  import type { FunctionValueGenerator, ParticleSystem, ValueGenerator } from 'babylon.quarks';
3
3
  import type { EffectBinding } from './binding.js';
4
- export type TimelineRow = {
4
+ /** A timeline row for a group node: a heading over the tracks of the systems under it. */
5
+ export interface TimelineGroupRow {
6
+ /** Tells group rows from track rows. */
5
7
  kind: 'group';
8
+ /** The group's node. */
6
9
  node: TransformNode;
10
+ /** The group's name. */
7
11
  name: string;
12
+ /** How deep the group sits in the effect tree; the root's children are 0. */
8
13
  depth: number;
9
- } | {
14
+ }
15
+ /** A timeline row for one particle system: a bar from its start delay over its duration. */
16
+ export interface TimelineSystemRow {
17
+ /** Tells group rows from track rows. */
10
18
  kind: 'track';
19
+ /** The system's emitter node. */
11
20
  node: TransformNode;
21
+ /** The system. */
12
22
  system: ParticleSystem;
23
+ /** The emitter's name. */
13
24
  name: string;
25
+ /** How deep the emitter sits in the effect tree. */
14
26
  depth: number;
27
+ /** True for the effect's main system. */
15
28
  isRoot: boolean;
29
+ /** False for the one system an effect cannot lose. */
16
30
  removable: boolean;
31
+ /** Where the bar starts: the start delay, its lower end when random, in seconds. */
17
32
  startOffset: number;
33
+ /** True when the start delay is a curve and the bar's start is only indicative. */
18
34
  startOffsetVariable: boolean;
35
+ /** The bar's length, the system's duration in seconds. */
19
36
  duration: number;
37
+ /** True when the system loops; its bar runs to the end of the ruler. */
20
38
  looping: boolean;
21
- };
39
+ }
40
+ /** One row of the focused effect's timeline. */
41
+ export type TimelineRow = TimelineGroupRow | TimelineSystemRow;
22
42
  /**
23
43
  * Reads a representative start-delay value for display without invoking the generator's
24
44
  * stateful `genValue` (IntervalValue caches its sampled slot on first call and returns NaN
@@ -1,27 +1,44 @@
1
- import type { FunctionValueGenerator, ValueGenerator } from 'babylon.quarks';
1
+ import type { FunctionValueGenerator, RotationGenerator, ValueGenerator, Vector3Generator } from 'babylon.quarks';
2
2
  import { PiecewiseBezier } from 'babylon.quarks';
3
+ /** A generator of one number: a constant or random value, or a curve over the particle's life. */
3
4
  export type ScalarGenerator = ValueGenerator | FunctionValueGenerator;
5
+ /** Any generator a value field can be pointed at; ones that are not scalar read as the default. */
6
+ export type AnyGenerator = ScalarGenerator | Vector3Generator | RotationGenerator;
7
+ /** How a value field produces its number: Unity's Constant, Random Between Two Constants or Curve. */
4
8
  export type ScalarMode = 'constant' | 'random' | 'curve';
5
9
  /** Editable snapshot of a scalar value generator. */
6
10
  export interface ScalarValueState {
11
+ /** Which of the fields below is the value. */
7
12
  mode: ScalarMode;
8
13
  /** Constant value (mode: constant). */
9
14
  value: number;
10
- /** Random range (mode: random). */
15
+ /** Lower end of the random range (mode: random). */
11
16
  min: number;
17
+ /** Upper end of the random range (mode: random). */
12
18
  max: number;
13
19
  /** Cubic bezier control values over normalized lifetime (mode: curve). */
14
20
  curve: [number, number, number, number];
15
21
  }
16
- export declare function readScalar(generator: ScalarGenerator | undefined): ScalarValueState;
22
+ /**
23
+ * What a value field shows for `generator`: its constant, its range or its first curve segment.
24
+ * Anything else, including a missing generator, reads as the constant 1.
25
+ */
26
+ export declare function readScalar(generator: AnyGenerator | undefined): ScalarValueState;
27
+ /** The generator a value field's state describes; a curve state builds a one-segment curve. */
28
+ export declare function buildScalar(state: ScalarValueState & {
29
+ mode: 'curve';
30
+ }): PiecewiseBezier;
17
31
  export declare function buildScalar(state: ScalarValueState): ScalarGenerator;
18
32
  /** One segment of a piecewise bezier curve: start x (0..1) + four control values. */
19
33
  export interface CurvePiece {
34
+ /** Where the segment starts, 0..1 over the particle's life. */
20
35
  start: number;
36
+ /** The segment's four bezier control values. */
21
37
  p: [number, number, number, number];
22
38
  }
23
39
  /** Reads pieces from a PiecewiseBezier (or synthesizes one segment for other generators). */
24
- export declare function readPieces(generator: ScalarGenerator | undefined): CurvePiece[];
40
+ export declare function readPieces(generator: AnyGenerator | undefined): CurvePiece[];
41
+ /** A piecewise bezier from segments, sorted by their start. */
25
42
  export declare function buildCurve(pieces: CurvePiece[]): PiecewiseBezier;
26
43
  /** Splits the piece containing x into two exact halves using Bezier.split. */
27
44
  export declare function splitPieces(pieces: CurvePiece[], x: number): CurvePiece[];
@@ -1,4 +1,8 @@
1
1
  import { Bezier, ConstantValue, IntervalValue, PiecewiseBezier } from 'babylon.quarks';
2
+ /**
3
+ * What a value field shows for `generator`: its constant, its range or its first curve segment.
4
+ * Anything else, including a missing generator, reads as the constant 1.
5
+ */
2
6
  export function readScalar(generator) {
3
7
  const state = { mode: 'constant', value: 1, min: 0.5, max: 1.5, curve: [0, 1, 1, 0] };
4
8
  if (generator instanceof ConstantValue) {
@@ -44,6 +48,7 @@ export function readPieces(generator) {
44
48
  const fallback = readScalar(generator);
45
49
  return [{ start: 0, p: fallback.curve }];
46
50
  }
51
+ /** A piecewise bezier from segments, sorted by their start. */
47
52
  export function buildCurve(pieces) {
48
53
  const sorted = [...pieces].sort((a, b) => a.start - b.start);
49
54
  return new PiecewiseBezier(sorted.map((piece) => [new Bezier(...piece.p), piece.start]));
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export type { AssetLoadProgress, EffectAsset } from './core/assets.js';
2
+ export type { AssetDragPayload } from './core/assetTree.js';
1
3
  export { EffectBinding } from './core/binding.js';
2
4
  export type { EditorListener } from './core/binding.js';
3
5
  export { GroundPlaneResolver, ensureGroundResolver } from './core/collision.js';
@@ -12,10 +14,12 @@ export { applyRendererMaterial, getMaterialLabel } from './core/material.js';
12
14
  export type { RendererMaterialPatch } from './core/material.js';
13
15
  export { formatBytes } from './core/projectStore.js';
14
16
  export type { ProjectMeta, ProjectStore, StorageEstimate, StoredAsset, StoredScene, StoredSceneEntry, } from './core/projectStore.js';
17
+ export type { SceneEntry } from './core/sceneEntries.js';
15
18
  export { DEFAULT_SHAPE_PARAMS, SHAPE_PARAM_KEYS, SHAPE_TYPES, createShape, getShapeType, readShapeParams, } from './core/shapes.js';
16
19
  export type { ShapeParams, ShapeType } from './core/shapes.js';
17
20
  export { createChildSystem } from './core/systems.js';
18
21
  export type { ChildSystemOptions } from './core/systems.js';
19
22
  export { ensurePortableTextureUrl } from './core/textureExport.js';
23
+ export type { TimelineGroupRow, TimelineRow, TimelineSystemRow } from './core/timeline.js';
20
24
  export { buildCurve, buildScalar, mergePieces, readPieces, readScalar, sampleCurve, splitPieces } from './core/values.js';
21
- export type { CurvePiece, ScalarGenerator, ScalarMode, ScalarValueState } from './core/values.js';
25
+ export type { AnyGenerator, CurvePiece, ScalarGenerator, ScalarMode, ScalarValueState } from './core/values.js';