pixi-effects 0.6.0 → 0.7.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 +15 -0
- package/README.md +16 -10
- package/ai/SKILL.md +1 -1
- package/ai/reference/cheatsheet.md +5 -1
- package/ai/template.html +4 -3
- package/ai/tools/check.mjs +14 -5
- package/ai/tools/render.mjs +202 -0
- package/ai/tools/view.mjs +269 -0
- package/dist/{Base-4vNLl4tH.d.cts → Base-CSIulyIq.d.cts} +1 -1
- package/dist/{Base-CD4AoT5-.d.ts → Base-DVgwyIUj.d.ts} +1 -1
- package/dist/Composition-3KHQPRBA.cjs +14 -0
- package/dist/{Composition-Y5VZSDDP.cjs.map → Composition-3KHQPRBA.cjs.map} +1 -1
- package/dist/Composition-DT657FO5.js +5 -0
- package/dist/{Composition-7SO5WYHU.js.map → Composition-DT657FO5.js.map} +1 -1
- package/dist/Controller.cjs +67 -0
- package/dist/Controller.cjs.map +1 -1
- package/dist/Controller.d.cts +15 -2
- package/dist/Controller.d.ts +15 -2
- package/dist/Controller.js +67 -0
- package/dist/Controller.js.map +1 -1
- package/dist/{Movie-CADDBfpl.d.cts → Movie-B0OUKlZI.d.ts} +52 -2
- package/dist/{Movie-Ch2SUI1h.d.ts → Movie-BK9daiTt.d.cts} +52 -2
- package/dist/{chunk-B2FTJLNB.js → chunk-36Z4RIRK.js} +3 -3
- package/dist/{chunk-B2FTJLNB.js.map → chunk-36Z4RIRK.js.map} +1 -1
- package/dist/{chunk-7IJHJXDI.js → chunk-4O2NYDJG.js} +127 -10
- package/dist/chunk-4O2NYDJG.js.map +1 -0
- package/dist/{chunk-4AGJF5RK.cjs → chunk-4VSIJLU3.cjs} +21 -21
- package/dist/{chunk-4AGJF5RK.cjs.map → chunk-4VSIJLU3.cjs.map} +1 -1
- package/dist/{chunk-KQM2ZZMK.cjs → chunk-6I55T4OH.cjs} +166 -29
- package/dist/chunk-6I55T4OH.cjs.map +1 -0
- package/dist/index.cjs +188 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +180 -9
- package/dist/index.js.map +1 -1
- package/dist/three.cjs +6 -5
- package/dist/three.cjs.map +1 -1
- package/dist/three.d.cts +2 -2
- package/dist/three.d.ts +2 -2
- package/dist/three.js +2 -1
- package/dist/three.js.map +1 -1
- package/dist/{types-DrW9QeKU.d.ts → types-oJijbn-K.d.cts} +14 -1
- package/dist/{types-DrW9QeKU.d.cts → types-oJijbn-K.d.ts} +14 -1
- package/docs/api.md +6 -0
- package/docs/dsl.md +48 -1
- package/llms-full.txt +60 -3
- package/package.json +7 -4
- package/dist/Composition-7SO5WYHU.js +0 -4
- package/dist/Composition-Y5VZSDDP.cjs +0 -13
- package/dist/chunk-7IJHJXDI.js.map +0 -1
- package/dist/chunk-KQM2ZZMK.cjs.map +0 -1
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkUQBGW5DO_cjs = require('./chunk-UQBGW5DO.cjs');
|
|
4
|
+
var PIXI = require('pixi.js');
|
|
4
5
|
var gsap = require('gsap');
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var PIXI__namespace = /*#__PURE__*/_interopNamespace(PIXI);
|
|
7
26
|
|
|
8
27
|
// src/expr/Parser.ts
|
|
9
28
|
var FUNCS = {
|
|
@@ -639,10 +658,10 @@ fn mainFragment(@location(0) uv : vec2<f32>) -> @location(0) vec4<f32> {
|
|
|
639
658
|
`;
|
|
640
659
|
function toRgb01(input) {
|
|
641
660
|
if (Array.isArray(input)) return [input[0], input[1], input[2]];
|
|
642
|
-
const c = new
|
|
661
|
+
const c = new PIXI.Color(input);
|
|
643
662
|
return [c.red, c.green, c.blue];
|
|
644
663
|
}
|
|
645
|
-
var ChromaKeyFilter = class extends
|
|
664
|
+
var ChromaKeyFilter = class extends PIXI.Filter {
|
|
646
665
|
constructor(options = {}) {
|
|
647
666
|
const {
|
|
648
667
|
keyColor = "#00ff00",
|
|
@@ -650,12 +669,12 @@ var ChromaKeyFilter = class extends pixi_js.Filter {
|
|
|
650
669
|
smoothing = 0.1,
|
|
651
670
|
spill = 0.2
|
|
652
671
|
} = options;
|
|
653
|
-
const glProgram =
|
|
654
|
-
vertex:
|
|
672
|
+
const glProgram = PIXI.GlProgram.from({
|
|
673
|
+
vertex: PIXI.defaultFilterVert,
|
|
655
674
|
fragment: GL_FRAGMENT,
|
|
656
675
|
name: "chroma-key-filter"
|
|
657
676
|
});
|
|
658
|
-
const gpuProgram =
|
|
677
|
+
const gpuProgram = PIXI.GpuProgram.from({
|
|
659
678
|
vertex: { source: WGSL_SOURCE, entryPoint: "mainVertex" },
|
|
660
679
|
fragment: { source: WGSL_SOURCE, entryPoint: "mainFragment" }
|
|
661
680
|
});
|
|
@@ -663,7 +682,7 @@ var ChromaKeyFilter = class extends pixi_js.Filter {
|
|
|
663
682
|
glProgram,
|
|
664
683
|
gpuProgram,
|
|
665
684
|
resources: {
|
|
666
|
-
chromaUniforms: new
|
|
685
|
+
chromaUniforms: new PIXI.UniformGroup({
|
|
667
686
|
uKeyColor: { value: toRgb01(keyColor), type: "vec3<f32>" },
|
|
668
687
|
uThreshold: { value: threshold, type: "f32" },
|
|
669
688
|
uSmoothing: { value: smoothing, type: "f32" },
|
|
@@ -698,6 +717,124 @@ var ChromaKeyFilter = class extends pixi_js.Filter {
|
|
|
698
717
|
u[2] = rgb[2];
|
|
699
718
|
}
|
|
700
719
|
};
|
|
720
|
+
var CORE = { blur: "BlurFilter", noise: "NoiseFilter", alpha: "AlphaFilter" };
|
|
721
|
+
var CORE_TYPES = [...Object.keys(CORE), "colorMatrix"];
|
|
722
|
+
var LIBRARY_TYPES = [
|
|
723
|
+
"adjustment",
|
|
724
|
+
"advancedBloom",
|
|
725
|
+
"ascii",
|
|
726
|
+
"backdropBlur",
|
|
727
|
+
"bevel",
|
|
728
|
+
"bloom",
|
|
729
|
+
"bulgePinch",
|
|
730
|
+
"colorGradient",
|
|
731
|
+
"colorMap",
|
|
732
|
+
"colorOverlay",
|
|
733
|
+
"colorReplace",
|
|
734
|
+
"convolution",
|
|
735
|
+
"crossHatch",
|
|
736
|
+
"crt",
|
|
737
|
+
"dot",
|
|
738
|
+
"dropShadow",
|
|
739
|
+
"emboss",
|
|
740
|
+
"glitch",
|
|
741
|
+
"glow",
|
|
742
|
+
"godray",
|
|
743
|
+
"grayscale",
|
|
744
|
+
"hslAdjustment",
|
|
745
|
+
"kawaseBlur",
|
|
746
|
+
"motionBlur",
|
|
747
|
+
"multiColorReplace",
|
|
748
|
+
"oldFilm",
|
|
749
|
+
"outline",
|
|
750
|
+
"pixelate",
|
|
751
|
+
"radialBlur",
|
|
752
|
+
"reflection",
|
|
753
|
+
"rgbSplit",
|
|
754
|
+
"shockwave",
|
|
755
|
+
"simpleLightmap",
|
|
756
|
+
"simplexNoise",
|
|
757
|
+
"tiltShift",
|
|
758
|
+
"tiltShiftAxis",
|
|
759
|
+
"twist",
|
|
760
|
+
"zoomBlur"
|
|
761
|
+
];
|
|
762
|
+
var FILTER_TYPES = [...CORE_TYPES, ...LIBRARY_TYPES];
|
|
763
|
+
var NOT_NAMED = /* @__PURE__ */ new Set(["custom", "chromaKey"]);
|
|
764
|
+
var lower = (s) => s.toLowerCase();
|
|
765
|
+
var isLibraryType = (t) => LIBRARY_TYPES.some((n) => lower(n) === lower(t));
|
|
766
|
+
var isCoreType = (t) => CORE_TYPES.some((n) => lower(n) === lower(t));
|
|
767
|
+
function isNamedFilterType(t) {
|
|
768
|
+
return !NOT_NAMED.has(t);
|
|
769
|
+
}
|
|
770
|
+
function unknownType(t) {
|
|
771
|
+
const guess = chunkUQBGW5DO_cjs.suggestName(t, FILTER_TYPES);
|
|
772
|
+
return new Error(`pixi-effects: unknown filter type "${t}"${guess ? ` \u2014 did you mean "${guess}"?` : ""} (valid: ${[...FILTER_TYPES, "chromaKey", "custom"].join(", ")})`);
|
|
773
|
+
}
|
|
774
|
+
var library = null;
|
|
775
|
+
function registerFilterLibrary(mod) {
|
|
776
|
+
library = /* @__PURE__ */ new Map();
|
|
777
|
+
for (const [key, value] of Object.entries(mod)) {
|
|
778
|
+
if (key.endsWith("Filter") && typeof value === "function") library.set(lower(key.slice(0, -"Filter".length)), value);
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
var MISSING = (type, why) => new Error(
|
|
782
|
+
`pixi-effects: the filter "${type}" comes from the pixi-filters package${why ? ` (${why})` : ""}. Add it to your import map ("pixi-filters": "https://esm.sh/pixi-filters@6.1.5?external=pixi.js") or run \`npm i pixi-filters\`.`
|
|
783
|
+
);
|
|
784
|
+
function needsFilterLibrary(spec) {
|
|
785
|
+
let needs = false;
|
|
786
|
+
const visit = (node) => {
|
|
787
|
+
if (!node || typeof node !== "object") return;
|
|
788
|
+
if (Array.isArray(node)) {
|
|
789
|
+
node.forEach(visit);
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
792
|
+
const o = node;
|
|
793
|
+
if (Array.isArray(o.filters)) {
|
|
794
|
+
for (const f of o.filters) {
|
|
795
|
+
if (typeof f?.type !== "string" || !isNamedFilterType(f.type)) continue;
|
|
796
|
+
if (isLibraryType(f.type)) needs = true;
|
|
797
|
+
else if (!isCoreType(f.type)) throw unknownType(f.type);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
for (const key of ["sequences", "mask"]) visit(o[key]);
|
|
801
|
+
};
|
|
802
|
+
visit(spec);
|
|
803
|
+
return needs;
|
|
804
|
+
}
|
|
805
|
+
async function ensureFilterLibrary(spec, load = () => import('pixi-filters')) {
|
|
806
|
+
if (!needsFilterLibrary(spec) || library) return;
|
|
807
|
+
try {
|
|
808
|
+
registerFilterLibrary(await load());
|
|
809
|
+
} catch (e) {
|
|
810
|
+
throw MISSING("(see the type in your filters)", e.message);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
var SINGLE_VALUE = { pixelate: "size", emboss: "strength" };
|
|
814
|
+
var MATRIX_PRESETS = ["sepia", "grayscale", "negative", "polaroid", "technicolor", "vintage", "kodachrome", "browni"];
|
|
815
|
+
function colorMatrix(params) {
|
|
816
|
+
const f = new PIXI__namespace.ColorMatrixFilter();
|
|
817
|
+
const preset = params.preset;
|
|
818
|
+
if (preset !== void 0) {
|
|
819
|
+
if (!MATRIX_PRESETS.includes(preset)) {
|
|
820
|
+
const guess = chunkUQBGW5DO_cjs.suggestName(preset, MATRIX_PRESETS);
|
|
821
|
+
throw new Error(`pixi-effects: colorMatrix preset "${preset}" is not one of ${MATRIX_PRESETS.join(", ")}${guess ? ` \u2014 did you mean "${guess}"?` : ""}`);
|
|
822
|
+
}
|
|
823
|
+
f[preset === "grayscale" ? "desaturate" : preset].call(f);
|
|
824
|
+
}
|
|
825
|
+
if (Array.isArray(params.matrix)) f.matrix = params.matrix;
|
|
826
|
+
return f;
|
|
827
|
+
}
|
|
828
|
+
function createNamedFilter(type, params) {
|
|
829
|
+
if (lower(type) === "colormatrix") return colorMatrix(params);
|
|
830
|
+
const core = Object.entries(CORE).find(([k]) => lower(k) === lower(type));
|
|
831
|
+
if (core) return new PIXI__namespace[core[1]](params);
|
|
832
|
+
if (!isLibraryType(type)) throw unknownType(type);
|
|
833
|
+
const Ctor = library?.get(lower(type));
|
|
834
|
+
if (!Ctor) throw MISSING(type, library ? "not found in the loaded package" : "not loaded yet");
|
|
835
|
+
const single = SINGLE_VALUE[Object.keys(SINGLE_VALUE).find((k) => lower(k) === lower(type)) ?? ""];
|
|
836
|
+
return single ? new Ctor(params[single]) : new Ctor(params);
|
|
837
|
+
}
|
|
701
838
|
|
|
702
839
|
// src/filters/index.ts
|
|
703
840
|
var registry = {
|
|
@@ -716,10 +853,9 @@ function createFilter(spec) {
|
|
|
716
853
|
named._name = spec.name;
|
|
717
854
|
return named;
|
|
718
855
|
}
|
|
719
|
-
const
|
|
720
|
-
|
|
721
|
-
const
|
|
722
|
-
const inst = new Cls(params);
|
|
856
|
+
const { type, name, ...params } = spec;
|
|
857
|
+
const Cls = registry[type];
|
|
858
|
+
const inst = Cls ? new Cls(params) : createNamedFilter(type, params);
|
|
723
859
|
inst._name = name;
|
|
724
860
|
return inst;
|
|
725
861
|
}
|
|
@@ -768,7 +904,7 @@ var Sequence = class {
|
|
|
768
904
|
}
|
|
769
905
|
const fa = this.spec.filterArea;
|
|
770
906
|
if (fa && this.target) {
|
|
771
|
-
this.target.filterArea = new
|
|
907
|
+
this.target.filterArea = new PIXI.Rectangle(fa.x, fa.y, fa.width, fa.height);
|
|
772
908
|
}
|
|
773
909
|
}
|
|
774
910
|
scope() {
|
|
@@ -995,7 +1131,7 @@ var CameraSequence = class extends Sequence {
|
|
|
995
1131
|
this.duration = this.parent?.duration ?? this.root.duration;
|
|
996
1132
|
}
|
|
997
1133
|
const home = homeCamera(compW, this.compH);
|
|
998
|
-
const carrier = new
|
|
1134
|
+
const carrier = new PIXI.Container();
|
|
999
1135
|
carrier.x = home.x;
|
|
1000
1136
|
carrier.y = home.y;
|
|
1001
1137
|
carrier.z = home.z;
|
|
@@ -1223,8 +1359,8 @@ function tweenColor(timeline, target, key, fromValue, toValue, duration, ease, a
|
|
|
1223
1359
|
// src/sequences/Image.ts
|
|
1224
1360
|
var ImageSequence = class extends Sequence {
|
|
1225
1361
|
async build() {
|
|
1226
|
-
const texture = await
|
|
1227
|
-
const sprite = new
|
|
1362
|
+
const texture = await PIXI.Assets.get(this.spec.asset);
|
|
1363
|
+
const sprite = new PIXI.Sprite({ texture, label: this.spec.name });
|
|
1228
1364
|
sprite.cullable = true;
|
|
1229
1365
|
this.target = sprite;
|
|
1230
1366
|
this.intrinsicWidth = texture.width;
|
|
@@ -1363,7 +1499,7 @@ var TextSequence = class extends Sequence {
|
|
|
1363
1499
|
};
|
|
1364
1500
|
const initialProps = this.spec.initial ?? {};
|
|
1365
1501
|
this._template = String(initialProps.text ?? this.spec.text ?? "");
|
|
1366
|
-
const text = new
|
|
1502
|
+
const text = new PIXI.Text({
|
|
1367
1503
|
text: this._template,
|
|
1368
1504
|
style: baseStyle,
|
|
1369
1505
|
label: this.spec.name
|
|
@@ -1549,7 +1685,7 @@ var AudioSequence = class extends Sequence {
|
|
|
1549
1685
|
if (this.spec.sfx !== void 0) return this._buildSfx(this.spec);
|
|
1550
1686
|
const spec = this.spec;
|
|
1551
1687
|
this._source = `asset "${spec.asset}"`;
|
|
1552
|
-
const data = await
|
|
1688
|
+
const data = await PIXI.Assets.get(spec.asset);
|
|
1553
1689
|
this._audioBuffer = data.audioBuffer;
|
|
1554
1690
|
if (this.duration === void 0) {
|
|
1555
1691
|
const rest = Math.max(0, (this.parent?.duration ?? this.root.duration) - this.at);
|
|
@@ -1720,7 +1856,7 @@ var VideoSequence = class extends Sequence {
|
|
|
1720
1856
|
_ctx = null;
|
|
1721
1857
|
_drawSeq = 0;
|
|
1722
1858
|
async build() {
|
|
1723
|
-
const data = await
|
|
1859
|
+
const data = await PIXI.Assets.get(this.spec.asset);
|
|
1724
1860
|
this._sourceDuration = data.duration;
|
|
1725
1861
|
this._audioBuffer = this.spec.audio !== false ? data.audioBuffer : null;
|
|
1726
1862
|
this._cache = new FrameCache(data.sink, { capacity: 30 });
|
|
@@ -1733,8 +1869,8 @@ var VideoSequence = class extends Sequence {
|
|
|
1733
1869
|
this._canvas = canvas;
|
|
1734
1870
|
this._ctx = canvas.getContext("2d", { alpha: true });
|
|
1735
1871
|
if (probeFrame && this._ctx) this._ctx.drawImage(probeFrame, 0, 0);
|
|
1736
|
-
const texture =
|
|
1737
|
-
const sprite = new
|
|
1872
|
+
const texture = PIXI.Texture.from(canvas);
|
|
1873
|
+
const sprite = new PIXI.Sprite({ texture, label: this.spec.name });
|
|
1738
1874
|
sprite.cullable = true;
|
|
1739
1875
|
this.target = sprite;
|
|
1740
1876
|
this.intrinsicWidth = w;
|
|
@@ -1857,15 +1993,15 @@ function makeGradientFill(g) {
|
|
|
1857
1993
|
const ctx = canvas.getContext("2d");
|
|
1858
1994
|
if (ctx) {
|
|
1859
1995
|
paintRadial(ctx, RADIAL_SIZE, g);
|
|
1860
|
-
return { texture:
|
|
1996
|
+
return { texture: PIXI.Texture.from(canvas), textureSpace: "local" };
|
|
1861
1997
|
}
|
|
1862
1998
|
}
|
|
1863
|
-
return new
|
|
1999
|
+
return new PIXI.FillGradient(gradientOptions(g));
|
|
1864
2000
|
}
|
|
1865
2001
|
var CURVE_STEPS = 24;
|
|
1866
2002
|
var ELLIPSE_STEPS = 128;
|
|
1867
2003
|
function flattenSvgPath(d) {
|
|
1868
|
-
const prims = new
|
|
2004
|
+
const prims = new PIXI.GraphicsPath(d).shapePath.shapePrimitives;
|
|
1869
2005
|
const out = [];
|
|
1870
2006
|
for (const { shape } of prims) {
|
|
1871
2007
|
const poly = shape;
|
|
@@ -1978,7 +2114,7 @@ var ShapeSequence = class extends Sequence {
|
|
|
1978
2114
|
};
|
|
1979
2115
|
_liveKeys = new Set(STYLE_KEYS);
|
|
1980
2116
|
async build() {
|
|
1981
|
-
const graphics = new
|
|
2117
|
+
const graphics = new PIXI.Graphics({ label: this.spec.name });
|
|
1982
2118
|
graphics.cullable = true;
|
|
1983
2119
|
this.target = graphics;
|
|
1984
2120
|
if (this.duration === void 0) {
|
|
@@ -2258,7 +2394,7 @@ function makePolygonDraw(spec, scope) {
|
|
|
2258
2394
|
}
|
|
2259
2395
|
function makePathDraw(spec) {
|
|
2260
2396
|
return (g) => {
|
|
2261
|
-
g.path(new
|
|
2397
|
+
g.path(new PIXI.GraphicsPath(spec.d));
|
|
2262
2398
|
};
|
|
2263
2399
|
}
|
|
2264
2400
|
var STATE_DRAWERS = {
|
|
@@ -2389,7 +2525,7 @@ function numOrZero(v, scope) {
|
|
|
2389
2525
|
var _CompositionSequence = null;
|
|
2390
2526
|
async function getCompositionSequence() {
|
|
2391
2527
|
if (!_CompositionSequence) {
|
|
2392
|
-
_CompositionSequence = (await import('./Composition-
|
|
2528
|
+
_CompositionSequence = (await import('./Composition-3KHQPRBA.cjs')).CompositionSequence;
|
|
2393
2529
|
}
|
|
2394
2530
|
return _CompositionSequence;
|
|
2395
2531
|
}
|
|
@@ -2436,6 +2572,7 @@ exports.buildSequenceTree = buildSequenceTree;
|
|
|
2436
2572
|
exports.cameraBasis = cameraBasis;
|
|
2437
2573
|
exports.collectPropKeys = collectPropKeys;
|
|
2438
2574
|
exports.describeLayer = describeLayer;
|
|
2575
|
+
exports.ensureFilterLibrary = ensureFilterLibrary;
|
|
2439
2576
|
exports.evaluateExpr = evaluateExpr;
|
|
2440
2577
|
exports.homeCamera = homeCamera;
|
|
2441
2578
|
exports.homeDistance = homeDistance;
|
|
@@ -2445,5 +2582,5 @@ exports.projectLayer = projectLayer;
|
|
|
2445
2582
|
exports.registerSequenceType = registerSequenceType;
|
|
2446
2583
|
exports.resolveAt = resolveAt;
|
|
2447
2584
|
exports.summarizeWarnings = summarizeWarnings;
|
|
2448
|
-
//# sourceMappingURL=chunk-
|
|
2449
|
-
//# sourceMappingURL=chunk-
|
|
2585
|
+
//# sourceMappingURL=chunk-6I55T4OH.cjs.map
|
|
2586
|
+
//# sourceMappingURL=chunk-6I55T4OH.cjs.map
|