@paper-design/shaders-react 0.0.28 → 0.0.30
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/color-props-are-equal.d.ts +6 -0
- package/dist/color-props-are-equal.js +34 -0
- package/dist/color-props-are-equal.js.map +7 -0
- package/dist/index.d.ts +46 -41
- package/dist/index.js +90 -2
- package/dist/index.js.map +4 -4
- package/dist/shader-mount.d.ts +15 -13
- package/dist/shader-mount.js +120 -0
- package/dist/shader-mount.js.map +7 -0
- package/dist/shaders/dithering.d.ts +15 -0
- package/dist/shaders/dithering.js +179 -0
- package/dist/shaders/dithering.js.map +7 -0
- package/dist/shaders/dot-grid.d.ts +6 -20
- package/dist/shaders/dot-grid.js +230 -0
- package/dist/shaders/dot-grid.js.map +7 -0
- package/dist/shaders/dot-orbit.d.ts +6 -18
- package/dist/shaders/dot-orbit.js +77 -0
- package/dist/shaders/dot-orbit.js.map +7 -0
- package/dist/shaders/god-rays.d.ts +6 -22
- package/dist/shaders/god-rays.js +160 -0
- package/dist/shaders/god-rays.js.map +7 -0
- package/dist/shaders/grain-gradient.d.ts +16 -0
- package/dist/shaders/grain-gradient.js +197 -0
- package/dist/shaders/grain-gradient.js.map +7 -0
- package/dist/shaders/liquid-metal.d.ts +9 -0
- package/dist/shaders/liquid-metal.js +87 -0
- package/dist/shaders/liquid-metal.js.map +7 -0
- package/dist/shaders/mesh-gradient.d.ts +7 -15
- package/dist/shaders/mesh-gradient.js +104 -0
- package/dist/shaders/mesh-gradient.js.map +7 -0
- package/dist/shaders/metaballs.d.ts +6 -16
- package/dist/shaders/metaballs.js +72 -0
- package/dist/shaders/metaballs.js.map +7 -0
- package/dist/shaders/neuro-noise.d.ts +6 -14
- package/dist/shaders/neuro-noise.js +82 -0
- package/dist/shaders/neuro-noise.js.map +7 -0
- package/dist/shaders/perlin-noise.d.ts +6 -17
- package/dist/shaders/perlin-noise.js +183 -0
- package/dist/shaders/perlin-noise.js.map +7 -0
- package/dist/shaders/pulsing-border.d.ts +11 -0
- package/dist/shaders/pulsing-border.js +153 -0
- package/dist/shaders/pulsing-border.js.map +7 -0
- package/dist/shaders/simplex-noise.d.ts +9 -0
- package/dist/shaders/simplex-noise.js +80 -0
- package/dist/shaders/simplex-noise.js.map +7 -0
- package/dist/shaders/smoke-ring.d.ts +8 -18
- package/dist/shaders/smoke-ring.js +134 -0
- package/dist/shaders/smoke-ring.js.map +7 -0
- package/dist/shaders/spiral.d.ts +6 -23
- package/dist/shaders/spiral.js +218 -0
- package/dist/shaders/spiral.js.map +7 -0
- package/dist/shaders/swirl.d.ts +12 -0
- package/dist/shaders/swirl.js +137 -0
- package/dist/shaders/swirl.js.map +7 -0
- package/dist/shaders/voronoi.d.ts +7 -28
- package/dist/shaders/voronoi.js +102 -0
- package/dist/shaders/voronoi.js.map +7 -0
- package/dist/shaders/warp.d.ts +6 -23
- package/dist/shaders/warp.js +290 -0
- package/dist/shaders/warp.js.map +7 -0
- package/dist/shaders/waves.d.ts +6 -19
- package/dist/shaders/waves.js +178 -0
- package/dist/shaders/waves.js.map +7 -0
- package/dist/use-merge-refs.js +48 -0
- package/dist/use-merge-refs.js.map +7 -0
- package/package.json +13 -4
- package/dist/shaders/stepped-simplex-noise.d.ts +0 -20
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
2
|
+
* Paper Shaders *
|
|
3
|
+
* https://github.com/paper-design/shaders *
|
|
4
|
+
* * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
5
|
+
|
|
6
|
+
import { memo } from "react";
|
|
7
|
+
import { ShaderMount } from "../shader-mount";
|
|
8
|
+
import { colorPropsAreEqual } from "../color-props-are-equal";
|
|
9
|
+
import {
|
|
10
|
+
defaultPatternSizing,
|
|
11
|
+
getShaderColorFromString,
|
|
12
|
+
warpFragmentShader,
|
|
13
|
+
ShaderFitOptions,
|
|
14
|
+
WarpPatterns
|
|
15
|
+
} from "@paper-design/shaders";
|
|
16
|
+
import { jsx } from "react/jsx-runtime";
|
|
17
|
+
const defaultPreset = {
|
|
18
|
+
name: "Default",
|
|
19
|
+
params: {
|
|
20
|
+
...defaultPatternSizing,
|
|
21
|
+
rotation: 0,
|
|
22
|
+
speed: 1,
|
|
23
|
+
frame: 0,
|
|
24
|
+
colors: ["hsla(0, 0%, 15%, 1)", "hsla(203, 80%, 70%, 1)", "hsla(0, 0%, 100%, 1)"],
|
|
25
|
+
proportion: 0.35,
|
|
26
|
+
softness: 1,
|
|
27
|
+
distortion: 0.25,
|
|
28
|
+
swirl: 0.8,
|
|
29
|
+
swirlIterations: 10,
|
|
30
|
+
shapeScale: 0.1,
|
|
31
|
+
shape: "edge"
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const presetCauldron = {
|
|
35
|
+
name: "Cauldron Pot",
|
|
36
|
+
params: {
|
|
37
|
+
...defaultPatternSizing,
|
|
38
|
+
scale: 1 / 1.1,
|
|
39
|
+
rotation: 1.62,
|
|
40
|
+
speed: 10,
|
|
41
|
+
frame: 0,
|
|
42
|
+
colors: ["hsla(100, 51%, 75%, 1)", "hsla(220, 39%, 32%, 1)", "hsla(129.2, 41.9%, 6.1%, 1)"],
|
|
43
|
+
proportion: 0.64,
|
|
44
|
+
softness: 0.95,
|
|
45
|
+
distortion: 0.2,
|
|
46
|
+
swirl: 0.86,
|
|
47
|
+
swirlIterations: 7,
|
|
48
|
+
shapeScale: 0,
|
|
49
|
+
shape: "edge"
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const presetSilk = {
|
|
53
|
+
name: "Silk",
|
|
54
|
+
params: {
|
|
55
|
+
...defaultPatternSizing,
|
|
56
|
+
scale: 1 / 0.26,
|
|
57
|
+
rotation: 0,
|
|
58
|
+
speed: 5,
|
|
59
|
+
frame: 0,
|
|
60
|
+
colors: ["hsla(0, 9%, 7%, 1)", "hsla(8, 13%, 34%, 1)", "hsla(5, 8%, 71%, 1)"],
|
|
61
|
+
proportion: 0,
|
|
62
|
+
softness: 1,
|
|
63
|
+
distortion: 0.3,
|
|
64
|
+
swirl: 0.6,
|
|
65
|
+
swirlIterations: 11,
|
|
66
|
+
shapeScale: 0.05,
|
|
67
|
+
shape: "stripes"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const presetPassion = {
|
|
71
|
+
name: "Passion",
|
|
72
|
+
params: {
|
|
73
|
+
...defaultPatternSizing,
|
|
74
|
+
scale: 1 / 0.25,
|
|
75
|
+
rotation: 1.35,
|
|
76
|
+
speed: 3,
|
|
77
|
+
frame: 0,
|
|
78
|
+
colors: ["hsla(0, 44.7%, 14.9%, 1)", "hsla(353.4, 34%, 42.2%, 1)", "hsla(29, 100%, 76.1%, 1)"],
|
|
79
|
+
proportion: 0.5,
|
|
80
|
+
softness: 1,
|
|
81
|
+
distortion: 0.09,
|
|
82
|
+
swirl: 0.9,
|
|
83
|
+
swirlIterations: 6,
|
|
84
|
+
shapeScale: 0.25,
|
|
85
|
+
shape: "checks"
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const presetPhantom = {
|
|
89
|
+
name: "Phantom",
|
|
90
|
+
params: {
|
|
91
|
+
...defaultPatternSizing,
|
|
92
|
+
scale: 1 / 0.68,
|
|
93
|
+
rotation: 1.8,
|
|
94
|
+
speed: 12,
|
|
95
|
+
frame: 0,
|
|
96
|
+
colors: ["hsla(242.2, 44.3%, 12%, 1)", "hsla(236.1, 80.4%, 70%, 1)", "hsla(0, 0%, 100%, 1)"],
|
|
97
|
+
proportion: 0.45,
|
|
98
|
+
softness: 1,
|
|
99
|
+
distortion: 0.16,
|
|
100
|
+
swirl: 0.3,
|
|
101
|
+
swirlIterations: 7,
|
|
102
|
+
shapeScale: 0.1,
|
|
103
|
+
shape: "checks"
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const presetAbyss = {
|
|
107
|
+
name: "The Abyss",
|
|
108
|
+
params: {
|
|
109
|
+
...defaultPatternSizing,
|
|
110
|
+
scale: 1 / 0.1,
|
|
111
|
+
rotation: 2,
|
|
112
|
+
speed: 0.6,
|
|
113
|
+
frame: 0,
|
|
114
|
+
colors: ["hsla(242.2, 44.3%, 12%, 1)", "hsla(236.1, 80.4%, 70%, 1)", "hsla(0, 0%, 100%, 1)"],
|
|
115
|
+
proportion: 0,
|
|
116
|
+
softness: 1,
|
|
117
|
+
distortion: 0.09,
|
|
118
|
+
swirl: 0.48,
|
|
119
|
+
swirlIterations: 4,
|
|
120
|
+
shapeScale: 0.1,
|
|
121
|
+
shape: "edge"
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const presetInk = {
|
|
125
|
+
name: "Live Ink",
|
|
126
|
+
params: {
|
|
127
|
+
...defaultPatternSizing,
|
|
128
|
+
scale: 1 / 0.7,
|
|
129
|
+
rotation: 1.5,
|
|
130
|
+
speed: 2.5,
|
|
131
|
+
frame: 0,
|
|
132
|
+
colors: ["hsla(210, 11.1%, 7.1%, 1)", "hsla(165, 9%, 65.1%, 1)", "hsla(84, 100%, 97.1%, 1)"],
|
|
133
|
+
proportion: 0.35,
|
|
134
|
+
softness: 0,
|
|
135
|
+
distortion: 0.25,
|
|
136
|
+
swirl: 0.8,
|
|
137
|
+
swirlIterations: 10,
|
|
138
|
+
shapeScale: 0.26,
|
|
139
|
+
shape: "checks"
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const presetIceberg = {
|
|
143
|
+
name: "Iceberg",
|
|
144
|
+
params: {
|
|
145
|
+
...defaultPatternSizing,
|
|
146
|
+
scale: 1 / 1.1,
|
|
147
|
+
rotation: 2,
|
|
148
|
+
speed: 0.5,
|
|
149
|
+
frame: 0,
|
|
150
|
+
colors: ["hsla(0, 0%, 100%, 1)", "hsla(220, 38.7%, 32%, 1)", "hsla(129.2, 41.9%, 6.1%, 1)"],
|
|
151
|
+
proportion: 0.3,
|
|
152
|
+
softness: 1,
|
|
153
|
+
distortion: 0.2,
|
|
154
|
+
swirl: 0.86,
|
|
155
|
+
swirlIterations: 7,
|
|
156
|
+
shapeScale: 0,
|
|
157
|
+
shape: "checks"
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
const presetNectar = {
|
|
161
|
+
name: "Nectar",
|
|
162
|
+
params: {
|
|
163
|
+
...defaultPatternSizing,
|
|
164
|
+
scale: 1 / 0.24,
|
|
165
|
+
rotation: 0,
|
|
166
|
+
speed: 4.2,
|
|
167
|
+
frame: 0,
|
|
168
|
+
colors: ["hsla(37.5, 22.2%, 7.1%, 1)", "hsla(38.5, 59.1%, 63.1%, 1)", "hsla(37.6, 30%, 95.2%, 1)"],
|
|
169
|
+
proportion: 0.24,
|
|
170
|
+
softness: 1,
|
|
171
|
+
distortion: 0.21,
|
|
172
|
+
swirl: 0.57,
|
|
173
|
+
swirlIterations: 10,
|
|
174
|
+
shapeScale: 0.32,
|
|
175
|
+
shape: "edge"
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const presetFilteredLight = {
|
|
179
|
+
name: "Filtered Light",
|
|
180
|
+
params: {
|
|
181
|
+
...defaultPatternSizing,
|
|
182
|
+
scale: 2,
|
|
183
|
+
rotation: 0.44,
|
|
184
|
+
speed: 3.2,
|
|
185
|
+
frame: 0,
|
|
186
|
+
colors: ["hsla(60.2, 7.8%, 8.3%, 1)", "hsla(64.4, 27.8%, 81%, 1)", "hsla(60, 100%, 93.9%, 1)"],
|
|
187
|
+
proportion: 0.25,
|
|
188
|
+
softness: 1,
|
|
189
|
+
distortion: 0.06,
|
|
190
|
+
swirl: 0,
|
|
191
|
+
swirlIterations: 0,
|
|
192
|
+
shapeScale: 0,
|
|
193
|
+
shape: "stripes"
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
const presetKelp = {
|
|
197
|
+
name: "Kelp",
|
|
198
|
+
params: {
|
|
199
|
+
...defaultPatternSizing,
|
|
200
|
+
scale: 0.38,
|
|
201
|
+
rotation: 0.6,
|
|
202
|
+
speed: 20,
|
|
203
|
+
frame: 0,
|
|
204
|
+
colors: ["hsla(79.3, 100%, 78%, 1)", "hsla(112, 10.5%, 28%, 1)", "hsla(203.3, 50%, 7.1%, 1)"],
|
|
205
|
+
proportion: 1,
|
|
206
|
+
softness: 0,
|
|
207
|
+
distortion: 0,
|
|
208
|
+
swirl: 0.15,
|
|
209
|
+
swirlIterations: 0,
|
|
210
|
+
shapeScale: 0.74,
|
|
211
|
+
shape: "stripes"
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const warpPresets = [
|
|
215
|
+
defaultPreset,
|
|
216
|
+
presetAbyss,
|
|
217
|
+
presetCauldron,
|
|
218
|
+
presetFilteredLight,
|
|
219
|
+
presetIceberg,
|
|
220
|
+
presetInk,
|
|
221
|
+
presetKelp,
|
|
222
|
+
presetNectar,
|
|
223
|
+
presetPassion,
|
|
224
|
+
presetPhantom,
|
|
225
|
+
presetSilk
|
|
226
|
+
];
|
|
227
|
+
const Warp = memo(function WarpImpl({
|
|
228
|
+
// Own props
|
|
229
|
+
speed = defaultPreset.params.speed,
|
|
230
|
+
frame = defaultPreset.params.frame,
|
|
231
|
+
colors = defaultPreset.params.colors,
|
|
232
|
+
proportion = defaultPreset.params.proportion,
|
|
233
|
+
softness = defaultPreset.params.softness,
|
|
234
|
+
distortion = defaultPreset.params.distortion,
|
|
235
|
+
swirl = defaultPreset.params.swirl,
|
|
236
|
+
swirlIterations = defaultPreset.params.swirlIterations,
|
|
237
|
+
shapeScale = defaultPreset.params.shapeScale,
|
|
238
|
+
shape = defaultPreset.params.shape,
|
|
239
|
+
// Sizing props
|
|
240
|
+
fit = defaultPreset.params.fit,
|
|
241
|
+
scale = defaultPreset.params.scale,
|
|
242
|
+
rotation = defaultPreset.params.rotation,
|
|
243
|
+
originX = defaultPreset.params.originX,
|
|
244
|
+
originY = defaultPreset.params.originY,
|
|
245
|
+
offsetX = defaultPreset.params.offsetX,
|
|
246
|
+
offsetY = defaultPreset.params.offsetY,
|
|
247
|
+
worldWidth = defaultPreset.params.worldWidth,
|
|
248
|
+
worldHeight = defaultPreset.params.worldHeight,
|
|
249
|
+
...props
|
|
250
|
+
}) {
|
|
251
|
+
const uniforms = {
|
|
252
|
+
// Own uniforms
|
|
253
|
+
u_colors: colors.map(getShaderColorFromString),
|
|
254
|
+
u_colorsCount: colors.length,
|
|
255
|
+
u_proportion: proportion,
|
|
256
|
+
u_softness: softness,
|
|
257
|
+
u_distortion: distortion,
|
|
258
|
+
u_swirl: swirl,
|
|
259
|
+
u_swirlIterations: swirlIterations,
|
|
260
|
+
u_shapeScale: shapeScale,
|
|
261
|
+
u_shape: WarpPatterns[shape],
|
|
262
|
+
// Sizing uniforms
|
|
263
|
+
u_scale: scale,
|
|
264
|
+
u_rotation: rotation,
|
|
265
|
+
u_fit: ShaderFitOptions[fit],
|
|
266
|
+
u_offsetX: offsetX,
|
|
267
|
+
u_offsetY: offsetY,
|
|
268
|
+
u_originX: originX,
|
|
269
|
+
u_originY: originY,
|
|
270
|
+
u_worldWidth: worldWidth,
|
|
271
|
+
u_worldHeight: worldHeight
|
|
272
|
+
};
|
|
273
|
+
return /* @__PURE__ */ jsx(ShaderMount, { ...props, speed, frame, fragmentShader: warpFragmentShader, uniforms });
|
|
274
|
+
}, colorPropsAreEqual);
|
|
275
|
+
export {
|
|
276
|
+
Warp,
|
|
277
|
+
defaultPreset,
|
|
278
|
+
presetAbyss,
|
|
279
|
+
presetCauldron,
|
|
280
|
+
presetFilteredLight,
|
|
281
|
+
presetIceberg,
|
|
282
|
+
presetInk,
|
|
283
|
+
presetKelp,
|
|
284
|
+
presetNectar,
|
|
285
|
+
presetPassion,
|
|
286
|
+
presetPhantom,
|
|
287
|
+
presetSilk,
|
|
288
|
+
warpPresets
|
|
289
|
+
};
|
|
290
|
+
//# sourceMappingURL=warp.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/shaders/warp.tsx"],
|
|
4
|
+
"sourcesContent": ["import { memo } from 'react';\nimport { ShaderMount, type ShaderComponentProps } from '../shader-mount';\nimport { colorPropsAreEqual } from '../color-props-are-equal';\nimport {\n defaultPatternSizing,\n getShaderColorFromString,\n warpFragmentShader,\n ShaderFitOptions,\n type WarpParams,\n type WarpUniforms,\n type ShaderPreset,\n WarpPatterns,\n} from '@paper-design/shaders';\n\nexport interface WarpProps extends ShaderComponentProps, WarpParams {}\n\ntype WarpPreset = ShaderPreset<WarpParams>;\n\n// Due to Leva controls limitation:\n// 1) keep default colors in HSLA format to keep alpha channel\n// 2) don't use decimal values on HSL values (to avoid button highlight bug)\n\nexport const defaultPreset: WarpPreset = {\n name: 'Default',\n params: {\n ...defaultPatternSizing,\n rotation: 0,\n speed: 1,\n frame: 0,\n colors: ['hsla(0, 0%, 15%, 1)', 'hsla(203, 80%, 70%, 1)', 'hsla(0, 0%, 100%, 1)'],\n proportion: 0.35,\n softness: 1,\n distortion: 0.25,\n swirl: 0.8,\n swirlIterations: 10,\n shapeScale: 0.1,\n shape: 'edge',\n },\n};\n\nexport const presetCauldron: WarpPreset = {\n name: 'Cauldron Pot',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 1.1,\n rotation: 1.62,\n speed: 10,\n frame: 0,\n colors: ['hsla(100, 51%, 75%, 1)', 'hsla(220, 39%, 32%, 1)', 'hsla(129.2, 41.9%, 6.1%, 1)'],\n proportion: 0.64,\n softness: 0.95,\n distortion: 0.2,\n swirl: 0.86,\n swirlIterations: 7,\n shapeScale: 0,\n shape: 'edge',\n },\n};\n\nexport const presetSilk: WarpPreset = {\n name: 'Silk',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.26,\n rotation: 0,\n speed: 5,\n frame: 0,\n colors: ['hsla(0, 9%, 7%, 1)', 'hsla(8, 13%, 34%, 1)', 'hsla(5, 8%, 71%, 1)'],\n proportion: 0,\n softness: 1,\n distortion: 0.3,\n swirl: 0.6,\n swirlIterations: 11,\n shapeScale: 0.05,\n shape: 'stripes',\n },\n};\n\nexport const presetPassion: WarpPreset = {\n name: 'Passion',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.25,\n rotation: 1.35,\n speed: 3,\n frame: 0,\n colors: ['hsla(0, 44.7%, 14.9%, 1)', 'hsla(353.4, 34%, 42.2%, 1)', 'hsla(29, 100%, 76.1%, 1)'],\n proportion: 0.5,\n softness: 1,\n distortion: 0.09,\n swirl: 0.9,\n swirlIterations: 6,\n shapeScale: 0.25,\n shape: 'checks',\n },\n};\n\nexport const presetPhantom: WarpPreset = {\n name: 'Phantom',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.68,\n rotation: 1.8,\n speed: 12,\n frame: 0,\n colors: ['hsla(242.2, 44.3%, 12%, 1)', 'hsla(236.1, 80.4%, 70%, 1)', 'hsla(0, 0%, 100%, 1)'],\n proportion: 0.45,\n softness: 1,\n distortion: 0.16,\n swirl: 0.3,\n swirlIterations: 7,\n shapeScale: 0.1,\n shape: 'checks',\n },\n};\n\nexport const presetAbyss: WarpPreset = {\n name: 'The Abyss',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.1,\n rotation: 2,\n speed: 0.6,\n frame: 0,\n colors: ['hsla(242.2, 44.3%, 12%, 1)', 'hsla(236.1, 80.4%, 70%, 1)', 'hsla(0, 0%, 100%, 1)'],\n proportion: 0,\n softness: 1,\n distortion: 0.09,\n swirl: 0.48,\n swirlIterations: 4,\n shapeScale: 0.1,\n shape: 'edge',\n },\n};\n\nexport const presetInk: WarpPreset = {\n name: 'Live Ink',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.7,\n rotation: 1.5,\n speed: 2.5,\n frame: 0,\n colors: ['hsla(210, 11.1%, 7.1%, 1)', 'hsla(165, 9%, 65.1%, 1)', 'hsla(84, 100%, 97.1%, 1)'],\n proportion: 0.35,\n softness: 0,\n distortion: 0.25,\n swirl: 0.8,\n swirlIterations: 10,\n shapeScale: 0.26,\n shape: 'checks',\n },\n};\n\nexport const presetIceberg: WarpPreset = {\n name: 'Iceberg',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 1.1,\n rotation: 2,\n speed: 0.5,\n frame: 0,\n colors: ['hsla(0, 0%, 100%, 1)', 'hsla(220, 38.7%, 32%, 1)', 'hsla(129.2, 41.9%, 6.1%, 1)'],\n proportion: 0.3,\n softness: 1,\n distortion: 0.2,\n swirl: 0.86,\n swirlIterations: 7,\n shapeScale: 0,\n shape: 'checks',\n },\n};\n\nexport const presetNectar: WarpPreset = {\n name: 'Nectar',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.24,\n rotation: 0,\n speed: 4.2,\n frame: 0,\n colors: ['hsla(37.5, 22.2%, 7.1%, 1)', 'hsla(38.5, 59.1%, 63.1%, 1)', 'hsla(37.6, 30%, 95.2%, 1)'],\n proportion: 0.24,\n softness: 1,\n distortion: 0.21,\n swirl: 0.57,\n swirlIterations: 10,\n shapeScale: 0.32,\n shape: 'edge',\n },\n};\n\nexport const presetFilteredLight: WarpPreset = {\n name: 'Filtered Light',\n params: {\n ...defaultPatternSizing,\n scale: 2,\n rotation: 0.44,\n speed: 3.2,\n frame: 0,\n colors: ['hsla(60.2, 7.8%, 8.3%, 1)', 'hsla(64.4, 27.8%, 81%, 1)', 'hsla(60, 100%, 93.9%, 1)'],\n proportion: 0.25,\n softness: 1,\n distortion: 0.06,\n swirl: 0,\n swirlIterations: 0,\n shapeScale: 0,\n shape: 'stripes',\n },\n};\n\nexport const presetKelp: WarpPreset = {\n name: 'Kelp',\n params: {\n ...defaultPatternSizing,\n scale: 0.38,\n rotation: 0.6,\n speed: 20,\n frame: 0,\n colors: ['hsla(79.3, 100%, 78%, 1)', 'hsla(112, 10.5%, 28%, 1)', 'hsla(203.3, 50%, 7.1%, 1)'],\n proportion: 1,\n softness: 0,\n distortion: 0,\n swirl: 0.15,\n swirlIterations: 0,\n shapeScale: 0.74,\n shape: 'stripes',\n },\n};\n\nexport const warpPresets: WarpPreset[] = [\n defaultPreset,\n presetAbyss,\n presetCauldron,\n presetFilteredLight,\n presetIceberg,\n presetInk,\n presetKelp,\n presetNectar,\n presetPassion,\n presetPhantom,\n presetSilk,\n];\n\nexport const Warp: React.FC<WarpProps> = memo(function WarpImpl({\n // Own props\n speed = defaultPreset.params.speed,\n frame = defaultPreset.params.frame,\n colors = defaultPreset.params.colors,\n proportion = defaultPreset.params.proportion,\n softness = defaultPreset.params.softness,\n distortion = defaultPreset.params.distortion,\n swirl = defaultPreset.params.swirl,\n swirlIterations = defaultPreset.params.swirlIterations,\n shapeScale = defaultPreset.params.shapeScale,\n shape = defaultPreset.params.shape,\n\n // Sizing props\n fit = defaultPreset.params.fit,\n scale = defaultPreset.params.scale,\n rotation = defaultPreset.params.rotation,\n originX = defaultPreset.params.originX,\n originY = defaultPreset.params.originY,\n offsetX = defaultPreset.params.offsetX,\n offsetY = defaultPreset.params.offsetY,\n worldWidth = defaultPreset.params.worldWidth,\n worldHeight = defaultPreset.params.worldHeight,\n ...props\n}: WarpProps) {\n const uniforms = {\n // Own uniforms\n u_colors: colors.map(getShaderColorFromString),\n u_colorsCount: colors.length,\n u_proportion: proportion,\n u_softness: softness,\n u_distortion: distortion,\n u_swirl: swirl,\n u_swirlIterations: swirlIterations,\n u_shapeScale: shapeScale,\n u_shape: WarpPatterns[shape],\n\n // Sizing uniforms\n u_scale: scale,\n u_rotation: rotation,\n u_fit: ShaderFitOptions[fit],\n u_offsetX: offsetX,\n u_offsetY: offsetY,\n u_originX: originX,\n u_originY: originY,\n u_worldWidth: worldWidth,\n u_worldHeight: worldHeight,\n } satisfies WarpUniforms;\n\n return <ShaderMount {...props} speed={speed} frame={frame} fragmentShader={warpFragmentShader} uniforms={uniforms} />;\n}, colorPropsAreEqual);\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA,SAAS,YAAY;AACrB,SAAS,mBAA8C;AACvD,SAAS,0BAA0B;AACnC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAIA;AAAA,OACK;AAyRE;AA/QF,MAAM,gBAA4B;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AG,OAAO,OAAc,OAAc,gBAAgB,oBAAoB,UAAoB;AACrH,GAAG,kBAAkB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/shaders/waves.d.ts
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
shape?: number;
|
|
7
|
-
frequency?: number;
|
|
8
|
-
amplitude?: number;
|
|
9
|
-
spacing?: number;
|
|
10
|
-
dutyCycle?: number;
|
|
11
|
-
softness?: number;
|
|
12
|
-
};
|
|
13
|
-
export type WavesProps = Omit<ShaderMountProps, 'fragmentShader'> & WavesParams;
|
|
14
|
-
type WavesPreset = {
|
|
15
|
-
name: string;
|
|
16
|
-
params: Required<WavesParams>;
|
|
17
|
-
style?: React.CSSProperties;
|
|
18
|
-
};
|
|
1
|
+
import { type ShaderComponentProps } from '../shader-mount';
|
|
2
|
+
import { type WavesParams, type ShaderPreset } from '@paper-design/shaders';
|
|
3
|
+
export interface WavesProps extends ShaderComponentProps, WavesParams {
|
|
4
|
+
}
|
|
5
|
+
type WavesPreset = ShaderPreset<WavesParams>;
|
|
19
6
|
export declare const defaultPreset: WavesPreset;
|
|
20
7
|
export declare const spikesPreset: WavesPreset;
|
|
21
8
|
export declare const groovyPreset: WavesPreset;
|
|
@@ -23,5 +10,5 @@ export declare const tangledUpPreset: WavesPreset;
|
|
|
23
10
|
export declare const zigZagPreset: WavesPreset;
|
|
24
11
|
export declare const waveRidePreset: WavesPreset;
|
|
25
12
|
export declare const wavesPresets: WavesPreset[];
|
|
26
|
-
export declare const Waves:
|
|
13
|
+
export declare const Waves: React.FC<WavesProps>;
|
|
27
14
|
export {};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
2
|
+
* Paper Shaders *
|
|
3
|
+
* https://github.com/paper-design/shaders *
|
|
4
|
+
* * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
5
|
+
|
|
6
|
+
import { memo } from "react";
|
|
7
|
+
import { ShaderMount } from "../shader-mount";
|
|
8
|
+
import { colorPropsAreEqual } from "../color-props-are-equal";
|
|
9
|
+
import {
|
|
10
|
+
defaultPatternSizing,
|
|
11
|
+
getShaderColorFromString,
|
|
12
|
+
wavesFragmentShader,
|
|
13
|
+
ShaderFitOptions
|
|
14
|
+
} from "@paper-design/shaders";
|
|
15
|
+
import { jsx } from "react/jsx-runtime";
|
|
16
|
+
const defaultPreset = {
|
|
17
|
+
name: "Default",
|
|
18
|
+
params: {
|
|
19
|
+
...defaultPatternSizing,
|
|
20
|
+
scale: 1.6,
|
|
21
|
+
rotation: 0,
|
|
22
|
+
color1: "hsla(0, 0%, 100%, 1)",
|
|
23
|
+
color2: "hsla(225, 75%, 24%, 1)",
|
|
24
|
+
shape: 0,
|
|
25
|
+
frequency: 0.5,
|
|
26
|
+
amplitude: 0.6,
|
|
27
|
+
spacing: 0.65,
|
|
28
|
+
dutyCycle: 0.15,
|
|
29
|
+
softness: 0
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const spikesPreset = {
|
|
33
|
+
name: "Spikes",
|
|
34
|
+
params: {
|
|
35
|
+
...defaultPatternSizing,
|
|
36
|
+
scale: 1 / 2.3,
|
|
37
|
+
rotation: 0,
|
|
38
|
+
color1: "hsla(65, 100%, 95%, 1)",
|
|
39
|
+
color2: "hsla(290, 52%, 15%, 1)",
|
|
40
|
+
shape: 0,
|
|
41
|
+
frequency: 0.5,
|
|
42
|
+
amplitude: 0.9,
|
|
43
|
+
spacing: 0.37,
|
|
44
|
+
dutyCycle: 0.93,
|
|
45
|
+
softness: 0.15
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const groovyPreset = {
|
|
49
|
+
name: "Groovy",
|
|
50
|
+
params: {
|
|
51
|
+
...defaultPatternSizing,
|
|
52
|
+
scale: 1 / 0.5,
|
|
53
|
+
rotation: 1,
|
|
54
|
+
color1: "hsla(60, 100%, 97%, 1)",
|
|
55
|
+
color2: "hsla(20, 100%, 71%, 1)",
|
|
56
|
+
shape: 2.37,
|
|
57
|
+
frequency: 0.2,
|
|
58
|
+
amplitude: 0.67,
|
|
59
|
+
spacing: 1.17,
|
|
60
|
+
dutyCycle: 0.57,
|
|
61
|
+
softness: 0
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const tangledUpPreset = {
|
|
65
|
+
name: "Tangled up",
|
|
66
|
+
params: {
|
|
67
|
+
...defaultPatternSizing,
|
|
68
|
+
scale: 1 / 3.04,
|
|
69
|
+
rotation: 1,
|
|
70
|
+
color1: "hsla(198.7, 66.7%, 14.1%, 1)",
|
|
71
|
+
color2: "hsla(85.5, 35.7%, 78%, 1)",
|
|
72
|
+
shape: 3,
|
|
73
|
+
frequency: 0.44,
|
|
74
|
+
amplitude: 0.57,
|
|
75
|
+
spacing: 1.05,
|
|
76
|
+
dutyCycle: 0.97,
|
|
77
|
+
softness: 0
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const zigZagPreset = {
|
|
81
|
+
name: "Zig zag",
|
|
82
|
+
params: {
|
|
83
|
+
...defaultPatternSizing,
|
|
84
|
+
scale: 1 / 2.7,
|
|
85
|
+
rotation: 1,
|
|
86
|
+
color1: "hsla(0, 0%, 0%, 1)",
|
|
87
|
+
color2: "hsla(0, 0%, 90%, 1)",
|
|
88
|
+
shape: 0,
|
|
89
|
+
frequency: 0.6,
|
|
90
|
+
amplitude: 0.8,
|
|
91
|
+
spacing: 0.5,
|
|
92
|
+
dutyCycle: 1,
|
|
93
|
+
softness: 0.5
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const waveRidePreset = {
|
|
97
|
+
name: "Ride the wave",
|
|
98
|
+
params: {
|
|
99
|
+
...defaultPatternSizing,
|
|
100
|
+
scale: 1 / 0.84,
|
|
101
|
+
rotation: 0,
|
|
102
|
+
color1: "hsla(65, 100%, 95%, 1)",
|
|
103
|
+
color2: "hsla(0, 0%, 12%, 1)",
|
|
104
|
+
shape: 2.23,
|
|
105
|
+
frequency: 0.1,
|
|
106
|
+
amplitude: 0.6,
|
|
107
|
+
spacing: 0.41,
|
|
108
|
+
dutyCycle: 0.99,
|
|
109
|
+
softness: 0
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
const wavesPresets = [
|
|
113
|
+
defaultPreset,
|
|
114
|
+
spikesPreset,
|
|
115
|
+
groovyPreset,
|
|
116
|
+
tangledUpPreset,
|
|
117
|
+
zigZagPreset,
|
|
118
|
+
waveRidePreset
|
|
119
|
+
];
|
|
120
|
+
const Waves = memo(function WavesImpl({
|
|
121
|
+
// Own props
|
|
122
|
+
color1 = defaultPreset.params.color1,
|
|
123
|
+
color2 = defaultPreset.params.color2,
|
|
124
|
+
shape = defaultPreset.params.shape,
|
|
125
|
+
frequency = defaultPreset.params.frequency,
|
|
126
|
+
amplitude = defaultPreset.params.amplitude,
|
|
127
|
+
spacing = defaultPreset.params.spacing,
|
|
128
|
+
dutyCycle = defaultPreset.params.dutyCycle,
|
|
129
|
+
softness = defaultPreset.params.softness,
|
|
130
|
+
// Sizing props
|
|
131
|
+
fit = defaultPreset.params.fit,
|
|
132
|
+
scale = defaultPreset.params.scale,
|
|
133
|
+
rotation = defaultPreset.params.rotation,
|
|
134
|
+
offsetX = defaultPreset.params.offsetX,
|
|
135
|
+
offsetY = defaultPreset.params.offsetY,
|
|
136
|
+
originX = defaultPreset.params.originX,
|
|
137
|
+
originY = defaultPreset.params.originY,
|
|
138
|
+
worldWidth = defaultPreset.params.worldWidth,
|
|
139
|
+
worldHeight = defaultPreset.params.worldHeight,
|
|
140
|
+
// Other props
|
|
141
|
+
maxPixelCount = 6016 * 3384,
|
|
142
|
+
// Higher max resolution for this shader
|
|
143
|
+
...props
|
|
144
|
+
}) {
|
|
145
|
+
const uniforms = {
|
|
146
|
+
// Own uniforms
|
|
147
|
+
u_color1: getShaderColorFromString(color1),
|
|
148
|
+
u_color2: getShaderColorFromString(color2),
|
|
149
|
+
u_shape: shape,
|
|
150
|
+
u_frequency: frequency,
|
|
151
|
+
u_amplitude: amplitude,
|
|
152
|
+
u_spacing: spacing,
|
|
153
|
+
u_dutyCycle: dutyCycle,
|
|
154
|
+
u_softness: softness,
|
|
155
|
+
// Sizing uniforms
|
|
156
|
+
u_fit: ShaderFitOptions[fit],
|
|
157
|
+
u_scale: scale,
|
|
158
|
+
u_rotation: rotation,
|
|
159
|
+
u_offsetX: offsetX,
|
|
160
|
+
u_offsetY: offsetY,
|
|
161
|
+
u_originX: originX,
|
|
162
|
+
u_originY: originY,
|
|
163
|
+
u_worldWidth: worldWidth,
|
|
164
|
+
u_worldHeight: worldHeight
|
|
165
|
+
};
|
|
166
|
+
return /* @__PURE__ */ jsx(ShaderMount, { ...props, fragmentShader: wavesFragmentShader, uniforms });
|
|
167
|
+
}, colorPropsAreEqual);
|
|
168
|
+
export {
|
|
169
|
+
Waves,
|
|
170
|
+
defaultPreset,
|
|
171
|
+
groovyPreset,
|
|
172
|
+
spikesPreset,
|
|
173
|
+
tangledUpPreset,
|
|
174
|
+
waveRidePreset,
|
|
175
|
+
wavesPresets,
|
|
176
|
+
zigZagPreset
|
|
177
|
+
};
|
|
178
|
+
//# sourceMappingURL=waves.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/shaders/waves.tsx"],
|
|
4
|
+
"sourcesContent": ["import { memo } from 'react';\nimport { ShaderMount, type ShaderComponentProps } from '../shader-mount';\nimport { colorPropsAreEqual } from '../color-props-are-equal';\nimport {\n defaultPatternSizing,\n getShaderColorFromString,\n wavesFragmentShader,\n ShaderFitOptions,\n type WavesParams,\n type WavesUniforms,\n type ShaderPreset,\n} from '@paper-design/shaders';\n\nexport interface WavesProps extends ShaderComponentProps, WavesParams {}\n\ntype WavesPreset = ShaderPreset<WavesParams>;\n\n// Due to Leva controls limitation:\n// 1) keep default colors in HSLA format to keep alpha channel\n// 2) don't use decimal values on HSL values (to avoid button highlight bug)\n\nexport const defaultPreset: WavesPreset = {\n name: 'Default',\n params: {\n ...defaultPatternSizing,\n scale: 1.6,\n rotation: 0,\n color1: 'hsla(0, 0%, 100%, 1)',\n color2: 'hsla(225, 75%, 24%, 1)',\n shape: 0,\n frequency: 0.5,\n amplitude: 0.6,\n spacing: 0.65,\n dutyCycle: 0.15,\n softness: 0,\n },\n};\n\nexport const spikesPreset: WavesPreset = {\n name: 'Spikes',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 2.3,\n rotation: 0,\n color1: 'hsla(65, 100%, 95%, 1)',\n color2: 'hsla(290, 52%, 15%, 1)',\n shape: 0,\n frequency: 0.5,\n amplitude: 0.9,\n spacing: 0.37,\n dutyCycle: 0.93,\n softness: 0.15,\n },\n};\n\nexport const groovyPreset: WavesPreset = {\n name: 'Groovy',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.5,\n rotation: 1,\n color1: 'hsla(60, 100%, 97%, 1)',\n color2: 'hsla(20, 100%, 71%, 1)',\n shape: 2.37,\n frequency: 0.2,\n amplitude: 0.67,\n spacing: 1.17,\n dutyCycle: 0.57,\n softness: 0,\n },\n};\n\nexport const tangledUpPreset: WavesPreset = {\n name: 'Tangled up',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 3.04,\n rotation: 1,\n color1: 'hsla(198.7, 66.7%, 14.1%, 1)',\n color2: 'hsla(85.5, 35.7%, 78%, 1)',\n shape: 3,\n frequency: 0.44,\n amplitude: 0.57,\n spacing: 1.05,\n dutyCycle: 0.97,\n softness: 0,\n },\n};\n\nexport const zigZagPreset: WavesPreset = {\n name: 'Zig zag',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 2.7,\n rotation: 1,\n color1: 'hsla(0, 0%, 0%, 1)',\n color2: 'hsla(0, 0%, 90%, 1)',\n shape: 0,\n frequency: 0.6,\n amplitude: 0.8,\n spacing: 0.5,\n dutyCycle: 1,\n softness: 0.5,\n },\n};\n\nexport const waveRidePreset: WavesPreset = {\n name: 'Ride the wave',\n params: {\n ...defaultPatternSizing,\n scale: 1 / 0.84,\n rotation: 0,\n color1: 'hsla(65, 100%, 95%, 1)',\n color2: 'hsla(0, 0%, 12%, 1)',\n shape: 2.23,\n frequency: 0.1,\n amplitude: 0.6,\n spacing: 0.41,\n dutyCycle: 0.99,\n softness: 0,\n },\n};\n\nexport const wavesPresets: WavesPreset[] = [\n defaultPreset,\n spikesPreset,\n groovyPreset,\n tangledUpPreset,\n zigZagPreset,\n waveRidePreset,\n];\n\nexport const Waves: React.FC<WavesProps> = memo(function WavesImpl({\n // Own props\n color1 = defaultPreset.params.color1,\n color2 = defaultPreset.params.color2,\n shape = defaultPreset.params.shape,\n frequency = defaultPreset.params.frequency,\n amplitude = defaultPreset.params.amplitude,\n spacing = defaultPreset.params.spacing,\n dutyCycle = defaultPreset.params.dutyCycle,\n softness = defaultPreset.params.softness,\n\n // Sizing props\n fit = defaultPreset.params.fit,\n scale = defaultPreset.params.scale,\n rotation = defaultPreset.params.rotation,\n offsetX = defaultPreset.params.offsetX,\n offsetY = defaultPreset.params.offsetY,\n originX = defaultPreset.params.originX,\n originY = defaultPreset.params.originY,\n worldWidth = defaultPreset.params.worldWidth,\n worldHeight = defaultPreset.params.worldHeight,\n\n // Other props\n maxPixelCount = 6016 * 3384, // Higher max resolution for this shader\n ...props\n}: WavesProps) {\n const uniforms = {\n // Own uniforms\n u_color1: getShaderColorFromString(color1),\n u_color2: getShaderColorFromString(color2),\n u_shape: shape,\n u_frequency: frequency,\n u_amplitude: amplitude,\n u_spacing: spacing,\n u_dutyCycle: dutyCycle,\n u_softness: softness,\n\n // Sizing uniforms\n u_fit: ShaderFitOptions[fit],\n u_scale: scale,\n u_rotation: rotation,\n u_offsetX: offsetX,\n u_offsetY: offsetY,\n u_originX: originX,\n u_originY: originY,\n u_worldWidth: worldWidth,\n u_worldHeight: worldHeight,\n } satisfies WavesUniforms;\n\n return <ShaderMount {...props} fragm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,OAAO;AAAA;AAAA,EAGnC,gBAAgB,OAAO;AAAA;AAAA,EACvB,GAAG;AACL,GAAe;AACb,QAAM,WAAW;AAAA;AAAA,IAEf,UAAU,yBAAyB,MAAM;AAAA,IACzC,UAAU,yBAAyB,MAAM;AAAA,IACzC,SAAS;AAAA,IACT,aAAa;AAAA,IACb,aAAa;AAAA,IACb,WAAW;AAAA,IACX,aAAa;AAAA,IACb,YAAY;AAAA;AAAA,IAGZ,OAAO,iBAAiB,GAAG;AAAA,IAC3B,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,WAAW;AAAA,IACX,cAAc;AAAA,IACd,eAAe;AAAA,EACjB;AAEA,SAAO,oBAAC,eAAa,GAAG,OAAO,gBAAgB,qBAAqB,UAAoB;AAC1F,GAAG,kBAAkB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
2
|
+
* Paper Shaders *
|
|
3
|
+
* https://github.com/paper-design/shaders *
|
|
4
|
+
* * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
5
|
+
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
function useMergeRefs(refs) {
|
|
8
|
+
const cleanupRef = React.useRef(void 0);
|
|
9
|
+
const refEffect = React.useCallback((instance) => {
|
|
10
|
+
const cleanups = refs.map((ref) => {
|
|
11
|
+
if (ref == null) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
if (typeof ref === "function") {
|
|
15
|
+
const refCallback = ref;
|
|
16
|
+
const refCleanup = refCallback(instance);
|
|
17
|
+
return typeof refCleanup === "function" ? refCleanup : () => {
|
|
18
|
+
refCallback(null);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
ref.current = instance;
|
|
22
|
+
return () => {
|
|
23
|
+
ref.current = null;
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
return () => {
|
|
27
|
+
cleanups.forEach((refCleanup) => refCleanup?.());
|
|
28
|
+
};
|
|
29
|
+
}, refs);
|
|
30
|
+
return React.useMemo(() => {
|
|
31
|
+
if (refs.every((ref) => ref == null)) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return (value) => {
|
|
35
|
+
if (cleanupRef.current) {
|
|
36
|
+
cleanupRef.current();
|
|
37
|
+
cleanupRef.current = void 0;
|
|
38
|
+
}
|
|
39
|
+
if (value != null) {
|
|
40
|
+
cleanupRef.current = refEffect(value);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}, refs);
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
useMergeRefs
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=use-merge-refs.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/use-merge-refs.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/react-utils#usemergerefs\n */\nexport function useMergeRefs<Instance>(refs: Array<React.Ref<Instance> | undefined>): null | React.Ref<Instance> {\n const cleanupRef = React.useRef<void | (() => void)>(undefined);\n\n const refEffect = React.useCallback((instance: Instance | null) => {\n const cleanups = refs.map((ref) => {\n if (ref == null) {\n return;\n }\n\n if (typeof ref === 'function') {\n const refCallback = ref;\n const refCleanup: void | (() => void) = refCallback(instance);\n return typeof refCleanup === 'function'\n ? refCleanup\n : () => {\n refCallback(null);\n };\n }\n\n (ref as React.RefObject<Instance | null>).current = instance;\n return () => {\n (ref as React.RefObject<Instance | null>).current = null;\n };\n });\n\n return () => {\n cleanups.forEach((refCleanup) => refCleanup?.());\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, refs);\n\n return React.useMemo(() => {\n if (refs.every((ref) => ref == null)) {\n return null;\n }\n\n return (value) => {\n if (cleanupRef.current) {\n cleanupRef.current();\n (cleanupRef as React.RefObject<void | (() => void)>).current = undefined;\n }\n\n if (value != null) {\n (cleanupRef as React.RefObject<void | (() => void)>).current = refEffect(value);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, refs);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;AAAA,YAAY,WAAW;AAMhB,SAAS,aAAuB,MAA0E;AAC/G,QAAM,aAAa,MAAM,OAA4B,MAAS;AAE9D,QAAM,YAAY,MAAM,YAAY,CAAC,aAA8B;AACjE,UAAM,WAAW,KAAK,IAAI,CAAC,QAAQ;AACjC,UAAI,OAAO,MAAM;AACf;AAAA,MACF;AAEA,UAAI,OAAO,QAAQ,YAAY;AAC7B,cAAM,cAAc;AACpB,cAAM,aAAkC,YAAY,QAAQ;AAC5D,eAAO,OAAO,eAAe,aACzB,aACA,MAAM;AACJ,sBAAY,IAAI;AAAA,QAClB;AAAA,MACN;AAEA,MAAC,IAAyC,UAAU;AACpD,aAAO,MAAM;AACX,QAAC,IAAyC,UAAU;AAAA,MACtD;AAAA,IACF,CAAC;AAED,WAAO,MAAM;AACX,eAAS,QAAQ,CAAC,eAAe,aAAa,CAAC;AAAA,IACjD;AAAA,EAEF,GAAG,IAAI;AAEP,SAAO,MAAM,QAAQ,MAAM;AACzB,QAAI,KAAK,MAAM,CAAC,QAAQ,OAAO,IAAI,GAAG;AACpC,aAAO;AAAA,IACT;AAEA,WAAO,CAAC,UAAU;AAChB,UAAI,WAAW,SAAS;AACtB,mBAAW,QAAQ;AACnB,QAAC,WAAoD,UAAU;AAAA,MACjE;AAEA,UAAI,SAAS,MAAM;AACjB,QAAC,WAAoD,UAAU,UAAU,KAAK;AAAA,MAChF;AAAA,IACF;AAAA,EAEF,GAAG,IAAI;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paper-design/shaders-react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
6
7
|
"publishConfig": {
|
|
7
8
|
"access": "public"
|
|
8
9
|
},
|
|
@@ -23,10 +24,18 @@
|
|
|
23
24
|
"type-check": "tsc --project tsconfig.json"
|
|
24
25
|
},
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"@paper-design/shaders": "0.0.
|
|
27
|
-
"react": ">=18"
|
|
27
|
+
"@paper-design/shaders": "0.0.27"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@types/react": "
|
|
30
|
+
"@types/react": "19.1.0"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"@types/react": "^18 || ^19",
|
|
34
|
+
"react": "^18 || ^19"
|
|
35
|
+
},
|
|
36
|
+
"peerDependenciesMeta": {
|
|
37
|
+
"@types/react": {
|
|
38
|
+
"optional": true
|
|
39
|
+
}
|
|
31
40
|
}
|
|
32
41
|
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type GlobalParams, type ShaderMountProps } from '../shader-mount';
|
|
2
|
-
export type SteppedSimplexNoiseParams = {
|
|
3
|
-
scale?: number;
|
|
4
|
-
color1?: string;
|
|
5
|
-
color2?: string;
|
|
6
|
-
color3?: string;
|
|
7
|
-
color4?: string;
|
|
8
|
-
color5?: string;
|
|
9
|
-
stepsNumber?: number;
|
|
10
|
-
} & GlobalParams;
|
|
11
|
-
export type SteppedSimplexNoiseProps = Omit<ShaderMountProps, 'fragmentShader'> & SteppedSimplexNoiseParams;
|
|
12
|
-
type SteppedSimplexNoisePreset = {
|
|
13
|
-
name: string;
|
|
14
|
-
params: Required<SteppedSimplexNoiseParams>;
|
|
15
|
-
style?: React.CSSProperties;
|
|
16
|
-
};
|
|
17
|
-
export declare const defaultPreset: SteppedSimplexNoisePreset;
|
|
18
|
-
export declare const steppedSimplexNoisePresets: SteppedSimplexNoisePreset[];
|
|
19
|
-
export declare const SteppedSimplexNoise: ({ scale, color1, color2, color3, color4, color5, stepsNumber, ...props }: SteppedSimplexNoiseProps) => React.ReactElement;
|
|
20
|
-
export {};
|