babylon.quarks-editor 0.18.0 → 0.19.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 (83) hide show
  1. package/README.md +6 -6
  2. package/dist/core/binding.d.ts +1 -1
  3. package/dist/core/colors.d.ts +1 -1
  4. package/dist/core/defaultEffect.d.ts +1 -1
  5. package/dist/core/effectTree.d.ts +1 -1
  6. package/dist/core/effectTree.js +18 -4
  7. package/dist/core/emitterShapeWireframe.d.ts +1 -1
  8. package/dist/core/emitterShapeWireframe.js +1 -1
  9. package/dist/core/galleryDropMarker.js +1 -1
  10. package/dist/core/galleryScene.d.ts +1 -1
  11. package/dist/core/galleryTree.js +4 -1
  12. package/dist/core/loadEffect.d.ts +2 -2
  13. package/dist/core/loadEffect.js +1 -1
  14. package/dist/core/loadEffectGallery.d.ts +2 -2
  15. package/dist/core/shapes.d.ts +1 -1
  16. package/dist/core/shapes.js +35 -8
  17. package/dist/core/systems.d.ts +1 -1
  18. package/dist/core/systems.js +3 -1
  19. package/dist/core/timeline.d.ts +1 -2
  20. package/dist/core/values.d.ts +1 -1
  21. package/dist/index.d.ts +11 -11
  22. package/dist/index.js +6 -6
  23. package/dist/react/CurveEditor.d.ts +1 -2
  24. package/dist/react/CurveEditor.js +14 -3
  25. package/dist/react/EffectEditor.d.ts +2 -2
  26. package/dist/react/EffectEditor.js +2 -2
  27. package/dist/react/EffectEditorHost.d.ts +1 -1
  28. package/dist/react/EffectEditorHost.js +123 -33
  29. package/dist/react/GalleryPanel.d.ts +1 -1
  30. package/dist/react/GalleryPanel.js +14 -7
  31. package/dist/react/GradientEditor.d.ts +1 -2
  32. package/dist/react/GradientEditor.js +8 -1
  33. package/dist/react/MessageDialog.js +7 -1
  34. package/dist/react/ModuleSection.js +10 -3
  35. package/dist/react/ObjectModule.d.ts +1 -2
  36. package/dist/react/ObjectModule.js +1 -1
  37. package/dist/react/SubEmittersModule.d.ts +1 -2
  38. package/dist/react/TimelinePanel.d.ts +3 -3
  39. package/dist/react/TimelinePanel.js +55 -9
  40. package/dist/react/TimelineTrackRow.d.ts +1 -1
  41. package/dist/react/TimelineTrackRow.js +20 -6
  42. package/dist/react/ValueField.d.ts +1 -2
  43. package/dist/react/behaviorModules.js +19 -5
  44. package/dist/react/index.d.ts +17 -17
  45. package/dist/react/index.js +11 -11
  46. package/dist/react/modules.js +55 -25
  47. package/package.json +68 -68
  48. package/src/core/binding.ts +2 -2
  49. package/src/core/colors.ts +1 -1
  50. package/src/core/defaultEffect.ts +1 -1
  51. package/src/core/effectTree.ts +22 -7
  52. package/src/core/emitterShapeWireframe.ts +8 -4
  53. package/src/core/galleryDropMarker.ts +6 -2
  54. package/src/core/galleryPlayback.ts +1 -1
  55. package/src/core/galleryScene.ts +3 -7
  56. package/src/core/gallerySelectionMarker.ts +5 -1
  57. package/src/core/galleryTree.ts +8 -5
  58. package/src/core/loadEffect.ts +3 -3
  59. package/src/core/loadEffectGallery.ts +7 -3
  60. package/src/core/pickGalleryFiles.ts +4 -1
  61. package/src/core/shapes.ts +48 -10
  62. package/src/core/systems.ts +9 -3
  63. package/src/core/timeline.ts +8 -8
  64. package/src/core/values.ts +1 -1
  65. package/src/core/viewportPicker.ts +1 -1
  66. package/src/index.ts +18 -18
  67. package/src/react/CurveEditor.tsx +40 -10
  68. package/src/react/EffectEditor.tsx +14 -13
  69. package/src/react/EffectEditorHost.tsx +239 -64
  70. package/src/react/GalleryPanel.tsx +56 -12
  71. package/src/react/GradientEditor.tsx +21 -4
  72. package/src/react/InspectorInfoIcon.tsx +6 -2
  73. package/src/react/MessageDialog.tsx +9 -1
  74. package/src/react/ModuleSection.tsx +12 -3
  75. package/src/react/ObjectModule.tsx +36 -15
  76. package/src/react/PromptDialog.tsx +5 -1
  77. package/src/react/SubEmittersModule.tsx +1 -2
  78. package/src/react/TimelinePanel.tsx +94 -21
  79. package/src/react/TimelineTrackRow.tsx +71 -18
  80. package/src/react/ValueField.tsx +0 -1
  81. package/src/react/behaviorModules.tsx +143 -29
  82. package/src/react/index.ts +33 -33
  83. package/src/react/modules.tsx +173 -57
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import type {Behavior} from 'babylon.quarks';
2
2
  import {
3
3
  ApplyCollision,
4
4
  ApplyForce,
@@ -22,15 +22,15 @@ import {
22
22
  VelocityOverLife,
23
23
  WidthOverLength,
24
24
  } from 'babylon.quarks';
25
- import type {Behavior} from 'babylon.quarks';
25
+ import React from 'react';
26
26
  import {EffectBinding} from '../core/binding';
27
27
  import {ensureGroundResolver} from '../core/collision';
28
28
  import {DEFAULT_GRADIENT_STOPS, buildGradient, findBehavior, readGradientStops} from '../core/colors';
29
29
  import {buildCurve, buildScalar, readPieces, readScalar} from '../core/values';
30
- import {GradientEditor} from './GradientEditor';
31
30
  import {CurveEditor} from './CurveEditor';
32
- import {ModuleSection} from './ModuleSection';
33
31
  import {NumberField, Row, SelectField} from './fields';
32
+ import {GradientEditor} from './GradientEditor';
33
+ import {ModuleSection} from './ModuleSection';
34
34
  import {ValueField} from './ValueField';
35
35
 
36
36
  interface ModuleProps {
@@ -79,7 +79,11 @@ export function SpeedOverLifeModule({binding}: ModuleProps) {
79
79
  binding={binding}
80
80
  title="Speed over Lifetime"
81
81
  type="SpeedOverLife"
82
- create={() => new SpeedOverLife(buildScalar({mode: 'curve', value: 1, min: 0, max: 1, curve: [1, 0.75, 0.5, 0]}) as never)}
82
+ create={() =>
83
+ new SpeedOverLife(
84
+ buildScalar({mode: 'curve', value: 1, min: 0, max: 1, curve: [1, 0.75, 0.5, 0]}) as never
85
+ )
86
+ }
83
87
  >
84
88
  {(behavior) => (
85
89
  <div style={{marginTop: 6}}>
@@ -100,7 +104,12 @@ export function LimitSpeedOverLifeModule({binding}: ModuleProps) {
100
104
  binding={binding}
101
105
  title="Limit Speed over Lifetime"
102
106
  type="LimitSpeedOverLife"
103
- create={() => new LimitSpeedOverLife(buildScalar({mode: 'curve', value: 1, min: 0, max: 1, curve: [4, 2, 1, 1]}) as never, 0.5)}
107
+ create={() =>
108
+ new LimitSpeedOverLife(
109
+ buildScalar({mode: 'curve', value: 1, min: 0, max: 1, curve: [4, 2, 1, 1]}) as never,
110
+ 0.5
111
+ )
112
+ }
104
113
  >
105
114
  {(behavior) => (
106
115
  <>
@@ -135,9 +144,27 @@ export function ForceOverLifeModule({binding}: ModuleProps) {
135
144
  >
136
145
  {(behavior) => (
137
146
  <>
138
- <ValueField hintKey="force.x" label="X" generator={behavior.x} curveMax={10} onChange={(g) => binding.apply(() => (behavior.x = g))} />
139
- <ValueField hintKey="force.y" label="Y" generator={behavior.y} curveMax={10} onChange={(g) => binding.apply(() => (behavior.y = g))} />
140
- <ValueField hintKey="force.z" label="Z" generator={behavior.z} curveMax={10} onChange={(g) => binding.apply(() => (behavior.z = g))} />
147
+ <ValueField
148
+ hintKey="force.x"
149
+ label="X"
150
+ generator={behavior.x}
151
+ curveMax={10}
152
+ onChange={(g) => binding.apply(() => (behavior.x = g))}
153
+ />
154
+ <ValueField
155
+ hintKey="force.y"
156
+ label="Y"
157
+ generator={behavior.y}
158
+ curveMax={10}
159
+ onChange={(g) => binding.apply(() => (behavior.y = g))}
160
+ />
161
+ <ValueField
162
+ hintKey="force.z"
163
+ label="Z"
164
+ generator={behavior.z}
165
+ curveMax={10}
166
+ onChange={(g) => binding.apply(() => (behavior.z = g))}
167
+ />
141
168
  </>
142
169
  )}
143
170
  </BehaviorModule>
@@ -164,12 +191,42 @@ export function VelocityOverLifeModule({binding}: ModuleProps) {
164
191
  onChange={(v) => binding.apply(() => (behavior.space = v))}
165
192
  />
166
193
  </Row>
167
- <ValueField label="Linear X" generator={behavior.linearX} curveMax={10} onChange={(g) => binding.apply(() => (behavior.linearX = g))} />
168
- <ValueField label="Linear Y" generator={behavior.linearY} curveMax={10} onChange={(g) => binding.apply(() => (behavior.linearY = g))} />
169
- <ValueField label="Linear Z" generator={behavior.linearZ} curveMax={10} onChange={(g) => binding.apply(() => (behavior.linearZ = g))} />
170
- <ValueField label="Orbital X" generator={behavior.orbitalX} curveMax={Math.PI * 4} onChange={(g) => binding.apply(() => (behavior.orbitalX = g))} />
171
- <ValueField label="Orbital Y" generator={behavior.orbitalY} curveMax={Math.PI * 4} onChange={(g) => binding.apply(() => (behavior.orbitalY = g))} />
172
- <ValueField label="Orbital Z" generator={behavior.orbitalZ} curveMax={Math.PI * 4} onChange={(g) => binding.apply(() => (behavior.orbitalZ = g))} />
194
+ <ValueField
195
+ label="Linear X"
196
+ generator={behavior.linearX}
197
+ curveMax={10}
198
+ onChange={(g) => binding.apply(() => (behavior.linearX = g))}
199
+ />
200
+ <ValueField
201
+ label="Linear Y"
202
+ generator={behavior.linearY}
203
+ curveMax={10}
204
+ onChange={(g) => binding.apply(() => (behavior.linearY = g))}
205
+ />
206
+ <ValueField
207
+ label="Linear Z"
208
+ generator={behavior.linearZ}
209
+ curveMax={10}
210
+ onChange={(g) => binding.apply(() => (behavior.linearZ = g))}
211
+ />
212
+ <ValueField
213
+ label="Orbital X"
214
+ generator={behavior.orbitalX}
215
+ curveMax={Math.PI * 4}
216
+ onChange={(g) => binding.apply(() => (behavior.orbitalX = g))}
217
+ />
218
+ <ValueField
219
+ label="Orbital Y"
220
+ generator={behavior.orbitalY}
221
+ curveMax={Math.PI * 4}
222
+ onChange={(g) => binding.apply(() => (behavior.orbitalY = g))}
223
+ />
224
+ <ValueField
225
+ label="Orbital Z"
226
+ generator={behavior.orbitalZ}
227
+ curveMax={Math.PI * 4}
228
+ onChange={(g) => binding.apply(() => (behavior.orbitalZ = g))}
229
+ />
173
230
  </>
174
231
  )}
175
232
  </BehaviorModule>
@@ -256,7 +313,9 @@ export function NoiseModule({binding}: ModuleProps) {
256
313
  binding={binding}
257
314
  title="Noise"
258
315
  type="Noise"
259
- create={() => new Noise(new ConstantValue(1), new ConstantValue(1), new ConstantValue(1), new ConstantValue(0))}
316
+ create={() =>
317
+ new Noise(new ConstantValue(1), new ConstantValue(1), new ConstantValue(1), new ConstantValue(0))
318
+ }
260
319
  >
261
320
  {(behavior) => (
262
321
  <>
@@ -297,7 +356,14 @@ export function NoiseModule({binding}: ModuleProps) {
297
356
  }
298
357
 
299
358
  /** Three numeric inputs for a Vector3 field, replacing the whole vector on any edit. */
300
- function Vector3Row(props: {label: string; hintKey?: string; value: Vector3; min?: number; step?: number; onChange: (v: Vector3) => void}) {
359
+ function Vector3Row(props: {
360
+ label: string;
361
+ hintKey?: string;
362
+ value: Vector3;
363
+ min?: number;
364
+ step?: number;
365
+ onChange: (v: Vector3) => void;
366
+ }) {
301
367
  const set = (axis: 'x' | 'y' | 'z', n: number) => {
302
368
  const next = props.value.clone();
303
369
  next[axis] = n;
@@ -325,7 +391,14 @@ export function TurbulenceModule({binding}: ModuleProps) {
325
391
  {(behavior) => (
326
392
  <>
327
393
  {/* scale divides particle position, so keep each axis strictly positive. */}
328
- <Vector3Row hintKey="turbulence.scale" label="Scale" value={behavior.scale} min={0.01} step={0.1} onChange={(v) => binding.apply(() => (behavior.scale = v))} />
394
+ <Vector3Row
395
+ hintKey="turbulence.scale"
396
+ label="Scale"
397
+ value={behavior.scale}
398
+ min={0.01}
399
+ step={0.1}
400
+ onChange={(v) => binding.apply(() => (behavior.scale = v))}
401
+ />
329
402
  <Row label="Octaves">
330
403
  <NumberField
331
404
  value={behavior.octaves}
@@ -403,8 +476,8 @@ export function CollisionModule({binding}: ModuleProps) {
403
476
  />
404
477
  </Row>
405
478
  <div style={{fontSize: 11, opacity: 0.6, marginTop: 4}}>
406
- Collides against a ground plane. Bounce is saved with the effect; Floor Y is an
407
- editor preview aid (a host can register its own colliders).
479
+ Collides against a ground plane. Bounce is saved with the effect; Floor Y is an editor preview
480
+ aid (a host can register its own colliders).
408
481
  </div>
409
482
  </>
410
483
  )}
@@ -420,12 +493,16 @@ function SpeedRangeRows({binding, behavior}: {binding: EffectBinding; behavior:
420
493
  <NumberField
421
494
  value={behavior.speedRange.a}
422
495
  min={0}
423
- onChange={(v) => binding.apply(() => (behavior.speedRange = new IntervalValue(v, behavior.speedRange.b)))}
496
+ onChange={(v) =>
497
+ binding.apply(() => (behavior.speedRange = new IntervalValue(v, behavior.speedRange.b)))
498
+ }
424
499
  />
425
500
  <NumberField
426
501
  value={behavior.speedRange.b}
427
502
  min={0}
428
- onChange={(v) => binding.apply(() => (behavior.speedRange = new IntervalValue(behavior.speedRange.a, v)))}
503
+ onChange={(v) =>
504
+ binding.apply(() => (behavior.speedRange = new IntervalValue(behavior.speedRange.a, v)))
505
+ }
429
506
  />
430
507
  </div>
431
508
  </Row>
@@ -444,7 +521,11 @@ export function ColorBySpeedModule({binding}: ModuleProps) {
444
521
  <>
445
522
  <div style={{marginTop: 6}}>
446
523
  <GradientEditor
447
- stops={behavior.color instanceof Gradient ? readGradientStops(behavior.color) : DEFAULT_GRADIENT_STOPS}
524
+ stops={
525
+ behavior.color instanceof Gradient
526
+ ? readGradientStops(behavior.color)
527
+ : DEFAULT_GRADIENT_STOPS
528
+ }
448
529
  onChange={(stops) => binding.apply(() => (behavior.color = buildGradient(stops)))}
449
530
  />
450
531
  </div>
@@ -461,7 +542,12 @@ export function SizeBySpeedModule({binding}: ModuleProps) {
461
542
  binding={binding}
462
543
  title="Size by Speed"
463
544
  type="SizeBySpeed"
464
- create={() => new SizeBySpeed(buildScalar({mode: 'curve', value: 1, min: 0, max: 1, curve: [0.5, 0.8, 1.2, 1.5]}) as never, new IntervalValue(0, 5))}
545
+ create={() =>
546
+ new SizeBySpeed(
547
+ buildScalar({mode: 'curve', value: 1, min: 0, max: 1, curve: [0.5, 0.8, 1.2, 1.5]}) as never,
548
+ new IntervalValue(0, 5)
549
+ )
550
+ }
465
551
  >
466
552
  {(behavior) => (
467
553
  <>
@@ -529,7 +615,11 @@ export function WidthOverTrailModule({binding}: ModuleProps) {
529
615
  binding={binding}
530
616
  title="Width over Trail"
531
617
  type="WidthOverLength"
532
- create={() => new WidthOverLength(buildScalar({mode: 'curve', value: 1, min: 0, max: 1, curve: [1, 0.75, 0.4, 0]}) as never)}
618
+ create={() =>
619
+ new WidthOverLength(
620
+ buildScalar({mode: 'curve', value: 1, min: 0, max: 1, curve: [1, 0.75, 0.4, 0]}) as never
621
+ )
622
+ }
533
623
  >
534
624
  {(behavior) => (
535
625
  <div style={{marginTop: 6}}>
@@ -559,7 +649,15 @@ export function TextureSheetModule({binding}: ModuleProps) {
559
649
  <ModuleSection title="Texture Sheet Animation" defaultOpen={false}>
560
650
  {textureUrl && (
561
651
  <div style={{marginTop: 6}}>
562
- <div style={{position: 'relative', width: 218, border: '1px solid #2b3761', borderRadius: 6, overflow: 'hidden'}}>
652
+ <div
653
+ style={{
654
+ position: 'relative',
655
+ width: 218,
656
+ border: '1px solid #2b3761',
657
+ borderRadius: 6,
658
+ overflow: 'hidden',
659
+ }}
660
+ >
563
661
  <img src={textureUrl} alt="texture atlas" style={{width: '100%', display: 'block'}} />
564
662
  <div
565
663
  style={{
@@ -607,10 +705,20 @@ export function TextureSheetModule({binding}: ModuleProps) {
607
705
  </div>
608
706
  )}
609
707
  <Row label="Tiles U">
610
- <NumberField value={system.uTileCount} min={1} step={1} onChange={(v) => binding.apply((s) => (s.uTileCount = Math.round(v)))} />
708
+ <NumberField
709
+ value={system.uTileCount}
710
+ min={1}
711
+ step={1}
712
+ onChange={(v) => binding.apply((s) => (s.uTileCount = Math.round(v)))}
713
+ />
611
714
  </Row>
612
715
  <Row label="Tiles V">
613
- <NumberField value={system.vTileCount} min={1} step={1} onChange={(v) => binding.apply((s) => (s.vTileCount = Math.round(v)))} />
716
+ <NumberField
717
+ value={system.vTileCount}
718
+ min={1}
719
+ step={1}
720
+ onChange={(v) => binding.apply((s) => (s.vTileCount = Math.round(v)))}
721
+ />
614
722
  </Row>
615
723
  <Row label="Blend tiles">
616
724
  <input
@@ -641,7 +749,13 @@ export function TextureSheetModule({binding}: ModuleProps) {
641
749
  if (e.target.checked) {
642
750
  s.addBehavior(
643
751
  new FrameOverLife(
644
- buildScalar({mode: 'curve', value: 0, min: 0, max: tiles - 1, curve: [0, (tiles - 1) / 3, (2 * (tiles - 1)) / 3, tiles - 1]}) as never
752
+ buildScalar({
753
+ mode: 'curve',
754
+ value: 0,
755
+ min: 0,
756
+ max: tiles - 1,
757
+ curve: [0, (tiles - 1) / 3, (2 * (tiles - 1)) / 3, tiles - 1],
758
+ }) as never
645
759
  )
646
760
  );
647
761
  }
@@ -1,47 +1,47 @@
1
- export {EffectEditor} from './EffectEditor';
2
- export type {EffectEditorProps} from './EffectEditor';
3
1
  export {
4
- SpeedOverLifeModule,
5
- LimitSpeedOverLifeModule,
2
+ CollisionModule,
3
+ ColorBySpeedModule,
4
+ EmitDirectionModule,
6
5
  ForceOverLifeModule,
7
6
  GravityModule,
8
- RotationOverLifeModule,
7
+ LimitSpeedOverLifeModule,
9
8
  NoiseModule,
10
- TurbulenceModule,
11
- CollisionModule,
12
- EmitDirectionModule,
13
- TextureSheetModule,
14
- ColorBySpeedModule,
15
- SizeBySpeedModule,
16
- RotationBySpeedModule,
17
9
  OrbitOverLifeModule,
10
+ RotationBySpeedModule,
11
+ RotationOverLifeModule,
12
+ SizeBySpeedModule,
13
+ SpeedOverLifeModule,
14
+ TextureSheetModule,
15
+ TurbulenceModule,
18
16
  WidthOverTrailModule,
19
17
  } from './behaviorModules';
20
- export type {TextureOption, GeometryOption, GeometryData} from './modules';
21
- export {SubEmittersModule} from './SubEmittersModule';
22
- export {TimelinePanel} from './TimelinePanel';
23
- export type {TimelinePanelProps, PlaybackState} from './TimelinePanel';
24
- export {TimelineTrackRow} from './TimelineTrackRow';
25
- export type {TimelineTrackRowProps} from './TimelineTrackRow';
26
- export {ModuleSection} from './ModuleSection';
27
- export {PromptDialog} from './PromptDialog';
28
- export type {PromptDialogProps} from './PromptDialog';
29
18
  export {CurveEditor} from './CurveEditor';
19
+ export {EffectEditor} from './EffectEditor';
20
+ export type {EffectEditorProps} from './EffectEditor';
21
+ export {EffectEditorHost, QuarksEffectEditor} from './EffectEditorHost';
22
+ export type {EffectEditorHostHandle, EffectEditorHostProps} from './EffectEditorHost';
23
+ export {CheckboxField, NumberField, Row, SelectField} from './fields';
24
+ export {GalleryPanel} from './GalleryPanel';
25
+ export type {GalleryPanelProps} from './GalleryPanel';
30
26
  export {GradientEditor} from './GradientEditor';
31
- export {ValueField} from './ValueField';
32
- export {Row, NumberField, CheckboxField, SelectField} from './fields';
27
+ export {MessageDialog} from './MessageDialog';
28
+ export type {MessageDialogProps} from './MessageDialog';
33
29
  export {
34
- MainModule,
30
+ ColorOverLifeModule,
35
31
  EmissionModule,
32
+ MainModule,
33
+ RendererModule,
36
34
  ShapeModule,
37
35
  SizeOverLifeModule,
38
- ColorOverLifeModule,
39
- RendererModule,
40
36
  } from './modules';
41
- export {theme, inputStyle, rowStyle, labelStyle, buttonStyle} from './theme';
42
- export {MessageDialog} from './MessageDialog';
43
- export type {MessageDialogProps} from './MessageDialog';
44
- export {GalleryPanel} from './GalleryPanel';
45
- export type {GalleryPanelProps} from './GalleryPanel';
46
- export {EffectEditorHost, QuarksEffectEditor} from './EffectEditorHost';
47
- export type {EffectEditorHostProps, EffectEditorHostHandle} from './EffectEditorHost';
37
+ export type {GeometryData, GeometryOption, TextureOption} from './modules';
38
+ export {ModuleSection} from './ModuleSection';
39
+ export {PromptDialog} from './PromptDialog';
40
+ export type {PromptDialogProps} from './PromptDialog';
41
+ export {SubEmittersModule} from './SubEmittersModule';
42
+ export {buttonStyle, inputStyle, labelStyle, rowStyle, theme} from './theme';
43
+ export {TimelinePanel} from './TimelinePanel';
44
+ export type {PlaybackState, TimelinePanelProps} from './TimelinePanel';
45
+ export {TimelineTrackRow} from './TimelineTrackRow';
46
+ export type {TimelineTrackRowProps} from './TimelineTrackRow';
47
+ export {ValueField} from './ValueField';