@firecms/neat 0.7.1 → 0.8.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,4 +1,4 @@
1
- const he = `void main() {
1
+ const Ce = `void main() {
2
2
  vUv = uv;
3
3
 
4
4
  // SCROLLING LOGIC
@@ -72,12 +72,15 @@ const he = `void main() {
72
72
 
73
73
  v_color = color;
74
74
 
75
- // 4. VERTEX POSITION
75
+ // 4. FRESNEL (rim glow)
76
+ // (Calculated in fragment shader using displacement slope approximation)
77
+
78
+ // 5. VERTEX POSITION
76
79
  vec3 newPosition = position + normal * v_displacement_amount * u_wave_amplitude;
77
80
  gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0);
78
81
  v_new_position = gl_Position;
79
82
  }
80
- `, de = `float random(vec2 p) {
83
+ `, Pe = `float random(vec2 p) {
81
84
  return fract(sin(dot(p, vec2(12.9898,78.233))) * 43758.5453);
82
85
  }
83
86
 
@@ -93,31 +96,32 @@ float fbm(vec3 x) {
93
96
  return value;
94
97
  }
95
98
 
99
+ // Branchless HSL to RGB for iridescence
100
+ vec3 hsl2rgb(float h, float s, float l) {
101
+ vec3 rgb = clamp(abs(mod(h * 6.0 + vec3(0.0, 4.0, 2.0), 6.0) - 3.0) - 1.0, 0.0, 1.0);
102
+ return l + s * (rgb - 0.5) * (1.0 - abs(2.0 * l - 1.0));
103
+ }
104
+
96
105
  void main() {
97
106
  vec2 finalUv = vFlowUv;
98
107
 
99
108
  vec3 baseColor;
100
109
 
101
110
  if (u_enable_procedural_texture > 0.5) {
102
- // Calculate flow field distance for ease effect
103
111
  vec2 ppp = -1.0 + 2.0 * finalUv;
104
112
  ppp += 0.1 * cos((1.5 * u_flow_scale) * ppp.yx + 1.1 * u_time + vec2(0.1, 1.1));
105
113
  ppp += 0.1 * cos((2.3 * u_flow_scale) * ppp.yx + 1.3 * u_time + vec2(3.2, 3.4));
106
114
  ppp += 0.1 * cos((2.2 * u_flow_scale) * ppp.yx + 1.7 * u_time + vec2(1.8, 5.2));
107
115
  ppp += u_flow_distortion_a * cos((u_flow_distortion_b * u_flow_scale) * ppp.yx + 1.4 * u_time + vec2(6.3, 3.9));
108
- float r = length(ppp); // Flow distance
116
+ float r = length(ppp);
109
117
 
110
- // Ease blending: 0 = topographic (flow), 1 = image (UV)
111
118
  float vx = (finalUv.x * u_texture_ease) + (r * (1.0 - u_texture_ease));
112
119
  float vy = (finalUv.y * u_texture_ease) + (0.0 * (1.0 - u_texture_ease));
113
120
  vec2 texUv = vec2(vx, vy);
114
121
 
115
- // PARALLAX SCROLLING
116
- // We manually apply a smaller offset here to make the texture lag behind
117
- float parallaxFactor = 0.25; // 25% speed of the color mixing
122
+ float parallaxFactor = 0.25;
118
123
  texUv.y -= (u_y_offset * u_y_offset_color_multiplier / u_plane_height) * parallaxFactor;
119
-
120
- texUv *= 1.5; // Tiling scale
124
+ texUv *= 1.5;
121
125
 
122
126
  vec4 texSample = texture2D(u_procedural_texture, texUv);
123
127
  baseColor = texSample.rgb;
@@ -127,24 +131,70 @@ void main() {
127
131
 
128
132
  vec3 color = baseColor;
129
133
 
134
+ // === DOMAIN WARPING (simplified: 3 fbm calls instead of 5) ===
135
+ if (u_domain_warp_enabled > 0.5) {
136
+ vec3 p = vec3(finalUv * u_domain_warp_scale, u_time * 0.15);
137
+ vec2 q = vec2(fbm(p), fbm(p + vec3(5.2, 1.3, 0.0)));
138
+ float f = fbm(p + vec3(4.0 * q, 0.0));
139
+ vec3 warpColor = color * (1.0 + f * 0.8 * u_domain_warp_intensity);
140
+ float pattern = clamp(f * f * f + 0.6 * f * f + 0.5 * f, 0.0, 1.0);
141
+ color = mix(color, warpColor * (0.6 + pattern * 0.8), u_domain_warp_intensity * 0.7);
142
+ }
143
+
130
144
  // Post-processing
131
145
  color += v_displacement_amount * u_highlights;
132
- // Replace pow() with direct multiplication to avoid negative base undefined behavior in GLSL
133
146
  float shadowFactor = 1.0 - v_displacement_amount;
134
147
  color -= shadowFactor * shadowFactor * u_shadows;
135
148
  color = saturation(color, 1.0 + u_saturation);
136
149
  color = color * u_brightness;
137
150
 
138
- // Grain
139
- vec2 noiseCoords = gl_FragCoord.xy / u_grain_scale;
151
+ // === IRIDESCENCE ===
152
+ if (u_iridescence_enabled > 0.5) {
153
+ float hue = fract(v_displacement_amount * 0.5 + 0.5 + u_time * u_iridescence_speed * 0.05);
154
+ vec3 iriColor = hsl2rgb(hue, 0.8, 0.6);
155
+ color = mix(color, iriColor, u_iridescence_intensity * abs(v_displacement_amount) * 0.6);
156
+ }
157
+
158
+ // === FRESNEL (Rim glow) ===
159
+ if (u_fresnel_enabled > 0.5) {
160
+ float slope = 1.0 - abs(v_displacement_amount);
161
+ float fresnel = pow(max(slope, 0.0), u_fresnel_power);
162
+ color += u_fresnel_color * fresnel * u_fresnel_intensity;
163
+ }
164
+
165
+ // === VIGNETTE ===
166
+ if (u_vignette_intensity > 0.0) {
167
+ float dist = length(vUv - vec2(0.5));
168
+ float vig = smoothstep(u_vignette_radius, u_vignette_radius * 0.3, dist);
169
+ color *= mix(1.0, vig, u_vignette_intensity);
170
+ }
171
+
172
+ // === FAKE BLOOM ===
173
+ if (u_bloom_intensity > 0.0) {
174
+ float luma = dot(color, vec3(0.2126, 0.7152, 0.0722));
175
+ float bloomMask = smoothstep(u_bloom_threshold, 1.0, luma);
176
+ color += color * bloomMask * u_bloom_intensity;
177
+ }
178
+
179
+ // === CHROMATIC ABERRATION ===
180
+ if (u_chromatic_aberration > 0.0) {
181
+ float caAmount = u_chromatic_aberration * 0.008;
182
+ float dist = length(vUv - vec2(0.5));
183
+ float rShift = v_displacement_amount + caAmount * dist;
184
+ float bShift = v_displacement_amount - caAmount * dist;
185
+ color.r *= 1.0 + rShift * caAmount * 10.0;
186
+ color.b *= 1.0 - bShift * caAmount * 10.0;
187
+ }
188
+
189
+ // Grain (use cheap hash noise instead of expensive fbm when static)
140
190
  float grain = 0.0;
141
-
142
- // Completely bypass expensive noise generation if grain is disabled
143
191
  if (u_grain_intensity > 0.0) {
192
+ vec2 noiseCoords = gl_FragCoord.xy / u_grain_scale;
144
193
  if (u_grain_speed != 0.0) {
145
194
  grain = fbm(vec3(noiseCoords, u_time * u_grain_speed));
146
195
  } else {
147
- grain = fbm(vec3(noiseCoords, 0.0));
196
+ // Static grain: use cheap hash instead of fbm
197
+ grain = random(noiseCoords) - 0.5;
148
198
  }
149
199
 
150
200
  grain = grain * 0.5 + 0.5;
@@ -158,7 +208,7 @@ void main() {
158
208
  gl_FragColor = vec4(color, 1.0);
159
209
  }
160
210
  `;
161
- function me() {
211
+ function De() {
162
212
  return `precision highp float;
163
213
 
164
214
  attribute vec3 position;
@@ -203,9 +253,15 @@ uniform float u_flow_distortion_b;
203
253
  uniform float u_flow_scale;
204
254
  uniform float u_flow_ease;
205
255
  uniform float u_flow_enabled;
256
+
257
+ // Fresnel uniforms
258
+ uniform float u_fresnel_enabled;
259
+ uniform float u_fresnel_power;
260
+ uniform float u_fresnel_intensity;
261
+ uniform vec3 u_fresnel_color;
206
262
  `;
207
263
  }
208
- function pe() {
264
+ function ze() {
209
265
  return `precision highp float;
210
266
 
211
267
  varying vec2 vUv;
@@ -214,6 +270,7 @@ varying vec3 v_color;
214
270
  varying float v_displacement_amount;
215
271
 
216
272
  uniform float u_time;
273
+ uniform vec2 u_resolution;
217
274
  uniform float u_plane_height;
218
275
 
219
276
  uniform float u_shadows;
@@ -237,6 +294,35 @@ uniform float u_flow_scale;
237
294
  uniform sampler2D u_procedural_texture;
238
295
  uniform float u_enable_procedural_texture;
239
296
  uniform float u_texture_ease;
297
+
298
+ // Domain warping uniforms
299
+ uniform float u_domain_warp_enabled;
300
+ uniform float u_domain_warp_intensity;
301
+ uniform float u_domain_warp_scale;
302
+
303
+ // Vignette uniforms
304
+ uniform float u_vignette_intensity;
305
+ uniform float u_vignette_radius;
306
+
307
+ // Fresnel uniforms (fragment side)
308
+ uniform float u_fresnel_enabled;
309
+ uniform float u_fresnel_power;
310
+ uniform float u_fresnel_intensity;
311
+ uniform vec3 u_fresnel_color;
312
+
313
+
314
+
315
+ // Iridescence uniforms
316
+ uniform float u_iridescence_enabled;
317
+ uniform float u_iridescence_intensity;
318
+ uniform float u_iridescence_speed;
319
+
320
+ // Bloom uniforms
321
+ uniform float u_bloom_intensity;
322
+ uniform float u_bloom_threshold;
323
+
324
+ // Chromatic aberration
325
+ uniform float u_chromatic_aberration;
240
326
  `;
241
327
  }
242
328
  function Y() {
@@ -425,15 +511,15 @@ class J {
425
511
  1
426
512
  ]);
427
513
  }
428
- translate(e, i, o) {
429
- return this.elements[12] += this.elements[0] * e + this.elements[4] * i + this.elements[8] * o, this.elements[13] += this.elements[1] * e + this.elements[5] * i + this.elements[9] * o, this.elements[14] += this.elements[2] * e + this.elements[6] * i + this.elements[10] * o, this.elements[15] += this.elements[3] * e + this.elements[7] * i + this.elements[11] * o, this;
514
+ translate(e, r, s) {
515
+ return this.elements[12] += this.elements[0] * e + this.elements[4] * r + this.elements[8] * s, this.elements[13] += this.elements[1] * e + this.elements[5] * r + this.elements[9] * s, this.elements[14] += this.elements[2] * e + this.elements[6] * r + this.elements[10] * s, this.elements[15] += this.elements[3] * e + this.elements[7] * r + this.elements[11] * s, this;
430
516
  }
431
517
  rotateX(e) {
432
- const i = Math.cos(e), o = Math.sin(e), t = this.elements[4], b = this.elements[5], y = this.elements[6], n = this.elements[7], p = this.elements[8], v = this.elements[9], T = this.elements[10], x = this.elements[11];
433
- return this.elements[4] = i * t + o * p, this.elements[5] = i * b + o * v, this.elements[6] = i * y + o * T, this.elements[7] = i * n + o * x, this.elements[8] = i * p - o * t, this.elements[9] = i * v - o * b, this.elements[10] = i * T - o * y, this.elements[11] = i * x - o * n, this;
518
+ const r = Math.cos(e), s = Math.sin(e), t = this.elements[4], S = this.elements[5], y = this.elements[6], a = this.elements[7], p = this.elements[8], v = this.elements[9], T = this.elements[10], x = this.elements[11];
519
+ return this.elements[4] = r * t + s * p, this.elements[5] = r * S + s * v, this.elements[6] = r * y + s * T, this.elements[7] = r * a + s * x, this.elements[8] = r * p - s * t, this.elements[9] = r * v - s * S, this.elements[10] = r * T - s * y, this.elements[11] = r * x - s * a, this;
434
520
  }
435
521
  }
436
- class ge {
522
+ class Fe {
437
523
  left;
438
524
  right;
439
525
  top;
@@ -442,63 +528,63 @@ class ge {
442
528
  far;
443
529
  position;
444
530
  projectionMatrix;
445
- constructor(e, i, o, t, b, y) {
446
- this.left = e, this.right = i, this.top = o, this.bottom = t, this.near = b, this.far = y, this.position = [0, 0, 0], this.projectionMatrix = new J(), this.updateProjectionMatrix();
531
+ constructor(e, r, s, t, S, y) {
532
+ this.left = e, this.right = r, this.top = s, this.bottom = t, this.near = S, this.far = y, this.position = [0, 0, 0], this.projectionMatrix = new J(), this.updateProjectionMatrix();
447
533
  }
448
534
  updateProjectionMatrix() {
449
- const e = 1 / (this.right - this.left), i = 1 / (this.top - this.bottom), o = 1 / (this.far - this.near), t = (this.right + this.left) * e, b = (this.top + this.bottom) * i, y = (this.far + this.near) * o;
535
+ const e = 1 / (this.right - this.left), r = 1 / (this.top - this.bottom), s = 1 / (this.far - this.near), t = (this.right + this.left) * e, S = (this.top + this.bottom) * r, y = (this.far + this.near) * s;
450
536
  this.projectionMatrix.elements = new Float32Array([
451
537
  2 * e,
452
538
  0,
453
539
  0,
454
540
  0,
455
541
  0,
456
- 2 * i,
542
+ 2 * r,
457
543
  0,
458
544
  0,
459
545
  0,
460
546
  0,
461
- -2 * o,
547
+ -2 * s,
462
548
  0,
463
549
  -t,
464
- -b,
550
+ -S,
465
551
  -y,
466
552
  1
467
553
  ]);
468
554
  }
469
555
  }
470
- function H(a, e, i, o = 50, t = 50) {
471
- const n = e * i / 1e6 * o * t / 1.5, p = e / i, v = Math.sqrt(n * p), T = n / v;
472
- let x = -o / 2, h = Math.min((x + v) / 1.5, o / 2), w = t / 4, R = Math.max((w - T) / 2, -t / 4);
556
+ function H(l, e, r, s = 50, t = 50) {
557
+ const a = e * r / 1e6 * s * t / 1.5, p = e / r, v = Math.sqrt(a * p), T = a / v;
558
+ let x = -s / 2, h = Math.min((x + v) / 1.5, s / 2), b = t / 4, R = Math.max((b - T) / 2, -t / 4);
473
559
  if (p < 1) {
474
560
  const E = p;
475
561
  x = x * E, h = h * E;
476
562
  const g = 1.05;
477
- x = x * g, h = h * g, w = w * g, R = R * g;
563
+ x = x * g, h = h * g, b = b * g, R = R * g;
478
564
  }
479
- a.left = x, a.right = h, a.top = w, a.bottom = R, a.near = -100, a.far = 1e3, a.updateProjectionMatrix();
565
+ l.left = x, l.right = h, l.top = b, l.bottom = R, l.near = -100, l.far = 1e3, l.updateProjectionMatrix();
480
566
  }
481
- function xe(a, e, i, o) {
482
- const t = a / 2, b = e / 2, y = Math.floor(i), n = Math.floor(o), p = y + 1, v = n + 1, T = a / y, x = e / n, h = [], w = [], R = [], E = [];
483
- for (let c = 0; c < v; c++) {
484
- const l = c * x - b;
567
+ function Ie(l, e, r, s) {
568
+ const t = l / 2, S = e / 2, y = Math.floor(r), a = Math.floor(s), p = y + 1, v = a + 1, T = l / y, x = e / a, h = [], b = [], R = [], E = [];
569
+ for (let _ = 0; _ < v; _++) {
570
+ const u = _ * x - S;
485
571
  for (let m = 0; m < p; m++) {
486
- const s = m * T - t;
487
- w.push(s, -l, 0), R.push(0, 0, 1), E.push(m / y), E.push(1 - c / n);
572
+ const n = m * T - t;
573
+ b.push(n, -u, 0), R.push(0, 0, 1), E.push(m / y), E.push(1 - _ / a);
488
574
  }
489
575
  }
490
- for (let c = 0; c < n; c++)
491
- for (let l = 0; l < y; l++) {
492
- const m = l + p * c, s = l + p * (c + 1), f = l + 1 + p * (c + 1), _ = l + 1 + p * c;
493
- h.push(m, s, _), h.push(s, f, _);
576
+ for (let _ = 0; _ < a; _++)
577
+ for (let u = 0; u < y; u++) {
578
+ const m = u + p * _, n = u + p * (_ + 1), f = u + 1 + p * (_ + 1), c = u + 1 + p * _;
579
+ h.push(m, n, c), h.push(n, f, c);
494
580
  }
495
- const g = w.length / 3 > 65535, A = [];
496
- for (let c = 0; c < h.length; c += 3) {
497
- const l = h[c], m = h[c + 1], s = h[c + 2];
498
- A.push(l, m, m, s, s, l);
581
+ const g = b.length / 3 > 65535, A = [];
582
+ for (let _ = 0; _ < h.length; _ += 3) {
583
+ const u = h[_], m = h[_ + 1], n = h[_ + 2];
584
+ A.push(u, m, m, n, n, u);
499
585
  }
500
586
  return {
501
- position: new Float32Array(w),
587
+ position: new Float32Array(b),
502
588
  normal: new Float32Array(R),
503
589
  uv: new Float32Array(E),
504
590
  index: g ? new Uint32Array(h) : new Uint16Array(h),
@@ -515,8 +601,8 @@ https://neat.firecms.co`,
515
601
  "font-weight: bold; font-size: 14px; color: #FF5772;",
516
602
  "color: inherit;"
517
603
  );
518
- const $ = 50, K = 80, O = 6, ye = Se();
519
- class Te {
604
+ const $ = 50, K = 80, O = 6, Me = Le();
605
+ class We {
520
606
  _ref;
521
607
  _speed = -1;
522
608
  _horizontalPressure = -1;
@@ -552,6 +638,22 @@ class Te {
552
638
  _textureColorBlending = 0.01;
553
639
  _textureSeed = 333;
554
640
  _textureEase = 0.5;
641
+ _domainWarpEnabled = !1;
642
+ _domainWarpIntensity = 0.5;
643
+ _domainWarpScale = 1;
644
+ _vignetteIntensity = 0.5;
645
+ _vignetteRadius = 0.8;
646
+ _fresnelEnabled = !1;
647
+ _fresnelPower = 2;
648
+ _fresnelIntensity = 0.5;
649
+ _fresnelColor = "#FFFFFF";
650
+ _fresnelColorRgb = [1, 1, 1];
651
+ _iridescenceEnabled = !1;
652
+ _iridescenceIntensity = 0.5;
653
+ _iridescenceSpeed = 1;
654
+ _bloomIntensity = 0;
655
+ _bloomThreshold = 0.7;
656
+ _chromaticAberration = 0;
555
657
  _proceduralTexture = null;
556
658
  _proceduralBackgroundColor = "#000000";
557
659
  _textureShapeTriangles = 20;
@@ -575,38 +677,38 @@ class Te {
575
677
  _textureDirty = !0;
576
678
  constructor(e) {
577
679
  const {
578
- ref: i,
579
- speed: o = 4,
680
+ ref: r,
681
+ speed: s = 4,
580
682
  horizontalPressure: t = 3,
581
- verticalPressure: b = 3,
683
+ verticalPressure: S = 3,
582
684
  waveFrequencyX: y = 5,
583
- waveFrequencyY: n = 5,
685
+ waveFrequencyY: a = 5,
584
686
  waveAmplitude: p = 3,
585
687
  colors: v,
586
688
  highlights: T = 4,
587
689
  shadows: x = 4,
588
690
  colorSaturation: h = 0,
589
- colorBrightness: w = 1,
691
+ colorBrightness: b = 1,
590
692
  colorBlending: R = 5,
591
693
  grainScale: E = 2,
592
694
  grainIntensity: g = 0.55,
593
695
  grainSparsity: A = 0,
594
- grainSpeed: c = 0.1,
595
- wireframe: l = !1,
696
+ grainSpeed: _ = 0.1,
697
+ wireframe: u = !1,
596
698
  backgroundColor: m = "#FFFFFF",
597
- backgroundAlpha: s = 1,
699
+ backgroundAlpha: n = 1,
598
700
  resolution: f = 1,
599
- seed: _,
701
+ seed: c,
600
702
  yOffset: d = 0,
601
- yOffsetWaveMultiplier: z = 4,
602
- yOffsetColorMultiplier: C = 4,
703
+ yOffsetWaveMultiplier: C = 4,
704
+ yOffsetColorMultiplier: D = 4,
603
705
  yOffsetFlowMultiplier: F = 4,
604
- flowDistortionA: M = 0,
706
+ flowDistortionA: I = 0,
605
707
  flowDistortionB: N = 0,
606
708
  flowScale: W = 1,
607
- flowEase: D = 0,
608
- flowEnabled: S = !0,
609
- enableProceduralTexture: U = !1,
709
+ flowEase: z = 0,
710
+ flowEnabled: w = !0,
711
+ enableProceduralTexture: M = !1,
610
712
  textureVoidLikelihood: Q = 0.45,
611
713
  textureVoidWidthMin: ee = 200,
612
714
  textureVoidWidthMax: te = 486,
@@ -618,42 +720,57 @@ class Te {
618
720
  textureShapeTriangles: ae = 20,
619
721
  textureShapeCircles: le = 15,
620
722
  textureShapeBars: ue = 15,
621
- textureShapeSquiggles: fe = 10
723
+ textureShapeSquiggles: fe = 10,
724
+ domainWarpEnabled: _e = !1,
725
+ domainWarpIntensity: ce = 0.5,
726
+ domainWarpScale: he = 1,
727
+ vignetteIntensity: de = 0.5,
728
+ vignetteRadius: me = 0.8,
729
+ fresnelEnabled: pe = !1,
730
+ fresnelPower: ge = 2,
731
+ fresnelIntensity: xe = 0.5,
732
+ fresnelColor: ye = "#FFFFFF",
733
+ iridescenceEnabled: ve = !1,
734
+ iridescenceIntensity: be = 0.5,
735
+ iridescenceSpeed: we = 1,
736
+ bloomIntensity: Se = 0,
737
+ bloomThreshold: Ee = 0.7,
738
+ chromaticAberration: Te = 0
622
739
  } = e;
623
- this._ref = i, this.destroy = this.destroy.bind(this), this._initScene = this._initScene.bind(this), this.speed = o, this.horizontalPressure = t, this.verticalPressure = b, this.waveFrequencyX = y, this.waveFrequencyY = n, this.waveAmplitude = p, this.colorBlending = R, this.grainScale = E, this.grainIntensity = g, this.grainSparsity = A, this.grainSpeed = c, this.colors = v, this.shadows = x, this.highlights = T, this.colorSaturation = h, this.colorBrightness = w, this.wireframe = l, this.backgroundColor = m, this.backgroundAlpha = s, this.yOffset = d, this.yOffsetWaveMultiplier = z, this.yOffsetColorMultiplier = C, this.yOffsetFlowMultiplier = F, this.flowDistortionA = M, this.flowDistortionB = N, this.flowScale = W, this.flowEase = D, this.flowEnabled = S, this.enableProceduralTexture = U, this.textureVoidLikelihood = Q, this.textureVoidWidthMin = ee, this.textureVoidWidthMax = te, this.textureBandDensity = ie, this.textureColorBlending = re, this.textureSeed = oe, this.textureEase = se, this._proceduralBackgroundColor = ne, this._textureShapeTriangles = ae, this._textureShapeCircles = le, this._textureShapeBars = ue, this._textureShapeSquiggles = fe, this.glState = this._initScene(f), Ee();
624
- let k = _ !== void 0 ? _ : we(), X = performance.now();
625
- const q = () => {
626
- const { gl: r, program: I, locations: u, indexCount: B, indexType: L } = this.glState;
627
- if (this._linkCheckCounter++, this._linkCheckCounter >= 300 && (this._linkCheckCounter = 0, (!this._linkElement || !document.contains(this._linkElement)) && (this._linkElement = ve(i))), this._initialized) {
628
- const V = performance.now();
629
- if (k += (V - X) / 1e3 * this._speed, X = V, r.useProgram(I), r.uniform1f(u.uniforms.u_time, k), this._uniformsDirty && (r.uniform2f(u.uniforms.u_resolution, this._ref.clientWidth, this._ref.clientHeight), r.uniform2f(u.uniforms.u_color_pressure, this._horizontalPressure, this._verticalPressure), r.uniform1f(u.uniforms.u_wave_frequency_x, this._waveFrequencyX), r.uniform1f(u.uniforms.u_wave_frequency_y, this._waveFrequencyY), r.uniform1f(u.uniforms.u_wave_amplitude, this._waveAmplitude), r.uniform1f(u.uniforms.u_color_blending, this._colorBlending), r.uniform1f(u.uniforms.u_shadows, this._shadows), r.uniform1f(u.uniforms.u_highlights, this._highlights), r.uniform1f(u.uniforms.u_saturation, this._saturation), r.uniform1f(u.uniforms.u_brightness, this._brightness), r.uniform1f(u.uniforms.u_grain_intensity, this._grainIntensity), r.uniform1f(u.uniforms.u_grain_sparsity, this._grainSparsity), r.uniform1f(u.uniforms.u_grain_speed, this._grainSpeed), r.uniform1f(u.uniforms.u_grain_scale, this._grainScale), r.uniform1f(u.uniforms.u_y_offset, this._yOffset), r.uniform1f(u.uniforms.u_y_offset_wave_multiplier, this._yOffsetWaveMultiplier), r.uniform1f(u.uniforms.u_y_offset_color_multiplier, this._yOffsetColorMultiplier), r.uniform1f(u.uniforms.u_y_offset_flow_multiplier, this._yOffsetFlowMultiplier), r.uniform1f(u.uniforms.u_flow_distortion_a, this._flowDistortionA), r.uniform1f(u.uniforms.u_flow_distortion_b, this._flowDistortionB), r.uniform1f(u.uniforms.u_flow_scale, this._flowScale), r.uniform1f(u.uniforms.u_flow_ease, this._flowEase), r.uniform1f(u.uniforms.u_flow_enabled, this._flowEnabled ? 1 : 0), r.uniform1f(u.uniforms.u_enable_procedural_texture, this._enableProceduralTexture ? 1 : 0), r.uniform1f(u.uniforms.u_texture_ease, this._textureEase), this._uniformsDirty = !1), this._textureNeedsUpdate && this._enableProceduralTexture && (this._proceduralTexture && r.deleteTexture(this._proceduralTexture), this._proceduralTexture = this._createProceduralTexture(r), this._textureNeedsUpdate = !1, this._textureDirty = !0), this._textureDirty && this._proceduralTexture && (r.activeTexture(r.TEXTURE1), r.bindTexture(r.TEXTURE_2D, this._proceduralTexture), r.uniform1i(u.uniforms.u_procedural_texture, 1), this._textureDirty = !1), this._colorsChanged) {
740
+ this._ref = r, this.destroy = this.destroy.bind(this), this._initScene = this._initScene.bind(this), this.speed = s, this.horizontalPressure = t, this.verticalPressure = S, this.waveFrequencyX = y, this.waveFrequencyY = a, this.waveAmplitude = p, this.colorBlending = R, this.grainScale = E, this.grainIntensity = g, this.grainSparsity = A, this.grainSpeed = _, this.colors = v, this.shadows = x, this.highlights = T, this.colorSaturation = h, this.colorBrightness = b, this.wireframe = u, this.backgroundColor = m, this.backgroundAlpha = n, this.yOffset = d, this.yOffsetWaveMultiplier = C, this.yOffsetColorMultiplier = D, this.yOffsetFlowMultiplier = F, this.flowDistortionA = I, this.flowDistortionB = N, this.flowScale = W, this.flowEase = z, this.flowEnabled = w, this.enableProceduralTexture = M, this.textureVoidLikelihood = Q, this.textureVoidWidthMin = ee, this.textureVoidWidthMax = te, this.textureBandDensity = ie, this.textureColorBlending = re, this.textureSeed = oe, this.textureEase = se, this._proceduralBackgroundColor = ne, this._textureShapeTriangles = ae, this._textureShapeCircles = le, this._textureShapeBars = ue, this._textureShapeSquiggles = fe, this.domainWarpEnabled = _e, this.domainWarpIntensity = ce, this.domainWarpScale = he, this.vignetteIntensity = de, this.vignetteRadius = me, this.fresnelEnabled = pe, this.fresnelPower = ge, this.fresnelIntensity = xe, this.fresnelColor = ye, this.iridescenceEnabled = ve, this.iridescenceIntensity = be, this.iridescenceSpeed = we, this.bloomIntensity = Se, this.bloomThreshold = Ee, this.chromaticAberration = Te, this.glState = this._initScene(f), Ne();
741
+ let k = c !== void 0 ? c : Be(), q = performance.now();
742
+ const V = () => {
743
+ const { gl: i, program: B, locations: o, indexCount: U, indexType: L } = this.glState;
744
+ if (this._linkCheckCounter++, this._linkCheckCounter >= 300 && (this._linkCheckCounter = 0, (!this._linkElement || !document.contains(this._linkElement)) && (this._linkElement = Ue(r))), this._initialized) {
745
+ const X = performance.now();
746
+ if (k += (X - q) / 1e3 * this._speed, q = X, i.useProgram(B), i.uniform1f(o.uniforms.u_time, k), this._uniformsDirty && (i.uniform2f(o.uniforms.u_resolution, this._ref.clientWidth, this._ref.clientHeight), i.uniform2f(o.uniforms.u_color_pressure, this._horizontalPressure, this._verticalPressure), i.uniform1f(o.uniforms.u_wave_frequency_x, this._waveFrequencyX), i.uniform1f(o.uniforms.u_wave_frequency_y, this._waveFrequencyY), i.uniform1f(o.uniforms.u_wave_amplitude, this._waveAmplitude), i.uniform1f(o.uniforms.u_color_blending, this._colorBlending), i.uniform1f(o.uniforms.u_shadows, this._shadows), i.uniform1f(o.uniforms.u_highlights, this._highlights), i.uniform1f(o.uniforms.u_saturation, this._saturation), i.uniform1f(o.uniforms.u_brightness, this._brightness), i.uniform1f(o.uniforms.u_grain_intensity, this._grainIntensity), i.uniform1f(o.uniforms.u_grain_sparsity, this._grainSparsity), i.uniform1f(o.uniforms.u_grain_speed, this._grainSpeed), i.uniform1f(o.uniforms.u_grain_scale, this._grainScale), i.uniform1f(o.uniforms.u_y_offset, this._yOffset), i.uniform1f(o.uniforms.u_y_offset_wave_multiplier, this._yOffsetWaveMultiplier), i.uniform1f(o.uniforms.u_y_offset_color_multiplier, this._yOffsetColorMultiplier), i.uniform1f(o.uniforms.u_y_offset_flow_multiplier, this._yOffsetFlowMultiplier), i.uniform1f(o.uniforms.u_flow_distortion_a, this._flowDistortionA), i.uniform1f(o.uniforms.u_flow_distortion_b, this._flowDistortionB), i.uniform1f(o.uniforms.u_flow_scale, this._flowScale), i.uniform1f(o.uniforms.u_flow_ease, this._flowEase), i.uniform1f(o.uniforms.u_flow_enabled, this._flowEnabled ? 1 : 0), i.uniform1f(o.uniforms.u_enable_procedural_texture, this._enableProceduralTexture ? 1 : 0), i.uniform1f(o.uniforms.u_texture_ease, this._textureEase), i.uniform1f(o.uniforms.u_domain_warp_enabled, this._domainWarpEnabled ? 1 : 0), i.uniform1f(o.uniforms.u_domain_warp_intensity, this._domainWarpIntensity), i.uniform1f(o.uniforms.u_domain_warp_scale, this._domainWarpScale), i.uniform1f(o.uniforms.u_vignette_intensity, this._vignetteIntensity), i.uniform1f(o.uniforms.u_vignette_radius, this._vignetteRadius), i.uniform1f(o.uniforms.u_fresnel_enabled, this._fresnelEnabled ? 1 : 0), i.uniform1f(o.uniforms.u_fresnel_power, this._fresnelPower), i.uniform1f(o.uniforms.u_fresnel_intensity, this._fresnelIntensity), i.uniform3fv(o.uniforms.u_fresnel_color, this._fresnelColorRgb), i.uniform1f(o.uniforms.u_iridescence_enabled, this._iridescenceEnabled ? 1 : 0), i.uniform1f(o.uniforms.u_iridescence_intensity, this._iridescenceIntensity), i.uniform1f(o.uniforms.u_iridescence_speed, this._iridescenceSpeed), i.uniform1f(o.uniforms.u_bloom_intensity, this._bloomIntensity), i.uniform1f(o.uniforms.u_bloom_threshold, this._bloomThreshold), i.uniform1f(o.uniforms.u_chromatic_aberration, this._chromaticAberration), this._uniformsDirty = !1), this._textureNeedsUpdate && this._enableProceduralTexture && (this._proceduralTexture && i.deleteTexture(this._proceduralTexture), this._proceduralTexture = this._createProceduralTexture(i), this._textureNeedsUpdate = !1, this._textureDirty = !0), this._textureDirty && this._proceduralTexture && (i.activeTexture(i.TEXTURE1), i.bindTexture(i.TEXTURE_2D, this._proceduralTexture), i.uniform1i(o.uniforms.u_procedural_texture, 1), this._textureDirty = !1), this._colorsChanged) {
630
747
  this._colorsChanged = !1;
631
748
  for (let P = 0; P < O; P++)
632
749
  if (P < this._colors.length) {
633
- const G = this._colors[P], _e = this._cachedColorRgb[P] || [0, 0, 0];
634
- r.uniform1f(u.uniforms[`u_colors[${P}].is_active`], G.enabled ? 1 : 0), r.uniform3fv(u.uniforms[`u_colors[${P}].color`], _e), r.uniform1f(u.uniforms[`u_colors[${P}].influence`], G.influence || 0);
750
+ const G = this._colors[P], Ae = this._cachedColorRgb[P] || [0, 0, 0];
751
+ i.uniform1f(o.uniforms[`u_colors[${P}].is_active`], G.enabled ? 1 : 0), i.uniform3fv(o.uniforms[`u_colors[${P}].color`], Ae), i.uniform1f(o.uniforms[`u_colors[${P}].influence`], G.influence || 0);
635
752
  } else
636
- r.uniform1f(u.uniforms[`u_colors[${P}].is_active`], 0);
637
- r.uniform1i(u.uniforms.u_colors_count, O);
753
+ i.uniform1f(o.uniforms[`u_colors[${P}].is_active`], 0);
754
+ i.uniform1i(o.uniforms.u_colors_count, O);
638
755
  }
639
756
  }
640
- r.clearColor(
757
+ i.clearColor(
641
758
  this._backgroundColorRgb[0],
642
759
  this._backgroundColorRgb[1],
643
760
  this._backgroundColorRgb[2],
644
761
  this._backgroundAlpha
645
- ), r.clear(r.COLOR_BUFFER_BIT | r.DEPTH_BUFFER_BIT), this._wireframe ? (r.bindBuffer(r.ELEMENT_ARRAY_BUFFER, this.glState.buffers.wireframeIndex), r.drawElements(r.LINES, this.glState.wireframeIndexCount, L, 0), r.bindBuffer(r.ELEMENT_ARRAY_BUFFER, this.glState.buffers.index)) : r.drawElements(r.TRIANGLES, B, L, 0), this.requestRef = requestAnimationFrame(q);
646
- }, ce = () => {
647
- const { gl: r, camera: I } = this.glState, u = this._ref.clientWidth, B = this._ref.clientHeight;
648
- this._ref.width = u, this._ref.height = B, r.viewport(0, 0, u, B), H(I, u, B);
649
- const L = r.getUniformLocation(this.glState.program, "projectionMatrix");
650
- r.useProgram(this.glState.program), r.uniformMatrix4fv(L, !1, I.projectionMatrix.elements);
762
+ ), i.clear(i.COLOR_BUFFER_BIT | i.DEPTH_BUFFER_BIT), this._wireframe ? (i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, this.glState.buffers.wireframeIndex), i.drawElements(i.LINES, this.glState.wireframeIndexCount, L, 0), i.bindBuffer(i.ELEMENT_ARRAY_BUFFER, this.glState.buffers.index)) : i.drawElements(i.TRIANGLES, U, L, 0), this.requestRef = requestAnimationFrame(V);
763
+ }, Re = () => {
764
+ const { gl: i, camera: B } = this.glState, o = this._ref.clientWidth, U = this._ref.clientHeight;
765
+ this._ref.width = o, this._ref.height = U, i.viewport(0, 0, o, U), H(B, o, U);
766
+ const L = i.getUniformLocation(this.glState.program, "projectionMatrix");
767
+ i.useProgram(this.glState.program), i.uniformMatrix4fv(L, !1, B.projectionMatrix.elements);
651
768
  };
652
769
  this.sizeObserver = new ResizeObserver(() => {
653
770
  this._resizeTimeoutId !== null && clearTimeout(this._resizeTimeoutId), this._resizeTimeoutId = window.setTimeout(() => {
654
- ce(), this._resizeTimeoutId = null;
771
+ Re(), this._resizeTimeoutId = null;
655
772
  }, 100);
656
- }), this.sizeObserver.observe(i), q();
773
+ }), this.sizeObserver.observe(r), V();
657
774
  }
658
775
  destroy() {
659
776
  if (cancelAnimationFrame(this.requestRef), this.sizeObserver.disconnect(), this._resizeTimeoutId !== null && (clearTimeout(this._resizeTimeoutId), this._resizeTimeoutId = null), this._linkElement && this._linkElement.parentElement && (this._linkElement.parentElement.removeChild(this._linkElement), this._linkElement = null), this.glState) {
@@ -663,8 +780,8 @@ class Te {
663
780
  this._proceduralTexture && this.glState && this.glState.gl.deleteTexture(this._proceduralTexture);
664
781
  }
665
782
  downloadAsPNG(e = "neat.png") {
666
- const i = this._ref.toDataURL("image/png");
667
- be(i, e);
783
+ const r = this._ref.toDataURL("image/png");
784
+ Oe(r, e);
668
785
  }
669
786
  set speed(e) {
670
787
  this._uniformsDirty = !0, this._speed = e / 20;
@@ -685,7 +802,7 @@ class Te {
685
802
  this._uniformsDirty = !0, this._waveAmplitude = e * 0.75;
686
803
  }
687
804
  set colors(e) {
688
- this._uniformsDirty = !0, this._colors = e, this._cachedColorRgb = e.map((i) => this._hexToRgb(i.color)), this._colorsChanged = !0;
805
+ this._uniformsDirty = !0, this._colors = e, this._cachedColorRgb = e.map((r) => this._hexToRgb(r.color)), this._colorsChanged = !0;
689
806
  }
690
807
  set highlights(e) {
691
808
  this._uniformsDirty = !0, this._highlights = e / 100;
@@ -719,8 +836,8 @@ class Te {
719
836
  }
720
837
  set resolution(e) {
721
838
  if (this._uniformsDirty = !0, this.glState) {
722
- const i = this.glState.gl;
723
- i.deleteProgram(this.glState.program), i.deleteBuffer(this.glState.buffers.position), i.deleteBuffer(this.glState.buffers.normal), i.deleteBuffer(this.glState.buffers.uv), i.deleteBuffer(this.glState.buffers.index), i.deleteBuffer(this.glState.buffers.wireframeIndex);
839
+ const r = this.glState.gl;
840
+ r.deleteProgram(this.glState.program), r.deleteBuffer(this.glState.buffers.position), r.deleteBuffer(this.glState.buffers.normal), r.deleteBuffer(this.glState.buffers.uv), r.deleteBuffer(this.glState.buffers.index), r.deleteBuffer(this.glState.buffers.wireframeIndex);
724
841
  }
725
842
  this.glState = this._initScene(e);
726
843
  }
@@ -812,59 +929,59 @@ class Te {
812
929
  this._uniformsDirty = !0, this._textureShapeSquiggles = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
813
930
  }
814
931
  _hexToRgb(e) {
815
- const i = parseInt(e.replace("#", ""), 16);
932
+ const r = parseInt(e.replace("#", ""), 16);
816
933
  return [
817
- (i >> 16 & 255) / 255,
818
- (i >> 8 & 255) / 255,
819
- (i & 255) / 255
934
+ (r >> 16 & 255) / 255,
935
+ (r >> 8 & 255) / 255,
936
+ (r & 255) / 255
820
937
  ];
821
938
  }
822
939
  _initScene(e) {
823
- const i = this._ref.clientWidth, o = this._ref.clientHeight, t = this._ref.getContext("webgl2", { alpha: !0, preserveDrawingBuffer: !0, antialias: !0 }) || this._ref.getContext("webgl", { alpha: !0, preserveDrawingBuffer: !0, antialias: !0 });
940
+ const r = this._ref.clientWidth, s = this._ref.clientHeight, t = this._ref.getContext("webgl2", { alpha: !0, preserveDrawingBuffer: !0, antialias: !0 }) || this._ref.getContext("webgl", { alpha: !0, preserveDrawingBuffer: !0, antialias: !0 });
824
941
  if (!t)
825
942
  throw new Error("WebGL not supported");
826
- t.getExtension("OES_standard_derivatives"), t.getExtension("OES_element_index_uint"), t.viewport(0, 0, i, o);
827
- const { position: b, normal: y, uv: n, index: p, wireframeIndex: v } = xe($, K, 240 * e, 240 * e), T = t.createBuffer();
828
- t.bindBuffer(t.ARRAY_BUFFER, T), t.bufferData(t.ARRAY_BUFFER, b, t.STATIC_DRAW);
943
+ t.getExtension("OES_standard_derivatives"), t.getExtension("OES_element_index_uint"), t.viewport(0, 0, r, s);
944
+ const { position: S, normal: y, uv: a, index: p, wireframeIndex: v } = Ie($, K, 240 * e, 240 * e), T = t.createBuffer();
945
+ t.bindBuffer(t.ARRAY_BUFFER, T), t.bufferData(t.ARRAY_BUFFER, S, t.STATIC_DRAW);
829
946
  const x = t.createBuffer();
830
947
  t.bindBuffer(t.ARRAY_BUFFER, x), t.bufferData(t.ARRAY_BUFFER, y, t.STATIC_DRAW);
831
948
  const h = t.createBuffer();
832
- t.bindBuffer(t.ARRAY_BUFFER, h), t.bufferData(t.ARRAY_BUFFER, n, t.STATIC_DRAW);
833
- const w = t.createBuffer();
834
- t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, w), t.bufferData(t.ELEMENT_ARRAY_BUFFER, p, t.STATIC_DRAW);
949
+ t.bindBuffer(t.ARRAY_BUFFER, h), t.bufferData(t.ARRAY_BUFFER, a, t.STATIC_DRAW);
950
+ const b = t.createBuffer();
951
+ t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, b), t.bufferData(t.ELEMENT_ARRAY_BUFFER, p, t.STATIC_DRAW);
835
952
  const R = t.createBuffer();
836
- t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, R), t.bufferData(t.ELEMENT_ARRAY_BUFFER, v, t.STATIC_DRAW), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, w);
837
- const E = me() + `
953
+ t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, R), t.bufferData(t.ELEMENT_ARRAY_BUFFER, v, t.STATIC_DRAW), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, b);
954
+ const E = De() + `
838
955
  ` + Y() + `
839
956
  ` + j() + `
840
- ` + he, g = t.createShader(t.VERTEX_SHADER);
957
+ ` + Ce, g = t.createShader(t.VERTEX_SHADER);
841
958
  t.shaderSource(g, E), t.compileShader(g), t.getShaderParameter(g, t.COMPILE_STATUS) || (console.log("VERTEX_SHADER_ERROR_START"), console.log("Vertex shader error: ", t.getShaderInfoLog(g)), console.log("GL Error Code:", t.getError()), console.log("Vertex Shader Source Dump:"), console.log(E.split(`
842
- `).map((S, U) => `${U + 1}: ${S}`).join(`
959
+ `).map((w, M) => `${M + 1}: ${w}`).join(`
843
960
  `)), console.log("VERTEX_SHADER_ERROR_END"));
844
- const A = pe() + `
961
+ const A = ze() + `
845
962
  ` + j() + `
846
963
  ` + Y() + `
847
- ` + de, c = t.createShader(t.FRAGMENT_SHADER);
848
- t.shaderSource(c, A), t.compileShader(c), t.getShaderParameter(c, t.COMPILE_STATUS) || (console.log("FRAGMENT_SHADER_ERROR_START"), console.log("Fragment shader error: ", t.getShaderInfoLog(c)), console.log("GL Error Code:", t.getError()), console.log("Fragment Shader Source Dump:"), console.log(A.split(`
849
- `).map((S, U) => `${U + 1}: ${S}`).join(`
964
+ ` + Pe, _ = t.createShader(t.FRAGMENT_SHADER);
965
+ t.shaderSource(_, A), t.compileShader(_), t.getShaderParameter(_, t.COMPILE_STATUS) || (console.log("FRAGMENT_SHADER_ERROR_START"), console.log("Fragment shader error: ", t.getShaderInfoLog(_)), console.log("GL Error Code:", t.getError()), console.log("Fragment Shader Source Dump:"), console.log(A.split(`
966
+ `).map((w, M) => `${M + 1}: ${w}`).join(`
850
967
  `)), console.log("FRAGMENT_SHADER_ERROR_END"));
851
- const l = t.createProgram();
852
- t.attachShader(l, g), t.attachShader(l, c), t.linkProgram(l), t.getProgramParameter(l, t.LINK_STATUS) || (console.log("PROGRAM_LINK_ERROR_START"), console.log("Program linking error: ", t.getProgramInfoLog(l)), console.log("GL Error Code:", t.getError()), console.log("PROGRAM_LINK_ERROR_END")), t.useProgram(l);
853
- const m = new ge(0, 0, 0, 0, 0, 1e3);
854
- m.position = [0, 0, 5], H(m, i, o);
855
- const s = t.getAttribLocation(l, "position"), f = t.getAttribLocation(l, "normal"), _ = t.getAttribLocation(l, "uv");
856
- t.enableVertexAttribArray(s), t.bindBuffer(t.ARRAY_BUFFER, T), t.vertexAttribPointer(s, 3, t.FLOAT, !1, 0, 0), t.enableVertexAttribArray(f), t.bindBuffer(t.ARRAY_BUFFER, x), t.vertexAttribPointer(f, 3, t.FLOAT, !1, 0, 0), t.enableVertexAttribArray(_), t.bindBuffer(t.ARRAY_BUFFER, h), t.vertexAttribPointer(_, 2, t.FLOAT, !1, 0, 0), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, w);
968
+ const u = t.createProgram();
969
+ t.attachShader(u, g), t.attachShader(u, _), t.linkProgram(u), t.getProgramParameter(u, t.LINK_STATUS) || (console.log("PROGRAM_LINK_ERROR_START"), console.log("Program linking error: ", t.getProgramInfoLog(u)), console.log("GL Error Code:", t.getError()), console.log("PROGRAM_LINK_ERROR_END")), t.useProgram(u);
970
+ const m = new Fe(0, 0, 0, 0, 0, 1e3);
971
+ m.position = [0, 0, 5], H(m, r, s);
972
+ const n = t.getAttribLocation(u, "position"), f = t.getAttribLocation(u, "normal"), c = t.getAttribLocation(u, "uv");
973
+ t.enableVertexAttribArray(n), t.bindBuffer(t.ARRAY_BUFFER, T), t.vertexAttribPointer(n, 3, t.FLOAT, !1, 0, 0), t.enableVertexAttribArray(f), t.bindBuffer(t.ARRAY_BUFFER, x), t.vertexAttribPointer(f, 3, t.FLOAT, !1, 0, 0), t.enableVertexAttribArray(c), t.bindBuffer(t.ARRAY_BUFFER, h), t.vertexAttribPointer(c, 2, t.FLOAT, !1, 0, 0), t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, b);
857
974
  const d = new J();
858
975
  d.translate(-m.position[0], -m.position[1], -m.position[2]), d.translate(0, 0, -1), d.rotateX(-Math.PI / 3.5);
859
- const z = t.getUniformLocation(l, "modelViewMatrix");
860
- t.uniformMatrix4fv(z, !1, d.elements);
861
- const C = t.getUniformLocation(l, "projectionMatrix");
862
- t.uniformMatrix4fv(C, !1, m.projectionMatrix.elements);
863
- const F = t.getUniformLocation(l, "u_plane_width");
976
+ const C = t.getUniformLocation(u, "modelViewMatrix");
977
+ t.uniformMatrix4fv(C, !1, d.elements);
978
+ const D = t.getUniformLocation(u, "projectionMatrix");
979
+ t.uniformMatrix4fv(D, !1, m.projectionMatrix.elements);
980
+ const F = t.getUniformLocation(u, "u_plane_width");
864
981
  t.uniform1f(F, $);
865
- const M = t.getUniformLocation(l, "u_plane_height");
866
- t.uniform1f(M, K);
867
- const N = t.getUniformLocation(l, "u_colors_count");
982
+ const I = t.getUniformLocation(u, "u_plane_height");
983
+ t.uniform1f(I, K);
984
+ const N = t.getUniformLocation(u, "u_colors_count");
868
985
  t.uniform1i(N, O);
869
986
  const W = [
870
987
  "u_time",
@@ -896,27 +1013,42 @@ class Te {
896
1013
  "u_texture_ease",
897
1014
  "u_saturation",
898
1015
  "u_brightness",
899
- "u_color_blending"
900
- ], D = {
901
- attributes: { position: s, normal: f, uv: _ },
1016
+ "u_color_blending",
1017
+ "u_domain_warp_enabled",
1018
+ "u_domain_warp_intensity",
1019
+ "u_domain_warp_scale",
1020
+ "u_vignette_intensity",
1021
+ "u_vignette_radius",
1022
+ "u_fresnel_enabled",
1023
+ "u_fresnel_power",
1024
+ "u_fresnel_intensity",
1025
+ "u_fresnel_color",
1026
+ "u_iridescence_enabled",
1027
+ "u_iridescence_intensity",
1028
+ "u_iridescence_speed",
1029
+ "u_bloom_intensity",
1030
+ "u_bloom_threshold",
1031
+ "u_chromatic_aberration"
1032
+ ], z = {
1033
+ attributes: { position: n, normal: f, uv: c },
902
1034
  uniforms: {}
903
1035
  };
904
- W.forEach((S) => {
905
- D.uniforms[S] = t.getUniformLocation(l, S);
1036
+ W.forEach((w) => {
1037
+ z.uniforms[w] = t.getUniformLocation(u, w);
906
1038
  });
907
- for (let S = 0; S < O; S++)
908
- D.uniforms[`u_colors[${S}].is_active`] = t.getUniformLocation(l, `u_colors[${S}].is_active`), D.uniforms[`u_colors[${S}].color`] = t.getUniformLocation(l, `u_colors[${S}].color`), D.uniforms[`u_colors[${S}].influence`] = t.getUniformLocation(l, `u_colors[${S}].influence`);
1039
+ for (let w = 0; w < O; w++)
1040
+ z.uniforms[`u_colors[${w}].is_active`] = t.getUniformLocation(u, `u_colors[${w}].is_active`), z.uniforms[`u_colors[${w}].color`] = t.getUniformLocation(u, `u_colors[${w}].color`), z.uniforms[`u_colors[${w}].influence`] = t.getUniformLocation(u, `u_colors[${w}].influence`);
909
1041
  return this._initialized = !0, this._uniformsDirty = !0, this._colorsChanged = !0, this._textureDirty = !0, t.enable(t.BLEND), t.blendFunc(t.SRC_ALPHA, t.ONE_MINUS_SRC_ALPHA), t.enable(t.DEPTH_TEST), {
910
1042
  gl: t,
911
- program: l,
1043
+ program: u,
912
1044
  buffers: {
913
1045
  position: T,
914
1046
  normal: x,
915
1047
  uv: h,
916
- index: w,
1048
+ index: b,
917
1049
  wireframeIndex: R
918
1050
  },
919
- locations: D,
1051
+ locations: z,
920
1052
  camera: m,
921
1053
  indexCount: p.length,
922
1054
  wireframeIndexCount: v.length,
@@ -924,66 +1056,66 @@ class Te {
924
1056
  };
925
1057
  }
926
1058
  _createProceduralTexture(e) {
927
- const o = document.createElement("canvas");
928
- o.width = 1024, o.height = 1024;
929
- const t = o.getContext("2d", { willReadFrequently: !0 });
1059
+ const s = document.createElement("canvas");
1060
+ s.width = 1024, s.height = 1024;
1061
+ const t = s.getContext("2d", { willReadFrequently: !0 });
930
1062
  if (!t)
931
1063
  return null;
932
- let b = this._textureSeed;
1064
+ let S = this._textureSeed;
933
1065
  const y = this._textureSeed;
934
- function n() {
935
- const s = Math.sin(b++) * 1e4;
936
- return s - Math.floor(s);
1066
+ function a() {
1067
+ const n = Math.sin(S++) * 1e4;
1068
+ return n - Math.floor(n);
937
1069
  }
938
- const p = (s) => {
939
- b = y + s;
940
- }, v = this._colors.filter((s) => s.enabled).map((s) => s.color);
1070
+ const p = (n) => {
1071
+ S = y + n;
1072
+ }, v = this._colors.filter((n) => n.enabled).map((n) => n.color);
941
1073
  if (v.length === 0)
942
1074
  return null;
943
- function T(s) {
944
- const f = parseInt(s.replace("#", ""), 16);
1075
+ function T(n) {
1076
+ const f = parseInt(n.replace("#", ""), 16);
945
1077
  return {
946
1078
  r: f >> 16 & 255,
947
1079
  g: f >> 8 & 255,
948
1080
  b: f & 255
949
1081
  };
950
1082
  }
951
- function x(s, f, _) {
952
- return "#" + ((1 << 24) + (Math.round(s) << 16) + (Math.round(f) << 8) + Math.round(_)).toString(16).slice(1).padStart(6, "0");
1083
+ function x(n, f, c) {
1084
+ return "#" + ((1 << 24) + (Math.round(n) << 16) + (Math.round(f) << 8) + Math.round(c)).toString(16).slice(1).padStart(6, "0");
953
1085
  }
954
1086
  const h = () => {
955
- const s = v[Math.floor(n() * v.length)], f = v[Math.floor(n() * v.length)], _ = n() * this._textureColorBlending, d = T(s), z = T(f), C = d.r + (z.r - d.r) * _, F = d.g + (z.g - d.g) * _, M = d.b + (z.b - d.b) * _;
956
- return x(C, F, M);
957
- }, w = this._proceduralBackgroundColor || "#000000";
958
- t.fillStyle = w, t.fillRect(0, 0, 1024, 1024);
1087
+ const n = v[Math.floor(a() * v.length)], f = v[Math.floor(a() * v.length)], c = a() * this._textureColorBlending, d = T(n), C = T(f), D = d.r + (C.r - d.r) * c, F = d.g + (C.g - d.g) * c, I = d.b + (C.b - d.b) * c;
1088
+ return x(D, F, I);
1089
+ }, b = this._proceduralBackgroundColor || "#000000";
1090
+ t.fillStyle = b, t.fillRect(0, 0, 1024, 1024);
959
1091
  const R = t.createLinearGradient(0, 0, 0, 1024);
960
1092
  R.addColorStop(0, h()), R.addColorStop(1, h()), t.fillStyle = R, t.fillRect(0, 0, 1024, 1024);
961
- for (let s = 0; s < this._textureShapeTriangles; s++) {
1093
+ for (let n = 0; n < this._textureShapeTriangles; n++) {
962
1094
  t.fillStyle = h(), t.beginPath();
963
- const f = n() * 1024, _ = n() * 1024, d = 100 + n() * 300;
964
- t.moveTo(f, _), t.lineTo(f + (n() - 0.5) * d, _ + (n() - 0.5) * d), t.lineTo(f + (n() - 0.5) * d, _ + (n() - 0.5) * d), t.fill();
1095
+ const f = a() * 1024, c = a() * 1024, d = 100 + a() * 300;
1096
+ t.moveTo(f, c), t.lineTo(f + (a() - 0.5) * d, c + (a() - 0.5) * d), t.lineTo(f + (a() - 0.5) * d, c + (a() - 0.5) * d), t.fill();
965
1097
  }
966
- for (let s = 0; s < this._textureShapeCircles; s++) {
967
- t.strokeStyle = h(), t.lineWidth = 10 + n() * 50, t.beginPath();
968
- const f = n() * 1024, _ = n() * 1024, d = 50 + n() * 150;
969
- t.arc(f, _, d, 0, Math.PI * 2), t.stroke();
1098
+ for (let n = 0; n < this._textureShapeCircles; n++) {
1099
+ t.strokeStyle = h(), t.lineWidth = 10 + a() * 50, t.beginPath();
1100
+ const f = a() * 1024, c = a() * 1024, d = 50 + a() * 150;
1101
+ t.arc(f, c, d, 0, Math.PI * 2), t.stroke();
970
1102
  }
971
- for (let s = 0; s < this._textureShapeBars; s++)
972
- t.fillStyle = h(), t.save(), t.translate(n() * 1024, n() * 1024), t.rotate(n() * Math.PI), t.fillRect(-150, -25, 300, 50), t.restore();
1103
+ for (let n = 0; n < this._textureShapeBars; n++)
1104
+ t.fillStyle = h(), t.save(), t.translate(a() * 1024, a() * 1024), t.rotate(a() * Math.PI), t.fillRect(-150, -25, 300, 50), t.restore();
973
1105
  t.lineWidth = 15, t.lineCap = "round";
974
- for (let s = 0; s < this._textureShapeSquiggles; s++) {
1106
+ for (let n = 0; n < this._textureShapeSquiggles; n++) {
975
1107
  t.strokeStyle = h(), t.beginPath();
976
- let f = n() * 1024, _ = n() * 1024;
977
- t.moveTo(f, _);
1108
+ let f = a() * 1024, c = a() * 1024;
1109
+ t.moveTo(f, c);
978
1110
  for (let d = 0; d < 4; d++)
979
1111
  t.bezierCurveTo(
980
- f + (n() - 0.5) * 300,
981
- _ + (n() - 0.5) * 300,
982
- f + (n() - 0.5) * 300,
983
- _ + (n() - 0.5) * 300,
984
- f + (n() - 0.5) * 300,
985
- _ + (n() - 0.5) * 300
986
- ), f += (n() - 0.5) * 300, _ += (n() - 0.5) * 300;
1112
+ f + (a() - 0.5) * 300,
1113
+ c + (a() - 0.5) * 300,
1114
+ f + (a() - 0.5) * 300,
1115
+ c + (a() - 0.5) * 300,
1116
+ f + (a() - 0.5) * 300,
1117
+ c + (a() - 0.5) * 300
1118
+ ), f += (a() - 0.5) * 300, c += (a() - 0.5) * 300;
987
1119
  t.stroke();
988
1120
  }
989
1121
  p(5e4);
@@ -992,80 +1124,125 @@ class Te {
992
1124
  const g = E.getContext("2d", { willReadFrequently: !0 });
993
1125
  if (!g)
994
1126
  return null;
995
- g.fillStyle = w, g.fillRect(0, 0, 1024, 1024);
1127
+ g.fillStyle = b, g.fillRect(0, 0, 1024, 1024);
996
1128
  let A = 0;
997
- const c = [];
1129
+ const _ = [];
998
1130
  for (; A < 1024; )
999
- if (n() < this._textureVoidLikelihood) {
1000
- const f = this._textureVoidWidthMin + n() * (this._textureVoidWidthMax - this._textureVoidWidthMin);
1001
- c.push({ type: "void", x: A, width: f }), A += f;
1131
+ if (a() < this._textureVoidLikelihood) {
1132
+ const f = this._textureVoidWidthMin + a() * (this._textureVoidWidthMax - this._textureVoidWidthMin);
1133
+ _.push({ type: "void", x: A, width: f }), A += f;
1002
1134
  } else {
1003
- const f = 50 + n() * 200;
1004
- c.push({ type: "matter", x: A, width: f }), A += f;
1135
+ const f = 50 + a() * 200;
1136
+ _.push({ type: "matter", x: A, width: f }), A += f;
1005
1137
  }
1006
- for (const s of c)
1007
- if (s.type === "matter") {
1008
- const f = s.x, _ = Math.min(s.x + s.width, 1024);
1138
+ for (const n of _)
1139
+ if (n.type === "matter") {
1140
+ const f = n.x, c = Math.min(n.x + n.width, 1024);
1009
1141
  let d = f;
1010
- for (; d < _; ) {
1011
- const z = (2 + n() * 20) / this._textureBandDensity, C = Math.floor(n() * 1024);
1142
+ for (; d < c; ) {
1143
+ const C = (2 + a() * 20) / this._textureBandDensity, D = Math.floor(a() * 1024);
1012
1144
  g.drawImage(
1013
- o,
1014
- C,
1145
+ s,
1146
+ D,
1015
1147
  0,
1016
- z,
1148
+ C,
1017
1149
  1024,
1018
1150
  d,
1019
1151
  0,
1020
- z,
1152
+ C,
1021
1153
  1024
1022
- ), d += z;
1154
+ ), d += C;
1023
1155
  }
1024
1156
  }
1025
- const l = e.createTexture();
1026
- e.bindTexture(e.TEXTURE_2D, l), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, E), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.REPEAT), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.REPEAT), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR_MIPMAP_LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.LINEAR), e.generateMipmap(e.TEXTURE_2D);
1157
+ const u = e.createTexture();
1158
+ e.bindTexture(e.TEXTURE_2D, u), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, E), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.REPEAT), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.REPEAT), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR_MIPMAP_LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.LINEAR), e.generateMipmap(e.TEXTURE_2D);
1027
1159
  const m = e.getExtension("EXT_texture_filter_anisotropic") || e.getExtension("MOZ_EXT_texture_filter_anisotropic") || e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
1028
1160
  if (m) {
1029
- const s = e.getParameter(m.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
1030
- e.texParameterf(e.TEXTURE_2D, m.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(16, s));
1161
+ const n = e.getParameter(m.MAX_TEXTURE_MAX_ANISOTROPY_EXT);
1162
+ e.texParameterf(e.TEXTURE_2D, m.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(16, n));
1031
1163
  }
1032
- return l;
1164
+ return u;
1165
+ }
1166
+ set domainWarpEnabled(e) {
1167
+ this._domainWarpEnabled !== e && (this._domainWarpEnabled = e, this._uniformsDirty = !0);
1168
+ }
1169
+ set domainWarpIntensity(e) {
1170
+ this._domainWarpIntensity !== e && (this._domainWarpIntensity = e, this._uniformsDirty = !0);
1171
+ }
1172
+ set domainWarpScale(e) {
1173
+ this._domainWarpScale !== e && (this._domainWarpScale = e, this._uniformsDirty = !0);
1174
+ }
1175
+ set vignetteIntensity(e) {
1176
+ this._vignetteIntensity !== e && (this._vignetteIntensity = e, this._uniformsDirty = !0);
1177
+ }
1178
+ set vignetteRadius(e) {
1179
+ this._vignetteRadius !== e && (this._vignetteRadius = e, this._uniformsDirty = !0);
1180
+ }
1181
+ set fresnelEnabled(e) {
1182
+ this._fresnelEnabled !== e && (this._fresnelEnabled = e, this._uniformsDirty = !0);
1183
+ }
1184
+ set fresnelPower(e) {
1185
+ this._fresnelPower !== e && (this._fresnelPower = e, this._uniformsDirty = !0);
1186
+ }
1187
+ set fresnelIntensity(e) {
1188
+ this._fresnelIntensity !== e && (this._fresnelIntensity = e, this._uniformsDirty = !0);
1189
+ }
1190
+ set fresnelColor(e) {
1191
+ this._fresnelColor !== e && (this._fresnelColor = e, this._fresnelColorRgb = this._hexToRgb(e), this._uniformsDirty = !0);
1192
+ }
1193
+ set iridescenceEnabled(e) {
1194
+ this._iridescenceEnabled !== e && (this._iridescenceEnabled = e, this._uniformsDirty = !0);
1195
+ }
1196
+ set iridescenceIntensity(e) {
1197
+ this._iridescenceIntensity !== e && (this._iridescenceIntensity = e, this._uniformsDirty = !0);
1198
+ }
1199
+ set iridescenceSpeed(e) {
1200
+ this._iridescenceSpeed !== e && (this._iridescenceSpeed = e, this._uniformsDirty = !0);
1201
+ }
1202
+ set bloomIntensity(e) {
1203
+ this._bloomIntensity !== e && (this._bloomIntensity = e, this._uniformsDirty = !0);
1204
+ }
1205
+ set bloomThreshold(e) {
1206
+ this._bloomThreshold !== e && (this._bloomThreshold = e, this._uniformsDirty = !0);
1207
+ }
1208
+ set chromaticAberration(e) {
1209
+ this._chromaticAberration !== e && (this._chromaticAberration = e, this._uniformsDirty = !0);
1033
1210
  }
1034
1211
  }
1035
- const Z = (a) => {
1036
- a.id = ye, a.href = "https://neat.firecms.co", a.target = "_blank", a.style.position = "absolute", a.style.display = "block", a.style.bottom = "0", a.style.right = "0", a.style.padding = "10px", a.style.color = "#dcdcdc", a.style.opacity = "0.8", a.style.fontFamily = "sans-serif", a.style.fontSize = "16px", a.style.fontWeight = "bold", a.style.textDecoration = "none", a.style.zIndex = "10000", a.style.pointerEvents = "auto", a.setAttribute("data-n", "1"), a.innerHTML = "NEAT";
1037
- }, ve = (a) => {
1038
- const e = a.parentElement;
1212
+ const Z = (l) => {
1213
+ l.id = Me, l.href = "https://neat.firecms.co", l.target = "_blank", l.style.position = "absolute", l.style.display = "block", l.style.bottom = "0", l.style.right = "0", l.style.padding = "10px", l.style.color = "#dcdcdc", l.style.opacity = "0.8", l.style.fontFamily = "sans-serif", l.style.fontSize = "16px", l.style.fontWeight = "bold", l.style.textDecoration = "none", l.style.zIndex = "10000", l.style.pointerEvents = "auto", l.setAttribute("data-n", "1"), l.innerHTML = "NEAT";
1214
+ }, Ue = (l) => {
1215
+ const e = l.parentElement;
1039
1216
  if (e && getComputedStyle(e).position === "static" && (e.style.position = "relative"), e) {
1040
- const o = e.querySelector("a[data-n]");
1041
- if (o)
1042
- return Z(o), o;
1217
+ const s = e.querySelector("a[data-n]");
1218
+ if (s)
1219
+ return Z(s), s;
1043
1220
  }
1044
- const i = document.createElement("a");
1045
- return Z(i), e?.appendChild(i), i;
1221
+ const r = document.createElement("a");
1222
+ return Z(r), e?.appendChild(r), r;
1046
1223
  };
1047
- function we() {
1048
- const a = new Date(), e = a.getMinutes(), i = a.getSeconds();
1049
- return e * 60 + i;
1224
+ function Be() {
1225
+ const l = new Date(), e = l.getMinutes(), r = l.getSeconds();
1226
+ return e * 60 + r;
1050
1227
  }
1051
- function Se(a = 6) {
1228
+ function Le(l = 6) {
1052
1229
  const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
1053
- let i = "";
1054
- for (let o = 0; o < a; o++) {
1230
+ let r = "";
1231
+ for (let s = 0; s < l; s++) {
1055
1232
  const t = Math.floor(Math.random() * e.length);
1056
- i += e.charAt(t);
1233
+ r += e.charAt(t);
1057
1234
  }
1058
- return i;
1235
+ return r;
1059
1236
  }
1060
- function be(a, e) {
1061
- const i = document.createElement("a");
1062
- i.download = e, i.href = a, document.body.appendChild(i), i.click(), document.body.removeChild(i);
1237
+ function Oe(l, e) {
1238
+ const r = document.createElement("a");
1239
+ r.download = e, r.href = l, document.body.appendChild(r), r.click(), document.body.removeChild(r);
1063
1240
  }
1064
- function Ee() {
1241
+ function Ne() {
1065
1242
  if (document.getElementById("neat-seo-schema"))
1066
1243
  return;
1067
- const a = document.createElement("script");
1068
- a.id = "neat-seo-schema", a.type = "application/ld+json", a.text = JSON.stringify({
1244
+ const l = document.createElement("script");
1245
+ l.id = "neat-seo-schema", l.type = "application/ld+json", l.text = JSON.stringify({
1069
1246
  "@context": "https://schema.org",
1070
1247
  "@type": "WebSite",
1071
1248
  name: "NEAT Gradient",
@@ -1076,19 +1253,19 @@ function Ee() {
1076
1253
  url: "https://firecms.co"
1077
1254
  },
1078
1255
  description: "Beautiful, fast, heavily customizable, WebGL based gradients."
1079
- }), document.head.appendChild(a);
1256
+ }), document.head.appendChild(l);
1080
1257
  const e = document.createElement("div");
1081
1258
  e.style.position = "absolute", e.style.width = "1px", e.style.height = "1px", e.style.padding = "0", e.style.margin = "-1px", e.style.overflow = "hidden", e.style.clip = "rect(0, 0, 0, 0)", e.style.whiteSpace = "nowrap", e.style.borderWidth = "0";
1082
1259
  try {
1083
- const i = e.attachShadow({ mode: "closed" }), o = document.createElement("a");
1084
- o.href = "https://firecms.co", o.textContent = "FireCMS", i.appendChild(o);
1260
+ const r = e.attachShadow({ mode: "closed" }), s = document.createElement("a");
1261
+ s.href = "https://firecms.co", s.textContent = "FireCMS", r.appendChild(s);
1085
1262
  } catch {
1086
- const o = document.createElement("a");
1087
- o.href = "https://firecms.co", o.textContent = "FireCMS", e.appendChild(o);
1263
+ const s = document.createElement("a");
1264
+ s.href = "https://firecms.co", s.textContent = "FireCMS", e.appendChild(s);
1088
1265
  }
1089
1266
  document.body.appendChild(e);
1090
1267
  }
1091
1268
  export {
1092
- Te as NeatGradient
1269
+ We as NeatGradient
1093
1270
  };
1094
1271
  //# sourceMappingURL=index.es.js.map