babylon.quarks-editor 0.28.0 → 0.30.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 (48) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +1 -1
  3. package/dist/core/collision.d.ts +2 -2
  4. package/dist/core/collision.js +3 -1
  5. package/dist/core/colors.d.ts +1 -8
  6. package/dist/core/colors.js +4 -10
  7. package/dist/core/defaultEffect.js +4 -2
  8. package/dist/core/editorSession.d.ts +0 -2
  9. package/dist/core/editorSession.js +0 -1
  10. package/dist/core/emitterShapeWireframe.js +11 -4
  11. package/dist/core/loadEffect.js +2 -0
  12. package/dist/core/shapes.d.ts +7 -1
  13. package/dist/core/shapes.js +13 -3
  14. package/dist/core/systems.js +6 -4
  15. package/dist/core/values.d.ts +23 -6
  16. package/dist/core/values.js +47 -9
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/react/AxesCurveField.d.ts +21 -0
  20. package/dist/react/AxesCurveField.js +25 -0
  21. package/dist/react/LifeCurveField.d.ts +18 -0
  22. package/dist/react/LifeCurveField.js +26 -0
  23. package/dist/react/ValueField.d.ts +4 -4
  24. package/dist/react/ValueField.js +20 -6
  25. package/dist/react/behaviorModules.js +23 -20
  26. package/dist/react/index.d.ts +11 -1
  27. package/dist/react/inspectorHints.js +1 -1
  28. package/dist/react/modules.js +60 -29
  29. package/dist/session.d.ts +8 -0
  30. package/package.json +2 -2
  31. package/src/core/collision.ts +5 -3
  32. package/src/core/colors.ts +4 -11
  33. package/src/core/defaultEffect.ts +3 -2
  34. package/src/core/editorSession.ts +0 -3
  35. package/src/core/emitterShapeWireframe.ts +12 -4
  36. package/src/core/loadEffect.ts +2 -0
  37. package/src/core/shapes.ts +20 -2
  38. package/src/core/systems.ts +8 -6
  39. package/src/core/values.ts +73 -12
  40. package/src/index.ts +0 -1
  41. package/src/react/AxesCurveField.tsx +72 -0
  42. package/src/react/LifeCurveField.tsx +57 -0
  43. package/src/react/ValueField.tsx +46 -6
  44. package/src/react/behaviorModules.tsx +45 -35
  45. package/src/react/index.ts +19 -1
  46. package/src/react/inspectorHints.ts +1 -1
  47. package/src/react/modules.tsx +149 -51
  48. package/src/session.ts +16 -0
@@ -28,18 +28,20 @@ import {
28
28
  SpeedOverLife,
29
29
  TextureSequencer,
30
30
  TurbulenceField,
31
- Vector3,
31
+ Vector3Function,
32
32
  VelocityOverLife,
33
33
  WidthOverLength,
34
+ type Vector3Like,
34
35
  } from 'babylon.quarks';
35
36
  import React from 'react';
36
37
  import {EffectBinding} from '../core/binding.js';
37
38
  import {buildGradient, DEFAULT_GRADIENT_STOPS, findBehavior, readGradientStops} from '../core/colors.js';
38
- import {buildCurve, buildScalar, readPieces, readScalar} from '../core/values.js';
39
- import {CurveEditor} from './CurveEditor.js';
39
+ import {buildScalar, readScalar} from '../core/values.js';
40
+ import {AxesCurveField} from './AxesCurveField.js';
40
41
  import {CheckboxField, NumberField, Row, SelectField} from './fields.js';
41
42
  import {GradientEditor} from './GradientEditor.js';
42
43
  import {iconStyle} from './icons.js';
44
+ import {LifeCurveField} from './LifeCurveField.js';
43
45
  import type {TextureOption} from './modules.js';
44
46
  import {ModuleSection, type ModuleProps} from './ModuleSection.js';
45
47
  import {theme} from './theme.js';
@@ -94,10 +96,10 @@ export function SpeedOverLifeModule({binding}: ModuleProps) {
94
96
  >
95
97
  {(behavior) => (
96
98
  <div style={{marginTop: 6}}>
97
- <CurveEditor
98
- pieces={readPieces(behavior.speed)}
99
+ <LifeCurveField
100
+ generator={behavior.speed}
99
101
  maxValue={2}
100
- onChange={(pieces) => binding.apply(() => (behavior.speed = buildCurve(pieces)))}
102
+ onChange={(curve) => binding.apply(() => (behavior.speed = curve))}
101
103
  />
102
104
  </div>
103
105
  )}
@@ -119,12 +121,24 @@ export function LimitSpeedOverLifeModule({binding}: ModuleProps) {
119
121
  {(behavior) => (
120
122
  <>
121
123
  <div style={{marginTop: 6}}>
122
- <CurveEditor
123
- pieces={readPieces(behavior.speed)}
124
+ <AxesCurveField
125
+ generator={behavior.speed}
124
126
  maxValue={8}
125
- onChange={(pieces) => binding.apply(() => (behavior.speed = buildCurve(pieces)))}
127
+ onChange={(speed) => binding.apply(() => (behavior.speed = speed))}
126
128
  />
127
129
  </div>
130
+ {behavior.speed instanceof Vector3Function && (
131
+ <Row label="Space" hint="The axes each limit is measured along: the emitter's or the world's.">
132
+ <SelectField
133
+ value={behavior.space}
134
+ options={[
135
+ {value: 'local', label: 'Local'},
136
+ {value: 'world', label: 'World'},
137
+ ]}
138
+ onChange={(v) => binding.apply(() => (behavior.space = v))}
139
+ />
140
+ </Row>
141
+ )}
128
142
  <Row label="Dampen">
129
143
  <NumberField
130
144
  value={behavior.dampen}
@@ -299,7 +313,7 @@ export function AttractorModule({binding}: ModuleProps) {
299
313
  binding={binding}
300
314
  title="Attractor"
301
315
  type="GravityForce"
302
- create={() => new GravityForce(new Vector3(0, 0, 0), 1)}
316
+ create={() => new GravityForce({x: 0, y: 0, z: 0}, 1)}
303
317
  >
304
318
  {(behavior) => (
305
319
  <>
@@ -335,7 +349,7 @@ export function GravityModule({binding}: ModuleProps) {
335
349
  binding={binding}
336
350
  title="Gravity"
337
351
  type="ApplyForce"
338
- create={() => new ApplyForce(new Vector3(0, -1, 0), new ConstantValue(9.81))}
352
+ create={() => new ApplyForce({x: 0, y: -1, z: 0}, new ConstantValue(9.81))}
339
353
  >
340
354
  {(behavior) => (
341
355
  <>
@@ -392,7 +406,7 @@ export function Rotation3DOverLifeModule({binding}: ModuleProps) {
392
406
  title="Rotation over Lifetime (3D)"
393
407
  type="Rotation3DOverLife"
394
408
  create={() =>
395
- new Rotation3DOverLife(new AxisAngleGenerator(new Vector3(0, 1, 0), new ConstantValue(Math.PI)))
409
+ new Rotation3DOverLife(new AxisAngleGenerator({x: 0, y: 1, z: 0}, new ConstantValue(Math.PI)))
396
410
  }
397
411
  >
398
412
  {(behavior) => {
@@ -422,10 +436,7 @@ export function Rotation3DOverLifeModule({binding}: ModuleProps) {
422
436
  binding.apply(() => {
423
437
  behavior.angularVelocity =
424
438
  next === 'axisAngle'
425
- ? new AxisAngleGenerator(
426
- new Vector3(0, 1, 0),
427
- new ConstantValue(Math.PI)
428
- )
439
+ ? new AxisAngleGenerator({x: 0, y: 1, z: 0}, new ConstantValue(Math.PI))
429
440
  : next === 'euler'
430
441
  ? new EulerGenerator(
431
442
  new ConstantValue(0),
@@ -511,7 +522,7 @@ export function SequencesModule({binding, textureOptions}: ModuleProps & {textur
511
522
  image.crossOrigin = 'anonymous';
512
523
  image.src = imageUrl;
513
524
  await image.decode();
514
- const sequencer = new TextureSequencer(0.05, 0.05, new Vector3());
525
+ const sequencer = new TextureSequencer(0.05, 0.05, {x: 0, y: 0, z: 0});
515
526
  sequencer.fromImage(image, threshold);
516
527
  const last = behavior.sequencers[behavior.sequencers.length - 1];
517
528
  const start = last ? last[0].b : 0;
@@ -602,7 +613,7 @@ export function SequencesModule({binding, textureOptions}: ModuleProps & {textur
602
613
  label="Position"
603
614
  value={texture.position}
604
615
  step={0.1}
605
- onChange={(v) => binding.apply(() => texture.position.copy(v))}
616
+ onChange={(v) => binding.apply(() => (texture.position = v))}
606
617
  />
607
618
  </>
608
619
  )}
@@ -725,19 +736,18 @@ export function NoiseModule({binding}: ModuleProps) {
725
736
  );
726
737
  }
727
738
 
728
- /** Three numeric inputs for a Vector3 field, replacing the whole vector on any edit. */
739
+ /** Three numeric inputs for a vector field, replacing the whole vector on any edit. */
729
740
  function Vector3Row(props: {
730
741
  label: string;
731
742
  hintKey?: string;
732
- value: Vector3;
743
+ value: Vector3Like;
733
744
  min?: number;
734
745
  step?: number;
735
- onChange: (v: Vector3) => void;
746
+ onChange: (v: Vector3Like) => void;
736
747
  }) {
737
748
  const set = (axis: 'x' | 'y' | 'z', n: number) => {
738
- const next = props.value.clone();
739
- next[axis] = n;
740
- props.onChange(next);
749
+ const {x, y, z} = props.value;
750
+ props.onChange({x, y, z, [axis]: n});
741
751
  };
742
752
  return (
743
753
  <Row label={props.label} hintKey={props.hintKey}>
@@ -757,7 +767,7 @@ export function TurbulenceModule({binding}: ModuleProps) {
757
767
  binding={binding}
758
768
  title="Turbulence"
759
769
  type="TurbulenceField"
760
- create={() => new TurbulenceField(new Vector3(1, 1, 1), 3, new Vector3(1, 1, 1), new Vector3(1, 1, 1))}
770
+ create={() => new TurbulenceField({x: 1, y: 1, z: 1}, 3, {x: 1, y: 1, z: 1}, {x: 1, y: 1, z: 1})}
761
771
  >
762
772
  {(behavior) => (
763
773
  <>
@@ -942,10 +952,10 @@ export function SizeBySpeedModule({binding}: ModuleProps) {
942
952
  {(behavior) => (
943
953
  <>
944
954
  <div style={{marginTop: 6}}>
945
- <CurveEditor
946
- pieces={readPieces(behavior.size)}
955
+ <AxesCurveField
956
+ generator={behavior.size}
947
957
  maxValue={2}
948
- onChange={(pieces) => binding.apply(() => (behavior.size = buildCurve(pieces)))}
958
+ onChange={(size) => binding.apply(() => (behavior.size = size))}
949
959
  />
950
960
  </div>
951
961
  <SpeedRangeRows binding={binding} behavior={behavior} />
@@ -987,7 +997,7 @@ export function OrbitOverLifeModule({binding}: ModuleProps) {
987
997
  binding={binding}
988
998
  title="Orbit over Lifetime"
989
999
  type="OrbitOverLife"
990
- create={() => new OrbitOverLife(new ConstantValue(Math.PI), new Vector3(0, 1, 0))}
1000
+ create={() => new OrbitOverLife(new ConstantValue(Math.PI), {x: 0, y: 1, z: 0})}
991
1001
  >
992
1002
  {(behavior) => (
993
1003
  <ValueField
@@ -1015,10 +1025,10 @@ export function WidthOverTrailModule({binding}: ModuleProps) {
1015
1025
  {(behavior) => (
1016
1026
  <>
1017
1027
  <div style={{marginTop: 6}}>
1018
- <CurveEditor
1019
- pieces={readPieces(behavior.width)}
1028
+ <LifeCurveField
1029
+ generator={behavior.width}
1020
1030
  maxValue={2}
1021
- onChange={(pieces) => binding.apply(() => (behavior.width = buildCurve(pieces)))}
1031
+ onChange={(curve) => binding.apply(() => (behavior.width = curve))}
1022
1032
  />
1023
1033
  </div>
1024
1034
  {/* Off: the curve multiplies the particle size. On: it is the width in world units (files from 0.21 and earlier). */}
@@ -1265,10 +1275,10 @@ export function TextureSheetModule({binding}: ModuleProps) {
1265
1275
  )}
1266
1276
  </Row>
1267
1277
  <div style={{marginTop: 6}}>
1268
- <CurveEditor
1269
- pieces={readPieces(frameBehavior.frame)}
1278
+ <LifeCurveField
1279
+ generator={frameBehavior.frame}
1270
1280
  maxValue={Math.max(1, tiles - 1)}
1271
- onChange={(pieces) => binding.apply(() => (frameBehavior.frame = buildCurve(pieces)))}
1281
+ onChange={(curve) => binding.apply(() => (frameBehavior.frame = curve))}
1272
1282
  />
1273
1283
  </div>
1274
1284
  </>
@@ -63,4 +63,22 @@ export type {TimelineTrackRowProps} from './TimelineTrackRow.js';
63
63
  export {TransportBar} from './TransportBar.js';
64
64
  export type {TransportBarProps} from './TransportBar.js';
65
65
  export {ValueField} from './ValueField.js';
66
- export type {ConstantValueFieldProps, CurveValueFieldProps} from './ValueField.js';
66
+ export type {ConstantValueFieldProps, CurveValueFieldProps, ValueFieldBaseProps} from './ValueField.js';
67
+ // The core types the components' props use, so a host can name them from this entry point too.
68
+ export type {AssetLoadProgress, EffectAsset} from '../core/assets.js';
69
+ export type {AssetDragPayload} from '../core/assetTree.js';
70
+ export type {EditorListener, EffectBinding} from '../core/binding.js';
71
+ export type {GradientStop} from '../core/colors.js';
72
+ export type {EffectTreeNode} from '../core/effectTree.js';
73
+ export type {EffectHistory, HistoryStacks} from '../core/history.js';
74
+ export type {
75
+ ProjectMeta,
76
+ ProjectStore,
77
+ StorageEstimate,
78
+ StoredAsset,
79
+ StoredScene,
80
+ StoredSceneEntry,
81
+ } from '../core/projectStore.js';
82
+ export type {SceneEntry} from '../core/sceneEntries.js';
83
+ export type {TimelineGroupRow, TimelineRow, TimelineSystemRow} from '../core/timeline.js';
84
+ export type {AnyGenerator, CurvePiece, ScalarGenerator} from '../core/values.js';
@@ -33,7 +33,7 @@ const INSPECTOR_HINTS: Record<string, string> = {
33
33
  Looping: 'When enabled, the effect restarts from the beginning after duration ends.',
34
34
  'World space': 'Simulates in world coordinates so moving the emitter does not drag existing particles.',
35
35
  'Scaling mode':
36
- 'What the emitter’s scale does to a world-space system: only the shape and sizes, or speeds and forces too (Unity’s Scaling Mode).',
36
+ 'Which scale reaches the effect (Unity’s Scaling Mode): Local, the emitter’s own; Hierarchy, its parents’ too; Shape, the whole scale on the emission shape alone.',
37
37
  Prewarm: 'Simulates the effect once at start so it already looks mid-playback when play begins.',
38
38
  'Warm-up time':
39
39
  'Seconds of the cycle simulated before the first frame of a looping system (Niagara’s Warmup Time); 0 warms up a whole cycle, as Unity does.',
@@ -20,21 +20,22 @@ import {
20
20
  BoxEmitFrom,
21
21
  ColorOverLife,
22
22
  ColorRange,
23
+ ConeEmitFrom,
23
24
  ConstantColor,
24
25
  ConstantValue,
25
26
  EulerGenerator,
26
27
  Gradient,
28
+ GridSampling,
27
29
  IntervalValue,
28
30
  RandomColor,
29
31
  RandomColorBetweenGradient,
30
32
  RandomQuatGenerator,
31
33
  RenderMode,
32
34
  SizeOverLife,
33
- Vector2,
34
- Vector3,
35
35
  Vector3Function,
36
- Vector4,
37
36
  normalizeTextureUV,
37
+ type Color4Like,
38
+ type Vector3Like,
38
39
  } from 'babylon.quarks';
39
40
  import React, {useMemo} from 'react';
40
41
  import {
@@ -56,8 +57,8 @@ import {
56
57
  getShapeType,
57
58
  readShapeParams,
58
59
  } from '../core/shapes.js';
59
- import {buildCurve, buildScalar, readPieces, readScalar} from '../core/values.js';
60
- import {CurveEditor} from './CurveEditor.js';
60
+ import {buildCurve, buildScalar, readScalar} from '../core/values.js';
61
+ import {AxesCurveField} from './AxesCurveField.js';
61
62
  import {GradientEditor} from './GradientEditor.js';
62
63
  import {InspectorInfoIcon} from './InspectorInfoIcon.js';
63
64
  import {ModuleSection, type ModuleProps} from './ModuleSection.js';
@@ -113,6 +114,7 @@ const PARAM_LABELS: {[key: string]: string} = {
113
114
  column: 'Columns',
114
115
  row: 'Rows',
115
116
  depth: 'Depth',
117
+ length: 'Length',
116
118
  speed: 'Speed (lengths/s)',
117
119
  };
118
120
 
@@ -139,8 +141,14 @@ function SubHeader(props: {title: string; hint: string}) {
139
141
  );
140
142
  }
141
143
 
142
- /** Three number inputs editing a Vector3 by value. */
143
- function AxisField(props: {value: Vector3; onChange: (next: Vector3) => void}) {
144
+ /** `v` scaled to length 1, or `v` itself when it has no length. */
145
+ function unitOrZero(v: Vector3Like): Vector3Like {
146
+ const length = Math.hypot(v.x, v.y, v.z);
147
+ return length > 0 ? {x: v.x / length, y: v.y / length, z: v.z / length} : v;
148
+ }
149
+
150
+ /** Three number inputs editing a vector by value: each edit hands over a new `{x, y, z}`. */
151
+ function AxisField(props: {value: Vector3Like; onChange: (next: Vector3Like) => void}) {
144
152
  return (
145
153
  <div style={{display: 'flex', gap: 6}}>
146
154
  {(['x', 'y', 'z'] as const).map((axis) => (
@@ -149,9 +157,8 @@ function AxisField(props: {value: Vector3; onChange: (next: Vector3) => void}) {
149
157
  value={props.value[axis]}
150
158
  step={0.1}
151
159
  onChange={(v) => {
152
- const next = props.value.clone();
153
- next[axis] = v;
154
- props.onChange(next);
160
+ const {x, y, z} = props.value;
161
+ props.onChange({x, y, z, [axis]: v});
155
162
  }}
156
163
  />
157
164
  ))}
@@ -159,17 +166,17 @@ function AxisField(props: {value: Vector3; onChange: (next: Vector3) => void}) {
159
166
  );
160
167
  }
161
168
 
162
- function ColorInput(props: {value: Vector4; onChange: (next: Vector4) => void}) {
169
+ function ColorInput(props: {value: Color4Like; onChange: (next: Color4Like) => void}) {
163
170
  const {value, onChange} = props;
164
171
  return (
165
172
  <div style={{display: 'flex', gap: 6, alignItems: 'center'}}>
166
173
  <input
167
174
  type="color"
168
175
  className="qe-hover"
169
- value={rgbToHex(value.x, value.y, value.z)}
176
+ value={rgbToHex(value.r, value.g, value.b)}
170
177
  onChange={(e) => {
171
178
  const rgb = hexToRgb(e.target.value);
172
- onChange(new Vector4(rgb.r, rgb.g, rgb.b, value.w));
179
+ onChange({r: rgb.r, g: rgb.g, b: rgb.b, a: value.a});
173
180
  }}
174
181
  style={{
175
182
  width: 42,
@@ -181,10 +188,10 @@ function ColorInput(props: {value: Vector4; onChange: (next: Vector4) => void})
181
188
  }}
182
189
  />
183
190
  <NumberField
184
- value={value.w}
191
+ value={value.a}
185
192
  min={0}
186
193
  step={0.05}
187
- onChange={(a) => onChange(new Vector4(value.x, value.y, value.z, Math.min(1, a)))}
194
+ onChange={(a) => onChange({r: value.r, g: value.g, b: value.b, a: Math.min(1, a)})}
188
195
  />
189
196
  </div>
190
197
  );
@@ -201,11 +208,11 @@ export function MainModule({binding}: ModuleProps) {
201
208
  ? twoColor.a
202
209
  : startColor instanceof ConstantColor
203
210
  ? startColor.color
204
- : new Vector4(1, 1, 1, 1);
205
- const colorB = twoColor ? twoColor.b : new Vector4(1, 0.5, 0.2, 1);
211
+ : {r: 1, g: 1, b: 1, a: 1};
212
+ const colorB: Color4Like = twoColor ? twoColor.b : {r: 1, g: 0.5, b: 0.2, a: 1};
206
213
  const twoColors = twoColor !== null;
207
214
  /** The two-colour generator of the current mode. */
208
- const makeTwoColors = (a: Vector4, b: Vector4) =>
215
+ const makeTwoColors = (a: Color4Like, b: Color4Like) =>
209
216
  colorMode === 'range' ? new ColorRange(a, b) : new RandomColor(a, b);
210
217
  const rotation = system.startRotation;
211
218
  const isEuler = rotation instanceof EulerGenerator;
@@ -260,18 +267,17 @@ export function MainModule({binding}: ModuleProps) {
260
267
  <Row label="World space">
261
268
  <CheckboxField value={system.worldSpace} onChange={(v) => binding.apply((s) => (s.worldSpace = v))} />
262
269
  </Row>
263
- {system.worldSpace && (
264
- <Row label="Scaling mode">
265
- <SelectField<ScalingMode>
266
- value={system.scalingMode}
267
- options={[
268
- {value: 'shape', label: 'Shape (sizes and shape only)'},
269
- {value: 'hierarchy', label: 'Hierarchy (motion scales too)'},
270
- ]}
271
- onChange={(mode) => binding.apply((s) => (s.scalingMode = mode))}
272
- />
273
- </Row>
274
- )}
270
+ <Row label="Scaling mode">
271
+ <SelectField<ScalingMode>
272
+ value={system.scalingMode}
273
+ options={[
274
+ {value: 'local', label: 'Local (own scale only)'},
275
+ {value: 'hierarchy', label: 'Hierarchy (parents too)'},
276
+ {value: 'shape', label: 'Shape (shape only)'},
277
+ ]}
278
+ onChange={(mode) => binding.apply((s) => (s.scalingMode = mode))}
279
+ />
280
+ </Row>
275
281
  <Row label="Prewarm">
276
282
  <CheckboxField value={system.prewarm} onChange={(v) => binding.apply((s) => (s.prewarm = v))} />
277
283
  </Row>
@@ -318,6 +324,20 @@ export function MainModule({binding}: ModuleProps) {
318
324
  onChange={(mode) => binding.apply((s) => (s.cullingMode = mode as CullingMode))}
319
325
  />
320
326
  </Row>
327
+ <Row
328
+ label="Stop action"
329
+ hint="What the system does once it has finished, as Unity's Stop Action. The editor saves it but does not apply it, so previews replay."
330
+ >
331
+ <SelectField
332
+ value={system.stopAction}
333
+ options={[
334
+ {value: 'none', label: 'None'},
335
+ {value: 'disable', label: 'Disable'},
336
+ {value: 'destroy', label: 'Destroy'},
337
+ ]}
338
+ onChange={(v) => binding.apply((s) => (s.stopAction = v))}
339
+ />
340
+ </Row>
321
341
  <ValueField
322
342
  label="Start delay"
323
343
  generator={system.startDelay}
@@ -494,7 +514,7 @@ export function MainModule({binding}: ModuleProps) {
494
514
  ? new RandomQuatGenerator()
495
515
  : mode === 'axisAngle'
496
516
  ? new AxisAngleGenerator(
497
- new Vector3(0, 1, 0),
517
+ {x: 0, y: 1, z: 0},
498
518
  new ConstantValue(rotationState.value)
499
519
  )
500
520
  : mode === 'euler'
@@ -725,17 +745,20 @@ export function ShapeModule({binding}: ModuleProps) {
725
745
  onChange={(next) => binding.apply((s) => (s.emitterShape = createShape(next, params)))}
726
746
  />
727
747
  </Row>
728
- {keys.map((key) => (
729
- <Row key={key} label={PARAM_LABELS[key]}>
730
- <NumberField
731
- value={params[key] as number}
732
- min={0}
733
- onChange={(v) =>
734
- binding.apply((s) => (s.emitterShape = createShape(type, {...params, [key]: v})))
735
- }
736
- />
737
- </Row>
738
- ))}
748
+ {keys
749
+ // A cone's Length only shapes Emit from Volume; Unity shows it for Cone Volume alone.
750
+ .filter((key) => key !== 'length' || params.coneEmitFrom === ConeEmitFrom.Volume)
751
+ .map((key) => (
752
+ <Row key={key} label={PARAM_LABELS[key]}>
753
+ <NumberField
754
+ value={params[key] as number}
755
+ min={0}
756
+ onChange={(v) =>
757
+ binding.apply((s) => (s.emitterShape = createShape(type, {...params, [key]: v})))
758
+ }
759
+ />
760
+ </Row>
761
+ ))}
739
762
  {type === 'mesh_surface' && (
740
763
  <Row label="Source mesh">
741
764
  <SelectField
@@ -767,6 +790,34 @@ export function ShapeModule({binding}: ModuleProps) {
767
790
  />
768
791
  </Row>
769
792
  )}
793
+ {type === 'cone' && (
794
+ <Row label="Emit from">
795
+ <SelectField
796
+ value={params.coneEmitFrom}
797
+ options={[
798
+ {value: ConeEmitFrom.Base, label: 'Base'},
799
+ {value: ConeEmitFrom.Volume, label: 'Volume'},
800
+ ]}
801
+ onChange={(coneEmitFrom) =>
802
+ binding.apply((s) => (s.emitterShape = createShape(type, {...params, coneEmitFrom})))
803
+ }
804
+ />
805
+ </Row>
806
+ )}
807
+ {type === 'grid' && (
808
+ <Row label="Sampling">
809
+ <SelectField
810
+ value={params.sampling}
811
+ options={[
812
+ {value: GridSampling.Random, label: 'Random'},
813
+ {value: GridSampling.Sequential, label: 'Sequential'},
814
+ ]}
815
+ onChange={(sampling) =>
816
+ binding.apply((s) => (s.emitterShape = createShape(type, {...params, sampling})))
817
+ }
818
+ />
819
+ </Row>
820
+ )}
770
821
  {!SHAPES_WITHOUT_MODE_SPREAD.has(type) && (
771
822
  <>
772
823
  <Row label="Emit mode">
@@ -824,13 +875,13 @@ export function SizeOverLifeModule({binding}: ModuleProps) {
824
875
  }
825
876
  >
826
877
  <div style={{marginTop: 6}}>
827
- <CurveEditor
828
- pieces={behavior ? readPieces(behavior.size) : [{start: 0, p: curve}]}
878
+ <AxesCurveField
879
+ generator={behavior ? behavior.size : buildCurve([{start: 0, p: curve}])}
829
880
  maxValue={2}
830
- onChange={(pieces) =>
881
+ onChange={(size) =>
831
882
  binding.apply((s) => {
832
883
  removeBehavior(s, 'SizeOverLife');
833
- s.addBehavior(new SizeOverLife(buildCurve(pieces)));
884
+ s.addBehavior(new SizeOverLife(size));
834
885
  })
835
886
  }
836
887
  />
@@ -1173,7 +1224,7 @@ export function RendererModule({
1173
1224
  onChange={(v) =>
1174
1225
  binding.apply((s) => {
1175
1226
  (s.rendererEmitterSettings as TrailSettings).sideAxis = v
1176
- ? new Vector3(0, 1, 0)
1227
+ ? {x: 0, y: 1, z: 0}
1177
1228
  : undefined;
1178
1229
  })
1179
1230
  }
@@ -1186,8 +1237,7 @@ export function RendererModule({
1186
1237
  onChange={(axis) =>
1187
1238
  binding.apply((s) => {
1188
1239
  // The axis's length scales the width: keep it a unit vector.
1189
- (s.rendererEmitterSettings as TrailSettings).sideAxis =
1190
- axis.length() > 0 ? axis.normalize() : axis;
1240
+ (s.rendererEmitterSettings as TrailSettings).sideAxis = unitOrZero(axis);
1191
1241
  })
1192
1242
  }
1193
1243
  />
@@ -1271,7 +1321,7 @@ export function RendererModule({
1271
1321
  step={0.1}
1272
1322
  onChange={(v) =>
1273
1323
  binding.apply((s) => {
1274
- const next = s.flip?.clone() ?? new Vector2(0, 0);
1324
+ const next = {x: s.flip?.x ?? 0, y: s.flip?.y ?? 0};
1275
1325
  next[axis] = Math.min(1, Math.max(0, v));
1276
1326
  s.flip = next.x === 0 && next.y === 0 ? undefined : next;
1277
1327
  })
@@ -1629,6 +1679,48 @@ export function RendererModule({
1629
1679
  />
1630
1680
  )}
1631
1681
  </Row>
1682
+ {system.maxParticles !== undefined && system.renderMode !== RenderMode.Trail && (
1683
+ <Row
1684
+ label="Ring buffer"
1685
+ hint="What a full system does with new particles, as Unity's Ring Buffer Mode."
1686
+ >
1687
+ <SelectField
1688
+ value={system.ringBufferMode}
1689
+ options={[
1690
+ {value: 'disabled', label: 'Disabled'},
1691
+ {value: 'pauseUntilReplaced', label: 'Pause until replaced'},
1692
+ {value: 'loopUntilReplaced', label: 'Loop until replaced'},
1693
+ ]}
1694
+ onChange={(v) => binding.apply((s) => (s.ringBufferMode = v))}
1695
+ />
1696
+ </Row>
1697
+ )}
1698
+ {system.maxParticles !== undefined &&
1699
+ system.renderMode !== RenderMode.Trail &&
1700
+ system.ringBufferMode === 'loopUntilReplaced' && (
1701
+ <Row label="Loop range" hint="The part of its life a particle plays again, from 0 to 1.">
1702
+ <div style={{display: 'flex', gap: 6}}>
1703
+ {(['x', 'y'] as const).map((end) => (
1704
+ <NumberField
1705
+ key={end}
1706
+ value={system.ringBufferLoopRange[end]}
1707
+ min={0}
1708
+ step={0.05}
1709
+ onChange={(v) =>
1710
+ binding.apply((s) => {
1711
+ const next = {x: s.ringBufferLoopRange.x, y: s.ringBufferLoopRange.y};
1712
+ next[end] = Math.min(1, Math.max(0, v));
1713
+ s.ringBufferLoopRange = {
1714
+ x: Math.min(next.x, next.y),
1715
+ y: Math.max(next.x, next.y),
1716
+ };
1717
+ })
1718
+ }
1719
+ />
1720
+ ))}
1721
+ </div>
1722
+ </Row>
1723
+ )}
1632
1724
  {system.renderMode !== RenderMode.Mesh && system.renderMode !== RenderMode.Trail && (
1633
1725
  <Row label="Pivot">
1634
1726
  <div style={{display: 'flex', gap: 6}}>
@@ -1639,7 +1731,7 @@ export function RendererModule({
1639
1731
  step={0.05}
1640
1732
  onChange={(v) =>
1641
1733
  binding.apply((s) => {
1642
- const next = (s.pivot ?? new Vector3()).clone();
1734
+ const next = {x: s.pivot?.x ?? 0, y: s.pivot?.y ?? 0, z: s.pivot?.z ?? 0};
1643
1735
  next[axis] = v;
1644
1736
  s.pivot = next;
1645
1737
  })
@@ -1730,6 +1822,12 @@ export function RendererModule({
1730
1822
  <Row label="Apply fog">
1731
1823
  <CheckboxField value={system.applyFog} onChange={(v) => binding.apply((s) => (s.applyFog = v))} />
1732
1824
  </Row>
1825
+ <Row label="Image processing">
1826
+ <CheckboxField
1827
+ value={system.applyImageProcessing}
1828
+ onChange={(v) => binding.apply((s) => (s.applyImageProcessing = v))}
1829
+ />
1830
+ </Row>
1733
1831
  <Row label="Soft particles">
1734
1832
  <CheckboxField
1735
1833
  value={system.softParticles}
package/src/session.ts CHANGED
@@ -15,3 +15,19 @@ export type {
15
15
  EffectEditorHostHandle,
16
16
  PrefabInfo,
17
17
  } from './core/editorSession.js';
18
+ // The types the session's own signatures use, so a host can name them from this entry point too.
19
+ export type {AssetLoadProgress, EffectAsset} from './core/assets.js';
20
+ export type {AssetDragPayload} from './core/assetTree.js';
21
+ export type {EditorListener, EffectBinding} from './core/binding.js';
22
+ export type {EffectTreeNode} from './core/effectTree.js';
23
+ export type {EffectHistory, HistoryStacks} from './core/history.js';
24
+ export type {PlaybackState} from './core/playback.js';
25
+ export type {
26
+ ProjectMeta,
27
+ ProjectStore,
28
+ StorageEstimate,
29
+ StoredAsset,
30
+ StoredScene,
31
+ StoredSceneEntry,
32
+ } from './core/projectStore.js';
33
+ export type {SceneEntry} from './core/sceneEntries.js';