babylon.quarks-editor 0.26.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 (211) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/README.md +69 -9
  3. package/dist/core/assetDragSession.d.ts +1 -1
  4. package/dist/core/assetTree.d.ts +6 -1
  5. package/dist/core/assets.d.ts +7 -0
  6. package/dist/core/assets.js +11 -7
  7. package/dist/core/binding.d.ts +11 -2
  8. package/dist/core/binding.js +9 -1
  9. package/dist/core/collision.d.ts +4 -0
  10. package/dist/core/collision.js +4 -0
  11. package/dist/core/colors.d.ts +16 -0
  12. package/dist/core/colors.js +8 -0
  13. package/dist/core/defaultEffect.d.ts +5 -4
  14. package/dist/core/defaultEffect.js +4 -4
  15. package/dist/core/editorScene.d.ts +1 -1
  16. package/dist/core/editorSession.d.ts +229 -0
  17. package/dist/core/editorSession.js +983 -0
  18. package/dist/core/effectTree.d.ts +6 -1
  19. package/dist/core/effectTree.js +13 -88
  20. package/dist/core/emitterShapeWireframe.d.ts +2 -2
  21. package/dist/core/emitterShapeWireframe.js +45 -13
  22. package/dist/core/galleryDropMarker.d.ts +2 -2
  23. package/dist/core/galleryDropMarker.js +6 -6
  24. package/dist/core/galleryLayout.d.ts +3 -3
  25. package/dist/core/galleryLayout.js +1 -1
  26. package/dist/core/galleryPlayback.d.ts +1 -1
  27. package/dist/core/galleryPlayback.js +2 -1
  28. package/dist/core/galleryScene.d.ts +4 -4
  29. package/dist/core/galleryScene.js +3 -3
  30. package/dist/core/gallerySelectionMarker.d.ts +4 -4
  31. package/dist/core/gallerySelectionMarker.js +5 -5
  32. package/dist/core/groups.d.ts +1 -1
  33. package/dist/core/groups.js +1 -1
  34. package/dist/core/history.d.ts +7 -1
  35. package/dist/core/history.js +4 -0
  36. package/dist/core/indexedDbProjectStore.d.ts +14 -1
  37. package/dist/core/indexedDbProjectStore.js +13 -0
  38. package/dist/core/lineShaders.d.ts +2 -2
  39. package/dist/core/lineShaders.js +2 -2
  40. package/dist/core/loadEffect.d.ts +2 -2
  41. package/dist/core/loadEffect.js +1 -1
  42. package/dist/core/material.d.ts +12 -2
  43. package/dist/core/pickAssetFiles.js +1 -1
  44. package/dist/core/playback.d.ts +6 -0
  45. package/dist/core/projectStore.d.ts +26 -0
  46. package/dist/core/projectStore.js +1 -0
  47. package/dist/core/sceneEntries.d.ts +7 -4
  48. package/dist/core/sceneEntries.js +2 -2
  49. package/dist/core/scrub.d.ts +2 -2
  50. package/dist/core/scrub.js +2 -2
  51. package/dist/core/shapes.d.ts +25 -1
  52. package/dist/core/shapes.js +5 -0
  53. package/dist/core/systems.d.ts +4 -2
  54. package/dist/core/systems.js +3 -1
  55. package/dist/core/textureExport.d.ts +1 -1
  56. package/dist/core/timeline.d.ts +25 -5
  57. package/dist/core/transport.d.ts +3 -3
  58. package/dist/core/transport.js +2 -2
  59. package/dist/core/values.d.ts +21 -4
  60. package/dist/core/values.js +5 -0
  61. package/dist/core/viewportPicker.d.ts +4 -4
  62. package/dist/core/viewportPicker.js +8 -7
  63. package/dist/index.d.ts +25 -21
  64. package/dist/index.js +12 -12
  65. package/dist/react/AssetsPanel.d.ts +9 -2
  66. package/dist/react/AssetsPanel.js +6 -6
  67. package/dist/react/ChoiceDialog.d.ts +7 -0
  68. package/dist/react/ChoiceDialog.js +1 -1
  69. package/dist/react/ContextMenu.d.ts +10 -1
  70. package/dist/react/ContextMenu.js +1 -1
  71. package/dist/react/CurveEditor.d.ts +1 -1
  72. package/dist/react/CurveEditor.js +2 -2
  73. package/dist/react/EditorWorkspace.d.ts +9 -2
  74. package/dist/react/EditorWorkspace.js +10 -7
  75. package/dist/react/EffectEditor.d.ts +11 -5
  76. package/dist/react/EffectEditor.js +7 -7
  77. package/dist/react/EffectEditorHost.d.ts +33 -29
  78. package/dist/react/EffectEditorHost.js +247 -1674
  79. package/dist/react/EffectTreeView.d.ts +4 -1
  80. package/dist/react/EffectTreeView.js +3 -3
  81. package/dist/react/GradientEditor.d.ts +1 -1
  82. package/dist/react/GradientEditor.js +3 -3
  83. package/dist/react/InspectorInfoIcon.js +3 -3
  84. package/dist/react/InspectorLabel.js +3 -3
  85. package/dist/react/MessageDialog.d.ts +5 -0
  86. package/dist/react/MessageDialog.js +1 -1
  87. package/dist/react/ModuleSection.d.ts +10 -0
  88. package/dist/react/ModuleSection.js +8 -5
  89. package/dist/react/ObjectModule.d.ts +1 -1
  90. package/dist/react/ObjectModule.js +4 -4
  91. package/dist/react/ProjectsPage.d.ts +7 -1
  92. package/dist/react/ProjectsPage.js +33 -17
  93. package/dist/react/PromptDialog.d.ts +7 -0
  94. package/dist/react/PromptDialog.js +1 -1
  95. package/dist/react/ScenePanel.d.ts +9 -2
  96. package/dist/react/ScenePanel.js +12 -10
  97. package/dist/react/SubEmittersModule.d.ts +1 -1
  98. package/dist/react/SubEmittersModule.js +5 -5
  99. package/dist/react/TextureSelect.d.ts +24 -0
  100. package/dist/react/TextureSelect.js +74 -0
  101. package/dist/react/TextureUVField.d.ts +14 -0
  102. package/dist/react/TextureUVField.js +23 -0
  103. package/dist/react/TimelinePanel.d.ts +20 -7
  104. package/dist/react/TimelinePanel.js +21 -15
  105. package/dist/react/TimelineTrackRow.d.ts +13 -3
  106. package/dist/react/TimelineTrackRow.js +6 -6
  107. package/dist/react/TransportBar.d.ts +13 -4
  108. package/dist/react/TransportBar.js +3 -3
  109. package/dist/react/ValueField.d.ts +32 -5
  110. package/dist/react/ValueField.js +22 -11
  111. package/dist/react/behaviorModules.d.ts +19 -6
  112. package/dist/react/behaviorModules.js +68 -17
  113. package/dist/react/fields.d.ts +9 -0
  114. package/dist/react/fields.js +6 -3
  115. package/dist/react/host/BottomDocks.d.ts +36 -0
  116. package/dist/react/host/BottomDocks.js +63 -0
  117. package/dist/react/host/HostDialogs.d.ts +50 -0
  118. package/dist/react/host/HostDialogs.js +113 -0
  119. package/dist/react/host/InspectorSidebar.d.ts +32 -0
  120. package/dist/react/host/InspectorSidebar.js +59 -0
  121. package/dist/react/host/SceneSidebar.d.ts +53 -0
  122. package/dist/react/host/SceneSidebar.js +62 -0
  123. package/dist/react/host/ViewportPane.d.ts +56 -0
  124. package/dist/react/host/ViewportPane.js +91 -0
  125. package/dist/react/host/hostHooks.d.ts +44 -0
  126. package/dist/react/host/hostHooks.js +164 -0
  127. package/dist/react/host/hostStyles.d.ts +21 -0
  128. package/dist/react/host/hostStyles.js +57 -0
  129. package/dist/react/index.d.ts +42 -38
  130. package/dist/react/index.js +25 -23
  131. package/dist/react/inspectorHints.js +31 -0
  132. package/dist/react/modules.d.ts +19 -6
  133. package/dist/react/modules.js +134 -117
  134. package/dist/react/theme.d.ts +15 -0
  135. package/dist/react/theme.js +15 -0
  136. package/dist/session.d.ts +9 -0
  137. package/dist/session.js +8 -0
  138. package/package.json +18 -11
  139. package/src/core/assetDragSession.ts +1 -1
  140. package/src/core/assetTree.ts +15 -2
  141. package/src/core/assets.ts +25 -10
  142. package/src/core/binding.ts +12 -3
  143. package/src/core/collision.ts +4 -0
  144. package/src/core/colors.ts +21 -1
  145. package/src/core/defaultEffect.ts +8 -7
  146. package/src/core/editorScene.ts +1 -1
  147. package/src/core/editorSession.ts +1299 -0
  148. package/src/core/effectTree.ts +18 -101
  149. package/src/core/emitterShapeWireframe.ts +48 -16
  150. package/src/core/galleryDropMarker.ts +8 -8
  151. package/src/core/galleryLayout.ts +4 -4
  152. package/src/core/galleryPlayback.ts +3 -2
  153. package/src/core/galleryScene.ts +5 -5
  154. package/src/core/gallerySelectionMarker.ts +7 -7
  155. package/src/core/groups.ts +1 -1
  156. package/src/core/history.ts +7 -1
  157. package/src/core/indexedDbProjectStore.ts +14 -1
  158. package/src/core/lineShaders.ts +2 -2
  159. package/src/core/loadEffect.ts +4 -4
  160. package/src/core/material.ts +14 -4
  161. package/src/core/pickAssetFiles.ts +2 -2
  162. package/src/core/playback.ts +6 -0
  163. package/src/core/projectStore.ts +26 -0
  164. package/src/core/sceneEntries.ts +8 -5
  165. package/src/core/scrub.ts +3 -3
  166. package/src/core/shapes.ts +29 -2
  167. package/src/core/systems.ts +11 -4
  168. package/src/core/textureExport.ts +1 -1
  169. package/src/core/timeline.ts +43 -18
  170. package/src/core/transport.ts +4 -4
  171. package/src/core/values.ts +20 -4
  172. package/src/core/viewportPicker.ts +12 -11
  173. package/src/index.ts +25 -21
  174. package/src/react/AssetsPanel.tsx +13 -6
  175. package/src/react/ChoiceDialog.tsx +8 -1
  176. package/src/react/ContextMenu.tsx +11 -2
  177. package/src/react/CurveEditor.tsx +2 -2
  178. package/src/react/EditorWorkspace.tsx +16 -10
  179. package/src/react/EffectEditor.tsx +17 -9
  180. package/src/react/EffectEditorHost.tsx +415 -2354
  181. package/src/react/EffectTreeView.tsx +7 -4
  182. package/src/react/GradientEditor.tsx +3 -3
  183. package/src/react/InspectorInfoIcon.tsx +3 -3
  184. package/src/react/InspectorLabel.tsx +3 -3
  185. package/src/react/MessageDialog.tsx +6 -1
  186. package/src/react/ModuleSection.tsx +15 -4
  187. package/src/react/ObjectModule.tsx +5 -5
  188. package/src/react/ProjectsPage.tsx +44 -17
  189. package/src/react/PromptDialog.tsx +8 -1
  190. package/src/react/ScenePanel.tsx +21 -12
  191. package/src/react/SubEmittersModule.tsx +6 -6
  192. package/src/react/TextureSelect.tsx +118 -0
  193. package/src/react/TextureUVField.tsx +62 -0
  194. package/src/react/TimelinePanel.tsx +40 -21
  195. package/src/react/TimelineTrackRow.tsx +19 -9
  196. package/src/react/TransportBar.tsx +16 -7
  197. package/src/react/ValueField.tsx +60 -16
  198. package/src/react/behaviorModules.tsx +240 -55
  199. package/src/react/fields.tsx +22 -4
  200. package/src/react/host/BottomDocks.tsx +178 -0
  201. package/src/react/host/HostDialogs.tsx +228 -0
  202. package/src/react/host/InspectorSidebar.tsx +147 -0
  203. package/src/react/host/SceneSidebar.tsx +227 -0
  204. package/src/react/host/ViewportPane.tsx +300 -0
  205. package/src/react/host/hostHooks.ts +198 -0
  206. package/src/react/host/hostStyles.ts +65 -0
  207. package/src/react/index.ts +43 -38
  208. package/src/react/inspectorHints.ts +40 -0
  209. package/src/react/modules.tsx +440 -170
  210. package/src/react/theme.ts +15 -0
  211. package/src/session.ts +17 -0
@@ -1,4 +1,4 @@
1
- import type {TransformNode} from '@babylonjs/core/Meshes/transformNode';
1
+ import type {TransformNode} from '@babylonjs/core/Meshes/transformNode.js';
2
2
  import {
3
3
  CheckIcon,
4
4
  ChevronDownIcon,
@@ -13,14 +13,14 @@ import {
13
13
  } from '@heroicons/react/24/solid';
14
14
  import type {ParticleSystem} from 'babylon.quarks';
15
15
  import React, {useState} from 'react';
16
- import type {EffectBinding} from '../core/binding';
17
- import {buildEffectTree, collectSystems} from '../core/effectTree';
18
- import {ungroupNode} from '../core/groups';
19
- import {createChildSystem, removeSystems} from '../core/systems';
20
- import type {TimelineRow} from '../core/timeline';
21
- import {PromptDialog} from './PromptDialog';
22
- import {iconStyle} from './icons';
23
- import {theme} from './theme';
16
+ import type {EffectBinding} from '../core/binding.js';
17
+ import {buildEffectTree, collectSystems} from '../core/effectTree.js';
18
+ import {ungroupNode} from '../core/groups.js';
19
+ import {createChildSystem, removeSystems} from '../core/systems.js';
20
+ import type {TimelineRow} from '../core/timeline.js';
21
+ import {PromptDialog} from './PromptDialog.js';
22
+ import {iconStyle} from './icons.js';
23
+ import {theme} from './theme.js';
24
24
 
25
25
  const iconButton: React.CSSProperties = {
26
26
  background: 'none',
@@ -34,21 +34,31 @@ const iconButton: React.CSSProperties = {
34
34
 
35
35
  const ROW_HEIGHT = 28;
36
36
 
37
+ /** Props of {@link TimelineTrackRow}. */
37
38
  export interface TimelineTrackRowProps {
39
+ /** The group or track the row shows. */
38
40
  row: TimelineRow;
41
+ /** The focused effect, edited by the row's actions. */
39
42
  binding: EffectBinding;
43
+ /** The row's node is the one in the inspector. */
40
44
  selected: boolean;
45
+ /** Selects the row's node. */
41
46
  onSelectNode: (node: TransformNode | null) => void;
47
+ /** The ruler's scale, pixels per second. */
42
48
  pxPerSecond: number;
43
49
  /** Matches the ruler's left gutter so bars line up under the correct tick. */
44
50
  offsetPx: number;
51
+ /** A group row's children are hidden. */
45
52
  collapsed: boolean;
53
+ /** Collapses or expands a group row. */
46
54
  onToggleCollapse?: () => void;
47
55
  /** Preview-only visibility (toggles `system.emitter.visible`); lets you isolate one track. */
48
56
  hidden?: boolean;
57
+ /** Shows or hides the track in the preview. */
49
58
  onToggleVisible?: () => void;
50
59
  /** Membership in the "group selected rows together" set (unrelated to inspector selection). */
51
60
  groupSelected: boolean;
61
+ /** Adds the row to the set, or takes it out. */
52
62
  onToggleGroupSelect: () => void;
53
63
  }
54
64
 
@@ -1,23 +1,32 @@
1
- import type {Scene} from '@babylonjs/core/scene';
1
+ import type {Scene} from '@babylonjs/core/scene.js';
2
2
  import {ArrowPathIcon, ForwardIcon, PauseIcon, PlayIcon} from '@heroicons/react/24/solid';
3
3
  import type {BatchedRenderer} from 'babylon.quarks';
4
4
  import React from 'react';
5
- import type {EffectBinding} from '../core/binding';
6
- import type {PlaybackState} from '../core/playback';
7
- import {PLAYBACK_SPEEDS, restartFocusPlayback, toggleStagePlayback} from '../core/transport';
8
- import {iconStyle} from './icons';
9
- import {buttonStyle, theme} from './theme';
5
+ import type {EffectBinding} from '../core/binding.js';
6
+ import type {PlaybackState} from '../core/playback.js';
7
+ import {PLAYBACK_SPEEDS, restartFocusPlayback, toggleStagePlayback} from '../core/transport.js';
8
+ import {iconStyle} from './icons.js';
9
+ import {buttonStyle, theme} from './theme.js';
10
10
 
11
+ /** Props of {@link TransportBar}. */
11
12
  export interface TransportBarProps {
13
+ /** The focused effect, which Restart and Step act on. */
12
14
  binding: EffectBinding | null;
15
+ /** The preview scene, redrawn after a restart. */
13
16
  scene: Scene;
17
+ /** The renderer the effects draw through. */
14
18
  renderer: BatchedRenderer;
19
+ /** Playback state shared with the host's render loop. */
15
20
  playbackRef: React.MutableRefObject<PlaybackState>;
16
21
  /** The host's render loop writes time and particle count here. */
17
- counterRef: React.RefObject<HTMLSpanElement>;
22
+ counterRef: React.RefObject<HTMLSpanElement | null>;
23
+ /** The stage is playing. */
18
24
  stagePlaying: boolean;
25
+ /** Plays or pauses the stage. */
19
26
  setStagePlaying: (playing: boolean) => void;
27
+ /** Playback speed, 1 for real time. */
20
28
  speed: number;
29
+ /** Sets the playback speed. */
21
30
  setSpeed: (speed: number) => void;
22
31
  /** False when the focused effect is hidden. */
23
32
  enabled: boolean;
@@ -1,28 +1,72 @@
1
+ import type {ValueGenerator} from 'babylon.quarks';
1
2
  import React from 'react';
2
- import {ScalarGenerator, ScalarValueState, buildCurve, buildScalar, readPieces, readScalar} from '../core/values';
3
- import {CurveEditor} from './CurveEditor';
4
- import {NumberField, Row, SelectField} from './fields';
3
+ import {
4
+ AnyGenerator,
5
+ ScalarGenerator,
6
+ ScalarValueState,
7
+ buildCurve,
8
+ buildScalar,
9
+ readPieces,
10
+ readScalar,
11
+ } from '../core/values.js';
12
+ import {CurveEditor} from './CurveEditor.js';
13
+ import {NumberField, Row, SelectField} from './fields.js';
5
14
 
6
- /**
7
- * Unity-like value field: Constant | Random Between Two Constants | Curve,
8
- * bound to a quarks value generator.
9
- */
10
15
  const captionStyle: React.CSSProperties = {fontSize: 10.5, opacity: 0.6, flex: 'none'};
11
16
 
12
- export function ValueField(props: {
17
+ /** Props every {@link ValueField} takes. */
18
+ interface ValueFieldBaseProps {
19
+ /** The row's label. */
13
20
  label: string;
21
+ /** Tooltip text of the label. */
14
22
  hint?: string;
23
+ /** Key into the inspector hints, used when `hint` is not given. */
15
24
  hintKey?: string;
16
- generator: ScalarGenerator | undefined;
17
- onChange: (generator: ScalarGenerator) => void;
25
+ /** The generator shown; one that is not a scalar reads as the constant 1. */
26
+ generator: AnyGenerator | undefined;
27
+ /** Smallest value the number fields accept. */
18
28
  min?: number;
29
+ /** Top of the curve editor's value range. */
19
30
  curveMax?: number;
20
- }) {
21
- const state = readScalar(props.generator);
31
+ }
32
+
33
+ /** A value field for a setting that takes a curve over the particle's life. */
34
+ export interface CurveValueFieldProps extends ValueFieldBaseProps {
35
+ /** Offers Curve beside Constant and Random (the default). */
36
+ curve?: true;
37
+ /** Receives the edited generator. */
38
+ onChange: (generator: ScalarGenerator) => void;
39
+ }
40
+
41
+ /** A value field for a setting sampled once, without a curve: Constant or Random. */
42
+ export interface ConstantValueFieldProps extends ValueFieldBaseProps {
43
+ /** Hides Curve: the setting takes no curve. */
44
+ curve: false;
45
+ /** Receives the edited generator. */
46
+ onChange: (generator: ValueGenerator) => void;
47
+ }
48
+
49
+ function isValueGenerator(generator: ScalarGenerator): generator is ValueGenerator {
50
+ return generator.type === 'value';
51
+ }
52
+
53
+ /**
54
+ * Unity-like value field: Constant | Random Between Two Constants | Curve, bound to a quarks value
55
+ * generator. With `curve={false}` it offers only the first two, for settings sampled once.
56
+ */
57
+ export function ValueField(props: CurveValueFieldProps | ConstantValueFieldProps): React.ReactElement {
58
+ const read = readScalar(props.generator);
59
+ // A setting without curves shows a curve it was loaded with as a constant, so an edit replaces it.
60
+ const state: ScalarValueState = props.curve === false && read.mode === 'curve' ? {...read, mode: 'constant'} : read;
22
61
 
23
- const commit = (patch: Partial<ScalarValueState>) => {
24
- props.onChange(buildScalar({...state, ...patch}));
62
+ const emit = (generator: ScalarGenerator) => {
63
+ if (props.curve !== false) {
64
+ props.onChange(generator);
65
+ } else if (isValueGenerator(generator)) {
66
+ props.onChange(generator);
67
+ }
25
68
  };
69
+ const commit = (patch: Partial<ScalarValueState>) => emit(buildScalar({...state, ...patch}));
26
70
 
27
71
  return (
28
72
  <>
@@ -32,7 +76,7 @@ export function ValueField(props: {
32
76
  options={[
33
77
  {value: 'constant', label: 'Constant'},
34
78
  {value: 'random', label: 'Random between two'},
35
- {value: 'curve', label: 'Curve'},
79
+ ...(props.curve !== false ? [{value: 'curve' as const, label: 'Curve'}] : []),
36
80
  ]}
37
81
  onChange={(mode) => commit({mode})}
38
82
  />
@@ -57,7 +101,7 @@ export function ValueField(props: {
57
101
  <CurveEditor
58
102
  pieces={readPieces(props.generator)}
59
103
  maxValue={props.curveMax}
60
- onChange={(pieces) => props.onChange(buildCurve(pieces))}
104
+ onChange={(pieces) => emit(buildCurve(pieces))}
61
105
  />
62
106
  </div>
63
107
  )}