@firecms/neat 0.3.0 → 0.5.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/README.md +365 -68
- package/dist/NeatGradient.d.ts +105 -0
- package/dist/NeatGradient.js +793 -202
- package/dist/NeatGradient.js.map +1 -1
- package/dist/index.es.js +604 -236
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +156 -133
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
- package/src/NeatGradient.ts +955 -209
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
const
|
|
3
|
-
class
|
|
1
|
+
import * as l from "three";
|
|
2
|
+
const D = 50, E = 80, pe = !0, k = 6, xe = new l.Clock(), G = be();
|
|
3
|
+
class ze {
|
|
4
4
|
_ref;
|
|
5
5
|
_speed = -1;
|
|
6
6
|
_horizontalPressure = -1;
|
|
@@ -14,70 +14,151 @@ class $ {
|
|
|
14
14
|
_brightness = -1;
|
|
15
15
|
_grainScale = -1;
|
|
16
16
|
_grainIntensity = -1;
|
|
17
|
+
_grainSparsity = -1;
|
|
17
18
|
_grainSpeed = -1;
|
|
18
19
|
_colorBlending = -1;
|
|
19
20
|
_colors = [];
|
|
20
21
|
_wireframe = !1;
|
|
21
22
|
_backgroundColor = "#FFFFFF";
|
|
22
23
|
_backgroundAlpha = 1;
|
|
24
|
+
_flowDistortionA = 0;
|
|
25
|
+
_flowDistortionB = 0;
|
|
26
|
+
_flowScale = 1;
|
|
27
|
+
_flowEase = 0;
|
|
28
|
+
_flowEnabled = !0;
|
|
29
|
+
_mouseDistortionStrength = 0;
|
|
30
|
+
_mouseDistortionRadius = 0.25;
|
|
31
|
+
_mouseDecayRate = 0.96;
|
|
32
|
+
_mouseDarken = 0;
|
|
33
|
+
_mouse = new l.Vector2(-1e3, -1e3);
|
|
34
|
+
_mouseFBO = null;
|
|
35
|
+
_sceneMouse = null;
|
|
36
|
+
_cameraMouse = null;
|
|
37
|
+
_mouseObjects = [];
|
|
38
|
+
_currentBrush = 0;
|
|
39
|
+
_mouseBrushBaseScale = 1;
|
|
40
|
+
_enableProceduralTexture = !1;
|
|
41
|
+
_textureVoidLikelihood = 0.45;
|
|
42
|
+
_textureVoidWidthMin = 200;
|
|
43
|
+
_textureVoidWidthMax = 486;
|
|
44
|
+
_textureBandDensity = 2.15;
|
|
45
|
+
_textureColorBlending = 0.01;
|
|
46
|
+
_textureSeed = 333;
|
|
47
|
+
_textureEase = 0.5;
|
|
48
|
+
_proceduralTexture = null;
|
|
49
|
+
_proceduralBackgroundColor = "#000000";
|
|
50
|
+
_textureShapeTriangles = 20;
|
|
51
|
+
_textureShapeCircles = 15;
|
|
52
|
+
_textureShapeBars = 15;
|
|
53
|
+
_textureShapeSquiggles = 10;
|
|
23
54
|
requestRef = -1;
|
|
24
55
|
sizeObserver;
|
|
25
56
|
sceneState;
|
|
57
|
+
_cachedUniforms = null;
|
|
58
|
+
_linkElement = null;
|
|
59
|
+
_yOffset = 0;
|
|
60
|
+
_yOffsetWaveMultiplier = 4e-3;
|
|
61
|
+
_yOffsetColorMultiplier = 4e-3;
|
|
62
|
+
_yOffsetFlowMultiplier = 4e-3;
|
|
63
|
+
_tempClearColor = new l.Color();
|
|
26
64
|
constructor(e) {
|
|
27
65
|
const {
|
|
28
66
|
ref: o,
|
|
29
|
-
speed:
|
|
30
|
-
horizontalPressure:
|
|
31
|
-
verticalPressure:
|
|
32
|
-
waveFrequencyX:
|
|
33
|
-
waveFrequencyY:
|
|
34
|
-
waveAmplitude:
|
|
35
|
-
colors:
|
|
36
|
-
highlights:
|
|
37
|
-
shadows:
|
|
38
|
-
colorSaturation:
|
|
39
|
-
colorBrightness:
|
|
40
|
-
colorBlending:
|
|
41
|
-
grainScale:
|
|
42
|
-
grainIntensity:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
67
|
+
speed: t = 4,
|
|
68
|
+
horizontalPressure: f = 3,
|
|
69
|
+
verticalPressure: u = 3,
|
|
70
|
+
waveFrequencyX: s = 5,
|
|
71
|
+
waveFrequencyY: d = 5,
|
|
72
|
+
waveAmplitude: x = 3,
|
|
73
|
+
colors: p,
|
|
74
|
+
highlights: y = 4,
|
|
75
|
+
shadows: c = 4,
|
|
76
|
+
colorSaturation: m = 0,
|
|
77
|
+
colorBrightness: P = 1,
|
|
78
|
+
colorBlending: M = 5,
|
|
79
|
+
grainScale: T = 2,
|
|
80
|
+
grainIntensity: C = 0.55,
|
|
81
|
+
grainSparsity: B = 0,
|
|
82
|
+
grainSpeed: z = 0.1,
|
|
83
|
+
wireframe: a = !1,
|
|
84
|
+
backgroundColor: n = "#FFFFFF",
|
|
85
|
+
backgroundAlpha: h = 1,
|
|
86
|
+
resolution: _ = 1,
|
|
87
|
+
seed: b,
|
|
88
|
+
yOffset: F = 0,
|
|
89
|
+
yOffsetWaveMultiplier: A = 4,
|
|
90
|
+
yOffsetColorMultiplier: R = 4,
|
|
91
|
+
yOffsetFlowMultiplier: X = 4,
|
|
92
|
+
flowDistortionA: K = 0,
|
|
93
|
+
flowDistortionB: H = 0,
|
|
94
|
+
flowScale: Y = 1,
|
|
95
|
+
flowEase: J = 0,
|
|
96
|
+
flowEnabled: Q = !0,
|
|
97
|
+
mouseDistortionStrength: Z = 0,
|
|
98
|
+
mouseDistortionRadius: $ = 0.25,
|
|
99
|
+
mouseDecayRate: ee = 0.96,
|
|
100
|
+
mouseDarken: te = 0,
|
|
101
|
+
enableProceduralTexture: oe = !1,
|
|
102
|
+
textureVoidLikelihood: se = 0.45,
|
|
103
|
+
textureVoidWidthMin: ie = 200,
|
|
104
|
+
textureVoidWidthMax: re = 486,
|
|
105
|
+
textureBandDensity: ae = 2.15,
|
|
106
|
+
textureColorBlending: le = 0.01,
|
|
107
|
+
textureSeed: ne = 333,
|
|
108
|
+
textureEase: ue = 0.5,
|
|
109
|
+
proceduralBackgroundColor: ce = "#000000",
|
|
110
|
+
textureShapeTriangles: _e = 20,
|
|
111
|
+
textureShapeCircles: he = 15,
|
|
112
|
+
textureShapeBars: fe = 15,
|
|
113
|
+
textureShapeSquiggles: de = 10
|
|
49
114
|
} = e;
|
|
50
|
-
this._ref = o, this.destroy = this.destroy.bind(this), this._initScene = this._initScene.bind(this), this._buildMaterial = this._buildMaterial.bind(this), this.speed =
|
|
51
|
-
let
|
|
52
|
-
const
|
|
53
|
-
const { renderer:
|
|
54
|
-
Math.floor(
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
115
|
+
this._ref = o, this.destroy = this.destroy.bind(this), this._initScene = this._initScene.bind(this), this._buildMaterial = this._buildMaterial.bind(this), this.speed = t, this.horizontalPressure = f, this.verticalPressure = u, this.waveFrequencyX = s, this.waveFrequencyY = d, this.waveAmplitude = x, this.colorBlending = M, this.grainScale = T, this.grainIntensity = C, this.grainSparsity = B, this.grainSpeed = z, this.colors = p, this.shadows = c, this.highlights = y, this.colorSaturation = m, this.colorBrightness = P, this.wireframe = a, this.backgroundColor = n, this.backgroundAlpha = h, this.yOffset = F, this.yOffsetWaveMultiplier = A, this.yOffsetColorMultiplier = R, this.yOffsetFlowMultiplier = X, this.flowDistortionA = K, this.flowDistortionB = H, this.flowScale = Y, this.flowEase = J, this.flowEnabled = Q, this.mouseDistortionStrength = Z, this.mouseDistortionRadius = $, this.mouseDecayRate = ee, this.mouseDarken = te, this.enableProceduralTexture = oe, this.textureVoidLikelihood = se, this.textureVoidWidthMin = ie, this.textureVoidWidthMax = re, this.textureBandDensity = ae, this.textureColorBlending = le, this.textureSeed = ne, this.textureEase = ue, this._proceduralBackgroundColor = ce, this._textureShapeTriangles = _e, this._textureShapeCircles = he, this._textureShapeBars = fe, this._textureShapeSquiggles = de, this._setupMouseInteraction(), this.sceneState = this._initScene(_);
|
|
116
|
+
let U = b !== void 0 ? b : we();
|
|
117
|
+
const I = () => {
|
|
118
|
+
const { renderer: g, camera: q, scene: O } = this.sceneState;
|
|
119
|
+
if (Math.floor(U * 10) % 5 === 0 && (!this._linkElement || !document.contains(this._linkElement)) && (this._linkElement = ye(o)), this._cachedUniforms) {
|
|
120
|
+
const i = this._cachedUniforms;
|
|
121
|
+
U += xe.getDelta() * this._speed, i.u_time.value = U, i.u_resolution.value.set(this._ref.width, this._ref.height), i.u_color_pressure.value.set(this._horizontalPressure, this._verticalPressure), i.u_wave_frequency_x.value = this._waveFrequencyX, i.u_wave_frequency_y.value = this._waveFrequencyY, i.u_wave_amplitude.value = this._waveAmplitude, i.u_color_blending.value = this._colorBlending, i.u_shadows.value = this._shadows, i.u_highlights.value = this._highlights, i.u_saturation.value = this._saturation, i.u_brightness.value = this._brightness, i.u_grain_intensity.value = this._grainIntensity, i.u_grain_sparsity.value = this._grainSparsity, i.u_grain_speed.value = this._grainSpeed, i.u_grain_scale.value = this._grainScale, i.u_y_offset.value = this._yOffset, i.u_y_offset_wave_multiplier.value = this._yOffsetWaveMultiplier, i.u_y_offset_color_multiplier.value = this._yOffsetColorMultiplier, i.u_y_offset_flow_multiplier.value = this._yOffsetFlowMultiplier, i.u_flow_distortion_a.value = this._flowDistortionA, i.u_flow_distortion_b.value = this._flowDistortionB, i.u_flow_scale.value = this._flowScale, i.u_flow_ease.value = this._flowEase, i.u_flow_enabled.value = this._flowEnabled ? 1 : 0, i.u_mouse_distortion_strength.value = this._mouseDistortionStrength, i.u_mouse_distortion_radius.value = this._mouseDistortionRadius, i.u_mouse_darken.value = this._mouseDarken, i.u_enable_procedural_texture.value = this._enableProceduralTexture ? 1 : 0, i.u_procedural_texture.value = this._proceduralTexture, i.u_texture_ease.value = this._textureEase;
|
|
122
|
+
const w = i.u_colors.value;
|
|
123
|
+
for (let v = 0; v < k; v++)
|
|
124
|
+
if (v < this._colors.length) {
|
|
125
|
+
const S = this._colors[v];
|
|
126
|
+
w[v].is_active = S.enabled ? 1 : 0, w[v].color.setStyle(S.color, ""), w[v].influence = S.influence || 0;
|
|
127
|
+
} else
|
|
128
|
+
w[v].is_active = 0;
|
|
129
|
+
i.u_colors_count.value = k, this.sceneState.meshes[0].material.wireframe = this._wireframe;
|
|
130
|
+
}
|
|
131
|
+
if (this._mouseFBO && this._sceneMouse && this._cameraMouse) {
|
|
132
|
+
let i = !1;
|
|
133
|
+
for (let v = 0; v < this._mouseObjects.length; v++) {
|
|
134
|
+
const S = this._mouseObjects[v];
|
|
135
|
+
S.mesh.visible && (i = !0, S.mesh.rotation.z += 0.01, S.mesh.material instanceof l.MeshBasicMaterial && (S.mesh.material.opacity *= this._mouseDecayRate, S.mesh.material.opacity < 0.01 && (S.mesh.visible = !1)));
|
|
136
|
+
}
|
|
137
|
+
g.getClearColor(this._tempClearColor);
|
|
138
|
+
const w = g.getClearAlpha();
|
|
139
|
+
g.setClearColor(0, 0), g.setRenderTarget(this._mouseFBO), g.clear(), i && g.render(this._sceneMouse, this._cameraMouse), g.setRenderTarget(null), g.setClearColor(this._tempClearColor, w), this._cachedUniforms && (this._cachedUniforms.u_mouse_texture.value = this._mouseFBO.texture);
|
|
140
|
+
}
|
|
141
|
+
g.setClearColor(this._backgroundColor, this._backgroundAlpha), g.render(O, q), this.requestRef = requestAnimationFrame(I);
|
|
142
|
+
}, ve = () => {
|
|
143
|
+
const { renderer: g } = this.sceneState, q = g.domElement, O = q.clientWidth, i = q.clientHeight;
|
|
144
|
+
if (this.sceneState.renderer.setSize(O, i, !1), W(this.sceneState.camera, O, i), this._mouseFBO && this._cameraMouse) {
|
|
145
|
+
const w = i / 2, v = O / i;
|
|
146
|
+
this._mouseFBO.setSize(O / 2, i / 2), this._cameraMouse.left = -w * v, this._cameraMouse.right = w * v, this._cameraMouse.top = w, this._cameraMouse.bottom = -w, this._cameraMouse.updateProjectionMatrix();
|
|
147
|
+
}
|
|
74
148
|
};
|
|
75
|
-
this.sizeObserver = new ResizeObserver((
|
|
76
|
-
|
|
77
|
-
}), this.sizeObserver.observe(o),
|
|
149
|
+
this.sizeObserver = new ResizeObserver((g) => {
|
|
150
|
+
ve();
|
|
151
|
+
}), this.sizeObserver.observe(o), I();
|
|
78
152
|
}
|
|
79
153
|
destroy() {
|
|
80
|
-
this && (cancelAnimationFrame(this.requestRef), this.sizeObserver.disconnect())
|
|
154
|
+
this && (cancelAnimationFrame(this.requestRef), this.sizeObserver.disconnect(), this.sceneState && (this.sceneState.renderer.dispose(), this.sceneState.meshes.forEach((e) => {
|
|
155
|
+
e.geometry.dispose(), Array.isArray(e.material) ? e.material.forEach((o) => o.dispose()) : e.material.dispose();
|
|
156
|
+
})), this._mouseFBO && this._mouseFBO.dispose(), this._proceduralTexture && this._proceduralTexture.dispose());
|
|
157
|
+
}
|
|
158
|
+
downloadAsPNG(e = "neat.png") {
|
|
159
|
+
console.log("Downloading as PNG", this._ref);
|
|
160
|
+
const o = this._ref.toDataURL("image/png");
|
|
161
|
+
console.log("data", o), Se(o, e);
|
|
81
162
|
}
|
|
82
163
|
set speed(e) {
|
|
83
164
|
this._speed = e / 20;
|
|
@@ -121,6 +202,9 @@ class $ {
|
|
|
121
202
|
set grainIntensity(e) {
|
|
122
203
|
this._grainIntensity = e;
|
|
123
204
|
}
|
|
205
|
+
set grainSparsity(e) {
|
|
206
|
+
this._grainSparsity = e;
|
|
207
|
+
}
|
|
124
208
|
set grainSpeed(e) {
|
|
125
209
|
this._grainSpeed = e;
|
|
126
210
|
}
|
|
@@ -136,94 +220,379 @@ class $ {
|
|
|
136
220
|
set backgroundAlpha(e) {
|
|
137
221
|
this._backgroundAlpha = e;
|
|
138
222
|
}
|
|
223
|
+
set yOffset(e) {
|
|
224
|
+
this._yOffset = e;
|
|
225
|
+
}
|
|
226
|
+
get yOffsetWaveMultiplier() {
|
|
227
|
+
return this._yOffsetWaveMultiplier * 1e3;
|
|
228
|
+
}
|
|
229
|
+
set yOffsetWaveMultiplier(e) {
|
|
230
|
+
this._yOffsetWaveMultiplier = e / 1e3;
|
|
231
|
+
}
|
|
232
|
+
get yOffsetColorMultiplier() {
|
|
233
|
+
return this._yOffsetColorMultiplier * 1e3;
|
|
234
|
+
}
|
|
235
|
+
set yOffsetColorMultiplier(e) {
|
|
236
|
+
this._yOffsetColorMultiplier = e / 1e3;
|
|
237
|
+
}
|
|
238
|
+
get yOffsetFlowMultiplier() {
|
|
239
|
+
return this._yOffsetFlowMultiplier * 1e3;
|
|
240
|
+
}
|
|
241
|
+
set yOffsetFlowMultiplier(e) {
|
|
242
|
+
this._yOffsetFlowMultiplier = e / 1e3;
|
|
243
|
+
}
|
|
244
|
+
set flowDistortionA(e) {
|
|
245
|
+
this._flowDistortionA = e;
|
|
246
|
+
}
|
|
247
|
+
set flowDistortionB(e) {
|
|
248
|
+
this._flowDistortionB = e;
|
|
249
|
+
}
|
|
250
|
+
set flowScale(e) {
|
|
251
|
+
this._flowScale = e;
|
|
252
|
+
}
|
|
253
|
+
set flowEase(e) {
|
|
254
|
+
this._flowEase = e;
|
|
255
|
+
}
|
|
256
|
+
set flowEnabled(e) {
|
|
257
|
+
this._flowEnabled = e;
|
|
258
|
+
}
|
|
259
|
+
get flowEnabled() {
|
|
260
|
+
return this._flowEnabled;
|
|
261
|
+
}
|
|
262
|
+
set mouseDistortionStrength(e) {
|
|
263
|
+
this._mouseDistortionStrength = Math.max(0, e);
|
|
264
|
+
}
|
|
265
|
+
set mouseDistortionRadius(e) {
|
|
266
|
+
this._mouseDistortionRadius = Math.max(0.01, Math.min(e, 1)), this._updateBrushScale();
|
|
267
|
+
}
|
|
268
|
+
_updateBrushScale() {
|
|
269
|
+
!this._mouseObjects || this._mouseObjects.length === 0 || (this._mouseBrushBaseScale = this._mouseDistortionRadius);
|
|
270
|
+
}
|
|
271
|
+
set mouseDecayRate(e) {
|
|
272
|
+
this._mouseDecayRate = Math.max(0.9, Math.min(e, 0.99));
|
|
273
|
+
}
|
|
274
|
+
set mouseDarken(e) {
|
|
275
|
+
this._mouseDarken = e;
|
|
276
|
+
}
|
|
277
|
+
set enableProceduralTexture(e) {
|
|
278
|
+
this._enableProceduralTexture = e, e && !this._proceduralTexture && (this._proceduralTexture = this._createProceduralTexture());
|
|
279
|
+
}
|
|
280
|
+
set textureVoidLikelihood(e) {
|
|
281
|
+
this._textureVoidLikelihood = e, this._enableProceduralTexture && (this._proceduralTexture = this._createProceduralTexture());
|
|
282
|
+
}
|
|
283
|
+
set textureVoidWidthMin(e) {
|
|
284
|
+
this._textureVoidWidthMin = e, this._enableProceduralTexture && (this._proceduralTexture = this._createProceduralTexture());
|
|
285
|
+
}
|
|
286
|
+
set textureVoidWidthMax(e) {
|
|
287
|
+
this._textureVoidWidthMax = e, this._enableProceduralTexture && (this._proceduralTexture = this._createProceduralTexture());
|
|
288
|
+
}
|
|
289
|
+
set textureBandDensity(e) {
|
|
290
|
+
this._textureBandDensity = e, this._enableProceduralTexture && (this._proceduralTexture = this._createProceduralTexture());
|
|
291
|
+
}
|
|
292
|
+
set textureColorBlending(e) {
|
|
293
|
+
this._textureColorBlending = e, this._enableProceduralTexture && (this._proceduralTexture = this._createProceduralTexture());
|
|
294
|
+
}
|
|
295
|
+
set textureSeed(e) {
|
|
296
|
+
this._textureSeed = e, this._enableProceduralTexture && (this._proceduralTexture = this._createProceduralTexture());
|
|
297
|
+
}
|
|
298
|
+
get textureEase() {
|
|
299
|
+
return this._textureEase;
|
|
300
|
+
}
|
|
301
|
+
set textureEase(e) {
|
|
302
|
+
this._textureEase = e;
|
|
303
|
+
}
|
|
304
|
+
set proceduralBackgroundColor(e) {
|
|
305
|
+
this._proceduralBackgroundColor = e, this._enableProceduralTexture && (this._proceduralTexture = this._createProceduralTexture());
|
|
306
|
+
}
|
|
307
|
+
set textureShapeTriangles(e) {
|
|
308
|
+
this._textureShapeTriangles = e, this._enableProceduralTexture && (this._proceduralTexture = this._createProceduralTexture());
|
|
309
|
+
}
|
|
310
|
+
set textureShapeCircles(e) {
|
|
311
|
+
this._textureShapeCircles = e, this._enableProceduralTexture && (this._proceduralTexture = this._createProceduralTexture());
|
|
312
|
+
}
|
|
313
|
+
set textureShapeBars(e) {
|
|
314
|
+
this._textureShapeBars = e, this._enableProceduralTexture && (this._proceduralTexture = this._createProceduralTexture());
|
|
315
|
+
}
|
|
316
|
+
set textureShapeSquiggles(e) {
|
|
317
|
+
this._textureShapeSquiggles = e, this._enableProceduralTexture && (this._proceduralTexture = this._createProceduralTexture());
|
|
318
|
+
}
|
|
139
319
|
_initScene(e) {
|
|
140
|
-
const o = this._ref.width,
|
|
320
|
+
const o = this._ref.width, t = this._ref.height;
|
|
321
|
+
this.sceneState && this.sceneState.renderer && (this.sceneState.renderer.dispose(), this.sceneState.meshes.forEach((c) => {
|
|
322
|
+
c.geometry.dispose(), Array.isArray(c.material) ? c.material.forEach((m) => m.dispose()) : c.material.dispose();
|
|
323
|
+
}));
|
|
324
|
+
const f = new l.WebGLRenderer({
|
|
141
325
|
alpha: !0,
|
|
326
|
+
preserveDrawingBuffer: !0,
|
|
142
327
|
canvas: this._ref
|
|
143
328
|
});
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
const
|
|
148
|
-
return
|
|
149
|
-
renderer:
|
|
150
|
-
camera:
|
|
151
|
-
scene:
|
|
152
|
-
meshes:
|
|
329
|
+
f.setClearColor(16711680, 0.5), f.setSize(o, t, !1);
|
|
330
|
+
const u = [], s = new l.Scene(), d = this._buildMaterial(o, t), x = new l.PlaneGeometry(D, E, 240 * e, 240 * e), p = new l.Mesh(x, d);
|
|
331
|
+
p.rotation.x = -Math.PI / 3.5, p.position.z = -1, u.push(p), s.add(p);
|
|
332
|
+
const y = new l.OrthographicCamera(0, 0, 0, 0, 0, 0);
|
|
333
|
+
return y.position.z = 5, W(y, o, t), {
|
|
334
|
+
renderer: f,
|
|
335
|
+
camera: y,
|
|
336
|
+
scene: s,
|
|
337
|
+
meshes: u,
|
|
153
338
|
resolution: e
|
|
154
339
|
};
|
|
155
340
|
}
|
|
156
341
|
_buildMaterial(e, o) {
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
})),
|
|
163
|
-
...Array.from({ length: S - this._colors.length }).map(() => ({
|
|
164
|
-
is_active: !1,
|
|
165
|
-
color: new i.Color(0)
|
|
166
|
-
}))
|
|
167
|
-
], s = {
|
|
342
|
+
const t = Array.from({ length: k }).map((s, d) => ({
|
|
343
|
+
is_active: d < this._colors.length && this._colors[d].enabled ? 1 : 0,
|
|
344
|
+
color: new l.Color(d < this._colors.length ? this._colors[d].color : 0),
|
|
345
|
+
influence: d < this._colors.length && this._colors[d].influence || 0
|
|
346
|
+
})), f = {
|
|
168
347
|
u_time: { value: 0 },
|
|
169
|
-
u_color_pressure: { value: new
|
|
348
|
+
u_color_pressure: { value: new l.Vector2(this._horizontalPressure, this._verticalPressure) },
|
|
170
349
|
u_wave_frequency_x: { value: this._waveFrequencyX },
|
|
171
350
|
u_wave_frequency_y: { value: this._waveFrequencyY },
|
|
172
351
|
u_wave_amplitude: { value: this._waveAmplitude },
|
|
173
|
-
u_resolution: { value: new
|
|
174
|
-
u_colors: { value:
|
|
352
|
+
u_resolution: { value: new l.Vector2(e, o) },
|
|
353
|
+
u_colors: { value: t },
|
|
175
354
|
u_colors_count: { value: this._colors.length },
|
|
176
|
-
u_plane_width: { value:
|
|
177
|
-
u_plane_height: { value:
|
|
355
|
+
u_plane_width: { value: D },
|
|
356
|
+
u_plane_height: { value: E },
|
|
178
357
|
u_shadows: { value: this._shadows },
|
|
179
358
|
u_highlights: { value: this._highlights },
|
|
180
359
|
u_grain_intensity: { value: this._grainIntensity },
|
|
360
|
+
u_grain_sparsity: { value: this._grainSparsity },
|
|
181
361
|
u_grain_scale: { value: this._grainScale },
|
|
182
|
-
u_grain_speed: { value: this._grainSpeed }
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
362
|
+
u_grain_speed: { value: this._grainSpeed },
|
|
363
|
+
u_flow_distortion_a: { value: this._flowDistortionA },
|
|
364
|
+
u_flow_distortion_b: { value: this._flowDistortionB },
|
|
365
|
+
u_flow_scale: { value: this._flowScale },
|
|
366
|
+
u_flow_ease: { value: this._flowEase },
|
|
367
|
+
u_flow_enabled: { value: this._flowEnabled ? 1 : 0 },
|
|
368
|
+
u_y_offset: { value: this._yOffset },
|
|
369
|
+
u_y_offset_wave_multiplier: { value: this._yOffsetWaveMultiplier },
|
|
370
|
+
u_y_offset_color_multiplier: { value: this._yOffsetColorMultiplier },
|
|
371
|
+
u_y_offset_flow_multiplier: { value: this._yOffsetFlowMultiplier },
|
|
372
|
+
u_mouse_distortion_strength: { value: this._mouseDistortionStrength },
|
|
373
|
+
u_mouse_distortion_radius: { value: this._mouseDistortionRadius },
|
|
374
|
+
u_mouse_darken: { value: this._mouseDarken },
|
|
375
|
+
u_mouse_texture: { value: this._mouseFBO ? this._mouseFBO.texture : null },
|
|
376
|
+
u_procedural_texture: { value: this._proceduralTexture },
|
|
377
|
+
u_enable_procedural_texture: { value: this._enableProceduralTexture ? 1 : 0 },
|
|
378
|
+
u_texture_ease: { value: this._textureEase },
|
|
379
|
+
u_saturation: { value: this._saturation },
|
|
380
|
+
u_brightness: { value: this._brightness },
|
|
381
|
+
u_color_blending: { value: this._colorBlending }
|
|
382
|
+
}, u = new l.ShaderMaterial({
|
|
383
|
+
uniforms: f,
|
|
384
|
+
vertexShader: V() + L() + N() + ge(),
|
|
385
|
+
fragmentShader: V() + N() + L() + me()
|
|
187
386
|
});
|
|
188
|
-
return
|
|
387
|
+
return this._cachedUniforms = f, u.wireframe = pe, u;
|
|
388
|
+
}
|
|
389
|
+
_setupMouseInteraction() {
|
|
390
|
+
if (!this._ref)
|
|
391
|
+
return;
|
|
392
|
+
const e = this._ref.width, o = this._ref.height;
|
|
393
|
+
this._mouseFBO = new l.WebGLRenderTarget(e / 2, o / 2), this._sceneMouse = new l.Scene();
|
|
394
|
+
const t = o / 2, f = e / o;
|
|
395
|
+
this._cameraMouse = new l.OrthographicCamera(
|
|
396
|
+
-t * f,
|
|
397
|
+
t * f,
|
|
398
|
+
t,
|
|
399
|
+
-t,
|
|
400
|
+
0,
|
|
401
|
+
1e4
|
|
402
|
+
), this._cameraMouse.position.set(0, 0, 100);
|
|
403
|
+
const u = document.createElement("canvas");
|
|
404
|
+
u.width = 128, u.height = 128;
|
|
405
|
+
const s = u.getContext("2d");
|
|
406
|
+
if (s) {
|
|
407
|
+
const c = s.createRadialGradient(64, 64, 0, 64, 64, 64);
|
|
408
|
+
c.addColorStop(0, "rgba(255,255,255,0.8)"), c.addColorStop(0.5, "rgba(255,255,255,0.4)"), c.addColorStop(1, "rgba(255,255,255,0)"), s.fillStyle = c, s.fillRect(0, 0, 128, 128);
|
|
409
|
+
}
|
|
410
|
+
const d = new l.CanvasTexture(u), x = new l.MeshBasicMaterial({
|
|
411
|
+
map: d,
|
|
412
|
+
transparent: !0,
|
|
413
|
+
opacity: 1,
|
|
414
|
+
depthTest: !1,
|
|
415
|
+
blending: l.AdditiveBlending
|
|
416
|
+
}), p = new l.PlaneGeometry(200, 200), y = 50;
|
|
417
|
+
for (let c = 0; c < y; c++) {
|
|
418
|
+
const m = new l.Mesh(p, x.clone());
|
|
419
|
+
m.visible = !1, this._sceneMouse.add(m), this._mouseObjects.push({ mesh: m, active: !1 });
|
|
420
|
+
}
|
|
421
|
+
this._updateBrushScale(), this._ref.addEventListener("mousemove", this._onMouseMove.bind(this));
|
|
422
|
+
}
|
|
423
|
+
_onMouseMove(e) {
|
|
424
|
+
if (!this._ref || !this._sceneMouse)
|
|
425
|
+
return;
|
|
426
|
+
const o = this._ref.getBoundingClientRect(), t = this._ref.width, f = this._ref.height;
|
|
427
|
+
this._mouse.x = e.clientX - o.left - t / 2, this._mouse.y = -(e.clientY - o.top - f / 2);
|
|
428
|
+
const u = this._mouseObjects[this._currentBrush];
|
|
429
|
+
u.mesh.scale.set(this._mouseBrushBaseScale, this._mouseBrushBaseScale, 1), u.active = !0, u.mesh.visible = !0, u.mesh.position.set(this._mouse.x, this._mouse.y, 0), u.mesh.rotation.z = Math.random() * Math.PI * 2, u.mesh.material instanceof l.MeshBasicMaterial && (u.mesh.material.opacity = 1), this._currentBrush = (this._currentBrush + 1) % this._mouseObjects.length;
|
|
430
|
+
}
|
|
431
|
+
_createProceduralTexture() {
|
|
432
|
+
const o = document.createElement("canvas");
|
|
433
|
+
o.width = 1024, o.height = 1024;
|
|
434
|
+
const t = o.getContext("2d");
|
|
435
|
+
if (!t)
|
|
436
|
+
return new l.Texture();
|
|
437
|
+
let f = this._textureSeed;
|
|
438
|
+
const u = this._textureSeed;
|
|
439
|
+
function s() {
|
|
440
|
+
const a = Math.sin(f++) * 1e4;
|
|
441
|
+
return a - Math.floor(a);
|
|
442
|
+
}
|
|
443
|
+
const d = (a) => {
|
|
444
|
+
f = u + a;
|
|
445
|
+
}, x = this._colors.filter((a) => a.enabled).map((a) => a.color);
|
|
446
|
+
if (x.length === 0)
|
|
447
|
+
return new l.Texture();
|
|
448
|
+
function p(a) {
|
|
449
|
+
const n = parseInt(a.replace("#", ""), 16);
|
|
450
|
+
return {
|
|
451
|
+
r: n >> 16 & 255,
|
|
452
|
+
g: n >> 8 & 255,
|
|
453
|
+
b: n & 255
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function y(a, n, h) {
|
|
457
|
+
return "#" + ((1 << 24) + (Math.round(a) << 16) + (Math.round(n) << 8) + Math.round(h)).toString(16).slice(1);
|
|
458
|
+
}
|
|
459
|
+
const c = () => {
|
|
460
|
+
const a = x[Math.floor(s() * x.length)], n = x[Math.floor(s() * x.length)], h = s() * this._textureColorBlending, _ = p(a), b = p(n), F = _.r + (b.r - _.r) * h, A = _.g + (b.g - _.g) * h, R = _.b + (b.b - _.b) * h;
|
|
461
|
+
return y(F, A, R);
|
|
462
|
+
}, m = this._proceduralBackgroundColor || "#000000";
|
|
463
|
+
t.fillStyle = m, t.fillRect(0, 0, 1024, 1024);
|
|
464
|
+
const P = t.createLinearGradient(0, 0, 0, 1024);
|
|
465
|
+
P.addColorStop(0, c()), P.addColorStop(1, c()), t.fillStyle = P, t.fillRect(0, 0, 1024, 1024);
|
|
466
|
+
for (let a = 0; a < this._textureShapeTriangles; a++) {
|
|
467
|
+
t.fillStyle = c(), t.beginPath();
|
|
468
|
+
const n = s() * 1024, h = s() * 1024, _ = 100 + s() * 300;
|
|
469
|
+
t.moveTo(n, h), t.lineTo(n + (s() - 0.5) * _, h + (s() - 0.5) * _), t.lineTo(n + (s() - 0.5) * _, h + (s() - 0.5) * _), t.fill();
|
|
470
|
+
}
|
|
471
|
+
for (let a = 0; a < this._textureShapeCircles; a++) {
|
|
472
|
+
t.strokeStyle = c(), t.lineWidth = 10 + s() * 50, t.beginPath();
|
|
473
|
+
const n = s() * 1024, h = s() * 1024, _ = 50 + s() * 150;
|
|
474
|
+
t.arc(n, h, _, 0, Math.PI * 2), t.stroke();
|
|
475
|
+
}
|
|
476
|
+
for (let a = 0; a < this._textureShapeBars; a++)
|
|
477
|
+
t.fillStyle = c(), t.save(), t.translate(s() * 1024, s() * 1024), t.rotate(s() * Math.PI), t.fillRect(-150, -25, 300, 50), t.restore();
|
|
478
|
+
t.lineWidth = 15, t.lineCap = "round";
|
|
479
|
+
for (let a = 0; a < this._textureShapeSquiggles; a++) {
|
|
480
|
+
t.strokeStyle = c(), t.beginPath();
|
|
481
|
+
let n = s() * 1024, h = s() * 1024;
|
|
482
|
+
t.moveTo(n, h);
|
|
483
|
+
for (let _ = 0; _ < 4; _++)
|
|
484
|
+
t.bezierCurveTo(
|
|
485
|
+
n + (s() - 0.5) * 300,
|
|
486
|
+
h + (s() - 0.5) * 300,
|
|
487
|
+
n + (s() - 0.5) * 300,
|
|
488
|
+
h + (s() - 0.5) * 300,
|
|
489
|
+
n + (s() - 0.5) * 300,
|
|
490
|
+
h + (s() - 0.5) * 300
|
|
491
|
+
), n += (s() - 0.5) * 300, h += (s() - 0.5) * 300;
|
|
492
|
+
t.stroke();
|
|
493
|
+
}
|
|
494
|
+
d(5e4);
|
|
495
|
+
const M = document.createElement("canvas");
|
|
496
|
+
M.width = 1024, M.height = 1024;
|
|
497
|
+
const T = M.getContext("2d");
|
|
498
|
+
if (!T)
|
|
499
|
+
return new l.Texture();
|
|
500
|
+
T.fillStyle = m, T.fillRect(0, 0, 1024, 1024);
|
|
501
|
+
let C = 0;
|
|
502
|
+
const B = [];
|
|
503
|
+
for (; C < 1024; )
|
|
504
|
+
if (s() < this._textureVoidLikelihood) {
|
|
505
|
+
const n = this._textureVoidWidthMin + s() * (this._textureVoidWidthMax - this._textureVoidWidthMin);
|
|
506
|
+
B.push({ type: "void", x: C, width: n }), C += n;
|
|
507
|
+
} else {
|
|
508
|
+
const n = 50 + s() * 200;
|
|
509
|
+
B.push({ type: "matter", x: C, width: n }), C += n;
|
|
510
|
+
}
|
|
511
|
+
for (const a of B)
|
|
512
|
+
if (a.type === "matter") {
|
|
513
|
+
const n = a.x, h = Math.min(a.x + a.width, 1024);
|
|
514
|
+
let _ = n;
|
|
515
|
+
for (; _ < h; ) {
|
|
516
|
+
const b = (2 + s() * 20) / this._textureBandDensity, F = Math.floor(s() * 1024);
|
|
517
|
+
T.drawImage(
|
|
518
|
+
o,
|
|
519
|
+
F,
|
|
520
|
+
0,
|
|
521
|
+
b,
|
|
522
|
+
1024,
|
|
523
|
+
_,
|
|
524
|
+
0,
|
|
525
|
+
b,
|
|
526
|
+
1024
|
|
527
|
+
), _ += b;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
const z = new l.CanvasTexture(M);
|
|
531
|
+
return z.minFilter = l.LinearMipmapLinearFilter, z.magFilter = l.LinearFilter, z.wrapS = l.RepeatWrapping, z.wrapT = l.RepeatWrapping, z.anisotropy = 16, z.needsUpdate = !0, z;
|
|
189
532
|
}
|
|
190
533
|
}
|
|
191
|
-
function
|
|
192
|
-
const
|
|
193
|
-
|
|
534
|
+
function W(r, e, o) {
|
|
535
|
+
const u = e * o / 1e6 * D * E / 1.5, s = e / o, d = Math.sqrt(u * s), x = u / d, p = -D / 2, y = Math.min((p + d) / 1.5, D / 2), c = E / 4, m = Math.max((c - x) / 2, -E / 4), P = -100, M = 1e3;
|
|
536
|
+
r instanceof l.OrthographicCamera ? (r.left = p, r.right = y, r.top = c, r.bottom = m, r.near = P, r.far = M, r.updateProjectionMatrix()) : r instanceof l.PerspectiveCamera && (r.aspect = e / o, r.updateProjectionMatrix());
|
|
194
537
|
}
|
|
195
|
-
function
|
|
538
|
+
function ge() {
|
|
196
539
|
return `
|
|
197
|
-
|
|
198
540
|
void main() {
|
|
199
|
-
|
|
200
541
|
vUv = uv;
|
|
201
542
|
|
|
543
|
+
// SCROLLING LOGIC
|
|
544
|
+
// Separate multipliers for wave, color, and flow offsets
|
|
545
|
+
float waveOffset = -u_y_offset * u_y_offset_wave_multiplier;
|
|
546
|
+
float colorOffset = -u_y_offset * u_y_offset_color_multiplier;
|
|
547
|
+
float flowOffset = -u_y_offset * u_y_offset_flow_multiplier;
|
|
548
|
+
|
|
549
|
+
// 1. DISPLACEMENT (WAVES)
|
|
550
|
+
// We add waveOffset to Y to scroll the wave pattern
|
|
202
551
|
v_displacement_amount = cnoise( vec3(
|
|
203
552
|
u_wave_frequency_x * position.x + u_time,
|
|
204
|
-
u_wave_frequency_y * position.y + u_time,
|
|
553
|
+
u_wave_frequency_y * (position.y + waveOffset) + u_time,
|
|
205
554
|
u_time
|
|
206
555
|
));
|
|
207
|
-
|
|
208
|
-
vec3 color;
|
|
209
556
|
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
557
|
+
// 2. FLOW FIELD
|
|
558
|
+
// Apply flow offset to scroll the flow field mask
|
|
559
|
+
vec2 baseUv = vUv;
|
|
560
|
+
baseUv.y += flowOffset / u_plane_height; // Scale to match wave speed
|
|
561
|
+
vec2 flowUv = baseUv;
|
|
562
|
+
|
|
563
|
+
if (u_flow_enabled > 0.5) {
|
|
564
|
+
if (u_flow_ease > 0.0 || u_flow_distortion_a > 0.0) {
|
|
565
|
+
vec2 ppp = -1.0 + 2.0 * baseUv;
|
|
566
|
+
ppp += 0.1 * cos((1.5 * u_flow_scale) * ppp.yx + 1.1 * u_time + vec2(0.1, 1.1));
|
|
567
|
+
ppp += 0.1 * cos((2.3 * u_flow_scale) * ppp.yx + 1.3 * u_time + vec2(3.2, 3.4));
|
|
568
|
+
ppp += 0.1 * cos((2.2 * u_flow_scale) * ppp.yx + 1.7 * u_time + vec2(1.8, 5.2));
|
|
569
|
+
ppp += u_flow_distortion_a * cos((u_flow_distortion_b * u_flow_scale) * ppp.yx + 1.4 * u_time + vec2(6.3, 3.9));
|
|
570
|
+
|
|
571
|
+
float r = length(ppp);
|
|
572
|
+
flowUv = mix(baseUv, vec2(baseUv.x * (1.0 - u_flow_ease) + r * u_flow_ease, baseUv.y), u_flow_ease);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// Pass the standard flow UV to fragment shader (for mouse/texture)
|
|
577
|
+
vFlowUv = flowUv;
|
|
578
|
+
|
|
579
|
+
// 3. COLOR MIXING
|
|
580
|
+
// We take the computed flow UVs and apply the color offset
|
|
581
|
+
// Scale by plane height to match wave offset speed (world space vs UV space)
|
|
582
|
+
vec3 color = u_colors[0].color;
|
|
583
|
+
vec2 adjustedUv = flowUv;
|
|
584
|
+
adjustedUv.y += colorOffset / u_plane_height; // Scroll the color mixing pattern
|
|
585
|
+
|
|
586
|
+
vec2 noise_cord = adjustedUv * u_color_pressure;
|
|
215
587
|
const float minNoise = .0;
|
|
216
588
|
const float maxNoise = .9;
|
|
217
|
-
|
|
589
|
+
|
|
218
590
|
for (int i = 1; i < u_colors_count; i++) {
|
|
219
|
-
|
|
220
|
-
if(u_colors[i].is_active == 1.0){
|
|
591
|
+
if(u_colors[i].is_active > 0.5){
|
|
221
592
|
float noiseFlow = (1. + float(i)) / 30.;
|
|
222
593
|
float noiseSpeed = (1. + float(i)) * 0.11;
|
|
223
594
|
float noiseSeed = 13. + float(i) * 7.;
|
|
224
|
-
|
|
225
|
-
int reverseIndex = u_colors_count - i;
|
|
226
|
-
|
|
595
|
+
|
|
227
596
|
float noise = snoise(
|
|
228
597
|
vec3(
|
|
229
598
|
noise_cord.x * u_color_pressure.x + u_time * noiseFlow * 2.,
|
|
@@ -231,30 +600,22 @@ void main() {
|
|
|
231
600
|
u_time * noiseSpeed
|
|
232
601
|
) + noiseSeed
|
|
233
602
|
) - (.1 * float(i)) + (.5 * u_color_blending);
|
|
234
|
-
|
|
603
|
+
|
|
235
604
|
noise = clamp(minNoise, maxNoise + float(i) * 0.02, noise);
|
|
236
|
-
|
|
237
|
-
color = mix(color, nextColor, smoothstep(0.0, u_color_blending, noise));
|
|
238
|
-
|
|
239
|
-
// vec3 colorOklab = oklab2rgb(color);
|
|
240
|
-
// vec3 nextColorOklab = oklab2rgb(nextColor);
|
|
241
|
-
// vec3 mixColor = mix(colorOklab, nextColorOklab, smoothstep(0.0, u_color_blending, noise));
|
|
242
|
-
// color = rgb2oklab(mixColor);
|
|
243
|
-
|
|
605
|
+
color = mix(color, u_colors[i].color, smoothstep(0.0, u_color_blending, noise));
|
|
244
606
|
}
|
|
245
|
-
|
|
246
607
|
}
|
|
247
|
-
|
|
608
|
+
|
|
248
609
|
v_color = color;
|
|
249
|
-
|
|
610
|
+
|
|
611
|
+
// 4. VERTEX POSITION
|
|
250
612
|
vec3 newPosition = position + normal * v_displacement_amount * u_wave_amplitude;
|
|
251
|
-
gl_Position = projectionMatrix * modelViewMatrix * vec4(
|
|
252
|
-
|
|
613
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0);
|
|
253
614
|
v_new_position = gl_Position;
|
|
254
615
|
}
|
|
255
616
|
`;
|
|
256
617
|
}
|
|
257
|
-
function
|
|
618
|
+
function me() {
|
|
258
619
|
return `
|
|
259
620
|
float random(vec2 p) {
|
|
260
621
|
return fract(sin(dot(p, vec2(12.9898,78.233))) * 43758.5453);
|
|
@@ -264,7 +625,6 @@ float fbm(vec3 x) {
|
|
|
264
625
|
float value = 0.0;
|
|
265
626
|
float amplitude = 0.5;
|
|
266
627
|
float frequency = 1.0;
|
|
267
|
-
|
|
268
628
|
for (int i = 0; i < 4; i++) {
|
|
269
629
|
value += amplitude * snoise(x * frequency);
|
|
270
630
|
frequency *= 2.0;
|
|
@@ -272,37 +632,75 @@ float fbm(vec3 x) {
|
|
|
272
632
|
}
|
|
273
633
|
return value;
|
|
274
634
|
}
|
|
635
|
+
|
|
636
|
+
void main() {
|
|
637
|
+
// MOUSE DISTORTION
|
|
638
|
+
vec2 finalUv = vFlowUv;
|
|
275
639
|
|
|
276
|
-
|
|
277
|
-
|
|
640
|
+
if (u_mouse_distortion_strength > 0.0) {
|
|
641
|
+
vec4 mouseColor = texture2D(u_mouse_texture, vUv);
|
|
642
|
+
float mouseValue = mouseColor.r;
|
|
643
|
+
|
|
644
|
+
if (mouseValue > 0.001) {
|
|
645
|
+
float distortionAmount = mouseValue * u_mouse_distortion_strength;
|
|
646
|
+
vec2 mouseDisp = vec2(distortionAmount, distortionAmount);
|
|
647
|
+
finalUv -= mouseDisp;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
278
650
|
|
|
651
|
+
vec3 baseColor;
|
|
652
|
+
|
|
653
|
+
if (u_enable_procedural_texture > 0.5) {
|
|
654
|
+
// Calculate flow field distance for ease effect
|
|
655
|
+
vec2 ppp = -1.0 + 2.0 * finalUv;
|
|
656
|
+
ppp += 0.1 * cos((1.5 * u_flow_scale) * ppp.yx + 1.1 * u_time + vec2(0.1, 1.1));
|
|
657
|
+
ppp += 0.1 * cos((2.3 * u_flow_scale) * ppp.yx + 1.3 * u_time + vec2(3.2, 3.4));
|
|
658
|
+
ppp += 0.1 * cos((2.2 * u_flow_scale) * ppp.yx + 1.7 * u_time + vec2(1.8, 5.2));
|
|
659
|
+
ppp += u_flow_distortion_a * cos((u_flow_distortion_b * u_flow_scale) * ppp.yx + 1.4 * u_time + vec2(6.3, 3.9));
|
|
660
|
+
float r = length(ppp); // Flow distance
|
|
661
|
+
|
|
662
|
+
// Ease blending: 0 = topographic (flow), 1 = image (UV)
|
|
663
|
+
float vx = (finalUv.x * u_texture_ease) + (r * (1.0 - u_texture_ease));
|
|
664
|
+
float vy = (finalUv.y * u_texture_ease) + (0.0 * (1.0 - u_texture_ease));
|
|
665
|
+
vec2 texUv = vec2(vx, vy);
|
|
666
|
+
|
|
667
|
+
// PARALLAX SCROLLING
|
|
668
|
+
// We manually apply a smaller offset here to make the texture lag behind
|
|
669
|
+
float parallaxFactor = 0.25; // 25% speed of the color mixing
|
|
670
|
+
texUv.y -= (u_y_offset * u_y_offset_color_multiplier / u_plane_height) * parallaxFactor;
|
|
671
|
+
|
|
672
|
+
texUv *= 1.5; // Tiling scale
|
|
673
|
+
|
|
674
|
+
vec4 texSample = texture2D(u_procedural_texture, texUv);
|
|
675
|
+
baseColor = texSample.rgb;
|
|
676
|
+
} else {
|
|
677
|
+
baseColor = v_color;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
vec3 color = baseColor;
|
|
681
|
+
|
|
682
|
+
// Post-processing
|
|
279
683
|
color += pow(v_displacement_amount, 1.0) * u_highlights;
|
|
280
684
|
color -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;
|
|
281
685
|
color = saturation(color, 1.0 + u_saturation);
|
|
282
686
|
color = color * u_brightness;
|
|
283
|
-
|
|
284
|
-
// Generate grain using fbm
|
|
285
|
-
vec2 noiseCoords = gl_FragCoord.xy / u_grain_scale;
|
|
286
687
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
688
|
+
// Grain
|
|
689
|
+
vec2 noiseCoords = gl_FragCoord.xy / u_grain_scale;
|
|
690
|
+
float grain = (u_grain_speed != 0.0) ? fbm(vec3(noiseCoords, u_time * u_grain_speed)) : fbm(vec3(noiseCoords, 0.0));
|
|
290
691
|
|
|
291
|
-
// Center the grain around zero
|
|
292
692
|
grain = grain * 0.5 + 0.5;
|
|
293
693
|
grain -= 0.5;
|
|
294
|
-
|
|
295
|
-
// Apply grain intensity
|
|
694
|
+
grain = (grain > u_grain_sparsity) ? grain : 0.0;
|
|
296
695
|
grain *= u_grain_intensity;
|
|
297
696
|
|
|
298
|
-
// Add grain to color
|
|
299
697
|
color += vec3(grain);
|
|
300
|
-
|
|
301
|
-
gl_FragColor = vec4(color,1.0);
|
|
698
|
+
|
|
699
|
+
gl_FragColor = vec4(color, 1.0);
|
|
302
700
|
}
|
|
303
|
-
`;
|
|
701
|
+
`;
|
|
304
702
|
}
|
|
305
|
-
const
|
|
703
|
+
const V = () => `
|
|
306
704
|
precision highp float;
|
|
307
705
|
|
|
308
706
|
struct Color {
|
|
@@ -312,6 +710,7 @@ struct Color {
|
|
|
312
710
|
};
|
|
313
711
|
|
|
314
712
|
uniform float u_grain_intensity;
|
|
713
|
+
uniform float u_grain_sparsity;
|
|
315
714
|
uniform float u_grain_scale;
|
|
316
715
|
uniform float u_grain_speed;
|
|
317
716
|
uniform float u_time;
|
|
@@ -333,79 +732,89 @@ uniform float u_brightness;
|
|
|
333
732
|
uniform float u_color_blending;
|
|
334
733
|
|
|
335
734
|
uniform int u_colors_count;
|
|
336
|
-
uniform Color u_colors[
|
|
735
|
+
uniform Color u_colors[6];
|
|
337
736
|
uniform vec2 u_resolution;
|
|
338
737
|
|
|
738
|
+
uniform float u_y_offset;
|
|
739
|
+
uniform float u_y_offset_wave_multiplier;
|
|
740
|
+
uniform float u_y_offset_color_multiplier;
|
|
741
|
+
uniform float u_y_offset_flow_multiplier;
|
|
742
|
+
|
|
743
|
+
// Flow field uniforms
|
|
744
|
+
uniform float u_flow_distortion_a;
|
|
745
|
+
uniform float u_flow_distortion_b;
|
|
746
|
+
uniform float u_flow_scale;
|
|
747
|
+
uniform float u_flow_ease;
|
|
748
|
+
uniform float u_flow_enabled;
|
|
749
|
+
|
|
750
|
+
// Mouse interaction uniforms
|
|
751
|
+
uniform float u_mouse_distortion_strength;
|
|
752
|
+
uniform float u_mouse_distortion_radius;
|
|
753
|
+
uniform float u_mouse_darken;
|
|
754
|
+
uniform sampler2D u_mouse_texture;
|
|
755
|
+
|
|
756
|
+
// Procedural texture uniforms
|
|
757
|
+
uniform sampler2D u_procedural_texture;
|
|
758
|
+
uniform float u_enable_procedural_texture;
|
|
759
|
+
uniform float u_texture_ease;
|
|
760
|
+
|
|
339
761
|
varying vec2 vUv;
|
|
762
|
+
varying vec2 vFlowUv;
|
|
340
763
|
varying vec4 v_new_position;
|
|
341
764
|
varying vec3 v_color;
|
|
342
765
|
varying float v_displacement_amount;
|
|
343
766
|
|
|
344
|
-
`,
|
|
345
|
-
|
|
346
|
-
vec3 mod289(vec3 x)
|
|
347
|
-
{
|
|
348
|
-
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
vec4 mod289(vec4 x)
|
|
352
|
-
{
|
|
353
|
-
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
|
354
|
-
}
|
|
767
|
+
`, L = () => `
|
|
355
768
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
769
|
+
// 1. REPLACEMENT PERMUTE:
|
|
770
|
+
// Uses a hash function (fract/sin) instead of a modular lookup table.
|
|
771
|
+
vec4 permute(vec4 x) {
|
|
772
|
+
return floor(fract(sin(x) * 43758.5453123) * 289.0);
|
|
359
773
|
}
|
|
360
774
|
|
|
361
|
-
|
|
362
|
-
{
|
|
775
|
+
// Taylor Inverse Sqrt
|
|
776
|
+
vec4 taylorInvSqrt(vec4 r) {
|
|
363
777
|
return 1.79284291400159 - 0.85373472095314 * r;
|
|
364
778
|
}
|
|
365
779
|
|
|
780
|
+
// Fade function
|
|
366
781
|
vec3 fade(vec3 t) {
|
|
367
782
|
return t*t*t*(t*(t*6.0-15.0)+10.0);
|
|
368
783
|
}
|
|
369
784
|
|
|
370
|
-
|
|
371
|
-
{
|
|
785
|
+
// 3D Simplex Noise
|
|
786
|
+
float snoise(vec3 v) {
|
|
372
787
|
const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
|
|
373
788
|
const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
|
|
374
789
|
|
|
375
|
-
// First corner
|
|
790
|
+
// First corner
|
|
376
791
|
vec3 i = floor(v + dot(v, C.yyy) );
|
|
377
792
|
vec3 x0 = v - i + dot(i, C.xxx) ;
|
|
378
793
|
|
|
379
|
-
// Other corners
|
|
794
|
+
// Other corners
|
|
380
795
|
vec3 g = step(x0.yzx, x0.xyz);
|
|
381
796
|
vec3 l = 1.0 - g;
|
|
382
797
|
vec3 i1 = min( g.xyz, l.zxy );
|
|
383
798
|
vec3 i2 = max( g.xyz, l.zxy );
|
|
384
799
|
|
|
385
|
-
// x0 = x0 - 0.0 + 0.0 * C.xxx;
|
|
386
|
-
// x1 = x0 - i1 + 1.0 * C.xxx;
|
|
387
|
-
// x2 = x0 - i2 + 2.0 * C.xxx;
|
|
388
|
-
// x3 = x0 - 1.0 + 3.0 * C.xxx;
|
|
389
800
|
vec3 x1 = x0 - i1 + C.xxx;
|
|
390
|
-
vec3 x2 = x0 - i2 + C.yyy;
|
|
391
|
-
vec3 x3 = x0 - D.yyy;
|
|
801
|
+
vec3 x2 = x0 - i2 + C.yyy;
|
|
802
|
+
vec3 x3 = x0 - D.yyy;
|
|
392
803
|
|
|
393
|
-
// Permutations
|
|
394
|
-
i = mod289(i);
|
|
804
|
+
// Permutations
|
|
395
805
|
vec4 p = permute( permute( permute(
|
|
396
806
|
i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
|
|
397
807
|
+ i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
|
|
398
808
|
+ i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
|
|
399
809
|
|
|
400
|
-
// Gradients
|
|
401
|
-
// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
|
|
810
|
+
// Gradients
|
|
402
811
|
float n_ = 0.142857142857; // 1.0/7.0
|
|
403
812
|
vec3 ns = n_ * D.wyz - D.xzx;
|
|
404
813
|
|
|
405
|
-
vec4 j = p - 49.0 * floor(p * ns.z * ns.z);
|
|
814
|
+
vec4 j = p - 49.0 * floor(p * ns.z * ns.z);
|
|
406
815
|
|
|
407
816
|
vec4 x_ = floor(j * ns.z);
|
|
408
|
-
vec4 y_ = floor(j - 7.0 * x_ );
|
|
817
|
+
vec4 y_ = floor(j - 7.0 * x_ );
|
|
409
818
|
|
|
410
819
|
vec4 x = x_ *ns.x + ns.yyyy;
|
|
411
820
|
vec4 y = y_ *ns.x + ns.yyyy;
|
|
@@ -414,8 +823,6 @@ float snoise(vec3 v)
|
|
|
414
823
|
vec4 b0 = vec4( x.xy, y.xy );
|
|
415
824
|
vec4 b1 = vec4( x.zw, y.zw );
|
|
416
825
|
|
|
417
|
-
//vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;
|
|
418
|
-
//vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;
|
|
419
826
|
vec4 s0 = floor(b0)*2.0 + 1.0;
|
|
420
827
|
vec4 s1 = floor(b1)*2.0 + 1.0;
|
|
421
828
|
vec4 sh = -step(h, vec4(0.0));
|
|
@@ -428,14 +835,14 @@ float snoise(vec3 v)
|
|
|
428
835
|
vec3 p2 = vec3(a1.xy,h.z);
|
|
429
836
|
vec3 p3 = vec3(a1.zw,h.w);
|
|
430
837
|
|
|
431
|
-
//Normalise gradients
|
|
838
|
+
// Normalise gradients
|
|
432
839
|
vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
|
|
433
840
|
p0 *= norm.x;
|
|
434
841
|
p1 *= norm.y;
|
|
435
842
|
p2 *= norm.z;
|
|
436
843
|
p3 *= norm.w;
|
|
437
844
|
|
|
438
|
-
// Mix final noise value
|
|
845
|
+
// Mix final noise value
|
|
439
846
|
vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
|
|
440
847
|
m = m * m;
|
|
441
848
|
return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
|
|
@@ -445,12 +852,11 @@ float snoise(vec3 v)
|
|
|
445
852
|
// Classic Perlin noise
|
|
446
853
|
float cnoise(vec3 P)
|
|
447
854
|
{
|
|
448
|
-
vec3 Pi0 = floor(P);
|
|
449
|
-
vec3 Pi1 = Pi0 + vec3(1.0);
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
vec3
|
|
453
|
-
vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
|
|
855
|
+
vec3 Pi0 = floor(P);
|
|
856
|
+
vec3 Pi1 = Pi0 + vec3(1.0);
|
|
857
|
+
|
|
858
|
+
vec3 Pf0 = fract(P);
|
|
859
|
+
vec3 Pf1 = Pf0 - vec3(1.0);
|
|
454
860
|
vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
|
|
455
861
|
vec4 iy = vec4(Pi0.yy, Pi1.yy);
|
|
456
862
|
vec4 iz0 = Pi0.zzzz;
|
|
@@ -511,47 +917,7 @@ float cnoise(vec3 P)
|
|
|
511
917
|
float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
|
|
512
918
|
return 2.2 * n_xyz;
|
|
513
919
|
}
|
|
514
|
-
|
|
515
|
-
// YUV to RGB matrix
|
|
516
|
-
mat3 yuv2rgb = mat3(1.0, 0.0, 1.13983,
|
|
517
|
-
1.0, -0.39465, -0.58060,
|
|
518
|
-
1.0, 2.03211, 0.0);
|
|
519
|
-
|
|
520
|
-
// RGB to YUV matrix
|
|
521
|
-
mat3 rgb2yuv = mat3(0.2126, 0.7152, 0.0722,
|
|
522
|
-
-0.09991, -0.33609, 0.43600,
|
|
523
|
-
0.615, -0.5586, -0.05639);
|
|
524
|
-
|
|
525
|
-
vec3 oklab2rgb(vec3 linear)
|
|
526
|
-
{
|
|
527
|
-
const mat3 im1 = mat3(0.4121656120, 0.2118591070, 0.0883097947,
|
|
528
|
-
0.5362752080, 0.6807189584, 0.2818474174,
|
|
529
|
-
0.0514575653, 0.1074065790, 0.6302613616);
|
|
530
|
-
|
|
531
|
-
const mat3 im2 = mat3(+0.2104542553, +1.9779984951, +0.0259040371,
|
|
532
|
-
+0.7936177850, -2.4285922050, +0.7827717662,
|
|
533
|
-
-0.0040720468, +0.4505937099, -0.8086757660);
|
|
534
|
-
|
|
535
|
-
vec3 lms = im1 * linear;
|
|
536
|
-
|
|
537
|
-
return im2 * (sign(lms) * pow(abs(lms), vec3(1.0/3.0)));
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
vec3 rgb2oklab(vec3 oklab)
|
|
541
|
-
{
|
|
542
|
-
const mat3 m1 = mat3(+1.000000000, +1.000000000, +1.000000000,
|
|
543
|
-
+0.396337777, -0.105561346, -0.089484178,
|
|
544
|
-
+0.215803757, -0.063854173, -1.291485548);
|
|
545
|
-
|
|
546
|
-
const mat3 m2 = mat3(+4.076724529, -1.268143773, -0.004111989,
|
|
547
|
-
-3.307216883, +2.609332323, -0.703476310,
|
|
548
|
-
+0.230759054, -0.341134429, +1.706862569);
|
|
549
|
-
vec3 lms = m1 * oklab;
|
|
550
|
-
|
|
551
|
-
return m2 * (lms * lms * lms);
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
`, k = () => `
|
|
920
|
+
`, N = () => `
|
|
555
921
|
|
|
556
922
|
vec3 saturation(vec3 rgb, float adjustment) {
|
|
557
923
|
const vec3 W = vec3(0.2125, 0.7154, 0.0721);
|
|
@@ -594,34 +960,36 @@ vec3 hsv2rgb(vec3 c)
|
|
|
594
960
|
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
|
595
961
|
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
|
596
962
|
}
|
|
597
|
-
`,
|
|
598
|
-
|
|
599
|
-
},
|
|
600
|
-
const e =
|
|
963
|
+
`, j = (r) => {
|
|
964
|
+
r.id = G, r.href = "https://neat.firecms.co", r.target = "_blank", r.style.position = "absolute", r.style.display = "block", r.style.bottom = "0", r.style.right = "0", r.style.padding = "10px", r.style.color = "#dcdcdc", r.style.opacity = "0.8", r.style.fontFamily = "sans-serif", r.style.fontSize = "16px", r.style.fontWeight = "bold", r.style.textDecoration = "none", r.style.zIndex = "10000", r.innerHTML = "NEAT";
|
|
965
|
+
}, ye = (r) => {
|
|
966
|
+
const e = r.parentElement?.getElementsByTagName("a");
|
|
601
967
|
if (e) {
|
|
602
|
-
for (let
|
|
603
|
-
if (e[
|
|
604
|
-
|
|
605
|
-
return;
|
|
606
|
-
}
|
|
968
|
+
for (let t = 0; t < e.length; t++)
|
|
969
|
+
if (e[t].id === G)
|
|
970
|
+
return j(e[t]), e[t];
|
|
607
971
|
}
|
|
608
972
|
const o = document.createElement("a");
|
|
609
|
-
|
|
973
|
+
return j(o), r.parentElement?.appendChild(o), o;
|
|
610
974
|
};
|
|
611
|
-
function
|
|
612
|
-
const
|
|
975
|
+
function we() {
|
|
976
|
+
const r = new Date(), e = r.getMinutes(), o = r.getSeconds();
|
|
613
977
|
return e * 60 + o;
|
|
614
978
|
}
|
|
615
|
-
function
|
|
979
|
+
function be(r = 6) {
|
|
616
980
|
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
617
981
|
let o = "";
|
|
618
|
-
for (let
|
|
619
|
-
const
|
|
620
|
-
o += e.charAt(
|
|
982
|
+
for (let t = 0; t < r; t++) {
|
|
983
|
+
const f = Math.floor(Math.random() * e.length);
|
|
984
|
+
o += e.charAt(f);
|
|
621
985
|
}
|
|
622
986
|
return o;
|
|
623
987
|
}
|
|
988
|
+
function Se(r, e) {
|
|
989
|
+
const o = document.createElement("a");
|
|
990
|
+
o.download = e, o.href = r, document.body.appendChild(o), o.click(), document.body.removeChild(o);
|
|
991
|
+
}
|
|
624
992
|
export {
|
|
625
|
-
|
|
993
|
+
ze as NeatGradient
|
|
626
994
|
};
|
|
627
995
|
//# sourceMappingURL=index.es.js.map
|