@jayf0x/fluidity-js 0.2.4 → 0.2.6
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/AGENTS.md +141 -55
- package/CONTRIBUTING.md +32 -1
- package/README.md +55 -40
- package/dist/globals.d.ts +20 -19
- package/dist/index.js +818 -763
- package/llms.txt +32 -38
- package/package.json +1 -1
package/llms.txt
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
- GitHub: https://github.com/jayf0x/fluidity
|
|
7
7
|
- Live demo: https://jayf0x.github.io/fluidity
|
|
8
8
|
- License: MIT
|
|
9
|
-
- Version: 0.2.2
|
|
10
9
|
|
|
11
10
|
## Install
|
|
12
11
|
|
|
@@ -35,8 +34,8 @@ import { FluidText, FluidImage } from '@jayf0x/fluidity-js';
|
|
|
35
34
|
// Fluid image with aurora algorithm
|
|
36
35
|
<FluidImage src="/hero.jpg" algorithm="aurora" />
|
|
37
36
|
|
|
38
|
-
// With preset and
|
|
39
|
-
<FluidText text="Wicked" preset="neon" algorithm="glass"
|
|
37
|
+
// With preset and per-prop config (all FluidConfig fields are flat props)
|
|
38
|
+
<FluidText text="Wicked" preset="neon" algorithm="glass" curl={0.4} />
|
|
40
39
|
```
|
|
41
40
|
|
|
42
41
|
## FluidText props
|
|
@@ -61,30 +60,33 @@ import { FluidText, FluidImage } from '@jayf0x/fluidity-js';
|
|
|
61
60
|
|
|
62
61
|
| Prop | Type | Default |
|
|
63
62
|
|------|------|---------|
|
|
64
|
-
| config | Partial<FluidConfig> | — |
|
|
65
63
|
| preset | PresetKey | — |
|
|
66
64
|
| algorithm | FluidAlgorithm | 'standard' |
|
|
67
|
-
|
|
|
65
|
+
| pixelRatio | number | 1 |
|
|
66
|
+
| simResolution | number | 0.5 |
|
|
68
67
|
| backgroundColor | string | '#0a0a0a' |
|
|
69
68
|
| backgroundSrc | string | — |
|
|
70
69
|
| backgroundSize | string\|number | 'cover' |
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
70
|
+
| mouseEnabled | boolean | true |
|
|
71
|
+
| workerEnabled | boolean | true |
|
|
72
|
+
| webGPUEnabled | boolean | true |
|
|
74
73
|
| className | string | — |
|
|
75
74
|
| style | CSSProperties | — |
|
|
76
75
|
|
|
76
|
+
All `FluidConfig` fields (e.g. `curl`, `splatRadius`, `waterColor`) are also valid flat props on both components.
|
|
77
|
+
|
|
77
78
|
## FluidHandle ref API
|
|
78
79
|
|
|
79
|
-
Access via `useRef<FluidHandle>()` and `ref` prop:
|
|
80
|
+
Access via `useRef<FluidHandle>()` and the `ref` prop:
|
|
80
81
|
|
|
81
82
|
```tsx
|
|
82
83
|
const fluid = useRef<FluidHandle>(null);
|
|
83
84
|
<FluidText ref={fluid} text="Touch me" />
|
|
85
|
+
|
|
84
86
|
fluid.current?.splat(200, 200, 8, -4);
|
|
85
87
|
fluid.current?.updateConfig({ curl: 0.5 });
|
|
86
88
|
fluid.current?.reset();
|
|
87
|
-
fluid.current?.move(
|
|
89
|
+
fluid.current?.move(100, 100, 2); // x, y, strength?
|
|
88
90
|
```
|
|
89
91
|
|
|
90
92
|
## Algorithms
|
|
@@ -101,43 +103,35 @@ fluid.current?.move({ x: 100, y: 100, strength: 2 });
|
|
|
101
103
|
|
|
102
104
|
`calm` · `sand` · `wave` · `neon` · `smoke`
|
|
103
105
|
|
|
104
|
-
## FluidConfig options
|
|
105
|
-
|
|
106
|
-
| Key | Default | Description |
|
|
107
|
-
|-----|---------|-------------|
|
|
108
|
-
| densityDissipation | 0.992 | Ink persistence (0–1) |
|
|
109
|
-
| velocityDissipation | 0.93 | Velocity decay (0–1) |
|
|
110
|
-
| pressureIterations | 1 | Jacobi iterations |
|
|
111
|
-
| curl | 0.0001 | Vorticity / swirl strength |
|
|
112
|
-
| splatRadius | 0.004 | Brush radius |
|
|
113
|
-
| splatForce | 0.91 | Brush force |
|
|
114
|
-
| refraction | 0.25 | Background warp strength |
|
|
115
|
-
| specularExp | 1.01 | Specular sharpness |
|
|
116
|
-
| shine | 0.01 | Highlight intensity |
|
|
117
|
-
| waterColor | [0,0,0] | Base fluid RGB (0–1 each) |
|
|
118
|
-
| glowColor | [0.7,0.85,1.0] | Specular/glow RGB (0–1 each) |
|
|
119
|
-
| warpStrength | 0.015 | UV warp (aurora algorithm) |
|
|
120
|
-
|
|
121
|
-
## Quality control
|
|
106
|
+
## FluidConfig options (normalized 0–1 space)
|
|
122
107
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
108
|
+
Seven props accept normalized `0–1` values; `normalizeConfig` converts them to physics before the shader sees them. Values outside `[0, 1]` pass through as raw physics overrides.
|
|
109
|
+
|
|
110
|
+
| Key | Description |
|
|
111
|
+
|-----|-------------|
|
|
112
|
+
| densityDissipation | Ink persistence |
|
|
113
|
+
| velocityDissipation | Velocity decay |
|
|
114
|
+
| pressureIterations | Jacobi iterations (integer) |
|
|
115
|
+
| curl | Vorticity / swirl strength |
|
|
116
|
+
| splatRadius | Brush radius |
|
|
117
|
+
| splatForce | Brush force |
|
|
118
|
+
| refraction | Background warp strength |
|
|
119
|
+
| specularExp | Specular sharpness |
|
|
120
|
+
| shine | Highlight intensity |
|
|
121
|
+
| waterColor | Base fluid colour (CSS hex) |
|
|
122
|
+
| glowColor | Specular/glow colour (CSS hex) |
|
|
123
|
+
| warpStrength | UV warp (aurora algorithm) |
|
|
128
124
|
|
|
129
|
-
|
|
125
|
+
See `src/core/config.ts` for exact defaults, preset values, and `PROP_RANGES`.
|
|
130
126
|
|
|
131
127
|
## TypeScript types
|
|
132
128
|
|
|
133
|
-
All types are globally ambient — no import needed:
|
|
129
|
+
All types are globally ambient — no import needed after installing the package:
|
|
134
130
|
|
|
135
131
|
```ts
|
|
136
|
-
// Available globally after installing the package:
|
|
137
132
|
FluidConfig
|
|
138
133
|
FluidHandle
|
|
139
134
|
FluidAlgorithm // 'standard'|'glass'|'ink'|'aurora'|'ripple'
|
|
140
|
-
FluidQuality // { dpr: number; sim: number }
|
|
141
135
|
PresetKey // 'calm'|'sand'|'wave'|'neon'|'smoke'
|
|
142
136
|
```
|
|
143
137
|
|
|
@@ -149,7 +143,7 @@ React component (FluidText / FluidImage)
|
|
|
149
143
|
└── FluidController
|
|
150
144
|
├── [worker mode] Web Worker → FluidSimulation (OffscreenCanvas)
|
|
151
145
|
└── [main mode] FluidSimulation directly
|
|
152
|
-
|
|
146
|
+
├── WebGPU path (FluidSimulation.create())
|
|
153
147
|
└── WebGL2 / WebGL1 fallback
|
|
154
148
|
```
|
|
155
149
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jayf0x/fluidity-js",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "WebGPU-first real-time Navier-Stokes fluid simulation for React — interactive water, ink, glass, aurora, and ripple effects on text and images. Falls back to WebGL2/WebGL1. Runs in a Web Worker.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.js",
|