@firecms/neat 0.1.2 → 0.1.4
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/NeatGradient.d.ts +7 -3
- package/dist/NeatGradient.js +17 -7
- package/dist/NeatGradient.js.map +1 -1
- package/dist/index.es.js +59 -51
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +6 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
- package/src/NeatGradient.ts +23 -9
package/dist/NeatGradient.d.ts
CHANGED
|
@@ -14,7 +14,8 @@ export declare type NeatConfig = {
|
|
|
14
14
|
waveAmplitude?: number;
|
|
15
15
|
highlights?: number;
|
|
16
16
|
shadows?: number;
|
|
17
|
-
|
|
17
|
+
colorSaturation?: number;
|
|
18
|
+
colorBrightness?: number;
|
|
18
19
|
colors: NeatColor[];
|
|
19
20
|
colorBlending?: number;
|
|
20
21
|
wireframe?: boolean;
|
|
@@ -42,6 +43,7 @@ export declare class NeatGradient implements NeatController {
|
|
|
42
43
|
private _shadows;
|
|
43
44
|
private _highlights;
|
|
44
45
|
private _saturation;
|
|
46
|
+
private _brightness;
|
|
45
47
|
private _colorBlending;
|
|
46
48
|
private _colors;
|
|
47
49
|
private _wireframe;
|
|
@@ -52,6 +54,7 @@ export declare class NeatGradient implements NeatController {
|
|
|
52
54
|
private readonly sceneState;
|
|
53
55
|
constructor(config: NeatConfig & {
|
|
54
56
|
ref: HTMLCanvasElement;
|
|
57
|
+
resolution?: number;
|
|
55
58
|
});
|
|
56
59
|
destroy(): void;
|
|
57
60
|
set speed(speed: number);
|
|
@@ -63,12 +66,13 @@ export declare class NeatGradient implements NeatController {
|
|
|
63
66
|
set colors(colors: NeatColor[]);
|
|
64
67
|
set highlights(highlights: number);
|
|
65
68
|
set shadows(shadows: number);
|
|
66
|
-
set
|
|
69
|
+
set colorSaturation(colorSaturation: number);
|
|
70
|
+
set colorBrightness(colorBrightness: number);
|
|
67
71
|
set colorBlending(colorBlending: number);
|
|
68
72
|
set wireframe(wireframe: boolean);
|
|
69
73
|
set backgroundColor(backgroundColor: string);
|
|
70
74
|
set backgroundAlpha(backgroundAlpha: number);
|
|
71
|
-
_initScene(ref: HTMLCanvasElement, width: number, height: number): SceneState;
|
|
75
|
+
_initScene(ref: HTMLCanvasElement, width: number, height: number, resolution: number): SceneState;
|
|
72
76
|
_buildMaterial(width: number, height: number): THREE.ShaderMaterial;
|
|
73
77
|
}
|
|
74
78
|
export {};
|
package/dist/NeatGradient.js
CHANGED
|
@@ -14,6 +14,7 @@ export class NeatGradient {
|
|
|
14
14
|
_shadows = -1;
|
|
15
15
|
_highlights = -1;
|
|
16
16
|
_saturation = -1;
|
|
17
|
+
_brightness = -1;
|
|
17
18
|
_colorBlending = -1;
|
|
18
19
|
_colors = [];
|
|
19
20
|
_wireframe = false;
|
|
@@ -23,7 +24,7 @@ export class NeatGradient {
|
|
|
23
24
|
sizeObserver;
|
|
24
25
|
sceneState;
|
|
25
26
|
constructor(config) {
|
|
26
|
-
const { ref, speed = 4, horizontalPressure = 3, verticalPressure = 3, waveFrequencyX = 5, waveFrequencyY = 5, waveAmplitude = 3, colors, highlights = 4, shadows = 4,
|
|
27
|
+
const { ref, speed = 4, horizontalPressure = 3, verticalPressure = 3, waveFrequencyX = 5, waveFrequencyY = 5, waveAmplitude = 3, colors, highlights = 4, shadows = 4, colorSaturation = 0, colorBrightness = 1, colorBlending = 5, wireframe = false, backgroundColor = "#FFFFFF", backgroundAlpha = 1.0, resolution = 1 } = config;
|
|
27
28
|
const width = ref.width, height = ref.height;
|
|
28
29
|
this.destroy = this.destroy.bind(this);
|
|
29
30
|
this._initScene = this._initScene.bind(this);
|
|
@@ -38,11 +39,12 @@ export class NeatGradient {
|
|
|
38
39
|
this.colors = colors;
|
|
39
40
|
this.shadows = shadows;
|
|
40
41
|
this.highlights = highlights;
|
|
41
|
-
this.
|
|
42
|
+
this.colorSaturation = colorSaturation;
|
|
43
|
+
this.colorBrightness = colorBrightness;
|
|
42
44
|
this.wireframe = wireframe;
|
|
43
45
|
this.backgroundColor = backgroundColor;
|
|
44
46
|
this.backgroundAlpha = backgroundAlpha;
|
|
45
|
-
this.sceneState = this._initScene(ref, width, height);
|
|
47
|
+
this.sceneState = this._initScene(ref, width, height, resolution);
|
|
46
48
|
const { renderer, camera, scene, meshes } = this.sceneState;
|
|
47
49
|
let tick = 0;
|
|
48
50
|
const render = () => {
|
|
@@ -92,6 +94,8 @@ export class NeatGradient {
|
|
|
92
94
|
// @ts-ignore
|
|
93
95
|
mesh.material.uniforms.u_saturation = { value: this._saturation };
|
|
94
96
|
// @ts-ignore
|
|
97
|
+
mesh.material.uniforms.u_brightness = { value: this._brightness };
|
|
98
|
+
// @ts-ignore
|
|
95
99
|
mesh.material.wireframe = this._wireframe;
|
|
96
100
|
});
|
|
97
101
|
renderer.render(scene, camera);
|
|
@@ -143,8 +147,12 @@ export class NeatGradient {
|
|
|
143
147
|
set shadows(shadows) {
|
|
144
148
|
this._shadows = shadows / 100;
|
|
145
149
|
}
|
|
146
|
-
set
|
|
147
|
-
this._saturation =
|
|
150
|
+
set colorSaturation(colorSaturation) {
|
|
151
|
+
this._saturation = colorSaturation / 10;
|
|
152
|
+
}
|
|
153
|
+
set colorBrightness(colorBrightness) {
|
|
154
|
+
console.log("colorBrightness", colorBrightness);
|
|
155
|
+
this._brightness = colorBrightness;
|
|
148
156
|
}
|
|
149
157
|
set colorBlending(colorBlending) {
|
|
150
158
|
this._colorBlending = colorBlending / 10;
|
|
@@ -158,7 +166,7 @@ export class NeatGradient {
|
|
|
158
166
|
set backgroundAlpha(backgroundAlpha) {
|
|
159
167
|
this._backgroundAlpha = backgroundAlpha;
|
|
160
168
|
}
|
|
161
|
-
_initScene(ref, width, height) {
|
|
169
|
+
_initScene(ref, width, height, resolution) {
|
|
162
170
|
const renderer = new THREE.WebGLRenderer({
|
|
163
171
|
// antialias: true,
|
|
164
172
|
alpha: true,
|
|
@@ -169,7 +177,7 @@ export class NeatGradient {
|
|
|
169
177
|
const meshes = [];
|
|
170
178
|
const scene = new THREE.Scene();
|
|
171
179
|
const material = this._buildMaterial(width, height);
|
|
172
|
-
const geo = new THREE.PlaneGeometry(PLANE_WIDTH, PLANE_HEIGHT, 240, 240);
|
|
180
|
+
const geo = new THREE.PlaneGeometry(PLANE_WIDTH, PLANE_HEIGHT, 240 * resolution, 240 * resolution);
|
|
173
181
|
const plane = new THREE.Mesh(geo, material);
|
|
174
182
|
plane.rotation.x = -Math.PI / 3.5;
|
|
175
183
|
plane.position.z = -1;
|
|
@@ -305,6 +313,7 @@ void main(){
|
|
|
305
313
|
color.rgb += pow(v_displacement_amount, 1.0) * u_highlights;
|
|
306
314
|
color.rgb -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;
|
|
307
315
|
color = saturation(color, 1.0 + u_saturation);
|
|
316
|
+
color = color * u_brightness;
|
|
308
317
|
|
|
309
318
|
gl_FragColor = vec4(color,1.0);
|
|
310
319
|
}
|
|
@@ -333,6 +342,7 @@ uniform float u_plane_height;
|
|
|
333
342
|
uniform float u_shadows;
|
|
334
343
|
uniform float u_highlights;
|
|
335
344
|
uniform float u_saturation;
|
|
345
|
+
uniform float u_brightness;
|
|
336
346
|
|
|
337
347
|
uniform float u_color_blending;
|
|
338
348
|
|
package/dist/NeatGradient.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NeatGradient.js","sourceRoot":"","sources":["../src/NeatGradient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,MAAM,SAAS,GAAG,IAAI,CAAC;AACvB,MAAM,YAAY,GAAG,CAAC,CAAC;AAEvB,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;AAuChC,MAAM,OAAO,YAAY;IAEb,MAAM,GAAW,CAAC,CA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AAa,EAAE;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC3C,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,WAAW,EAAE;gBACrC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;gBAChC,OAAO;aACV;SACJ;KACJ;IACD,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACzC,aAAa,CAAC,IAAI,CAAC,CAAC;IACpB,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC,CAAA"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i from "three";
|
|
2
|
-
const
|
|
3
|
-
class
|
|
2
|
+
const x = 50, h = 80, V = !0, b = 5, Y = new i.Clock();
|
|
3
|
+
class W {
|
|
4
4
|
_speed = -1;
|
|
5
5
|
_horizontalPressure = -1;
|
|
6
6
|
_verticalPressure = -1;
|
|
@@ -10,6 +10,7 @@ class D {
|
|
|
10
10
|
_shadows = -1;
|
|
11
11
|
_highlights = -1;
|
|
12
12
|
_saturation = -1;
|
|
13
|
+
_brightness = -1;
|
|
13
14
|
_colorBlending = -1;
|
|
14
15
|
_colors = [];
|
|
15
16
|
_wireframe = !1;
|
|
@@ -23,43 +24,45 @@ class D {
|
|
|
23
24
|
ref: r,
|
|
24
25
|
speed: s = 4,
|
|
25
26
|
horizontalPressure: l = 3,
|
|
26
|
-
verticalPressure:
|
|
27
|
-
waveFrequencyX:
|
|
27
|
+
verticalPressure: n = 3,
|
|
28
|
+
waveFrequencyX: a = 5,
|
|
28
29
|
waveFrequencyY: v = 5,
|
|
29
30
|
waveAmplitude: m = 3,
|
|
30
|
-
colors:
|
|
31
|
-
highlights:
|
|
32
|
-
shadows:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
colors: _,
|
|
32
|
+
highlights: c = 4,
|
|
33
|
+
shadows: u = 4,
|
|
34
|
+
colorSaturation: d = 0,
|
|
35
|
+
colorBrightness: y = 1,
|
|
36
|
+
colorBlending: p = 5,
|
|
37
|
+
wireframe: E = !1,
|
|
38
|
+
backgroundColor: N = "#FFFFFF",
|
|
39
|
+
backgroundAlpha: R = 1,
|
|
40
|
+
resolution: B = 1
|
|
38
41
|
} = e, P = r.width, q = r.height;
|
|
39
|
-
this.destroy = this.destroy.bind(this), this._initScene = this._initScene.bind(this), this._buildMaterial = this._buildMaterial.bind(this), this.speed = s, this.horizontalPressure = l, this.verticalPressure =
|
|
40
|
-
const { renderer: w, camera:
|
|
42
|
+
this.destroy = this.destroy.bind(this), this._initScene = this._initScene.bind(this), this._buildMaterial = this._buildMaterial.bind(this), this.speed = s, this.horizontalPressure = l, this.verticalPressure = n, this.waveFrequencyX = a, this.waveFrequencyY = v, this.waveAmplitude = m, this.colorBlending = p, this.colors = _, this.shadows = u, this.highlights = c, this.colorSaturation = d, this.colorBrightness = y, this.wireframe = E, this.backgroundColor = N, this.backgroundAlpha = R, this.sceneState = this._initScene(r, P, q, B);
|
|
43
|
+
const { renderer: w, camera: I, scene: K, meshes: O } = this.sceneState;
|
|
41
44
|
let z = 0;
|
|
42
45
|
const C = () => {
|
|
43
|
-
Math.floor(z * 10) % 5 === 0 &&
|
|
44
|
-
const
|
|
45
|
-
...this._colors.map((
|
|
46
|
-
is_active:
|
|
47
|
-
color: new i.Color(
|
|
48
|
-
influence:
|
|
46
|
+
Math.floor(z * 10) % 5 === 0 && L(r), w.setClearColor(this._backgroundColor, this._backgroundAlpha), O.forEach((o) => {
|
|
47
|
+
const f = [
|
|
48
|
+
...this._colors.map((g) => ({
|
|
49
|
+
is_active: g.enabled,
|
|
50
|
+
color: new i.Color(g.color),
|
|
51
|
+
influence: g.influence
|
|
49
52
|
})),
|
|
50
53
|
...Array.from({ length: b - this._colors.length }).map(() => ({
|
|
51
54
|
is_active: !1,
|
|
52
55
|
color: new i.Color(0)
|
|
53
56
|
}))
|
|
54
57
|
];
|
|
55
|
-
z +=
|
|
56
|
-
}), w.render(
|
|
57
|
-
},
|
|
58
|
-
const o = w.domElement,
|
|
59
|
-
this.sceneState.renderer.setSize(
|
|
58
|
+
z += Y.getDelta() * this._speed, o.material.uniforms.u_time.value = z, o.material.uniforms.u_resolution = { value: new i.Vector2(P, q) }, o.material.uniforms.u_color_pressure = { value: new i.Vector2(this._horizontalPressure, this._verticalPressure) }, o.material.uniforms.u_wave_frequency_x = { value: this._waveFrequencyX }, o.material.uniforms.u_wave_frequency_y = { value: this._waveFrequencyY }, o.material.uniforms.u_wave_amplitude = { value: this._waveAmplitude }, o.material.uniforms.u_plane_width = { value: x }, o.material.uniforms.u_plane_height = { value: h }, o.material.uniforms.u_color_blending = { value: this._colorBlending }, o.material.uniforms.u_colors = { value: f }, o.material.uniforms.u_colors_count = { value: b }, o.material.uniforms.u_shadows = { value: this._shadows }, o.material.uniforms.u_highlights = { value: this._highlights }, o.material.uniforms.u_saturation = { value: this._saturation }, o.material.uniforms.u_brightness = { value: this._brightness }, o.material.wireframe = this._wireframe;
|
|
59
|
+
}), w.render(K, I), this.requestRef = requestAnimationFrame(C);
|
|
60
|
+
}, T = () => {
|
|
61
|
+
const o = w.domElement, f = o.clientWidth, g = o.clientHeight;
|
|
62
|
+
this.sceneState.renderer.setSize(f, g, !1), F(this.sceneState.camera, f, g);
|
|
60
63
|
};
|
|
61
64
|
this.sizeObserver = new ResizeObserver((o) => {
|
|
62
|
-
|
|
65
|
+
T();
|
|
63
66
|
}), this.sizeObserver.observe(r), C();
|
|
64
67
|
}
|
|
65
68
|
destroy() {
|
|
@@ -92,9 +95,12 @@ class D {
|
|
|
92
95
|
set shadows(e) {
|
|
93
96
|
this._shadows = e / 100;
|
|
94
97
|
}
|
|
95
|
-
set
|
|
98
|
+
set colorSaturation(e) {
|
|
96
99
|
this._saturation = e / 10;
|
|
97
100
|
}
|
|
101
|
+
set colorBrightness(e) {
|
|
102
|
+
console.log("colorBrightness", e), this._brightness = e;
|
|
103
|
+
}
|
|
98
104
|
set colorBlending(e) {
|
|
99
105
|
this._colorBlending = e / 10;
|
|
100
106
|
}
|
|
@@ -107,28 +113,28 @@ class D {
|
|
|
107
113
|
set backgroundAlpha(e) {
|
|
108
114
|
this._backgroundAlpha = e;
|
|
109
115
|
}
|
|
110
|
-
_initScene(e, r, s) {
|
|
111
|
-
const
|
|
116
|
+
_initScene(e, r, s, l) {
|
|
117
|
+
const n = new i.WebGLRenderer({
|
|
112
118
|
alpha: !0,
|
|
113
119
|
canvas: e
|
|
114
120
|
});
|
|
115
|
-
|
|
116
|
-
const a = [],
|
|
117
|
-
c.rotation.x = -Math.PI / 3.5, c.position.z = -1, a.push(c),
|
|
121
|
+
n.setClearColor(16711680, 0.5), n.setSize(r, s, !1);
|
|
122
|
+
const a = [], v = new i.Scene(), m = this._buildMaterial(r, s), _ = new i.PlaneGeometry(x, h, 240 * l, 240 * l), c = new i.Mesh(_, m);
|
|
123
|
+
c.rotation.x = -Math.PI / 3.5, c.position.z = -1, a.push(c), v.add(c);
|
|
118
124
|
const u = new i.OrthographicCamera(0, 0, 0, 0, 0, 0);
|
|
119
125
|
return F(u, r, s), {
|
|
120
|
-
renderer:
|
|
126
|
+
renderer: n,
|
|
121
127
|
camera: u,
|
|
122
|
-
scene:
|
|
128
|
+
scene: v,
|
|
123
129
|
meshes: a
|
|
124
130
|
};
|
|
125
131
|
}
|
|
126
132
|
_buildMaterial(e, r) {
|
|
127
133
|
const s = [
|
|
128
|
-
...this._colors.map((
|
|
129
|
-
is_active:
|
|
130
|
-
color: new i.Color(
|
|
131
|
-
influence:
|
|
134
|
+
...this._colors.map((a) => ({
|
|
135
|
+
is_active: a.enabled,
|
|
136
|
+
color: new i.Color(a.color),
|
|
137
|
+
influence: a.influence
|
|
132
138
|
})),
|
|
133
139
|
...Array.from({ length: b - this._colors.length }).map(() => ({
|
|
134
140
|
is_active: !1,
|
|
@@ -143,23 +149,23 @@ class D {
|
|
|
143
149
|
u_resolution: { value: new i.Vector2(e, r) },
|
|
144
150
|
u_colors: { value: s },
|
|
145
151
|
u_colors_count: { value: this._colors.length },
|
|
146
|
-
u_plane_width: { value:
|
|
147
|
-
u_plane_height: { value:
|
|
152
|
+
u_plane_width: { value: x },
|
|
153
|
+
u_plane_height: { value: h },
|
|
148
154
|
u_shadows: { value: this._shadows },
|
|
149
155
|
u_highlights: { value: this._highlights }
|
|
150
|
-
},
|
|
156
|
+
}, n = new i.ShaderMaterial({
|
|
151
157
|
uniforms: l,
|
|
152
|
-
vertexShader: S() +
|
|
153
|
-
fragmentShader: S() + A() +
|
|
158
|
+
vertexShader: S() + D() + A() + j(),
|
|
159
|
+
fragmentShader: S() + A() + k()
|
|
154
160
|
});
|
|
155
|
-
return
|
|
161
|
+
return n.wireframe = V, n;
|
|
156
162
|
}
|
|
157
163
|
}
|
|
158
164
|
function F(t, e, r) {
|
|
159
|
-
const
|
|
160
|
-
t.left =
|
|
165
|
+
const n = e * r / 1e6 * x * h / 1.5, a = e / r, v = Math.sqrt(n * a), m = n / v, _ = -x / 2, c = Math.min((_ + v) / 1.5, x / 2), u = h / 4, d = Math.max((u - m) / 2, -h / 4), y = -100, p = 1e3;
|
|
166
|
+
t.left = _, t.right = c, t.top = u, t.bottom = d, t.near = y, t.far = p, t.updateProjectionMatrix();
|
|
161
167
|
}
|
|
162
|
-
function
|
|
168
|
+
function j() {
|
|
163
169
|
return `
|
|
164
170
|
|
|
165
171
|
void main() {
|
|
@@ -213,7 +219,7 @@ void main() {
|
|
|
213
219
|
}
|
|
214
220
|
`;
|
|
215
221
|
}
|
|
216
|
-
function
|
|
222
|
+
function k() {
|
|
217
223
|
return `
|
|
218
224
|
|
|
219
225
|
void main(){
|
|
@@ -222,6 +228,7 @@ void main(){
|
|
|
222
228
|
color.rgb += pow(v_displacement_amount, 1.0) * u_highlights;
|
|
223
229
|
color.rgb -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;
|
|
224
230
|
color = saturation(color, 1.0 + u_saturation);
|
|
231
|
+
color = color * u_brightness;
|
|
225
232
|
|
|
226
233
|
gl_FragColor = vec4(color,1.0);
|
|
227
234
|
}
|
|
@@ -250,6 +257,7 @@ uniform float u_plane_height;
|
|
|
250
257
|
uniform float u_shadows;
|
|
251
258
|
uniform float u_highlights;
|
|
252
259
|
uniform float u_saturation;
|
|
260
|
+
uniform float u_brightness;
|
|
253
261
|
|
|
254
262
|
uniform float u_color_blending;
|
|
255
263
|
|
|
@@ -262,7 +270,7 @@ varying vec4 v_new_position;
|
|
|
262
270
|
varying vec3 v_color;
|
|
263
271
|
varying float v_displacement_amount;
|
|
264
272
|
|
|
265
|
-
`,
|
|
273
|
+
`, D = () => `
|
|
266
274
|
|
|
267
275
|
vec3 mod289(vec3 x)
|
|
268
276
|
{
|
|
@@ -488,7 +496,7 @@ vec3 hsv2rgb(vec3 c)
|
|
|
488
496
|
}
|
|
489
497
|
`, M = (t) => {
|
|
490
498
|
t.id = "neat-link", t.href = "https://neat.firecms.co", t.target = "_blank", t.style.position = "absolute", t.style.display = "block", t.style.opacity = "1", t.style.bottom = "0", t.style.right = "0", t.style.padding = "10px", t.style.color = "#dcdcdc", t.style.fontFamily = "sans-serif", t.style.fontSize = "16px", t.style.fontWeight = "bold", t.style.textDecoration = "none", t.style.zIndex = "100", t.innerHTML = "NEAT";
|
|
491
|
-
},
|
|
499
|
+
}, L = (t) => {
|
|
492
500
|
const e = t.parentElement?.getElementsByTagName("a");
|
|
493
501
|
if (e) {
|
|
494
502
|
for (let s = 0; s < e.length; s++)
|
|
@@ -501,6 +509,6 @@ vec3 hsv2rgb(vec3 c)
|
|
|
501
509
|
M(r), t.parentElement?.appendChild(r);
|
|
502
510
|
};
|
|
503
511
|
export {
|
|
504
|
-
|
|
512
|
+
W as NeatGradient
|
|
505
513
|
};
|
|
506
514
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../src/NeatGradient.ts"],"sourcesContent":["import * as THREE from \"three\";\n\nconst PLANE_WIDTH = 50;\nconst PLANE_HEIGHT = 80;\n\nconst WIREFRAME = true;\nconst COLORS_COUNT = 5;\n\nconst clock = new THREE.Clock();\n\ntype SceneState = {\n renderer: THREE.WebGLRenderer,\n camera: THREE.OrthographicCamera,\n scene: THREE.Scene,\n meshes: THREE.Mesh[],\n}\n\nexport type NeatConfig = {\n speed?: number;\n horizontalPressure?: number;\n verticalPressure?: number;\n waveFrequencyX?: number;\n waveFrequencyY?: number;\n waveAmplitude?: number;\n highlights?: number;\n shadows?: number;\n saturation?: number;\n colors: NeatColor[];\n colorBlending?: number;\n wireframe?: boolean;\n backgroundColor?: string;\n backgroundAlpha?: number;\n};\n\nexport type NeatColor = {\n color: string;\n enabled: boolean;\n /**\n * Value from 0 to 1\n */\n influence?: number;\n}\n\nexport type NeatController = {\n destroy: () => void;\n}\n\nexport class NeatGradient implements NeatController {\n\n private _speed: number = -1;\n\n private _horizontalPressure: number = -1;\n private _verticalPressure: number = -1;\n\n private _waveFrequencyX: number = -1;\n private _waveFrequencyY: number = -1;\n private _waveAmplitude: number = -1;\n\n private _shadows: number = -1;\n private _highlights: number = -1;\n private _saturation: number = -1;\n\n private _colorBlending: number = -1;\n\n private _colors: NeatColor[] = [];\n private _wireframe: boolean = false;\n\n private _backgroundColor: string = \"#FFFFFF\";\n private _backgroundAlpha: number = 1.0;\n\n private requestRef: number = -1;\n private sizeObserver: ResizeObserver;\n private readonly sceneState: SceneState;\n\n constructor(config: NeatConfig & { ref: HTMLCanvasElement }) {\n\n const {\n ref,\n speed = 4,\n horizontalPressure = 3,\n verticalPressure = 3,\n waveFrequencyX = 5,\n waveFrequencyY = 5,\n waveAmplitude = 3,\n colors,\n highlights = 4,\n shadows = 4,\n saturation = 0,\n colorBlending = 5,\n wireframe = false,\n backgroundColor = \"#FFFFFF\",\n backgroundAlpha = 1.0,\n } = config;\n\n const width = ref.width,\n height = ref.height;\n\n this.destroy = this.destroy.bind(this);\n this._initScene = this._initScene.bind(this);\n this._buildMaterial = this._buildMaterial.bind(this);\n\n this.speed = speed;\n this.horizontalPressure = horizontalPressure;\n this.verticalPressure = verticalPressure;\n this.waveFrequencyX = waveFrequencyX;\n this.waveFrequencyY = waveFrequencyY;\n this.waveAmplitude = waveAmplitude;\n this.colorBlending = colorBlending;\n this.colors = colors;\n this.shadows = shadows;\n this.highlights = highlights;\n this.saturation = saturation;\n this.wireframe = wireframe;\n this.backgroundColor = backgroundColor;\n this.backgroundAlpha = backgroundAlpha;\n\n this.sceneState = this._initScene(ref, width, height);\n\n const { renderer, camera, scene, meshes } = this.sceneState;\n\n let tick = 0;\n const render = () => {\n\n if (Math.floor(tick * 10) % 5 === 0) {\n addNeatLink(ref);\n }\n\n renderer.setClearColor(this._backgroundColor, this._backgroundAlpha);\n meshes.forEach((mesh) => {\n\n const colors = [\n ...this._colors.map(color => ({\n is_active: color.enabled,\n color: new THREE.Color(color.color),\n influence: color.influence\n })),\n ...Array.from({ length: COLORS_COUNT - this._colors.length }).map(() => ({\n is_active: false,\n color: new THREE.Color(0x000000)\n }))\n ];\n\n tick += clock.getDelta() * this._speed;\n // @ts-ignore\n mesh.material.uniforms.u_time.value = tick;\n // @ts-ignore\n mesh.material.uniforms.u_resolution = { value: new THREE.Vector2(width, height) };\n // @ts-ignore\n mesh.material.uniforms.u_color_pressure = { value: new THREE.Vector2(this._horizontalPressure, this._verticalPressure) };\n // @ts-ignore\n mesh.material.uniforms.u_wave_frequency_x = { value: this._waveFrequencyX };\n // @ts-ignore\n mesh.material.uniforms.u_wave_frequency_y = { value: this._waveFrequencyY };\n // @ts-ignore\n mesh.material.uniforms.u_wave_amplitude = { value: this._waveAmplitude };\n // @ts-ignore\n mesh.material.uniforms.u_plane_width = { value: PLANE_WIDTH };\n // @ts-ignore\n mesh.material.uniforms.u_plane_height = { value: PLANE_HEIGHT };\n // @ts-ignore\n mesh.material.uniforms.u_color_blending = { value: this._colorBlending };\n // @ts-ignore\n mesh.material.uniforms.u_colors = { value: colors };\n // @ts-ignore\n mesh.material.uniforms.u_colors_count = { value: COLORS_COUNT };\n // @ts-ignore\n mesh.material.uniforms.u_shadows = { value: this._shadows };\n // @ts-ignore\n mesh.material.uniforms.u_highlights = { value: this._highlights };\n // @ts-ignore\n mesh.material.uniforms.u_saturation = { value: this._saturation };\n // @ts-ignore\n mesh.material.wireframe = this._wireframe;\n });\n\n renderer.render(scene, camera);\n this.requestRef = requestAnimationFrame(render);\n };\n\n const setSize = () => {\n const canvas = renderer.domElement;\n const width = canvas.clientWidth;\n const height = canvas.clientHeight;\n\n this.sceneState.renderer.setSize(width, height, false);\n updateCamera(this.sceneState.camera, width, height);\n };\n\n this.sizeObserver = new ResizeObserver(entries => {\n setSize();\n });\n\n this.sizeObserver.observe(ref);\n\n\n render();\n }\n\n destroy() {\n if (this) {\n cancelAnimationFrame(this.requestRef);\n this.sizeObserver.disconnect();\n }\n }\n\n set speed(speed: number) {\n this._speed = speed / 20;\n }\n\n set horizontalPressure(horizontalPressure: number) {\n this._horizontalPressure = horizontalPressure / 4;\n }\n\n set verticalPressure(verticalPressure: number) {\n this._verticalPressure = verticalPressure / 4;\n }\n\n set waveFrequencyX(waveFrequencyX: number) {\n this._waveFrequencyX = waveFrequencyX * 0.04;\n }\n\n set waveFrequencyY(waveFrequencyY: number) {\n this._waveFrequencyY = waveFrequencyY * 0.04;\n }\n\n set waveAmplitude(waveAmplitude: number) {\n this._waveAmplitude = waveAmplitude * .75;\n }\n\n set colors(colors: NeatColor[]) {\n this._colors = colors;\n }\n\n set highlights(highlights: number) {\n this._highlights = highlights / 100;\n }\n\n set shadows(shadows: number) {\n this._shadows = shadows / 100;\n }\n\n set saturation(saturation: number) {\n this._saturation = saturation / 10;\n }\n\n set colorBlending(colorBlending: number) {\n this._colorBlending = colorBlending / 10;\n }\n\n set wireframe(wireframe: boolean) {\n this._wireframe = wireframe;\n }\n\n set backgroundColor(backgroundColor: string) {\n this._backgroundColor = backgroundColor;\n }\n\n set backgroundAlpha(backgroundAlpha: number) {\n this._backgroundAlpha = backgroundAlpha;\n }\n\n _initScene(ref: HTMLCanvasElement, width: number, height: number): SceneState {\n\n const renderer = new THREE.WebGLRenderer({\n // antialias: true,\n alpha: true,\n canvas: ref\n });\n\n renderer.setClearColor(0xFF0000, .5);\n renderer.setSize(width, height, false);\n\n const meshes: THREE.Mesh[] = [];\n\n const scene = new THREE.Scene();\n\n const material = this._buildMaterial(width, height);\n\n const geo = new THREE.PlaneGeometry(PLANE_WIDTH, PLANE_HEIGHT, 240, 240);\n const plane = new THREE.Mesh(geo, material);\n plane.rotation.x = -Math.PI / 3.5;\n plane.position.z = -1;\n meshes.push(plane);\n scene.add(plane);\n\n const camera = new THREE.OrthographicCamera(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);\n // camera.zoom = 1;\n updateCamera(camera, width, height);\n\n return {\n renderer,\n camera,\n scene,\n meshes\n };\n }\n\n _buildMaterial(width: number, height: number) {\n\n const colors = [\n ...this._colors.map(color => ({\n is_active: color.enabled,\n color: new THREE.Color(color.color),\n influence: color.influence\n })),\n ...Array.from({ length: COLORS_COUNT - this._colors.length }).map(() => ({\n is_active: false,\n color: new THREE.Color(0x000000)\n }))\n ];\n\n const uniforms = {\n u_time: { value: 0 },\n u_color_pressure: { value: new THREE.Vector2(this._horizontalPressure, this._verticalPressure) },\n u_wave_frequency_x: { value: this._waveFrequencyX },\n u_wave_frequency_y: { value: this._waveFrequencyY },\n u_wave_amplitude: { value: this._waveAmplitude },\n u_resolution: { value: new THREE.Vector2(width, height) },\n u_colors: { value: colors },\n u_colors_count: { value: this._colors.length },\n u_plane_width: { value: PLANE_WIDTH },\n u_plane_height: { value: PLANE_HEIGHT },\n u_shadows: { value: this._shadows },\n u_highlights: { value: this._highlights },\n };\n\n const material = new THREE.ShaderMaterial({\n uniforms: uniforms,\n vertexShader: buildUniforms() + buildNoise() + buildColorFunctions() + buildVertexShader(),\n fragmentShader: buildUniforms() + buildColorFunctions() + buildFragmentShader()\n });\n\n material.wireframe = WIREFRAME;\n return material;\n }\n\n\n}\n\nfunction updateCamera(camera: THREE.OrthographicCamera, width: number, height: number) {\n\n const viewPortAreaRatio = 1000000;\n const areaViewPort = width * height;\n const targetPlaneArea =\n areaViewPort / viewPortAreaRatio *\n PLANE_WIDTH * PLANE_HEIGHT / 1.5;\n\n const ratio = width / height;\n\n const targetWidth = Math.sqrt(targetPlaneArea * ratio);\n const targetHeight = targetPlaneArea / targetWidth;\n\n const left = -PLANE_WIDTH / 2;\n const right = Math.min((left + targetWidth) / 1.5, PLANE_WIDTH / 2);\n\n const top = PLANE_HEIGHT / 4;\n const bottom = Math.max((top - targetHeight) / 2, -PLANE_HEIGHT / 4);\n\n const near = -100;\n const far = 1000;\n camera.left = left;\n camera.right = right;\n camera.top = top;\n camera.bottom = bottom;\n camera.near = near;\n camera.far = far;\n camera.updateProjectionMatrix();\n}\n\n\nfunction buildVertexShader() {\n return `\n\nvoid main() {\n\n vUv = uv;\n\n v_displacement_amount = cnoise( vec3(\n u_wave_frequency_x * position.x + u_time,\n u_wave_frequency_y * position.y + u_time,\n u_time\n ));\n \n vec3 color;\n\n // float t = mod(u_base_color, 100.0);\n color = u_colors[0].color;\n \n vec2 noise_cord = vUv * u_color_pressure;\n \n const float minNoise = .0;\n const float maxNoise = .9;\n \n for (int i = 1; i < u_colors_count; i++) {\n \n if(u_colors[i].is_active == 1.0){\n float noiseFlow = (1. + float(i)) / 30.;\n float noiseSpeed = (1. + float(i)) * 0.11;\n float noiseSeed = 13. + float(i) * 7.;\n \n float noise = snoise(\n vec3(\n noise_cord.x * u_color_pressure.x + u_time * noiseFlow * 2.,\n noise_cord.y * u_color_pressure.y,\n u_time * noiseSpeed\n ) + noiseSeed\n );\n \n noise = clamp(minNoise, maxNoise + float(i) * 0.02, noise);\n vec3 nextColor = u_colors[i].color;\n color = mix(color, nextColor, smoothstep(0.0, u_color_blending, noise));\n }\n \n }\n \n v_color = color;\n \n vec3 newPosition = position + normal * v_displacement_amount * u_wave_amplitude;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0 );\n \n v_new_position = gl_Position;\n}\n`;\n}\n\nfunction buildFragmentShader() {\n return `\n\nvoid main(){\n vec3 color = v_color;\n \n color.rgb += pow(v_displacement_amount, 1.0) * u_highlights;\n color.rgb -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;\n color = saturation(color, 1.0 + u_saturation);\n \n gl_FragColor = vec4(color,1.0);\n}\n`;\n}\n\nconst buildUniforms = () => `\nprecision highp float;\n\nstruct Color {\n float is_active;\n vec3 color;\n float value;\n};\n\nuniform float u_time;\n\nuniform float u_wave_amplitude;\nuniform float u_wave_frequency_x;\nuniform float u_wave_frequency_y;\n\nuniform vec2 u_color_pressure;\n\nuniform float u_plane_width;\nuniform float u_plane_height;\n\nuniform float u_shadows;\nuniform float u_highlights;\nuniform float u_saturation;\n\nuniform float u_color_blending;\n\nuniform int u_colors_count;\nuniform Color u_colors[5];\nuniform vec2 u_resolution;\n\nvarying vec2 vUv;\nvarying vec4 v_new_position;\nvarying vec3 v_color;\nvarying float v_displacement_amount;\n\n `;\n\nconst buildNoise = () => `\n\nvec3 mod289(vec3 x)\n{\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 mod289(vec4 x)\n{\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x)\n{\n return mod289(((x*34.0)+1.0)*x);\n}\n\nvec4 taylorInvSqrt(vec4 r)\n{\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec3 fade(vec3 t) {\n return t*t*t*(t*(t*6.0-15.0)+10.0);\n}\n\nfloat snoise(vec3 v)\n{\n const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n// First corner\n vec3 i = floor(v + dot(v, C.yyy) );\n vec3 x0 = v - i + dot(i, C.xxx) ;\n\n// Other corners\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n // x0 = x0 - 0.0 + 0.0 * C.xxx;\n // x1 = x0 - i1 + 1.0 * C.xxx;\n // x2 = x0 - i2 + 2.0 * C.xxx;\n // x3 = x0 - 1.0 + 3.0 * C.xxx;\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n// Permutations\n i = mod289(i);\n vec4 p = permute( permute( permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\n// Gradients: 7x7 points over a square, mapped onto an octahedron.\n// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;\n //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;\n vec4 s0 = floor(b0)*2.0 + 1.0;\n vec4 s1 = floor(b1)*2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n\n vec3 p0 = vec3(a0.xy,h.x);\n vec3 p1 = vec3(a0.zw,h.y);\n vec3 p2 = vec3(a1.xy,h.z);\n vec3 p3 = vec3(a1.zw,h.w);\n\n//Normalise gradients\n vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n// Mix final noise value\n vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),\n dot(p2,x2), dot(p3,x3) ) );\n}\n\n// Classic Perlin noise\nfloat cnoise(vec3 P)\n{\n vec3 Pi0 = floor(P); // Integer part for indexing\n vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); // Fractional part for interpolation\n vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);\n return 2.2 * n_xyz;\n}\n\n// YUV to RGB matrix\nmat3 yuv2rgb = mat3(1.0, 0.0, 1.13983,\n 1.0, -0.39465, -0.58060,\n 1.0, 2.03211, 0.0);\n\n// RGB to YUV matrix\nmat3 rgb2yuv = mat3(0.2126, 0.7152, 0.0722,\n -0.09991, -0.33609, 0.43600,\n 0.615, -0.5586, -0.05639);\n\n `;\n\nconst buildColorFunctions = () => `\n\nvec3 saturation(vec3 rgb, float adjustment) {\n const vec3 W = vec3(0.2125, 0.7154, 0.0721);\n vec3 intensity = vec3(dot(rgb, W));\n return mix(intensity, rgb, adjustment);\n}\n\nfloat saturation(vec3 rgb)\n{\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(rgb.bg, K.wz), vec4(rgb.gb, K.xy), step(rgb.b, rgb.g));\n vec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));\n\n float d = q.x - min(q.w, q.y);\n float e = 1.0e-10;\n return abs(6.0 * d + e);\n}\n\n// get saturation of a color in values between 0 and 1\nfloat getSaturation(vec3 color) {\n float max = max(color.r, max(color.g, color.b));\n float min = min(color.r, min(color.g, color.b));\n return (max - min) / max;\n}\n \nvec3 rgb2hsv(vec3 c)\n{\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n\n float d = q.x - min(q.w, q.y);\n float e = 1.0e-10;\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n}\n\nvec3 hsv2rgb(vec3 c)\n{\n vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n`;\n\n\nconst setLinkStyles = (link: HTMLAnchorElement) => {\n link.id = \"neat-link\";\n link.href = \"https://neat.firecms.co\";\n link.target = \"_blank\";\n link.style.position = \"absolute\";\n link.style.display = \"block\";\n link.style.opacity = \"1\";\n link.style.bottom = \"0\";\n link.style.right = \"0\";\n link.style.padding = \"10px\";\n link.style.color = \"#dcdcdc\";\n link.style.fontFamily = \"sans-serif\";\n link.style.fontSize = \"16px\";\n link.style.fontWeight = \"bold\";\n link.style.textDecoration = \"none\";\n link.style.zIndex = \"100\";\n link.innerHTML = \"NEAT\";\n}\n\nconst addNeatLink = (ref: HTMLCanvasElement) => {\n const existingLinks = ref.parentElement?.getElementsByTagName(\"a\");\n if (existingLinks) {\n for (let i = 0; i < existingLinks.length; i++) {\n if (existingLinks[i].id === \"neat-link\") {\n setLinkStyles(existingLinks[i]);\n return;\n }\n }\n }\n const link = document.createElement(\"a\");\n setLinkStyles(link);\n ref.parentElement?.appendChild(link);\n}\n"],"names":["PLANE_WIDTH","PLANE_HEIGHT","WIREFRAME","COLORS_COUNT","clock","THREE","NeatGradient","config","ref","speed","horizontalPressure","verticalPressure","waveFrequencyX","waveFrequencyY","waveAmplitude","colors","highlights","shadows","saturation","colorBlending","wireframe","backgroundColor","backgroundAlpha","width","height","renderer","camera","scene","meshes","tick","render","addNeatLink","mesh","color","setSize","canvas","updateCamera","entries","material","geo","plane","uniforms","buildUniforms","buildNoise","buildColorFunctions","buildVertexShader","buildFragmentShader","targetPlaneArea","ratio","targetWidth","targetHeight","left","right","top","bottom","near","far","setLinkStyles","link","existingLinks","i"],"mappings":";AAEA,MAAMA,IAAc,IACdC,IAAe,IAEfC,IAAY,IACZC,IAAe,GAEfC,IAAQ,IAAIC,EAAM;AAuCjB,MAAMC,EAAuC;AAAA,EAExC,SAAiB;AAAA,EAEjB,sBAA8B;AAAA,EAC9B,oBAA4B;AAAA,EAE5B,kBAA0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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAuLnBC,IAAsB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,GA8C5Ba,IAAgB,CAACC,MAA4B;AAC/C,EAAAA,EAAK,KAAK,aACVA,EAAK,OAAO,2BACZA,EAAK,SAAS,UACdA,EAAK,MAAM,WAAW,YACtBA,EAAK,MAAM,UAAU,SACrBA,EAAK,MAAM,UAAU,KACrBA,EAAK,MAAM,SAAS,KACpBA,EAAK,MAAM,QAAQ,KACnBA,EAAK,MAAM,UAAU,QACrBA,EAAK,MAAM,QAAQ,WACnBA,EAAK,MAAM,aAAa,cACxBA,EAAK,MAAM,WAAW,QACtBA,EAAK,MAAM,aAAa,QACxBA,EAAK,MAAM,iBAAiB,QAC5BA,EAAK,MAAM,SAAS,OACpBA,EAAK,YAAY;AACrB,GAEM3B,IAAc,CAACvB,MAA2B;AAC5C,QAAMmD,IAAgBnD,EAAI,eAAe,qBAAqB,GAAG;AACjE,MAAImD;AACA,aAASC,IAAI,GAAGA,IAAID,EAAc,QAAQC;AAClC,UAAAD,EAAcC,GAAG,OAAO,aAAa;AACrC,QAAAH,EAAcE,EAAcC,EAAE;AAC9B;AAAA,MACJ;AAAA;AAGF,QAAAF,IAAO,SAAS,cAAc,GAAG;AACvC,EAAAD,EAAcC,CAAI,GACdlD,EAAA,eAAe,YAAYkD,CAAI;AACvC;"}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../src/NeatGradient.ts"],"sourcesContent":["import * as THREE from \"three\";\n\nconst PLANE_WIDTH = 50;\nconst PLANE_HEIGHT = 80;\n\nconst WIREFRAME = true;\nconst COLORS_COUNT = 5;\n\nconst clock = new THREE.Clock();\n\ntype SceneState = {\n renderer: THREE.WebGLRenderer,\n camera: THREE.OrthographicCamera,\n scene: THREE.Scene,\n meshes: THREE.Mesh[],\n}\n\nexport type NeatConfig = {\n speed?: number;\n horizontalPressure?: number;\n verticalPressure?: number;\n waveFrequencyX?: number;\n waveFrequencyY?: number;\n waveAmplitude?: number;\n highlights?: number;\n shadows?: number;\n colorSaturation?: number;\n colorBrightness?: number;\n colors: NeatColor[];\n colorBlending?: number;\n wireframe?: boolean;\n backgroundColor?: string;\n backgroundAlpha?: number;\n};\n\nexport type NeatColor = {\n color: string;\n enabled: boolean;\n /**\n * Value from 0 to 1\n */\n influence?: number;\n}\n\nexport type NeatController = {\n destroy: () => void;\n}\n\nexport class NeatGradient implements NeatController {\n\n private _speed: number = -1;\n\n private _horizontalPressure: number = -1;\n private _verticalPressure: number = -1;\n\n private _waveFrequencyX: number = -1;\n private _waveFrequencyY: number = -1;\n private _waveAmplitude: number = -1;\n\n private _shadows: number = -1;\n private _highlights: number = -1;\n private _saturation: number = -1;\n private _brightness: number = -1;\n\n private _colorBlending: number = -1;\n\n private _colors: NeatColor[] = [];\n private _wireframe: boolean = false;\n\n private _backgroundColor: string = \"#FFFFFF\";\n private _backgroundAlpha: number = 1.0;\n\n private requestRef: number = -1;\n private sizeObserver: ResizeObserver;\n private readonly sceneState: SceneState;\n\n constructor(config: NeatConfig & { ref: HTMLCanvasElement, resolution?: number }) {\n\n const {\n ref,\n speed = 4,\n horizontalPressure = 3,\n verticalPressure = 3,\n waveFrequencyX = 5,\n waveFrequencyY = 5,\n waveAmplitude = 3,\n colors,\n highlights = 4,\n shadows = 4,\n colorSaturation = 0,\n colorBrightness = 1,\n colorBlending = 5,\n wireframe = false,\n backgroundColor = \"#FFFFFF\",\n backgroundAlpha = 1.0,\n resolution = 1\n } = config;\n\n const width = ref.width,\n height = ref.height;\n\n this.destroy = this.destroy.bind(this);\n this._initScene = this._initScene.bind(this);\n this._buildMaterial = this._buildMaterial.bind(this);\n\n this.speed = speed;\n this.horizontalPressure = horizontalPressure;\n this.verticalPressure = verticalPressure;\n this.waveFrequencyX = waveFrequencyX;\n this.waveFrequencyY = waveFrequencyY;\n this.waveAmplitude = waveAmplitude;\n this.colorBlending = colorBlending;\n this.colors = colors;\n this.shadows = shadows;\n this.highlights = highlights;\n this.colorSaturation = colorSaturation;\n this.colorBrightness = colorBrightness;\n this.wireframe = wireframe;\n this.backgroundColor = backgroundColor;\n this.backgroundAlpha = backgroundAlpha;\n\n this.sceneState = this._initScene(ref, width, height, resolution);\n\n const { renderer, camera, scene, meshes } = this.sceneState;\n\n let tick = 0;\n const render = () => {\n\n if (Math.floor(tick * 10) % 5 === 0) {\n addNeatLink(ref);\n }\n\n renderer.setClearColor(this._backgroundColor, this._backgroundAlpha);\n meshes.forEach((mesh) => {\n\n const colors = [\n ...this._colors.map(color => ({\n is_active: color.enabled,\n color: new THREE.Color(color.color),\n influence: color.influence\n })),\n ...Array.from({ length: COLORS_COUNT - this._colors.length }).map(() => ({\n is_active: false,\n color: new THREE.Color(0x000000)\n }))\n ];\n\n tick += clock.getDelta() * this._speed;\n // @ts-ignore\n mesh.material.uniforms.u_time.value = tick;\n // @ts-ignore\n mesh.material.uniforms.u_resolution = { value: new THREE.Vector2(width, height) };\n // @ts-ignore\n mesh.material.uniforms.u_color_pressure = { value: new THREE.Vector2(this._horizontalPressure, this._verticalPressure) };\n // @ts-ignore\n mesh.material.uniforms.u_wave_frequency_x = { value: this._waveFrequencyX };\n // @ts-ignore\n mesh.material.uniforms.u_wave_frequency_y = { value: this._waveFrequencyY };\n // @ts-ignore\n mesh.material.uniforms.u_wave_amplitude = { value: this._waveAmplitude };\n // @ts-ignore\n mesh.material.uniforms.u_plane_width = { value: PLANE_WIDTH };\n // @ts-ignore\n mesh.material.uniforms.u_plane_height = { value: PLANE_HEIGHT };\n // @ts-ignore\n mesh.material.uniforms.u_color_blending = { value: this._colorBlending };\n // @ts-ignore\n mesh.material.uniforms.u_colors = { value: colors };\n // @ts-ignore\n mesh.material.uniforms.u_colors_count = { value: COLORS_COUNT };\n // @ts-ignore\n mesh.material.uniforms.u_shadows = { value: this._shadows };\n // @ts-ignore\n mesh.material.uniforms.u_highlights = { value: this._highlights };\n // @ts-ignore\n mesh.material.uniforms.u_saturation = { value: this._saturation };\n // @ts-ignore\n mesh.material.uniforms.u_brightness = { value: this._brightness };\n // @ts-ignore\n mesh.material.wireframe = this._wireframe;\n });\n\n renderer.render(scene, camera);\n this.requestRef = requestAnimationFrame(render);\n };\n\n const setSize = () => {\n const canvas = renderer.domElement;\n const width = canvas.clientWidth;\n const height = canvas.clientHeight;\n\n this.sceneState.renderer.setSize(width, height, false);\n updateCamera(this.sceneState.camera, width, height);\n };\n\n this.sizeObserver = new ResizeObserver(entries => {\n setSize();\n });\n\n this.sizeObserver.observe(ref);\n\n\n render();\n }\n\n destroy() {\n if (this) {\n cancelAnimationFrame(this.requestRef);\n this.sizeObserver.disconnect();\n }\n }\n\n set speed(speed: number) {\n this._speed = speed / 20;\n }\n\n set horizontalPressure(horizontalPressure: number) {\n this._horizontalPressure = horizontalPressure / 4;\n }\n\n set verticalPressure(verticalPressure: number) {\n this._verticalPressure = verticalPressure / 4;\n }\n\n set waveFrequencyX(waveFrequencyX: number) {\n this._waveFrequencyX = waveFrequencyX * 0.04;\n }\n\n set waveFrequencyY(waveFrequencyY: number) {\n this._waveFrequencyY = waveFrequencyY * 0.04;\n }\n\n set waveAmplitude(waveAmplitude: number) {\n this._waveAmplitude = waveAmplitude * .75;\n }\n\n set colors(colors: NeatColor[]) {\n this._colors = colors;\n }\n\n set highlights(highlights: number) {\n this._highlights = highlights / 100;\n }\n\n set shadows(shadows: number) {\n this._shadows = shadows / 100;\n }\n\n set colorSaturation(colorSaturation: number) {\n this._saturation = colorSaturation / 10;\n }\n\n set colorBrightness(colorBrightness: number) {\n console.log(\"colorBrightness\", colorBrightness)\n this._brightness = colorBrightness;\n }\n\n set colorBlending(colorBlending: number) {\n this._colorBlending = colorBlending / 10;\n }\n\n set wireframe(wireframe: boolean) {\n this._wireframe = wireframe;\n }\n\n set backgroundColor(backgroundColor: string) {\n this._backgroundColor = backgroundColor;\n }\n\n set backgroundAlpha(backgroundAlpha: number) {\n this._backgroundAlpha = backgroundAlpha;\n }\n\n _initScene(ref: HTMLCanvasElement, width: number, height: number, resolution: number): SceneState {\n\n const renderer = new THREE.WebGLRenderer({\n // antialias: true,\n alpha: true,\n canvas: ref\n });\n\n renderer.setClearColor(0xFF0000, .5);\n renderer.setSize(width, height, false);\n\n const meshes: THREE.Mesh[] = [];\n\n const scene = new THREE.Scene();\n\n const material = this._buildMaterial(width, height);\n\n const geo = new THREE.PlaneGeometry(PLANE_WIDTH, PLANE_HEIGHT, 240 * resolution, 240 * resolution);\n const plane = new THREE.Mesh(geo, material);\n plane.rotation.x = -Math.PI / 3.5;\n plane.position.z = -1;\n meshes.push(plane);\n scene.add(plane);\n\n const camera = new THREE.OrthographicCamera(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);\n // camera.zoom = 1;\n updateCamera(camera, width, height);\n\n return {\n renderer,\n camera,\n scene,\n meshes\n };\n }\n\n _buildMaterial(width: number, height: number) {\n\n const colors = [\n ...this._colors.map(color => ({\n is_active: color.enabled,\n color: new THREE.Color(color.color),\n influence: color.influence\n })),\n ...Array.from({ length: COLORS_COUNT - this._colors.length }).map(() => ({\n is_active: false,\n color: new THREE.Color(0x000000)\n }))\n ];\n\n const uniforms = {\n u_time: { value: 0 },\n u_color_pressure: { value: new THREE.Vector2(this._horizontalPressure, this._verticalPressure) },\n u_wave_frequency_x: { value: this._waveFrequencyX },\n u_wave_frequency_y: { value: this._waveFrequencyY },\n u_wave_amplitude: { value: this._waveAmplitude },\n u_resolution: { value: new THREE.Vector2(width, height) },\n u_colors: { value: colors },\n u_colors_count: { value: this._colors.length },\n u_plane_width: { value: PLANE_WIDTH },\n u_plane_height: { value: PLANE_HEIGHT },\n u_shadows: { value: this._shadows },\n u_highlights: { value: this._highlights },\n };\n\n const material = new THREE.ShaderMaterial({\n uniforms: uniforms,\n vertexShader: buildUniforms() + buildNoise() + buildColorFunctions() + buildVertexShader(),\n fragmentShader: buildUniforms() + buildColorFunctions() + buildFragmentShader()\n });\n\n material.wireframe = WIREFRAME;\n return material;\n }\n\n\n}\n\nfunction updateCamera(camera: THREE.OrthographicCamera, width: number, height: number) {\n\n const viewPortAreaRatio = 1000000;\n const areaViewPort = width * height;\n const targetPlaneArea =\n areaViewPort / viewPortAreaRatio *\n PLANE_WIDTH * PLANE_HEIGHT / 1.5;\n\n const ratio = width / height;\n\n const targetWidth = Math.sqrt(targetPlaneArea * ratio);\n const targetHeight = targetPlaneArea / targetWidth;\n\n const left = -PLANE_WIDTH / 2;\n const right = Math.min((left + targetWidth) / 1.5, PLANE_WIDTH / 2);\n\n const top = PLANE_HEIGHT / 4;\n const bottom = Math.max((top - targetHeight) / 2, -PLANE_HEIGHT / 4);\n\n const near = -100;\n const far = 1000;\n camera.left = left;\n camera.right = right;\n camera.top = top;\n camera.bottom = bottom;\n camera.near = near;\n camera.far = far;\n camera.updateProjectionMatrix();\n}\n\n\nfunction buildVertexShader() {\n return `\n\nvoid main() {\n\n vUv = uv;\n\n v_displacement_amount = cnoise( vec3(\n u_wave_frequency_x * position.x + u_time,\n u_wave_frequency_y * position.y + u_time,\n u_time\n ));\n \n vec3 color;\n\n // float t = mod(u_base_color, 100.0);\n color = u_colors[0].color;\n \n vec2 noise_cord = vUv * u_color_pressure;\n \n const float minNoise = .0;\n const float maxNoise = .9;\n \n for (int i = 1; i < u_colors_count; i++) {\n \n if(u_colors[i].is_active == 1.0){\n float noiseFlow = (1. + float(i)) / 30.;\n float noiseSpeed = (1. + float(i)) * 0.11;\n float noiseSeed = 13. + float(i) * 7.;\n \n float noise = snoise(\n vec3(\n noise_cord.x * u_color_pressure.x + u_time * noiseFlow * 2.,\n noise_cord.y * u_color_pressure.y,\n u_time * noiseSpeed\n ) + noiseSeed\n );\n \n noise = clamp(minNoise, maxNoise + float(i) * 0.02, noise);\n vec3 nextColor = u_colors[i].color;\n color = mix(color, nextColor, smoothstep(0.0, u_color_blending, noise));\n }\n \n }\n \n v_color = color;\n \n vec3 newPosition = position + normal * v_displacement_amount * u_wave_amplitude;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0 );\n \n v_new_position = gl_Position;\n}\n`;\n}\n\nfunction buildFragmentShader() {\n return `\n\nvoid main(){\n vec3 color = v_color;\n \n color.rgb += pow(v_displacement_amount, 1.0) * u_highlights;\n color.rgb -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;\n color = saturation(color, 1.0 + u_saturation);\n color = color * u_brightness;\n \n gl_FragColor = vec4(color,1.0);\n}\n`;\n}\n\nconst buildUniforms = () => `\nprecision highp float;\n\nstruct Color {\n float is_active;\n vec3 color;\n float value;\n};\n\nuniform float u_time;\n\nuniform float u_wave_amplitude;\nuniform float u_wave_frequency_x;\nuniform float u_wave_frequency_y;\n\nuniform vec2 u_color_pressure;\n\nuniform float u_plane_width;\nuniform float u_plane_height;\n\nuniform float u_shadows;\nuniform float u_highlights;\nuniform float u_saturation;\nuniform float u_brightness;\n\nuniform float u_color_blending;\n\nuniform int u_colors_count;\nuniform Color u_colors[5];\nuniform vec2 u_resolution;\n\nvarying vec2 vUv;\nvarying vec4 v_new_position;\nvarying vec3 v_color;\nvarying float v_displacement_amount;\n\n `;\n\nconst buildNoise = () => `\n\nvec3 mod289(vec3 x)\n{\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 mod289(vec4 x)\n{\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x)\n{\n return mod289(((x*34.0)+1.0)*x);\n}\n\nvec4 taylorInvSqrt(vec4 r)\n{\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec3 fade(vec3 t) {\n return t*t*t*(t*(t*6.0-15.0)+10.0);\n}\n\nfloat snoise(vec3 v)\n{\n const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n// First corner\n vec3 i = floor(v + dot(v, C.yyy) );\n vec3 x0 = v - i + dot(i, C.xxx) ;\n\n// Other corners\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n // x0 = x0 - 0.0 + 0.0 * C.xxx;\n // x1 = x0 - i1 + 1.0 * C.xxx;\n // x2 = x0 - i2 + 2.0 * C.xxx;\n // x3 = x0 - 1.0 + 3.0 * C.xxx;\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n// Permutations\n i = mod289(i);\n vec4 p = permute( permute( permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\n// Gradients: 7x7 points over a square, mapped onto an octahedron.\n// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;\n //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;\n vec4 s0 = floor(b0)*2.0 + 1.0;\n vec4 s1 = floor(b1)*2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n\n vec3 p0 = vec3(a0.xy,h.x);\n vec3 p1 = vec3(a0.zw,h.y);\n vec3 p2 = vec3(a1.xy,h.z);\n vec3 p3 = vec3(a1.zw,h.w);\n\n//Normalise gradients\n vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n// Mix final noise value\n vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),\n dot(p2,x2), dot(p3,x3) ) );\n}\n\n// Classic Perlin noise\nfloat cnoise(vec3 P)\n{\n vec3 Pi0 = floor(P); // Integer part for indexing\n vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); // Fractional part for interpolation\n vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);\n return 2.2 * n_xyz;\n}\n\n// YUV to RGB matrix\nmat3 yuv2rgb = mat3(1.0, 0.0, 1.13983,\n 1.0, -0.39465, -0.58060,\n 1.0, 2.03211, 0.0);\n\n// RGB to YUV matrix\nmat3 rgb2yuv = mat3(0.2126, 0.7152, 0.0722,\n -0.09991, -0.33609, 0.43600,\n 0.615, -0.5586, -0.05639);\n\n `;\n\nconst buildColorFunctions = () => `\n\nvec3 saturation(vec3 rgb, float adjustment) {\n const vec3 W = vec3(0.2125, 0.7154, 0.0721);\n vec3 intensity = vec3(dot(rgb, W));\n return mix(intensity, rgb, adjustment);\n}\n\nfloat saturation(vec3 rgb)\n{\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(rgb.bg, K.wz), vec4(rgb.gb, K.xy), step(rgb.b, rgb.g));\n vec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));\n\n float d = q.x - min(q.w, q.y);\n float e = 1.0e-10;\n return abs(6.0 * d + e);\n}\n\n// get saturation of a color in values between 0 and 1\nfloat getSaturation(vec3 color) {\n float max = max(color.r, max(color.g, color.b));\n float min = min(color.r, min(color.g, color.b));\n return (max - min) / max;\n}\n \nvec3 rgb2hsv(vec3 c)\n{\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n\n float d = q.x - min(q.w, q.y);\n float e = 1.0e-10;\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n}\n\nvec3 hsv2rgb(vec3 c)\n{\n vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n`;\n\n\nconst setLinkStyles = (link: HTMLAnchorElement) => {\n link.id = \"neat-link\";\n link.href = \"https://neat.firecms.co\";\n link.target = \"_blank\";\n link.style.position = \"absolute\";\n link.style.display = \"block\";\n link.style.opacity = \"1\";\n link.style.bottom = \"0\";\n link.style.right = \"0\";\n link.style.padding = \"10px\";\n link.style.color = \"#dcdcdc\";\n link.style.fontFamily = \"sans-serif\";\n link.style.fontSize = \"16px\";\n link.style.fontWeight = \"bold\";\n link.style.textDecoration = \"none\";\n link.style.zIndex = \"100\";\n link.innerHTML = \"NEAT\";\n}\n\nconst addNeatLink = (ref: HTMLCanvasElement) => {\n const existingLinks = ref.parentElement?.getElementsByTagName(\"a\");\n if (existingLinks) {\n for (let i = 0; i < existingLinks.length; i++) {\n if (existingLinks[i].id === \"neat-link\") {\n setLinkStyles(existingLinks[i]);\n return;\n }\n }\n }\n const link = document.createElement(\"a\");\n setLinkStyles(link);\n ref.parentElement?.appendChild(link);\n}\n"],"names":["PLANE_WIDTH","PLANE_HEIGHT","WIREFRAME","COLORS_COUNT","clock","THREE","NeatGradient","config","ref","speed","horizontalPressure","verticalPressure","waveFrequencyX","waveFrequencyY","waveAmplitude","colors","highlights","shadows","colorSaturation","colorBrightness","colorBlending","wireframe","backgroundColor","backgroundAlpha","resolution","width","height","renderer","camera","scene","meshes","tick","render","addNeatLink","mesh","color","setSize","canvas","updateCamera","entries","material","geo","plane","uniforms","buildUniforms","buildNoise","buildColorFunctions","buildVertexShader","buildFragmentShader","targetPlaneArea","ratio","targetWidth","targetHeight","left","right","top","bottom","near","far","setLinkStyles","link","existingLinks","i"],"mappings":";AAEA,MAAMA,IAAc,IACdC,IAAe,IAEfC,IAAY,IACZC,IAAe,GAEfC,IAAQ,IAAIC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G;AACjE,MAAIqD;AACA,aAASC,IAAI,GAAGA,IAAID,EAAc,QAAQC;AAClC,UAAAD,EAAcC,GAAG,OAAO,aAAa;AACrC,QAAAH,EAAcE,EAAcC,EAAE;AAC9B;AAAA,MACJ;AAAA;AAGF,QAAAF,IAAO,SAAS,cAAc,GAAG;AACvC,EAAAD,EAAcC,CAAI,GACdpD,EAAA,eAAe,YAAYoD,CAAI;AACvC;"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(l,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],h):(l=typeof globalThis<"u"?globalThis:l||self,h(l.FireCMS={},l.THREE))})(this,function(l,h){"use strict";function O(t){if(t&&t.__esModule)return t;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const i=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,i.get?i:{enumerable:!0,get:()=>t[o]})}}return e.default=t,Object.freeze(e)}const s=O(h),g=50,x=80,T=!0,p=5,j=new s.Clock;class R{_speed=-1;_horizontalPressure=-1;_verticalPressure=-1;_waveFrequencyX=-1;_waveFrequencyY=-1;_waveAmplitude=-1;_shadows=-1;_highlights=-1;_saturation=-1;_brightness=-1;_colorBlending=-1;_colors=[];_wireframe=!1;_backgroundColor="#FFFFFF";_backgroundAlpha=1;requestRef=-1;sizeObserver;sceneState;constructor(e){const{ref:o,speed:i=4,horizontalPressure:u=3,verticalPressure:n=3,waveFrequencyX:a=5,waveFrequencyY:v=5,waveAmplitude:m=3,colors:f,highlights:c=4,shadows:_=4,colorSaturation:w=0,colorBrightness:z=1,colorBlending:b=5,wireframe:k=!1,backgroundColor:D="#FFFFFF",backgroundAlpha:Y=1,resolution:G=1}=e,M=o.width,E=o.height;this.destroy=this.destroy.bind(this),this._initScene=this._initScene.bind(this),this._buildMaterial=this._buildMaterial.bind(this),this.speed=i,this.horizontalPressure=u,this.verticalPressure=n,this.waveFrequencyX=a,this.waveFrequencyY=v,this.waveAmplitude=m,this.colorBlending=b,this.colors=f,this.shadows=_,this.highlights=c,this.colorSaturation=w,this.colorBrightness=z,this.wireframe=k,this.backgroundColor=D,this.backgroundAlpha=Y,this.sceneState=this._initScene(o,M,E,G);const{renderer:P,camera:H,scene:L,meshes:W}=this.sceneState;let q=0;const N=()=>{Math.floor(q*10)%5===0&&V(o),P.setClearColor(this._backgroundColor,this._backgroundAlpha),W.forEach(r=>{const y=[...this._colors.map(d=>({is_active:d.enabled,color:new s.Color(d.color),influence:d.influence})),...Array.from({length:p-this._colors.length}).map(()=>({is_active:!1,color:new s.Color(0)}))];q+=j.getDelta()*this._speed,r.material.uniforms.u_time.value=q,r.material.uniforms.u_resolution={value:new s.Vector2(M,E)},r.material.uniforms.u_color_pressure={value:new s.Vector2(this._horizontalPressure,this._verticalPressure)},r.material.uniforms.u_wave_frequency_x={value:this._waveFrequencyX},r.material.uniforms.u_wave_frequency_y={value:this._waveFrequencyY},r.material.uniforms.u_wave_amplitude={value:this._waveAmplitude},r.material.uniforms.u_plane_width={value:g},r.material.uniforms.u_plane_height={value:x},r.material.uniforms.u_color_blending={value:this._colorBlending},r.material.uniforms.u_colors={value:y},r.material.uniforms.u_colors_count={value:p},r.material.uniforms.u_shadows={value:this._shadows},r.material.uniforms.u_highlights={value:this._highlights},r.material.uniforms.u_saturation={value:this._saturation},r.material.uniforms.u_brightness={value:this._brightness},r.material.wireframe=this._wireframe}),P.render(L,H),this.requestRef=requestAnimationFrame(N)},U=()=>{const r=P.domElement,y=r.clientWidth,d=r.clientHeight;this.sceneState.renderer.setSize(y,d,!1),C(this.sceneState.camera,y,d)};this.sizeObserver=new ResizeObserver(r=>{U()}),this.sizeObserver.observe(o),N()}destroy(){this&&(cancelAnimationFrame(this.requestRef),this.sizeObserver.disconnect())}set speed(e){this._speed=e/20}set horizontalPressure(e){this._horizontalPressure=e/4}set verticalPressure(e){this._verticalPressure=e/4}set waveFrequencyX(e){this._waveFrequencyX=e*.04}set waveFrequencyY(e){this._waveFrequencyY=e*.04}set waveAmplitude(e){this._waveAmplitude=e*.75}set colors(e){this._colors=e}set highlights(e){this._highlights=e/100}set shadows(e){this._shadows=e/100}set colorSaturation(e){this._saturation=e/10}set colorBrightness(e){console.log("colorBrightness",e),this._brightness=e}set colorBlending(e){this._colorBlending=e/10}set wireframe(e){this._wireframe=e}set backgroundColor(e){this._backgroundColor=e}set backgroundAlpha(e){this._backgroundAlpha=e}_initScene(e,o,i,u){const n=new s.WebGLRenderer({alpha:!0,canvas:e});n.setClearColor(16711680,.5),n.setSize(o,i,!1);const a=[],v=new s.Scene,m=this._buildMaterial(o,i),f=new s.PlaneGeometry(g,x,240*u,240*u),c=new s.Mesh(f,m);c.rotation.x=-Math.PI/3.5,c.position.z=-1,a.push(c),v.add(c);const _=new s.OrthographicCamera(0,0,0,0,0,0);return C(_,o,i),{renderer:n,camera:_,scene:v,meshes:a}}_buildMaterial(e,o){const i=[...this._colors.map(a=>({is_active:a.enabled,color:new s.Color(a.color),influence:a.influence})),...Array.from({length:p-this._colors.length}).map(()=>({is_active:!1,color:new s.Color(0)}))],u={u_time:{value:0},u_color_pressure:{value:new s.Vector2(this._horizontalPressure,this._verticalPressure)},u_wave_frequency_x:{value:this._waveFrequencyX},u_wave_frequency_y:{value:this._waveFrequencyY},u_wave_amplitude:{value:this._waveAmplitude},u_resolution:{value:new s.Vector2(e,o)},u_colors:{value:i},u_colors_count:{value:this._colors.length},u_plane_width:{value:g},u_plane_height:{value:x},u_shadows:{value:this._shadows},u_highlights:{value:this._highlights}},n=new s.ShaderMaterial({uniforms:u,vertexShader:F()+K()+S()+B(),fragmentShader:F()+S()+I()});return n.wireframe=T,n}}function C(t,e,o){const n=e*o/1e6*g*x/1.5,a=e/o,v=Math.sqrt(n*a),m=n/v,f=-g/2,c=Math.min((f+v)/1.5,g/2),_=x/4,w=Math.max((_-m)/2,-x/4),z=-100,b=1e3;t.left=f,t.right=c,t.top=_,t.bottom=w,t.near=z,t.far=b,t.updateProjectionMatrix()}function B(){return`
|
|
2
2
|
|
|
3
3
|
void main() {
|
|
4
4
|
|
|
@@ -49,7 +49,7 @@ void main() {
|
|
|
49
49
|
|
|
50
50
|
v_new_position = gl_Position;
|
|
51
51
|
}
|
|
52
|
-
`}function
|
|
52
|
+
`}function I(){return`
|
|
53
53
|
|
|
54
54
|
void main(){
|
|
55
55
|
vec3 color = v_color;
|
|
@@ -57,6 +57,7 @@ void main(){
|
|
|
57
57
|
color.rgb += pow(v_displacement_amount, 1.0) * u_highlights;
|
|
58
58
|
color.rgb -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;
|
|
59
59
|
color = saturation(color, 1.0 + u_saturation);
|
|
60
|
+
color = color * u_brightness;
|
|
60
61
|
|
|
61
62
|
gl_FragColor = vec4(color,1.0);
|
|
62
63
|
}
|
|
@@ -83,6 +84,7 @@ uniform float u_plane_height;
|
|
|
83
84
|
uniform float u_shadows;
|
|
84
85
|
uniform float u_highlights;
|
|
85
86
|
uniform float u_saturation;
|
|
87
|
+
uniform float u_brightness;
|
|
86
88
|
|
|
87
89
|
uniform float u_color_blending;
|
|
88
90
|
|
|
@@ -95,7 +97,7 @@ varying vec4 v_new_position;
|
|
|
95
97
|
varying vec3 v_color;
|
|
96
98
|
varying float v_displacement_amount;
|
|
97
99
|
|
|
98
|
-
`,
|
|
100
|
+
`,K=()=>`
|
|
99
101
|
|
|
100
102
|
vec3 mod289(vec3 x)
|
|
101
103
|
{
|
|
@@ -319,5 +321,5 @@ vec3 hsv2rgb(vec3 c)
|
|
|
319
321
|
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
|
320
322
|
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
|
321
323
|
}
|
|
322
|
-
`,A=t=>{t.id="neat-link",t.href="https://neat.firecms.co",t.target="_blank",t.style.position="absolute",t.style.display="block",t.style.opacity="1",t.style.bottom="0",t.style.right="0",t.style.padding="10px",t.style.color="#dcdcdc",t.style.fontFamily="sans-serif",t.style.fontSize="16px",t.style.fontWeight="bold",t.style.textDecoration="none",t.style.zIndex="100",t.innerHTML="NEAT"},
|
|
324
|
+
`,A=t=>{t.id="neat-link",t.href="https://neat.firecms.co",t.target="_blank",t.style.position="absolute",t.style.display="block",t.style.opacity="1",t.style.bottom="0",t.style.right="0",t.style.padding="10px",t.style.color="#dcdcdc",t.style.fontFamily="sans-serif",t.style.fontSize="16px",t.style.fontWeight="bold",t.style.textDecoration="none",t.style.zIndex="100",t.innerHTML="NEAT"},V=t=>{const e=t.parentElement?.getElementsByTagName("a");if(e){for(let i=0;i<e.length;i++)if(e[i].id==="neat-link"){A(e[i]);return}}const o=document.createElement("a");A(o),t.parentElement?.appendChild(o)};l.NeatGradient=R,Object.defineProperties(l,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
323
325
|
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/NeatGradient.ts"],"sourcesContent":["import * as THREE from \"three\";\n\nconst PLANE_WIDTH = 50;\nconst PLANE_HEIGHT = 80;\n\nconst WIREFRAME = true;\nconst COLORS_COUNT = 5;\n\nconst clock = new THREE.Clock();\n\ntype SceneState = {\n renderer: THREE.WebGLRenderer,\n camera: THREE.OrthographicCamera,\n scene: THREE.Scene,\n meshes: THREE.Mesh[],\n}\n\nexport type NeatConfig = {\n speed?: number;\n horizontalPressure?: number;\n verticalPressure?: number;\n waveFrequencyX?: number;\n waveFrequencyY?: number;\n waveAmplitude?: number;\n highlights?: number;\n shadows?: number;\n saturation?: number;\n colors: NeatColor[];\n colorBlending?: number;\n wireframe?: boolean;\n backgroundColor?: string;\n backgroundAlpha?: number;\n};\n\nexport type NeatColor = {\n color: string;\n enabled: boolean;\n /**\n * Value from 0 to 1\n */\n influence?: number;\n}\n\nexport type NeatController = {\n destroy: () => void;\n}\n\nexport class NeatGradient implements NeatController {\n\n private _speed: number = -1;\n\n private _horizontalPressure: number = -1;\n private _verticalPressure: number = -1;\n\n private _waveFrequencyX: number = -1;\n private _waveFrequencyY: number = -1;\n private _waveAmplitude: number = -1;\n\n private _shadows: number = -1;\n private _highlights: number = -1;\n private _saturation: number = -1;\n\n private _colorBlending: number = -1;\n\n private _colors: NeatColor[] = [];\n private _wireframe: boolean = false;\n\n private _backgroundColor: string = \"#FFFFFF\";\n private _backgroundAlpha: number = 1.0;\n\n private requestRef: number = -1;\n private sizeObserver: ResizeObserver;\n private readonly sceneState: SceneState;\n\n constructor(config: NeatConfig & { ref: HTMLCanvasElement }) {\n\n const {\n ref,\n speed = 4,\n horizontalPressure = 3,\n verticalPressure = 3,\n waveFrequencyX = 5,\n waveFrequencyY = 5,\n waveAmplitude = 3,\n colors,\n highlights = 4,\n shadows = 4,\n saturation = 0,\n colorBlending = 5,\n wireframe = false,\n backgroundColor = \"#FFFFFF\",\n backgroundAlpha = 1.0,\n } = config;\n\n const width = ref.width,\n height = ref.height;\n\n this.destroy = this.destroy.bind(this);\n this._initScene = this._initScene.bind(this);\n this._buildMaterial = this._buildMaterial.bind(this);\n\n this.speed = speed;\n this.horizontalPressure = horizontalPressure;\n this.verticalPressure = verticalPressure;\n this.waveFrequencyX = waveFrequencyX;\n this.waveFrequencyY = waveFrequencyY;\n this.waveAmplitude = waveAmplitude;\n this.colorBlending = colorBlending;\n this.colors = colors;\n this.shadows = shadows;\n this.highlights = highlights;\n this.saturation = saturation;\n this.wireframe = wireframe;\n this.backgroundColor = backgroundColor;\n this.backgroundAlpha = backgroundAlpha;\n\n this.sceneState = this._initScene(ref, width, height);\n\n const { renderer, camera, scene, meshes } = this.sceneState;\n\n let tick = 0;\n const render = () => {\n\n if (Math.floor(tick * 10) % 5 === 0) {\n addNeatLink(ref);\n }\n\n renderer.setClearColor(this._backgroundColor, this._backgroundAlpha);\n meshes.forEach((mesh) => {\n\n const colors = [\n ...this._colors.map(color => ({\n is_active: color.enabled,\n color: new THREE.Color(color.color),\n influence: color.influence\n })),\n ...Array.from({ length: COLORS_COUNT - this._colors.length }).map(() => ({\n is_active: false,\n color: new THREE.Color(0x000000)\n }))\n ];\n\n tick += clock.getDelta() * this._speed;\n // @ts-ignore\n mesh.material.uniforms.u_time.value = tick;\n // @ts-ignore\n mesh.material.uniforms.u_resolution = { value: new THREE.Vector2(width, height) };\n // @ts-ignore\n mesh.material.uniforms.u_color_pressure = { value: new THREE.Vector2(this._horizontalPressure, this._verticalPressure) };\n // @ts-ignore\n mesh.material.uniforms.u_wave_frequency_x = { value: this._waveFrequencyX };\n // @ts-ignore\n mesh.material.uniforms.u_wave_frequency_y = { value: this._waveFrequencyY };\n // @ts-ignore\n mesh.material.uniforms.u_wave_amplitude = { value: this._waveAmplitude };\n // @ts-ignore\n mesh.material.uniforms.u_plane_width = { value: PLANE_WIDTH };\n // @ts-ignore\n mesh.material.uniforms.u_plane_height = { value: PLANE_HEIGHT };\n // @ts-ignore\n mesh.material.uniforms.u_color_blending = { value: this._colorBlending };\n // @ts-ignore\n mesh.material.uniforms.u_colors = { value: colors };\n // @ts-ignore\n mesh.material.uniforms.u_colors_count = { value: COLORS_COUNT };\n // @ts-ignore\n mesh.material.uniforms.u_shadows = { value: this._shadows };\n // @ts-ignore\n mesh.material.uniforms.u_highlights = { value: this._highlights };\n // @ts-ignore\n mesh.material.uniforms.u_saturation = { value: this._saturation };\n // @ts-ignore\n mesh.material.wireframe = this._wireframe;\n });\n\n renderer.render(scene, camera);\n this.requestRef = requestAnimationFrame(render);\n };\n\n const setSize = () => {\n const canvas = renderer.domElement;\n const width = canvas.clientWidth;\n const height = canvas.clientHeight;\n\n this.sceneState.renderer.setSize(width, height, false);\n updateCamera(this.sceneState.camera, width, height);\n };\n\n this.sizeObserver = new ResizeObserver(entries => {\n setSize();\n });\n\n this.sizeObserver.observe(ref);\n\n\n render();\n }\n\n destroy() {\n if (this) {\n cancelAnimationFrame(this.requestRef);\n this.sizeObserver.disconnect();\n }\n }\n\n set speed(speed: number) {\n this._speed = speed / 20;\n }\n\n set horizontalPressure(horizontalPressure: number) {\n this._horizontalPressure = horizontalPressure / 4;\n }\n\n set verticalPressure(verticalPressure: number) {\n this._verticalPressure = verticalPressure / 4;\n }\n\n set waveFrequencyX(waveFrequencyX: number) {\n this._waveFrequencyX = waveFrequencyX * 0.04;\n }\n\n set waveFrequencyY(waveFrequencyY: number) {\n this._waveFrequencyY = waveFrequencyY * 0.04;\n }\n\n set waveAmplitude(waveAmplitude: number) {\n this._waveAmplitude = waveAmplitude * .75;\n }\n\n set colors(colors: NeatColor[]) {\n this._colors = colors;\n }\n\n set highlights(highlights: number) {\n this._highlights = highlights / 100;\n }\n\n set shadows(shadows: number) {\n this._shadows = shadows / 100;\n }\n\n set saturation(saturation: number) {\n this._saturation = saturation / 10;\n }\n\n set colorBlending(colorBlending: number) {\n this._colorBlending = colorBlending / 10;\n }\n\n set wireframe(wireframe: boolean) {\n this._wireframe = wireframe;\n }\n\n set backgroundColor(backgroundColor: string) {\n this._backgroundColor = backgroundColor;\n }\n\n set backgroundAlpha(backgroundAlpha: number) {\n this._backgroundAlpha = backgroundAlpha;\n }\n\n _initScene(ref: HTMLCanvasElement, width: number, height: number): SceneState {\n\n const renderer = new THREE.WebGLRenderer({\n // antialias: true,\n alpha: true,\n canvas: ref\n });\n\n renderer.setClearColor(0xFF0000, .5);\n renderer.setSize(width, height, false);\n\n const meshes: THREE.Mesh[] = [];\n\n const scene = new THREE.Scene();\n\n const material = this._buildMaterial(width, height);\n\n const geo = new THREE.PlaneGeometry(PLANE_WIDTH, PLANE_HEIGHT, 240, 240);\n const plane = new THREE.Mesh(geo, material);\n plane.rotation.x = -Math.PI / 3.5;\n plane.position.z = -1;\n meshes.push(plane);\n scene.add(plane);\n\n const camera = new THREE.OrthographicCamera(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);\n // camera.zoom = 1;\n updateCamera(camera, width, height);\n\n return {\n renderer,\n camera,\n scene,\n meshes\n };\n }\n\n _buildMaterial(width: number, height: number) {\n\n const colors = [\n ...this._colors.map(color => ({\n is_active: color.enabled,\n color: new THREE.Color(color.color),\n influence: color.influence\n })),\n ...Array.from({ length: COLORS_COUNT - this._colors.length }).map(() => ({\n is_active: false,\n color: new THREE.Color(0x000000)\n }))\n ];\n\n const uniforms = {\n u_time: { value: 0 },\n u_color_pressure: { value: new THREE.Vector2(this._horizontalPressure, this._verticalPressure) },\n u_wave_frequency_x: { value: this._waveFrequencyX },\n u_wave_frequency_y: { value: this._waveFrequencyY },\n u_wave_amplitude: { value: this._waveAmplitude },\n u_resolution: { value: new THREE.Vector2(width, height) },\n u_colors: { value: colors },\n u_colors_count: { value: this._colors.length },\n u_plane_width: { value: PLANE_WIDTH },\n u_plane_height: { value: PLANE_HEIGHT },\n u_shadows: { value: this._shadows },\n u_highlights: { value: this._highlights },\n };\n\n const material = new THREE.ShaderMaterial({\n uniforms: uniforms,\n vertexShader: buildUniforms() + buildNoise() + buildColorFunctions() + buildVertexShader(),\n fragmentShader: buildUniforms() + buildColorFunctions() + buildFragmentShader()\n });\n\n material.wireframe = WIREFRAME;\n return material;\n }\n\n\n}\n\nfunction updateCamera(camera: THREE.OrthographicCamera, width: number, height: number) {\n\n const viewPortAreaRatio = 1000000;\n const areaViewPort = width * height;\n const targetPlaneArea =\n areaViewPort / viewPortAreaRatio *\n PLANE_WIDTH * PLANE_HEIGHT / 1.5;\n\n const ratio = width / height;\n\n const targetWidth = Math.sqrt(targetPlaneArea * ratio);\n const targetHeight = targetPlaneArea / targetWidth;\n\n const left = -PLANE_WIDTH / 2;\n const right = Math.min((left + targetWidth) / 1.5, PLANE_WIDTH / 2);\n\n const top = PLANE_HEIGHT / 4;\n const bottom = Math.max((top - targetHeight) / 2, -PLANE_HEIGHT / 4);\n\n const near = -100;\n const far = 1000;\n camera.left = left;\n camera.right = right;\n camera.top = top;\n camera.bottom = bottom;\n camera.near = near;\n camera.far = far;\n camera.updateProjectionMatrix();\n}\n\n\nfunction buildVertexShader() {\n return `\n\nvoid main() {\n\n vUv = uv;\n\n v_displacement_amount = cnoise( vec3(\n u_wave_frequency_x * position.x + u_time,\n u_wave_frequency_y * position.y + u_time,\n u_time\n ));\n \n vec3 color;\n\n // float t = mod(u_base_color, 100.0);\n color = u_colors[0].color;\n \n vec2 noise_cord = vUv * u_color_pressure;\n \n const float minNoise = .0;\n const float maxNoise = .9;\n \n for (int i = 1; i < u_colors_count; i++) {\n \n if(u_colors[i].is_active == 1.0){\n float noiseFlow = (1. + float(i)) / 30.;\n float noiseSpeed = (1. + float(i)) * 0.11;\n float noiseSeed = 13. + float(i) * 7.;\n \n float noise = snoise(\n vec3(\n noise_cord.x * u_color_pressure.x + u_time * noiseFlow * 2.,\n noise_cord.y * u_color_pressure.y,\n u_time * noiseSpeed\n ) + noiseSeed\n );\n \n noise = clamp(minNoise, maxNoise + float(i) * 0.02, noise);\n vec3 nextColor = u_colors[i].color;\n color = mix(color, nextColor, smoothstep(0.0, u_color_blending, noise));\n }\n \n }\n \n v_color = color;\n \n vec3 newPosition = position + normal * v_displacement_amount * u_wave_amplitude;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0 );\n \n v_new_position = gl_Position;\n}\n`;\n}\n\nfunction buildFragmentShader() {\n return `\n\nvoid main(){\n vec3 color = v_color;\n \n color.rgb += pow(v_displacement_amount, 1.0) * u_highlights;\n color.rgb -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;\n color = saturation(color, 1.0 + u_saturation);\n \n gl_FragColor = vec4(color,1.0);\n}\n`;\n}\n\nconst buildUniforms = () => `\nprecision highp float;\n\nstruct Color {\n float is_active;\n vec3 color;\n float value;\n};\n\nuniform float u_time;\n\nuniform float u_wave_amplitude;\nuniform float u_wave_frequency_x;\nuniform float u_wave_frequency_y;\n\nuniform vec2 u_color_pressure;\n\nuniform float u_plane_width;\nuniform float u_plane_height;\n\nuniform float u_shadows;\nuniform float u_highlights;\nuniform float u_saturation;\n\nuniform float u_color_blending;\n\nuniform int u_colors_count;\nuniform Color u_colors[5];\nuniform vec2 u_resolution;\n\nvarying vec2 vUv;\nvarying vec4 v_new_position;\nvarying vec3 v_color;\nvarying float v_displacement_amount;\n\n `;\n\nconst buildNoise = () => `\n\nvec3 mod289(vec3 x)\n{\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 mod289(vec4 x)\n{\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x)\n{\n return mod289(((x*34.0)+1.0)*x);\n}\n\nvec4 taylorInvSqrt(vec4 r)\n{\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec3 fade(vec3 t) {\n return t*t*t*(t*(t*6.0-15.0)+10.0);\n}\n\nfloat snoise(vec3 v)\n{\n const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n// First corner\n vec3 i = floor(v + dot(v, C.yyy) );\n vec3 x0 = v - i + dot(i, C.xxx) ;\n\n// Other corners\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n // x0 = x0 - 0.0 + 0.0 * C.xxx;\n // x1 = x0 - i1 + 1.0 * C.xxx;\n // x2 = x0 - i2 + 2.0 * C.xxx;\n // x3 = x0 - 1.0 + 3.0 * C.xxx;\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n// Permutations\n i = mod289(i);\n vec4 p = permute( permute( permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\n// Gradients: 7x7 points over a square, mapped onto an octahedron.\n// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;\n //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;\n vec4 s0 = floor(b0)*2.0 + 1.0;\n vec4 s1 = floor(b1)*2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n\n vec3 p0 = vec3(a0.xy,h.x);\n vec3 p1 = vec3(a0.zw,h.y);\n vec3 p2 = vec3(a1.xy,h.z);\n vec3 p3 = vec3(a1.zw,h.w);\n\n//Normalise gradients\n vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n// Mix final noise value\n vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),\n dot(p2,x2), dot(p3,x3) ) );\n}\n\n// Classic Perlin noise\nfloat cnoise(vec3 P)\n{\n vec3 Pi0 = floor(P); // Integer part for indexing\n vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); // Fractional part for interpolation\n vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);\n return 2.2 * n_xyz;\n}\n\n// YUV to RGB matrix\nmat3 yuv2rgb = mat3(1.0, 0.0, 1.13983,\n 1.0, -0.39465, -0.58060,\n 1.0, 2.03211, 0.0);\n\n// RGB to YUV matrix\nmat3 rgb2yuv = mat3(0.2126, 0.7152, 0.0722,\n -0.09991, -0.33609, 0.43600,\n 0.615, -0.5586, -0.05639);\n\n `;\n\nconst buildColorFunctions = () => `\n\nvec3 saturation(vec3 rgb, float adjustment) {\n const vec3 W = vec3(0.2125, 0.7154, 0.0721);\n vec3 intensity = vec3(dot(rgb, W));\n return mix(intensity, rgb, adjustment);\n}\n\nfloat saturation(vec3 rgb)\n{\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(rgb.bg, K.wz), vec4(rgb.gb, K.xy), step(rgb.b, rgb.g));\n vec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));\n\n float d = q.x - min(q.w, q.y);\n float e = 1.0e-10;\n return abs(6.0 * d + e);\n}\n\n// get saturation of a color in values between 0 and 1\nfloat getSaturation(vec3 color) {\n float max = max(color.r, max(color.g, color.b));\n float min = min(color.r, min(color.g, color.b));\n return (max - min) / max;\n}\n \nvec3 rgb2hsv(vec3 c)\n{\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n\n float d = q.x - min(q.w, q.y);\n float e = 1.0e-10;\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n}\n\nvec3 hsv2rgb(vec3 c)\n{\n vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n`;\n\n\nconst setLinkStyles = (link: HTMLAnchorElement) => {\n link.id = \"neat-link\";\n link.href = \"https://neat.firecms.co\";\n link.target = \"_blank\";\n link.style.position = \"absolute\";\n link.style.display = \"block\";\n link.style.opacity = \"1\";\n link.style.bottom = \"0\";\n link.style.right = \"0\";\n link.style.padding = \"10px\";\n link.style.color = \"#dcdcdc\";\n link.style.fontFamily = \"sans-serif\";\n link.style.fontSize = \"16px\";\n link.style.fontWeight = \"bold\";\n link.style.textDecoration = \"none\";\n link.style.zIndex = \"100\";\n link.innerHTML = \"NEAT\";\n}\n\nconst addNeatLink = (ref: HTMLCanvasElement) => {\n const existingLinks = ref.parentElement?.getElementsByTagName(\"a\");\n if (existingLinks) {\n for (let i = 0; i < existingLinks.length; i++) {\n if (existingLinks[i].id === \"neat-link\") {\n setLinkStyles(existingLinks[i]);\n return;\n }\n }\n }\n const link = document.createElement(\"a\");\n setLinkStyles(link);\n ref.parentElement?.appendChild(link);\n}\n"],"names":["PLANE_WIDTH","PLANE_HEIGHT","WIREFRAME","COLORS_COUNT","clock","THREE","NeatGradient","config","ref","speed","horizontalPressure","verticalPressure","waveFrequencyX","waveFrequencyY","waveAmplitude","colors","highlights","shadows","saturation","colorBlending","wireframe","backgroundColor","backgroundAlpha","width","height","renderer","camera","scene","meshes","tick","render","addNeatLink","mesh","color","setSize","canvas","updateCamera","entries","material","geo","plane","uniforms","buildUniforms","buildNoise","buildColorFunctions","buildVertexShader","buildFragmentShader","targetPlaneArea","ratio","targetWidth","targetHeight","left","right","top","bottom","near","far","setLinkStyles","link","existingLinks"],"mappings":"wjBAEMA,EAAc,GACdC,EAAe,GAEfC,EAAY,GACZC,EAAe,EAEfC,EAAQ,IAAIC,EAAM,MAuCjB,MAAMC,CAAuC,CAExC,OAAiB,GAEjB,oBAA8B,GAC9B,kBAA4B,GAE5B,gBAA0B,GAC1B,gBAA0B,GAC1B,eAAyB,GAEzB,SAAmB,GACnB,YAAsB,GACtB,YAAsB,GAEtB,eAAyB,GAEzB,QAAuB,CAAA,EACvB,WAAsB,GAEtB,iBAA2B,UAC3B,iBAA2B,EAE3B,WAAqB,GACrB,aACS,WAEjB,YAAYC,EAAiD,CAEnD,KAAA,CACF,IAAAC,EACA,MAAAC,EAAQ,EACR,mBAAAC,EAAqB,EACrB,iBAAAC,EAAmB,EACnB,eAAAC,EAAiB,EACjB,eAAAC,EAAiB,EACjB,cAAAC,EAAgB,EAChB,OAAAC,EACA,WAAAC,EAAa,EACb,QAAAC,EAAU,EACV,WAAAC,EAAa,EACb,cAAAC,EAAgB,EAChB,UAAAC,EAAY,GACZ,gBAAAC,EAAkB,UAClB,gBAAAC,EAAkB,CAClB,EAAAf,EAEEgB,EAAQf,EAAI,MACdgB,EAAShB,EAAI,OAEjB,KAAK,QAAU,KAAK,QAAQ,KAAK,IAAI,EACrC,KAAK,WAAa,KAAK,WAAW,KAAK,IAAI,EAC3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A;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA8C5Ba,EAAiBC,GAA4B,CAC/CA,EAAK,GAAK,YACVA,EAAK,KAAO,0BACZA,EAAK,OAAS,SACdA,EAAK,MAAM,SAAW,WACtBA,EAAK,MAAM,QAAU,QACrBA,EAAK,MAAM,QAAU,IACrBA,EAAK,MAAM,OAAS,IACpBA,EAAK,MAAM,MAAQ,IACnBA,EAAK,MAAM,QAAU,OACrBA,EAAK,MAAM,MAAQ,UACnBA,EAAK,MAAM,WAAa,aACxBA,EAAK,MAAM,SAAW,OACtBA,EAAK,MAAM,WAAa,OACxBA,EAAK,MAAM,eAAiB,OAC5BA,EAAK,MAAM,OAAS,MACpBA,EAAK,UAAY,MACrB,EAEM3B,EAAevB,GAA2B,CAC5C,MAAMmD,EAAgBnD,EAAI,eAAe,qBAAqB,GAAG,EACjE,GAAImD,GACA,QAAS,EAAI,EAAG,EAAIA,EAAc,OAAQ,IAClC,GAAAA,EAAc,GAAG,KAAO,YAAa,CACrCF,EAAcE,EAAc,EAAE,EAC9B,MACJ,EAGF,MAAAD,EAAO,SAAS,cAAc,GAAG,EACvCD,EAAcC,CAAI,EACdlD,EAAA,eAAe,YAAYkD,CAAI,CACvC"}
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/NeatGradient.ts"],"sourcesContent":["import * as THREE from \"three\";\n\nconst PLANE_WIDTH = 50;\nconst PLANE_HEIGHT = 80;\n\nconst WIREFRAME = true;\nconst COLORS_COUNT = 5;\n\nconst clock = new THREE.Clock();\n\ntype SceneState = {\n renderer: THREE.WebGLRenderer,\n camera: THREE.OrthographicCamera,\n scene: THREE.Scene,\n meshes: THREE.Mesh[],\n}\n\nexport type NeatConfig = {\n speed?: number;\n horizontalPressure?: number;\n verticalPressure?: number;\n waveFrequencyX?: number;\n waveFrequencyY?: number;\n waveAmplitude?: number;\n highlights?: number;\n shadows?: number;\n colorSaturation?: number;\n colorBrightness?: number;\n colors: NeatColor[];\n colorBlending?: number;\n wireframe?: boolean;\n backgroundColor?: string;\n backgroundAlpha?: number;\n};\n\nexport type NeatColor = {\n color: string;\n enabled: boolean;\n /**\n * Value from 0 to 1\n */\n influence?: number;\n}\n\nexport type NeatController = {\n destroy: () => void;\n}\n\nexport class NeatGradient implements NeatController {\n\n private _speed: number = -1;\n\n private _horizontalPressure: number = -1;\n private _verticalPressure: number = -1;\n\n private _waveFrequencyX: number = -1;\n private _waveFrequencyY: number = -1;\n private _waveAmplitude: number = -1;\n\n private _shadows: number = -1;\n private _highlights: number = -1;\n private _saturation: number = -1;\n private _brightness: number = -1;\n\n private _colorBlending: number = -1;\n\n private _colors: NeatColor[] = [];\n private _wireframe: boolean = false;\n\n private _backgroundColor: string = \"#FFFFFF\";\n private _backgroundAlpha: number = 1.0;\n\n private requestRef: number = -1;\n private sizeObserver: ResizeObserver;\n private readonly sceneState: SceneState;\n\n constructor(config: NeatConfig & { ref: HTMLCanvasElement, resolution?: number }) {\n\n const {\n ref,\n speed = 4,\n horizontalPressure = 3,\n verticalPressure = 3,\n waveFrequencyX = 5,\n waveFrequencyY = 5,\n waveAmplitude = 3,\n colors,\n highlights = 4,\n shadows = 4,\n colorSaturation = 0,\n colorBrightness = 1,\n colorBlending = 5,\n wireframe = false,\n backgroundColor = \"#FFFFFF\",\n backgroundAlpha = 1.0,\n resolution = 1\n } = config;\n\n const width = ref.width,\n height = ref.height;\n\n this.destroy = this.destroy.bind(this);\n this._initScene = this._initScene.bind(this);\n this._buildMaterial = this._buildMaterial.bind(this);\n\n this.speed = speed;\n this.horizontalPressure = horizontalPressure;\n this.verticalPressure = verticalPressure;\n this.waveFrequencyX = waveFrequencyX;\n this.waveFrequencyY = waveFrequencyY;\n this.waveAmplitude = waveAmplitude;\n this.colorBlending = colorBlending;\n this.colors = colors;\n this.shadows = shadows;\n this.highlights = highlights;\n this.colorSaturation = colorSaturation;\n this.colorBrightness = colorBrightness;\n this.wireframe = wireframe;\n this.backgroundColor = backgroundColor;\n this.backgroundAlpha = backgroundAlpha;\n\n this.sceneState = this._initScene(ref, width, height, resolution);\n\n const { renderer, camera, scene, meshes } = this.sceneState;\n\n let tick = 0;\n const render = () => {\n\n if (Math.floor(tick * 10) % 5 === 0) {\n addNeatLink(ref);\n }\n\n renderer.setClearColor(this._backgroundColor, this._backgroundAlpha);\n meshes.forEach((mesh) => {\n\n const colors = [\n ...this._colors.map(color => ({\n is_active: color.enabled,\n color: new THREE.Color(color.color),\n influence: color.influence\n })),\n ...Array.from({ length: COLORS_COUNT - this._colors.length }).map(() => ({\n is_active: false,\n color: new THREE.Color(0x000000)\n }))\n ];\n\n tick += clock.getDelta() * this._speed;\n // @ts-ignore\n mesh.material.uniforms.u_time.value = tick;\n // @ts-ignore\n mesh.material.uniforms.u_resolution = { value: new THREE.Vector2(width, height) };\n // @ts-ignore\n mesh.material.uniforms.u_color_pressure = { value: new THREE.Vector2(this._horizontalPressure, this._verticalPressure) };\n // @ts-ignore\n mesh.material.uniforms.u_wave_frequency_x = { value: this._waveFrequencyX };\n // @ts-ignore\n mesh.material.uniforms.u_wave_frequency_y = { value: this._waveFrequencyY };\n // @ts-ignore\n mesh.material.uniforms.u_wave_amplitude = { value: this._waveAmplitude };\n // @ts-ignore\n mesh.material.uniforms.u_plane_width = { value: PLANE_WIDTH };\n // @ts-ignore\n mesh.material.uniforms.u_plane_height = { value: PLANE_HEIGHT };\n // @ts-ignore\n mesh.material.uniforms.u_color_blending = { value: this._colorBlending };\n // @ts-ignore\n mesh.material.uniforms.u_colors = { value: colors };\n // @ts-ignore\n mesh.material.uniforms.u_colors_count = { value: COLORS_COUNT };\n // @ts-ignore\n mesh.material.uniforms.u_shadows = { value: this._shadows };\n // @ts-ignore\n mesh.material.uniforms.u_highlights = { value: this._highlights };\n // @ts-ignore\n mesh.material.uniforms.u_saturation = { value: this._saturation };\n // @ts-ignore\n mesh.material.uniforms.u_brightness = { value: this._brightness };\n // @ts-ignore\n mesh.material.wireframe = this._wireframe;\n });\n\n renderer.render(scene, camera);\n this.requestRef = requestAnimationFrame(render);\n };\n\n const setSize = () => {\n const canvas = renderer.domElement;\n const width = canvas.clientWidth;\n const height = canvas.clientHeight;\n\n this.sceneState.renderer.setSize(width, height, false);\n updateCamera(this.sceneState.camera, width, height);\n };\n\n this.sizeObserver = new ResizeObserver(entries => {\n setSize();\n });\n\n this.sizeObserver.observe(ref);\n\n\n render();\n }\n\n destroy() {\n if (this) {\n cancelAnimationFrame(this.requestRef);\n this.sizeObserver.disconnect();\n }\n }\n\n set speed(speed: number) {\n this._speed = speed / 20;\n }\n\n set horizontalPressure(horizontalPressure: number) {\n this._horizontalPressure = horizontalPressure / 4;\n }\n\n set verticalPressure(verticalPressure: number) {\n this._verticalPressure = verticalPressure / 4;\n }\n\n set waveFrequencyX(waveFrequencyX: number) {\n this._waveFrequencyX = waveFrequencyX * 0.04;\n }\n\n set waveFrequencyY(waveFrequencyY: number) {\n this._waveFrequencyY = waveFrequencyY * 0.04;\n }\n\n set waveAmplitude(waveAmplitude: number) {\n this._waveAmplitude = waveAmplitude * .75;\n }\n\n set colors(colors: NeatColor[]) {\n this._colors = colors;\n }\n\n set highlights(highlights: number) {\n this._highlights = highlights / 100;\n }\n\n set shadows(shadows: number) {\n this._shadows = shadows / 100;\n }\n\n set colorSaturation(colorSaturation: number) {\n this._saturation = colorSaturation / 10;\n }\n\n set colorBrightness(colorBrightness: number) {\n console.log(\"colorBrightness\", colorBrightness)\n this._brightness = colorBrightness;\n }\n\n set colorBlending(colorBlending: number) {\n this._colorBlending = colorBlending / 10;\n }\n\n set wireframe(wireframe: boolean) {\n this._wireframe = wireframe;\n }\n\n set backgroundColor(backgroundColor: string) {\n this._backgroundColor = backgroundColor;\n }\n\n set backgroundAlpha(backgroundAlpha: number) {\n this._backgroundAlpha = backgroundAlpha;\n }\n\n _initScene(ref: HTMLCanvasElement, width: number, height: number, resolution: number): SceneState {\n\n const renderer = new THREE.WebGLRenderer({\n // antialias: true,\n alpha: true,\n canvas: ref\n });\n\n renderer.setClearColor(0xFF0000, .5);\n renderer.setSize(width, height, false);\n\n const meshes: THREE.Mesh[] = [];\n\n const scene = new THREE.Scene();\n\n const material = this._buildMaterial(width, height);\n\n const geo = new THREE.PlaneGeometry(PLANE_WIDTH, PLANE_HEIGHT, 240 * resolution, 240 * resolution);\n const plane = new THREE.Mesh(geo, material);\n plane.rotation.x = -Math.PI / 3.5;\n plane.position.z = -1;\n meshes.push(plane);\n scene.add(plane);\n\n const camera = new THREE.OrthographicCamera(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);\n // camera.zoom = 1;\n updateCamera(camera, width, height);\n\n return {\n renderer,\n camera,\n scene,\n meshes\n };\n }\n\n _buildMaterial(width: number, height: number) {\n\n const colors = [\n ...this._colors.map(color => ({\n is_active: color.enabled,\n color: new THREE.Color(color.color),\n influence: color.influence\n })),\n ...Array.from({ length: COLORS_COUNT - this._colors.length }).map(() => ({\n is_active: false,\n color: new THREE.Color(0x000000)\n }))\n ];\n\n const uniforms = {\n u_time: { value: 0 },\n u_color_pressure: { value: new THREE.Vector2(this._horizontalPressure, this._verticalPressure) },\n u_wave_frequency_x: { value: this._waveFrequencyX },\n u_wave_frequency_y: { value: this._waveFrequencyY },\n u_wave_amplitude: { value: this._waveAmplitude },\n u_resolution: { value: new THREE.Vector2(width, height) },\n u_colors: { value: colors },\n u_colors_count: { value: this._colors.length },\n u_plane_width: { value: PLANE_WIDTH },\n u_plane_height: { value: PLANE_HEIGHT },\n u_shadows: { value: this._shadows },\n u_highlights: { value: this._highlights },\n };\n\n const material = new THREE.ShaderMaterial({\n uniforms: uniforms,\n vertexShader: buildUniforms() + buildNoise() + buildColorFunctions() + buildVertexShader(),\n fragmentShader: buildUniforms() + buildColorFunctions() + buildFragmentShader()\n });\n\n material.wireframe = WIREFRAME;\n return material;\n }\n\n\n}\n\nfunction updateCamera(camera: THREE.OrthographicCamera, width: number, height: number) {\n\n const viewPortAreaRatio = 1000000;\n const areaViewPort = width * height;\n const targetPlaneArea =\n areaViewPort / viewPortAreaRatio *\n PLANE_WIDTH * PLANE_HEIGHT / 1.5;\n\n const ratio = width / height;\n\n const targetWidth = Math.sqrt(targetPlaneArea * ratio);\n const targetHeight = targetPlaneArea / targetWidth;\n\n const left = -PLANE_WIDTH / 2;\n const right = Math.min((left + targetWidth) / 1.5, PLANE_WIDTH / 2);\n\n const top = PLANE_HEIGHT / 4;\n const bottom = Math.max((top - targetHeight) / 2, -PLANE_HEIGHT / 4);\n\n const near = -100;\n const far = 1000;\n camera.left = left;\n camera.right = right;\n camera.top = top;\n camera.bottom = bottom;\n camera.near = near;\n camera.far = far;\n camera.updateProjectionMatrix();\n}\n\n\nfunction buildVertexShader() {\n return `\n\nvoid main() {\n\n vUv = uv;\n\n v_displacement_amount = cnoise( vec3(\n u_wave_frequency_x * position.x + u_time,\n u_wave_frequency_y * position.y + u_time,\n u_time\n ));\n \n vec3 color;\n\n // float t = mod(u_base_color, 100.0);\n color = u_colors[0].color;\n \n vec2 noise_cord = vUv * u_color_pressure;\n \n const float minNoise = .0;\n const float maxNoise = .9;\n \n for (int i = 1; i < u_colors_count; i++) {\n \n if(u_colors[i].is_active == 1.0){\n float noiseFlow = (1. + float(i)) / 30.;\n float noiseSpeed = (1. + float(i)) * 0.11;\n float noiseSeed = 13. + float(i) * 7.;\n \n float noise = snoise(\n vec3(\n noise_cord.x * u_color_pressure.x + u_time * noiseFlow * 2.,\n noise_cord.y * u_color_pressure.y,\n u_time * noiseSpeed\n ) + noiseSeed\n );\n \n noise = clamp(minNoise, maxNoise + float(i) * 0.02, noise);\n vec3 nextColor = u_colors[i].color;\n color = mix(color, nextColor, smoothstep(0.0, u_color_blending, noise));\n }\n \n }\n \n v_color = color;\n \n vec3 newPosition = position + normal * v_displacement_amount * u_wave_amplitude;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0 );\n \n v_new_position = gl_Position;\n}\n`;\n}\n\nfunction buildFragmentShader() {\n return `\n\nvoid main(){\n vec3 color = v_color;\n \n color.rgb += pow(v_displacement_amount, 1.0) * u_highlights;\n color.rgb -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;\n color = saturation(color, 1.0 + u_saturation);\n color = color * u_brightness;\n \n gl_FragColor = vec4(color,1.0);\n}\n`;\n}\n\nconst buildUniforms = () => `\nprecision highp float;\n\nstruct Color {\n float is_active;\n vec3 color;\n float value;\n};\n\nuniform float u_time;\n\nuniform float u_wave_amplitude;\nuniform float u_wave_frequency_x;\nuniform float u_wave_frequency_y;\n\nuniform vec2 u_color_pressure;\n\nuniform float u_plane_width;\nuniform float u_plane_height;\n\nuniform float u_shadows;\nuniform float u_highlights;\nuniform float u_saturation;\nuniform float u_brightness;\n\nuniform float u_color_blending;\n\nuniform int u_colors_count;\nuniform Color u_colors[5];\nuniform vec2 u_resolution;\n\nvarying vec2 vUv;\nvarying vec4 v_new_position;\nvarying vec3 v_color;\nvarying float v_displacement_amount;\n\n `;\n\nconst buildNoise = () => `\n\nvec3 mod289(vec3 x)\n{\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 mod289(vec4 x)\n{\n return x - floor(x * (1.0 / 289.0)) * 289.0;\n}\n\nvec4 permute(vec4 x)\n{\n return mod289(((x*34.0)+1.0)*x);\n}\n\nvec4 taylorInvSqrt(vec4 r)\n{\n return 1.79284291400159 - 0.85373472095314 * r;\n}\n\nvec3 fade(vec3 t) {\n return t*t*t*(t*(t*6.0-15.0)+10.0);\n}\n\nfloat snoise(vec3 v)\n{\n const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\n// First corner\n vec3 i = floor(v + dot(v, C.yyy) );\n vec3 x0 = v - i + dot(i, C.xxx) ;\n\n// Other corners\n vec3 g = step(x0.yzx, x0.xyz);\n vec3 l = 1.0 - g;\n vec3 i1 = min( g.xyz, l.zxy );\n vec3 i2 = max( g.xyz, l.zxy );\n\n // x0 = x0 - 0.0 + 0.0 * C.xxx;\n // x1 = x0 - i1 + 1.0 * C.xxx;\n // x2 = x0 - i2 + 2.0 * C.xxx;\n // x3 = x0 - 1.0 + 3.0 * C.xxx;\n vec3 x1 = x0 - i1 + C.xxx;\n vec3 x2 = x0 - i2 + C.yyy; // 2.0*C.x = 1/3 = C.y\n vec3 x3 = x0 - D.yyy; // -1.0+3.0*C.x = -0.5 = -D.y\n\n// Permutations\n i = mod289(i);\n vec4 p = permute( permute( permute(\n i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n + i.y + vec4(0.0, i1.y, i2.y, 1.0 ))\n + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\n// Gradients: 7x7 points over a square, mapped onto an octahedron.\n// The ring size 17*17 = 289 is close to a multiple of 49 (49*6 = 294)\n float n_ = 0.142857142857; // 1.0/7.0\n vec3 ns = n_ * D.wyz - D.xzx;\n\n vec4 j = p - 49.0 * floor(p * ns.z * ns.z); // mod(p,7*7)\n\n vec4 x_ = floor(j * ns.z);\n vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\n vec4 x = x_ *ns.x + ns.yyyy;\n vec4 y = y_ *ns.x + ns.yyyy;\n vec4 h = 1.0 - abs(x) - abs(y);\n\n vec4 b0 = vec4( x.xy, y.xy );\n vec4 b1 = vec4( x.zw, y.zw );\n\n //vec4 s0 = vec4(lessThan(b0,0.0))*2.0 - 1.0;\n //vec4 s1 = vec4(lessThan(b1,0.0))*2.0 - 1.0;\n vec4 s0 = floor(b0)*2.0 + 1.0;\n vec4 s1 = floor(b1)*2.0 + 1.0;\n vec4 sh = -step(h, vec4(0.0));\n\n vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n\n vec3 p0 = vec3(a0.xy,h.x);\n vec3 p1 = vec3(a0.zw,h.y);\n vec3 p2 = vec3(a1.xy,h.z);\n vec3 p3 = vec3(a1.zw,h.w);\n\n//Normalise gradients\n vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n p0 *= norm.x;\n p1 *= norm.y;\n p2 *= norm.z;\n p3 *= norm.w;\n\n// Mix final noise value\n vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n m = m * m;\n return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),\n dot(p2,x2), dot(p3,x3) ) );\n}\n\n// Classic Perlin noise\nfloat cnoise(vec3 P)\n{\n vec3 Pi0 = floor(P); // Integer part for indexing\n vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1\n Pi0 = mod289(Pi0);\n Pi1 = mod289(Pi1);\n vec3 Pf0 = fract(P); // Fractional part for interpolation\n vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0\n vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n vec4 iy = vec4(Pi0.yy, Pi1.yy);\n vec4 iz0 = Pi0.zzzz;\n vec4 iz1 = Pi1.zzzz;\n\n vec4 ixy = permute(permute(ix) + iy);\n vec4 ixy0 = permute(ixy + iz0);\n vec4 ixy1 = permute(ixy + iz1);\n\n vec4 gx0 = ixy0 * (1.0 / 7.0);\n vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;\n gx0 = fract(gx0);\n vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n vec4 sz0 = step(gz0, vec4(0.0));\n gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\n vec4 gx1 = ixy1 * (1.0 / 7.0);\n vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;\n gx1 = fract(gx1);\n vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n vec4 sz1 = step(gz1, vec4(0.0));\n gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\n vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\n vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n g000 *= norm0.x;\n g010 *= norm0.y;\n g100 *= norm0.z;\n g110 *= norm0.w;\n vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n g001 *= norm1.x;\n g011 *= norm1.y;\n g101 *= norm1.z;\n g111 *= norm1.w;\n\n float n000 = dot(g000, Pf0);\n float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n float n111 = dot(g111, Pf1);\n\n vec3 fade_xyz = fade(Pf0);\n vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);\n return 2.2 * n_xyz;\n}\n\n// YUV to RGB matrix\nmat3 yuv2rgb = mat3(1.0, 0.0, 1.13983,\n 1.0, -0.39465, -0.58060,\n 1.0, 2.03211, 0.0);\n\n// RGB to YUV matrix\nmat3 rgb2yuv = mat3(0.2126, 0.7152, 0.0722,\n -0.09991, -0.33609, 0.43600,\n 0.615, -0.5586, -0.05639);\n\n `;\n\nconst buildColorFunctions = () => `\n\nvec3 saturation(vec3 rgb, float adjustment) {\n const vec3 W = vec3(0.2125, 0.7154, 0.0721);\n vec3 intensity = vec3(dot(rgb, W));\n return mix(intensity, rgb, adjustment);\n}\n\nfloat saturation(vec3 rgb)\n{\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(rgb.bg, K.wz), vec4(rgb.gb, K.xy), step(rgb.b, rgb.g));\n vec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));\n\n float d = q.x - min(q.w, q.y);\n float e = 1.0e-10;\n return abs(6.0 * d + e);\n}\n\n// get saturation of a color in values between 0 and 1\nfloat getSaturation(vec3 color) {\n float max = max(color.r, max(color.g, color.b));\n float min = min(color.r, min(color.g, color.b));\n return (max - min) / max;\n}\n \nvec3 rgb2hsv(vec3 c)\n{\n vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\n vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n\n float d = q.x - min(q.w, q.y);\n float e = 1.0e-10;\n return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n}\n\nvec3 hsv2rgb(vec3 c)\n{\n vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\n`;\n\n\nconst setLinkStyles = (link: HTMLAnchorElement) => {\n link.id = \"neat-link\";\n link.href = \"https://neat.firecms.co\";\n link.target = \"_blank\";\n link.style.position = \"absolute\";\n link.style.display = \"block\";\n link.style.opacity = \"1\";\n link.style.bottom = \"0\";\n link.style.right = \"0\";\n link.style.padding = \"10px\";\n link.style.color = \"#dcdcdc\";\n link.style.fontFamily = \"sans-serif\";\n link.style.fontSize = \"16px\";\n link.style.fontWeight = \"bold\";\n link.style.textDecoration = \"none\";\n link.style.zIndex = \"100\";\n link.innerHTML = \"NEAT\";\n}\n\nconst addNeatLink = (ref: HTMLCanvasElement) => {\n const existingLinks = ref.parentElement?.getElementsByTagName(\"a\");\n if (existingLinks) {\n for (let i = 0; i < existingLinks.length; i++) {\n if (existingLinks[i].id === \"neat-link\") {\n setLinkStyles(existingLinks[i]);\n return;\n }\n }\n }\n const link = document.createElement(\"a\");\n setLinkStyles(link);\n ref.parentElement?.appendChild(link);\n}\n"],"names":["PLANE_WIDTH","PLANE_HEIGHT","WIREFRAME","COLORS_COUNT","clock","THREE","NeatGradient","config","ref","speed","horizontalPressure","verticalPressure","waveFrequencyX","waveFrequencyY","waveAmplitude","colors","highlights","shadows","colorSaturation","colorBrightness","colorBlending","wireframe","backgroundColor","backgroundAlpha","resolution","width","height","renderer","camera","scene","meshes","tick","render","addNeatLink","mesh","color","setSize","canvas","updateCamera","entries","material","geo","plane","uniforms","buildUniforms","buildNoise","buildColorFunctions","buildVertexShader","buildFragmentShader","targetPlaneArea","ratio","targetWidth","targetHeight","left","right","top","bottom","near","far","setLinkStyles","link","existingLinks"],"mappings":"wjBAEMA,EAAc,GACdC,EAAe,GAEfC,EAAY,GACZC,EAAe,EAEfC,EAAQ,IAAIC,EAAM,MAwCjB,MAAMC,CAAuC,CAExC,OAAiB,GAEjB,oBAA8B,GAC9B,kBAA4B,GAE5B,gBAA0B,GAC1B,gBAA0B,GAC1B,eAAyB,GAEzB,SAAmB,GACnB,YAAsB,GACtB,YAAsB,GACtB,YAAsB,GAEtB,eAAyB,GAEzB,QAAuB,CAAA,EACvB,WAAsB,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AW,OACtBA,EAAK,MAAM,WAAa,OACxBA,EAAK,MAAM,eAAiB,OAC5BA,EAAK,MAAM,OAAS,MACpBA,EAAK,UAAY,MACrB,EAEM3B,EAAezB,GAA2B,CAC5C,MAAMqD,EAAgBrD,EAAI,eAAe,qBAAqB,GAAG,EACjE,GAAIqD,GACA,QAAS,EAAI,EAAG,EAAIA,EAAc,OAAQ,IAClC,GAAAA,EAAc,GAAG,KAAO,YAAa,CACrCF,EAAcE,EAAc,EAAE,EAC9B,MACJ,EAGF,MAAAD,EAAO,SAAS,cAAc,GAAG,EACvCD,EAAcC,CAAI,EACdpD,EAAA,eAAe,YAAYoD,CAAI,CACvC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@firecms/neat",
|
|
3
3
|
"description": "Beautiful 3D gradients for your website",
|
|
4
4
|
"access": "public",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.4",
|
|
6
6
|
"main": "./dist/index.umd.js",
|
|
7
7
|
"module": "./dist/index.es.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"three": "^0.144.0"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
|
-
"start": "
|
|
24
|
-
"build": "
|
|
23
|
+
"start": "vite",
|
|
24
|
+
"build": "vite build && tsc"
|
|
25
25
|
},
|
|
26
26
|
"browserslist": {
|
|
27
27
|
"production": [
|
package/src/NeatGradient.ts
CHANGED
|
@@ -24,7 +24,8 @@ export type NeatConfig = {
|
|
|
24
24
|
waveAmplitude?: number;
|
|
25
25
|
highlights?: number;
|
|
26
26
|
shadows?: number;
|
|
27
|
-
|
|
27
|
+
colorSaturation?: number;
|
|
28
|
+
colorBrightness?: number;
|
|
28
29
|
colors: NeatColor[];
|
|
29
30
|
colorBlending?: number;
|
|
30
31
|
wireframe?: boolean;
|
|
@@ -59,6 +60,7 @@ export class NeatGradient implements NeatController {
|
|
|
59
60
|
private _shadows: number = -1;
|
|
60
61
|
private _highlights: number = -1;
|
|
61
62
|
private _saturation: number = -1;
|
|
63
|
+
private _brightness: number = -1;
|
|
62
64
|
|
|
63
65
|
private _colorBlending: number = -1;
|
|
64
66
|
|
|
@@ -72,7 +74,7 @@ export class NeatGradient implements NeatController {
|
|
|
72
74
|
private sizeObserver: ResizeObserver;
|
|
73
75
|
private readonly sceneState: SceneState;
|
|
74
76
|
|
|
75
|
-
constructor(config: NeatConfig & { ref: HTMLCanvasElement }) {
|
|
77
|
+
constructor(config: NeatConfig & { ref: HTMLCanvasElement, resolution?: number }) {
|
|
76
78
|
|
|
77
79
|
const {
|
|
78
80
|
ref,
|
|
@@ -85,11 +87,13 @@ export class NeatGradient implements NeatController {
|
|
|
85
87
|
colors,
|
|
86
88
|
highlights = 4,
|
|
87
89
|
shadows = 4,
|
|
88
|
-
|
|
90
|
+
colorSaturation = 0,
|
|
91
|
+
colorBrightness = 1,
|
|
89
92
|
colorBlending = 5,
|
|
90
93
|
wireframe = false,
|
|
91
94
|
backgroundColor = "#FFFFFF",
|
|
92
95
|
backgroundAlpha = 1.0,
|
|
96
|
+
resolution = 1
|
|
93
97
|
} = config;
|
|
94
98
|
|
|
95
99
|
const width = ref.width,
|
|
@@ -109,12 +113,13 @@ export class NeatGradient implements NeatController {
|
|
|
109
113
|
this.colors = colors;
|
|
110
114
|
this.shadows = shadows;
|
|
111
115
|
this.highlights = highlights;
|
|
112
|
-
this.
|
|
116
|
+
this.colorSaturation = colorSaturation;
|
|
117
|
+
this.colorBrightness = colorBrightness;
|
|
113
118
|
this.wireframe = wireframe;
|
|
114
119
|
this.backgroundColor = backgroundColor;
|
|
115
120
|
this.backgroundAlpha = backgroundAlpha;
|
|
116
121
|
|
|
117
|
-
this.sceneState = this._initScene(ref, width, height);
|
|
122
|
+
this.sceneState = this._initScene(ref, width, height, resolution);
|
|
118
123
|
|
|
119
124
|
const { renderer, camera, scene, meshes } = this.sceneState;
|
|
120
125
|
|
|
@@ -170,6 +175,8 @@ export class NeatGradient implements NeatController {
|
|
|
170
175
|
// @ts-ignore
|
|
171
176
|
mesh.material.uniforms.u_saturation = { value: this._saturation };
|
|
172
177
|
// @ts-ignore
|
|
178
|
+
mesh.material.uniforms.u_brightness = { value: this._brightness };
|
|
179
|
+
// @ts-ignore
|
|
173
180
|
mesh.material.wireframe = this._wireframe;
|
|
174
181
|
});
|
|
175
182
|
|
|
@@ -239,8 +246,13 @@ export class NeatGradient implements NeatController {
|
|
|
239
246
|
this._shadows = shadows / 100;
|
|
240
247
|
}
|
|
241
248
|
|
|
242
|
-
set
|
|
243
|
-
this._saturation =
|
|
249
|
+
set colorSaturation(colorSaturation: number) {
|
|
250
|
+
this._saturation = colorSaturation / 10;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
set colorBrightness(colorBrightness: number) {
|
|
254
|
+
console.log("colorBrightness", colorBrightness)
|
|
255
|
+
this._brightness = colorBrightness;
|
|
244
256
|
}
|
|
245
257
|
|
|
246
258
|
set colorBlending(colorBlending: number) {
|
|
@@ -259,7 +271,7 @@ export class NeatGradient implements NeatController {
|
|
|
259
271
|
this._backgroundAlpha = backgroundAlpha;
|
|
260
272
|
}
|
|
261
273
|
|
|
262
|
-
_initScene(ref: HTMLCanvasElement, width: number, height: number): SceneState {
|
|
274
|
+
_initScene(ref: HTMLCanvasElement, width: number, height: number, resolution: number): SceneState {
|
|
263
275
|
|
|
264
276
|
const renderer = new THREE.WebGLRenderer({
|
|
265
277
|
// antialias: true,
|
|
@@ -276,7 +288,7 @@ export class NeatGradient implements NeatController {
|
|
|
276
288
|
|
|
277
289
|
const material = this._buildMaterial(width, height);
|
|
278
290
|
|
|
279
|
-
const geo = new THREE.PlaneGeometry(PLANE_WIDTH, PLANE_HEIGHT, 240, 240);
|
|
291
|
+
const geo = new THREE.PlaneGeometry(PLANE_WIDTH, PLANE_HEIGHT, 240 * resolution, 240 * resolution);
|
|
280
292
|
const plane = new THREE.Mesh(geo, material);
|
|
281
293
|
plane.rotation.x = -Math.PI / 3.5;
|
|
282
294
|
plane.position.z = -1;
|
|
@@ -432,6 +444,7 @@ void main(){
|
|
|
432
444
|
color.rgb += pow(v_displacement_amount, 1.0) * u_highlights;
|
|
433
445
|
color.rgb -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;
|
|
434
446
|
color = saturation(color, 1.0 + u_saturation);
|
|
447
|
+
color = color * u_brightness;
|
|
435
448
|
|
|
436
449
|
gl_FragColor = vec4(color,1.0);
|
|
437
450
|
}
|
|
@@ -461,6 +474,7 @@ uniform float u_plane_height;
|
|
|
461
474
|
uniform float u_shadows;
|
|
462
475
|
uniform float u_highlights;
|
|
463
476
|
uniform float u_saturation;
|
|
477
|
+
uniform float u_brightness;
|
|
464
478
|
|
|
465
479
|
uniform float u_color_blending;
|
|
466
480
|
|