@firecms/neat 0.4.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/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
- import * as i from "three";
2
- const _ = 50, g = 80, W = !0, S = 5, X = new i.Clock(), R = ee();
3
- class oe {
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;
@@ -21,72 +21,144 @@ class oe {
21
21
  _wireframe = !1;
22
22
  _backgroundColor = "#FFFFFF";
23
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;
24
54
  requestRef = -1;
25
55
  sizeObserver;
26
56
  sceneState;
57
+ _cachedUniforms = null;
58
+ _linkElement = null;
27
59
  _yOffset = 0;
60
+ _yOffsetWaveMultiplier = 4e-3;
61
+ _yOffsetColorMultiplier = 4e-3;
62
+ _yOffsetFlowMultiplier = 4e-3;
63
+ _tempClearColor = new l.Color();
28
64
  constructor(e) {
29
65
  const {
30
66
  ref: o,
31
- speed: n = 4,
32
- horizontalPressure: s = 3,
33
- verticalPressure: a = 3,
34
- waveFrequencyX: c = 5,
35
- waveFrequencyY: v = 5,
36
- waveAmplitude: f = 3,
37
- colors: l,
38
- highlights: u = 4,
39
- shadows: h = 4,
40
- colorSaturation: p = 0,
41
- colorBrightness: w = 1,
42
- colorBlending: z = 5,
43
- grainScale: E = 2,
44
- grainIntensity: B = 0.55,
45
- grainSparsity: D = 0,
46
- grainSpeed: k = 0.1,
47
- wireframe: K = !1,
48
- backgroundColor: L = "#FFFFFF",
49
- backgroundAlpha: U = 1,
50
- resolution: V = 1,
51
- seed: C,
52
- yOffset: G = 0
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
53
114
  } = e;
54
- this._ref = o, this.destroy = this.destroy.bind(this), this._initScene = this._initScene.bind(this), this._buildMaterial = this._buildMaterial.bind(this), this.speed = n, this.horizontalPressure = s, this.verticalPressure = a, this.waveFrequencyX = c, this.waveFrequencyY = v, this.waveAmplitude = f, this.colorBlending = z, this.grainScale = E, this.grainIntensity = B, this.grainSparsity = D, this.grainSpeed = k, this.colors = l, this.shadows = h, this.highlights = u, this.colorSaturation = p, this.colorBrightness = w, this.wireframe = K, this.backgroundColor = L, this.backgroundAlpha = U, this.yOffset = G, this.sceneState = this._initScene(V);
55
- let b = C !== void 0 ? C : $();
56
- const q = () => {
57
- const { renderer: d, camera: m, scene: y, meshes: x } = this.sceneState;
58
- Math.floor(b * 10) % 5 === 0 && Z(o), d.setClearColor(this._backgroundColor, this._backgroundAlpha), x.forEach((r) => {
59
- const j = this._ref.width, Y = this._ref.height, H = [
60
- ...this._colors.map((P) => {
61
- let F = new i.Color();
62
- return F.setStyle(P.color, ""), {
63
- is_active: P.enabled,
64
- color: F,
65
- influence: P.influence
66
- };
67
- }),
68
- ...Array.from({ length: S - this._colors.length }).map(() => ({
69
- is_active: !1,
70
- color: new i.Color(0)
71
- }))
72
- ];
73
- b += X.getDelta() * this._speed, r.material.uniforms.u_time.value = b, r.material.uniforms.u_resolution = { value: new i.Vector2(j, Y) }, r.material.uniforms.u_color_pressure = { value: new i.Vector2(this._horizontalPressure, this._verticalPressure) }, r.material.uniforms.u_wave_frequency_x = { value: this._waveFrequencyX }, r.material.uniforms.u_wave_frequency_y = { value: this._waveFrequencyY }, r.material.uniforms.u_wave_amplitude = { value: this._waveAmplitude }, r.material.uniforms.u_plane_width = { value: _ }, r.material.uniforms.u_plane_height = { value: g }, r.material.uniforms.u_color_blending = { value: this._colorBlending }, r.material.uniforms.u_colors = { value: H }, r.material.uniforms.u_colors_count = { value: S }, r.material.uniforms.u_shadows = { value: this._shadows }, r.material.uniforms.u_highlights = { value: this._highlights }, r.material.uniforms.u_saturation = { value: this._saturation }, r.material.uniforms.u_brightness = { value: this._brightness }, r.material.uniforms.u_grain_intensity = { value: this._grainIntensity }, r.material.uniforms.u_grain_sparsity = { value: this._grainSparsity }, r.material.uniforms.u_grain_speed = { value: this._grainSpeed }, r.material.uniforms.u_grain_scale = { value: this._grainScale }, r.material.uniforms.u_y_offset = { value: this._yOffset }, r.material.wireframe = this._wireframe;
74
- }), d.render(y, m), this.requestRef = requestAnimationFrame(q);
75
- }, T = () => {
76
- const { renderer: d } = this.sceneState, m = d.domElement, y = m.clientWidth, x = m.clientHeight;
77
- this.sceneState.renderer.setSize(y, x, !1), A(this.sceneState.camera, y, x);
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
+ }
78
148
  };
79
- this.sizeObserver = new ResizeObserver((d) => {
80
- T();
81
- }), this.sizeObserver.observe(o), q();
149
+ this.sizeObserver = new ResizeObserver((g) => {
150
+ ve();
151
+ }), this.sizeObserver.observe(o), I();
82
152
  }
83
153
  destroy() {
84
- 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());
85
157
  }
86
158
  downloadAsPNG(e = "neat.png") {
87
159
  console.log("Downloading as PNG", this._ref);
88
160
  const o = this._ref.toDataURL("image/png");
89
- console.log("data", o), te(o, e);
161
+ console.log("data", o), Se(o, e);
90
162
  }
91
163
  set speed(e) {
92
164
  this._speed = e / 20;
@@ -151,101 +223,376 @@ class oe {
151
223
  set yOffset(e) {
152
224
  this._yOffset = e;
153
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
+ }
154
319
  _initScene(e) {
155
- const o = this._ref.width, n = this._ref.height, s = new i.WebGLRenderer({
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({
156
325
  alpha: !0,
157
326
  preserveDrawingBuffer: !0,
158
327
  canvas: this._ref
159
328
  });
160
- s.setClearColor(16711680, 0.5), s.setSize(o, n, !1);
161
- const a = [], c = new i.Scene(), v = this._buildMaterial(o, n), f = new i.PlaneGeometry(_, g, 240 * e, 240 * e), l = new i.Mesh(f, v);
162
- l.rotation.x = -Math.PI / 3.5, l.position.z = -1, a.push(l), c.add(l);
163
- const u = new i.OrthographicCamera(0, 0, 0, 0, 0, 0);
164
- return u.position.z = 5, A(u, o, n), {
165
- renderer: s,
166
- camera: u,
167
- scene: c,
168
- meshes: a,
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,
169
338
  resolution: e
170
339
  };
171
340
  }
172
341
  _buildMaterial(e, o) {
173
- const n = [
174
- ...this._colors.map((c) => ({
175
- is_active: c.enabled,
176
- color: new i.Color(c.color),
177
- influence: c.influence
178
- })),
179
- ...Array.from({ length: S - this._colors.length }).map(() => ({
180
- is_active: !1,
181
- color: new i.Color(0)
182
- }))
183
- ], 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 = {
184
347
  u_time: { value: 0 },
185
- u_color_pressure: { value: new i.Vector2(this._horizontalPressure, this._verticalPressure) },
348
+ u_color_pressure: { value: new l.Vector2(this._horizontalPressure, this._verticalPressure) },
186
349
  u_wave_frequency_x: { value: this._waveFrequencyX },
187
350
  u_wave_frequency_y: { value: this._waveFrequencyY },
188
351
  u_wave_amplitude: { value: this._waveAmplitude },
189
- u_resolution: { value: new i.Vector2(e, o) },
190
- u_colors: { value: n },
352
+ u_resolution: { value: new l.Vector2(e, o) },
353
+ u_colors: { value: t },
191
354
  u_colors_count: { value: this._colors.length },
192
- u_plane_width: { value: _ },
193
- u_plane_height: { value: g },
355
+ u_plane_width: { value: D },
356
+ u_plane_height: { value: E },
194
357
  u_shadows: { value: this._shadows },
195
358
  u_highlights: { value: this._highlights },
196
359
  u_grain_intensity: { value: this._grainIntensity },
197
360
  u_grain_sparsity: { value: this._grainSparsity },
198
361
  u_grain_scale: { value: this._grainScale },
199
- u_grain_speed: { value: this._grainSpeed }
200
- }, a = new i.ShaderMaterial({
201
- uniforms: s,
202
- vertexShader: I() + M() + O() + J(),
203
- fragmentShader: I() + O() + M() + Q()
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()
204
386
  });
205
- return a.wireframe = W, a;
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;
206
532
  }
207
533
  }
208
- function A(t, e, o) {
209
- const a = e * o / 1e6 * _ * g / 1.5, c = e / o, v = Math.sqrt(a * c), f = a / v, l = -_ / 2, u = Math.min((l + v) / 1.5, _ / 2), h = g / 4, p = Math.max((h - f) / 2, -g / 4), w = -100, z = 1e3;
210
- t instanceof i.OrthographicCamera ? (t.left = l, t.right = u, t.top = h, t.bottom = p, t.near = w, t.far = z, t.updateProjectionMatrix()) : t instanceof i.PerspectiveCamera && (t.aspect = e / o, t.updateProjectionMatrix());
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());
211
537
  }
212
- function J() {
538
+ function ge() {
213
539
  return `
214
-
215
540
  void main() {
216
-
217
541
  vUv = uv;
218
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
219
551
  v_displacement_amount = cnoise( vec3(
220
552
  u_wave_frequency_x * position.x + u_time,
221
- u_wave_frequency_y * position.y + u_time,
553
+ u_wave_frequency_y * (position.y + waveOffset) + u_time,
222
554
  u_time
223
555
  ));
224
556
 
225
- vec3 color;
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
+ }
226
575
 
227
- // float t = mod(u_base_color, 100.0);
228
- color = u_colors[0].color;
576
+ // Pass the standard flow UV to fragment shader (for mouse/texture)
577
+ vFlowUv = flowUv;
229
578
 
230
- // Apply y_offset to the noise coordinates
231
- vec2 noise_cord = vUv * u_color_pressure;
232
- // Apply the y-offset to shift the pattern vertically (1:1 pixel ratio)
233
- // Scale the offset to match the UV coordinate space
234
- float scaledOffset = u_y_offset / u_resolution.y;
235
- noise_cord.y -= scaledOffset;
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
236
585
 
586
+ vec2 noise_cord = adjustedUv * u_color_pressure;
237
587
  const float minNoise = .0;
238
588
  const float maxNoise = .9;
239
589
 
240
590
  for (int i = 1; i < u_colors_count; i++) {
241
-
242
- if(u_colors[i].is_active == 1.0){
591
+ if(u_colors[i].is_active > 0.5){
243
592
  float noiseFlow = (1. + float(i)) / 30.;
244
593
  float noiseSpeed = (1. + float(i)) * 0.11;
245
594
  float noiseSeed = 13. + float(i) * 7.;
246
595
 
247
- int reverseIndex = u_colors_count - i;
248
-
249
596
  float noise = snoise(
250
597
  vec3(
251
598
  noise_cord.x * u_color_pressure.x + u_time * noiseFlow * 2.,
@@ -255,21 +602,20 @@ void main() {
255
602
  ) - (.1 * float(i)) + (.5 * u_color_blending);
256
603
 
257
604
  noise = clamp(minNoise, maxNoise + float(i) * 0.02, noise);
258
- vec3 nextColor = u_colors[i].color;
259
- color = mix(color, nextColor, smoothstep(0.0, u_color_blending, noise));
605
+ color = mix(color, u_colors[i].color, smoothstep(0.0, u_color_blending, noise));
260
606
  }
261
607
  }
262
608
 
263
609
  v_color = color;
264
610
 
611
+ // 4. VERTEX POSITION
265
612
  vec3 newPosition = position + normal * v_displacement_amount * u_wave_amplitude;
266
613
  gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0);
267
-
268
614
  v_new_position = gl_Position;
269
615
  }
270
616
  `;
271
617
  }
272
- function Q() {
618
+ function me() {
273
619
  return `
274
620
  float random(vec2 p) {
275
621
  return fract(sin(dot(p, vec2(12.9898,78.233))) * 43758.5453);
@@ -288,34 +634,73 @@ float fbm(vec3 x) {
288
634
  }
289
635
 
290
636
  void main() {
291
- vec3 color = v_color;
637
+ // MOUSE DISTORTION
638
+ vec2 finalUv = vFlowUv;
639
+
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
+ }
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
292
683
  color += pow(v_displacement_amount, 1.0) * u_highlights;
293
684
  color -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;
294
685
  color = saturation(color, 1.0 + u_saturation);
295
686
  color = color * u_brightness;
296
687
 
297
- // Generate grain using fbm
688
+ // Grain
298
689
  vec2 noiseCoords = gl_FragCoord.xy / u_grain_scale;
299
690
  float grain = (u_grain_speed != 0.0) ? fbm(vec3(noiseCoords, u_time * u_grain_speed)) : fbm(vec3(noiseCoords, 0.0));
300
691
 
301
- // Center the grain around zero
302
692
  grain = grain * 0.5 + 0.5;
303
693
  grain -= 0.5;
304
-
305
- // Add sparsity control
306
694
  grain = (grain > u_grain_sparsity) ? grain : 0.0;
307
-
308
- // Apply grain intensity
309
695
  grain *= u_grain_intensity;
310
696
 
311
- // Add grain to color
312
697
  color += vec3(grain);
313
698
 
314
699
  gl_FragColor = vec4(color, 1.0);
315
700
  }
316
701
  `;
317
702
  }
318
- const I = () => `
703
+ const V = () => `
319
704
  precision highp float;
320
705
 
321
706
  struct Color {
@@ -347,81 +732,89 @@ uniform float u_brightness;
347
732
  uniform float u_color_blending;
348
733
 
349
734
  uniform int u_colors_count;
350
- uniform Color u_colors[5];
735
+ uniform Color u_colors[6];
351
736
  uniform vec2 u_resolution;
352
737
 
353
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;
354
760
 
355
761
  varying vec2 vUv;
762
+ varying vec2 vFlowUv;
356
763
  varying vec4 v_new_position;
357
764
  varying vec3 v_color;
358
765
  varying float v_displacement_amount;
359
766
 
360
- `, M = () => `
767
+ `, L = () => `
361
768
 
362
- vec3 mod289(vec3 x)
363
- {
364
- return x - floor(x * (1.0 / 289.0)) * 289.0;
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);
365
773
  }
366
774
 
367
- vec4 mod289(vec4 x)
368
- {
369
- return x - floor(x * (1.0 / 289.0)) * 289.0;
370
- }
371
-
372
- vec4 permute(vec4 x)
373
- {
374
- return mod289(((x*34.0)+1.0)*x);
375
- }
376
-
377
- vec4 taylorInvSqrt(vec4 r)
378
- {
775
+ // Taylor Inverse Sqrt
776
+ vec4 taylorInvSqrt(vec4 r) {
379
777
  return 1.79284291400159 - 0.85373472095314 * r;
380
778
  }
381
779
 
780
+ // Fade function
382
781
  vec3 fade(vec3 t) {
383
782
  return t*t*t*(t*(t*6.0-15.0)+10.0);
384
783
  }
385
784
 
386
- float snoise(vec3 v)
387
- {
785
+ // 3D Simplex Noise
786
+ float snoise(vec3 v) {
388
787
  const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;
389
788
  const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);
390
789
 
391
- // First corner
790
+ // First corner
392
791
  vec3 i = floor(v + dot(v, C.yyy) );
393
792
  vec3 x0 = v - i + dot(i, C.xxx) ;
394
793
 
395
- // Other corners
794
+ // Other corners
396
795
  vec3 g = step(x0.yzx, x0.xyz);
397
796
  vec3 l = 1.0 - g;
398
797
  vec3 i1 = min( g.xyz, l.zxy );
399
798
  vec3 i2 = max( g.xyz, l.zxy );
400
799
 
401
- // x0 = x0 - 0.0 + 0.0 * C.xxx;
402
- // x1 = x0 - i1 + 1.0 * C.xxx;
403
- // x2 = x0 - i2 + 2.0 * C.xxx;
404
- // x3 = x0 - 1.0 + 3.0 * C.xxx;
405
800
  vec3 x1 = x0 - i1 + C.xxx;
406
- vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y
407
- vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y
801
+ vec3 x2 = x0 - i2 + C.yyy;
802
+ vec3 x3 = x0 - D.yyy;
408
803
 
409
- // Permutations
410
- i = mod289(i);
804
+ // Permutations
411
805
  vec4 p = permute( permute( permute(
412
806
  i.z + vec4(0.0, i1.z, i2.z, 1.0 ))
413
807
  + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))
414
808
  + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));
415
809
 
416
- // Gradients: 7x7 points over a square, mapped onto an octahedron.
417
- // The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)
810
+ // Gradients
418
811
  float n_ = 0.142857142857; // 1.0/7.0
419
812
  vec3 ns = n_ * D.wyz - D.xzx;
420
813
 
421
- vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)
814
+ vec4 j = p - 49.0 * floor(p * ns.z * ns.z);
422
815
 
423
816
  vec4 x_ = floor(j * ns.z);
424
- vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)
817
+ vec4 y_ = floor(j - 7.0 * x_ );
425
818
 
426
819
  vec4 x = x_ *ns.x + ns.yyyy;
427
820
  vec4 y = y_ *ns.x + ns.yyyy;
@@ -430,8 +823,6 @@ float snoise(vec3 v)
430
823
  vec4 b0 = vec4( x.xy, y.xy );
431
824
  vec4 b1 = vec4( x.zw, y.zw );
432
825
 
433
- //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;
434
- //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;
435
826
  vec4 s0 = floor(b0)*2.0 + 1.0;
436
827
  vec4 s1 = floor(b1)*2.0 + 1.0;
437
828
  vec4 sh = -step(h, vec4(0.0));
@@ -444,14 +835,14 @@ float snoise(vec3 v)
444
835
  vec3 p2 = vec3(a1.xy,h.z);
445
836
  vec3 p3 = vec3(a1.zw,h.w);
446
837
 
447
- //Normalise gradients
838
+ // Normalise gradients
448
839
  vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));
449
840
  p0 *= norm.x;
450
841
  p1 *= norm.y;
451
842
  p2 *= norm.z;
452
843
  p3 *= norm.w;
453
844
 
454
- // Mix final noise value
845
+ // Mix final noise value
455
846
  vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
456
847
  m = m * m;
457
848
  return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
@@ -461,12 +852,11 @@ float snoise(vec3 v)
461
852
  // Classic Perlin noise
462
853
  float cnoise(vec3 P)
463
854
  {
464
- vec3 Pi0 = floor(P); // Integer part for indexing
465
- vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1
466
- Pi0 = mod289(Pi0);
467
- Pi1 = mod289(Pi1);
468
- vec3 Pf0 = fract(P); // Fractional part for interpolation
469
- 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);
470
860
  vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
471
861
  vec4 iy = vec4(Pi0.yy, Pi1.yy);
472
862
  vec4 iz0 = Pi0.zzzz;
@@ -527,47 +917,7 @@ float cnoise(vec3 P)
527
917
  float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
528
918
  return 2.2 * n_xyz;
529
919
  }
530
-
531
- // YUV to RGB matrix
532
- mat3 yuv2rgb = mat3(1.0, 0.0, 1.13983,
533
- 1.0, -0.39465, -0.58060,
534
- 1.0, 2.03211, 0.0);
535
-
536
- // RGB to YUV matrix
537
- mat3 rgb2yuv = mat3(0.2126, 0.7152, 0.0722,
538
- -0.09991, -0.33609, 0.43600,
539
- 0.615, -0.5586, -0.05639);
540
-
541
- vec3 oklab2rgb(vec3 linear)
542
- {
543
- const mat3 im1 = mat3(0.4121656120, 0.2118591070, 0.0883097947,
544
- 0.5362752080, 0.6807189584, 0.2818474174,
545
- 0.0514575653, 0.1074065790, 0.6302613616);
546
-
547
- const mat3 im2 = mat3(+0.2104542553, +1.9779984951, +0.0259040371,
548
- +0.7936177850, -2.4285922050, +0.7827717662,
549
- -0.0040720468, +0.4505937099, -0.8086757660);
550
-
551
- vec3 lms = im1 * linear;
552
-
553
- return im2 * (sign(lms) * pow(abs(lms), vec3(1.0/3.0)));
554
- }
555
-
556
- vec3 rgb2oklab(vec3 oklab)
557
- {
558
- const mat3 m1 = mat3(+1.000000000, +1.000000000, +1.000000000,
559
- +0.396337777, -0.105561346, -0.089484178,
560
- +0.215803757, -0.063854173, -1.291485548);
561
-
562
- const mat3 m2 = mat3(+4.076724529, -1.268143773, -0.004111989,
563
- -3.307216883, +2.609332323, -0.703476310,
564
- +0.230759054, -0.341134429, +1.706862569);
565
- vec3 lms = m1 * oklab;
566
-
567
- return m2 * (lms * lms * lms);
568
- }
569
-
570
- `, O = () => `
920
+ `, N = () => `
571
921
 
572
922
  vec3 saturation(vec3 rgb, float adjustment) {
573
923
  const vec3 W = vec3(0.2125, 0.7154, 0.0721);
@@ -610,38 +960,36 @@ vec3 hsv2rgb(vec3 c)
610
960
  vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
611
961
  return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
612
962
  }
613
- `, N = (t) => {
614
- t.id = R, t.href = "https://neat.firecms.co", t.target = "_blank", t.style.position = "absolute", t.style.display = "block", t.style.bottom = "0", t.style.right = "0", t.style.padding = "10px", t.style.color = "#dcdcdc", t.style.opacity = "0.8", t.style.fontFamily = "sans-serif", t.style.fontSize = "16px", t.style.fontWeight = "bold", t.style.textDecoration = "none", t.style.zIndex = "10000", t.innerHTML = "NEAT";
615
- }, Z = (t) => {
616
- const e = t.parentElement?.getElementsByTagName("a");
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");
617
967
  if (e) {
618
- for (let n = 0; n < e.length; n++)
619
- if (e[n].id === R) {
620
- N(e[n]);
621
- return;
622
- }
968
+ for (let t = 0; t < e.length; t++)
969
+ if (e[t].id === G)
970
+ return j(e[t]), e[t];
623
971
  }
624
972
  const o = document.createElement("a");
625
- N(o), t.parentElement?.appendChild(o);
973
+ return j(o), r.parentElement?.appendChild(o), o;
626
974
  };
627
- function $() {
628
- const t = new Date(), e = t.getMinutes(), o = t.getSeconds();
975
+ function we() {
976
+ const r = new Date(), e = r.getMinutes(), o = r.getSeconds();
629
977
  return e * 60 + o;
630
978
  }
631
- function ee(t = 6) {
979
+ function be(r = 6) {
632
980
  const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
633
981
  let o = "";
634
- for (let n = 0; n < t; n++) {
635
- const s = Math.floor(Math.random() * e.length);
636
- o += e.charAt(s);
982
+ for (let t = 0; t < r; t++) {
983
+ const f = Math.floor(Math.random() * e.length);
984
+ o += e.charAt(f);
637
985
  }
638
986
  return o;
639
987
  }
640
- function te(t, e) {
988
+ function Se(r, e) {
641
989
  const o = document.createElement("a");
642
- o.download = e, o.href = t, document.body.appendChild(o), o.click(), document.body.removeChild(o);
990
+ o.download = e, o.href = r, document.body.appendChild(o), o.click(), document.body.removeChild(o);
643
991
  }
644
992
  export {
645
- oe as NeatGradient
993
+ ze as NeatGradient
646
994
  };
647
995
  //# sourceMappingURL=index.es.js.map