babylon.quarks-editor 0.29.0 → 0.31.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.
- package/CHANGELOG.md +31 -1
- package/README.md +7 -2
- package/dist/core/collision.d.ts +2 -2
- package/dist/core/collision.js +3 -1
- package/dist/core/colors.d.ts +1 -8
- package/dist/core/colors.js +4 -10
- package/dist/core/defaultEffect.js +2 -2
- package/dist/core/editorSession.d.ts +0 -2
- package/dist/core/editorSession.js +0 -1
- package/dist/core/systems.js +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/react/ValueField.d.ts +1 -2
- package/dist/react/behaviorModules.js +12 -13
- package/dist/react/index.d.ts +11 -1
- package/dist/react/modules.js +24 -18
- package/dist/session.d.ts +8 -0
- package/package.json +4 -4
- package/src/core/collision.ts +5 -3
- package/src/core/colors.ts +4 -11
- package/src/core/defaultEffect.ts +1 -2
- package/src/core/editorSession.ts +0 -3
- package/src/core/systems.ts +6 -6
- package/src/index.ts +0 -1
- package/src/react/ValueField.tsx +1 -1
- package/src/react/behaviorModules.tsx +14 -18
- package/src/react/index.ts +19 -1
- package/src/react/modules.tsx +30 -27
- package/src/session.ts +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,37 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to the `babylon.quarks-editor` package are documented here.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
5
|
-
and the
|
|
5
|
+
and the editor keeps its own 0.x version line; each release names the babylon.quarks line it
|
|
6
|
+
needs in its peer dependency.
|
|
7
|
+
|
|
8
|
+
## [0.31.0] — 2026-10-26
|
|
9
|
+
|
|
10
|
+
Released with babylon.quarks 1.0.0-rc.1, on npm's `next` tag with it. The editor stays on 0.x
|
|
11
|
+
while the library reaches 1.0.
|
|
12
|
+
|
|
13
|
+
### Breaking
|
|
14
|
+
|
|
15
|
+
- The peer dependency on babylon.quarks is `~1.0.0-rc.1`: this candidate and the 1.0.x releases
|
|
16
|
+
after it. An editor release that names 1.0.0 itself follows with it.
|
|
17
|
+
- Peer ranges are `@babylonjs/core` `^9.24.0` and `@babylonjs/materials` `^9.23.0`, the releases
|
|
18
|
+
babylon.quarks now needs and CI tests against.
|
|
19
|
+
|
|
20
|
+
## [0.30.0] — 2026-10-24
|
|
21
|
+
|
|
22
|
+
### Breaking
|
|
23
|
+
|
|
24
|
+
- `EffectEditorHostHandle.importGallery`, deprecated since it was renamed, is removed: call
|
|
25
|
+
`importAssets`.
|
|
26
|
+
- `rgbaToVector4` is removed, with quarks' own `Vector4` (see babylon.quarks 0.30): colours are
|
|
27
|
+
plain `{r, g, b, a}`.
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- The `./session` and `./react` entry points export the types their signatures use (`EffectAsset`,
|
|
32
|
+
`ProjectStore`, `EffectBinding`, `EffectHistory`, `SceneEntry`, `PlaybackState`, `CurvePiece`,
|
|
33
|
+
`GradientStop`, `ScalarGenerator`, `TimelineRow`, `ValueFieldBaseProps` and the rest), so a host
|
|
34
|
+
can name them from the entry point it imports. Each entry point's API is recorded in
|
|
35
|
+
`api/*.api.md` and checked in CI.
|
|
6
36
|
|
|
7
37
|
## [0.29.0] — 2026-10-24
|
|
8
38
|
|
package/README.md
CHANGED
|
@@ -10,8 +10,13 @@ Shuriken-style effect editor for [babylon.quarks](https://www.npmjs.com/package/
|
|
|
10
10
|
npm install babylon.quarks-editor babylon.quarks @babylonjs/core @babylonjs/materials react react-dom @heroicons/react @tanstack/react-virtual
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
Until babylon.quarks 1.0.0 is out, editor 0.31 and the 1.0 release candidate are on the `next` tag:
|
|
14
|
+
install `babylon.quarks-editor@next babylon.quarks@next` in place of the first two.
|
|
15
|
+
|
|
16
|
+
The editor is an ES module package (`import`, not `require`). It stays on 0.x while babylon.quarks
|
|
17
|
+
reaches 1.0, and each editor release names the babylon.quarks line it works with: editor 0.31.x
|
|
18
|
+
needs babylon.quarks 1.0 (from 1.0.0-rc.1, installed with `@next` until 1.0.0 is out), and editor
|
|
19
|
+
0.30.x needs babylon.quarks 0.30.x.
|
|
15
20
|
|
|
16
21
|
## Usage
|
|
17
22
|
|
package/dist/core/collision.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Vector3Like } from 'babylon.quarks';
|
|
2
2
|
/**
|
|
3
3
|
* A horizontal ground plane collider for hosts/demos that opt in via ensureGroundResolver /
|
|
4
4
|
* setPhysicsResolver. The editor never registers this automatically.
|
|
@@ -13,7 +13,7 @@ export declare class GroundPlaneResolver {
|
|
|
13
13
|
/**
|
|
14
14
|
* True when `position` is at or below the plane, with the plane's normal written to `normal`.
|
|
15
15
|
*/
|
|
16
|
-
resolve(position:
|
|
16
|
+
resolve(position: Vector3Like, normal: Vector3Like): boolean;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Opt-in helper for hosts/demos that want a simple floor collider.
|
package/dist/core/collision.js
CHANGED
package/dist/core/colors.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Behavior } from 'babylon.quarks';
|
|
2
|
-
import { ColorOverLife, Gradient
|
|
2
|
+
import { ColorOverLife, Gradient } from 'babylon.quarks';
|
|
3
3
|
/** One RGBA stop of the editable gradient (all channels 0..1, pos 0..1). */
|
|
4
4
|
export interface GradientStop {
|
|
5
5
|
/** Where the stop sits over the particle's life, 0..1. */
|
|
@@ -19,13 +19,6 @@ export declare const DEFAULT_GRADIENT_STOPS: GradientStop[];
|
|
|
19
19
|
export declare function buildGradient(stops: GradientStop[]): Gradient;
|
|
20
20
|
/** A Color over Lifetime behavior through `stops`. */
|
|
21
21
|
export declare function buildColorOverLife(stops: GradientStop[]): ColorOverLife;
|
|
22
|
-
/** An RGBA colour as a quarks `Vector4`. */
|
|
23
|
-
export declare function rgbaToVector4(stop: {
|
|
24
|
-
r: number;
|
|
25
|
-
g: number;
|
|
26
|
-
b: number;
|
|
27
|
-
a: number;
|
|
28
|
-
}): Vector4;
|
|
29
22
|
/** A stop's colour as CSS `rgba()`. */
|
|
30
23
|
export declare function stopToCss(stop: GradientStop): string;
|
|
31
24
|
/** The stops as a left-to-right CSS `linear-gradient`, for a gradient preview. */
|
package/dist/core/colors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColorOverLife, Gradient
|
|
1
|
+
import { ColorOverLife, Gradient } from 'babylon.quarks';
|
|
2
2
|
/** The gradient a new Color over Lifetime starts with: warm yellow fading out through red. */
|
|
3
3
|
export const DEFAULT_GRADIENT_STOPS = [
|
|
4
4
|
{ pos: 0, r: 1, g: 0.85, b: 0.4, a: 1 },
|
|
@@ -7,16 +7,12 @@ export const DEFAULT_GRADIENT_STOPS = [
|
|
|
7
7
|
/** A quarks gradient through `stops`, sorted by position; colour and alpha share the stops. */
|
|
8
8
|
export function buildGradient(stops) {
|
|
9
9
|
const sorted = [...stops].sort((a, b) => a.pos - b.pos);
|
|
10
|
-
return new Gradient(sorted.map((s) => [
|
|
10
|
+
return new Gradient(sorted.map((s) => [{ r: s.r, g: s.g, b: s.b }, s.pos]), sorted.map((s) => [s.a, s.pos]));
|
|
11
11
|
}
|
|
12
12
|
/** A Color over Lifetime behavior through `stops`. */
|
|
13
13
|
export function buildColorOverLife(stops) {
|
|
14
14
|
return new ColorOverLife(buildGradient(stops));
|
|
15
15
|
}
|
|
16
|
-
/** An RGBA colour as a quarks `Vector4`. */
|
|
17
|
-
export function rgbaToVector4(stop) {
|
|
18
|
-
return new Vector4(stop.r, stop.g, stop.b, stop.a);
|
|
19
|
-
}
|
|
20
16
|
/** A stop's colour as CSS `rgba()`. */
|
|
21
17
|
export function stopToCss(stop) {
|
|
22
18
|
const c = (v) => Math.round(v * 255);
|
|
@@ -53,13 +49,11 @@ export function readGradientStops(gradient) {
|
|
|
53
49
|
for (const [, pos] of gradient.alpha.keys) {
|
|
54
50
|
positions.add(Math.round(pos * 1000) / 1000);
|
|
55
51
|
}
|
|
56
|
-
const color = new Vector3();
|
|
57
52
|
return [...positions]
|
|
58
53
|
.sort((a, b) => a - b)
|
|
59
54
|
.map((pos) => {
|
|
60
|
-
gradient.
|
|
61
|
-
|
|
62
|
-
return { pos, r: color.x, g: color.y, b: color.z, a: alpha };
|
|
55
|
+
const { r, g, b, a } = gradient.evaluate(pos);
|
|
56
|
+
return { pos, r, g, b, a };
|
|
63
57
|
});
|
|
64
58
|
}
|
|
65
59
|
/** Finds a behavior of the given quarks type string (e.g. 'ColorOverLife'). */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TransformNode } from '@babylonjs/core/Meshes/transformNode.js';
|
|
2
|
-
import { ColorOverLife, ConeEmitter, ConstantColor, ConstantValue, IntervalValue, ParticleSystem, RenderMode,
|
|
2
|
+
import { ColorOverLife, ConeEmitter, ConstantColor, ConstantValue, IntervalValue, ParticleSystem, RenderMode, } from 'babylon.quarks';
|
|
3
3
|
import { DEFAULT_GRADIENT_STOPS, buildGradient } from './colors.js';
|
|
4
4
|
import { uniqueEntryName } from './sceneEntries.js';
|
|
5
5
|
/** Creates a simple cone burst preset for new editor effects. */
|
|
@@ -11,7 +11,7 @@ export function createDefaultEffect(scene, resolveTexture, textureUrl) {
|
|
|
11
11
|
startLife: new IntervalValue(1.2, 1.8),
|
|
12
12
|
startSpeed: new IntervalValue(3, 5),
|
|
13
13
|
startSize: new IntervalValue(0.25, 0.5),
|
|
14
|
-
startColor: new ConstantColor(
|
|
14
|
+
startColor: new ConstantColor({ r: 1, g: 1, b: 1, a: 1 }),
|
|
15
15
|
emissionOverTime: new ConstantValue(80),
|
|
16
16
|
shape: new ConeEmitter({ radius: 0.3, angle: 0.25 }),
|
|
17
17
|
renderMode: RenderMode.BillBoard,
|
|
@@ -28,8 +28,6 @@ export interface EffectEditorHostHandle {
|
|
|
28
28
|
importJson: (json: unknown) => void;
|
|
29
29
|
/** Imports effect files (and the texture/geometry files they reference) into Assets. */
|
|
30
30
|
importAssets: (files: FileList | File[]) => Promise<void>;
|
|
31
|
-
/** @deprecated Renamed to `importAssets`. */
|
|
32
|
-
importGallery: (files: FileList | File[]) => Promise<void>;
|
|
33
31
|
/** The focused effect as quarks JSON; throws when no effect is focused. */
|
|
34
32
|
exportJson: () => string;
|
|
35
33
|
}
|
|
@@ -778,7 +778,6 @@ export function createEditorSession(options) {
|
|
|
778
778
|
renderer,
|
|
779
779
|
importJson,
|
|
780
780
|
importAssets,
|
|
781
|
-
importGallery: importAssets,
|
|
782
781
|
exportJson: () => makeHandle().binding.exportJSON('EditorEffect'),
|
|
783
782
|
});
|
|
784
783
|
/** Adds `json` to Assets and returns its single instance; throws when it has no systems. */
|
package/dist/core/systems.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConeEmitter, ConstantColor, ConstantValue, IntervalValue, ParticleSystem, RenderMode,
|
|
1
|
+
import { ConeEmitter, ConstantColor, ConstantValue, EmitSubParticleSystem, IntervalValue, ParticleSystem, RenderMode, } from 'babylon.quarks';
|
|
2
2
|
/**
|
|
3
3
|
* Creates a child system sharing the parent's scene/texture/blending, parented to the
|
|
4
4
|
* parent emitter (or `options.parentNode` when given) — the Unity pattern where an effect is
|
|
@@ -13,7 +13,7 @@ export function createChildSystem(parent, options = {}) {
|
|
|
13
13
|
startLife: new IntervalValue(0.3, oneShot ? 0.6 : 1.2),
|
|
14
14
|
startSpeed: new IntervalValue(1, 3),
|
|
15
15
|
startSize: new IntervalValue(0.05, 0.2),
|
|
16
|
-
startColor: new ConstantColor(
|
|
16
|
+
startColor: new ConstantColor({ r: 1, g: 0.9, b: 0.6, a: 1 }),
|
|
17
17
|
emissionOverTime: new ConstantValue(oneShot ? 0 : 30),
|
|
18
18
|
emissionBursts: oneShot
|
|
19
19
|
? [{ time: 0, count: new ConstantValue(8), cycle: 1, interval: 0.01, probability: 1 }]
|
|
@@ -45,8 +45,8 @@ export function unlinkSubEmitterReferences(systems, removed) {
|
|
|
45
45
|
const behaviors = system.behaviors;
|
|
46
46
|
for (let i = behaviors.length - 1; i >= 0; i--) {
|
|
47
47
|
const behavior = behaviors[i];
|
|
48
|
-
if (behavior
|
|
49
|
-
behavior.subParticleSystem &&
|
|
48
|
+
if (behavior instanceof EmitSubParticleSystem &&
|
|
49
|
+
typeof behavior.subParticleSystem === 'object' &&
|
|
50
50
|
removedEmitters.has(behavior.subParticleSystem)) {
|
|
51
51
|
behaviors.splice(i, 1);
|
|
52
52
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { AssetDragPayload } from './core/assetTree.js';
|
|
|
3
3
|
export { EffectBinding } from './core/binding.js';
|
|
4
4
|
export type { EditorListener } from './core/binding.js';
|
|
5
5
|
export { GroundPlaneResolver, ensureGroundResolver } from './core/collision.js';
|
|
6
|
-
export { DEFAULT_GRADIENT_STOPS, buildColorOverLife, buildGradient, findBehavior, hexToRgb, rgbToHex,
|
|
6
|
+
export { DEFAULT_GRADIENT_STOPS, buildColorOverLife, buildGradient, findBehavior, hexToRgb, rgbToHex, stopToCss, stopsToCssGradient, } from './core/colors.js';
|
|
7
7
|
export type { GradientStop } from './core/colors.js';
|
|
8
8
|
export { buildEffectTree, collectSystems, serializeEffectForest, serializeEffectTree } from './core/effectTree.js';
|
|
9
9
|
export type { EffectTreeNode } from './core/effectTree.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { EffectBinding } from './core/binding.js';
|
|
2
2
|
export { GroundPlaneResolver, ensureGroundResolver } from './core/collision.js';
|
|
3
|
-
export { DEFAULT_GRADIENT_STOPS, buildColorOverLife, buildGradient, findBehavior, hexToRgb, rgbToHex,
|
|
3
|
+
export { DEFAULT_GRADIENT_STOPS, buildColorOverLife, buildGradient, findBehavior, hexToRgb, rgbToHex, stopToCss, stopsToCssGradient, } from './core/colors.js';
|
|
4
4
|
export { buildEffectTree, collectSystems, serializeEffectForest, serializeEffectTree } from './core/effectTree.js';
|
|
5
5
|
export { EffectHistory } from './core/history.js';
|
|
6
6
|
export { IndexedDbProjectStore } from './core/indexedDbProjectStore.js';
|
|
@@ -2,7 +2,7 @@ import type { ValueGenerator } from 'babylon.quarks';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { AnyGenerator, ScalarGenerator } from '../core/values.js';
|
|
4
4
|
/** Props every {@link ValueField} takes. */
|
|
5
|
-
interface ValueFieldBaseProps {
|
|
5
|
+
export interface ValueFieldBaseProps {
|
|
6
6
|
/** The row's label. */
|
|
7
7
|
label: string;
|
|
8
8
|
/** Tooltip text of the label. */
|
|
@@ -36,4 +36,3 @@ export interface ConstantValueFieldProps extends ValueFieldBaseProps {
|
|
|
36
36
|
* for settings sampled once.
|
|
37
37
|
*/
|
|
38
38
|
export declare function ValueField(props: CurveValueFieldProps | ConstantValueFieldProps): React.ReactElement;
|
|
39
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
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,
|
|
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
6
|
import { buildScalar, readScalar } from '../core/values.js';
|
|
@@ -61,11 +61,11 @@ export function InheritVelocityModule({ binding }) {
|
|
|
61
61
|
}
|
|
62
62
|
/** A point attractor (`GravityForce`): particles fall towards a point, harder the nearer they are. */
|
|
63
63
|
export function AttractorModule({ binding }) {
|
|
64
|
-
return (_jsx(BehaviorModule, { binding: binding, title: "Attractor", type: "GravityForce", create: () => new GravityForce(
|
|
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)) }) })] })) }));
|
|
65
65
|
}
|
|
66
66
|
/** The Gravity module: pulls particles towards a point. */
|
|
67
67
|
export function GravityModule({ binding }) {
|
|
68
|
-
return (_jsx(BehaviorModule, { binding: binding, title: "Gravity", type: "ApplyForce", create: () => new ApplyForce(
|
|
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: [
|
|
69
69
|
{ value: 'world', label: 'World' },
|
|
70
70
|
{ value: 'local', label: 'Local' },
|
|
71
71
|
], onChange: (v) => binding.apply(() => (behavior.space = v)) }) })] })) }));
|
|
@@ -76,7 +76,7 @@ export function RotationOverLifeModule({ binding }) {
|
|
|
76
76
|
}
|
|
77
77
|
/** Turns mesh particles by a 3D angular velocity; billboards turn through Rotation over Lifetime. */
|
|
78
78
|
export function Rotation3DOverLifeModule({ binding }) {
|
|
79
|
-
return (_jsx(BehaviorModule, { binding: binding, title: "Rotation over Lifetime (3D)", type: "Rotation3DOverLife", create: () => new Rotation3DOverLife(new AxisAngleGenerator(
|
|
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) => {
|
|
80
80
|
const generator = behavior.angularVelocity;
|
|
81
81
|
const mode = generator instanceof AxisAngleGenerator
|
|
82
82
|
? 'axisAngle'
|
|
@@ -92,7 +92,7 @@ export function Rotation3DOverLifeModule({ binding }) {
|
|
|
92
92
|
], onChange: (next) => binding.apply(() => {
|
|
93
93
|
behavior.angularVelocity =
|
|
94
94
|
next === 'axisAngle'
|
|
95
|
-
? new AxisAngleGenerator(
|
|
95
|
+
? new AxisAngleGenerator({ x: 0, y: 1, z: 0 }, new ConstantValue(Math.PI))
|
|
96
96
|
: next === 'euler'
|
|
97
97
|
? new EulerGenerator(new ConstantValue(0), new ConstantValue(Math.PI), new ConstantValue(0))
|
|
98
98
|
: new RandomQuatGenerator();
|
|
@@ -119,7 +119,7 @@ export function SequencesModule({ binding, textureOptions }) {
|
|
|
119
119
|
image.crossOrigin = 'anonymous';
|
|
120
120
|
image.src = imageUrl;
|
|
121
121
|
await image.decode();
|
|
122
|
-
const sequencer = new TextureSequencer(0.05, 0.05,
|
|
122
|
+
const sequencer = new TextureSequencer(0.05, 0.05, { x: 0, y: 0, z: 0 });
|
|
123
123
|
sequencer.fromImage(image, threshold);
|
|
124
124
|
const last = behavior.sequencers[behavior.sequencers.length - 1];
|
|
125
125
|
const start = last ? last[0].b : 0;
|
|
@@ -143,7 +143,7 @@ export function SequencesModule({ binding, textureOptions }) {
|
|
|
143
143
|
background: 'none',
|
|
144
144
|
border: 'none',
|
|
145
145
|
cursor: 'pointer',
|
|
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
|
|
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));
|
|
147
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 })] })) }));
|
|
148
148
|
}
|
|
149
149
|
/** The Noise module (Unity's Noise): moves and turns particles by a noise field. */
|
|
@@ -152,18 +152,17 @@ export function NoiseModule({ binding }) {
|
|
|
152
152
|
? new PiecewiseBezier([[new Bezier(-1, -1 / 3, 1 / 3, 1), 0]])
|
|
153
153
|
: undefined)) }) }), behavior.remap !== undefined && (_jsx(ValueField, { label: "Remap curve", generator: behavior.remap, curveMax: 1, onChange: (g) => binding.apply(() => (behavior.remap = g)) }))] })) }));
|
|
154
154
|
}
|
|
155
|
-
/** Three numeric inputs for a
|
|
155
|
+
/** Three numeric inputs for a vector field, replacing the whole vector on any edit. */
|
|
156
156
|
function Vector3Row(props) {
|
|
157
157
|
const set = (axis, n) => {
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
props.onChange(next);
|
|
158
|
+
const { x, y, z } = props.value;
|
|
159
|
+
props.onChange({ x, y, z, [axis]: n });
|
|
161
160
|
};
|
|
162
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) })] }) }));
|
|
163
162
|
}
|
|
164
163
|
/** The Turbulence module: a curl noise force field. */
|
|
165
164
|
export function TurbulenceModule({ binding }) {
|
|
166
|
-
return (_jsx(BehaviorModule, { binding: binding, title: "Turbulence", type: "TurbulenceField", create: () => new TurbulenceField(
|
|
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(() => {
|
|
167
166
|
const seed = Math.round(v);
|
|
168
167
|
const next = new TurbulenceField(behavior.scale, behavior.octaves, behavior.velocityMultiplier, behavior.timeScale, seed);
|
|
169
168
|
behavior.seed = seed;
|
|
@@ -202,7 +201,7 @@ export function RotationBySpeedModule({ binding }) {
|
|
|
202
201
|
}
|
|
203
202
|
/** The Orbit over Lifetime module (Unity's Velocity over Lifetime orbital): turns particles about an axis. */
|
|
204
203
|
export function OrbitOverLifeModule({ binding }) {
|
|
205
|
-
return (_jsx(BehaviorModule, { binding: binding, title: "Orbit over Lifetime", type: "OrbitOverLife", create: () => new OrbitOverLife(new ConstantValue(Math.PI),
|
|
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)) })) }));
|
|
206
205
|
}
|
|
207
206
|
/** The Width over Trail module (Unity's Trails width over trail): a trail's width along its length. */
|
|
208
207
|
export function WidthOverTrailModule({ binding }) {
|
package/dist/react/index.d.ts
CHANGED
|
@@ -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';
|
package/dist/react/modules.js
CHANGED
|
@@ -2,7 +2,7 @@ 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, ConeEmitFrom, ConstantColor, ConstantValue, EulerGenerator, Gradient, GridSampling, IntervalValue, RandomColor, RandomColorBetweenGradient, RandomQuatGenerator, RenderMode, SizeOverLife,
|
|
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';
|
|
@@ -78,19 +78,23 @@ function SubHeader(props) {
|
|
|
78
78
|
gap: 5,
|
|
79
79
|
}, children: [props.title, _jsx(InspectorInfoIcon, { content: props.hint, size: 12 })] }));
|
|
80
80
|
}
|
|
81
|
-
/**
|
|
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}`. */
|
|
82
87
|
function AxisField(props) {
|
|
83
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) => {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
props.onChange(next);
|
|
89
|
+
const { x, y, z } = props.value;
|
|
90
|
+
props.onChange({ x, y, z, [axis]: v });
|
|
87
91
|
} }, axis))) }));
|
|
88
92
|
}
|
|
89
93
|
function ColorInput(props) {
|
|
90
94
|
const { value, onChange } = props;
|
|
91
|
-
return (_jsxs("div", { style: { display: 'flex', gap: 6, alignItems: 'center' }, children: [_jsx("input", { type: "color", className: "qe-hover", value: rgbToHex(value.
|
|
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) => {
|
|
92
96
|
const rgb = hexToRgb(e.target.value);
|
|
93
|
-
onChange(
|
|
97
|
+
onChange({ r: rgb.r, g: rgb.g, b: rgb.b, a: value.a });
|
|
94
98
|
}, style: {
|
|
95
99
|
width: 42,
|
|
96
100
|
height: 24,
|
|
@@ -98,7 +102,7 @@ function ColorInput(props) {
|
|
|
98
102
|
background: 'transparent',
|
|
99
103
|
padding: 0,
|
|
100
104
|
cursor: 'pointer',
|
|
101
|
-
} }), _jsx(NumberField, { value: value.
|
|
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) }) })] }));
|
|
102
106
|
}
|
|
103
107
|
/** The Main module (Unity's main module): duration, looping, start delay, life, speed, size, rotation and colour. */
|
|
104
108
|
export function MainModule({ binding }) {
|
|
@@ -110,8 +114,8 @@ export function MainModule({ binding }) {
|
|
|
110
114
|
? twoColor.a
|
|
111
115
|
: startColor instanceof ConstantColor
|
|
112
116
|
? startColor.color
|
|
113
|
-
:
|
|
114
|
-
const colorB = twoColor ? twoColor.b :
|
|
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 };
|
|
115
119
|
const twoColors = twoColor !== null;
|
|
116
120
|
/** The two-colour generator of the current mode. */
|
|
117
121
|
const makeTwoColors = (a, b) => colorMode === 'range' ? new ColorRange(a, b) : new RandomColor(a, b);
|
|
@@ -216,7 +220,7 @@ export function MainModule({ binding }) {
|
|
|
216
220
|
mode === '3d'
|
|
217
221
|
? new RandomQuatGenerator()
|
|
218
222
|
: mode === 'axisAngle'
|
|
219
|
-
? new AxisAngleGenerator(
|
|
223
|
+
? new AxisAngleGenerator({ x: 0, y: 1, z: 0 }, new ConstantValue(rotationState.value))
|
|
220
224
|
: mode === 'euler'
|
|
221
225
|
? new EulerGenerator(new ConstantValue(eulerAngles.x), new ConstantValue(eulerAngles.y), new ConstantValue(eulerAngles.z))
|
|
222
226
|
: mode === 'random'
|
|
@@ -457,19 +461,18 @@ export function RendererModule({ binding, textureOptions, geometryOptions, resol
|
|
|
457
461
|
s.rendererEmitterSettings.lifetime = v > 0 ? v : undefined;
|
|
458
462
|
}) }) }), _jsx(Row, { label: "Swept trail", children: _jsx(CheckboxField, { value: !!system.rendererEmitterSettings.sideAxis, onChange: (v) => binding.apply((s) => {
|
|
459
463
|
s.rendererEmitterSettings.sideAxis = v
|
|
460
|
-
?
|
|
464
|
+
? { x: 0, y: 1, z: 0 }
|
|
461
465
|
: undefined;
|
|
462
466
|
}) }) }), system.rendererEmitterSettings.sideAxis && (_jsx(Row, { label: "Side axis", children: _jsx(AxisField, { value: system.rendererEmitterSettings.sideAxis, onChange: (axis) => binding.apply((s) => {
|
|
463
467
|
// The axis's length scales the width: keep it a unit vector.
|
|
464
|
-
s.rendererEmitterSettings.sideAxis =
|
|
465
|
-
axis.length() > 0 ? axis.normalize() : axis;
|
|
468
|
+
s.rendererEmitterSettings.sideAxis = unitOrZero(axis);
|
|
466
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: [
|
|
467
470
|
{ value: 1, label: 'Additive' },
|
|
468
471
|
{ value: 2, label: 'Alpha blend' },
|
|
469
472
|
{ value: 3, label: 'Subtract' },
|
|
470
473
|
{ value: 4, label: 'Multiply' },
|
|
471
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) => {
|
|
472
|
-
const next = s.flip?.
|
|
475
|
+
const next = { x: s.flip?.x ?? 0, y: s.flip?.y ?? 0 };
|
|
473
476
|
next[axis] = Math.min(1, Math.max(0, v));
|
|
474
477
|
s.flip = next.x === 0 && next.y === 0 ? undefined : next;
|
|
475
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: [
|
|
@@ -576,11 +579,14 @@ export function RendererModule({ binding, textureOptions, geometryOptions, resol
|
|
|
576
579
|
], onChange: (v) => binding.apply((s) => (s.ringBufferMode = v)) }) })), system.maxParticles !== undefined &&
|
|
577
580
|
system.renderMode !== RenderMode.Trail &&
|
|
578
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) => {
|
|
579
|
-
const next = s.ringBufferLoopRange.
|
|
582
|
+
const next = { x: s.ringBufferLoopRange.x, y: s.ringBufferLoopRange.y };
|
|
580
583
|
next[end] = Math.min(1, Math.max(0, v));
|
|
581
|
-
s.ringBufferLoopRange =
|
|
584
|
+
s.ringBufferLoopRange = {
|
|
585
|
+
x: Math.min(next.x, next.y),
|
|
586
|
+
y: Math.max(next.x, next.y),
|
|
587
|
+
};
|
|
582
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) => {
|
|
583
|
-
const next =
|
|
589
|
+
const next = { x: s.pivot?.x ?? 0, y: s.pivot?.y ?? 0, z: s.pivot?.z ?? 0 };
|
|
584
590
|
next[axis] = v;
|
|
585
591
|
s.pivot = next;
|
|
586
592
|
}) }, axis))) }) })), system.renderMode === RenderMode.Mesh && (_jsxs(_Fragment, { children: [_jsx(Row, { label: "Env map atlas", children: _jsx(SelectField, { value: system.getRendererSettings().reflectionAtlas?.url ?? '', options: [
|
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.
|
|
3
|
+
"version": "0.31.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",
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
},
|
|
58
58
|
"homepage": "https://github.com/Soullnik/babylon.quarks-standalone#readme",
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@babylonjs/core": "^9.
|
|
61
|
-
"@babylonjs/materials": "^9.
|
|
60
|
+
"@babylonjs/core": "^9.24.0",
|
|
61
|
+
"@babylonjs/materials": "^9.23.0",
|
|
62
62
|
"@heroicons/react": ">=2.0.0",
|
|
63
63
|
"@tanstack/react-virtual": ">=3.0.0",
|
|
64
|
-
"babylon.quarks": "~0.
|
|
64
|
+
"babylon.quarks": "~1.0.0-rc.1",
|
|
65
65
|
"react": ">=18",
|
|
66
66
|
"react-dom": ">=18"
|
|
67
67
|
},
|
package/src/core/collision.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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:
|
|
17
|
+
resolve(position: Vector3Like, normal: Vector3Like): boolean {
|
|
18
18
|
if (position.y <= this.y) {
|
|
19
|
-
normal.
|
|
19
|
+
normal.x = 0;
|
|
20
|
+
normal.y = 1;
|
|
21
|
+
normal.z = 0;
|
|
20
22
|
return true;
|
|
21
23
|
}
|
|
22
24
|
return false;
|
package/src/core/colors.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {Behavior} from 'babylon.quarks';
|
|
2
|
-
import {ColorOverLife, Gradient
|
|
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) => [
|
|
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.
|
|
96
|
-
|
|
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(
|
|
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,
|
|
@@ -71,8 +71,6 @@ export interface EffectEditorHostHandle {
|
|
|
71
71
|
importJson: (json: unknown) => void;
|
|
72
72
|
/** Imports effect files (and the texture/geometry files they reference) into Assets. */
|
|
73
73
|
importAssets: (files: FileList | File[]) => Promise<void>;
|
|
74
|
-
/** @deprecated Renamed to `importAssets`. */
|
|
75
|
-
importGallery: (files: FileList | File[]) => Promise<void>;
|
|
76
74
|
/** The focused effect as quarks JSON; throws when no effect is focused. */
|
|
77
75
|
exportJson: () => string;
|
|
78
76
|
}
|
|
@@ -1079,7 +1077,6 @@ export function createEditorSession(options: EditorSessionOptions): EditorSessio
|
|
|
1079
1077
|
renderer,
|
|
1080
1078
|
importJson,
|
|
1081
1079
|
importAssets,
|
|
1082
|
-
importGallery: importAssets,
|
|
1083
1080
|
exportJson: () => makeHandle().binding.exportJSON('EditorEffect'),
|
|
1084
1081
|
});
|
|
1085
1082
|
|
package/src/core/systems.ts
CHANGED
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
ConeEmitter,
|
|
4
4
|
ConstantColor,
|
|
5
5
|
ConstantValue,
|
|
6
|
+
EmitSubParticleSystem,
|
|
6
7
|
IntervalValue,
|
|
7
8
|
ParticleSystem,
|
|
8
9
|
RenderMode,
|
|
9
|
-
Vector4,
|
|
10
10
|
type ParticleEmitter,
|
|
11
11
|
} from 'babylon.quarks';
|
|
12
12
|
import type {EffectBinding} from './binding.js';
|
|
@@ -36,7 +36,7 @@ export function createChildSystem(parent: ParticleSystem, options: ChildSystemOp
|
|
|
36
36
|
startLife: new IntervalValue(0.3, oneShot ? 0.6 : 1.2),
|
|
37
37
|
startSpeed: new IntervalValue(1, 3),
|
|
38
38
|
startSize: new IntervalValue(0.05, 0.2),
|
|
39
|
-
startColor: new ConstantColor(
|
|
39
|
+
startColor: new ConstantColor({r: 1, g: 0.9, b: 0.6, a: 1}),
|
|
40
40
|
emissionOverTime: new ConstantValue(oneShot ? 0 : 30),
|
|
41
41
|
emissionBursts: oneShot
|
|
42
42
|
? [{time: 0, count: new ConstantValue(8), cycle: 1, interval: 0.01, probability: 1}]
|
|
@@ -66,13 +66,13 @@ export function createChildSystem(parent: ParticleSystem, options: ChildSystemOp
|
|
|
66
66
|
export function unlinkSubEmitterReferences(systems: ParticleSystem[], removed: ParticleSystem[]): void {
|
|
67
67
|
const removedEmitters = new Set(removed.map((system) => system.emitter));
|
|
68
68
|
for (const system of systems) {
|
|
69
|
-
const behaviors = system.behaviors
|
|
69
|
+
const behaviors = system.behaviors;
|
|
70
70
|
for (let i = behaviors.length - 1; i >= 0; i--) {
|
|
71
71
|
const behavior = behaviors[i];
|
|
72
72
|
if (
|
|
73
|
-
behavior
|
|
74
|
-
behavior.subParticleSystem &&
|
|
75
|
-
removedEmitters.has(behavior.subParticleSystem)
|
|
73
|
+
behavior instanceof EmitSubParticleSystem &&
|
|
74
|
+
typeof behavior.subParticleSystem === 'object' &&
|
|
75
|
+
removedEmitters.has(behavior.subParticleSystem as ParticleEmitter)
|
|
76
76
|
) {
|
|
77
77
|
behaviors.splice(i, 1);
|
|
78
78
|
}
|
package/src/index.ts
CHANGED
package/src/react/ValueField.tsx
CHANGED
|
@@ -17,7 +17,7 @@ import {NumberField, Row, SelectField} from './fields.js';
|
|
|
17
17
|
const captionStyle: React.CSSProperties = {fontSize: 10.5, opacity: 0.6, flex: 'none'};
|
|
18
18
|
|
|
19
19
|
/** Props every {@link ValueField} takes. */
|
|
20
|
-
interface ValueFieldBaseProps {
|
|
20
|
+
export interface ValueFieldBaseProps {
|
|
21
21
|
/** The row's label. */
|
|
22
22
|
label: string;
|
|
23
23
|
/** Tooltip text of the label. */
|
|
@@ -28,10 +28,10 @@ import {
|
|
|
28
28
|
SpeedOverLife,
|
|
29
29
|
TextureSequencer,
|
|
30
30
|
TurbulenceField,
|
|
31
|
-
Vector3,
|
|
32
31
|
Vector3Function,
|
|
33
32
|
VelocityOverLife,
|
|
34
33
|
WidthOverLength,
|
|
34
|
+
type Vector3Like,
|
|
35
35
|
} from 'babylon.quarks';
|
|
36
36
|
import React from 'react';
|
|
37
37
|
import {EffectBinding} from '../core/binding.js';
|
|
@@ -313,7 +313,7 @@ export function AttractorModule({binding}: ModuleProps) {
|
|
|
313
313
|
binding={binding}
|
|
314
314
|
title="Attractor"
|
|
315
315
|
type="GravityForce"
|
|
316
|
-
create={() => new GravityForce(
|
|
316
|
+
create={() => new GravityForce({x: 0, y: 0, z: 0}, 1)}
|
|
317
317
|
>
|
|
318
318
|
{(behavior) => (
|
|
319
319
|
<>
|
|
@@ -349,7 +349,7 @@ export function GravityModule({binding}: ModuleProps) {
|
|
|
349
349
|
binding={binding}
|
|
350
350
|
title="Gravity"
|
|
351
351
|
type="ApplyForce"
|
|
352
|
-
create={() => new ApplyForce(
|
|
352
|
+
create={() => new ApplyForce({x: 0, y: -1, z: 0}, new ConstantValue(9.81))}
|
|
353
353
|
>
|
|
354
354
|
{(behavior) => (
|
|
355
355
|
<>
|
|
@@ -406,7 +406,7 @@ export function Rotation3DOverLifeModule({binding}: ModuleProps) {
|
|
|
406
406
|
title="Rotation over Lifetime (3D)"
|
|
407
407
|
type="Rotation3DOverLife"
|
|
408
408
|
create={() =>
|
|
409
|
-
new Rotation3DOverLife(new AxisAngleGenerator(
|
|
409
|
+
new Rotation3DOverLife(new AxisAngleGenerator({x: 0, y: 1, z: 0}, new ConstantValue(Math.PI)))
|
|
410
410
|
}
|
|
411
411
|
>
|
|
412
412
|
{(behavior) => {
|
|
@@ -436,10 +436,7 @@ export function Rotation3DOverLifeModule({binding}: ModuleProps) {
|
|
|
436
436
|
binding.apply(() => {
|
|
437
437
|
behavior.angularVelocity =
|
|
438
438
|
next === 'axisAngle'
|
|
439
|
-
? new AxisAngleGenerator(
|
|
440
|
-
new Vector3(0, 1, 0),
|
|
441
|
-
new ConstantValue(Math.PI)
|
|
442
|
-
)
|
|
439
|
+
? new AxisAngleGenerator({x: 0, y: 1, z: 0}, new ConstantValue(Math.PI))
|
|
443
440
|
: next === 'euler'
|
|
444
441
|
? new EulerGenerator(
|
|
445
442
|
new ConstantValue(0),
|
|
@@ -525,7 +522,7 @@ export function SequencesModule({binding, textureOptions}: ModuleProps & {textur
|
|
|
525
522
|
image.crossOrigin = 'anonymous';
|
|
526
523
|
image.src = imageUrl;
|
|
527
524
|
await image.decode();
|
|
528
|
-
const sequencer = new TextureSequencer(0.05, 0.05,
|
|
525
|
+
const sequencer = new TextureSequencer(0.05, 0.05, {x: 0, y: 0, z: 0});
|
|
529
526
|
sequencer.fromImage(image, threshold);
|
|
530
527
|
const last = behavior.sequencers[behavior.sequencers.length - 1];
|
|
531
528
|
const start = last ? last[0].b : 0;
|
|
@@ -616,7 +613,7 @@ export function SequencesModule({binding, textureOptions}: ModuleProps & {textur
|
|
|
616
613
|
label="Position"
|
|
617
614
|
value={texture.position}
|
|
618
615
|
step={0.1}
|
|
619
|
-
onChange={(v) => binding.apply(() => texture.position
|
|
616
|
+
onChange={(v) => binding.apply(() => (texture.position = v))}
|
|
620
617
|
/>
|
|
621
618
|
</>
|
|
622
619
|
)}
|
|
@@ -739,19 +736,18 @@ export function NoiseModule({binding}: ModuleProps) {
|
|
|
739
736
|
);
|
|
740
737
|
}
|
|
741
738
|
|
|
742
|
-
/** Three numeric inputs for a
|
|
739
|
+
/** Three numeric inputs for a vector field, replacing the whole vector on any edit. */
|
|
743
740
|
function Vector3Row(props: {
|
|
744
741
|
label: string;
|
|
745
742
|
hintKey?: string;
|
|
746
|
-
value:
|
|
743
|
+
value: Vector3Like;
|
|
747
744
|
min?: number;
|
|
748
745
|
step?: number;
|
|
749
|
-
onChange: (v:
|
|
746
|
+
onChange: (v: Vector3Like) => void;
|
|
750
747
|
}) {
|
|
751
748
|
const set = (axis: 'x' | 'y' | 'z', n: number) => {
|
|
752
|
-
const
|
|
753
|
-
|
|
754
|
-
props.onChange(next);
|
|
749
|
+
const {x, y, z} = props.value;
|
|
750
|
+
props.onChange({x, y, z, [axis]: n});
|
|
755
751
|
};
|
|
756
752
|
return (
|
|
757
753
|
<Row label={props.label} hintKey={props.hintKey}>
|
|
@@ -771,7 +767,7 @@ export function TurbulenceModule({binding}: ModuleProps) {
|
|
|
771
767
|
binding={binding}
|
|
772
768
|
title="Turbulence"
|
|
773
769
|
type="TurbulenceField"
|
|
774
|
-
create={() => new TurbulenceField(
|
|
770
|
+
create={() => new TurbulenceField({x: 1, y: 1, z: 1}, 3, {x: 1, y: 1, z: 1}, {x: 1, y: 1, z: 1})}
|
|
775
771
|
>
|
|
776
772
|
{(behavior) => (
|
|
777
773
|
<>
|
|
@@ -1001,7 +997,7 @@ export function OrbitOverLifeModule({binding}: ModuleProps) {
|
|
|
1001
997
|
binding={binding}
|
|
1002
998
|
title="Orbit over Lifetime"
|
|
1003
999
|
type="OrbitOverLife"
|
|
1004
|
-
create={() => new OrbitOverLife(new ConstantValue(Math.PI),
|
|
1000
|
+
create={() => new OrbitOverLife(new ConstantValue(Math.PI), {x: 0, y: 1, z: 0})}
|
|
1005
1001
|
>
|
|
1006
1002
|
{(behavior) => (
|
|
1007
1003
|
<ValueField
|
package/src/react/index.ts
CHANGED
|
@@ -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';
|
package/src/react/modules.tsx
CHANGED
|
@@ -32,11 +32,10 @@ import {
|
|
|
32
32
|
RandomQuatGenerator,
|
|
33
33
|
RenderMode,
|
|
34
34
|
SizeOverLife,
|
|
35
|
-
Vector2,
|
|
36
|
-
Vector3,
|
|
37
35
|
Vector3Function,
|
|
38
|
-
Vector4,
|
|
39
36
|
normalizeTextureUV,
|
|
37
|
+
type Color4Like,
|
|
38
|
+
type Vector3Like,
|
|
40
39
|
} from 'babylon.quarks';
|
|
41
40
|
import React, {useMemo} from 'react';
|
|
42
41
|
import {
|
|
@@ -142,8 +141,14 @@ function SubHeader(props: {title: string; hint: string}) {
|
|
|
142
141
|
);
|
|
143
142
|
}
|
|
144
143
|
|
|
145
|
-
/**
|
|
146
|
-
function
|
|
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}) {
|
|
147
152
|
return (
|
|
148
153
|
<div style={{display: 'flex', gap: 6}}>
|
|
149
154
|
{(['x', 'y', 'z'] as const).map((axis) => (
|
|
@@ -152,9 +157,8 @@ function AxisField(props: {value: Vector3; onChange: (next: Vector3) => void}) {
|
|
|
152
157
|
value={props.value[axis]}
|
|
153
158
|
step={0.1}
|
|
154
159
|
onChange={(v) => {
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
props.onChange(next);
|
|
160
|
+
const {x, y, z} = props.value;
|
|
161
|
+
props.onChange({x, y, z, [axis]: v});
|
|
158
162
|
}}
|
|
159
163
|
/>
|
|
160
164
|
))}
|
|
@@ -162,17 +166,17 @@ function AxisField(props: {value: Vector3; onChange: (next: Vector3) => void}) {
|
|
|
162
166
|
);
|
|
163
167
|
}
|
|
164
168
|
|
|
165
|
-
function ColorInput(props: {value:
|
|
169
|
+
function ColorInput(props: {value: Color4Like; onChange: (next: Color4Like) => void}) {
|
|
166
170
|
const {value, onChange} = props;
|
|
167
171
|
return (
|
|
168
172
|
<div style={{display: 'flex', gap: 6, alignItems: 'center'}}>
|
|
169
173
|
<input
|
|
170
174
|
type="color"
|
|
171
175
|
className="qe-hover"
|
|
172
|
-
value={rgbToHex(value.
|
|
176
|
+
value={rgbToHex(value.r, value.g, value.b)}
|
|
173
177
|
onChange={(e) => {
|
|
174
178
|
const rgb = hexToRgb(e.target.value);
|
|
175
|
-
onChange(
|
|
179
|
+
onChange({r: rgb.r, g: rgb.g, b: rgb.b, a: value.a});
|
|
176
180
|
}}
|
|
177
181
|
style={{
|
|
178
182
|
width: 42,
|
|
@@ -184,10 +188,10 @@ function ColorInput(props: {value: Vector4; onChange: (next: Vector4) => void})
|
|
|
184
188
|
}}
|
|
185
189
|
/>
|
|
186
190
|
<NumberField
|
|
187
|
-
value={value.
|
|
191
|
+
value={value.a}
|
|
188
192
|
min={0}
|
|
189
193
|
step={0.05}
|
|
190
|
-
onChange={(a) => onChange(
|
|
194
|
+
onChange={(a) => onChange({r: value.r, g: value.g, b: value.b, a: Math.min(1, a)})}
|
|
191
195
|
/>
|
|
192
196
|
</div>
|
|
193
197
|
);
|
|
@@ -204,11 +208,11 @@ export function MainModule({binding}: ModuleProps) {
|
|
|
204
208
|
? twoColor.a
|
|
205
209
|
: startColor instanceof ConstantColor
|
|
206
210
|
? startColor.color
|
|
207
|
-
:
|
|
208
|
-
const colorB = twoColor ? twoColor.b :
|
|
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};
|
|
209
213
|
const twoColors = twoColor !== null;
|
|
210
214
|
/** The two-colour generator of the current mode. */
|
|
211
|
-
const makeTwoColors = (a:
|
|
215
|
+
const makeTwoColors = (a: Color4Like, b: Color4Like) =>
|
|
212
216
|
colorMode === 'range' ? new ColorRange(a, b) : new RandomColor(a, b);
|
|
213
217
|
const rotation = system.startRotation;
|
|
214
218
|
const isEuler = rotation instanceof EulerGenerator;
|
|
@@ -510,7 +514,7 @@ export function MainModule({binding}: ModuleProps) {
|
|
|
510
514
|
? new RandomQuatGenerator()
|
|
511
515
|
: mode === 'axisAngle'
|
|
512
516
|
? new AxisAngleGenerator(
|
|
513
|
-
|
|
517
|
+
{x: 0, y: 1, z: 0},
|
|
514
518
|
new ConstantValue(rotationState.value)
|
|
515
519
|
)
|
|
516
520
|
: mode === 'euler'
|
|
@@ -1220,7 +1224,7 @@ export function RendererModule({
|
|
|
1220
1224
|
onChange={(v) =>
|
|
1221
1225
|
binding.apply((s) => {
|
|
1222
1226
|
(s.rendererEmitterSettings as TrailSettings).sideAxis = v
|
|
1223
|
-
?
|
|
1227
|
+
? {x: 0, y: 1, z: 0}
|
|
1224
1228
|
: undefined;
|
|
1225
1229
|
})
|
|
1226
1230
|
}
|
|
@@ -1233,8 +1237,7 @@ export function RendererModule({
|
|
|
1233
1237
|
onChange={(axis) =>
|
|
1234
1238
|
binding.apply((s) => {
|
|
1235
1239
|
// The axis's length scales the width: keep it a unit vector.
|
|
1236
|
-
(s.rendererEmitterSettings as TrailSettings).sideAxis =
|
|
1237
|
-
axis.length() > 0 ? axis.normalize() : axis;
|
|
1240
|
+
(s.rendererEmitterSettings as TrailSettings).sideAxis = unitOrZero(axis);
|
|
1238
1241
|
})
|
|
1239
1242
|
}
|
|
1240
1243
|
/>
|
|
@@ -1318,7 +1321,7 @@ export function RendererModule({
|
|
|
1318
1321
|
step={0.1}
|
|
1319
1322
|
onChange={(v) =>
|
|
1320
1323
|
binding.apply((s) => {
|
|
1321
|
-
const next = s.flip?.
|
|
1324
|
+
const next = {x: s.flip?.x ?? 0, y: s.flip?.y ?? 0};
|
|
1322
1325
|
next[axis] = Math.min(1, Math.max(0, v));
|
|
1323
1326
|
s.flip = next.x === 0 && next.y === 0 ? undefined : next;
|
|
1324
1327
|
})
|
|
@@ -1705,12 +1708,12 @@ export function RendererModule({
|
|
|
1705
1708
|
step={0.05}
|
|
1706
1709
|
onChange={(v) =>
|
|
1707
1710
|
binding.apply((s) => {
|
|
1708
|
-
const next = s.ringBufferLoopRange.
|
|
1711
|
+
const next = {x: s.ringBufferLoopRange.x, y: s.ringBufferLoopRange.y};
|
|
1709
1712
|
next[end] = Math.min(1, Math.max(0, v));
|
|
1710
|
-
s.ringBufferLoopRange =
|
|
1711
|
-
Math.min(next.x, next.y),
|
|
1712
|
-
Math.max(next.x, next.y)
|
|
1713
|
-
|
|
1713
|
+
s.ringBufferLoopRange = {
|
|
1714
|
+
x: Math.min(next.x, next.y),
|
|
1715
|
+
y: Math.max(next.x, next.y),
|
|
1716
|
+
};
|
|
1714
1717
|
})
|
|
1715
1718
|
}
|
|
1716
1719
|
/>
|
|
@@ -1728,7 +1731,7 @@ export function RendererModule({
|
|
|
1728
1731
|
step={0.05}
|
|
1729
1732
|
onChange={(v) =>
|
|
1730
1733
|
binding.apply((s) => {
|
|
1731
|
-
const next =
|
|
1734
|
+
const next = {x: s.pivot?.x ?? 0, y: s.pivot?.y ?? 0, z: s.pivot?.z ?? 0};
|
|
1732
1735
|
next[axis] = v;
|
|
1733
1736
|
s.pivot = next;
|
|
1734
1737
|
})
|
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';
|