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
@@ -1,5 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { buildCurve, buildScalar, readPieces, readScalar, } from '../core/values.js';
2
+ import { RandomBetweenCurves } from 'babylon.quarks';
3
+ import { buildCurve, buildScalar, readPieces, readScalar, withCurves, } from '../core/values.js';
3
4
  import { CurveEditor } from './CurveEditor.js';
4
5
  import { NumberField, Row, SelectField } from './fields.js';
5
6
  const captionStyle = { fontSize: 10.5, opacity: 0.6, flex: 'none' };
@@ -7,13 +8,15 @@ function isValueGenerator(generator) {
7
8
  return generator.type === 'value';
8
9
  }
9
10
  /**
10
- * Unity-like value field: Constant | Random Between Two Constants | Curve, bound to a quarks value
11
- * generator. With `curve={false}` it offers only the first two, for settings sampled once.
11
+ * Unity-like value field: Constant | Random Between Two Constants | Curve | Random Between Two
12
+ * Curves, bound to a quarks value generator. With `curve={false}` it offers only the first two,
13
+ * for settings sampled once.
12
14
  */
13
15
  export function ValueField(props) {
14
16
  const read = readScalar(props.generator);
15
17
  // A setting without curves shows a curve it was loaded with as a constant, so an edit replaces it.
16
- const state = props.curve === false && read.mode === 'curve' ? { ...read, mode: 'constant' } : read;
18
+ const curved = read.mode === 'curve' || read.mode === 'curves';
19
+ const state = props.curve === false && curved ? { ...read, mode: 'constant' } : read;
17
20
  const emit = (generator) => {
18
21
  if (props.curve !== false) {
19
22
  props.onChange(generator);
@@ -26,6 +29,17 @@ export function ValueField(props) {
26
29
  return (_jsxs(_Fragment, { children: [_jsx(Row, { label: props.label, hint: props.hint, hintKey: props.hintKey, children: _jsx(SelectField, { value: state.mode, options: [
27
30
  { value: 'constant', label: 'Constant' },
28
31
  { value: 'random', label: 'Random between two' },
29
- ...(props.curve !== false ? [{ value: 'curve', label: 'Curve' }] : []),
30
- ], onChange: (mode) => commit({ mode }) }) }), state.mode === 'constant' && (_jsx(Row, { label: "", children: _jsx(NumberField, { value: state.value, min: props.min, onChange: (value) => commit({ value }) }) })), state.mode === 'random' && (_jsx(Row, { label: "", children: _jsxs("div", { style: { display: 'flex', gap: 6, alignItems: 'center' }, children: [_jsx("span", { style: captionStyle, children: "min" }), _jsx(NumberField, { value: state.min, min: props.min, onChange: (min) => commit({ min }) }), _jsx("span", { style: captionStyle, children: "max" }), _jsx(NumberField, { value: state.max, min: props.min, onChange: (max) => commit({ max }) })] }) })), state.mode === 'curve' && (_jsx("div", { style: { marginTop: 6 }, children: _jsx(CurveEditor, { pieces: readPieces(props.generator), maxValue: props.curveMax, onChange: (pieces) => emit(buildCurve(pieces)) }) }))] }));
32
+ ...(props.curve !== false
33
+ ? [
34
+ { value: 'curve', label: 'Curve' },
35
+ { value: 'curves', label: 'Random between two curves' },
36
+ ]
37
+ : []),
38
+ ], onChange: (mode) =>
39
+ // Between one curve and two, every segment is kept; other switches start afresh.
40
+ (mode === 'curve' || mode === 'curves') && curved
41
+ ? emit(withCurves(props.generator, mode))
42
+ : commit({ mode }) }) }), state.mode === 'constant' && (_jsx(Row, { label: "", children: _jsx(NumberField, { value: state.value, min: props.min, onChange: (value) => commit({ value }) }) })), state.mode === 'random' && (_jsx(Row, { label: "", children: _jsxs("div", { style: { display: 'flex', gap: 6, alignItems: 'center' }, children: [_jsx("span", { style: captionStyle, children: "min" }), _jsx(NumberField, { value: state.min, min: props.min, onChange: (min) => commit({ min }) }), _jsx("span", { style: captionStyle, children: "max" }), _jsx(NumberField, { value: state.max, min: props.min, onChange: (max) => commit({ max }) })] }) })), state.mode === 'curve' && (_jsx("div", { style: { marginTop: 6 }, children: _jsx(CurveEditor, { pieces: readPieces(props.generator), maxValue: props.curveMax, onChange: (pieces) => emit(buildCurve(pieces)) }) })), state.mode === 'curves' && (_jsx(_Fragment, { children: ['lower', 'upper'].map((bound, index) => (_jsxs("div", { style: { marginTop: 6 }, children: [_jsx("span", { style: captionStyle, children: bound }), _jsx(CurveEditor, { pieces: readPieces(props.generator, index === 1), maxValue: props.curveMax, onChange: (pieces) => emit(index === 0
43
+ ? new RandomBetweenCurves(buildCurve(pieces), buildCurve(readPieces(props.generator, true)))
44
+ : new RandomBetweenCurves(buildCurve(readPieces(props.generator)), buildCurve(pieces))) })] }, bound))) }))] }));
31
45
  }
@@ -1,13 +1,14 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { PlusIcon, XMarkIcon } from '@heroicons/react/24/solid';
3
- import { ApplyCollision, ApplyForce, ApplySequences, AxisAngleGenerator, Bezier, ChangeEmitDirection, ColorBySpeed, ConstantValue, EulerGenerator, ForceOverLife, FrameOverLife, Gradient, GravityForce, InheritVelocity, IntervalValue, LimitSpeedOverLife, Noise, OrbitOverLife, PiecewiseBezier, RandomQuatGenerator, Rotation3DOverLife, RotationBySpeed, RotationOverLife, SizeBySpeed, SpeedOverLife, TextureSequencer, TurbulenceField, Vector3, VelocityOverLife, WidthOverLength, } from 'babylon.quarks';
3
+ import { ApplyCollision, ApplyForce, ApplySequences, AxisAngleGenerator, Bezier, ChangeEmitDirection, ColorBySpeed, ConstantValue, EulerGenerator, ForceOverLife, FrameOverLife, Gradient, GravityForce, InheritVelocity, IntervalValue, LimitSpeedOverLife, Noise, OrbitOverLife, PiecewiseBezier, RandomQuatGenerator, Rotation3DOverLife, RotationBySpeed, RotationOverLife, SizeBySpeed, SpeedOverLife, TextureSequencer, TurbulenceField, Vector3Function, VelocityOverLife, WidthOverLength, } from 'babylon.quarks';
4
4
  import React from 'react';
5
5
  import { buildGradient, DEFAULT_GRADIENT_STOPS, findBehavior, readGradientStops } from '../core/colors.js';
6
- import { buildCurve, buildScalar, readPieces, readScalar } from '../core/values.js';
7
- import { CurveEditor } from './CurveEditor.js';
6
+ import { buildScalar, readScalar } from '../core/values.js';
7
+ import { AxesCurveField } from './AxesCurveField.js';
8
8
  import { CheckboxField, NumberField, Row, SelectField } from './fields.js';
9
9
  import { GradientEditor } from './GradientEditor.js';
10
10
  import { iconStyle } from './icons.js';
11
+ import { LifeCurveField } from './LifeCurveField.js';
11
12
  import { ModuleSection } from './ModuleSection.js';
12
13
  import { theme } from './theme.js';
13
14
  import { ValueField } from './ValueField.js';
@@ -30,11 +31,14 @@ function BehaviorModule(props) {
30
31
  }
31
32
  /** The Speed over Lifetime module (Unity's Speed Modifier): scales speed by a curve over the particle's life. */
32
33
  export function SpeedOverLifeModule({ binding }) {
33
- return (_jsx(BehaviorModule, { binding: binding, title: "Speed over Lifetime", type: "SpeedOverLife", create: () => new SpeedOverLife(buildScalar({ mode: 'curve', value: 1, min: 0, max: 1, curve: [1, 0.75, 0.5, 0] })), children: (behavior) => (_jsx("div", { style: { marginTop: 6 }, children: _jsx(CurveEditor, { pieces: readPieces(behavior.speed), maxValue: 2, onChange: (pieces) => binding.apply(() => (behavior.speed = buildCurve(pieces))) }) })) }));
34
+ return (_jsx(BehaviorModule, { binding: binding, title: "Speed over Lifetime", type: "SpeedOverLife", create: () => new SpeedOverLife(buildScalar({ mode: 'curve', value: 1, min: 0, max: 1, curve: [1, 0.75, 0.5, 0] })), children: (behavior) => (_jsx("div", { style: { marginTop: 6 }, children: _jsx(LifeCurveField, { generator: behavior.speed, maxValue: 2, onChange: (curve) => binding.apply(() => (behavior.speed = curve)) }) })) }));
34
35
  }
35
36
  /** The Limit Speed over Lifetime module (Unity's Limit Velocity over Lifetime): caps speed by a curve, with dampening. */
36
37
  export function LimitSpeedOverLifeModule({ binding }) {
37
- return (_jsx(BehaviorModule, { binding: binding, title: "Limit Speed over Lifetime", type: "LimitSpeedOverLife", create: () => new LimitSpeedOverLife(buildScalar({ mode: 'curve', value: 1, min: 0, max: 1, curve: [4, 2, 1, 1] }), 0.5), children: (behavior) => (_jsxs(_Fragment, { children: [_jsx("div", { style: { marginTop: 6 }, children: _jsx(CurveEditor, { pieces: readPieces(behavior.speed), maxValue: 8, onChange: (pieces) => binding.apply(() => (behavior.speed = buildCurve(pieces))) }) }), _jsx(Row, { label: "Dampen", children: _jsx(NumberField, { value: behavior.dampen, min: 0, step: 0.05, onChange: (v) => binding.apply(() => (behavior.dampen = Math.min(1, v))) }) })] })) }));
38
+ return (_jsx(BehaviorModule, { binding: binding, title: "Limit Speed over Lifetime", type: "LimitSpeedOverLife", create: () => new LimitSpeedOverLife(buildScalar({ mode: 'curve', value: 1, min: 0, max: 1, curve: [4, 2, 1, 1] }), 0.5), children: (behavior) => (_jsxs(_Fragment, { children: [_jsx("div", { style: { marginTop: 6 }, children: _jsx(AxesCurveField, { generator: behavior.speed, maxValue: 8, onChange: (speed) => binding.apply(() => (behavior.speed = speed)) }) }), behavior.speed instanceof Vector3Function && (_jsx(Row, { label: "Space", hint: "The axes each limit is measured along: the emitter's or the world's.", children: _jsx(SelectField, { value: behavior.space, options: [
39
+ { value: 'local', label: 'Local' },
40
+ { value: 'world', label: 'World' },
41
+ ], onChange: (v) => binding.apply(() => (behavior.space = v)) }) })), _jsx(Row, { label: "Dampen", children: _jsx(NumberField, { value: behavior.dampen, min: 0, step: 0.05, onChange: (v) => binding.apply(() => (behavior.dampen = Math.min(1, v))) }) })] })) }));
38
42
  }
39
43
  /** The Force over Lifetime module (Unity's Force over Lifetime): a constant push per axis. */
40
44
  export function ForceOverLifeModule({ binding }) {
@@ -57,11 +61,11 @@ export function InheritVelocityModule({ binding }) {
57
61
  }
58
62
  /** A point attractor (`GravityForce`): particles fall towards a point, harder the nearer they are. */
59
63
  export function AttractorModule({ binding }) {
60
- return (_jsx(BehaviorModule, { binding: binding, title: "Attractor", type: "GravityForce", create: () => new GravityForce(new Vector3(0, 0, 0), 1), children: (behavior) => (_jsxs(_Fragment, { children: [_jsx(Row, { label: "Center", hintKey: "attractor.center", children: _jsx("div", { style: { display: 'flex', gap: 6 }, children: ['x', 'y', 'z'].map((axis) => (_jsx(NumberField, { value: behavior.center[axis], step: 0.1, onChange: (v) => binding.apply(() => (behavior.center[axis] = v)) }, axis))) }) }), _jsx(Row, { label: "Strength", hintKey: "attractor.magnitude", children: _jsx(NumberField, { value: behavior.magnitude, step: 0.1, onChange: (v) => binding.apply(() => (behavior.magnitude = v)) }) })] })) }));
64
+ return (_jsx(BehaviorModule, { binding: binding, title: "Attractor", type: "GravityForce", create: () => new GravityForce({ x: 0, y: 0, z: 0 }, 1), children: (behavior) => (_jsxs(_Fragment, { children: [_jsx(Row, { label: "Center", hintKey: "attractor.center", children: _jsx("div", { style: { display: 'flex', gap: 6 }, children: ['x', 'y', 'z'].map((axis) => (_jsx(NumberField, { value: behavior.center[axis], step: 0.1, onChange: (v) => binding.apply(() => (behavior.center[axis] = v)) }, axis))) }) }), _jsx(Row, { label: "Strength", hintKey: "attractor.magnitude", children: _jsx(NumberField, { value: behavior.magnitude, step: 0.1, onChange: (v) => binding.apply(() => (behavior.magnitude = v)) }) })] })) }));
61
65
  }
62
66
  /** The Gravity module: pulls particles towards a point. */
63
67
  export function GravityModule({ binding }) {
64
- return (_jsx(BehaviorModule, { binding: binding, title: "Gravity", type: "ApplyForce", create: () => new ApplyForce(new Vector3(0, -1, 0), new ConstantValue(9.81)), children: (behavior) => (_jsxs(_Fragment, { children: [_jsx(Row, { label: "Strength", hintKey: "gravity.strength", children: _jsx(NumberField, { value: readScalar(behavior.magnitude).value, step: 0.5, onChange: (v) => binding.apply(() => (behavior.magnitude = new ConstantValue(v))) }) }), _jsx(Row, { label: "Space", children: _jsx(SelectField, { value: behavior.space, options: [
68
+ return (_jsx(BehaviorModule, { binding: binding, title: "Gravity", type: "ApplyForce", create: () => new ApplyForce({ x: 0, y: -1, z: 0 }, new ConstantValue(9.81)), children: (behavior) => (_jsxs(_Fragment, { children: [_jsx(Row, { label: "Strength", hintKey: "gravity.strength", children: _jsx(NumberField, { value: readScalar(behavior.magnitude).value, step: 0.5, onChange: (v) => binding.apply(() => (behavior.magnitude = new ConstantValue(v))) }) }), _jsx(Row, { label: "Space", children: _jsx(SelectField, { value: behavior.space, options: [
65
69
  { value: 'world', label: 'World' },
66
70
  { value: 'local', label: 'Local' },
67
71
  ], onChange: (v) => binding.apply(() => (behavior.space = v)) }) })] })) }));
@@ -72,7 +76,7 @@ export function RotationOverLifeModule({ binding }) {
72
76
  }
73
77
  /** Turns mesh particles by a 3D angular velocity; billboards turn through Rotation over Lifetime. */
74
78
  export function Rotation3DOverLifeModule({ binding }) {
75
- return (_jsx(BehaviorModule, { binding: binding, title: "Rotation over Lifetime (3D)", type: "Rotation3DOverLife", create: () => new Rotation3DOverLife(new AxisAngleGenerator(new Vector3(0, 1, 0), new ConstantValue(Math.PI))), children: (behavior) => {
79
+ return (_jsx(BehaviorModule, { binding: binding, title: "Rotation over Lifetime (3D)", type: "Rotation3DOverLife", create: () => new Rotation3DOverLife(new AxisAngleGenerator({ x: 0, y: 1, z: 0 }, new ConstantValue(Math.PI))), children: (behavior) => {
76
80
  const generator = behavior.angularVelocity;
77
81
  const mode = generator instanceof AxisAngleGenerator
78
82
  ? 'axisAngle'
@@ -88,7 +92,7 @@ export function Rotation3DOverLifeModule({ binding }) {
88
92
  ], onChange: (next) => binding.apply(() => {
89
93
  behavior.angularVelocity =
90
94
  next === 'axisAngle'
91
- ? new AxisAngleGenerator(new Vector3(0, 1, 0), new ConstantValue(Math.PI))
95
+ ? new AxisAngleGenerator({ x: 0, y: 1, z: 0 }, new ConstantValue(Math.PI))
92
96
  : next === 'euler'
93
97
  ? new EulerGenerator(new ConstantValue(0), new ConstantValue(Math.PI), new ConstantValue(0))
94
98
  : new RandomQuatGenerator();
@@ -115,7 +119,7 @@ export function SequencesModule({ binding, textureOptions }) {
115
119
  image.crossOrigin = 'anonymous';
116
120
  image.src = imageUrl;
117
121
  await image.decode();
118
- const sequencer = new TextureSequencer(0.05, 0.05, new Vector3());
122
+ const sequencer = new TextureSequencer(0.05, 0.05, { x: 0, y: 0, z: 0 });
119
123
  sequencer.fromImage(image, threshold);
120
124
  const last = behavior.sequencers[behavior.sequencers.length - 1];
121
125
  const start = last ? last[0].b : 0;
@@ -139,7 +143,7 @@ export function SequencesModule({ binding, textureOptions }) {
139
143
  background: 'none',
140
144
  border: 'none',
141
145
  cursor: 'pointer',
142
- }, title: "Remove sequence", onClick: () => binding.apply(() => behavior.sequencers.splice(index, 1)), children: _jsx(XMarkIcon, { style: iconStyle(13) }) })] }), _jsx(Row, { label: "Time from / to (s)", children: pair(range.a, range.b, (v) => binding.apply(() => (range.a = v)), (v) => binding.apply(() => (range.b = v)), 0.1) }), texture.locations !== undefined && (_jsxs(_Fragment, { children: [_jsx(Row, { label: "Scale X / Y", children: pair(texture.scaleX, texture.scaleY, (v) => binding.apply(() => (texture.scaleX = v)), (v) => binding.apply(() => (texture.scaleY = v)), 0.01) }), _jsx(Vector3Row, { label: "Position", value: texture.position, step: 0.1, onChange: (v) => binding.apply(() => texture.position.copy(v)) })] }))] }, index));
146
+ }, title: "Remove sequence", onClick: () => binding.apply(() => behavior.sequencers.splice(index, 1)), children: _jsx(XMarkIcon, { style: iconStyle(13) }) })] }), _jsx(Row, { label: "Time from / to (s)", children: pair(range.a, range.b, (v) => binding.apply(() => (range.a = v)), (v) => binding.apply(() => (range.b = v)), 0.1) }), texture.locations !== undefined && (_jsxs(_Fragment, { children: [_jsx(Row, { label: "Scale X / Y", children: pair(texture.scaleX, texture.scaleY, (v) => binding.apply(() => (texture.scaleX = v)), (v) => binding.apply(() => (texture.scaleY = v)), 0.01) }), _jsx(Vector3Row, { label: "Position", value: texture.position, step: 0.1, onChange: (v) => binding.apply(() => (texture.position = v)) })] }))] }, index));
143
147
  }), _jsx(Row, { label: "Image", children: textureOptions && textureOptions.length > 0 ? (_jsx(SelectField, { value: imageUrl, options: textureOptions.map((option) => ({ value: option.url, label: option.label })), onChange: (url) => setImageUrl(url) })) : (_jsx("input", { className: "qe-hover", style: { flex: 1, minWidth: 0, fontSize: 12 }, placeholder: "Image URL", value: imageUrl, onChange: (event) => setImageUrl(event.target.value) })) }), _jsx(Row, { label: "Alpha threshold", children: _jsx(NumberField, { value: threshold, min: 0, step: 0.05, onChange: (v) => setThreshold(Math.min(1, v)) }) }), _jsxs("button", { className: "qe-hover", style: { display: 'flex', alignItems: 'center', gap: 4, marginTop: 6, fontSize: 12 }, onClick: () => void addFromImage(behavior), children: [_jsx(PlusIcon, { style: iconStyle(13) }), "Add sequence from image"] }), status && _jsx("p", { style: { margin: '4px 0 0', color: theme.textDim, fontSize: 11.5 }, children: status })] })) }));
144
148
  }
145
149
  /** The Noise module (Unity's Noise): moves and turns particles by a noise field. */
@@ -148,18 +152,17 @@ export function NoiseModule({ binding }) {
148
152
  ? new PiecewiseBezier([[new Bezier(-1, -1 / 3, 1 / 3, 1), 0]])
149
153
  : undefined)) }) }), behavior.remap !== undefined && (_jsx(ValueField, { label: "Remap curve", generator: behavior.remap, curveMax: 1, onChange: (g) => binding.apply(() => (behavior.remap = g)) }))] })) }));
150
154
  }
151
- /** Three numeric inputs for a Vector3 field, replacing the whole vector on any edit. */
155
+ /** Three numeric inputs for a vector field, replacing the whole vector on any edit. */
152
156
  function Vector3Row(props) {
153
157
  const set = (axis, n) => {
154
- const next = props.value.clone();
155
- next[axis] = n;
156
- props.onChange(next);
158
+ const { x, y, z } = props.value;
159
+ props.onChange({ x, y, z, [axis]: n });
157
160
  };
158
161
  return (_jsx(Row, { label: props.label, hintKey: props.hintKey, children: _jsxs("div", { style: { display: 'flex', gap: 6 }, children: [_jsx(NumberField, { value: props.value.x, min: props.min, step: props.step, onChange: (n) => set('x', n) }), _jsx(NumberField, { value: props.value.y, min: props.min, step: props.step, onChange: (n) => set('y', n) }), _jsx(NumberField, { value: props.value.z, min: props.min, step: props.step, onChange: (n) => set('z', n) })] }) }));
159
162
  }
160
163
  /** The Turbulence module: a curl noise force field. */
161
164
  export function TurbulenceModule({ binding }) {
162
- return (_jsx(BehaviorModule, { binding: binding, title: "Turbulence", type: "TurbulenceField", create: () => new TurbulenceField(new Vector3(1, 1, 1), 3, new Vector3(1, 1, 1), new Vector3(1, 1, 1)), children: (behavior) => (_jsxs(_Fragment, { children: [_jsx(Vector3Row, { hintKey: "turbulence.scale", label: "Scale", value: behavior.scale, min: 0.01, step: 0.1, onChange: (v) => binding.apply(() => (behavior.scale = v)) }), _jsx(Row, { label: "Octaves", children: _jsx(NumberField, { value: behavior.octaves, min: 1, step: 1, onChange: (v) => binding.apply(() => (behavior.octaves = Math.max(1, Math.round(v)))) }) }), _jsx(Vector3Row, { hintKey: "turbulence.strength", label: "Strength", value: behavior.velocityMultiplier, step: 0.5, onChange: (v) => binding.apply(() => (behavior.velocityMultiplier = v)) }), _jsx(Vector3Row, { label: "Time scale", value: behavior.timeScale, step: 0.1, onChange: (v) => binding.apply(() => (behavior.timeScale = v)) }), _jsx(Row, { label: "Seed", children: _jsx(NumberField, { value: behavior.seed, step: 1, onChange: (v) => binding.apply(() => {
165
+ return (_jsx(BehaviorModule, { binding: binding, title: "Turbulence", type: "TurbulenceField", create: () => new TurbulenceField({ x: 1, y: 1, z: 1 }, 3, { x: 1, y: 1, z: 1 }, { x: 1, y: 1, z: 1 }), children: (behavior) => (_jsxs(_Fragment, { children: [_jsx(Vector3Row, { hintKey: "turbulence.scale", label: "Scale", value: behavior.scale, min: 0.01, step: 0.1, onChange: (v) => binding.apply(() => (behavior.scale = v)) }), _jsx(Row, { label: "Octaves", children: _jsx(NumberField, { value: behavior.octaves, min: 1, step: 1, onChange: (v) => binding.apply(() => (behavior.octaves = Math.max(1, Math.round(v)))) }) }), _jsx(Vector3Row, { hintKey: "turbulence.strength", label: "Strength", value: behavior.velocityMultiplier, step: 0.5, onChange: (v) => binding.apply(() => (behavior.velocityMultiplier = v)) }), _jsx(Vector3Row, { label: "Time scale", value: behavior.timeScale, step: 0.1, onChange: (v) => binding.apply(() => (behavior.timeScale = v)) }), _jsx(Row, { label: "Seed", children: _jsx(NumberField, { value: behavior.seed, step: 1, onChange: (v) => binding.apply(() => {
163
166
  const seed = Math.round(v);
164
167
  const next = new TurbulenceField(behavior.scale, behavior.octaves, behavior.velocityMultiplier, behavior.timeScale, seed);
165
168
  behavior.seed = seed;
@@ -190,7 +193,7 @@ export function ColorBySpeedModule({ binding }) {
190
193
  }
191
194
  /** The Size by Speed module (Unity's Size by Speed): size over a speed range. */
192
195
  export function SizeBySpeedModule({ binding }) {
193
- return (_jsx(BehaviorModule, { binding: binding, title: "Size by Speed", type: "SizeBySpeed", create: () => new SizeBySpeed(buildScalar({ mode: 'curve', value: 1, min: 0, max: 1, curve: [0.5, 0.8, 1.2, 1.5] }), new IntervalValue(0, 5)), children: (behavior) => (_jsxs(_Fragment, { children: [_jsx("div", { style: { marginTop: 6 }, children: _jsx(CurveEditor, { pieces: readPieces(behavior.size), maxValue: 2, onChange: (pieces) => binding.apply(() => (behavior.size = buildCurve(pieces))) }) }), _jsx(SpeedRangeRows, { binding: binding, behavior: behavior })] })) }));
196
+ return (_jsx(BehaviorModule, { binding: binding, title: "Size by Speed", type: "SizeBySpeed", create: () => new SizeBySpeed(buildScalar({ mode: 'curve', value: 1, min: 0, max: 1, curve: [0.5, 0.8, 1.2, 1.5] }), new IntervalValue(0, 5)), children: (behavior) => (_jsxs(_Fragment, { children: [_jsx("div", { style: { marginTop: 6 }, children: _jsx(AxesCurveField, { generator: behavior.size, maxValue: 2, onChange: (size) => binding.apply(() => (behavior.size = size)) }) }), _jsx(SpeedRangeRows, { binding: binding, behavior: behavior })] })) }));
194
197
  }
195
198
  /** The Rotation by Speed module (Unity's Rotation by Speed): spin rate over a speed range. */
196
199
  export function RotationBySpeedModule({ binding }) {
@@ -198,11 +201,11 @@ export function RotationBySpeedModule({ binding }) {
198
201
  }
199
202
  /** The Orbit over Lifetime module (Unity's Velocity over Lifetime orbital): turns particles about an axis. */
200
203
  export function OrbitOverLifeModule({ binding }) {
201
- return (_jsx(BehaviorModule, { binding: binding, title: "Orbit over Lifetime", type: "OrbitOverLife", create: () => new OrbitOverLife(new ConstantValue(Math.PI), new Vector3(0, 1, 0)), children: (behavior) => (_jsx(ValueField, { label: "Orbit speed", generator: behavior.orbitSpeed, curveMax: Math.PI * 4, onChange: (g) => binding.apply(() => (behavior.orbitSpeed = g)) })) }));
204
+ return (_jsx(BehaviorModule, { binding: binding, title: "Orbit over Lifetime", type: "OrbitOverLife", create: () => new OrbitOverLife(new ConstantValue(Math.PI), { x: 0, y: 1, z: 0 }), children: (behavior) => (_jsx(ValueField, { label: "Orbit speed", generator: behavior.orbitSpeed, curveMax: Math.PI * 4, onChange: (g) => binding.apply(() => (behavior.orbitSpeed = g)) })) }));
202
205
  }
203
206
  /** The Width over Trail module (Unity's Trails width over trail): a trail's width along its length. */
204
207
  export function WidthOverTrailModule({ binding }) {
205
- return (_jsx(BehaviorModule, { binding: binding, title: "Width over Trail", type: "WidthOverLength", create: () => new WidthOverLength(buildScalar({ mode: 'curve', value: 1, min: 0, max: 1, curve: [1, 0.75, 0.4, 0] })), children: (behavior) => (_jsxs(_Fragment, { children: [_jsx("div", { style: { marginTop: 6 }, children: _jsx(CurveEditor, { pieces: readPieces(behavior.width), maxValue: 2, onChange: (pieces) => binding.apply(() => (behavior.width = buildCurve(pieces))) }) }), _jsx(Row, { label: "Absolute width", children: _jsx(CheckboxField, { value: behavior.absolute, onChange: (v) => binding.apply(() => (behavior.absolute = v)) }) })] })) }));
208
+ return (_jsx(BehaviorModule, { binding: binding, title: "Width over Trail", type: "WidthOverLength", create: () => new WidthOverLength(buildScalar({ mode: 'curve', value: 1, min: 0, max: 1, curve: [1, 0.75, 0.4, 0] })), children: (behavior) => (_jsxs(_Fragment, { children: [_jsx("div", { style: { marginTop: 6 }, children: _jsx(LifeCurveField, { generator: behavior.width, maxValue: 2, onChange: (curve) => binding.apply(() => (behavior.width = curve)) }) }), _jsx(Row, { label: "Absolute width", children: _jsx(CheckboxField, { value: behavior.absolute, onChange: (v) => binding.apply(() => (behavior.absolute = v)) }) })] })) }));
206
209
  }
207
210
  /** How many of the first frames a start-frame generator picks from: its exclusive upper bound. */
208
211
  function startFrameCount(startFrame) {
@@ -276,5 +279,5 @@ export function TextureSheetModule({ binding }) {
276
279
  if (v && frameBehavior.frameCount <= 0) {
277
280
  frameBehavior.frameCount = tiles;
278
281
  }
279
- }) }), frameBehavior.startFrame && (_jsx(NumberField, { value: startFrameCount(frameBehavior.startFrame), min: 1, max: tiles, step: 1, onChange: (v) => binding.apply(() => (frameBehavior.startFrame = new IntervalValue(0, Math.max(1, Math.round(v))))) }))] }), _jsx("div", { style: { marginTop: 6 }, children: _jsx(CurveEditor, { pieces: readPieces(frameBehavior.frame), maxValue: Math.max(1, tiles - 1), onChange: (pieces) => binding.apply(() => (frameBehavior.frame = buildCurve(pieces))) }) })] }))] }));
282
+ }) }), frameBehavior.startFrame && (_jsx(NumberField, { value: startFrameCount(frameBehavior.startFrame), min: 1, max: tiles, step: 1, onChange: (v) => binding.apply(() => (frameBehavior.startFrame = new IntervalValue(0, Math.max(1, Math.round(v))))) }))] }), _jsx("div", { style: { marginTop: 6 }, children: _jsx(LifeCurveField, { generator: frameBehavior.frame, maxValue: Math.max(1, tiles - 1), onChange: (curve) => binding.apply(() => (frameBehavior.frame = curve)) }) })] }))] }));
280
283
  }
@@ -39,4 +39,14 @@ export type { TimelineTrackRowProps } from './TimelineTrackRow.js';
39
39
  export { TransportBar } from './TransportBar.js';
40
40
  export type { TransportBarProps } from './TransportBar.js';
41
41
  export { ValueField } from './ValueField.js';
42
- export type { ConstantValueFieldProps, CurveValueFieldProps } from './ValueField.js';
42
+ export type { ConstantValueFieldProps, CurveValueFieldProps, ValueFieldBaseProps } from './ValueField.js';
43
+ export type { AssetLoadProgress, EffectAsset } from '../core/assets.js';
44
+ export type { AssetDragPayload } from '../core/assetTree.js';
45
+ export type { EditorListener, EffectBinding } from '../core/binding.js';
46
+ export type { GradientStop } from '../core/colors.js';
47
+ export type { EffectTreeNode } from '../core/effectTree.js';
48
+ export type { EffectHistory, HistoryStacks } from '../core/history.js';
49
+ export type { ProjectMeta, ProjectStore, StorageEstimate, StoredAsset, StoredScene, StoredSceneEntry, } from '../core/projectStore.js';
50
+ export type { SceneEntry } from '../core/sceneEntries.js';
51
+ export type { TimelineGroupRow, TimelineRow, TimelineSystemRow } from '../core/timeline.js';
52
+ export type { AnyGenerator, CurvePiece, ScalarGenerator } from '../core/values.js';
@@ -31,7 +31,7 @@ const INSPECTOR_HINTS = {
31
31
  Duration: 'How long the particle system runs before stopping (non-looping) or one loop cycle.',
32
32
  Looping: 'When enabled, the effect restarts from the beginning after duration ends.',
33
33
  'World space': 'Simulates in world coordinates so moving the emitter does not drag existing particles.',
34
- 'Scaling mode': '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).',
34
+ 'Scaling mode': '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.',
35
35
  Prewarm: 'Simulates the effect once at start so it already looks mid-playback when play begins.',
36
36
  'Warm-up time': '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.',
37
37
  'Start delay': 'Wait time before emission starts after play or restart.',
@@ -2,13 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { Texture } from '@babylonjs/core/Materials/Textures/texture.js';
3
3
  import { Mesh } from '@babylonjs/core/Meshes/mesh.js';
4
4
  import { PlusIcon, XMarkIcon } from '@heroicons/react/24/solid';
5
- import { AxisAngleGenerator, BoxEmitFrom, ColorOverLife, ColorRange, ConstantColor, ConstantValue, EulerGenerator, Gradient, IntervalValue, RandomColor, RandomColorBetweenGradient, RandomQuatGenerator, RenderMode, SizeOverLife, Vector2, Vector3, Vector3Function, Vector4, normalizeTextureUV, } from 'babylon.quarks';
5
+ import { AxisAngleGenerator, BoxEmitFrom, ColorOverLife, ColorRange, ConeEmitFrom, ConstantColor, ConstantValue, EulerGenerator, Gradient, GridSampling, IntervalValue, RandomColor, RandomColorBetweenGradient, RandomQuatGenerator, RenderMode, SizeOverLife, Vector3Function, normalizeTextureUV, } from 'babylon.quarks';
6
6
  import React, { useMemo } from 'react';
7
7
  import { DEFAULT_GRADIENT_STOPS, buildGradient, findBehavior, hexToRgb, readGradientStops, rgbToHex, } from '../core/colors.js';
8
8
  import { applyRendererMaterial, getMaterialLabel } from '../core/material.js';
9
9
  import { DEFAULT_SHAPE_PARAMS, SHAPE_PARAM_KEYS, SHAPE_TYPES, createShape, getShapeType, readShapeParams, } from '../core/shapes.js';
10
- import { buildCurve, buildScalar, readPieces, readScalar } from '../core/values.js';
11
- import { CurveEditor } from './CurveEditor.js';
10
+ import { buildCurve, buildScalar, readScalar } from '../core/values.js';
11
+ import { AxesCurveField } from './AxesCurveField.js';
12
12
  import { GradientEditor } from './GradientEditor.js';
13
13
  import { InspectorInfoIcon } from './InspectorInfoIcon.js';
14
14
  import { ModuleSection } from './ModuleSection.js';
@@ -60,6 +60,7 @@ const PARAM_LABELS = {
60
60
  column: 'Columns',
61
61
  row: 'Rows',
62
62
  depth: 'Depth',
63
+ length: 'Length',
63
64
  speed: 'Speed (lengths/s)',
64
65
  };
65
66
  /** Uppercase group title inside a module, as the Renderer's "Material" heading. */
@@ -77,19 +78,23 @@ function SubHeader(props) {
77
78
  gap: 5,
78
79
  }, children: [props.title, _jsx(InspectorInfoIcon, { content: props.hint, size: 12 })] }));
79
80
  }
80
- /** Three number inputs editing a Vector3 by value. */
81
+ /** `v` scaled to length 1, or `v` itself when it has no length. */
82
+ function unitOrZero(v) {
83
+ const length = Math.hypot(v.x, v.y, v.z);
84
+ return length > 0 ? { x: v.x / length, y: v.y / length, z: v.z / length } : v;
85
+ }
86
+ /** Three number inputs editing a vector by value: each edit hands over a new `{x, y, z}`. */
81
87
  function AxisField(props) {
82
88
  return (_jsx("div", { style: { display: 'flex', gap: 6 }, children: ['x', 'y', 'z'].map((axis) => (_jsx(NumberField, { value: props.value[axis], step: 0.1, onChange: (v) => {
83
- const next = props.value.clone();
84
- next[axis] = v;
85
- props.onChange(next);
89
+ const { x, y, z } = props.value;
90
+ props.onChange({ x, y, z, [axis]: v });
86
91
  } }, axis))) }));
87
92
  }
88
93
  function ColorInput(props) {
89
94
  const { value, onChange } = props;
90
- return (_jsxs("div", { style: { display: 'flex', gap: 6, alignItems: 'center' }, children: [_jsx("input", { type: "color", className: "qe-hover", value: rgbToHex(value.x, value.y, value.z), onChange: (e) => {
95
+ return (_jsxs("div", { style: { display: 'flex', gap: 6, alignItems: 'center' }, children: [_jsx("input", { type: "color", className: "qe-hover", value: rgbToHex(value.r, value.g, value.b), onChange: (e) => {
91
96
  const rgb = hexToRgb(e.target.value);
92
- onChange(new Vector4(rgb.r, rgb.g, rgb.b, value.w));
97
+ onChange({ r: rgb.r, g: rgb.g, b: rgb.b, a: value.a });
93
98
  }, style: {
94
99
  width: 42,
95
100
  height: 24,
@@ -97,7 +102,7 @@ function ColorInput(props) {
97
102
  background: 'transparent',
98
103
  padding: 0,
99
104
  cursor: 'pointer',
100
- } }), _jsx(NumberField, { value: value.w, min: 0, step: 0.05, onChange: (a) => onChange(new Vector4(value.x, value.y, value.z, Math.min(1, a))) })] }));
105
+ } }), _jsx(NumberField, { value: value.a, min: 0, step: 0.05, onChange: (a) => onChange({ r: value.r, g: value.g, b: value.b, a: Math.min(1, a) }) })] }));
101
106
  }
102
107
  /** The Main module (Unity's main module): duration, looping, start delay, life, speed, size, rotation and colour. */
103
108
  export function MainModule({ binding }) {
@@ -109,8 +114,8 @@ export function MainModule({ binding }) {
109
114
  ? twoColor.a
110
115
  : startColor instanceof ConstantColor
111
116
  ? startColor.color
112
- : new Vector4(1, 1, 1, 1);
113
- const colorB = twoColor ? twoColor.b : new Vector4(1, 0.5, 0.2, 1);
117
+ : { r: 1, g: 1, b: 1, a: 1 };
118
+ const colorB = twoColor ? twoColor.b : { r: 1, g: 0.5, b: 0.2, a: 1 };
114
119
  const twoColors = twoColor !== null;
115
120
  /** The two-colour generator of the current mode. */
116
121
  const makeTwoColors = (a, b) => colorMode === 'range' ? new ColorRange(a, b) : new RandomColor(a, b);
@@ -143,14 +148,19 @@ export function MainModule({ binding }) {
143
148
  : startColor instanceof Gradient
144
149
  ? 'gradient'
145
150
  : colorMode;
146
- return (_jsxs(ModuleSection, { title: "Main", children: [_jsx(Row, { label: "Duration", children: _jsx(NumberField, { value: system.duration, min: 0.05, onChange: (v) => binding.apply((s) => (s.duration = v)) }) }), _jsx(Row, { label: "Looping", children: _jsx(CheckboxField, { value: system.looping, onChange: (v) => binding.apply((s) => (s.looping = v)) }) }), _jsx(Row, { label: "World space", children: _jsx(CheckboxField, { value: system.worldSpace, onChange: (v) => binding.apply((s) => (s.worldSpace = v)) }) }), system.worldSpace && (_jsx(Row, { label: "Scaling mode", children: _jsx(SelectField, { value: system.scalingMode, options: [
147
- { value: 'shape', label: 'Shape (sizes and shape only)' },
148
- { value: 'hierarchy', label: 'Hierarchy (motion scales too)' },
149
- ], onChange: (mode) => binding.apply((s) => (s.scalingMode = mode)) }) })), _jsx(Row, { label: "Prewarm", children: _jsx(CheckboxField, { value: system.prewarm, onChange: (v) => binding.apply((s) => (s.prewarm = v)) }) }), system.prewarm && (_jsx(Row, { label: "Warm-up time", children: _jsx(NumberField, { value: system.prewarmTime, step: 0.1, min: 0, onChange: (v) => binding.apply((s) => (s.prewarmTime = Math.max(0, v))) }) })), _jsx(Row, { label: "Playback speed", children: _jsx(NumberField, { value: system.playbackSpeed, step: 0.1, min: 0, onChange: (v) => binding.apply((s) => (s.playbackSpeed = Math.max(0, v))) }) }), _jsxs(Row, { label: "Fixed seed", children: [_jsx(CheckboxField, { value: system.seed !== undefined, onChange: (v) => binding.apply((s) => (s.seed = v ? (s.seed ?? 1) : undefined)) }), system.seed !== undefined && (_jsx(NumberField, { value: system.seed, step: 1, min: 0, onChange: (v) => binding.apply((s) => (s.seed = Math.max(0, Math.floor(v)))) }))] }), _jsx(Row, { label: "Off screen", children: _jsx(SelectField, { value: system.cullingMode, options: [
151
+ return (_jsxs(ModuleSection, { title: "Main", children: [_jsx(Row, { label: "Duration", children: _jsx(NumberField, { value: system.duration, min: 0.05, onChange: (v) => binding.apply((s) => (s.duration = v)) }) }), _jsx(Row, { label: "Looping", children: _jsx(CheckboxField, { value: system.looping, onChange: (v) => binding.apply((s) => (s.looping = v)) }) }), _jsx(Row, { label: "World space", children: _jsx(CheckboxField, { value: system.worldSpace, onChange: (v) => binding.apply((s) => (s.worldSpace = v)) }) }), _jsx(Row, { label: "Scaling mode", children: _jsx(SelectField, { value: system.scalingMode, options: [
152
+ { value: 'local', label: 'Local (own scale only)' },
153
+ { value: 'hierarchy', label: 'Hierarchy (parents too)' },
154
+ { value: 'shape', label: 'Shape (shape only)' },
155
+ ], onChange: (mode) => binding.apply((s) => (s.scalingMode = mode)) }) }), _jsx(Row, { label: "Prewarm", children: _jsx(CheckboxField, { value: system.prewarm, onChange: (v) => binding.apply((s) => (s.prewarm = v)) }) }), system.prewarm && (_jsx(Row, { label: "Warm-up time", children: _jsx(NumberField, { value: system.prewarmTime, step: 0.1, min: 0, onChange: (v) => binding.apply((s) => (s.prewarmTime = Math.max(0, v))) }) })), _jsx(Row, { label: "Playback speed", children: _jsx(NumberField, { value: system.playbackSpeed, step: 0.1, min: 0, onChange: (v) => binding.apply((s) => (s.playbackSpeed = Math.max(0, v))) }) }), _jsxs(Row, { label: "Fixed seed", children: [_jsx(CheckboxField, { value: system.seed !== undefined, onChange: (v) => binding.apply((s) => (s.seed = v ? (s.seed ?? 1) : undefined)) }), system.seed !== undefined && (_jsx(NumberField, { value: system.seed, step: 1, min: 0, onChange: (v) => binding.apply((s) => (s.seed = Math.max(0, Math.floor(v)))) }))] }), _jsx(Row, { label: "Off screen", children: _jsx(SelectField, { value: system.cullingMode, options: [
150
156
  { value: 'always', label: 'Always simulate' },
151
157
  { value: 'pause', label: 'Pause' },
152
158
  { value: 'pauseAndCatchUp', label: 'Pause and catch up' },
153
- ], onChange: (mode) => binding.apply((s) => (s.cullingMode = mode)) }) }), _jsx(ValueField, { label: "Start delay", generator: system.startDelay, min: 0, curveMax: 5, onChange: (g) => binding.apply((s) => {
159
+ ], onChange: (mode) => binding.apply((s) => (s.cullingMode = mode)) }) }), _jsx(Row, { label: "Stop action", 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.", children: _jsx(SelectField, { value: system.stopAction, options: [
160
+ { value: 'none', label: 'None' },
161
+ { value: 'disable', label: 'Disable' },
162
+ { value: 'destroy', label: 'Destroy' },
163
+ ], onChange: (v) => binding.apply((s) => (s.stopAction = v)) }) }), _jsx(ValueField, { label: "Start delay", generator: system.startDelay, min: 0, curveMax: 5, onChange: (g) => binding.apply((s) => {
154
164
  s.startDelay = g;
155
165
  s.restart();
156
166
  }) }), _jsx(ValueField, { label: "Start lifetime", generator: system.startLife, min: 0.01, curveMax: 10, onChange: (g) => binding.apply((s) => (s.startLife = g)) }), _jsx(ValueField, { label: "Start speed", generator: system.startSpeed, min: 0, curveMax: 20, onChange: (g) => binding.apply((s) => (s.startSpeed = g)) }), _jsx(Row, { label: "Start size", children: _jsx(SelectField, { value: startSize3D ? '3d' : 'uniform', options: [
@@ -210,7 +220,7 @@ export function MainModule({ binding }) {
210
220
  mode === '3d'
211
221
  ? new RandomQuatGenerator()
212
222
  : mode === 'axisAngle'
213
- ? new AxisAngleGenerator(new Vector3(0, 1, 0), new ConstantValue(rotationState.value))
223
+ ? new AxisAngleGenerator({ x: 0, y: 1, z: 0 }, new ConstantValue(rotationState.value))
214
224
  : mode === 'euler'
215
225
  ? new EulerGenerator(new ConstantValue(eulerAngles.x), new ConstantValue(eulerAngles.y), new ConstantValue(eulerAngles.z))
216
226
  : mode === 'random'
@@ -266,7 +276,10 @@ export function ShapeModule({ binding }) {
266
276
  const scene = system.emitter.getScene();
267
277
  // 'vfxBatch' is the renderer's own internal instancing mesh — never a valid emission source.
268
278
  const meshOptions = scene.meshes.filter((m) => m instanceof Mesh && m.name !== 'vfxBatch' && m.getTotalVertices() > 0);
269
- return (_jsxs(ModuleSection, { title: "Shape", children: [_jsx(Row, { label: "Shape", hintKey: "shape.type", children: _jsx(SelectField, { value: type, options: SHAPE_TYPES, onChange: (next) => binding.apply((s) => (s.emitterShape = createShape(next, params))) }) }), keys.map((key) => (_jsx(Row, { label: PARAM_LABELS[key], children: _jsx(NumberField, { value: params[key], min: 0, onChange: (v) => binding.apply((s) => (s.emitterShape = createShape(type, { ...params, [key]: v }))) }) }, key))), type === 'mesh_surface' && (_jsx(Row, { label: "Source mesh", children: _jsx(SelectField, { value: params.mesh?.uniqueId != null ? String(params.mesh.uniqueId) : '__none', options: [
279
+ return (_jsxs(ModuleSection, { title: "Shape", children: [_jsx(Row, { label: "Shape", hintKey: "shape.type", children: _jsx(SelectField, { value: type, options: SHAPE_TYPES, onChange: (next) => binding.apply((s) => (s.emitterShape = createShape(next, params))) }) }), keys
280
+ // A cone's Length only shapes Emit from Volume; Unity shows it for Cone Volume alone.
281
+ .filter((key) => key !== 'length' || params.coneEmitFrom === ConeEmitFrom.Volume)
282
+ .map((key) => (_jsx(Row, { label: PARAM_LABELS[key], children: _jsx(NumberField, { value: params[key], min: 0, onChange: (v) => binding.apply((s) => (s.emitterShape = createShape(type, { ...params, [key]: v }))) }) }, key))), type === 'mesh_surface' && (_jsx(Row, { label: "Source mesh", children: _jsx(SelectField, { value: params.mesh?.uniqueId != null ? String(params.mesh.uniqueId) : '__none', options: [
270
283
  { value: '__none', label: '(none)' },
271
284
  ...meshOptions.map((m) => ({ value: String(m.uniqueId), label: m.name })),
272
285
  ], onChange: (id) => {
@@ -276,7 +289,13 @@ export function ShapeModule({ binding }) {
276
289
  { value: BoxEmitFrom.Volume, label: 'Volume' },
277
290
  { value: BoxEmitFrom.Shell, label: 'Shell (faces)' },
278
291
  { value: BoxEmitFrom.Edge, label: 'Edges' },
279
- ], onChange: (emitFrom) => binding.apply((s) => (s.emitterShape = createShape(type, { ...params, emitFrom }))) }) })), !SHAPES_WITHOUT_MODE_SPREAD.has(type) && (_jsxs(_Fragment, { children: [_jsx(Row, { label: "Emit mode", children: _jsx(SelectField, { value: params.mode, options: [
292
+ ], onChange: (emitFrom) => binding.apply((s) => (s.emitterShape = createShape(type, { ...params, emitFrom }))) }) })), type === 'cone' && (_jsx(Row, { label: "Emit from", children: _jsx(SelectField, { value: params.coneEmitFrom, options: [
293
+ { value: ConeEmitFrom.Base, label: 'Base' },
294
+ { value: ConeEmitFrom.Volume, label: 'Volume' },
295
+ ], onChange: (coneEmitFrom) => binding.apply((s) => (s.emitterShape = createShape(type, { ...params, coneEmitFrom }))) }) })), type === 'grid' && (_jsx(Row, { label: "Sampling", children: _jsx(SelectField, { value: params.sampling, options: [
296
+ { value: GridSampling.Random, label: 'Random' },
297
+ { value: GridSampling.Sequential, label: 'Sequential' },
298
+ ], onChange: (sampling) => binding.apply((s) => (s.emitterShape = createShape(type, { ...params, sampling }))) }) })), !SHAPES_WITHOUT_MODE_SPREAD.has(type) && (_jsxs(_Fragment, { children: [_jsx(Row, { label: "Emit mode", children: _jsx(SelectField, { value: params.mode, options: [
280
299
  { value: 0, label: 'Random' },
281
300
  { value: 1, label: 'Loop' },
282
301
  { value: 2, label: 'Ping-pong' },
@@ -293,9 +312,9 @@ export function SizeOverLifeModule({ binding }) {
293
312
  if (enabled) {
294
313
  s.addBehavior(new SizeOverLife(buildScalar({ mode: 'curve', value: 1, min: 0, max: 1, curve })));
295
314
  }
296
- }), children: _jsx("div", { style: { marginTop: 6 }, children: _jsx(CurveEditor, { pieces: behavior ? readPieces(behavior.size) : [{ start: 0, p: curve }], maxValue: 2, onChange: (pieces) => binding.apply((s) => {
315
+ }), children: _jsx("div", { style: { marginTop: 6 }, children: _jsx(AxesCurveField, { generator: behavior ? behavior.size : buildCurve([{ start: 0, p: curve }]), maxValue: 2, onChange: (size) => binding.apply((s) => {
297
316
  removeBehavior(s, 'SizeOverLife');
298
- s.addBehavior(new SizeOverLife(buildCurve(pieces)));
317
+ s.addBehavior(new SizeOverLife(size));
299
318
  }) }) }) }));
300
319
  }
301
320
  /** The Color over Lifetime module (Unity's Color over Lifetime): a gradient over the particle's life. */
@@ -442,19 +461,18 @@ export function RendererModule({ binding, textureOptions, geometryOptions, resol
442
461
  s.rendererEmitterSettings.lifetime = v > 0 ? v : undefined;
443
462
  }) }) }), _jsx(Row, { label: "Swept trail", children: _jsx(CheckboxField, { value: !!system.rendererEmitterSettings.sideAxis, onChange: (v) => binding.apply((s) => {
444
463
  s.rendererEmitterSettings.sideAxis = v
445
- ? new Vector3(0, 1, 0)
464
+ ? { x: 0, y: 1, z: 0 }
446
465
  : undefined;
447
466
  }) }) }), system.rendererEmitterSettings.sideAxis && (_jsx(Row, { label: "Side axis", children: _jsx(AxisField, { value: system.rendererEmitterSettings.sideAxis, onChange: (axis) => binding.apply((s) => {
448
467
  // The axis's length scales the width: keep it a unit vector.
449
- s.rendererEmitterSettings.sideAxis =
450
- axis.length() > 0 ? axis.normalize() : axis;
468
+ s.rendererEmitterSettings.sideAxis = unitOrZero(axis);
451
469
  }) }) }))] })), system.renderMode === RenderMode.StretchedBillBoard && (_jsxs(_Fragment, { children: [_jsx(Row, { label: "Speed factor", children: _jsx(NumberField, { value: system.rendererEmitterSettings.speedFactor ?? 0, step: 0.1, onChange: (v) => binding.apply((s) => (s.rendererEmitterSettings.speedFactor = v)) }) }), _jsx(Row, { label: "Length factor", children: _jsx(NumberField, { value: system.rendererEmitterSettings.lengthFactor ?? 2, step: 0.1, onChange: (v) => binding.apply((s) => (s.rendererEmitterSettings.lengthFactor = v)) }) })] })), _jsx(SubHeader, { title: "Material", hint: "Shader and blending settings applied to the particle sprite or mesh." }), materialLabel ? (_jsx(Row, { label: "Source", children: _jsx("div", { style: { fontSize: 12, color: theme.textDim, lineHeight: 1.45 }, children: materialLabel }) })) : null, _jsx(Row, { label: "Blend mode", children: _jsx(SelectField, { value: system.blending, options: [
452
470
  { value: 1, label: 'Additive' },
453
471
  { value: 2, label: 'Alpha blend' },
454
472
  { value: 3, label: 'Subtract' },
455
473
  { value: 4, label: 'Multiply' },
456
474
  ], onChange: (blend) => patchMaterial({ blendMode: blend }) }) }), _jsx(Row, { label: "Transparent", children: _jsx(CheckboxField, { value: !!system.getRendererSettings().materialTransparent, onChange: (v) => patchMaterial({ transparent: v }) }) }), _jsx(Row, { label: "Texture", children: _jsx(TextureSelect, { value: system.texture, textureOptions: textureOptions, loadTexture: loadTexture, onChange: (texture) => patchMaterial({ texture }), preview: true }) }), _jsx(TextureUVField, { labelPrefix: "Map ", value: system.mapUV ?? normalizeTextureUV(undefined), onChange: (uv) => binding.apply((s) => (s.mapUV = uv)) }), !isMesh && (_jsx(Row, { label: "Flip U/V", children: _jsx("div", { style: { display: 'flex', gap: 6 }, children: ['x', 'y'].map((axis) => (_jsx(NumberField, { value: system.flip?.[axis] ?? 0, min: 0, max: 1, step: 0.1, onChange: (v) => binding.apply((s) => {
457
- const next = s.flip?.clone() ?? new Vector2(0, 0);
475
+ const next = { x: s.flip?.x ?? 0, y: s.flip?.y ?? 0 };
458
476
  next[axis] = Math.min(1, Math.max(0, v));
459
477
  s.flip = next.x === 0 && next.y === 0 ? undefined : next;
460
478
  }) }, axis))) }) })), _jsx(Row, { label: "Alpha test", children: _jsx(NumberField, { value: system.getRendererSettings().materialAlphaTest ?? 0, min: 0, step: 0.05, onChange: (v) => patchMaterial({ alphaTest: Math.min(1, v) }) }) }), _jsx(Row, { label: "Depth write", children: _jsx(CheckboxField, { value: system.getRendererSettings().materialDepthWrite, onChange: (v) => patchMaterial({ depthWrite: v }) }) }), _jsx(Row, { label: "Depth test", children: _jsx(CheckboxField, { value: system.getRendererSettings().materialDepthTest, onChange: (v) => patchMaterial({ depthTest: v }) }) }), _jsx(SubHeader, { title: "Gradient map", hint: "Recolours the map through a colour ramp: one channel of the map, or its luminance, picks a colour along the ramp." }), _jsx(Row, { label: "Ramp", children: _jsx(TextureSelect, { value: gradientMap?.ramp, textureOptions: textureOptions, loadTexture: loadTexture, promptTitle: "Ramp texture URL", onChange: (ramp) => binding.apply((s) => (s.gradientMap = ramp ? { ...s.gradientMap, ramp } : undefined)) }) }), gradientMap && (_jsx(Row, { label: "Ramp channel", children: _jsx(SelectField, { value: gradientMap.channel, options: [
@@ -554,8 +572,21 @@ export function RendererModule({ binding, textureOptions, geometryOptions, resol
554
572
  { value: 'mix', label: 'Mix (outline)' },
555
573
  { value: 'fade', label: 'Fade (faces fade, edges stay)' },
556
574
  ], onChange: (mode) => patchRim({ mode }) }) }), _jsx(Row, { label: "Rim color", children: _jsx("div", { style: { display: 'flex', gap: 6 }, children: [0, 1, 2].map((channel) => (_jsx(NumberField, { value: rim.color[channel], min: 0, step: 0.05, onChange: (v) => setChannel(channel, v) }, channel))) }) }), _jsx(Row, { label: "Rim power", children: _jsx(NumberField, { value: rim.power, min: 0.01, step: 0.25, onChange: (power) => patchRim({ power }) }) }), _jsx(Row, { label: "Rim strength", children: _jsx(NumberField, { value: rim.strength, min: 0, step: 0.05, onChange: (strength) => patchRim({ strength }) }) })] }));
557
- })(), _jsx(Row, { label: "Render order", children: _jsx(NumberField, { value: system.renderOrder, step: 1, onChange: (v) => binding.apply((s) => (s.renderOrder = Math.round(v))) }) }), _jsx(Row, { label: "Rendering group", children: _jsx(NumberField, { value: system.renderingGroupId, step: 1, min: 0, onChange: (v) => binding.apply((s) => (s.renderingGroupId = Math.max(0, Math.round(v)))) }) }), _jsx(Row, { label: "Layer mask", children: _jsx(NumberField, { value: system.layers.mask, min: 0, step: 1, onChange: (v) => binding.apply((s) => (s.layers.mask = Math.max(0, Math.floor(v)))) }) }), _jsxs(Row, { label: "Max particles", children: [_jsx(CheckboxField, { value: system.maxParticles !== undefined, onChange: (v) => binding.apply((s) => (s.maxParticles = v ? 1000 : undefined)) }), system.maxParticles !== undefined && (_jsx(NumberField, { value: system.maxParticles, min: 1, step: 10, onChange: (v) => binding.apply((s) => (s.maxParticles = Math.max(1, Math.floor(v)))) }))] }), system.renderMode !== RenderMode.Mesh && system.renderMode !== RenderMode.Trail && (_jsx(Row, { label: "Pivot", children: _jsx("div", { style: { display: 'flex', gap: 6 }, children: ['x', 'y', 'z'].map((axis) => (_jsx(NumberField, { value: system.pivot?.[axis] ?? 0, step: 0.05, onChange: (v) => binding.apply((s) => {
558
- const next = (s.pivot ?? new Vector3()).clone();
575
+ })(), _jsx(Row, { label: "Render order", children: _jsx(NumberField, { value: system.renderOrder, step: 1, onChange: (v) => binding.apply((s) => (s.renderOrder = Math.round(v))) }) }), _jsx(Row, { label: "Rendering group", children: _jsx(NumberField, { value: system.renderingGroupId, step: 1, min: 0, onChange: (v) => binding.apply((s) => (s.renderingGroupId = Math.max(0, Math.round(v)))) }) }), _jsx(Row, { label: "Layer mask", children: _jsx(NumberField, { value: system.layers.mask, min: 0, step: 1, onChange: (v) => binding.apply((s) => (s.layers.mask = Math.max(0, Math.floor(v)))) }) }), _jsxs(Row, { label: "Max particles", children: [_jsx(CheckboxField, { value: system.maxParticles !== undefined, onChange: (v) => binding.apply((s) => (s.maxParticles = v ? 1000 : undefined)) }), system.maxParticles !== undefined && (_jsx(NumberField, { value: system.maxParticles, min: 1, step: 10, onChange: (v) => binding.apply((s) => (s.maxParticles = Math.max(1, Math.floor(v)))) }))] }), system.maxParticles !== undefined && system.renderMode !== RenderMode.Trail && (_jsx(Row, { label: "Ring buffer", hint: "What a full system does with new particles, as Unity's Ring Buffer Mode.", children: _jsx(SelectField, { value: system.ringBufferMode, options: [
576
+ { value: 'disabled', label: 'Disabled' },
577
+ { value: 'pauseUntilReplaced', label: 'Pause until replaced' },
578
+ { value: 'loopUntilReplaced', label: 'Loop until replaced' },
579
+ ], onChange: (v) => binding.apply((s) => (s.ringBufferMode = v)) }) })), system.maxParticles !== undefined &&
580
+ system.renderMode !== RenderMode.Trail &&
581
+ system.ringBufferMode === 'loopUntilReplaced' && (_jsx(Row, { label: "Loop range", hint: "The part of its life a particle plays again, from 0 to 1.", children: _jsx("div", { style: { display: 'flex', gap: 6 }, children: ['x', 'y'].map((end) => (_jsx(NumberField, { value: system.ringBufferLoopRange[end], min: 0, step: 0.05, onChange: (v) => binding.apply((s) => {
582
+ const next = { x: s.ringBufferLoopRange.x, y: s.ringBufferLoopRange.y };
583
+ next[end] = Math.min(1, Math.max(0, v));
584
+ s.ringBufferLoopRange = {
585
+ x: Math.min(next.x, next.y),
586
+ y: Math.max(next.x, next.y),
587
+ };
588
+ }) }, end))) }) })), system.renderMode !== RenderMode.Mesh && system.renderMode !== RenderMode.Trail && (_jsx(Row, { label: "Pivot", children: _jsx("div", { style: { display: 'flex', gap: 6 }, children: ['x', 'y', 'z'].map((axis) => (_jsx(NumberField, { value: system.pivot?.[axis] ?? 0, step: 0.05, onChange: (v) => binding.apply((s) => {
589
+ const next = { x: s.pivot?.x ?? 0, y: s.pivot?.y ?? 0, z: s.pivot?.z ?? 0 };
559
590
  next[axis] = v;
560
591
  s.pivot = next;
561
592
  }) }, axis))) }) })), system.renderMode === RenderMode.Mesh && (_jsxs(_Fragment, { children: [_jsx(Row, { label: "Env map atlas", children: _jsx(SelectField, { value: system.getRendererSettings().reflectionAtlas?.url ?? '', options: [
@@ -573,7 +604,7 @@ export function RendererModule({ binding, textureOptions, geometryOptions, resol
573
604
  ], onChange: (mode) => binding.apply((s) => (s.sortMode = mode)) }) }), _jsx(Row, { label: "Limit screen size", children: _jsx(CheckboxField, { value: system.minParticleSize > 0 || system.maxParticleSize !== Infinity, onChange: (v) => binding.apply((s) => {
574
605
  s.minParticleSize = 0;
575
606
  s.maxParticleSize = v ? 0.5 : Infinity;
576
- }) }) }), (system.minParticleSize > 0 || system.maxParticleSize !== Infinity) && (_jsxs(_Fragment, { children: [_jsx(Row, { label: "Min size (viewport)", children: _jsx(NumberField, { value: system.minParticleSize, step: 0.01, min: 0, onChange: (v) => binding.apply((s) => (s.minParticleSize = Math.max(0, v))) }) }), _jsx(Row, { label: "Max size (viewport)", children: _jsx(NumberField, { value: system.maxParticleSize === Infinity ? 0 : system.maxParticleSize, step: 0.05, min: 0, onChange: (v) => binding.apply((s) => (s.maxParticleSize = v > 0 ? v : Infinity)) }) })] })), _jsx(Row, { label: "Apply fog", children: _jsx(CheckboxField, { value: system.applyFog, onChange: (v) => binding.apply((s) => (s.applyFog = v)) }) }), _jsx(Row, { label: "Soft particles", children: _jsx(CheckboxField, { value: system.softParticles, onChange: (v) => binding.apply((s) => (s.softParticles = v)) }) }), system.softParticles && (_jsx(Row, { label: "Fade near/far", children: _jsxs("div", { style: { display: 'flex', gap: 6 }, children: [_jsx(NumberField, { value: system.softNearFade, min: 0, onChange: (v) => binding.apply((s) => (s.softNearFade = v)) }), _jsx(NumberField, { value: system.softFarFade, min: 0, onChange: (v) => binding.apply((s) => (s.softFarFade = v)) })] }) }))] }));
607
+ }) }) }), (system.minParticleSize > 0 || system.maxParticleSize !== Infinity) && (_jsxs(_Fragment, { children: [_jsx(Row, { label: "Min size (viewport)", children: _jsx(NumberField, { value: system.minParticleSize, step: 0.01, min: 0, onChange: (v) => binding.apply((s) => (s.minParticleSize = Math.max(0, v))) }) }), _jsx(Row, { label: "Max size (viewport)", children: _jsx(NumberField, { value: system.maxParticleSize === Infinity ? 0 : system.maxParticleSize, step: 0.05, min: 0, onChange: (v) => binding.apply((s) => (s.maxParticleSize = v > 0 ? v : Infinity)) }) })] })), _jsx(Row, { label: "Apply fog", children: _jsx(CheckboxField, { value: system.applyFog, onChange: (v) => binding.apply((s) => (s.applyFog = v)) }) }), _jsx(Row, { label: "Image processing", children: _jsx(CheckboxField, { value: system.applyImageProcessing, onChange: (v) => binding.apply((s) => (s.applyImageProcessing = v)) }) }), _jsx(Row, { label: "Soft particles", children: _jsx(CheckboxField, { value: system.softParticles, onChange: (v) => binding.apply((s) => (s.softParticles = v)) }) }), system.softParticles && (_jsx(Row, { label: "Fade near/far", children: _jsxs("div", { style: { display: 'flex', gap: 6 }, children: [_jsx(NumberField, { value: system.softNearFade, min: 0, onChange: (v) => binding.apply((s) => (s.softNearFade = v)) }), _jsx(NumberField, { value: system.softFarFade, min: 0, onChange: (v) => binding.apply((s) => (s.softFarFade = v)) })] }) }))] }));
577
608
  }
578
609
  function removeBehavior(system, type) {
579
610
  const behaviors = system.behaviors;
package/dist/session.d.ts CHANGED
@@ -7,3 +7,11 @@
7
7
  */
8
8
  export { createEditorSession } from './core/editorSession.js';
9
9
  export type { EditorFrameStats, EditorProject, EditorSession, EditorSessionOptions, EditorSessionView, EffectEditorHostHandle, PrefabInfo, } from './core/editorSession.js';
10
+ export type { AssetLoadProgress, EffectAsset } from './core/assets.js';
11
+ export type { AssetDragPayload } from './core/assetTree.js';
12
+ export type { EditorListener, EffectBinding } from './core/binding.js';
13
+ export type { EffectTreeNode } from './core/effectTree.js';
14
+ export type { EffectHistory, HistoryStacks } from './core/history.js';
15
+ export type { PlaybackState } from './core/playback.js';
16
+ export type { ProjectMeta, ProjectStore, StorageEstimate, StoredAsset, StoredScene, StoredSceneEntry, } from './core/projectStore.js';
17
+ export type { SceneEntry } from './core/sceneEntries.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babylon.quarks-editor",
3
- "version": "0.28.0",
3
+ "version": "0.30.0",
4
4
  "description": "Shuriken-style effect editor for babylon.quarks: headless edit-model core + React module-stack UI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -61,7 +61,7 @@
61
61
  "@babylonjs/materials": "^9.0.0",
62
62
  "@heroicons/react": ">=2.0.0",
63
63
  "@tanstack/react-virtual": ">=3.0.0",
64
- "babylon.quarks": "~0.28.0",
64
+ "babylon.quarks": "~0.30.0",
65
65
  "react": ">=18",
66
66
  "react-dom": ">=18"
67
67
  },
@@ -1,4 +1,4 @@
1
- import {Vector3, getPhysicsResolver, setPhysicsResolver} from 'babylon.quarks';
1
+ import {getPhysicsResolver, setPhysicsResolver, type Vector3Like} from 'babylon.quarks';
2
2
 
3
3
  /**
4
4
  * A horizontal ground plane collider for hosts/demos that opt in via ensureGroundResolver /
@@ -14,9 +14,11 @@ export class GroundPlaneResolver {
14
14
  /**
15
15
  * True when `position` is at or below the plane, with the plane's normal written to `normal`.
16
16
  */
17
- resolve(position: Vector3, normal: Vector3): boolean {
17
+ resolve(position: Vector3Like, normal: Vector3Like): boolean {
18
18
  if (position.y <= this.y) {
19
- normal.set(0, 1, 0);
19
+ normal.x = 0;
20
+ normal.y = 1;
21
+ normal.z = 0;
20
22
  return true;
21
23
  }
22
24
  return false;
@@ -1,5 +1,5 @@
1
1
  import type {Behavior} from 'babylon.quarks';
2
- import {ColorOverLife, Gradient, Vector3, Vector4} from 'babylon.quarks';
2
+ import {ColorOverLife, Gradient} from 'babylon.quarks';
3
3
 
4
4
  /** One RGBA stop of the editable gradient (all channels 0..1, pos 0..1). */
5
5
  export interface GradientStop {
@@ -25,7 +25,7 @@ export const DEFAULT_GRADIENT_STOPS: GradientStop[] = [
25
25
  export function buildGradient(stops: GradientStop[]): Gradient {
26
26
  const sorted = [...stops].sort((a, b) => a.pos - b.pos);
27
27
  return new Gradient(
28
- sorted.map((s) => [new Vector3(s.r, s.g, s.b), s.pos] as [Vector3, number]),
28
+ sorted.map((s) => [{r: s.r, g: s.g, b: s.b}, s.pos] as [{r: number; g: number; b: number}, number]),
29
29
  sorted.map((s) => [s.a, s.pos] as [number, number])
30
30
  );
31
31
  }
@@ -35,11 +35,6 @@ export function buildColorOverLife(stops: GradientStop[]): ColorOverLife {
35
35
  return new ColorOverLife(buildGradient(stops));
36
36
  }
37
37
 
38
- /** An RGBA colour as a quarks `Vector4`. */
39
- export function rgbaToVector4(stop: {r: number; g: number; b: number; a: number}): Vector4 {
40
- return new Vector4(stop.r, stop.g, stop.b, stop.a);
41
- }
42
-
43
38
  /** A stop's colour as CSS `rgba()`. */
44
39
  export function stopToCss(stop: GradientStop): string {
45
40
  const c = (v: number) => Math.round(v * 255);
@@ -88,13 +83,11 @@ export function readGradientStops(gradient: Gradient): GradientStop[] {
88
83
  for (const [, pos] of gradient.alpha.keys) {
89
84
  positions.add(Math.round(pos * 1000) / 1000);
90
85
  }
91
- const color = new Vector3();
92
86
  return [...positions]
93
87
  .sort((a, b) => a - b)
94
88
  .map((pos) => {
95
- gradient.color.genValue(color, pos);
96
- const alpha = gradient.alpha.genValue(0, pos);
97
- return {pos, r: color.x, g: color.y, b: color.z, a: alpha};
89
+ const {r, g, b, a} = gradient.evaluate(pos);
90
+ return {pos, r, g, b, a};
98
91
  });
99
92
  }
100
93
 
@@ -9,7 +9,6 @@ import {
9
9
  IntervalValue,
10
10
  ParticleSystem,
11
11
  RenderMode,
12
- Vector4,
13
12
  } from 'babylon.quarks';
14
13
  import {DEFAULT_GRADIENT_STOPS, buildGradient} from './colors.js';
15
14
  import {uniqueEntryName, type SceneEntry} from './sceneEntries.js';
@@ -32,7 +31,7 @@ export function createDefaultEffect(
32
31
  startLife: new IntervalValue(1.2, 1.8),
33
32
  startSpeed: new IntervalValue(3, 5),
34
33
  startSize: new IntervalValue(0.25, 0.5),
35
- startColor: new ConstantColor(new Vector4(1, 1, 1, 1)),
34
+ startColor: new ConstantColor({r: 1, g: 1, b: 1, a: 1}),
36
35
  emissionOverTime: new ConstantValue(80),
37
36
  shape: new ConeEmitter({radius: 0.3, angle: 0.25}),
38
37
  renderMode: RenderMode.BillBoard,
@@ -40,6 +39,8 @@ export function createDefaultEffect(
40
39
  transparent: true,
41
40
  blendMode: 1,
42
41
  });
42
+ // The editor previews over and over; the stop action is saved, not applied.
43
+ system.ignoreStopAction = true;
43
44
  system.addBehavior(new ColorOverLife(buildGradient(DEFAULT_GRADIENT_STOPS)));
44
45
  system.emitter.rotation.x = -Math.PI / 2;
45
46
  return system;