@firecms/neat 0.1.3 → 0.1.5
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 +13 -5
- package/dist/NeatGradient.js +44 -18
- package/dist/NeatGradient.js.map +1 -1
- package/dist/index.es.js +81 -68
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +8 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
- package/src/NeatGradient.ts +61 -23
package/dist/NeatGradient.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as THREE from "three";
|
|
2
2
|
declare type SceneState = {
|
|
3
3
|
renderer: THREE.WebGLRenderer;
|
|
4
|
-
camera: THREE.
|
|
4
|
+
camera: THREE.Camera;
|
|
5
5
|
scene: THREE.Scene;
|
|
6
6
|
meshes: THREE.Mesh[];
|
|
7
|
+
resolution: number;
|
|
7
8
|
};
|
|
8
9
|
export declare type NeatConfig = {
|
|
10
|
+
resolution?: number;
|
|
9
11
|
speed?: number;
|
|
10
12
|
horizontalPressure?: number;
|
|
11
13
|
verticalPressure?: number;
|
|
@@ -14,7 +16,8 @@ export declare type NeatConfig = {
|
|
|
14
16
|
waveAmplitude?: number;
|
|
15
17
|
highlights?: number;
|
|
16
18
|
shadows?: number;
|
|
17
|
-
|
|
19
|
+
colorSaturation?: number;
|
|
20
|
+
colorBrightness?: number;
|
|
18
21
|
colors: NeatColor[];
|
|
19
22
|
colorBlending?: number;
|
|
20
23
|
wireframe?: boolean;
|
|
@@ -33,6 +36,7 @@ export declare type NeatController = {
|
|
|
33
36
|
destroy: () => void;
|
|
34
37
|
};
|
|
35
38
|
export declare class NeatGradient implements NeatController {
|
|
39
|
+
private _ref;
|
|
36
40
|
private _speed;
|
|
37
41
|
private _horizontalPressure;
|
|
38
42
|
private _verticalPressure;
|
|
@@ -42,14 +46,16 @@ export declare class NeatGradient implements NeatController {
|
|
|
42
46
|
private _shadows;
|
|
43
47
|
private _highlights;
|
|
44
48
|
private _saturation;
|
|
49
|
+
private _brightness;
|
|
45
50
|
private _colorBlending;
|
|
46
51
|
private _colors;
|
|
47
52
|
private _wireframe;
|
|
53
|
+
private _resolution;
|
|
48
54
|
private _backgroundColor;
|
|
49
55
|
private _backgroundAlpha;
|
|
50
56
|
private requestRef;
|
|
51
57
|
private sizeObserver;
|
|
52
|
-
private
|
|
58
|
+
private sceneState;
|
|
53
59
|
constructor(config: NeatConfig & {
|
|
54
60
|
ref: HTMLCanvasElement;
|
|
55
61
|
resolution?: number;
|
|
@@ -64,12 +70,14 @@ export declare class NeatGradient implements NeatController {
|
|
|
64
70
|
set colors(colors: NeatColor[]);
|
|
65
71
|
set highlights(highlights: number);
|
|
66
72
|
set shadows(shadows: number);
|
|
67
|
-
set
|
|
73
|
+
set colorSaturation(colorSaturation: number);
|
|
74
|
+
set colorBrightness(colorBrightness: number);
|
|
68
75
|
set colorBlending(colorBlending: number);
|
|
69
76
|
set wireframe(wireframe: boolean);
|
|
77
|
+
set resolution(resolution: number);
|
|
70
78
|
set backgroundColor(backgroundColor: string);
|
|
71
79
|
set backgroundAlpha(backgroundAlpha: number);
|
|
72
|
-
_initScene(
|
|
80
|
+
_initScene(resolution: number): SceneState;
|
|
73
81
|
_buildMaterial(width: number, height: number): THREE.ShaderMaterial;
|
|
74
82
|
}
|
|
75
83
|
export {};
|
package/dist/NeatGradient.js
CHANGED
|
@@ -5,6 +5,7 @@ const WIREFRAME = true;
|
|
|
5
5
|
const COLORS_COUNT = 5;
|
|
6
6
|
const clock = new THREE.Clock();
|
|
7
7
|
export class NeatGradient {
|
|
8
|
+
_ref;
|
|
8
9
|
_speed = -1;
|
|
9
10
|
_horizontalPressure = -1;
|
|
10
11
|
_verticalPressure = -1;
|
|
@@ -14,17 +15,19 @@ export class NeatGradient {
|
|
|
14
15
|
_shadows = -1;
|
|
15
16
|
_highlights = -1;
|
|
16
17
|
_saturation = -1;
|
|
18
|
+
_brightness = -1;
|
|
17
19
|
_colorBlending = -1;
|
|
18
20
|
_colors = [];
|
|
19
21
|
_wireframe = false;
|
|
22
|
+
_resolution = 1;
|
|
20
23
|
_backgroundColor = "#FFFFFF";
|
|
21
24
|
_backgroundAlpha = 1.0;
|
|
22
25
|
requestRef = -1;
|
|
23
26
|
sizeObserver;
|
|
24
27
|
sceneState;
|
|
25
28
|
constructor(config) {
|
|
26
|
-
const { ref, speed = 4, horizontalPressure = 3, verticalPressure = 3, waveFrequencyX = 5, waveFrequencyY = 5, waveAmplitude = 3, colors, highlights = 4, shadows = 4,
|
|
27
|
-
|
|
29
|
+
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;
|
|
30
|
+
this._ref = ref;
|
|
28
31
|
this.destroy = this.destroy.bind(this);
|
|
29
32
|
this._initScene = this._initScene.bind(this);
|
|
30
33
|
this._buildMaterial = this._buildMaterial.bind(this);
|
|
@@ -38,19 +41,21 @@ export class NeatGradient {
|
|
|
38
41
|
this.colors = colors;
|
|
39
42
|
this.shadows = shadows;
|
|
40
43
|
this.highlights = highlights;
|
|
41
|
-
this.
|
|
44
|
+
this.colorSaturation = colorSaturation;
|
|
45
|
+
this.colorBrightness = colorBrightness;
|
|
42
46
|
this.wireframe = wireframe;
|
|
43
47
|
this.backgroundColor = backgroundColor;
|
|
44
48
|
this.backgroundAlpha = backgroundAlpha;
|
|
45
|
-
this.sceneState = this._initScene(
|
|
46
|
-
const { renderer, camera, scene, meshes } = this.sceneState;
|
|
49
|
+
this.sceneState = this._initScene(resolution);
|
|
47
50
|
let tick = 0;
|
|
48
51
|
const render = () => {
|
|
52
|
+
const { renderer, camera, scene, meshes } = this.sceneState;
|
|
49
53
|
if (Math.floor(tick * 10) % 5 === 0) {
|
|
50
54
|
addNeatLink(ref);
|
|
51
55
|
}
|
|
52
56
|
renderer.setClearColor(this._backgroundColor, this._backgroundAlpha);
|
|
53
57
|
meshes.forEach((mesh) => {
|
|
58
|
+
const width = this._ref.width, height = this._ref.height;
|
|
54
59
|
const colors = [
|
|
55
60
|
...this._colors.map(color => ({
|
|
56
61
|
is_active: color.enabled,
|
|
@@ -92,12 +97,15 @@ export class NeatGradient {
|
|
|
92
97
|
// @ts-ignore
|
|
93
98
|
mesh.material.uniforms.u_saturation = { value: this._saturation };
|
|
94
99
|
// @ts-ignore
|
|
100
|
+
mesh.material.uniforms.u_brightness = { value: this._brightness };
|
|
101
|
+
// @ts-ignore
|
|
95
102
|
mesh.material.wireframe = this._wireframe;
|
|
96
103
|
});
|
|
97
104
|
renderer.render(scene, camera);
|
|
98
105
|
this.requestRef = requestAnimationFrame(render);
|
|
99
106
|
};
|
|
100
107
|
const setSize = () => {
|
|
108
|
+
const { renderer } = this.sceneState;
|
|
101
109
|
const canvas = renderer.domElement;
|
|
102
110
|
const width = canvas.clientWidth;
|
|
103
111
|
const height = canvas.clientHeight;
|
|
@@ -143,8 +151,11 @@ export class NeatGradient {
|
|
|
143
151
|
set shadows(shadows) {
|
|
144
152
|
this._shadows = shadows / 100;
|
|
145
153
|
}
|
|
146
|
-
set
|
|
147
|
-
this._saturation =
|
|
154
|
+
set colorSaturation(colorSaturation) {
|
|
155
|
+
this._saturation = colorSaturation / 10;
|
|
156
|
+
}
|
|
157
|
+
set colorBrightness(colorBrightness) {
|
|
158
|
+
this._brightness = colorBrightness;
|
|
148
159
|
}
|
|
149
160
|
set colorBlending(colorBlending) {
|
|
150
161
|
this._colorBlending = colorBlending / 10;
|
|
@@ -152,17 +163,22 @@ export class NeatGradient {
|
|
|
152
163
|
set wireframe(wireframe) {
|
|
153
164
|
this._wireframe = wireframe;
|
|
154
165
|
}
|
|
166
|
+
set resolution(resolution) {
|
|
167
|
+
this._resolution = resolution;
|
|
168
|
+
this.sceneState = this._initScene(resolution);
|
|
169
|
+
}
|
|
155
170
|
set backgroundColor(backgroundColor) {
|
|
156
171
|
this._backgroundColor = backgroundColor;
|
|
157
172
|
}
|
|
158
173
|
set backgroundAlpha(backgroundAlpha) {
|
|
159
174
|
this._backgroundAlpha = backgroundAlpha;
|
|
160
175
|
}
|
|
161
|
-
_initScene(
|
|
176
|
+
_initScene(resolution) {
|
|
177
|
+
const width = this._ref.width, height = this._ref.height;
|
|
162
178
|
const renderer = new THREE.WebGLRenderer({
|
|
163
179
|
// antialias: true,
|
|
164
180
|
alpha: true,
|
|
165
|
-
canvas:
|
|
181
|
+
canvas: this._ref
|
|
166
182
|
});
|
|
167
183
|
renderer.setClearColor(0xFF0000, .5);
|
|
168
184
|
renderer.setSize(width, height, false);
|
|
@@ -176,13 +192,15 @@ export class NeatGradient {
|
|
|
176
192
|
meshes.push(plane);
|
|
177
193
|
scene.add(plane);
|
|
178
194
|
const camera = new THREE.OrthographicCamera(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
|
179
|
-
// camera
|
|
195
|
+
// const camera = new THREE.PerspectiveCamera( 1000, window.innerWidth / window.innerHeight, 1, 1000000 );
|
|
196
|
+
camera.position.z = 5;
|
|
180
197
|
updateCamera(camera, width, height);
|
|
181
198
|
return {
|
|
182
199
|
renderer,
|
|
183
200
|
camera,
|
|
184
201
|
scene,
|
|
185
|
-
meshes
|
|
202
|
+
meshes,
|
|
203
|
+
resolution
|
|
186
204
|
};
|
|
187
205
|
}
|
|
188
206
|
_buildMaterial(width, height) {
|
|
@@ -234,13 +252,19 @@ function updateCamera(camera, width, height) {
|
|
|
234
252
|
const bottom = Math.max((top - targetHeight) / 2, -PLANE_HEIGHT / 4);
|
|
235
253
|
const near = -100;
|
|
236
254
|
const far = 1000;
|
|
237
|
-
camera.
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
255
|
+
if (camera instanceof THREE.OrthographicCamera) {
|
|
256
|
+
camera.left = left;
|
|
257
|
+
camera.right = right;
|
|
258
|
+
camera.top = top;
|
|
259
|
+
camera.bottom = bottom;
|
|
260
|
+
camera.near = near;
|
|
261
|
+
camera.far = far;
|
|
262
|
+
camera.updateProjectionMatrix();
|
|
263
|
+
}
|
|
264
|
+
else if (camera instanceof THREE.PerspectiveCamera) {
|
|
265
|
+
camera.aspect = width / height;
|
|
266
|
+
camera.updateProjectionMatrix();
|
|
267
|
+
}
|
|
244
268
|
}
|
|
245
269
|
function buildVertexShader() {
|
|
246
270
|
return `
|
|
@@ -305,6 +329,7 @@ void main(){
|
|
|
305
329
|
color.rgb += pow(v_displacement_amount, 1.0) * u_highlights;
|
|
306
330
|
color.rgb -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;
|
|
307
331
|
color = saturation(color, 1.0 + u_saturation);
|
|
332
|
+
color = color * u_brightness;
|
|
308
333
|
|
|
309
334
|
gl_FragColor = vec4(color,1.0);
|
|
310
335
|
}
|
|
@@ -333,6 +358,7 @@ uniform float u_plane_height;
|
|
|
333
358
|
uniform float u_shadows;
|
|
334
359
|
uniform float u_highlights;
|
|
335
360
|
uniform float u_saturation;
|
|
361
|
+
uniform float u_brightness;
|
|
336
362
|
|
|
337
363
|
uniform float u_color_blending;
|
|
338
364
|
|
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,CAAC,CAAC;IAE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
const _ = 50, g = 80, V = !0, q = 5, j = new o.Clock();
|
|
3
|
+
class W {
|
|
4
|
+
_ref;
|
|
4
5
|
_speed = -1;
|
|
5
6
|
_horizontalPressure = -1;
|
|
6
7
|
_verticalPressure = -1;
|
|
@@ -10,9 +11,11 @@ class L {
|
|
|
10
11
|
_shadows = -1;
|
|
11
12
|
_highlights = -1;
|
|
12
13
|
_saturation = -1;
|
|
14
|
+
_brightness = -1;
|
|
13
15
|
_colorBlending = -1;
|
|
14
16
|
_colors = [];
|
|
15
17
|
_wireframe = !1;
|
|
18
|
+
_resolution = 1;
|
|
16
19
|
_backgroundColor = "#FFFFFF";
|
|
17
20
|
_backgroundAlpha = 1;
|
|
18
21
|
requestRef = -1;
|
|
@@ -23,44 +26,45 @@ class L {
|
|
|
23
26
|
ref: r,
|
|
24
27
|
speed: s = 4,
|
|
25
28
|
horizontalPressure: l = 3,
|
|
26
|
-
verticalPressure:
|
|
27
|
-
waveFrequencyX:
|
|
28
|
-
waveFrequencyY:
|
|
29
|
-
waveAmplitude:
|
|
30
|
-
colors:
|
|
31
|
-
highlights:
|
|
32
|
-
shadows:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
let
|
|
29
|
+
verticalPressure: n = 3,
|
|
30
|
+
waveFrequencyX: a = 5,
|
|
31
|
+
waveFrequencyY: u = 5,
|
|
32
|
+
waveAmplitude: x = 3,
|
|
33
|
+
colors: c,
|
|
34
|
+
highlights: v = 4,
|
|
35
|
+
shadows: f = 4,
|
|
36
|
+
colorSaturation: p = 0,
|
|
37
|
+
colorBrightness: w = 1,
|
|
38
|
+
colorBlending: z = 5,
|
|
39
|
+
wireframe: E = !1,
|
|
40
|
+
backgroundColor: N = "#FFFFFF",
|
|
41
|
+
backgroundAlpha: R = 1,
|
|
42
|
+
resolution: B = 1
|
|
43
|
+
} = e;
|
|
44
|
+
this._ref = r, 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 = u, this.waveAmplitude = x, this.colorBlending = z, this.colors = c, this.shadows = f, this.highlights = v, this.colorSaturation = p, this.colorBrightness = w, this.wireframe = E, this.backgroundColor = N, this.backgroundAlpha = R, this.sceneState = this._initScene(B);
|
|
45
|
+
let b = 0;
|
|
43
46
|
const C = () => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const { renderer: h, camera: m, scene: d, meshes: y } = this.sceneState;
|
|
48
|
+
Math.floor(b * 10) % 5 === 0 && L(r), h.setClearColor(this._backgroundColor, this._backgroundAlpha), y.forEach((i) => {
|
|
49
|
+
const K = this._ref.width, O = this._ref.height, T = [
|
|
50
|
+
...this._colors.map((P) => ({
|
|
51
|
+
is_active: P.enabled,
|
|
52
|
+
color: new o.Color(P.color),
|
|
53
|
+
influence: P.influence
|
|
50
54
|
})),
|
|
51
|
-
...Array.from({ length:
|
|
55
|
+
...Array.from({ length: q - this._colors.length }).map(() => ({
|
|
52
56
|
is_active: !1,
|
|
53
|
-
color: new
|
|
57
|
+
color: new o.Color(0)
|
|
54
58
|
}))
|
|
55
59
|
];
|
|
56
|
-
|
|
57
|
-
}),
|
|
58
|
-
},
|
|
59
|
-
const
|
|
60
|
-
this.sceneState.renderer.setSize(d,
|
|
60
|
+
b += j.getDelta() * this._speed, i.material.uniforms.u_time.value = b, i.material.uniforms.u_resolution = { value: new o.Vector2(K, O) }, i.material.uniforms.u_color_pressure = { value: new o.Vector2(this._horizontalPressure, this._verticalPressure) }, i.material.uniforms.u_wave_frequency_x = { value: this._waveFrequencyX }, i.material.uniforms.u_wave_frequency_y = { value: this._waveFrequencyY }, i.material.uniforms.u_wave_amplitude = { value: this._waveAmplitude }, i.material.uniforms.u_plane_width = { value: _ }, i.material.uniforms.u_plane_height = { value: g }, i.material.uniforms.u_color_blending = { value: this._colorBlending }, i.material.uniforms.u_colors = { value: T }, i.material.uniforms.u_colors_count = { value: q }, i.material.uniforms.u_shadows = { value: this._shadows }, i.material.uniforms.u_highlights = { value: this._highlights }, i.material.uniforms.u_saturation = { value: this._saturation }, i.material.uniforms.u_brightness = { value: this._brightness }, i.material.wireframe = this._wireframe;
|
|
61
|
+
}), h.render(d, m), this.requestRef = requestAnimationFrame(C);
|
|
62
|
+
}, I = () => {
|
|
63
|
+
const { renderer: h } = this.sceneState, m = h.domElement, d = m.clientWidth, y = m.clientHeight;
|
|
64
|
+
this.sceneState.renderer.setSize(d, y, !1), F(this.sceneState.camera, d, y);
|
|
61
65
|
};
|
|
62
|
-
this.sizeObserver = new ResizeObserver((
|
|
63
|
-
|
|
66
|
+
this.sizeObserver = new ResizeObserver((h) => {
|
|
67
|
+
I();
|
|
64
68
|
}), this.sizeObserver.observe(r), C();
|
|
65
69
|
}
|
|
66
70
|
destroy() {
|
|
@@ -93,72 +97,79 @@ class L {
|
|
|
93
97
|
set shadows(e) {
|
|
94
98
|
this._shadows = e / 100;
|
|
95
99
|
}
|
|
96
|
-
set
|
|
100
|
+
set colorSaturation(e) {
|
|
97
101
|
this._saturation = e / 10;
|
|
98
102
|
}
|
|
103
|
+
set colorBrightness(e) {
|
|
104
|
+
this._brightness = e;
|
|
105
|
+
}
|
|
99
106
|
set colorBlending(e) {
|
|
100
107
|
this._colorBlending = e / 10;
|
|
101
108
|
}
|
|
102
109
|
set wireframe(e) {
|
|
103
110
|
this._wireframe = e;
|
|
104
111
|
}
|
|
112
|
+
set resolution(e) {
|
|
113
|
+
this._resolution = e, this.sceneState = this._initScene(e);
|
|
114
|
+
}
|
|
105
115
|
set backgroundColor(e) {
|
|
106
116
|
this._backgroundColor = e;
|
|
107
117
|
}
|
|
108
118
|
set backgroundAlpha(e) {
|
|
109
119
|
this._backgroundAlpha = e;
|
|
110
120
|
}
|
|
111
|
-
_initScene(e
|
|
112
|
-
const
|
|
121
|
+
_initScene(e) {
|
|
122
|
+
const r = this._ref.width, s = this._ref.height, l = new o.WebGLRenderer({
|
|
113
123
|
alpha: !0,
|
|
114
|
-
canvas:
|
|
124
|
+
canvas: this._ref
|
|
115
125
|
});
|
|
116
|
-
|
|
117
|
-
const n = [],
|
|
118
|
-
c.rotation.x = -Math.PI / 3.5, c.position.z = -1, n.push(c),
|
|
119
|
-
const
|
|
120
|
-
return F(
|
|
121
|
-
renderer:
|
|
122
|
-
camera:
|
|
123
|
-
scene:
|
|
124
|
-
meshes: n
|
|
126
|
+
l.setClearColor(16711680, 0.5), l.setSize(r, s, !1);
|
|
127
|
+
const n = [], a = new o.Scene(), u = this._buildMaterial(r, s), x = new o.PlaneGeometry(_, g, 240 * e, 240 * e), c = new o.Mesh(x, u);
|
|
128
|
+
c.rotation.x = -Math.PI / 3.5, c.position.z = -1, n.push(c), a.add(c);
|
|
129
|
+
const v = new o.OrthographicCamera(0, 0, 0, 0, 0, 0);
|
|
130
|
+
return v.position.z = 5, F(v, r, s), {
|
|
131
|
+
renderer: l,
|
|
132
|
+
camera: v,
|
|
133
|
+
scene: a,
|
|
134
|
+
meshes: n,
|
|
135
|
+
resolution: e
|
|
125
136
|
};
|
|
126
137
|
}
|
|
127
138
|
_buildMaterial(e, r) {
|
|
128
139
|
const s = [
|
|
129
|
-
...this._colors.map((
|
|
130
|
-
is_active:
|
|
131
|
-
color: new
|
|
132
|
-
influence:
|
|
140
|
+
...this._colors.map((a) => ({
|
|
141
|
+
is_active: a.enabled,
|
|
142
|
+
color: new o.Color(a.color),
|
|
143
|
+
influence: a.influence
|
|
133
144
|
})),
|
|
134
|
-
...Array.from({ length:
|
|
145
|
+
...Array.from({ length: q - this._colors.length }).map(() => ({
|
|
135
146
|
is_active: !1,
|
|
136
|
-
color: new
|
|
147
|
+
color: new o.Color(0)
|
|
137
148
|
}))
|
|
138
149
|
], l = {
|
|
139
150
|
u_time: { value: 0 },
|
|
140
|
-
u_color_pressure: { value: new
|
|
151
|
+
u_color_pressure: { value: new o.Vector2(this._horizontalPressure, this._verticalPressure) },
|
|
141
152
|
u_wave_frequency_x: { value: this._waveFrequencyX },
|
|
142
153
|
u_wave_frequency_y: { value: this._waveFrequencyY },
|
|
143
154
|
u_wave_amplitude: { value: this._waveAmplitude },
|
|
144
|
-
u_resolution: { value: new
|
|
155
|
+
u_resolution: { value: new o.Vector2(e, r) },
|
|
145
156
|
u_colors: { value: s },
|
|
146
157
|
u_colors_count: { value: this._colors.length },
|
|
147
|
-
u_plane_width: { value:
|
|
148
|
-
u_plane_height: { value:
|
|
158
|
+
u_plane_width: { value: _ },
|
|
159
|
+
u_plane_height: { value: g },
|
|
149
160
|
u_shadows: { value: this._shadows },
|
|
150
161
|
u_highlights: { value: this._highlights }
|
|
151
|
-
},
|
|
162
|
+
}, n = new o.ShaderMaterial({
|
|
152
163
|
uniforms: l,
|
|
153
|
-
vertexShader: S() +
|
|
154
|
-
fragmentShader: S() + A() +
|
|
164
|
+
vertexShader: S() + D() + A() + Y(),
|
|
165
|
+
fragmentShader: S() + A() + k()
|
|
155
166
|
});
|
|
156
|
-
return
|
|
167
|
+
return n.wireframe = V, n;
|
|
157
168
|
}
|
|
158
169
|
}
|
|
159
170
|
function F(t, e, r) {
|
|
160
|
-
const
|
|
161
|
-
t.left =
|
|
171
|
+
const n = e * r / 1e6 * _ * g / 1.5, a = e / r, u = Math.sqrt(n * a), x = n / u, c = -_ / 2, v = Math.min((c + u) / 1.5, _ / 2), f = g / 4, p = Math.max((f - x) / 2, -g / 4), w = -100, z = 1e3;
|
|
172
|
+
t instanceof o.OrthographicCamera ? (t.left = c, t.right = v, t.top = f, t.bottom = p, t.near = w, t.far = z, t.updateProjectionMatrix()) : t instanceof o.PerspectiveCamera && (t.aspect = e / r, t.updateProjectionMatrix());
|
|
162
173
|
}
|
|
163
174
|
function Y() {
|
|
164
175
|
return `
|
|
@@ -214,7 +225,7 @@ void main() {
|
|
|
214
225
|
}
|
|
215
226
|
`;
|
|
216
227
|
}
|
|
217
|
-
function
|
|
228
|
+
function k() {
|
|
218
229
|
return `
|
|
219
230
|
|
|
220
231
|
void main(){
|
|
@@ -223,6 +234,7 @@ void main(){
|
|
|
223
234
|
color.rgb += pow(v_displacement_amount, 1.0) * u_highlights;
|
|
224
235
|
color.rgb -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;
|
|
225
236
|
color = saturation(color, 1.0 + u_saturation);
|
|
237
|
+
color = color * u_brightness;
|
|
226
238
|
|
|
227
239
|
gl_FragColor = vec4(color,1.0);
|
|
228
240
|
}
|
|
@@ -251,6 +263,7 @@ uniform float u_plane_height;
|
|
|
251
263
|
uniform float u_shadows;
|
|
252
264
|
uniform float u_highlights;
|
|
253
265
|
uniform float u_saturation;
|
|
266
|
+
uniform float u_brightness;
|
|
254
267
|
|
|
255
268
|
uniform float u_color_blending;
|
|
256
269
|
|
|
@@ -263,7 +276,7 @@ varying vec4 v_new_position;
|
|
|
263
276
|
varying vec3 v_color;
|
|
264
277
|
varying float v_displacement_amount;
|
|
265
278
|
|
|
266
|
-
`,
|
|
279
|
+
`, D = () => `
|
|
267
280
|
|
|
268
281
|
vec3 mod289(vec3 x)
|
|
269
282
|
{
|
|
@@ -489,7 +502,7 @@ vec3 hsv2rgb(vec3 c)
|
|
|
489
502
|
}
|
|
490
503
|
`, M = (t) => {
|
|
491
504
|
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";
|
|
492
|
-
},
|
|
505
|
+
}, L = (t) => {
|
|
493
506
|
const e = t.parentElement?.getElementsByTagName("a");
|
|
494
507
|
if (e) {
|
|
495
508
|
for (let s = 0; s < e.length; s++)
|
|
@@ -502,6 +515,6 @@ vec3 hsv2rgb(vec3 c)
|
|
|
502
515
|
M(r), t.parentElement?.appendChild(r);
|
|
503
516
|
};
|
|
504
517
|
export {
|
|
505
|
-
|
|
518
|
+
W as NeatGradient
|
|
506
519
|
};
|
|
507
520
|
//# 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, 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 saturation = 0,\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.saturation = saturation;\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.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, 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 \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","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,EAAM;AAuCjB,MAAMC,EAAuC;AAAA,EAExC,SAAiB;AAAA,EAEjB,sBAA8B;AAAA,EAC9B,oBAA4B;AAAA,EAE5B,kBAA0B;AAAA,EAC1B,kBAA0B;AAAA,EAC1B,iBAAyB;AAAA,EAEzB,WAAmB;AAAA,EACnB,cAAsB;AAAA,EACtB,cAAsB;AAAA,EAEtB,iBAAyB;AAAA,EAEzB,UAAuB,CAAA;AAAA,EACvB,aAAsB;AAAA,EAEtB,mBAA2B;AAAA,EAC3B,mBAA2B;AAAA,EAE3B,aAAqB;AAAA,EACrB;AAAA,EACS;AAAA,EAEjB,YAAYC,GAAsE;AAExE,UAAA;AAAA,MACF,KAAAC;AAAA,MACA,OAAAC,IAAQ;AAAA,MACR,oBAAAC,IAAqB;AAAA,MACrB,kBAAAC,IAAmB;AAAA,MACnB,gBAAAC,IAAiB;AAAA,MACjB,gBAAAC,IAAiB;AAAA,MACjB,eAAAC,IAAgB;AAAA,MAChB,QAAAC;AAAA,MACA,YAAAC,IAAa;AAAA,MACb,SAAAC,IAAU;AAAA,MACV,YAAAC,IAAa;AAAA,MACb,eAAAC,IAAgB;AAAA,MAChB,WAAAC,IAAY;AAAA,MACZ,iBAAAC,IAAkB;AAAA,MAClB,iBAAAC,IAAkB;AAAA,MAClB,YAAAC,IAAa;AAAA,IACb,IAAAhB,GAEEiB,IAAQhB,EAAI,OACdiB,IAASjB,EAAI;AAEjB,SAAK,UAAU,KAAK,QAAQ,KAAK,IAAI,GACrC,KAAK,aAAa,KAAK,WAAW,KAAK,IAAI,GAC3C,KAAK,iBAAiB,KAAK,eAAe,KAAK,IAAI,GAEnD,KAAK,QAAQC,GACb,KAAK,qBAAqBC,GAC1B,KAAK,mBAAmBC,GACxB,KA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AG,OAAO,aAAa;AACrC,QAAAH,EAAcE,EAAcC,EAAE;AAC9B;AAAA,MACJ;AAAA;AAGF,QAAAF,IAAO,SAAS,cAAc,GAAG;AACvC,EAAAD,EAAcC,CAAI,GACdnD,EAAA,eAAe,YAAYmD,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.Camera,\n scene: THREE.Scene,\n meshes: THREE.Mesh[],\n resolution: number\n}\n\nexport type NeatConfig = {\n resolution?: number;\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 _ref: HTMLCanvasElement;\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 _resolution: number = 1;\n private _backgroundColor: string = \"#FFFFFF\";\n private _backgroundAlpha: number = 1.0;\n\n private requestRef: number = -1;\n private sizeObserver: ResizeObserver;\n private 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\n this._ref = ref;\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(resolution);\n\n\n let tick = 0;\n const render = () => {\n\n const { renderer, camera, scene, meshes } = this.sceneState;\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 width = this._ref.width,\n height = this._ref.height;\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\n const { renderer } = this.sceneState;\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 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 resolution(resolution: number) {\n this._resolution = resolution;\n this.sceneState = this._initScene(resolution);\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(resolution: number): SceneState {\n\n const width = this._ref.width,\n height = this._ref.height;\n\n const renderer = new THREE.WebGLRenderer({\n // antialias: true,\n alpha: true,\n canvas: this._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 // const camera = new THREE.PerspectiveCamera( 1000, window.innerWidth / window.innerHeight, 1, 1000000 );\n camera.position.z = 5;\n updateCamera(camera, width, height);\n\n return {\n renderer,\n camera,\n scene,\n meshes,\n resolution\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.Camera, 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 if (camera instanceof THREE.OrthographicCamera) {\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 } else if (camera instanceof THREE.PerspectiveCamera) {\n camera.aspect = width / height;\n camera.updateProjectionMatrix();\n }\n\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","tick","render","renderer","camera","scene","meshes","addNeatLink","mesh","width","height","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;AA0CjB,MAAMC,EAAuC;AAAA,EAExC;AAAA,EAEA,SAAiB;AAAA,EAEjB,sBAA8B;AAAA,EAC9B,oBAA4B;AAAA,EAE5B,kBAA0B;AAAA,EAC1B,kBAA0B;AAAA,EAC1B,iBAAyB;AAAA,EAEzB,WAAmB;AAAA,EACnB,cAAsB;AAAA,EACtB,cAAsB;AAAA,EACtB,cAAsB;AAAA,EAEtB,iBAAyB;AAAA,EAEzB,UAAuB,CAAA;AAAA,EACvB,aAAsB;AAAA,EAEtB,cAAsB;AAAA,EACtB,mBAA2B;AAAA,EAC3B,mBAA2B;AAAA,EAE3B,aAAqB;AAAA,EACrB;AAAA,EACA;AAAA,EAER,YAAYC,GAAsE;AAExE,UAAA;AAAA,MACF,KAAAC;AAAA,MACA,OAAAC,IAAQ;AAAA,MACR,oBAAAC,IAAqB;AAAA,MACrB,kBAAAC,IAAmB;AAAA,MACnB,gBAAAC,IAAiB;AAAA,MACjB,gBAAAC,IAAiB;AAAA,MACj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,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(u,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],h):(u=typeof globalThis<"u"?globalThis:u||self,h(u.FireCMS={},u.THREE))})(this,function(u,h){"use strict";function N(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 r=N(h),_=50,g=80,j=!0,z=5,T=new r.Clock;class R{_ref;_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;_resolution=1;_backgroundColor="#FFFFFF";_backgroundAlpha=1;requestRef=-1;sizeObserver;sceneState;constructor(e){const{ref:o,speed:i=4,horizontalPressure:l=3,verticalPressure:n=3,waveFrequencyX:a=5,waveFrequencyY:x=5,waveAmplitude:f=3,colors:c,highlights:v=4,shadows:m=4,colorSaturation:b=0,colorBrightness:P=1,colorBlending:q=5,wireframe:k=!1,backgroundColor:D="#FFFFFF",backgroundAlpha:Y=1,resolution:G=1}=e;this._ref=o,this.destroy=this.destroy.bind(this),this._initScene=this._initScene.bind(this),this._buildMaterial=this._buildMaterial.bind(this),this.speed=i,this.horizontalPressure=l,this.verticalPressure=n,this.waveFrequencyX=a,this.waveFrequencyY=x,this.waveAmplitude=f,this.colorBlending=q,this.colors=c,this.shadows=m,this.highlights=v,this.colorSaturation=b,this.colorBrightness=P,this.wireframe=k,this.backgroundColor=D,this.backgroundAlpha=Y,this.sceneState=this._initScene(G);let C=0;const E=()=>{const{renderer:d,camera:y,scene:p,meshes:w}=this.sceneState;Math.floor(C*10)%5===0&&V(o),d.setClearColor(this._backgroundColor,this._backgroundAlpha),w.forEach(s=>{const L=this._ref.width,W=this._ref.height,U=[...this._colors.map(S=>({is_active:S.enabled,color:new r.Color(S.color),influence:S.influence})),...Array.from({length:z-this._colors.length}).map(()=>({is_active:!1,color:new r.Color(0)}))];C+=T.getDelta()*this._speed,s.material.uniforms.u_time.value=C,s.material.uniforms.u_resolution={value:new r.Vector2(L,W)},s.material.uniforms.u_color_pressure={value:new r.Vector2(this._horizontalPressure,this._verticalPressure)},s.material.uniforms.u_wave_frequency_x={value:this._waveFrequencyX},s.material.uniforms.u_wave_frequency_y={value:this._waveFrequencyY},s.material.uniforms.u_wave_amplitude={value:this._waveAmplitude},s.material.uniforms.u_plane_width={value:_},s.material.uniforms.u_plane_height={value:g},s.material.uniforms.u_color_blending={value:this._colorBlending},s.material.uniforms.u_colors={value:U},s.material.uniforms.u_colors_count={value:z},s.material.uniforms.u_shadows={value:this._shadows},s.material.uniforms.u_highlights={value:this._highlights},s.material.uniforms.u_saturation={value:this._saturation},s.material.uniforms.u_brightness={value:this._brightness},s.material.wireframe=this._wireframe}),d.render(p,y),this.requestRef=requestAnimationFrame(E)},H=()=>{const{renderer:d}=this.sceneState,y=d.domElement,p=y.clientWidth,w=y.clientHeight;this.sceneState.renderer.setSize(p,w,!1),F(this.sceneState.camera,p,w)};this.sizeObserver=new ResizeObserver(d=>{H()}),this.sizeObserver.observe(o),E()}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){this._brightness=e}set colorBlending(e){this._colorBlending=e/10}set wireframe(e){this._wireframe=e}set resolution(e){this._resolution=e,this.sceneState=this._initScene(e)}set backgroundColor(e){this._backgroundColor=e}set backgroundAlpha(e){this._backgroundAlpha=e}_initScene(e){const o=this._ref.width,i=this._ref.height,l=new r.WebGLRenderer({alpha:!0,canvas:this._ref});l.setClearColor(16711680,.5),l.setSize(o,i,!1);const n=[],a=new r.Scene,x=this._buildMaterial(o,i),f=new r.PlaneGeometry(_,g,240*e,240*e),c=new r.Mesh(f,x);c.rotation.x=-Math.PI/3.5,c.position.z=-1,n.push(c),a.add(c);const v=new r.OrthographicCamera(0,0,0,0,0,0);return v.position.z=5,F(v,o,i),{renderer:l,camera:v,scene:a,meshes:n,resolution:e}}_buildMaterial(e,o){const i=[...this._colors.map(a=>({is_active:a.enabled,color:new r.Color(a.color),influence:a.influence})),...Array.from({length:z-this._colors.length}).map(()=>({is_active:!1,color:new r.Color(0)}))],l={u_time:{value:0},u_color_pressure:{value:new r.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 r.Vector2(e,o)},u_colors:{value:i},u_colors_count:{value:this._colors.length},u_plane_width:{value:_},u_plane_height:{value:g},u_shadows:{value:this._shadows},u_highlights:{value:this._highlights}},n=new r.ShaderMaterial({uniforms:l,vertexShader:A()+K()+M()+B(),fragmentShader:A()+M()+I()});return n.wireframe=j,n}}function F(t,e,o){const n=e*o/1e6*_*g/1.5,a=e/o,x=Math.sqrt(n*a),f=n/x,c=-_/2,v=Math.min((c+x)/1.5,_/2),m=g/4,b=Math.max((m-f)/2,-g/4),P=-100,q=1e3;t instanceof r.OrthographicCamera?(t.left=c,t.right=v,t.top=m,t.bottom=b,t.near=P,t.far=q,t.updateProjectionMatrix()):t instanceof r.PerspectiveCamera&&(t.aspect=e/o,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,10 +57,11 @@ 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
|
}
|
|
63
|
-
`}const
|
|
64
|
+
`}const A=()=>`
|
|
64
65
|
precision highp float;
|
|
65
66
|
|
|
66
67
|
struct Color {
|
|
@@ -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
|
{
|
|
@@ -276,7 +278,7 @@ mat3 rgb2yuv = mat3(0.2126, 0.7152, 0.0722,
|
|
|
276
278
|
-0.09991, -0.33609, 0.43600,
|
|
277
279
|
0.615, -0.5586, -0.05639);
|
|
278
280
|
|
|
279
|
-
`,
|
|
281
|
+
`,M=()=>`
|
|
280
282
|
|
|
281
283
|
vec3 saturation(vec3 rgb, float adjustment) {
|
|
282
284
|
const vec3 W = vec3(0.2125, 0.7154, 0.0721);
|
|
@@ -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
|
-
`,
|
|
324
|
+
`,O=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"){O(e[i]);return}}const o=document.createElement("a");O(o),t.parentElement?.appendChild(o)};u.NeatGradient=R,Object.defineProperties(u,{__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, 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 saturation = 0,\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.saturation = saturation;\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.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, 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 \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","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,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,EAAsE,CAExE,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,EAClB,WAAAC,EAAa,CACb,EAAAhB,EAEEiB,EAAQhB,EAAI,MACdiB,EAASjB,EAAI,OAEjB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sB,IAAM;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,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,EAAexB,GAA2B,CAC5C,MAAMoD,EAAgBpD,EAAI,eAAe,qBAAqB,GAAG,EACjE,GAAIoD,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,EACdnD,EAAA,eAAe,YAAYmD,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.Camera,\n scene: THREE.Scene,\n meshes: THREE.Mesh[],\n resolution: number\n}\n\nexport type NeatConfig = {\n resolution?: number;\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 _ref: HTMLCanvasElement;\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 _resolution: number = 1;\n private _backgroundColor: string = \"#FFFFFF\";\n private _backgroundAlpha: number = 1.0;\n\n private requestRef: number = -1;\n private sizeObserver: ResizeObserver;\n private 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\n this._ref = ref;\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(resolution);\n\n\n let tick = 0;\n const render = () => {\n\n const { renderer, camera, scene, meshes } = this.sceneState;\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 width = this._ref.width,\n height = this._ref.height;\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\n const { renderer } = this.sceneState;\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 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 resolution(resolution: number) {\n this._resolution = resolution;\n this.sceneState = this._initScene(resolution);\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(resolution: number): SceneState {\n\n const width = this._ref.width,\n height = this._ref.height;\n\n const renderer = new THREE.WebGLRenderer({\n // antialias: true,\n alpha: true,\n canvas: this._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 // const camera = new THREE.PerspectiveCamera( 1000, window.innerWidth / window.innerHeight, 1, 1000000 );\n camera.position.z = 5;\n updateCamera(camera, width, height);\n\n return {\n renderer,\n camera,\n scene,\n meshes,\n resolution\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.Camera, 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 if (camera instanceof THREE.OrthographicCamera) {\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 } else if (camera instanceof THREE.PerspectiveCamera) {\n camera.aspect = width / height;\n camera.updateProjectionMatrix();\n }\n\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","tick","render","renderer","camera","scene","meshes","addNeatLink","mesh","width","height","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,MA0CjB,MAAMC,CAAuC,CAExC,KAEA,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,GAEtB,YAAsB,EACtB,iBAA2B,UAC3B,iBAA2B,EAE3B,WAAqB,GACrB,aACA,WAER,YAAYC,EAAsE,CAExE,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,gBAAAC,EAAkB,EAClB,gBAAAC,EAAkB,EAClB,cAAAC,EAAgB,EAChB,UAAAC,EAAY,GACZ,gBAAAC,EAAkB,UAClB,gBAAAC,EAAkB,EAClB,WAAAC,EAAa,CACb,EAAAjB,EAGJ,KAAK,KAAOC,EAEZ,KAAK,QAAU,KAAK,QAAQ,KAAK,IAAI,EACrC,KAAK,WAAa,KAAK,WAAW,KAAK,IAAI,EAC3C,KAAK,eAAiB,KAAK,eAAe,KAAK,IAAI,EAEnD,KAAK,MAAQC,EACb,KAAK,mBAAqBC,EAC1B,KAAK,iBAAmBC,EACxB,KAAK,eAAiBC,EACtB,KAAK,eAAiBC,EACtB,KAAK,cAAgBC,EACrB,KAAK,cAAgBM,EACrB,KAAK,OAASL,EACd,KAAK,QAAUE,EACf,KAAK,WAAaD,EAClB,KAAK,gBAAkBE,E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access": "public",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.5",
|
|
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
|
@@ -10,12 +10,14 @@ const clock = new THREE.Clock();
|
|
|
10
10
|
|
|
11
11
|
type SceneState = {
|
|
12
12
|
renderer: THREE.WebGLRenderer,
|
|
13
|
-
camera: THREE.
|
|
13
|
+
camera: THREE.Camera,
|
|
14
14
|
scene: THREE.Scene,
|
|
15
15
|
meshes: THREE.Mesh[],
|
|
16
|
+
resolution: number
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export type NeatConfig = {
|
|
20
|
+
resolution?: number;
|
|
19
21
|
speed?: number;
|
|
20
22
|
horizontalPressure?: number;
|
|
21
23
|
verticalPressure?: number;
|
|
@@ -24,7 +26,8 @@ export type NeatConfig = {
|
|
|
24
26
|
waveAmplitude?: number;
|
|
25
27
|
highlights?: number;
|
|
26
28
|
shadows?: number;
|
|
27
|
-
|
|
29
|
+
colorSaturation?: number;
|
|
30
|
+
colorBrightness?: number;
|
|
28
31
|
colors: NeatColor[];
|
|
29
32
|
colorBlending?: number;
|
|
30
33
|
wireframe?: boolean;
|
|
@@ -47,6 +50,8 @@ export type NeatController = {
|
|
|
47
50
|
|
|
48
51
|
export class NeatGradient implements NeatController {
|
|
49
52
|
|
|
53
|
+
private _ref: HTMLCanvasElement;
|
|
54
|
+
|
|
50
55
|
private _speed: number = -1;
|
|
51
56
|
|
|
52
57
|
private _horizontalPressure: number = -1;
|
|
@@ -59,18 +64,20 @@ export class NeatGradient implements NeatController {
|
|
|
59
64
|
private _shadows: number = -1;
|
|
60
65
|
private _highlights: number = -1;
|
|
61
66
|
private _saturation: number = -1;
|
|
67
|
+
private _brightness: number = -1;
|
|
62
68
|
|
|
63
69
|
private _colorBlending: number = -1;
|
|
64
70
|
|
|
65
71
|
private _colors: NeatColor[] = [];
|
|
66
72
|
private _wireframe: boolean = false;
|
|
67
73
|
|
|
74
|
+
private _resolution: number = 1;
|
|
68
75
|
private _backgroundColor: string = "#FFFFFF";
|
|
69
76
|
private _backgroundAlpha: number = 1.0;
|
|
70
77
|
|
|
71
78
|
private requestRef: number = -1;
|
|
72
79
|
private sizeObserver: ResizeObserver;
|
|
73
|
-
private
|
|
80
|
+
private sceneState: SceneState;
|
|
74
81
|
|
|
75
82
|
constructor(config: NeatConfig & { ref: HTMLCanvasElement, resolution?: number }) {
|
|
76
83
|
|
|
@@ -85,7 +92,8 @@ export class NeatGradient implements NeatController {
|
|
|
85
92
|
colors,
|
|
86
93
|
highlights = 4,
|
|
87
94
|
shadows = 4,
|
|
88
|
-
|
|
95
|
+
colorSaturation = 0,
|
|
96
|
+
colorBrightness = 1,
|
|
89
97
|
colorBlending = 5,
|
|
90
98
|
wireframe = false,
|
|
91
99
|
backgroundColor = "#FFFFFF",
|
|
@@ -93,8 +101,8 @@ export class NeatGradient implements NeatController {
|
|
|
93
101
|
resolution = 1
|
|
94
102
|
} = config;
|
|
95
103
|
|
|
96
|
-
|
|
97
|
-
|
|
104
|
+
|
|
105
|
+
this._ref = ref;
|
|
98
106
|
|
|
99
107
|
this.destroy = this.destroy.bind(this);
|
|
100
108
|
this._initScene = this._initScene.bind(this);
|
|
@@ -110,18 +118,19 @@ export class NeatGradient implements NeatController {
|
|
|
110
118
|
this.colors = colors;
|
|
111
119
|
this.shadows = shadows;
|
|
112
120
|
this.highlights = highlights;
|
|
113
|
-
this.
|
|
121
|
+
this.colorSaturation = colorSaturation;
|
|
122
|
+
this.colorBrightness = colorBrightness;
|
|
114
123
|
this.wireframe = wireframe;
|
|
115
124
|
this.backgroundColor = backgroundColor;
|
|
116
125
|
this.backgroundAlpha = backgroundAlpha;
|
|
117
126
|
|
|
118
|
-
this.sceneState = this._initScene(
|
|
127
|
+
this.sceneState = this._initScene(resolution);
|
|
119
128
|
|
|
120
|
-
const { renderer, camera, scene, meshes } = this.sceneState;
|
|
121
129
|
|
|
122
130
|
let tick = 0;
|
|
123
131
|
const render = () => {
|
|
124
132
|
|
|
133
|
+
const { renderer, camera, scene, meshes } = this.sceneState;
|
|
125
134
|
if (Math.floor(tick * 10) % 5 === 0) {
|
|
126
135
|
addNeatLink(ref);
|
|
127
136
|
}
|
|
@@ -129,6 +138,9 @@ export class NeatGradient implements NeatController {
|
|
|
129
138
|
renderer.setClearColor(this._backgroundColor, this._backgroundAlpha);
|
|
130
139
|
meshes.forEach((mesh) => {
|
|
131
140
|
|
|
141
|
+
const width = this._ref.width,
|
|
142
|
+
height = this._ref.height;
|
|
143
|
+
|
|
132
144
|
const colors = [
|
|
133
145
|
...this._colors.map(color => ({
|
|
134
146
|
is_active: color.enabled,
|
|
@@ -171,6 +183,8 @@ export class NeatGradient implements NeatController {
|
|
|
171
183
|
// @ts-ignore
|
|
172
184
|
mesh.material.uniforms.u_saturation = { value: this._saturation };
|
|
173
185
|
// @ts-ignore
|
|
186
|
+
mesh.material.uniforms.u_brightness = { value: this._brightness };
|
|
187
|
+
// @ts-ignore
|
|
174
188
|
mesh.material.wireframe = this._wireframe;
|
|
175
189
|
});
|
|
176
190
|
|
|
@@ -179,6 +193,8 @@ export class NeatGradient implements NeatController {
|
|
|
179
193
|
};
|
|
180
194
|
|
|
181
195
|
const setSize = () => {
|
|
196
|
+
|
|
197
|
+
const { renderer } = this.sceneState;
|
|
182
198
|
const canvas = renderer.domElement;
|
|
183
199
|
const width = canvas.clientWidth;
|
|
184
200
|
const height = canvas.clientHeight;
|
|
@@ -240,8 +256,12 @@ export class NeatGradient implements NeatController {
|
|
|
240
256
|
this._shadows = shadows / 100;
|
|
241
257
|
}
|
|
242
258
|
|
|
243
|
-
set
|
|
244
|
-
this._saturation =
|
|
259
|
+
set colorSaturation(colorSaturation: number) {
|
|
260
|
+
this._saturation = colorSaturation / 10;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
set colorBrightness(colorBrightness: number) {
|
|
264
|
+
this._brightness = colorBrightness;
|
|
245
265
|
}
|
|
246
266
|
|
|
247
267
|
set colorBlending(colorBlending: number) {
|
|
@@ -252,6 +272,11 @@ export class NeatGradient implements NeatController {
|
|
|
252
272
|
this._wireframe = wireframe;
|
|
253
273
|
}
|
|
254
274
|
|
|
275
|
+
set resolution(resolution: number) {
|
|
276
|
+
this._resolution = resolution;
|
|
277
|
+
this.sceneState = this._initScene(resolution);
|
|
278
|
+
}
|
|
279
|
+
|
|
255
280
|
set backgroundColor(backgroundColor: string) {
|
|
256
281
|
this._backgroundColor = backgroundColor;
|
|
257
282
|
}
|
|
@@ -260,12 +285,15 @@ export class NeatGradient implements NeatController {
|
|
|
260
285
|
this._backgroundAlpha = backgroundAlpha;
|
|
261
286
|
}
|
|
262
287
|
|
|
263
|
-
_initScene(
|
|
288
|
+
_initScene(resolution: number): SceneState {
|
|
289
|
+
|
|
290
|
+
const width = this._ref.width,
|
|
291
|
+
height = this._ref.height;
|
|
264
292
|
|
|
265
293
|
const renderer = new THREE.WebGLRenderer({
|
|
266
294
|
// antialias: true,
|
|
267
295
|
alpha: true,
|
|
268
|
-
canvas:
|
|
296
|
+
canvas: this._ref
|
|
269
297
|
});
|
|
270
298
|
|
|
271
299
|
renderer.setClearColor(0xFF0000, .5);
|
|
@@ -285,14 +313,16 @@ export class NeatGradient implements NeatController {
|
|
|
285
313
|
scene.add(plane);
|
|
286
314
|
|
|
287
315
|
const camera = new THREE.OrthographicCamera(0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
|
|
288
|
-
// camera
|
|
316
|
+
// const camera = new THREE.PerspectiveCamera( 1000, window.innerWidth / window.innerHeight, 1, 1000000 );
|
|
317
|
+
camera.position.z = 5;
|
|
289
318
|
updateCamera(camera, width, height);
|
|
290
319
|
|
|
291
320
|
return {
|
|
292
321
|
renderer,
|
|
293
322
|
camera,
|
|
294
323
|
scene,
|
|
295
|
-
meshes
|
|
324
|
+
meshes,
|
|
325
|
+
resolution
|
|
296
326
|
};
|
|
297
327
|
}
|
|
298
328
|
|
|
@@ -338,7 +368,7 @@ export class NeatGradient implements NeatController {
|
|
|
338
368
|
|
|
339
369
|
}
|
|
340
370
|
|
|
341
|
-
function updateCamera(camera: THREE.
|
|
371
|
+
function updateCamera(camera: THREE.Camera, width: number, height: number) {
|
|
342
372
|
|
|
343
373
|
const viewPortAreaRatio = 1000000;
|
|
344
374
|
const areaViewPort = width * height;
|
|
@@ -359,13 +389,19 @@ function updateCamera(camera: THREE.OrthographicCamera, width: number, height: n
|
|
|
359
389
|
|
|
360
390
|
const near = -100;
|
|
361
391
|
const far = 1000;
|
|
362
|
-
camera.
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
392
|
+
if (camera instanceof THREE.OrthographicCamera) {
|
|
393
|
+
camera.left = left;
|
|
394
|
+
camera.right = right;
|
|
395
|
+
camera.top = top;
|
|
396
|
+
camera.bottom = bottom;
|
|
397
|
+
camera.near = near;
|
|
398
|
+
camera.far = far;
|
|
399
|
+
camera.updateProjectionMatrix();
|
|
400
|
+
} else if (camera instanceof THREE.PerspectiveCamera) {
|
|
401
|
+
camera.aspect = width / height;
|
|
402
|
+
camera.updateProjectionMatrix();
|
|
403
|
+
}
|
|
404
|
+
|
|
369
405
|
}
|
|
370
406
|
|
|
371
407
|
|
|
@@ -433,6 +469,7 @@ void main(){
|
|
|
433
469
|
color.rgb += pow(v_displacement_amount, 1.0) * u_highlights;
|
|
434
470
|
color.rgb -= pow(1.0 - v_displacement_amount, 2.0) * u_shadows;
|
|
435
471
|
color = saturation(color, 1.0 + u_saturation);
|
|
472
|
+
color = color * u_brightness;
|
|
436
473
|
|
|
437
474
|
gl_FragColor = vec4(color,1.0);
|
|
438
475
|
}
|
|
@@ -462,6 +499,7 @@ uniform float u_plane_height;
|
|
|
462
499
|
uniform float u_shadows;
|
|
463
500
|
uniform float u_highlights;
|
|
464
501
|
uniform float u_saturation;
|
|
502
|
+
uniform float u_brightness;
|
|
465
503
|
|
|
466
504
|
uniform float u_color_blending;
|
|
467
505
|
|