@moku-labs/game 0.15.151 → 0.15.153
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/README.md +1 -1
- package/dist/app/page.d.mts +1 -1
- package/dist/app/system.d.mts +2 -2
- package/dist/app.d.mts +1 -1
- package/dist/app.mjs +1 -1
- package/dist/{commands-DXSaq2AP.d.mts → commands-CBxAIuzU.d.mts} +1 -1
- package/dist/control.d.mts +1 -1
- package/dist/{index-Dgwheaoi.d.mts → index-DiZomBIu.d.mts} +91 -4
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +2 -2
- package/dist/inspect.d.mts +1 -1
- package/dist/{src-CpV819p3.mjs → src-Dd04I2Us.mjs} +524 -162
- package/dist/testing.d.mts +2 -2
- package/dist/testing.mjs +1 -1
- package/dist/{types-BpmdVJso.d.mts → types-D_eHSpKN.d.mts} +84 -3
- package/dist/{types-C2-KGQGt.d.mts → types-TjhiJIZ4.d.mts} +2 -2
- package/dist/{visual-Dw4QXpgC.d.mts → visual-ACZOnh3-.d.mts} +2 -2
- package/dist/visual.d.mts +1 -1
- package/llms.txt +2 -2
- package/package.json +1 -1
|
@@ -41497,6 +41497,61 @@ function localTargetOf(ecs, entity, component, to) {
|
|
|
41497
41497
|
return local;
|
|
41498
41498
|
}
|
|
41499
41499
|
//#endregion
|
|
41500
|
+
//#region src/plugins/renderer/color.ts
|
|
41501
|
+
/**
|
|
41502
|
+
* Mixes two `0xrrggbb` colours, linear per channel, each channel rounded to a whole number. A
|
|
41503
|
+
* colour mixed as one number borrows across channels: white to grey passes magenta.
|
|
41504
|
+
*
|
|
41505
|
+
* @param from - The colour at `t` 0.
|
|
41506
|
+
* @param to - The colour at `t` 1.
|
|
41507
|
+
* @param t - Where between them; read as is, so an overshooting ease is clamped per channel.
|
|
41508
|
+
* @returns The `0xrrggbb` colour at `t`, a whole number.
|
|
41509
|
+
* @example
|
|
41510
|
+
* ```ts
|
|
41511
|
+
* mixColor(0xff_ff_ff, 0xc7_c7_c7, 0.5); // 0xe3e3e3
|
|
41512
|
+
* ```
|
|
41513
|
+
*/
|
|
41514
|
+
function mixColor(from, to, t) {
|
|
41515
|
+
return mixChannel(from, to, t, 16) << 16 | mixChannel(from, to, t, 8) << 8 | mixChannel(from, to, t, 0);
|
|
41516
|
+
}
|
|
41517
|
+
/**
|
|
41518
|
+
* One channel of a per-channel mix, rounded and kept inside 0..255.
|
|
41519
|
+
*
|
|
41520
|
+
* @param from - The colour at `t` 0.
|
|
41521
|
+
* @param to - The colour at `t` 1.
|
|
41522
|
+
* @param t - Where between them.
|
|
41523
|
+
* @param shift - The bit offset of the channel: 16 red, 8 green, 0 blue.
|
|
41524
|
+
* @returns The channel, 0..255.
|
|
41525
|
+
* @example
|
|
41526
|
+
* ```ts
|
|
41527
|
+
* mixChannel(0xff_00_00, 0x00_00_00, 0.5, 16); // 128
|
|
41528
|
+
* ```
|
|
41529
|
+
*/
|
|
41530
|
+
function mixChannel(from, to, t, shift) {
|
|
41531
|
+
const start = from >> shift & 255;
|
|
41532
|
+
const end = to >> shift & 255;
|
|
41533
|
+
const value = Math.round(start + (end - start) * t);
|
|
41534
|
+
return Math.min(Math.max(value, 0), 255);
|
|
41535
|
+
}
|
|
41536
|
+
/**
|
|
41537
|
+
* Tells whether a field of a component holds a `0xrrggbb` colour: the `tint` of a `Sprite` or a
|
|
41538
|
+
* `NineSlice`, the `fill` and the `stroke` of a `Shape`. A game's own component never does, so a
|
|
41539
|
+
* field of its own named `fill` stays a number.
|
|
41540
|
+
*
|
|
41541
|
+
* @param component - The component the field belongs to.
|
|
41542
|
+
* @param field - The field name.
|
|
41543
|
+
* @returns True for a colour field.
|
|
41544
|
+
* @example
|
|
41545
|
+
* ```ts
|
|
41546
|
+
* isColorField(Sprite, "tint"); // true
|
|
41547
|
+
* ```
|
|
41548
|
+
*/
|
|
41549
|
+
function isColorField(component, field) {
|
|
41550
|
+
if (component === Sprite || component === NineSlice) return field === "tint";
|
|
41551
|
+
if (component === Shape) return field === "fill" || field === "stroke";
|
|
41552
|
+
return false;
|
|
41553
|
+
}
|
|
41554
|
+
//#endregion
|
|
41500
41555
|
//#region src/plugins/anim/tween/cells.ts
|
|
41501
41556
|
/** The running sum of `sumOffsets`: a cell, so neither the sum nor its callback allocates. */
|
|
41502
41557
|
const SUM = /* @__PURE__ */ new Float64Array(1);
|
|
@@ -41789,6 +41844,20 @@ function beginTrack(actx, track, stored) {
|
|
|
41789
41844
|
}
|
|
41790
41845
|
}
|
|
41791
41846
|
/**
|
|
41847
|
+
* The value of a slot between two values at the eased time in `values[slot]`: a number mixed as
|
|
41848
|
+
* one, a colour per channel and rounded (F219), so white to grey passes only greys.
|
|
41849
|
+
*
|
|
41850
|
+
* @param track - The track, its eased time in `values[slot]`.
|
|
41851
|
+
* @param slot - The slot.
|
|
41852
|
+
* @param from - The value at eased time 0.
|
|
41853
|
+
* @param to - The value at eased time 1.
|
|
41854
|
+
* @returns The value of the slot now.
|
|
41855
|
+
*/
|
|
41856
|
+
function mixed(track, slot, from, to) {
|
|
41857
|
+
const t = track.values[slot] ?? 0;
|
|
41858
|
+
return track.colors[slot] === 1 ? mixColor(from, to, t) : from + (to - from) * t;
|
|
41859
|
+
}
|
|
41860
|
+
/**
|
|
41792
41861
|
* Walks the keyframe segments of a track to its normalised time `clock[1]`, for one slot. Each
|
|
41793
41862
|
* segment eases, with its own curve or the track's, from where the segment before left the
|
|
41794
41863
|
* field; a segment that does not name the field holds it, and past the last segment the field
|
|
@@ -41817,7 +41886,7 @@ function walkSlot(track, segments, slot) {
|
|
|
41817
41886
|
return;
|
|
41818
41887
|
}
|
|
41819
41888
|
easeCell(segment.ease ?? track.ease, values, slot);
|
|
41820
|
-
values[slot] =
|
|
41889
|
+
values[slot] = mixed(track, slot, from, target);
|
|
41821
41890
|
return;
|
|
41822
41891
|
}
|
|
41823
41892
|
from = target;
|
|
@@ -41846,7 +41915,7 @@ function slotValue(track, slot, final) {
|
|
|
41846
41915
|
const start = track.starts[slot] ?? 0;
|
|
41847
41916
|
values[slot] = track.clock[1] ?? 0;
|
|
41848
41917
|
easeCell(track.ease, values, slot);
|
|
41849
|
-
values[slot] =
|
|
41918
|
+
values[slot] = mixed(track, slot, start, track.targets[slot] ?? 0);
|
|
41850
41919
|
} else walkSlot(track, segments, slot);
|
|
41851
41920
|
if (track.additive && !walksOffsets) values[slot] = (values[slot] ?? 0) - (track.starts[slot] ?? 0);
|
|
41852
41921
|
}
|
|
@@ -42282,6 +42351,7 @@ function startTrack$1(actx, entity, component, to, options, muted, driven = fals
|
|
|
42282
42351
|
live: new Uint8Array(names.length).fill(1),
|
|
42283
42352
|
moved: new Uint8Array(names.length),
|
|
42284
42353
|
values: new Float64Array(names.length),
|
|
42354
|
+
colors: Uint8Array.from(names, (field) => isColorField(component, field) ? 1 : 0),
|
|
42285
42355
|
seen: new Float64Array(names.length).fill(NaN),
|
|
42286
42356
|
muted,
|
|
42287
42357
|
additive: options.additive === true,
|
|
@@ -50545,6 +50615,140 @@ function createEffectsApi(ctx) {
|
|
|
50545
50615
|
};
|
|
50546
50616
|
}
|
|
50547
50617
|
//#endregion
|
|
50618
|
+
//#region src/plugins/effects/set/head.ts
|
|
50619
|
+
/**
|
|
50620
|
+
* @file effects/set — the set head: the WGSL and GLSL the engine's effect set puts before every member's body. Four
|
|
50621
|
+
* helpers: `inputPlace(uv)`, where the pixel is in its input frame (0..1 on each axis, the padded frame Pixi hands the
|
|
50622
|
+
* filter), and `sampleInput(n)`, the input read at such a place, inside the clamp; `inputFrame()`, the size of that
|
|
50623
|
+
* frame in CSS px, for a padded member that maps its content box; and `setHash(cell)`, the integer hash of `Dissolve`.
|
|
50624
|
+
* They read the input's own uniforms (`uInputClamp`, `uInputPixel`, `uInputSize`), never the screen, so a member stays
|
|
50625
|
+
* `"local"`; and the clamp is half a texel in from the frame in a live pass and from the whole picture on the quad of
|
|
50626
|
+
* stage 2 (`shade.ts`), so one body draws the same in both. The first three are the place part, which the built-in
|
|
50627
|
+
* `Outline` draws on too (`withPlaceWgsl`); the hash is the members' alone. A game's body does not get them. Pure
|
|
50628
|
+
* strings.
|
|
50629
|
+
*/
|
|
50630
|
+
/**
|
|
50631
|
+
* The place part of the WGSL head: `inputPlace(uv)` and `sampleInput(n)` over the filter's input, and `inputFrame()`.
|
|
50632
|
+
* `textureSampleLevel`, so a member may read its input inside a branch. `inputFrame()` is the clamp's span plus one
|
|
50633
|
+
* texel, times the texture's CSS size: live the frame is a share of a pooled texture and `uInputSize` is the texture's,
|
|
50634
|
+
* on the quad the frame is the whole picture; both give the frame. The built-in `Outline` draws on it alone
|
|
50635
|
+
* (`withPlaceWgsl`), so every game that composes `effectsPlugin` carries these three and no hash.
|
|
50636
|
+
*/
|
|
50637
|
+
const PLACE_WGSL = `fn inputPlace(uv: vec2<f32>) -> vec2<f32> {
|
|
50638
|
+
return (uv - gfu.uInputClamp.xy) / (gfu.uInputClamp.zw - gfu.uInputClamp.xy);
|
|
50639
|
+
}
|
|
50640
|
+
|
|
50641
|
+
fn sampleInput(n: vec2<f32>) -> vec4<f32> {
|
|
50642
|
+
return textureSampleLevel(uTexture, uSampler, mix(gfu.uInputClamp.xy, gfu.uInputClamp.zw, clamp(n, vec2<f32>(0.0), vec2<f32>(1.0))), 0.0);
|
|
50643
|
+
}
|
|
50644
|
+
|
|
50645
|
+
fn inputFrame() -> vec2<f32> {
|
|
50646
|
+
return (gfu.uInputClamp.zw - gfu.uInputClamp.xy + gfu.uInputPixel.zw) * gfu.uInputSize.xy;
|
|
50647
|
+
}
|
|
50648
|
+
|
|
50649
|
+
`;
|
|
50650
|
+
/**
|
|
50651
|
+
* The hash part of the WGSL head: `setHash(cell)`, a 32-bit integer hash of a cell, 0 up to 1 (24 bits). Integers wrap
|
|
50652
|
+
* the same on every GPU, so WebGL and WebGPU dissolve the same cells.
|
|
50653
|
+
*/
|
|
50654
|
+
const HASH_WGSL = `fn setHash(cell: vec2<f32>) -> f32 {
|
|
50655
|
+
let q = vec2<u32>(vec2<i32>(cell));
|
|
50656
|
+
var h = (q.x * 1597334677u) ^ (q.y * 3812015801u);
|
|
50657
|
+
h = (h ^ (h >> 16u)) * 2246822519u;
|
|
50658
|
+
h = h ^ (h >> 13u);
|
|
50659
|
+
return f32(h >> 8u) / 16777216.0;
|
|
50660
|
+
}
|
|
50661
|
+
|
|
50662
|
+
`;
|
|
50663
|
+
/** The GLSL twin of `PLACE_WGSL`, over `uInputClamp`, `uInputPixel`, `uInputSize` and `uTexture` of the GLSL header. */
|
|
50664
|
+
const PLACE_GLSL = `vec2 inputPlace(vec2 uv) {
|
|
50665
|
+
return (uv - uInputClamp.xy) / (uInputClamp.zw - uInputClamp.xy);
|
|
50666
|
+
}
|
|
50667
|
+
|
|
50668
|
+
vec4 sampleInput(vec2 n) {
|
|
50669
|
+
return textureLod(uTexture, mix(uInputClamp.xy, uInputClamp.zw, clamp(n, 0.0, 1.0)), 0.0);
|
|
50670
|
+
}
|
|
50671
|
+
|
|
50672
|
+
vec2 inputFrame() {
|
|
50673
|
+
return (uInputClamp.zw - uInputClamp.xy + uInputPixel.zw) * uInputSize.xy;
|
|
50674
|
+
}
|
|
50675
|
+
|
|
50676
|
+
`;
|
|
50677
|
+
/**
|
|
50678
|
+
* The GLSL twin of `HASH_WGSL`. The hash's integers are `highp`: the default of a fragment stage is `mediump`, 16 bits
|
|
50679
|
+
* on a phone.
|
|
50680
|
+
*/
|
|
50681
|
+
const HASH_GLSL = `float setHash(vec2 cell) {
|
|
50682
|
+
highp uvec2 q = uvec2(ivec2(cell));
|
|
50683
|
+
highp uint h = (q.x * 1597334677u) ^ (q.y * 3812015801u);
|
|
50684
|
+
h = (h ^ (h >> 16u)) * 2246822519u;
|
|
50685
|
+
h = h ^ (h >> 13u);
|
|
50686
|
+
return float(h >> 8u) / 16777216.0;
|
|
50687
|
+
}
|
|
50688
|
+
|
|
50689
|
+
`;
|
|
50690
|
+
/**
|
|
50691
|
+
* A body with the place part of the head before it, and no hash: the built-in `Outline`'s source. A call, so a bundle
|
|
50692
|
+
* that drops the body drops the text too: a concatenation at module scope would stay, its strings with it.
|
|
50693
|
+
*
|
|
50694
|
+
* @param body - The WGSL body.
|
|
50695
|
+
* @returns The place helpers, then the body.
|
|
50696
|
+
* @example
|
|
50697
|
+
* ```ts
|
|
50698
|
+
* withPlaceWgsl("@fragment fn mainFragment").includes("fn setHash("); // false
|
|
50699
|
+
* ```
|
|
50700
|
+
*/
|
|
50701
|
+
function withPlaceWgsl(body) {
|
|
50702
|
+
return PLACE_WGSL + body;
|
|
50703
|
+
}
|
|
50704
|
+
/**
|
|
50705
|
+
* The GLSL twin of `withPlaceWgsl`.
|
|
50706
|
+
*
|
|
50707
|
+
* @param body - The GLSL body.
|
|
50708
|
+
* @returns The place helpers, then the body.
|
|
50709
|
+
* @example
|
|
50710
|
+
* ```ts
|
|
50711
|
+
* withPlaceGlsl("void main() {}").startsWith("vec2 inputPlace("); // true
|
|
50712
|
+
* ```
|
|
50713
|
+
*/
|
|
50714
|
+
function withPlaceGlsl(body) {
|
|
50715
|
+
return PLACE_GLSL + body;
|
|
50716
|
+
}
|
|
50717
|
+
/**
|
|
50718
|
+
* The WGSL head of every member: the place part, then the hash part, `inputPlace(uv)`, `sampleInput(n)`,
|
|
50719
|
+
* `inputFrame()` and `setHash(cell)`. Made by a call, so a game that lists no member carries neither part's hash.
|
|
50720
|
+
*/
|
|
50721
|
+
const SET_WGSL = /*#__PURE__*/ withPlaceWgsl(HASH_WGSL);
|
|
50722
|
+
/** The GLSL twin of `SET_WGSL`: the same four helpers. */
|
|
50723
|
+
const SET_GLSL = /*#__PURE__*/ withPlaceGlsl(HASH_GLSL);
|
|
50724
|
+
/**
|
|
50725
|
+
* A member's WGSL body with the set head before it. A call, so a bundle that drops the member drops the text too: a
|
|
50726
|
+
* concatenation at module scope would stay, its strings with it.
|
|
50727
|
+
*
|
|
50728
|
+
* @param body - The member's WGSL body.
|
|
50729
|
+
* @returns The head, then the body.
|
|
50730
|
+
* @example
|
|
50731
|
+
* ```ts
|
|
50732
|
+
* withSetWgsl("@fragment fn mainFragment").startsWith("fn inputPlace("); // true
|
|
50733
|
+
* ```
|
|
50734
|
+
*/
|
|
50735
|
+
function withSetWgsl(body) {
|
|
50736
|
+
return SET_WGSL + body;
|
|
50737
|
+
}
|
|
50738
|
+
/**
|
|
50739
|
+
* A member's GLSL body with the set head before it, for the same reason as `withSetWgsl`.
|
|
50740
|
+
*
|
|
50741
|
+
* @param body - The member's GLSL body.
|
|
50742
|
+
* @returns The head, then the body.
|
|
50743
|
+
* @example
|
|
50744
|
+
* ```ts
|
|
50745
|
+
* withSetGlsl("void main() {}").startsWith("vec2 inputPlace("); // true
|
|
50746
|
+
* ```
|
|
50747
|
+
*/
|
|
50748
|
+
function withSetGlsl(body) {
|
|
50749
|
+
return SET_GLSL + body;
|
|
50750
|
+
}
|
|
50751
|
+
//#endregion
|
|
50548
50752
|
//#region src/plugins/effects/filters/wgsl.ts
|
|
50549
50753
|
/**
|
|
50550
50754
|
* The head of every filter shader: the global filter uniforms and the input texture and sampler
|
|
@@ -51633,71 +51837,60 @@ fn mainFragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|
|
51633
51837
|
//#endregion
|
|
51634
51838
|
//#region src/plugins/effects/filters/outline-glsl.ts
|
|
51635
51839
|
/**
|
|
51636
|
-
* @file effects/filters — the GLSL twin of the `Outline` fragment, the same math as
|
|
51637
|
-
*
|
|
51638
|
-
* `color × alpha`, sampled in 8 directions, 12 from 6 px.
|
|
51840
|
+
* @file effects/filters — the GLSL twin of the `Outline` fragment, the same math as `outline-wgsl.ts` for the WebGL
|
|
51841
|
+
* fallback: the source drawn over a hard ring of `thickness` CSS px in `color × alpha`, 12 probes.
|
|
51639
51842
|
*/
|
|
51640
51843
|
/**
|
|
51641
|
-
* The GLSL ES 3.0 fragment body of `Outline`. Reads the uniforms `thickness`, `color` and `alpha`
|
|
51642
|
-
*
|
|
51844
|
+
* The GLSL ES 3.0 fragment body of `Outline`. Reads the uniforms `thickness`, `color` and `alpha` under their bare
|
|
51845
|
+
* names, and the place helpers of the effect set's head.
|
|
51643
51846
|
*/
|
|
51644
51847
|
const OUTLINE_GLSL = `const float OUTLINE_TAU = 6.283185307179586;
|
|
51645
51848
|
|
|
51646
51849
|
void main() {
|
|
51647
|
-
|
|
51648
|
-
|
|
51649
|
-
|
|
51650
|
-
float
|
|
51651
|
-
|
|
51652
|
-
for (int spoke = 0; spoke < spokes; spoke++) {
|
|
51653
|
-
float turn = OUTLINE_TAU * float(spoke) / float(spokes);
|
|
51654
|
-
vec2 probe = clamp(
|
|
51655
|
-
vTextureCoord + vec2(cos(turn), sin(turn)) * texel * thickness,
|
|
51656
|
-
uInputClamp.xy,
|
|
51657
|
-
uInputClamp.zw
|
|
51658
|
-
);
|
|
51850
|
+
vec2 n = inputPlace(vTextureCoord);
|
|
51851
|
+
vec4 c = sampleInput(n);
|
|
51852
|
+
vec2 reach = thickness / inputFrame();
|
|
51853
|
+
float ring = 0.0;
|
|
51659
51854
|
|
|
51660
|
-
|
|
51855
|
+
for (int i = 0; i < 12; i++) {
|
|
51856
|
+
float turn = OUTLINE_TAU * float(i) / 12.0;
|
|
51857
|
+
ring = max(ring, sampleInput(n + vec2(cos(turn), sin(turn)) * reach).a);
|
|
51661
51858
|
}
|
|
51662
51859
|
|
|
51663
|
-
float line =
|
|
51860
|
+
float line = ring * alpha;
|
|
51664
51861
|
|
|
51665
|
-
finalColor =
|
|
51862
|
+
finalColor = c + vec4(color * line, line) * (1.0 - c.a);
|
|
51666
51863
|
}
|
|
51667
51864
|
`;
|
|
51668
51865
|
//#endregion
|
|
51669
51866
|
//#region src/plugins/effects/filters/outline-wgsl.ts
|
|
51670
51867
|
/**
|
|
51671
|
-
* @file effects/filters — the fragment body of `Outline`: the source drawn over a ring of
|
|
51672
|
-
* `
|
|
51673
|
-
* outline does.
|
|
51868
|
+
* @file effects/filters — the fragment body of `Outline`: the source drawn over a hard ring of `thickness` CSS px in
|
|
51869
|
+
* `color × alpha`, the largest alpha of 12 probes on that ring, over the place helpers of the effect set's head.
|
|
51674
51870
|
*/
|
|
51675
51871
|
/**
|
|
51676
|
-
* The WGSL fragment body of `Outline`. Reads `fu.thickness`, `fu.color`, `fu.alpha`.
|
|
51872
|
+
* The WGSL fragment body of `Outline`. Reads `fu.thickness`, `fu.color`, `fu.alpha`. The probes stand on a ring of
|
|
51873
|
+
* `thickness` CSS px around the pixel: `thickness / inputFrame()` is that radius in 0..1 of the padded frame, as
|
|
51874
|
+
* `Aura`'s ring, so the line is as wide as the padding at any resolution. The ring is hard: the largest alpha of the
|
|
51875
|
+
* 12 probes, not their mean. The line is drawn in `color` under the source.
|
|
51677
51876
|
*/
|
|
51678
51877
|
const OUTLINE_WGSL = `const OUTLINE_TAU: f32 = 6.283185307179586;
|
|
51679
51878
|
|
|
51680
51879
|
@fragment
|
|
51681
51880
|
fn mainFragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|
51682
|
-
let
|
|
51683
|
-
let
|
|
51684
|
-
let
|
|
51685
|
-
var
|
|
51686
|
-
|
|
51687
|
-
for (var spoke = 0; spoke < spokes; spoke++) {
|
|
51688
|
-
let turn = OUTLINE_TAU * f32(spoke) / f32(spokes);
|
|
51689
|
-
let probe = clamp(
|
|
51690
|
-
uv + vec2<f32>(cos(turn), sin(turn)) * texel * fu.thickness,
|
|
51691
|
-
gfu.uInputClamp.xy,
|
|
51692
|
-
gfu.uInputClamp.zw
|
|
51693
|
-
);
|
|
51881
|
+
let n = inputPlace(uv);
|
|
51882
|
+
let c = sampleInput(n);
|
|
51883
|
+
let reach = fu.thickness / inputFrame();
|
|
51884
|
+
var ring = 0.0;
|
|
51694
51885
|
|
|
51695
|
-
|
|
51886
|
+
for (var i = 0; i < 12; i++) {
|
|
51887
|
+
let turn = OUTLINE_TAU * f32(i) / 12.0;
|
|
51888
|
+
ring = max(ring, sampleInput(n + vec2<f32>(cos(turn), sin(turn)) * reach).a);
|
|
51696
51889
|
}
|
|
51697
51890
|
|
|
51698
|
-
let line =
|
|
51891
|
+
let line = ring * fu.alpha;
|
|
51699
51892
|
|
|
51700
|
-
return
|
|
51893
|
+
return c + vec4<f32>(fu.color * line, line) * (1.0 - c.a);
|
|
51701
51894
|
}
|
|
51702
51895
|
`;
|
|
51703
51896
|
//#endregion
|
|
@@ -51766,8 +51959,10 @@ const Glow = /*#__PURE__*/ defineFilter("effects.glow", {
|
|
|
51766
51959
|
padding: "distance"
|
|
51767
51960
|
});
|
|
51768
51961
|
/**
|
|
51769
|
-
* A ring of `thickness`
|
|
51770
|
-
* view is padded by its live `thickness`. One
|
|
51962
|
+
* A hard ring of `thickness` CSS px in `color` around the opaque pixels of a view and its subtree,
|
|
51963
|
+
* the largest alpha of 12 probes on that ring; the view is padded by its live `thickness`. One
|
|
51964
|
+
* render pass per apply; on WebGPU a tween of `alpha` draws on the view's own quad, no pass, from
|
|
51965
|
+
* its third frame.
|
|
51771
51966
|
*
|
|
51772
51967
|
* @example
|
|
51773
51968
|
* ```ts
|
|
@@ -51776,8 +51971,8 @@ const Glow = /*#__PURE__*/ defineFilter("effects.glow", {
|
|
|
51776
51971
|
* ```
|
|
51777
51972
|
*/
|
|
51778
51973
|
const Outline = /*#__PURE__*/ defineFilter("effects.outline", {
|
|
51779
|
-
wgsl: OUTLINE_WGSL,
|
|
51780
|
-
glsl: OUTLINE_GLSL,
|
|
51974
|
+
wgsl: /* @__PURE__ */ withPlaceWgsl(OUTLINE_WGSL),
|
|
51975
|
+
glsl: /* @__PURE__ */ withPlaceGlsl(OUTLINE_GLSL),
|
|
51781
51976
|
uniforms: {
|
|
51782
51977
|
thickness: 2,
|
|
51783
51978
|
color: { color: 0 },
|
|
@@ -52098,6 +52293,27 @@ function startValue(uniform, value) {
|
|
|
52098
52293
|
return vector;
|
|
52099
52294
|
}
|
|
52100
52295
|
/**
|
|
52296
|
+
* Moves the number fields the sync reads by a uniform's name to V8's tagged form, once, as an instance is built. V8 may
|
|
52297
|
+
* keep a number field as a raw double, by the history of the object's shape: a `Pixelate`'s one `size` came out so,
|
|
52298
|
+
* `Wave`'s `phase` did not. A read by a name the code learns only at run time, as every read of the sync is
|
|
52299
|
+
* (`value[uniform.name]`, `uniforms[name]`), then hands back a new box of that double: 16 B per read, two reads per
|
|
52300
|
+
* sync of a tweened view. A field that held a non-number once stays tagged for every object of its shape, and a read
|
|
52301
|
+
* hands its number as it is. The number is written back at once; a frozen object (the defaults, a probe's value) is
|
|
52302
|
+
* left alone.
|
|
52303
|
+
*
|
|
52304
|
+
* @param target - The stored filter value, or the values of the uniform group.
|
|
52305
|
+
* @param uniforms - The uniforms of the definition.
|
|
52306
|
+
*/
|
|
52307
|
+
function tagNumbers(target, uniforms) {
|
|
52308
|
+
if (Object.isFrozen(target)) return;
|
|
52309
|
+
for (const { name } of uniforms) {
|
|
52310
|
+
const held = target[name];
|
|
52311
|
+
if (typeof held !== "number") continue;
|
|
52312
|
+
Reflect.set(target, name, false);
|
|
52313
|
+
target[name] = held;
|
|
52314
|
+
}
|
|
52315
|
+
}
|
|
52316
|
+
/**
|
|
52101
52317
|
* The padding of an instance of ours: a fixed number, or the live value of a number uniform.
|
|
52102
52318
|
*
|
|
52103
52319
|
* @param definition - The filter definition.
|
|
@@ -52166,6 +52382,8 @@ function createOurs(pixi, definition, value) {
|
|
|
52166
52382
|
type: definition.origin.type
|
|
52167
52383
|
};
|
|
52168
52384
|
const group = definition.uniforms.length > 0 || definition.inputs.length > 0 || definition.backdrop || definition.origin !== void 0 ? new pixi.UniformGroup(structures) : void 0;
|
|
52385
|
+
tagNumbers(value, definition.uniforms);
|
|
52386
|
+
if (group !== void 0) tagNumbers(group.uniforms, definition.uniforms);
|
|
52169
52387
|
const resources = group === void 0 ? {} : { fu: group };
|
|
52170
52388
|
const empty = pixi.Texture.EMPTY.source;
|
|
52171
52389
|
for (const input of definition.inputs) {
|
|
@@ -55169,30 +55387,6 @@ function along(curve, t) {
|
|
|
55169
55387
|
return curve.from + (curve.to - curve.from) * t;
|
|
55170
55388
|
}
|
|
55171
55389
|
/**
|
|
55172
|
-
* A colour between two colours, linear per channel.
|
|
55173
|
-
*
|
|
55174
|
-
* @param curve - The two `0xrrggbb` ends.
|
|
55175
|
-
* @param t - Where between them, 0..1.
|
|
55176
|
-
* @returns The `0xrrggbb` colour at `t`.
|
|
55177
|
-
* @example
|
|
55178
|
-
* ```ts
|
|
55179
|
-
* mixColor({ from: 0x000000, to: 0xff_ff_ff }, 0.5); // 0x808080
|
|
55180
|
-
* ```
|
|
55181
|
-
*/
|
|
55182
|
-
function mixColor(curve, t) {
|
|
55183
|
-
let color = 0;
|
|
55184
|
-
for (const shift of [
|
|
55185
|
-
16,
|
|
55186
|
-
8,
|
|
55187
|
-
0
|
|
55188
|
-
]) {
|
|
55189
|
-
const from = curve.from >> shift & 255;
|
|
55190
|
-
const to = curve.to >> shift & 255;
|
|
55191
|
-
color |= Math.round(from + (to - from) * t) << shift;
|
|
55192
|
-
}
|
|
55193
|
-
return color;
|
|
55194
|
-
}
|
|
55195
|
-
/**
|
|
55196
55390
|
* How far from the origin a particle is born at most.
|
|
55197
55391
|
*
|
|
55198
55392
|
* @param shape - The birth shape.
|
|
@@ -55241,7 +55435,7 @@ function bakeEmitter(definition, textures) {
|
|
|
55241
55435
|
const t = index / 63;
|
|
55242
55436
|
scaleTable[index] = along(config.scale, t);
|
|
55243
55437
|
alphaTable[index] = along(config.alpha, t);
|
|
55244
|
-
tintTable[index] = toBgr(mixColor(config.tint, t));
|
|
55438
|
+
tintTable[index] = toBgr(mixColor(config.tint.from, config.tint.to, t));
|
|
55245
55439
|
colorTable[index] = ((tintTable[index] ?? 0) | alphaByte(alphaTable[index] ?? 1) << 24) >>> 0;
|
|
55246
55440
|
}
|
|
55247
55441
|
const maxSide = Math.max(...textures.map((texture) => Math.max(texture.width, texture.height)));
|
|
@@ -78427,97 +78621,6 @@ function cubicBezier(x1, y1, x2, y2) {
|
|
|
78427
78621
|
const table = solveTable(Float64Array.of(x1, y1, x2, y2));
|
|
78428
78622
|
return (t) => progressAt(table, t);
|
|
78429
78623
|
}
|
|
78430
|
-
//#endregion
|
|
78431
|
-
//#region src/plugins/effects/set/head.ts
|
|
78432
|
-
/**
|
|
78433
|
-
* @file effects/set — the set head: the WGSL and GLSL the engine's effect set puts before every member's body. Four
|
|
78434
|
-
* helpers: `inputPlace(uv)`, where the pixel is in its input frame (0..1 on each axis, the padded frame Pixi hands the
|
|
78435
|
-
* filter), and `sampleInput(n)`, the input read at such a place, inside the clamp; `inputFrame()`, the size of that
|
|
78436
|
-
* frame in CSS px, for a padded member that maps its content box; and `setHash(cell)`, the integer hash of `Dissolve`.
|
|
78437
|
-
* They read the input's own uniforms (`uInputClamp`, `uInputPixel`, `uInputSize`), never the screen, so a member stays
|
|
78438
|
-
* `"local"`; and the clamp is half a texel in from the frame in a live pass and from the whole picture on the quad of
|
|
78439
|
-
* stage 2 (`shade.ts`), so one body draws the same in both. A game's body does not get them. Pure strings.
|
|
78440
|
-
*/
|
|
78441
|
-
/**
|
|
78442
|
-
* The WGSL head of every member: `inputPlace(uv)` and `sampleInput(n)` over the filter's input, `inputFrame()` and
|
|
78443
|
-
* `setHash(cell)`. `textureSampleLevel`, so a member may read its input inside a branch. `inputFrame()` is the clamp's
|
|
78444
|
-
* span plus one texel, times the texture's CSS size: live the frame is a share of a pooled texture and `uInputSize` is
|
|
78445
|
-
* the texture's, on the quad the frame is the whole picture; both give the frame. `setHash` is a 32-bit integer hash of
|
|
78446
|
-
* a cell, 0 up to 1 (24 bits): integers wrap the same on every GPU, so WebGL and WebGPU dissolve the same cells.
|
|
78447
|
-
*/
|
|
78448
|
-
const SET_WGSL = `fn inputPlace(uv: vec2<f32>) -> vec2<f32> {
|
|
78449
|
-
return (uv - gfu.uInputClamp.xy) / (gfu.uInputClamp.zw - gfu.uInputClamp.xy);
|
|
78450
|
-
}
|
|
78451
|
-
|
|
78452
|
-
fn sampleInput(n: vec2<f32>) -> vec4<f32> {
|
|
78453
|
-
return textureSampleLevel(uTexture, uSampler, mix(gfu.uInputClamp.xy, gfu.uInputClamp.zw, clamp(n, vec2<f32>(0.0), vec2<f32>(1.0))), 0.0);
|
|
78454
|
-
}
|
|
78455
|
-
|
|
78456
|
-
fn inputFrame() -> vec2<f32> {
|
|
78457
|
-
return (gfu.uInputClamp.zw - gfu.uInputClamp.xy + gfu.uInputPixel.zw) * gfu.uInputSize.xy;
|
|
78458
|
-
}
|
|
78459
|
-
|
|
78460
|
-
fn setHash(cell: vec2<f32>) -> f32 {
|
|
78461
|
-
let q = vec2<u32>(vec2<i32>(cell));
|
|
78462
|
-
var h = (q.x * 1597334677u) ^ (q.y * 3812015801u);
|
|
78463
|
-
h = (h ^ (h >> 16u)) * 2246822519u;
|
|
78464
|
-
h = h ^ (h >> 13u);
|
|
78465
|
-
return f32(h >> 8u) / 16777216.0;
|
|
78466
|
-
}
|
|
78467
|
-
|
|
78468
|
-
`;
|
|
78469
|
-
/**
|
|
78470
|
-
* The GLSL twin of `SET_WGSL`: the same four helpers over `uInputClamp`, `uInputPixel`, `uInputSize` and `uTexture` of
|
|
78471
|
-
* the GLSL header. The hash's integers are `highp`: the default of a fragment stage is `mediump`, 16 bits on a phone.
|
|
78472
|
-
*/
|
|
78473
|
-
const SET_GLSL = `vec2 inputPlace(vec2 uv) {
|
|
78474
|
-
return (uv - uInputClamp.xy) / (uInputClamp.zw - uInputClamp.xy);
|
|
78475
|
-
}
|
|
78476
|
-
|
|
78477
|
-
vec4 sampleInput(vec2 n) {
|
|
78478
|
-
return textureLod(uTexture, mix(uInputClamp.xy, uInputClamp.zw, clamp(n, 0.0, 1.0)), 0.0);
|
|
78479
|
-
}
|
|
78480
|
-
|
|
78481
|
-
vec2 inputFrame() {
|
|
78482
|
-
return (uInputClamp.zw - uInputClamp.xy + uInputPixel.zw) * uInputSize.xy;
|
|
78483
|
-
}
|
|
78484
|
-
|
|
78485
|
-
float setHash(vec2 cell) {
|
|
78486
|
-
highp uvec2 q = uvec2(ivec2(cell));
|
|
78487
|
-
highp uint h = (q.x * 1597334677u) ^ (q.y * 3812015801u);
|
|
78488
|
-
h = (h ^ (h >> 16u)) * 2246822519u;
|
|
78489
|
-
h = h ^ (h >> 13u);
|
|
78490
|
-
return float(h >> 8u) / 16777216.0;
|
|
78491
|
-
}
|
|
78492
|
-
|
|
78493
|
-
`;
|
|
78494
|
-
/**
|
|
78495
|
-
* A member's WGSL body with the set head before it. A call, so a bundle that drops the member drops the text too: a
|
|
78496
|
-
* concatenation at module scope would stay, its strings with it.
|
|
78497
|
-
*
|
|
78498
|
-
* @param body - The member's WGSL body.
|
|
78499
|
-
* @returns The head, then the body.
|
|
78500
|
-
* @example
|
|
78501
|
-
* ```ts
|
|
78502
|
-
* withSetWgsl("@fragment fn mainFragment").startsWith("fn inputPlace("); // true
|
|
78503
|
-
* ```
|
|
78504
|
-
*/
|
|
78505
|
-
function withSetWgsl(body) {
|
|
78506
|
-
return SET_WGSL + body;
|
|
78507
|
-
}
|
|
78508
|
-
/**
|
|
78509
|
-
* A member's GLSL body with the set head before it, for the same reason as `withSetWgsl`.
|
|
78510
|
-
*
|
|
78511
|
-
* @param body - The member's GLSL body.
|
|
78512
|
-
* @returns The head, then the body.
|
|
78513
|
-
* @example
|
|
78514
|
-
* ```ts
|
|
78515
|
-
* withSetGlsl("void main() {}").startsWith("vec2 inputPlace("); // true
|
|
78516
|
-
* ```
|
|
78517
|
-
*/
|
|
78518
|
-
function withSetGlsl(body) {
|
|
78519
|
-
return SET_GLSL + body;
|
|
78520
|
-
}
|
|
78521
78624
|
/**
|
|
78522
78625
|
* A soft halo of `color` around the shape of a view and its subtree, `spread` CSS px wide and as strong as `strength`
|
|
78523
78626
|
* (0..2; 1 is full next to a straight edge, 2 widens the full part). The view is padded by its live `spread`, so the
|
|
@@ -79073,6 +79176,135 @@ void main() {
|
|
|
79073
79176
|
}
|
|
79074
79177
|
});
|
|
79075
79178
|
/**
|
|
79179
|
+
* A view recoloured by its light: its Rec. 709 luma maps black to `dark`, a half to `middle` and white to `light`,
|
|
79180
|
+
* mixed straight between them, and `amount` (0..1) mixes the view's own colour to the mapped one. The alpha is kept.
|
|
79181
|
+
* For a sepia memory, a night tint, a duotone. List it in a feature's `filters`, as a game's own filter. One render
|
|
79182
|
+
* pass, one sample; on WebGPU a tween of `amount` draws on the view's own quad, no pass, from its third frame.
|
|
79183
|
+
*
|
|
79184
|
+
* @example
|
|
79185
|
+
* ```ts
|
|
79186
|
+
* // An old memory turns sepia, then its colour comes back.
|
|
79187
|
+
* GradientMap({ dark: 0x2b1a0e, middle: 0x9c6b3c, light: 0xf5e6c8 }).value.amount; // 1
|
|
79188
|
+
* view.tween(GradientMap, { amount: 0 }, { ms: 400 });
|
|
79189
|
+
* ```
|
|
79190
|
+
*/
|
|
79191
|
+
const GradientMap = /*#__PURE__*/ defineFilter("effects.gradientMap", {
|
|
79192
|
+
wgsl: /* @__PURE__ */ withSetWgsl(`@fragment
|
|
79193
|
+
fn mainFragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|
79194
|
+
let n = inputPlace(uv);
|
|
79195
|
+
let c = sampleInput(n);
|
|
79196
|
+
let s = c.rgb / max(c.a, 1e-5);
|
|
79197
|
+
let l = clamp(dot(s, vec3<f32>(0.2126, 0.7152, 0.0722)), 0.0, 1.0);
|
|
79198
|
+
let m = mix(mix(fu.dark, fu.middle, l * 2.0), mix(fu.middle, fu.light, l * 2.0 - 1.0), step(0.5, l));
|
|
79199
|
+
let o = mix(s, m, clamp(fu.amount, 0.0, 1.0));
|
|
79200
|
+
|
|
79201
|
+
return vec4<f32>(o * c.a, c.a);
|
|
79202
|
+
}
|
|
79203
|
+
`),
|
|
79204
|
+
glsl: /* @__PURE__ */ withSetGlsl(`void main() {
|
|
79205
|
+
vec2 n = inputPlace(vTextureCoord);
|
|
79206
|
+
vec4 c = sampleInput(n);
|
|
79207
|
+
vec3 s = c.rgb / max(c.a, 1e-5);
|
|
79208
|
+
float l = clamp(dot(s, vec3(0.2126, 0.7152, 0.0722)), 0.0, 1.0);
|
|
79209
|
+
vec3 m = mix(mix(dark, middle, l * 2.0), mix(middle, light, l * 2.0 - 1.0), step(0.5, l));
|
|
79210
|
+
vec3 o = mix(s, m, clamp(amount, 0.0, 1.0));
|
|
79211
|
+
|
|
79212
|
+
finalColor = vec4(o * c.a, c.a);
|
|
79213
|
+
}
|
|
79214
|
+
`),
|
|
79215
|
+
uniforms: {
|
|
79216
|
+
dark: { color: 0 },
|
|
79217
|
+
middle: { color: 8421504 },
|
|
79218
|
+
light: { color: 16777215 },
|
|
79219
|
+
amount: 1
|
|
79220
|
+
}
|
|
79221
|
+
});
|
|
79222
|
+
/**
|
|
79223
|
+
* A view flipped in place: `axis: 1` top to bottom, `axis: 0` left to right, as `Fold`'s axes. `alpha` (0..1) fades
|
|
79224
|
+
* it; `fade` above 0 eases it out to nothing at that share of the view from its mirror line, the top edge for axis 1
|
|
79225
|
+
* and the left edge for axis 0; 0 keeps it whole. It draws inside its own view, no padding: put it on a copy of a view
|
|
79226
|
+
* placed under the original for a reflection on a floor or water. List it in a feature's `filters`, as a game's own
|
|
79227
|
+
* filter. One render pass, one sample; on WebGPU a tween draws on the view's own quad, no pass, from its third frame.
|
|
79228
|
+
*
|
|
79229
|
+
* @example
|
|
79230
|
+
* ```ts
|
|
79231
|
+
* // The copy of a vase under it is its reflection on the polished floor, gone at half its height.
|
|
79232
|
+
* Mirror({ alpha: 0.4, fade: 0.5 }).value.axis; // 1
|
|
79233
|
+
* view.tween(Mirror, { alpha: 0 }, { ms: 300 });
|
|
79234
|
+
* ```
|
|
79235
|
+
*/
|
|
79236
|
+
const Mirror = /*#__PURE__*/ defineFilter("effects.mirror", {
|
|
79237
|
+
wgsl: /* @__PURE__ */ withSetWgsl(`@fragment
|
|
79238
|
+
fn mainFragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|
79239
|
+
let n = inputPlace(uv);
|
|
79240
|
+
let a = step(0.5, fu.axis);
|
|
79241
|
+
let q = vec2<f32>(mix(1.0 - n.x, n.x, a), mix(n.y, 1.0 - n.y, a));
|
|
79242
|
+
let t = mix(n.x, n.y, a);
|
|
79243
|
+
let fading = 1.0 - step(fu.fade, 0.0);
|
|
79244
|
+
let keep = 1.0 - fading * smoothstep(0.0, max(fu.fade, 1e-4), t);
|
|
79245
|
+
|
|
79246
|
+
return sampleInput(q) * (clamp(fu.alpha, 0.0, 1.0) * keep);
|
|
79247
|
+
}
|
|
79248
|
+
`),
|
|
79249
|
+
glsl: /* @__PURE__ */ withSetGlsl(`void main() {
|
|
79250
|
+
vec2 n = inputPlace(vTextureCoord);
|
|
79251
|
+
float a = step(0.5, axis);
|
|
79252
|
+
vec2 q = vec2(mix(1.0 - n.x, n.x, a), mix(n.y, 1.0 - n.y, a));
|
|
79253
|
+
float t = mix(n.x, n.y, a);
|
|
79254
|
+
float fading = 1.0 - step(fade, 0.0);
|
|
79255
|
+
float keep = 1.0 - fading * smoothstep(0.0, max(fade, 1e-4), t);
|
|
79256
|
+
|
|
79257
|
+
finalColor = sampleInput(q) * (clamp(alpha, 0.0, 1.0) * keep);
|
|
79258
|
+
}
|
|
79259
|
+
`),
|
|
79260
|
+
uniforms: {
|
|
79261
|
+
axis: 1,
|
|
79262
|
+
alpha: 1,
|
|
79263
|
+
fade: 0
|
|
79264
|
+
}
|
|
79265
|
+
});
|
|
79266
|
+
/**
|
|
79267
|
+
* A view drawn in square blocks `size` CSS px wide, counted from its top-left, each the colour of the view at the
|
|
79268
|
+
* block's centre; a `size` of 1 or less draws the view as it is. For a memory that breaks up, a picture that sharpens
|
|
79269
|
+
* as it loads. List it in a feature's `filters`, as a game's own filter. One render pass, one sample; on WebGPU a tween
|
|
79270
|
+
* draws on the view's own quad, no pass, from its third frame.
|
|
79271
|
+
*
|
|
79272
|
+
* @example
|
|
79273
|
+
* ```ts
|
|
79274
|
+
* // A blurred memory sharpens: its blocks shrink from 8 px to none.
|
|
79275
|
+
* Pixelate().value.size; // 8
|
|
79276
|
+
* view.tween(Pixelate, { size: 1 }, { ms: 600 });
|
|
79277
|
+
* ```
|
|
79278
|
+
*/
|
|
79279
|
+
const Pixelate = /*#__PURE__*/ defineFilter("effects.pixelate", {
|
|
79280
|
+
wgsl: /* @__PURE__ */ withSetWgsl(`@fragment
|
|
79281
|
+
fn mainFragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|
79282
|
+
let n = inputPlace(uv);
|
|
79283
|
+
let s = inputFrame();
|
|
79284
|
+
let px = clamp(n * s, vec2<f32>(0.0), s - 0.5);
|
|
79285
|
+
let side = max(fu.size, 1.0);
|
|
79286
|
+
let cell = (floor(px / side) + 0.5) * side;
|
|
79287
|
+
let blocky = 1.0 - step(fu.size, 1.0);
|
|
79288
|
+
let q = mix(n, cell / s, blocky);
|
|
79289
|
+
|
|
79290
|
+
return sampleInput(q);
|
|
79291
|
+
}
|
|
79292
|
+
`),
|
|
79293
|
+
glsl: /* @__PURE__ */ withSetGlsl(`void main() {
|
|
79294
|
+
vec2 n = inputPlace(vTextureCoord);
|
|
79295
|
+
vec2 s = inputFrame();
|
|
79296
|
+
vec2 px = clamp(n * s, vec2(0.0), s - 0.5);
|
|
79297
|
+
float side = max(size, 1.0);
|
|
79298
|
+
vec2 cell = (floor(px / side) + 0.5) * side;
|
|
79299
|
+
float blocky = 1.0 - step(size, 1.0);
|
|
79300
|
+
vec2 q = mix(n, cell / s, blocky);
|
|
79301
|
+
|
|
79302
|
+
finalColor = sampleInput(q);
|
|
79303
|
+
}
|
|
79304
|
+
`),
|
|
79305
|
+
uniforms: { size: 8 }
|
|
79306
|
+
});
|
|
79307
|
+
/**
|
|
79076
79308
|
* A view shown up to a straight line that sweeps across it: `progress` 0 hides all of it, 1 shows all of it, the line
|
|
79077
79309
|
* at `angle` radians (0 sweeps from the left, `Math.PI / 2` from the top) with an edge `soft` wide. The angle is in the
|
|
79078
79310
|
* view's own 0..1 frame, so `Math.PI / 4` sweeps from one corner to the opposite one on a view of any shape. For a wipe
|
|
@@ -79164,6 +79396,81 @@ fn mainFragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|
|
79164
79396
|
}
|
|
79165
79397
|
});
|
|
79166
79398
|
/**
|
|
79399
|
+
* A drop shadow of `color` at `alpha` (0..1) under the shape of a view and its subtree, moved by `x`, `y` CSS px and
|
|
79400
|
+
* blurred `soft` CSS px wide; the view is drawn over it. The view is padded by 8 px, the shadow's reach: `soft` is at
|
|
79401
|
+
* most 8, and `x` and `y` are clamped so `|x| + soft` and `|y| + soft` stay within 8. 9 samples of the shape on a
|
|
79402
|
+
* ring, where a blurred copy takes a chain, so a wide `soft` bands a little. For a card lifted off the table, a piece being dragged. List it
|
|
79403
|
+
* in a feature's `filters`, as a game's own filter. One render pass; on WebGPU a tween draws on the view's own quad,
|
|
79404
|
+
* no pass, from its third frame.
|
|
79405
|
+
*
|
|
79406
|
+
* @example
|
|
79407
|
+
* ```ts
|
|
79408
|
+
* // A picked card lifts: its shadow drops further and softens.
|
|
79409
|
+
* Shadow().value.y; // 4
|
|
79410
|
+
* Shadow.filter.padding; // 8
|
|
79411
|
+
* view.tween(Shadow, { y: 5, soft: 3 }, { ms: 160 });
|
|
79412
|
+
* ```
|
|
79413
|
+
*/
|
|
79414
|
+
const Shadow = /*#__PURE__*/ defineFilter("effects.shadow", {
|
|
79415
|
+
wgsl: /* @__PURE__ */ withSetWgsl(`const SHADOW_TAU: f32 = 6.283185307179586;
|
|
79416
|
+
const SHADOW_REACH: f32 = 8.0;
|
|
79417
|
+
|
|
79418
|
+
@fragment
|
|
79419
|
+
fn mainFragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|
79420
|
+
let n = inputPlace(uv);
|
|
79421
|
+
let c = sampleInput(n);
|
|
79422
|
+
let f = inputFrame();
|
|
79423
|
+
let radius = clamp(fu.soft, 0.0, SHADOW_REACH);
|
|
79424
|
+
let room = SHADOW_REACH - radius;
|
|
79425
|
+
let off = vec2<f32>(clamp(fu.x, -room, room), clamp(fu.y, -room, room));
|
|
79426
|
+
let base = n - off / f;
|
|
79427
|
+
let reach = radius / f;
|
|
79428
|
+
var cover = sampleInput(base).a;
|
|
79429
|
+
|
|
79430
|
+
for (var i = 0; i < 8; i++) {
|
|
79431
|
+
let turn = SHADOW_TAU * f32(i) / 8.0;
|
|
79432
|
+
cover += sampleInput(base + vec2<f32>(cos(turn), sin(turn)) * reach).a;
|
|
79433
|
+
}
|
|
79434
|
+
|
|
79435
|
+
let shade = clamp(cover / 9.0 * fu.alpha, 0.0, 1.0);
|
|
79436
|
+
|
|
79437
|
+
return c + vec4<f32>(fu.color * shade, shade) * (1.0 - c.a);
|
|
79438
|
+
}
|
|
79439
|
+
`),
|
|
79440
|
+
glsl: /* @__PURE__ */ withSetGlsl(`const float SHADOW_TAU = 6.283185307179586;
|
|
79441
|
+
const float SHADOW_REACH = 8.0;
|
|
79442
|
+
|
|
79443
|
+
void main() {
|
|
79444
|
+
vec2 n = inputPlace(vTextureCoord);
|
|
79445
|
+
vec4 c = sampleInput(n);
|
|
79446
|
+
vec2 f = inputFrame();
|
|
79447
|
+
float radius = clamp(soft, 0.0, SHADOW_REACH);
|
|
79448
|
+
float room = SHADOW_REACH - radius;
|
|
79449
|
+
vec2 off = vec2(clamp(x, -room, room), clamp(y, -room, room));
|
|
79450
|
+
vec2 base = n - off / f;
|
|
79451
|
+
vec2 reach = radius / f;
|
|
79452
|
+
float cover = sampleInput(base).a;
|
|
79453
|
+
|
|
79454
|
+
for (int i = 0; i < 8; i++) {
|
|
79455
|
+
float turn = SHADOW_TAU * float(i) / 8.0;
|
|
79456
|
+
cover += sampleInput(base + vec2(cos(turn), sin(turn)) * reach).a;
|
|
79457
|
+
}
|
|
79458
|
+
|
|
79459
|
+
float shade = clamp(cover / 9.0 * alpha, 0.0, 1.0);
|
|
79460
|
+
|
|
79461
|
+
finalColor = c + vec4(color * shade, shade) * (1.0 - c.a);
|
|
79462
|
+
}
|
|
79463
|
+
`),
|
|
79464
|
+
uniforms: {
|
|
79465
|
+
x: 0,
|
|
79466
|
+
y: 4,
|
|
79467
|
+
soft: 4,
|
|
79468
|
+
color: { color: 0 },
|
|
79469
|
+
alpha: .5
|
|
79470
|
+
},
|
|
79471
|
+
padding: 8
|
|
79472
|
+
});
|
|
79473
|
+
/**
|
|
79167
79474
|
* A band of light across a view: `position` is where the band stands along its sweep, -0.5 before the view and 1.5 past
|
|
79168
79475
|
* it, so a tween from one to the other sweeps it across once; `width` is how far from its line the band reaches (0..1
|
|
79169
79476
|
* of the sweep), `angle` its direction in radians in the view's own 0..1 frame, `strength` how much light it adds. Light
|
|
@@ -79253,6 +79560,61 @@ fn mainFragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|
|
79253
79560
|
amount: 1
|
|
79254
79561
|
}
|
|
79255
79562
|
});
|
|
79563
|
+
/**
|
|
79564
|
+
* A view swaying in a sine wave: at `angle` 0 its rows move left and right, at `π / 2` its columns move up and down,
|
|
79565
|
+
* by up to `amplitude` CSS px, one wave every `wavelength` CSS px, shifted by `phase` (radians). What would come from
|
|
79566
|
+
* outside the view is transparent. There is no time in the shader: a tween of `phase` by a full turn, repeated, makes
|
|
79567
|
+
* it flow. For water, heat, a dream. List it in a feature's `filters`, as a game's own filter. One render pass, one
|
|
79568
|
+
* sample; on WebGPU a tween draws on the view's own quad, no pass, from its third frame.
|
|
79569
|
+
*
|
|
79570
|
+
* @example
|
|
79571
|
+
* ```ts
|
|
79572
|
+
* // A reflection in a pond ripples for as long as the scene is open.
|
|
79573
|
+
* Wave({ amplitude: 3 }).value.wavelength; // 48
|
|
79574
|
+
* view.tween(Wave, { phase: Math.PI * 2 }, { ms: 1200, ease: "linear", repeat: "forever" });
|
|
79575
|
+
* ```
|
|
79576
|
+
*/
|
|
79577
|
+
const Wave = /*#__PURE__*/ defineFilter("effects.wave", {
|
|
79578
|
+
wgsl: /* @__PURE__ */ withSetWgsl(`const WAVE_TAU: f32 = 6.283185307179586;
|
|
79579
|
+
|
|
79580
|
+
@fragment
|
|
79581
|
+
fn mainFragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
|
|
79582
|
+
let n = inputPlace(uv);
|
|
79583
|
+
let f = inputFrame();
|
|
79584
|
+
let px = n * f;
|
|
79585
|
+
let dir = vec2<f32>(cos(fu.angle), sin(fu.angle));
|
|
79586
|
+
let along = dot(px, vec2<f32>(-dir.y, dir.x));
|
|
79587
|
+
let o = fu.amplitude * sin(WAVE_TAU * along / max(fu.wavelength, 1.0) + fu.phase);
|
|
79588
|
+
let q = (px - dir * o) / f;
|
|
79589
|
+
let away = max(abs(q.x - clamp(q.x, 0.0, 1.0)), abs(q.y - clamp(q.y, 0.0, 1.0)));
|
|
79590
|
+
let inside = step(away, 1e-4);
|
|
79591
|
+
|
|
79592
|
+
return sampleInput(q) * inside;
|
|
79593
|
+
}
|
|
79594
|
+
`),
|
|
79595
|
+
glsl: /* @__PURE__ */ withSetGlsl(`const float WAVE_TAU = 6.283185307179586;
|
|
79596
|
+
|
|
79597
|
+
void main() {
|
|
79598
|
+
vec2 n = inputPlace(vTextureCoord);
|
|
79599
|
+
vec2 f = inputFrame();
|
|
79600
|
+
vec2 px = n * f;
|
|
79601
|
+
vec2 dir = vec2(cos(angle), sin(angle));
|
|
79602
|
+
float along = dot(px, vec2(-dir.y, dir.x));
|
|
79603
|
+
float o = amplitude * sin(WAVE_TAU * along / max(wavelength, 1.0) + phase);
|
|
79604
|
+
vec2 q = (px - dir * o) / f;
|
|
79605
|
+
float away = max(abs(q.x - clamp(q.x, 0.0, 1.0)), abs(q.y - clamp(q.y, 0.0, 1.0)));
|
|
79606
|
+
float inside = step(away, 1e-4);
|
|
79607
|
+
|
|
79608
|
+
finalColor = sampleInput(q) * inside;
|
|
79609
|
+
}
|
|
79610
|
+
`),
|
|
79611
|
+
uniforms: {
|
|
79612
|
+
amplitude: 4,
|
|
79613
|
+
wavelength: 48,
|
|
79614
|
+
phase: 0,
|
|
79615
|
+
angle: 0
|
|
79616
|
+
}
|
|
79617
|
+
});
|
|
79256
79618
|
//#endregion
|
|
79257
79619
|
//#region src/index.ts
|
|
79258
79620
|
/**
|
|
@@ -79470,4 +79832,4 @@ const screen = [
|
|
|
79470
79832
|
uiPlugin
|
|
79471
79833
|
];
|
|
79472
79834
|
//#endregion
|
|
79473
|
-
export {
|
|
79835
|
+
export { uiPlugin as $, animPlugin as $t, defineEmitter as A, Pressed as At, types_exports$5 as B, Emitter as Bt, hint as C, SaveUnreadableError as Cn, Draggable as Ct, tr as D, Pointer as Dt, defineScene as E, timePlugin as En, Hovered as Et, types_exports as F, Traced as Ft, types_exports$10 as G, Glow as Gt, types_exports$7 as H, Blur as Ht, types_exports$1 as I, i18nPlugin as It, types_exports$13 as J, defineFilter as Jt, types_exports$11 as K, Noise as Kt, types_exports$2 as L, messageArgument as Lt, defineBundles as M, Tappable as Mt, load as N, Touchable as Nt, defineFeature as O, PointerOver as Ot, ready as P, Traceable as Pt, types_exports$17 as Q, assetsPlugin as Qt, types_exports$3 as R, messageDuration as Rt, guide as S, modelPlugin as Sn, inputPlugin as St, projection as T, lifecyclePlugin as Tn, Held as Tt, types_exports$8 as U, ColorMatrix as Ut, types_exports$6 as V, Alpha as Vt, types_exports$9 as W, Displacement as Wt, types_exports$15 as X, audioPlugin as Xt, types_exports$14 as Y, debugPlugin as Yt, types_exports$16 as Z, scenesPlugin as Zt, Dissolve as _, contribution as _n, stagger as _t, Wave as a, frameAt as an, defineAnimation as at, cubicBezier as b, to as bn, use as bt, Shadow as c, PERF_GAP_BUCKETS as cn, haptic as ct, Pixelate as d, SHADER_WHATS as dn, play$1 as dt, AnimPlayer as en, resolve as et, Mirror as f, CANVAS_RESTARTS as fn, sequence as ft, Flash as g, refuseStart as gn, spawned as gt, Fold as h, flowPlugin as hn, spawn as ht, screen as i, PASS_KINDS as in, HAPTIC_KINDS as it, music as j, Swipeable as jt, flattenFeatures as k, Pressable as kt, RevealRound as l, PERF_LOG_VERSION as ln, mark as lt, Grade as m, worldPlugin as mn, sfx as mt, createPlugin as n, Frames as nn, textPlugin as nt, Vignette as o, MONITOR_SECTIONS as on, external as ot, GradientMap as p, DEMAND_REASONS as pn, set as pt, types_exports$12 as q, Outline as qt, defineGame as r, rendererPlugin as rn, platformPlugin as rt, Shine as s, PERF_CAUSES as sn, frames as st, createApp as t, Animation as tn, defineMotion as tt, RevealLine as u, PROBLEM_RULES as un, parallel as ut, Bloom as v, exit as vn, stopSfx as vt, schedule as w, clockPlugin as wn, DropTarget as wt, defineEffect as x, type as xn, wait as xt, Aura as y, slot as yn, tween as yt, types_exports$4 as z, effectsPlugin as zt };
|