@firecms/neat 0.6.0 → 0.7.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,584 +1,4 @@
1
- import * as n from "three";
2
- console.info(
3
- `%c\u{1F308} Neat Gradients%c
4
-
5
- Licensed under MIT + The Commons Clause.
6
- Free for personal and commercial use.
7
- Selling this software or its derivatives is strictly prohibited.
8
- https://neat.firecms.co`,
9
- "font-weight: bold; font-size: 14px; color: #FF5772;",
10
- "color: inherit;"
11
- );
12
- const U = 50, D = 80, be = !0, j = 6, ze = new n.Clock(), Q = Fe();
13
- class Ue {
14
- _ref;
15
- _speed = -1;
16
- _horizontalPressure = -1;
17
- _verticalPressure = -1;
18
- _waveFrequencyX = -1;
19
- _waveFrequencyY = -1;
20
- _waveAmplitude = -1;
21
- _shadows = -1;
22
- _highlights = -1;
23
- _saturation = -1;
24
- _brightness = -1;
25
- _grainScale = -1;
26
- _grainIntensity = -1;
27
- _grainSparsity = -1;
28
- _grainSpeed = -1;
29
- _colorBlending = -1;
30
- _colors = [];
31
- _wireframe = !1;
32
- _backgroundColor = "#FFFFFF";
33
- _backgroundAlpha = 1;
34
- _flowDistortionA = 0;
35
- _flowDistortionB = 0;
36
- _flowScale = 1;
37
- _flowEase = 0;
38
- _flowEnabled = !0;
39
- _mouseDistortionStrength = 0;
40
- _mouseDistortionRadius = 0.25;
41
- _mouseDecayRate = 0.96;
42
- _mouseDarken = 0;
43
- _mouse = new n.Vector2(-1e3, -1e3);
44
- _mouseFBO = null;
45
- _sceneMouse = null;
46
- _cameraMouse = null;
47
- _mouseObjects = [];
48
- _currentBrush = 0;
49
- _mouseBrushBaseScale = 1;
50
- _enableProceduralTexture = !1;
51
- _textureVoidLikelihood = 0.45;
52
- _textureVoidWidthMin = 200;
53
- _textureVoidWidthMax = 486;
54
- _textureBandDensity = 2.15;
55
- _textureColorBlending = 0.01;
56
- _textureSeed = 333;
57
- _textureEase = 0.5;
58
- _proceduralTexture = null;
59
- _proceduralBackgroundColor = "#000000";
60
- _textureShapeTriangles = 20;
61
- _textureShapeCircles = 15;
62
- _textureShapeBars = 15;
63
- _textureShapeSquiggles = 10;
64
- requestRef = -1;
65
- sizeObserver;
66
- sceneState;
67
- _cachedUniforms = null;
68
- _linkElement = null;
69
- _yOffset = 0;
70
- _yOffsetWaveMultiplier = 4e-3;
71
- _yOffsetColorMultiplier = 4e-3;
72
- _yOffsetFlowMultiplier = 4e-3;
73
- _tempClearColor = new n.Color();
74
- _resizeTimeoutId = null;
75
- _textureNeedsUpdate = !1;
76
- _lastColorUpdate = 0;
77
- _linkCheckCounter = 0;
78
- _mouseUpdateScheduled = !1;
79
- _pendingMousePosition = null;
80
- _colorsChanged = !0;
81
- constructor(e) {
82
- const {
83
- ref: o,
84
- speed: t = 4,
85
- horizontalPressure: d = 3,
86
- verticalPressure: c = 3,
87
- waveFrequencyX: s = 5,
88
- waveFrequencyY: p = 5,
89
- waveAmplitude: g = 3,
90
- colors: f,
91
- highlights: m = 4,
92
- shadows: u = 4,
93
- colorSaturation: v = 0,
94
- colorBrightness: O = 1,
95
- colorBlending: M = 5,
96
- grainScale: z = 2,
97
- grainIntensity: y = 0.55,
98
- grainSparsity: T = 0,
99
- grainSpeed: C = 0.1,
100
- wireframe: a = !1,
101
- backgroundColor: l = "#FFFFFF",
102
- backgroundAlpha: h = 1,
103
- resolution: _ = 1,
104
- seed: S,
105
- yOffset: B = 0,
106
- yOffsetWaveMultiplier: N = 4,
107
- yOffsetColorMultiplier: L = 4,
108
- yOffsetFlowMultiplier: $ = 4,
109
- flowDistortionA: ee = 0,
110
- flowDistortionB: te = 0,
111
- flowScale: oe = 1,
112
- flowEase: se = 0,
113
- flowEnabled: ie = !0,
114
- mouseDistortionStrength: re = 0,
115
- mouseDistortionRadius: ae = 0.25,
116
- mouseDecayRate: ne = 0.96,
117
- mouseDarken: le = 0,
118
- enableProceduralTexture: ue = !1,
119
- textureVoidLikelihood: ce = 0.45,
120
- textureVoidWidthMin: _e = 200,
121
- textureVoidWidthMax: he = 486,
122
- textureBandDensity: de = 2.15,
123
- textureColorBlending: fe = 0.01,
124
- textureSeed: pe = 333,
125
- textureEase: me = 0.5,
126
- proceduralBackgroundColor: ve = "#000000",
127
- textureShapeTriangles: ge = 20,
128
- textureShapeCircles: xe = 15,
129
- textureShapeBars: ye = 15,
130
- textureShapeSquiggles: we = 10
131
- } = e;
132
- 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 = d, this.verticalPressure = c, this.waveFrequencyX = s, this.waveFrequencyY = p, this.waveAmplitude = g, this.colorBlending = M, this.grainScale = z, this.grainIntensity = y, this.grainSparsity = T, this.grainSpeed = C, this.colors = f, this.shadows = u, this.highlights = m, this.colorSaturation = v, this.colorBrightness = O, this.wireframe = a, this.backgroundColor = l, this.backgroundAlpha = h, this.yOffset = B, this.yOffsetWaveMultiplier = N, this.yOffsetColorMultiplier = L, this.yOffsetFlowMultiplier = $, this.flowDistortionA = ee, this.flowDistortionB = te, this.flowScale = oe, this.flowEase = se, this.flowEnabled = ie, this.mouseDistortionStrength = re, this.mouseDistortionRadius = ae, this.mouseDecayRate = ne, this.mouseDarken = le, this.enableProceduralTexture = ue, this.textureVoidLikelihood = ce, this.textureVoidWidthMin = _e, this.textureVoidWidthMax = he, this.textureBandDensity = de, this.textureColorBlending = fe, this.textureSeed = pe, this.textureEase = me, this._proceduralBackgroundColor = ve, this._textureShapeTriangles = ge, this._textureShapeCircles = xe, this._textureShapeBars = ye, this._textureShapeSquiggles = we, this._setupMouseInteraction(), this.sceneState = this._initScene(_), Be();
133
- let G = S !== void 0 ? S : Oe();
134
- const X = () => {
135
- const { renderer: w, camera: E, scene: F } = this.sceneState;
136
- if (this._linkCheckCounter++, this._linkCheckCounter >= 300 && (this._linkCheckCounter = 0, (!this._linkElement || !document.contains(this._linkElement)) && (this._linkElement = Pe(o))), this._cachedUniforms) {
137
- const r = this._cachedUniforms;
138
- G += ze.getDelta() * this._speed, r.u_time.value = G, r.u_resolution.value.set(this._ref.width, this._ref.height), r.u_color_pressure.value.set(this._horizontalPressure, this._verticalPressure), r.u_wave_frequency_x.value = this._waveFrequencyX, r.u_wave_frequency_y.value = this._waveFrequencyY, r.u_wave_amplitude.value = this._waveAmplitude, r.u_color_blending.value = this._colorBlending, r.u_shadows.value = this._shadows, r.u_highlights.value = this._highlights, r.u_saturation.value = this._saturation, r.u_brightness.value = this._brightness, r.u_grain_intensity.value = this._grainIntensity, r.u_grain_sparsity.value = this._grainSparsity, r.u_grain_speed.value = this._grainSpeed, r.u_grain_scale.value = this._grainScale, r.u_y_offset.value = this._yOffset, r.u_y_offset_wave_multiplier.value = this._yOffsetWaveMultiplier, r.u_y_offset_color_multiplier.value = this._yOffsetColorMultiplier, r.u_y_offset_flow_multiplier.value = this._yOffsetFlowMultiplier, r.u_flow_distortion_a.value = this._flowDistortionA, r.u_flow_distortion_b.value = this._flowDistortionB, r.u_flow_scale.value = this._flowScale, r.u_flow_ease.value = this._flowEase, r.u_flow_enabled.value = this._flowEnabled ? 1 : 0, r.u_mouse_distortion_strength.value = this._mouseDistortionStrength, r.u_mouse_distortion_radius.value = this._mouseDistortionRadius, r.u_mouse_darken.value = this._mouseDarken, r.u_enable_procedural_texture.value = this._enableProceduralTexture ? 1 : 0, this._textureNeedsUpdate && this._enableProceduralTexture && (this._proceduralTexture && this._proceduralTexture.dispose(), this._proceduralTexture = this._createProceduralTexture(), this._textureNeedsUpdate = !1), r.u_procedural_texture.value = this._proceduralTexture, r.u_texture_ease.value = this._textureEase, this.sceneState.meshes[0].material.wireframe = this._wireframe;
139
- const x = Date.now();
140
- if (this._colorsChanged || x - this._lastColorUpdate > 100) {
141
- this._lastColorUpdate = x, this._colorsChanged = !1;
142
- const q = r.u_colors.value;
143
- for (let P = 0; P < j; P++)
144
- if (P < this._colors.length) {
145
- const V = this._colors[P];
146
- q[P].is_active = V.enabled ? 1 : 0, q[P].color.setStyle(V.color, ""), q[P].influence = V.influence || 0;
147
- } else
148
- q[P].is_active = 0;
149
- r.u_colors_count.value = j;
150
- }
151
- }
152
- if (this._mouseFBO && this._sceneMouse && this._cameraMouse && this._mouseDistortionStrength > 0) {
153
- let r = !1;
154
- for (let x = 0; x < this._mouseObjects.length; x++) {
155
- const b = this._mouseObjects[x];
156
- b.mesh.visible && (r = !0, b.mesh.rotation.z += 0.01, b.mesh.material instanceof n.MeshBasicMaterial && (b.mesh.material.opacity *= this._mouseDecayRate, b.mesh.material.opacity < 0.01 && (b.mesh.visible = !1)));
157
- }
158
- if (r) {
159
- w.getClearColor(this._tempClearColor);
160
- const x = w.getClearAlpha();
161
- w.setClearColor(0, 0), w.setRenderTarget(this._mouseFBO), w.clear(), w.render(this._sceneMouse, this._cameraMouse), w.setRenderTarget(null), w.setClearColor(this._tempClearColor, x), this._cachedUniforms && (this._cachedUniforms.u_mouse_texture.value = this._mouseFBO.texture);
162
- }
163
- }
164
- w.setClearColor(this._backgroundColor, this._backgroundAlpha), w.render(F, E), this.requestRef = requestAnimationFrame(X);
165
- }, Se = () => {
166
- const { renderer: w } = this.sceneState, E = w.domElement, F = E.clientWidth, r = E.clientHeight;
167
- if (this.sceneState.renderer.setSize(F, r, !1), K(this.sceneState.camera, F, r), this._mouseFBO && this._cameraMouse) {
168
- const x = r / 2, b = F / r;
169
- this._mouseFBO.setSize(F / 2, r / 2), this._cameraMouse.left = -x * b, this._cameraMouse.right = x * b, this._cameraMouse.top = x, this._cameraMouse.bottom = -x, this._cameraMouse.updateProjectionMatrix();
170
- }
171
- };
172
- this.sizeObserver = new ResizeObserver(() => {
173
- this._resizeTimeoutId !== null && clearTimeout(this._resizeTimeoutId), this._resizeTimeoutId = window.setTimeout(() => {
174
- Se(), this._resizeTimeoutId = null;
175
- }, 100);
176
- }), this.sizeObserver.observe(o), X();
177
- }
178
- destroy() {
179
- this && (cancelAnimationFrame(this.requestRef), this.sizeObserver.disconnect(), this._resizeTimeoutId !== null && (clearTimeout(this._resizeTimeoutId), this._resizeTimeoutId = null), this.sceneState && (this.sceneState.renderer.dispose(), this.sceneState.meshes.forEach((e) => {
180
- e.geometry.dispose(), Array.isArray(e.material) ? e.material.forEach((o) => o.dispose()) : e.material.dispose();
181
- })), this._mouseFBO && this._mouseFBO.dispose(), this._proceduralTexture && this._proceduralTexture.dispose());
182
- }
183
- downloadAsPNG(e = "neat.png") {
184
- console.log("Downloading as PNG", this._ref);
185
- const o = this._ref.toDataURL("image/png");
186
- console.log("data", o), Te(o, e);
187
- }
188
- set speed(e) {
189
- this._speed = e / 20;
190
- }
191
- set horizontalPressure(e) {
192
- this._horizontalPressure = e / 4;
193
- }
194
- set verticalPressure(e) {
195
- this._verticalPressure = e / 4;
196
- }
197
- set waveFrequencyX(e) {
198
- this._waveFrequencyX = e * 0.04;
199
- }
200
- set waveFrequencyY(e) {
201
- this._waveFrequencyY = e * 0.04;
202
- }
203
- set waveAmplitude(e) {
204
- this._waveAmplitude = e * 0.75;
205
- }
206
- set colors(e) {
207
- this._colors = e, this._colorsChanged = !0;
208
- }
209
- set highlights(e) {
210
- this._highlights = e / 100;
211
- }
212
- set shadows(e) {
213
- this._shadows = e / 100;
214
- }
215
- set colorSaturation(e) {
216
- this._saturation = e / 10;
217
- }
218
- set colorBrightness(e) {
219
- this._brightness = e;
220
- }
221
- set colorBlending(e) {
222
- this._colorBlending = e / 10;
223
- }
224
- set grainScale(e) {
225
- this._grainScale = e == 0 ? 1 : e;
226
- }
227
- set grainIntensity(e) {
228
- this._grainIntensity = e;
229
- }
230
- set grainSparsity(e) {
231
- this._grainSparsity = e;
232
- }
233
- set grainSpeed(e) {
234
- this._grainSpeed = e;
235
- }
236
- set wireframe(e) {
237
- this._wireframe = e;
238
- }
239
- set resolution(e) {
240
- this.sceneState = this._initScene(e);
241
- }
242
- set backgroundColor(e) {
243
- this._backgroundColor = e;
244
- }
245
- set backgroundAlpha(e) {
246
- this._backgroundAlpha = e;
247
- }
248
- set yOffset(e) {
249
- this._yOffset = e;
250
- }
251
- get yOffsetWaveMultiplier() {
252
- return this._yOffsetWaveMultiplier * 1e3;
253
- }
254
- set yOffsetWaveMultiplier(e) {
255
- this._yOffsetWaveMultiplier = e / 1e3;
256
- }
257
- get yOffsetColorMultiplier() {
258
- return this._yOffsetColorMultiplier * 1e3;
259
- }
260
- set yOffsetColorMultiplier(e) {
261
- this._yOffsetColorMultiplier = e / 1e3;
262
- }
263
- get yOffsetFlowMultiplier() {
264
- return this._yOffsetFlowMultiplier * 1e3;
265
- }
266
- set yOffsetFlowMultiplier(e) {
267
- this._yOffsetFlowMultiplier = e / 1e3;
268
- }
269
- set flowDistortionA(e) {
270
- this._flowDistortionA = e;
271
- }
272
- set flowDistortionB(e) {
273
- this._flowDistortionB = e;
274
- }
275
- set flowScale(e) {
276
- this._flowScale = e;
277
- }
278
- set flowEase(e) {
279
- this._flowEase = e;
280
- }
281
- set flowEnabled(e) {
282
- this._flowEnabled = e;
283
- }
284
- get flowEnabled() {
285
- return this._flowEnabled;
286
- }
287
- set mouseDistortionStrength(e) {
288
- this._mouseDistortionStrength = Math.max(0, e);
289
- }
290
- set mouseDistortionRadius(e) {
291
- this._mouseDistortionRadius = Math.max(0.01, Math.min(e, 1)), this._updateBrushScale();
292
- }
293
- _updateBrushScale() {
294
- !this._mouseObjects || this._mouseObjects.length === 0 || (this._mouseBrushBaseScale = this._mouseDistortionRadius);
295
- }
296
- set mouseDecayRate(e) {
297
- this._mouseDecayRate = Math.max(0.9, Math.min(e, 0.99));
298
- }
299
- set mouseDarken(e) {
300
- this._mouseDarken = e;
301
- }
302
- set enableProceduralTexture(e) {
303
- this._enableProceduralTexture = e, e && !this._proceduralTexture && (this._textureNeedsUpdate = !0);
304
- }
305
- set textureVoidLikelihood(e) {
306
- this._textureVoidLikelihood = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
307
- }
308
- set textureVoidWidthMin(e) {
309
- this._textureVoidWidthMin = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
310
- }
311
- set textureVoidWidthMax(e) {
312
- this._textureVoidWidthMax = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
313
- }
314
- set textureBandDensity(e) {
315
- this._textureBandDensity = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
316
- }
317
- set textureColorBlending(e) {
318
- this._textureColorBlending = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
319
- }
320
- set textureSeed(e) {
321
- this._textureSeed = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
322
- }
323
- get textureEase() {
324
- return this._textureEase;
325
- }
326
- set textureEase(e) {
327
- this._textureEase = e;
328
- }
329
- set proceduralBackgroundColor(e) {
330
- this._proceduralBackgroundColor = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
331
- }
332
- set textureShapeTriangles(e) {
333
- this._textureShapeTriangles = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
334
- }
335
- set textureShapeCircles(e) {
336
- this._textureShapeCircles = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
337
- }
338
- set textureShapeBars(e) {
339
- this._textureShapeBars = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
340
- }
341
- set textureShapeSquiggles(e) {
342
- this._textureShapeSquiggles = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
343
- }
344
- _initScene(e) {
345
- const o = this._ref.width, t = this._ref.height;
346
- this.sceneState && this.sceneState.renderer && (this.sceneState.renderer.dispose(), this.sceneState.meshes.forEach((u) => {
347
- u.geometry.dispose(), Array.isArray(u.material) ? u.material.forEach((v) => v.dispose()) : u.material.dispose();
348
- }));
349
- const d = new n.WebGLRenderer({
350
- alpha: !0,
351
- preserveDrawingBuffer: !0,
352
- canvas: this._ref
353
- });
354
- d.setClearColor(16711680, 0.5), d.setSize(o, t, !1);
355
- const c = [], s = new n.Scene(), p = this._buildMaterial(o, t), g = new n.PlaneGeometry(U, D, 240 * e, 240 * e), f = new n.Mesh(g, p);
356
- f.rotation.x = -Math.PI / 3.5, f.position.z = -1, c.push(f), s.add(f);
357
- const m = new n.OrthographicCamera(0, 0, 0, 0, 0, 0);
358
- return m.position.z = 5, K(m, o, t), {
359
- renderer: d,
360
- camera: m,
361
- scene: s,
362
- meshes: c,
363
- resolution: e
364
- };
365
- }
366
- _buildMaterial(e, o) {
367
- const t = Array.from({ length: j }).map((s, p) => ({
368
- is_active: p < this._colors.length && this._colors[p].enabled ? 1 : 0,
369
- color: new n.Color(p < this._colors.length ? this._colors[p].color : 0),
370
- influence: p < this._colors.length && this._colors[p].influence || 0
371
- })), d = {
372
- u_time: { value: 0 },
373
- u_color_pressure: { value: new n.Vector2(this._horizontalPressure, this._verticalPressure) },
374
- u_wave_frequency_x: { value: this._waveFrequencyX },
375
- u_wave_frequency_y: { value: this._waveFrequencyY },
376
- u_wave_amplitude: { value: this._waveAmplitude },
377
- u_resolution: { value: new n.Vector2(e, o) },
378
- u_colors: { value: t },
379
- u_colors_count: { value: this._colors.length },
380
- u_plane_width: { value: U },
381
- u_plane_height: { value: D },
382
- u_shadows: { value: this._shadows },
383
- u_highlights: { value: this._highlights },
384
- u_grain_intensity: { value: this._grainIntensity },
385
- u_grain_sparsity: { value: this._grainSparsity },
386
- u_grain_scale: { value: this._grainScale },
387
- u_grain_speed: { value: this._grainSpeed },
388
- u_flow_distortion_a: { value: this._flowDistortionA },
389
- u_flow_distortion_b: { value: this._flowDistortionB },
390
- u_flow_scale: { value: this._flowScale },
391
- u_flow_ease: { value: this._flowEase },
392
- u_flow_enabled: { value: this._flowEnabled ? 1 : 0 },
393
- u_y_offset: { value: this._yOffset },
394
- u_y_offset_wave_multiplier: { value: this._yOffsetWaveMultiplier },
395
- u_y_offset_color_multiplier: { value: this._yOffsetColorMultiplier },
396
- u_y_offset_flow_multiplier: { value: this._yOffsetFlowMultiplier },
397
- u_mouse_distortion_strength: { value: this._mouseDistortionStrength },
398
- u_mouse_distortion_radius: { value: this._mouseDistortionRadius },
399
- u_mouse_darken: { value: this._mouseDarken },
400
- u_mouse_texture: { value: this._mouseFBO ? this._mouseFBO.texture : null },
401
- u_procedural_texture: { value: this._proceduralTexture },
402
- u_enable_procedural_texture: { value: this._enableProceduralTexture ? 1 : 0 },
403
- u_texture_ease: { value: this._textureEase },
404
- u_saturation: { value: this._saturation },
405
- u_brightness: { value: this._brightness },
406
- u_color_blending: { value: this._colorBlending }
407
- }, c = new n.ShaderMaterial({
408
- uniforms: d,
409
- vertexShader: H() + Y() + J() + Ce(),
410
- fragmentShader: H() + J() + Y() + Me()
411
- });
412
- return this._cachedUniforms = d, c.wireframe = be, c;
413
- }
414
- _setupMouseInteraction() {
415
- if (!this._ref)
416
- return;
417
- const e = this._ref.width, o = this._ref.height;
418
- this._mouseFBO = new n.WebGLRenderTarget(e / 2, o / 2), this._sceneMouse = new n.Scene();
419
- const t = o / 2, d = e / o;
420
- this._cameraMouse = new n.OrthographicCamera(
421
- -t * d,
422
- t * d,
423
- t,
424
- -t,
425
- 0,
426
- 1e4
427
- ), this._cameraMouse.position.set(0, 0, 100);
428
- const c = document.createElement("canvas");
429
- c.width = 128, c.height = 128;
430
- const s = c.getContext("2d");
431
- if (s) {
432
- const u = s.createRadialGradient(64, 64, 0, 64, 64, 64);
433
- u.addColorStop(0, "rgba(255,255,255,0.8)"), u.addColorStop(0.5, "rgba(255,255,255,0.4)"), u.addColorStop(1, "rgba(255,255,255,0)"), s.fillStyle = u, s.fillRect(0, 0, 128, 128);
434
- }
435
- const p = new n.CanvasTexture(c), g = new n.MeshBasicMaterial({
436
- map: p,
437
- transparent: !0,
438
- opacity: 1,
439
- depthTest: !1,
440
- blending: n.AdditiveBlending
441
- }), f = new n.PlaneGeometry(200, 200), m = 50;
442
- for (let u = 0; u < m; u++) {
443
- const v = new n.Mesh(f, g.clone());
444
- v.visible = !1, this._sceneMouse.add(v), this._mouseObjects.push({ mesh: v, active: !1 });
445
- }
446
- this._updateBrushScale(), this._ref.addEventListener("mousemove", this._onMouseMove.bind(this));
447
- }
448
- _onMouseMove(e) {
449
- if (!this._ref || !this._sceneMouse)
450
- return;
451
- const o = this._ref.getBoundingClientRect(), t = this._ref.width, d = this._ref.height;
452
- this._pendingMousePosition = {
453
- x: e.clientX - o.left - t / 2,
454
- y: -(e.clientY - o.top - d / 2)
455
- }, this._mouseUpdateScheduled || (this._mouseUpdateScheduled = !0, requestAnimationFrame(() => {
456
- if (this._mouseUpdateScheduled = !1, !this._pendingMousePosition)
457
- return;
458
- this._mouse.x = this._pendingMousePosition.x, this._mouse.y = this._pendingMousePosition.y;
459
- const c = this._mouseObjects[this._currentBrush];
460
- c.mesh.scale.set(this._mouseBrushBaseScale, this._mouseBrushBaseScale, 1), c.active = !0, c.mesh.visible = !0, c.mesh.position.set(this._mouse.x, this._mouse.y, 0), c.mesh.rotation.z = Math.random() * Math.PI * 2, c.mesh.material instanceof n.MeshBasicMaterial && (c.mesh.material.opacity = 1), this._currentBrush = (this._currentBrush + 1) % this._mouseObjects.length, this._pendingMousePosition = null;
461
- }));
462
- }
463
- _createProceduralTexture() {
464
- const o = document.createElement("canvas");
465
- o.width = 1024, o.height = 1024;
466
- const t = o.getContext("2d", { willReadFrequently: !0 });
467
- if (!t)
468
- return new n.Texture();
469
- let d = this._textureSeed;
470
- const c = this._textureSeed;
471
- function s() {
472
- const a = Math.sin(d++) * 1e4;
473
- return a - Math.floor(a);
474
- }
475
- const p = (a) => {
476
- d = c + a;
477
- }, g = this._colors.filter((a) => a.enabled).map((a) => a.color);
478
- if (g.length === 0)
479
- return new n.Texture();
480
- function f(a) {
481
- const l = parseInt(a.replace("#", ""), 16);
482
- return {
483
- r: l >> 16 & 255,
484
- g: l >> 8 & 255,
485
- b: l & 255
486
- };
487
- }
488
- function m(a, l, h) {
489
- return "#" + ((1 << 24) + (Math.round(a) << 16) + (Math.round(l) << 8) + Math.round(h)).toString(16).slice(1);
490
- }
491
- const u = () => {
492
- const a = g[Math.floor(s() * g.length)], l = g[Math.floor(s() * g.length)], h = s() * this._textureColorBlending, _ = f(a), S = f(l), B = _.r + (S.r - _.r) * h, N = _.g + (S.g - _.g) * h, L = _.b + (S.b - _.b) * h;
493
- return m(B, N, L);
494
- }, v = this._proceduralBackgroundColor || "#000000";
495
- t.fillStyle = v, t.fillRect(0, 0, 1024, 1024);
496
- const O = t.createLinearGradient(0, 0, 0, 1024);
497
- O.addColorStop(0, u()), O.addColorStop(1, u()), t.fillStyle = O, t.fillRect(0, 0, 1024, 1024);
498
- for (let a = 0; a < this._textureShapeTriangles; a++) {
499
- t.fillStyle = u(), t.beginPath();
500
- const l = s() * 1024, h = s() * 1024, _ = 100 + s() * 300;
501
- t.moveTo(l, h), t.lineTo(l + (s() - 0.5) * _, h + (s() - 0.5) * _), t.lineTo(l + (s() - 0.5) * _, h + (s() - 0.5) * _), t.fill();
502
- }
503
- for (let a = 0; a < this._textureShapeCircles; a++) {
504
- t.strokeStyle = u(), t.lineWidth = 10 + s() * 50, t.beginPath();
505
- const l = s() * 1024, h = s() * 1024, _ = 50 + s() * 150;
506
- t.arc(l, h, _, 0, Math.PI * 2), t.stroke();
507
- }
508
- for (let a = 0; a < this._textureShapeBars; a++)
509
- t.fillStyle = u(), t.save(), t.translate(s() * 1024, s() * 1024), t.rotate(s() * Math.PI), t.fillRect(-150, -25, 300, 50), t.restore();
510
- t.lineWidth = 15, t.lineCap = "round";
511
- for (let a = 0; a < this._textureShapeSquiggles; a++) {
512
- t.strokeStyle = u(), t.beginPath();
513
- let l = s() * 1024, h = s() * 1024;
514
- t.moveTo(l, h);
515
- for (let _ = 0; _ < 4; _++)
516
- t.bezierCurveTo(
517
- l + (s() - 0.5) * 300,
518
- h + (s() - 0.5) * 300,
519
- l + (s() - 0.5) * 300,
520
- h + (s() - 0.5) * 300,
521
- l + (s() - 0.5) * 300,
522
- h + (s() - 0.5) * 300
523
- ), l += (s() - 0.5) * 300, h += (s() - 0.5) * 300;
524
- t.stroke();
525
- }
526
- p(5e4);
527
- const M = document.createElement("canvas");
528
- M.width = 1024, M.height = 1024;
529
- const z = M.getContext("2d", { willReadFrequently: !0 });
530
- if (!z)
531
- return new n.Texture();
532
- z.fillStyle = v, z.fillRect(0, 0, 1024, 1024);
533
- let y = 0;
534
- const T = [];
535
- for (; y < 1024; )
536
- if (s() < this._textureVoidLikelihood) {
537
- const l = this._textureVoidWidthMin + s() * (this._textureVoidWidthMax - this._textureVoidWidthMin);
538
- T.push({ type: "void", x: y, width: l }), y += l;
539
- } else {
540
- const l = 50 + s() * 200;
541
- T.push({ type: "matter", x: y, width: l }), y += l;
542
- }
543
- for (const a of T)
544
- if (a.type === "matter") {
545
- const l = a.x, h = Math.min(a.x + a.width, 1024);
546
- let _ = l;
547
- for (; _ < h; ) {
548
- const S = (2 + s() * 20) / this._textureBandDensity, B = Math.floor(s() * 1024);
549
- z.drawImage(
550
- o,
551
- B,
552
- 0,
553
- S,
554
- 1024,
555
- _,
556
- 0,
557
- S,
558
- 1024
559
- ), _ += S;
560
- }
561
- }
562
- const C = new n.CanvasTexture(M);
563
- return C.minFilter = n.LinearMipmapLinearFilter, C.magFilter = n.LinearFilter, C.wrapS = n.RepeatWrapping, C.wrapT = n.RepeatWrapping, C.anisotropy = 16, C.needsUpdate = !0, C;
564
- }
565
- }
566
- function K(i, e, o) {
567
- const c = e * o / 1e6 * U * D / 1.5, s = e / o, p = Math.sqrt(c * s), g = c / p;
568
- let f = -U / 2, m = Math.min((f + p) / 1.5, U / 2), u = D / 4, v = Math.max((u - g) / 2, -D / 4);
569
- if (s < 1) {
570
- const z = s;
571
- f = f * z, m = m * z;
572
- const y = 1.05;
573
- f = f * y, m = m * y, u = u * y, v = v * y;
574
- }
575
- const O = -100, M = 1e3;
576
- i instanceof n.OrthographicCamera ? (i.left = f, i.right = m, i.top = u, i.bottom = v, i.near = O, i.far = M, i.updateProjectionMatrix()) : i instanceof n.PerspectiveCamera && (i.aspect = e / o, i.updateProjectionMatrix());
577
- }
578
- let k = null, A = null;
579
- function Ce() {
580
- return k || (k = `
581
- void main() {
1
+ const he = `void main() {
582
2
  vUv = uv;
583
3
 
584
4
  // SCROLLING LOGIC
@@ -614,13 +34,14 @@ void main() {
614
34
  }
615
35
  }
616
36
 
617
- // Pass the standard flow UV to fragment shader (for mouse/texture)
37
+ // Pass the standard flow UV to fragment shader (for texture)
618
38
  vFlowUv = flowUv;
619
39
 
620
40
  // 3. COLOR MIXING
621
41
  // We take the computed flow UVs and apply the color offset
622
42
  // Scale by plane height to match wave offset speed (world space vs UV space)
623
43
  vec3 color = u_colors[0].color;
44
+ // ...
624
45
  vec2 adjustedUv = flowUv;
625
46
  adjustedUv.y += colorOffset / u_plane_height; // Scroll the color mixing pattern
626
47
 
@@ -628,22 +49,24 @@ void main() {
628
49
  const float minNoise = .0;
629
50
  const float maxNoise = .9;
630
51
 
631
- for (int i = 1; i < u_colors_count; i++) {
632
- if(u_colors[i].is_active > 0.5){
633
- float noiseFlow = (1. + float(i)) / 30.;
634
- float noiseSpeed = (1. + float(i)) * 0.11;
635
- float noiseSeed = 13. + float(i) * 7.;
636
-
637
- float noise = snoise(
638
- vec3(
639
- noise_cord.x * u_color_pressure.x + u_time * noiseFlow * 2.,
640
- noise_cord.y * u_color_pressure.y,
641
- u_time * noiseSpeed
642
- ) + noiseSeed
643
- ) - (.1 * float(i)) + (.5 * u_color_blending);
644
-
645
- noise = clamp(minNoise, maxNoise + float(i) * 0.02, noise);
646
- color = mix(color, u_colors[i].color, smoothstep(0.0, u_color_blending, noise));
52
+ for (int i = 1; i < 6; i++) {
53
+ if (i < u_colors_count) {
54
+ if (u_colors[i].is_active > 0.5) {
55
+ float noiseFlow = (1. + float(i)) / 30.;
56
+ float noiseSpeed = (1. + float(i)) * 0.11;
57
+ float noiseSeed = 13. + float(i) * 7.;
58
+
59
+ float noise = snoise(
60
+ vec3(
61
+ noise_cord.x * u_color_pressure.x + u_time * noiseFlow * 2.,
62
+ noise_cord.y * u_color_pressure.y,
63
+ u_time * noiseSpeed
64
+ ) + noiseSeed
65
+ ) - (.1 * float(i)) + (.5 * u_color_blending);
66
+
67
+ noise = clamp(noise, minNoise, maxNoise + float(i) * 0.02);
68
+ color = mix(color, u_colors[i].color, smoothstep(0.0, u_color_blending, noise));
69
+ }
647
70
  }
648
71
  }
649
72
 
@@ -654,11 +77,7 @@ void main() {
654
77
  gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0);
655
78
  v_new_position = gl_Position;
656
79
  }
657
- `, k);
658
- }
659
- function Me() {
660
- return A || (A = `
661
- float random(vec2 p) {
80
+ `, de = `float random(vec2 p) {
662
81
  return fract(sin(dot(p, vec2(12.9898,78.233))) * 43758.5453);
663
82
  }
664
83
 
@@ -675,20 +94,8 @@ float fbm(vec3 x) {
675
94
  }
676
95
 
677
96
  void main() {
678
- // MOUSE DISTORTION
679
97
  vec2 finalUv = vFlowUv;
680
98
 
681
- if (u_mouse_distortion_strength > 0.0) {
682
- vec4 mouseColor = texture2D(u_mouse_texture, vUv);
683
- float mouseValue = mouseColor.r;
684
-
685
- if (mouseValue > 0.001) {
686
- float distortionAmount = mouseValue * u_mouse_distortion_strength;
687
- vec2 mouseDisp = vec2(distortionAmount, distortionAmount);
688
- finalUv -= mouseDisp;
689
- }
690
- }
691
-
692
99
  vec3 baseColor;
693
100
 
694
101
  if (u_enable_procedural_texture > 0.5) {
@@ -721,61 +128,69 @@ void main() {
721
128
  vec3 color = baseColor;
722
129
 
723
130
  // Post-processing
724
- color += pow(v_displacement_amount, 1.0) * u_highlights;
725
- color -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;
131
+ color += v_displacement_amount * u_highlights;
132
+ // Replace pow() with direct multiplication to avoid negative base undefined behavior in GLSL
133
+ float shadowFactor = 1.0 - v_displacement_amount;
134
+ color -= shadowFactor * shadowFactor * u_shadows;
726
135
  color = saturation(color, 1.0 + u_saturation);
727
136
  color = color * u_brightness;
728
137
 
729
138
  // Grain
730
139
  vec2 noiseCoords = gl_FragCoord.xy / u_grain_scale;
731
- float grain = (u_grain_speed != 0.0) ? fbm(vec3(noiseCoords, u_time * u_grain_speed)) : fbm(vec3(noiseCoords, 0.0));
140
+ float grain = 0.0;
141
+
142
+ // Completely bypass expensive noise generation if grain is disabled
143
+ if (u_grain_intensity > 0.0) {
144
+ if (u_grain_speed != 0.0) {
145
+ grain = fbm(vec3(noiseCoords, u_time * u_grain_speed));
146
+ } else {
147
+ grain = fbm(vec3(noiseCoords, 0.0));
148
+ }
732
149
 
733
- grain = grain * 0.5 + 0.5;
734
- grain -= 0.5;
735
- grain = (grain > u_grain_sparsity) ? grain : 0.0;
736
- grain *= u_grain_intensity;
150
+ grain = grain * 0.5 + 0.5;
151
+ grain -= 0.5;
152
+ grain = (grain > u_grain_sparsity) ? grain : 0.0;
153
+ grain *= u_grain_intensity;
154
+ }
737
155
 
738
156
  color += vec3(grain);
739
157
 
740
158
  gl_FragColor = vec4(color, 1.0);
741
159
  }
742
- `, A);
743
- }
744
- let R = null;
745
- const H = () => R || (R = `
746
- precision highp float;
160
+ `;
161
+ function me() {
162
+ return `precision highp float;
747
163
 
748
- struct Color {
749
- float is_active;
750
- vec3 color;
751
- float value;
752
- };
164
+ attribute vec3 position;
165
+ attribute vec3 normal;
166
+ attribute vec2 uv;
753
167
 
754
- uniform float u_grain_intensity;
755
- uniform float u_grain_sparsity;
756
- uniform float u_grain_scale;
757
- uniform float u_grain_speed;
758
- uniform float u_time;
168
+ uniform mat4 modelViewMatrix;
169
+ uniform mat4 projectionMatrix;
759
170
 
760
- uniform float u_wave_amplitude;
761
- uniform float u_wave_frequency_x;
762
- uniform float u_wave_frequency_y;
171
+ varying vec2 vUv;
172
+ varying vec2 vFlowUv;
173
+ varying vec4 v_new_position;
174
+ varying vec3 v_color;
175
+ varying float v_displacement_amount;
763
176
 
177
+ uniform float u_time;
178
+ uniform vec2 u_resolution;
764
179
  uniform vec2 u_color_pressure;
765
-
180
+ uniform float u_wave_frequency_x;
181
+ uniform float u_wave_frequency_y;
182
+ uniform float u_wave_amplitude;
766
183
  uniform float u_plane_width;
767
184
  uniform float u_plane_height;
768
-
769
- uniform float u_shadows;
770
- uniform float u_highlights;
771
- uniform float u_saturation;
772
- uniform float u_brightness;
773
-
774
185
  uniform float u_color_blending;
775
186
 
776
187
  uniform int u_colors_count;
777
- uniform Color u_colors[6];
778
- uniform vec2 u_resolution;
188
+ struct ColorStop {
189
+ float is_active;
190
+ vec3 color;
191
+ float influence;
192
+ };
193
+ uniform ColorStop u_colors[6];
779
194
 
780
195
  uniform float u_y_offset;
781
196
  uniform float u_y_offset_wave_multiplier;
@@ -788,28 +203,44 @@ uniform float u_flow_distortion_b;
788
203
  uniform float u_flow_scale;
789
204
  uniform float u_flow_ease;
790
205
  uniform float u_flow_enabled;
791
-
792
- // Mouse interaction uniforms
793
- uniform float u_mouse_distortion_strength;
794
- uniform float u_mouse_distortion_radius;
795
- uniform float u_mouse_darken;
796
- uniform sampler2D u_mouse_texture;
797
-
798
- // Procedural texture uniforms
799
- uniform sampler2D u_procedural_texture;
800
- uniform float u_enable_procedural_texture;
801
- uniform float u_texture_ease;
206
+ `;
207
+ }
208
+ function pe() {
209
+ return `precision highp float;
802
210
 
803
211
  varying vec2 vUv;
804
212
  varying vec2 vFlowUv;
805
- varying vec4 v_new_position;
806
213
  varying vec3 v_color;
807
214
  varying float v_displacement_amount;
808
215
 
809
- `, R);
810
- let I = null;
811
- const Y = () => I || (I = `
216
+ uniform float u_time;
217
+ uniform float u_plane_height;
218
+
219
+ uniform float u_shadows;
220
+ uniform float u_highlights;
221
+ uniform float u_saturation;
222
+ uniform float u_brightness;
223
+ uniform float u_grain_intensity;
224
+ uniform float u_grain_sparsity;
225
+ uniform float u_grain_scale;
226
+ uniform float u_grain_speed;
227
+
228
+ uniform float u_y_offset;
229
+ uniform float u_y_offset_color_multiplier;
812
230
 
231
+ // Flow field uniforms
232
+ uniform float u_flow_distortion_a;
233
+ uniform float u_flow_distortion_b;
234
+ uniform float u_flow_scale;
235
+
236
+ // Procedural texture uniforms
237
+ uniform sampler2D u_procedural_texture;
238
+ uniform float u_enable_procedural_texture;
239
+ uniform float u_texture_ease;
240
+ `;
241
+ }
242
+ function Y() {
243
+ return `
813
244
  // 1. REPLACEMENT PERMUTE:
814
245
  // Uses a hash function (fract/sin) instead of a modular lookup table.
815
246
  vec4 permute(vec4 x) {
@@ -961,85 +392,680 @@ float cnoise(vec3 P)
961
392
  float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
962
393
  return 2.2 * n_xyz;
963
394
  }
964
- `, I);
965
- let W = null;
966
- const J = () => W || (W = `
967
-
395
+ `;
396
+ }
397
+ function j() {
398
+ return `
968
399
  vec3 saturation(vec3 rgb, float adjustment) {
969
400
  const vec3 W = vec3(0.2125, 0.7154, 0.0721);
970
401
  vec3 intensity = vec3(dot(rgb, W));
971
402
  return mix(intensity, rgb, adjustment);
972
403
  }
973
-
974
- float saturation(vec3 rgb)
975
- {
976
- vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
977
- vec4 p = mix(vec4(rgb.bg, K.wz), vec4(rgb.gb, K.xy), step(rgb.b, rgb.g));
978
- vec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));
979
-
980
- float d = q.x - min(q.w, q.y);
981
- float e = 1.0e-10;
982
- return abs(6.0 * d + e);
404
+ `;
983
405
  }
984
-
985
- // get saturation of a color in values between 0 and 1
986
- float getSaturation(vec3 color) {
987
- float max = max(color.r, max(color.g, color.b));
988
- float min = min(color.r, min(color.g, color.b));
989
- return (max - min) / max;
406
+ class J {
407
+ elements;
408
+ constructor() {
409
+ this.elements = new Float32Array([
410
+ 1,
411
+ 0,
412
+ 0,
413
+ 0,
414
+ 0,
415
+ 1,
416
+ 0,
417
+ 0,
418
+ 0,
419
+ 0,
420
+ 1,
421
+ 0,
422
+ 0,
423
+ 0,
424
+ 0,
425
+ 1
426
+ ]);
427
+ }
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;
430
+ }
431
+ 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;
434
+ }
990
435
  }
991
-
992
- vec3 rgb2hsv(vec3 c)
993
- {
994
- vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
995
- vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
996
- vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
997
-
998
- float d = q.x - min(q.w, q.y);
999
- float e = 1.0e-10;
1000
- return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
436
+ class ge {
437
+ left;
438
+ right;
439
+ top;
440
+ bottom;
441
+ near;
442
+ far;
443
+ position;
444
+ 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();
447
+ }
448
+ 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;
450
+ this.projectionMatrix.elements = new Float32Array([
451
+ 2 * e,
452
+ 0,
453
+ 0,
454
+ 0,
455
+ 0,
456
+ 2 * i,
457
+ 0,
458
+ 0,
459
+ 0,
460
+ 0,
461
+ -2 * o,
462
+ 0,
463
+ -t,
464
+ -b,
465
+ -y,
466
+ 1
467
+ ]);
468
+ }
469
+ }
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);
473
+ if (p < 1) {
474
+ const E = p;
475
+ x = x * E, h = h * E;
476
+ const g = 1.05;
477
+ x = x * g, h = h * g, w = w * g, R = R * g;
478
+ }
479
+ a.left = x, a.right = h, a.top = w, a.bottom = R, a.near = -100, a.far = 1e3, a.updateProjectionMatrix();
1001
480
  }
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;
485
+ 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);
488
+ }
489
+ }
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, _);
494
+ }
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);
499
+ }
500
+ return {
501
+ position: new Float32Array(w),
502
+ normal: new Float32Array(R),
503
+ uv: new Float32Array(E),
504
+ index: g ? new Uint32Array(h) : new Uint16Array(h),
505
+ wireframeIndex: g ? new Uint32Array(A) : new Uint16Array(A)
506
+ };
507
+ }
508
+ console.info(
509
+ `%c\u{1F308} Neat Gradients%c
1002
510
 
1003
- vec3 hsv2rgb(vec3 c)
1004
- {
1005
- vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
1006
- vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
1007
- return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
511
+ Licensed under MIT + The Commons Clause.
512
+ Free for personal and commercial use.
513
+ Selling this software or its derivatives is strictly prohibited.
514
+ https://neat.firecms.co`,
515
+ "font-weight: bold; font-size: 14px; color: #FF5772;",
516
+ "color: inherit;"
517
+ );
518
+ const $ = 50, K = 80, O = 6, ye = Se();
519
+ class Te {
520
+ _ref;
521
+ _speed = -1;
522
+ _horizontalPressure = -1;
523
+ _verticalPressure = -1;
524
+ _waveFrequencyX = -1;
525
+ _waveFrequencyY = -1;
526
+ _waveAmplitude = -1;
527
+ _shadows = -1;
528
+ _highlights = -1;
529
+ _saturation = -1;
530
+ _brightness = -1;
531
+ _grainScale = -1;
532
+ _grainIntensity = -1;
533
+ _grainSparsity = -1;
534
+ _grainSpeed = -1;
535
+ _colorBlending = -1;
536
+ _colors = [];
537
+ _wireframe = !1;
538
+ _backgroundColor = "#FFFFFF";
539
+ _backgroundColorRgb = [1, 1, 1];
540
+ _backgroundAlpha = 1;
541
+ _flowDistortionA = 0;
542
+ _flowDistortionB = 0;
543
+ _flowScale = 1;
544
+ _flowEase = 0;
545
+ _flowEnabled = !0;
546
+ glState;
547
+ _enableProceduralTexture = !1;
548
+ _textureVoidLikelihood = 0.45;
549
+ _textureVoidWidthMin = 200;
550
+ _textureVoidWidthMax = 486;
551
+ _textureBandDensity = 2.15;
552
+ _textureColorBlending = 0.01;
553
+ _textureSeed = 333;
554
+ _textureEase = 0.5;
555
+ _proceduralTexture = null;
556
+ _proceduralBackgroundColor = "#000000";
557
+ _textureShapeTriangles = 20;
558
+ _textureShapeCircles = 15;
559
+ _textureShapeBars = 15;
560
+ _textureShapeSquiggles = 10;
561
+ requestRef = -1;
562
+ sizeObserver;
563
+ _initialized = !1;
564
+ _linkElement = null;
565
+ _cachedColorRgb = [];
566
+ _yOffset = 0;
567
+ _yOffsetWaveMultiplier = 4e-3;
568
+ _yOffsetColorMultiplier = 4e-3;
569
+ _yOffsetFlowMultiplier = 4e-3;
570
+ _resizeTimeoutId = null;
571
+ _textureNeedsUpdate = !1;
572
+ _linkCheckCounter = 0;
573
+ _colorsChanged = !0;
574
+ _uniformsDirty = !0;
575
+ _textureDirty = !0;
576
+ constructor(e) {
577
+ const {
578
+ ref: i,
579
+ speed: o = 4,
580
+ horizontalPressure: t = 3,
581
+ verticalPressure: b = 3,
582
+ waveFrequencyX: y = 5,
583
+ waveFrequencyY: n = 5,
584
+ waveAmplitude: p = 3,
585
+ colors: v,
586
+ highlights: T = 4,
587
+ shadows: x = 4,
588
+ colorSaturation: h = 0,
589
+ colorBrightness: w = 1,
590
+ colorBlending: R = 5,
591
+ grainScale: E = 2,
592
+ grainIntensity: g = 0.55,
593
+ grainSparsity: A = 0,
594
+ grainSpeed: c = 0.1,
595
+ wireframe: l = !1,
596
+ backgroundColor: m = "#FFFFFF",
597
+ backgroundAlpha: s = 1,
598
+ resolution: f = 1,
599
+ seed: _,
600
+ yOffset: d = 0,
601
+ yOffsetWaveMultiplier: z = 4,
602
+ yOffsetColorMultiplier: C = 4,
603
+ yOffsetFlowMultiplier: F = 4,
604
+ flowDistortionA: M = 0,
605
+ flowDistortionB: N = 0,
606
+ flowScale: W = 1,
607
+ flowEase: D = 0,
608
+ flowEnabled: S = !0,
609
+ enableProceduralTexture: U = !1,
610
+ textureVoidLikelihood: Q = 0.45,
611
+ textureVoidWidthMin: ee = 200,
612
+ textureVoidWidthMax: te = 486,
613
+ textureBandDensity: ie = 2.15,
614
+ textureColorBlending: re = 0.01,
615
+ textureSeed: oe = 333,
616
+ textureEase: se = 0.5,
617
+ proceduralBackgroundColor: ne = "#000000",
618
+ textureShapeTriangles: ae = 20,
619
+ textureShapeCircles: le = 15,
620
+ textureShapeBars: ue = 15,
621
+ textureShapeSquiggles: fe = 10
622
+ } = 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) {
630
+ this._colorsChanged = !1;
631
+ for (let P = 0; P < O; P++)
632
+ 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);
635
+ } else
636
+ r.uniform1f(u.uniforms[`u_colors[${P}].is_active`], 0);
637
+ r.uniform1i(u.uniforms.u_colors_count, O);
638
+ }
639
+ }
640
+ r.clearColor(
641
+ this._backgroundColorRgb[0],
642
+ this._backgroundColorRgb[1],
643
+ this._backgroundColorRgb[2],
644
+ 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);
651
+ };
652
+ this.sizeObserver = new ResizeObserver(() => {
653
+ this._resizeTimeoutId !== null && clearTimeout(this._resizeTimeoutId), this._resizeTimeoutId = window.setTimeout(() => {
654
+ ce(), this._resizeTimeoutId = null;
655
+ }, 100);
656
+ }), this.sizeObserver.observe(i), q();
657
+ }
658
+ destroy() {
659
+ 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) {
660
+ const e = this.glState.gl;
661
+ e.deleteProgram(this.glState.program), e.deleteBuffer(this.glState.buffers.position), e.deleteBuffer(this.glState.buffers.normal), e.deleteBuffer(this.glState.buffers.uv), e.deleteBuffer(this.glState.buffers.index), e.deleteBuffer(this.glState.buffers.wireframeIndex);
662
+ }
663
+ this._proceduralTexture && this.glState && this.glState.gl.deleteTexture(this._proceduralTexture);
664
+ }
665
+ downloadAsPNG(e = "neat.png") {
666
+ const i = this._ref.toDataURL("image/png");
667
+ be(i, e);
668
+ }
669
+ set speed(e) {
670
+ this._uniformsDirty = !0, this._speed = e / 20;
671
+ }
672
+ set horizontalPressure(e) {
673
+ this._uniformsDirty = !0, this._horizontalPressure = e / 4;
674
+ }
675
+ set verticalPressure(e) {
676
+ this._uniformsDirty = !0, this._verticalPressure = e / 4;
677
+ }
678
+ set waveFrequencyX(e) {
679
+ this._uniformsDirty = !0, this._waveFrequencyX = e * 0.04;
680
+ }
681
+ set waveFrequencyY(e) {
682
+ this._uniformsDirty = !0, this._waveFrequencyY = e * 0.04;
683
+ }
684
+ set waveAmplitude(e) {
685
+ this._uniformsDirty = !0, this._waveAmplitude = e * 0.75;
686
+ }
687
+ set colors(e) {
688
+ this._uniformsDirty = !0, this._colors = e, this._cachedColorRgb = e.map((i) => this._hexToRgb(i.color)), this._colorsChanged = !0;
689
+ }
690
+ set highlights(e) {
691
+ this._uniformsDirty = !0, this._highlights = e / 100;
692
+ }
693
+ set shadows(e) {
694
+ this._uniformsDirty = !0, this._shadows = e / 100;
695
+ }
696
+ set colorSaturation(e) {
697
+ this._uniformsDirty = !0, this._saturation = e / 10;
698
+ }
699
+ set colorBrightness(e) {
700
+ this._uniformsDirty = !0, this._brightness = e;
701
+ }
702
+ set colorBlending(e) {
703
+ this._uniformsDirty = !0, this._colorBlending = e / 10;
704
+ }
705
+ set grainScale(e) {
706
+ this._uniformsDirty = !0, this._grainScale = e == 0 ? 1 : e;
707
+ }
708
+ set grainIntensity(e) {
709
+ this._uniformsDirty = !0, this._grainIntensity = e;
710
+ }
711
+ set grainSparsity(e) {
712
+ this._uniformsDirty = !0, this._grainSparsity = e;
713
+ }
714
+ set grainSpeed(e) {
715
+ this._uniformsDirty = !0, this._grainSpeed = e;
716
+ }
717
+ set wireframe(e) {
718
+ this._uniformsDirty = !0, this._wireframe = e;
719
+ }
720
+ set resolution(e) {
721
+ 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);
724
+ }
725
+ this.glState = this._initScene(e);
726
+ }
727
+ set backgroundColor(e) {
728
+ this._uniformsDirty = !0, this._backgroundColor = e, this._backgroundColorRgb = this._hexToRgb(e);
729
+ }
730
+ set backgroundAlpha(e) {
731
+ this._uniformsDirty = !0, this._backgroundAlpha = e;
732
+ }
733
+ set yOffset(e) {
734
+ this._uniformsDirty = !0, this._yOffset = e;
735
+ }
736
+ get yOffsetWaveMultiplier() {
737
+ return this._yOffsetWaveMultiplier * 1e3;
738
+ }
739
+ set yOffsetWaveMultiplier(e) {
740
+ this._uniformsDirty = !0, this._yOffsetWaveMultiplier = e / 1e3;
741
+ }
742
+ get yOffsetColorMultiplier() {
743
+ return this._yOffsetColorMultiplier * 1e3;
744
+ }
745
+ set yOffsetColorMultiplier(e) {
746
+ this._uniformsDirty = !0, this._yOffsetColorMultiplier = e / 1e3;
747
+ }
748
+ get yOffsetFlowMultiplier() {
749
+ return this._yOffsetFlowMultiplier * 1e3;
750
+ }
751
+ set yOffsetFlowMultiplier(e) {
752
+ this._uniformsDirty = !0, this._yOffsetFlowMultiplier = e / 1e3;
753
+ }
754
+ set flowDistortionA(e) {
755
+ this._uniformsDirty = !0, this._flowDistortionA = e;
756
+ }
757
+ set flowDistortionB(e) {
758
+ this._uniformsDirty = !0, this._flowDistortionB = e;
759
+ }
760
+ set flowScale(e) {
761
+ this._uniformsDirty = !0, this._flowScale = e;
762
+ }
763
+ set flowEase(e) {
764
+ this._uniformsDirty = !0, this._flowEase = e;
765
+ }
766
+ set flowEnabled(e) {
767
+ this._uniformsDirty = !0, this._flowEnabled = e;
768
+ }
769
+ get flowEnabled() {
770
+ return this._flowEnabled;
771
+ }
772
+ set enableProceduralTexture(e) {
773
+ this._uniformsDirty = !0, this._enableProceduralTexture = e, e && !this._proceduralTexture && (this._textureNeedsUpdate = !0);
774
+ }
775
+ set textureVoidLikelihood(e) {
776
+ this._uniformsDirty = !0, this._textureVoidLikelihood = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
777
+ }
778
+ set textureVoidWidthMin(e) {
779
+ this._uniformsDirty = !0, this._textureVoidWidthMin = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
780
+ }
781
+ set textureVoidWidthMax(e) {
782
+ this._uniformsDirty = !0, this._textureVoidWidthMax = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
783
+ }
784
+ set textureBandDensity(e) {
785
+ this._uniformsDirty = !0, this._textureBandDensity = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
786
+ }
787
+ set textureColorBlending(e) {
788
+ this._uniformsDirty = !0, this._textureColorBlending = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
789
+ }
790
+ set textureSeed(e) {
791
+ this._uniformsDirty = !0, this._textureSeed = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
792
+ }
793
+ get textureEase() {
794
+ return this._textureEase;
795
+ }
796
+ set textureEase(e) {
797
+ this._uniformsDirty = !0, this._textureEase = e;
798
+ }
799
+ set proceduralBackgroundColor(e) {
800
+ this._uniformsDirty = !0, this._proceduralBackgroundColor = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
801
+ }
802
+ set textureShapeTriangles(e) {
803
+ this._uniformsDirty = !0, this._textureShapeTriangles = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
804
+ }
805
+ set textureShapeCircles(e) {
806
+ this._uniformsDirty = !0, this._textureShapeCircles = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
807
+ }
808
+ set textureShapeBars(e) {
809
+ this._uniformsDirty = !0, this._textureShapeBars = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
810
+ }
811
+ set textureShapeSquiggles(e) {
812
+ this._uniformsDirty = !0, this._textureShapeSquiggles = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
813
+ }
814
+ _hexToRgb(e) {
815
+ const i = parseInt(e.replace("#", ""), 16);
816
+ return [
817
+ (i >> 16 & 255) / 255,
818
+ (i >> 8 & 255) / 255,
819
+ (i & 255) / 255
820
+ ];
821
+ }
822
+ _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 });
824
+ if (!t)
825
+ 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);
829
+ const x = t.createBuffer();
830
+ t.bindBuffer(t.ARRAY_BUFFER, x), t.bufferData(t.ARRAY_BUFFER, y, t.STATIC_DRAW);
831
+ 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);
835
+ 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() + `
838
+ ` + Y() + `
839
+ ` + j() + `
840
+ ` + he, g = t.createShader(t.VERTEX_SHADER);
841
+ 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(`
843
+ `)), console.log("VERTEX_SHADER_ERROR_END"));
844
+ const A = pe() + `
845
+ ` + j() + `
846
+ ` + 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(`
850
+ `)), 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);
857
+ const d = new J();
858
+ 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");
864
+ 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");
868
+ t.uniform1i(N, O);
869
+ const W = [
870
+ "u_time",
871
+ "u_resolution",
872
+ "u_color_pressure",
873
+ "u_wave_frequency_x",
874
+ "u_wave_frequency_y",
875
+ "u_wave_amplitude",
876
+ "u_colors_count",
877
+ "u_plane_width",
878
+ "u_plane_height",
879
+ "u_shadows",
880
+ "u_highlights",
881
+ "u_grain_intensity",
882
+ "u_grain_sparsity",
883
+ "u_grain_scale",
884
+ "u_grain_speed",
885
+ "u_flow_distortion_a",
886
+ "u_flow_distortion_b",
887
+ "u_flow_scale",
888
+ "u_flow_ease",
889
+ "u_flow_enabled",
890
+ "u_y_offset",
891
+ "u_y_offset_wave_multiplier",
892
+ "u_y_offset_color_multiplier",
893
+ "u_y_offset_flow_multiplier",
894
+ "u_procedural_texture",
895
+ "u_enable_procedural_texture",
896
+ "u_texture_ease",
897
+ "u_saturation",
898
+ "u_brightness",
899
+ "u_color_blending"
900
+ ], D = {
901
+ attributes: { position: s, normal: f, uv: _ },
902
+ uniforms: {}
903
+ };
904
+ W.forEach((S) => {
905
+ D.uniforms[S] = t.getUniformLocation(l, S);
906
+ });
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`);
909
+ 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
+ gl: t,
911
+ program: l,
912
+ buffers: {
913
+ position: T,
914
+ normal: x,
915
+ uv: h,
916
+ index: w,
917
+ wireframeIndex: R
918
+ },
919
+ locations: D,
920
+ camera: m,
921
+ indexCount: p.length,
922
+ wireframeIndexCount: v.length,
923
+ indexType: p instanceof Uint32Array ? t.UNSIGNED_INT : t.UNSIGNED_SHORT
924
+ };
925
+ }
926
+ _createProceduralTexture(e) {
927
+ const o = document.createElement("canvas");
928
+ o.width = 1024, o.height = 1024;
929
+ const t = o.getContext("2d", { willReadFrequently: !0 });
930
+ if (!t)
931
+ return null;
932
+ let b = this._textureSeed;
933
+ const y = this._textureSeed;
934
+ function n() {
935
+ const s = Math.sin(b++) * 1e4;
936
+ return s - Math.floor(s);
937
+ }
938
+ const p = (s) => {
939
+ b = y + s;
940
+ }, v = this._colors.filter((s) => s.enabled).map((s) => s.color);
941
+ if (v.length === 0)
942
+ return null;
943
+ function T(s) {
944
+ const f = parseInt(s.replace("#", ""), 16);
945
+ return {
946
+ r: f >> 16 & 255,
947
+ g: f >> 8 & 255,
948
+ b: f & 255
949
+ };
950
+ }
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");
953
+ }
954
+ 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);
959
+ const R = t.createLinearGradient(0, 0, 0, 1024);
960
+ 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++) {
962
+ 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();
965
+ }
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();
970
+ }
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();
973
+ t.lineWidth = 15, t.lineCap = "round";
974
+ for (let s = 0; s < this._textureShapeSquiggles; s++) {
975
+ t.strokeStyle = h(), t.beginPath();
976
+ let f = n() * 1024, _ = n() * 1024;
977
+ t.moveTo(f, _);
978
+ for (let d = 0; d < 4; d++)
979
+ 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;
987
+ t.stroke();
988
+ }
989
+ p(5e4);
990
+ const E = document.createElement("canvas");
991
+ E.width = 1024, E.height = 1024;
992
+ const g = E.getContext("2d", { willReadFrequently: !0 });
993
+ if (!g)
994
+ return null;
995
+ g.fillStyle = w, g.fillRect(0, 0, 1024, 1024);
996
+ let A = 0;
997
+ const c = [];
998
+ 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;
1002
+ } else {
1003
+ const f = 50 + n() * 200;
1004
+ c.push({ type: "matter", x: A, width: f }), A += f;
1005
+ }
1006
+ for (const s of c)
1007
+ if (s.type === "matter") {
1008
+ const f = s.x, _ = Math.min(s.x + s.width, 1024);
1009
+ let d = f;
1010
+ for (; d < _; ) {
1011
+ const z = (2 + n() * 20) / this._textureBandDensity, C = Math.floor(n() * 1024);
1012
+ g.drawImage(
1013
+ o,
1014
+ C,
1015
+ 0,
1016
+ z,
1017
+ 1024,
1018
+ d,
1019
+ 0,
1020
+ z,
1021
+ 1024
1022
+ ), d += z;
1023
+ }
1024
+ }
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);
1027
+ const m = e.getExtension("EXT_texture_filter_anisotropic") || e.getExtension("MOZ_EXT_texture_filter_anisotropic") || e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
1028
+ 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));
1031
+ }
1032
+ return l;
1033
+ }
1008
1034
  }
1009
- `, W), Z = (i) => {
1010
- i.id = Q, i.href = "https://neat.firecms.co", i.target = "_blank", i.style.position = "absolute", i.style.display = "block", i.style.bottom = "0", i.style.right = "0", i.style.padding = "10px", i.style.color = "#dcdcdc", i.style.opacity = "0.8", i.style.fontFamily = "sans-serif", i.style.fontSize = "16px", i.style.fontWeight = "bold", i.style.textDecoration = "none", i.style.zIndex = "10000", i.innerHTML = "NEAT";
1011
- }, Pe = (i) => {
1012
- const e = i.parentElement?.getElementsByTagName("a");
1013
- if (e) {
1014
- for (let t = 0; t < e.length; t++)
1015
- if (e[t].id === Q)
1016
- return Z(e[t]), e[t];
1017
- }
1018
- const o = document.createElement("a");
1019
- return Z(o), i.parentElement?.appendChild(o), o;
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;
1039
+ 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;
1043
+ }
1044
+ const i = document.createElement("a");
1045
+ return Z(i), e?.appendChild(i), i;
1020
1046
  };
1021
- function Oe() {
1022
- const i = new Date(), e = i.getMinutes(), o = i.getSeconds();
1023
- return e * 60 + o;
1047
+ function we() {
1048
+ const a = new Date(), e = a.getMinutes(), i = a.getSeconds();
1049
+ return e * 60 + i;
1024
1050
  }
1025
- function Fe(i = 6) {
1051
+ function Se(a = 6) {
1026
1052
  const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
1027
- let o = "";
1028
- for (let t = 0; t < i; t++) {
1029
- const d = Math.floor(Math.random() * e.length);
1030
- o += e.charAt(d);
1053
+ let i = "";
1054
+ for (let o = 0; o < a; o++) {
1055
+ const t = Math.floor(Math.random() * e.length);
1056
+ i += e.charAt(t);
1031
1057
  }
1032
- return o;
1058
+ return i;
1033
1059
  }
1034
- function Te(i, e) {
1035
- const o = document.createElement("a");
1036
- o.download = e, o.href = i, document.body.appendChild(o), o.click(), document.body.removeChild(o);
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);
1037
1063
  }
1038
- function Be() {
1064
+ function Ee() {
1039
1065
  if (document.getElementById("neat-seo-schema"))
1040
1066
  return;
1041
- const i = document.createElement("script");
1042
- i.id = "neat-seo-schema", i.type = "application/ld+json", i.text = JSON.stringify({
1067
+ const a = document.createElement("script");
1068
+ a.id = "neat-seo-schema", a.type = "application/ld+json", a.text = JSON.stringify({
1043
1069
  "@context": "https://schema.org",
1044
1070
  "@type": "WebSite",
1045
1071
  name: "NEAT Gradient",
@@ -1050,19 +1076,19 @@ function Be() {
1050
1076
  url: "https://firecms.co"
1051
1077
  },
1052
1078
  description: "Beautiful, fast, heavily customizable, WebGL based gradients."
1053
- }), document.head.appendChild(i);
1079
+ }), document.head.appendChild(a);
1054
1080
  const e = document.createElement("div");
1055
1081
  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";
1056
1082
  try {
1057
- const o = e.attachShadow({ mode: "closed" }), t = document.createElement("a");
1058
- t.href = "https://firecms.co", t.textContent = "FireCMS", o.appendChild(t);
1083
+ const i = e.attachShadow({ mode: "closed" }), o = document.createElement("a");
1084
+ o.href = "https://firecms.co", o.textContent = "FireCMS", i.appendChild(o);
1059
1085
  } catch {
1060
- const t = document.createElement("a");
1061
- t.href = "https://firecms.co", t.textContent = "FireCMS", e.appendChild(t);
1086
+ const o = document.createElement("a");
1087
+ o.href = "https://firecms.co", o.textContent = "FireCMS", e.appendChild(o);
1062
1088
  }
1063
1089
  document.body.appendChild(e);
1064
1090
  }
1065
1091
  export {
1066
- Ue as NeatGradient
1092
+ Te as NeatGradient
1067
1093
  };
1068
1094
  //# sourceMappingURL=index.es.js.map