@dopaminefx/effect-dots 0.1.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/dist/dots-shader.d.ts +38 -0
- package/dist/dots-shader.d.ts.map +1 -0
- package/dist/dots-shader.js +230 -0
- package/dist/dots-shader.js.map +1 -0
- package/dist/dots.dope.json +331 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
- package/src/dots-shader.ts +239 -0
- package/src/dots.dope.json +331 -0
- package/src/index.ts +50 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dots (the calm ambient "thinking" indicator) as an `EffectFactory` on the
|
|
3
|
+
* Dopamine backbone.
|
|
4
|
+
*
|
|
5
|
+
* FULLY DATA-DRIVEN: everything that isn't the GLSL lives in dots.dope.json —
|
|
6
|
+
* the mood→params mapping + OKLCH palette (the loader), AND the per-frame logic:
|
|
7
|
+
* `tempo.frame` (the steady periodic breathe gate), `render.shadowHeightFrac`
|
|
8
|
+
* (the dots' outer reach), `render.consts` (MAX_DOTS/MIN_DOTS), `render.config`
|
|
9
|
+
* and the uniform `binding` contract. `registerDopeEffect` interprets that data
|
|
10
|
+
* through the generic pass runner; this module is just the dot-row SHADER + the
|
|
11
|
+
* registration call. No swift/ or android/ folder — those factories + the MSL /
|
|
12
|
+
* Kotlin shaders are generated from this one .dope plus the GLSL source.
|
|
13
|
+
*
|
|
14
|
+
* CONTINUOUS / LOOPING. Dots is Dopamine's second continuous effect (after halo):
|
|
15
|
+
* it declares the first-class `tempo.loop` contract (`periodMs = 1000`): the
|
|
16
|
+
* parser validates the seam invariants (the period is exactly 12
|
|
17
|
+
* "animate-on-twos" steps and `durationMs = 4000` is exactly 4 periods), the
|
|
18
|
+
* runner derives the standard periodic clocks `uPhase`/`uLoopS` every frame, and
|
|
19
|
+
* `tempo.frame.amp` is a STEADY periodic breathe of that phase —
|
|
20
|
+
* `0.85 + 0.15·sin(2π·phase)` — so the frame at `t == durationMs` matches
|
|
21
|
+
* `t == 0` at every whimsy. The conductor re-arms it at every `durationMs` seam;
|
|
22
|
+
* the host stops it (and can pause/resume it) via the handle `play()` returns.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { DOTS_FRAGMENT_SRC, DOTS_VERTEX_SRC } from "./dots-shader.js";
|
|
26
|
+
import { parseDope, registerDopeEffect, type EffectFactory, type PassParams } from "@dopaminefx/core";
|
|
27
|
+
import doc from "./dots.dope.json";
|
|
28
|
+
|
|
29
|
+
const DOPE = parseDope(doc as object);
|
|
30
|
+
|
|
31
|
+
/** The resolved render params Dots' shader consumes. */
|
|
32
|
+
export interface DotsParams extends PassParams {
|
|
33
|
+
exposure: number;
|
|
34
|
+
dotCount: number;
|
|
35
|
+
dotRadius: number;
|
|
36
|
+
dotGap: number;
|
|
37
|
+
breathe: number;
|
|
38
|
+
chase: number;
|
|
39
|
+
glow: number;
|
|
40
|
+
dotsSeed: number;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// The whole factory (resolve / create / reducedMotion / program registration)
|
|
44
|
+
// is data: dots.dope.json interpreted by the core backbone.
|
|
45
|
+
export const dots = registerDopeEffect(DOPE, {
|
|
46
|
+
vertex: DOTS_VERTEX_SRC,
|
|
47
|
+
fragment: DOTS_FRAGMENT_SRC,
|
|
48
|
+
}) as EffectFactory<PassParams> as EffectFactory<DotsParams>;
|
|
49
|
+
|
|
50
|
+
export default dots;
|