@firecms/neat 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/NeatGradient.d.ts +7 -0
- package/dist/NeatGradient.js +166 -73
- package/dist/NeatGradient.js.map +1 -1
- package/dist/index.es.js +253 -217
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +6 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/NeatGradient.ts +180 -75
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as l from "three";
|
|
2
|
-
const
|
|
3
|
-
class
|
|
2
|
+
const U = 50, D = 80, be = !0, j = 6, ze = new l.Clock(), Q = Te();
|
|
3
|
+
class Be {
|
|
4
4
|
_ref;
|
|
5
5
|
_speed = -1;
|
|
6
6
|
_horizontalPressure = -1;
|
|
@@ -61,104 +61,119 @@ class ze {
|
|
|
61
61
|
_yOffsetColorMultiplier = 4e-3;
|
|
62
62
|
_yOffsetFlowMultiplier = 4e-3;
|
|
63
63
|
_tempClearColor = new l.Color();
|
|
64
|
+
_resizeTimeoutId = null;
|
|
65
|
+
_textureNeedsUpdate = !1;
|
|
66
|
+
_lastColorUpdate = 0;
|
|
67
|
+
_linkCheckCounter = 0;
|
|
68
|
+
_mouseUpdateScheduled = !1;
|
|
69
|
+
_pendingMousePosition = null;
|
|
70
|
+
_colorsChanged = !0;
|
|
64
71
|
constructor(e) {
|
|
65
72
|
const {
|
|
66
|
-
ref:
|
|
73
|
+
ref: s,
|
|
67
74
|
speed: t = 4,
|
|
68
75
|
horizontalPressure: f = 3,
|
|
69
|
-
verticalPressure:
|
|
70
|
-
waveFrequencyX:
|
|
71
|
-
waveFrequencyY:
|
|
72
|
-
waveAmplitude:
|
|
73
|
-
colors:
|
|
74
|
-
highlights:
|
|
75
|
-
shadows:
|
|
76
|
-
colorSaturation:
|
|
77
|
-
colorBrightness:
|
|
76
|
+
verticalPressure: c = 3,
|
|
77
|
+
waveFrequencyX: o = 5,
|
|
78
|
+
waveFrequencyY: p = 5,
|
|
79
|
+
waveAmplitude: g = 3,
|
|
80
|
+
colors: d,
|
|
81
|
+
highlights: v = 4,
|
|
82
|
+
shadows: u = 4,
|
|
83
|
+
colorSaturation: x = 0,
|
|
84
|
+
colorBrightness: O = 1,
|
|
78
85
|
colorBlending: M = 5,
|
|
79
|
-
grainScale:
|
|
80
|
-
grainIntensity:
|
|
81
|
-
grainSparsity:
|
|
82
|
-
grainSpeed:
|
|
86
|
+
grainScale: z = 2,
|
|
87
|
+
grainIntensity: y = 0.55,
|
|
88
|
+
grainSparsity: F = 0,
|
|
89
|
+
grainSpeed: C = 0.1,
|
|
83
90
|
wireframe: a = !1,
|
|
84
91
|
backgroundColor: n = "#FFFFFF",
|
|
85
92
|
backgroundAlpha: h = 1,
|
|
86
93
|
resolution: _ = 1,
|
|
87
|
-
seed:
|
|
88
|
-
yOffset:
|
|
89
|
-
yOffsetWaveMultiplier:
|
|
90
|
-
yOffsetColorMultiplier:
|
|
91
|
-
yOffsetFlowMultiplier:
|
|
92
|
-
flowDistortionA:
|
|
93
|
-
flowDistortionB:
|
|
94
|
-
flowScale:
|
|
95
|
-
flowEase:
|
|
96
|
-
flowEnabled:
|
|
97
|
-
mouseDistortionStrength:
|
|
98
|
-
mouseDistortionRadius:
|
|
99
|
-
mouseDecayRate:
|
|
100
|
-
mouseDarken:
|
|
101
|
-
enableProceduralTexture:
|
|
102
|
-
textureVoidLikelihood:
|
|
103
|
-
textureVoidWidthMin:
|
|
104
|
-
textureVoidWidthMax:
|
|
105
|
-
textureBandDensity:
|
|
106
|
-
textureColorBlending:
|
|
107
|
-
textureSeed:
|
|
108
|
-
textureEase:
|
|
109
|
-
proceduralBackgroundColor:
|
|
110
|
-
textureShapeTriangles:
|
|
111
|
-
textureShapeCircles:
|
|
112
|
-
textureShapeBars:
|
|
113
|
-
textureShapeSquiggles:
|
|
94
|
+
seed: S,
|
|
95
|
+
yOffset: B = 0,
|
|
96
|
+
yOffsetWaveMultiplier: N = 4,
|
|
97
|
+
yOffsetColorMultiplier: V = 4,
|
|
98
|
+
yOffsetFlowMultiplier: $ = 4,
|
|
99
|
+
flowDistortionA: ee = 0,
|
|
100
|
+
flowDistortionB: te = 0,
|
|
101
|
+
flowScale: oe = 1,
|
|
102
|
+
flowEase: se = 0,
|
|
103
|
+
flowEnabled: ie = !0,
|
|
104
|
+
mouseDistortionStrength: re = 0,
|
|
105
|
+
mouseDistortionRadius: ae = 0.25,
|
|
106
|
+
mouseDecayRate: le = 0.96,
|
|
107
|
+
mouseDarken: ne = 0,
|
|
108
|
+
enableProceduralTexture: ue = !1,
|
|
109
|
+
textureVoidLikelihood: ce = 0.45,
|
|
110
|
+
textureVoidWidthMin: _e = 200,
|
|
111
|
+
textureVoidWidthMax: he = 486,
|
|
112
|
+
textureBandDensity: fe = 2.15,
|
|
113
|
+
textureColorBlending: de = 0.01,
|
|
114
|
+
textureSeed: pe = 333,
|
|
115
|
+
textureEase: ve = 0.5,
|
|
116
|
+
proceduralBackgroundColor: xe = "#000000",
|
|
117
|
+
textureShapeTriangles: ge = 20,
|
|
118
|
+
textureShapeCircles: me = 15,
|
|
119
|
+
textureShapeBars: ye = 15,
|
|
120
|
+
textureShapeSquiggles: we = 10
|
|
114
121
|
} = e;
|
|
115
|
-
this._ref =
|
|
116
|
-
let
|
|
117
|
-
const
|
|
118
|
-
const { renderer:
|
|
119
|
-
if (
|
|
122
|
+
this._ref = s, this.destroy = this.destroy.bind(this), this._initScene = this._initScene.bind(this), this._buildMaterial = this._buildMaterial.bind(this), this.speed = t, this.horizontalPressure = f, this.verticalPressure = c, this.waveFrequencyX = o, this.waveFrequencyY = p, this.waveAmplitude = g, this.colorBlending = M, this.grainScale = z, this.grainIntensity = y, this.grainSparsity = F, this.grainSpeed = C, this.colors = d, this.shadows = u, this.highlights = v, this.colorSaturation = x, this.colorBrightness = O, this.wireframe = a, this.backgroundColor = n, this.backgroundAlpha = h, this.yOffset = B, this.yOffsetWaveMultiplier = N, this.yOffsetColorMultiplier = V, this.yOffsetFlowMultiplier = $, this.flowDistortionA = ee, this.flowDistortionB = te, this.flowScale = oe, this.flowEase = se, this.flowEnabled = ie, this.mouseDistortionStrength = re, this.mouseDistortionRadius = ae, this.mouseDecayRate = le, this.mouseDarken = ne, this.enableProceduralTexture = ue, this.textureVoidLikelihood = ce, this.textureVoidWidthMin = _e, this.textureVoidWidthMax = he, this.textureBandDensity = fe, this.textureColorBlending = de, this.textureSeed = pe, this.textureEase = ve, this._proceduralBackgroundColor = xe, this._textureShapeTriangles = ge, this._textureShapeCircles = me, this._textureShapeBars = ye, this._textureShapeSquiggles = we, this._setupMouseInteraction(), this.sceneState = this._initScene(_);
|
|
123
|
+
let G = S !== void 0 ? S : Oe();
|
|
124
|
+
const X = () => {
|
|
125
|
+
const { renderer: w, camera: E, scene: T } = this.sceneState;
|
|
126
|
+
if (this._linkCheckCounter++, this._linkCheckCounter >= 300 && (this._linkCheckCounter = 0, (!this._linkElement || !document.contains(this._linkElement)) && (this._linkElement = Pe(s))), this._cachedUniforms) {
|
|
120
127
|
const i = this._cachedUniforms;
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
G += ze.getDelta() * this._speed, i.u_time.value = G, i.u_resolution.value.set(this._ref.width, this._ref.height), i.u_color_pressure.value.set(this._horizontalPressure, this._verticalPressure), i.u_wave_frequency_x.value = this._waveFrequencyX, i.u_wave_frequency_y.value = this._waveFrequencyY, i.u_wave_amplitude.value = this._waveAmplitude, i.u_color_blending.value = this._colorBlending, i.u_shadows.value = this._shadows, i.u_highlights.value = this._highlights, i.u_saturation.value = this._saturation, i.u_brightness.value = this._brightness, i.u_grain_intensity.value = this._grainIntensity, i.u_grain_sparsity.value = this._grainSparsity, i.u_grain_speed.value = this._grainSpeed, i.u_grain_scale.value = this._grainScale, i.u_y_offset.value = this._yOffset, i.u_y_offset_wave_multiplier.value = this._yOffsetWaveMultiplier, i.u_y_offset_color_multiplier.value = this._yOffsetColorMultiplier, i.u_y_offset_flow_multiplier.value = this._yOffsetFlowMultiplier, i.u_flow_distortion_a.value = this._flowDistortionA, i.u_flow_distortion_b.value = this._flowDistortionB, i.u_flow_scale.value = this._flowScale, i.u_flow_ease.value = this._flowEase, i.u_flow_enabled.value = this._flowEnabled ? 1 : 0, i.u_mouse_distortion_strength.value = this._mouseDistortionStrength, i.u_mouse_distortion_radius.value = this._mouseDistortionRadius, i.u_mouse_darken.value = this._mouseDarken, i.u_enable_procedural_texture.value = this._enableProceduralTexture ? 1 : 0, this._textureNeedsUpdate && this._enableProceduralTexture && (this._proceduralTexture && this._proceduralTexture.dispose(), this._proceduralTexture = this._createProceduralTexture(), this._textureNeedsUpdate = !1), i.u_procedural_texture.value = this._proceduralTexture, i.u_texture_ease.value = this._textureEase, this.sceneState.meshes[0].material.wireframe = this._wireframe;
|
|
129
|
+
const m = Date.now();
|
|
130
|
+
if (this._colorsChanged || m - this._lastColorUpdate > 100) {
|
|
131
|
+
this._lastColorUpdate = m, this._colorsChanged = !1;
|
|
132
|
+
const q = i.u_colors.value;
|
|
133
|
+
for (let P = 0; P < j; P++)
|
|
134
|
+
if (P < this._colors.length) {
|
|
135
|
+
const L = this._colors[P];
|
|
136
|
+
q[P].is_active = L.enabled ? 1 : 0, q[P].color.setStyle(L.color, ""), q[P].influence = L.influence || 0;
|
|
137
|
+
} else
|
|
138
|
+
q[P].is_active = 0;
|
|
139
|
+
i.u_colors_count.value = j;
|
|
140
|
+
}
|
|
130
141
|
}
|
|
131
|
-
if (this._mouseFBO && this._sceneMouse && this._cameraMouse) {
|
|
142
|
+
if (this._mouseFBO && this._sceneMouse && this._cameraMouse && this._mouseDistortionStrength > 0) {
|
|
132
143
|
let i = !1;
|
|
133
|
-
for (let
|
|
134
|
-
const
|
|
135
|
-
|
|
144
|
+
for (let m = 0; m < this._mouseObjects.length; m++) {
|
|
145
|
+
const b = this._mouseObjects[m];
|
|
146
|
+
b.mesh.visible && (i = !0, b.mesh.rotation.z += 0.01, b.mesh.material instanceof l.MeshBasicMaterial && (b.mesh.material.opacity *= this._mouseDecayRate, b.mesh.material.opacity < 0.01 && (b.mesh.visible = !1)));
|
|
147
|
+
}
|
|
148
|
+
if (i) {
|
|
149
|
+
w.getClearColor(this._tempClearColor);
|
|
150
|
+
const m = w.getClearAlpha();
|
|
151
|
+
w.setClearColor(0, 0), w.setRenderTarget(this._mouseFBO), w.clear(), w.render(this._sceneMouse, this._cameraMouse), w.setRenderTarget(null), w.setClearColor(this._tempClearColor, m), this._cachedUniforms && (this._cachedUniforms.u_mouse_texture.value = this._mouseFBO.texture);
|
|
136
152
|
}
|
|
137
|
-
g.getClearColor(this._tempClearColor);
|
|
138
|
-
const w = g.getClearAlpha();
|
|
139
|
-
g.setClearColor(0, 0), g.setRenderTarget(this._mouseFBO), g.clear(), i && g.render(this._sceneMouse, this._cameraMouse), g.setRenderTarget(null), g.setClearColor(this._tempClearColor, w), this._cachedUniforms && (this._cachedUniforms.u_mouse_texture.value = this._mouseFBO.texture);
|
|
140
153
|
}
|
|
141
|
-
|
|
142
|
-
},
|
|
143
|
-
const { renderer:
|
|
144
|
-
if (this.sceneState.renderer.setSize(
|
|
145
|
-
const
|
|
146
|
-
this._mouseFBO.setSize(
|
|
154
|
+
w.setClearColor(this._backgroundColor, this._backgroundAlpha), w.render(T, E), this.requestRef = requestAnimationFrame(X);
|
|
155
|
+
}, Se = () => {
|
|
156
|
+
const { renderer: w } = this.sceneState, E = w.domElement, T = E.clientWidth, i = E.clientHeight;
|
|
157
|
+
if (this.sceneState.renderer.setSize(T, i, !1), K(this.sceneState.camera, T, i), this._mouseFBO && this._cameraMouse) {
|
|
158
|
+
const m = i / 2, b = T / i;
|
|
159
|
+
this._mouseFBO.setSize(T / 2, i / 2), this._cameraMouse.left = -m * b, this._cameraMouse.right = m * b, this._cameraMouse.top = m, this._cameraMouse.bottom = -m, this._cameraMouse.updateProjectionMatrix();
|
|
147
160
|
}
|
|
148
161
|
};
|
|
149
|
-
this.sizeObserver = new ResizeObserver((
|
|
150
|
-
|
|
151
|
-
|
|
162
|
+
this.sizeObserver = new ResizeObserver(() => {
|
|
163
|
+
this._resizeTimeoutId !== null && clearTimeout(this._resizeTimeoutId), this._resizeTimeoutId = window.setTimeout(() => {
|
|
164
|
+
Se(), this._resizeTimeoutId = null;
|
|
165
|
+
}, 100);
|
|
166
|
+
}), this.sizeObserver.observe(s), X();
|
|
152
167
|
}
|
|
153
168
|
destroy() {
|
|
154
|
-
this && (cancelAnimationFrame(this.requestRef), this.sizeObserver.disconnect(), this.sceneState && (this.sceneState.renderer.dispose(), this.sceneState.meshes.forEach((e) => {
|
|
155
|
-
e.geometry.dispose(), Array.isArray(e.material) ? e.material.forEach((
|
|
169
|
+
this && (cancelAnimationFrame(this.requestRef), this.sizeObserver.disconnect(), this._resizeTimeoutId !== null && (clearTimeout(this._resizeTimeoutId), this._resizeTimeoutId = null), this.sceneState && (this.sceneState.renderer.dispose(), this.sceneState.meshes.forEach((e) => {
|
|
170
|
+
e.geometry.dispose(), Array.isArray(e.material) ? e.material.forEach((s) => s.dispose()) : e.material.dispose();
|
|
156
171
|
})), this._mouseFBO && this._mouseFBO.dispose(), this._proceduralTexture && this._proceduralTexture.dispose());
|
|
157
172
|
}
|
|
158
173
|
downloadAsPNG(e = "neat.png") {
|
|
159
174
|
console.log("Downloading as PNG", this._ref);
|
|
160
|
-
const
|
|
161
|
-
console.log("data",
|
|
175
|
+
const s = this._ref.toDataURL("image/png");
|
|
176
|
+
console.log("data", s), Fe(s, e);
|
|
162
177
|
}
|
|
163
178
|
set speed(e) {
|
|
164
179
|
this._speed = e / 20;
|
|
@@ -179,7 +194,7 @@ class ze {
|
|
|
179
194
|
this._waveAmplitude = e * 0.75;
|
|
180
195
|
}
|
|
181
196
|
set colors(e) {
|
|
182
|
-
this._colors = e;
|
|
197
|
+
this._colors = e, this._colorsChanged = !0;
|
|
183
198
|
}
|
|
184
199
|
set highlights(e) {
|
|
185
200
|
this._highlights = e / 100;
|
|
@@ -275,25 +290,25 @@ class ze {
|
|
|
275
290
|
this._mouseDarken = e;
|
|
276
291
|
}
|
|
277
292
|
set enableProceduralTexture(e) {
|
|
278
|
-
this._enableProceduralTexture = e, e && !this._proceduralTexture && (this.
|
|
293
|
+
this._enableProceduralTexture = e, e && !this._proceduralTexture && (this._textureNeedsUpdate = !0);
|
|
279
294
|
}
|
|
280
295
|
set textureVoidLikelihood(e) {
|
|
281
|
-
this._textureVoidLikelihood = e, this._enableProceduralTexture && (this.
|
|
296
|
+
this._textureVoidLikelihood = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
|
|
282
297
|
}
|
|
283
298
|
set textureVoidWidthMin(e) {
|
|
284
|
-
this._textureVoidWidthMin = e, this._enableProceduralTexture && (this.
|
|
299
|
+
this._textureVoidWidthMin = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
|
|
285
300
|
}
|
|
286
301
|
set textureVoidWidthMax(e) {
|
|
287
|
-
this._textureVoidWidthMax = e, this._enableProceduralTexture && (this.
|
|
302
|
+
this._textureVoidWidthMax = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
|
|
288
303
|
}
|
|
289
304
|
set textureBandDensity(e) {
|
|
290
|
-
this._textureBandDensity = e, this._enableProceduralTexture && (this.
|
|
305
|
+
this._textureBandDensity = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
|
|
291
306
|
}
|
|
292
307
|
set textureColorBlending(e) {
|
|
293
|
-
this._textureColorBlending = e, this._enableProceduralTexture && (this.
|
|
308
|
+
this._textureColorBlending = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
|
|
294
309
|
}
|
|
295
310
|
set textureSeed(e) {
|
|
296
|
-
this._textureSeed = e, this._enableProceduralTexture && (this.
|
|
311
|
+
this._textureSeed = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
|
|
297
312
|
}
|
|
298
313
|
get textureEase() {
|
|
299
314
|
return this._textureEase;
|
|
@@ -302,58 +317,58 @@ class ze {
|
|
|
302
317
|
this._textureEase = e;
|
|
303
318
|
}
|
|
304
319
|
set proceduralBackgroundColor(e) {
|
|
305
|
-
this._proceduralBackgroundColor = e, this._enableProceduralTexture && (this.
|
|
320
|
+
this._proceduralBackgroundColor = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
|
|
306
321
|
}
|
|
307
322
|
set textureShapeTriangles(e) {
|
|
308
|
-
this._textureShapeTriangles = e, this._enableProceduralTexture && (this.
|
|
323
|
+
this._textureShapeTriangles = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
|
|
309
324
|
}
|
|
310
325
|
set textureShapeCircles(e) {
|
|
311
|
-
this._textureShapeCircles = e, this._enableProceduralTexture && (this.
|
|
326
|
+
this._textureShapeCircles = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
|
|
312
327
|
}
|
|
313
328
|
set textureShapeBars(e) {
|
|
314
|
-
this._textureShapeBars = e, this._enableProceduralTexture && (this.
|
|
329
|
+
this._textureShapeBars = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
|
|
315
330
|
}
|
|
316
331
|
set textureShapeSquiggles(e) {
|
|
317
|
-
this._textureShapeSquiggles = e, this._enableProceduralTexture && (this.
|
|
332
|
+
this._textureShapeSquiggles = e, this._enableProceduralTexture && (this._textureNeedsUpdate = !0);
|
|
318
333
|
}
|
|
319
334
|
_initScene(e) {
|
|
320
|
-
const
|
|
321
|
-
this.sceneState && this.sceneState.renderer && (this.sceneState.renderer.dispose(), this.sceneState.meshes.forEach((
|
|
322
|
-
|
|
335
|
+
const s = this._ref.width, t = this._ref.height;
|
|
336
|
+
this.sceneState && this.sceneState.renderer && (this.sceneState.renderer.dispose(), this.sceneState.meshes.forEach((u) => {
|
|
337
|
+
u.geometry.dispose(), Array.isArray(u.material) ? u.material.forEach((x) => x.dispose()) : u.material.dispose();
|
|
323
338
|
}));
|
|
324
339
|
const f = new l.WebGLRenderer({
|
|
325
340
|
alpha: !0,
|
|
326
341
|
preserveDrawingBuffer: !0,
|
|
327
342
|
canvas: this._ref
|
|
328
343
|
});
|
|
329
|
-
f.setClearColor(16711680, 0.5), f.setSize(
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
const
|
|
333
|
-
return
|
|
344
|
+
f.setClearColor(16711680, 0.5), f.setSize(s, t, !1);
|
|
345
|
+
const c = [], o = new l.Scene(), p = this._buildMaterial(s, t), g = new l.PlaneGeometry(U, D, 240 * e, 240 * e), d = new l.Mesh(g, p);
|
|
346
|
+
d.rotation.x = -Math.PI / 3.5, d.position.z = -1, c.push(d), o.add(d);
|
|
347
|
+
const v = new l.OrthographicCamera(0, 0, 0, 0, 0, 0);
|
|
348
|
+
return v.position.z = 5, K(v, s, t), {
|
|
334
349
|
renderer: f,
|
|
335
|
-
camera:
|
|
336
|
-
scene:
|
|
337
|
-
meshes:
|
|
350
|
+
camera: v,
|
|
351
|
+
scene: o,
|
|
352
|
+
meshes: c,
|
|
338
353
|
resolution: e
|
|
339
354
|
};
|
|
340
355
|
}
|
|
341
|
-
_buildMaterial(e,
|
|
342
|
-
const t = Array.from({ length:
|
|
343
|
-
is_active:
|
|
344
|
-
color: new l.Color(
|
|
345
|
-
influence:
|
|
356
|
+
_buildMaterial(e, s) {
|
|
357
|
+
const t = Array.from({ length: j }).map((o, p) => ({
|
|
358
|
+
is_active: p < this._colors.length && this._colors[p].enabled ? 1 : 0,
|
|
359
|
+
color: new l.Color(p < this._colors.length ? this._colors[p].color : 0),
|
|
360
|
+
influence: p < this._colors.length && this._colors[p].influence || 0
|
|
346
361
|
})), f = {
|
|
347
362
|
u_time: { value: 0 },
|
|
348
363
|
u_color_pressure: { value: new l.Vector2(this._horizontalPressure, this._verticalPressure) },
|
|
349
364
|
u_wave_frequency_x: { value: this._waveFrequencyX },
|
|
350
365
|
u_wave_frequency_y: { value: this._waveFrequencyY },
|
|
351
366
|
u_wave_amplitude: { value: this._waveAmplitude },
|
|
352
|
-
u_resolution: { value: new l.Vector2(e,
|
|
367
|
+
u_resolution: { value: new l.Vector2(e, s) },
|
|
353
368
|
u_colors: { value: t },
|
|
354
369
|
u_colors_count: { value: this._colors.length },
|
|
355
|
-
u_plane_width: { value:
|
|
356
|
-
u_plane_height: { value:
|
|
370
|
+
u_plane_width: { value: U },
|
|
371
|
+
u_plane_height: { value: D },
|
|
357
372
|
u_shadows: { value: this._shadows },
|
|
358
373
|
u_highlights: { value: this._highlights },
|
|
359
374
|
u_grain_intensity: { value: this._grainIntensity },
|
|
@@ -379,19 +394,19 @@ class ze {
|
|
|
379
394
|
u_saturation: { value: this._saturation },
|
|
380
395
|
u_brightness: { value: this._brightness },
|
|
381
396
|
u_color_blending: { value: this._colorBlending }
|
|
382
|
-
},
|
|
397
|
+
}, c = new l.ShaderMaterial({
|
|
383
398
|
uniforms: f,
|
|
384
|
-
vertexShader:
|
|
385
|
-
fragmentShader:
|
|
399
|
+
vertexShader: H() + Y() + Z() + Ce(),
|
|
400
|
+
fragmentShader: H() + Z() + Y() + Me()
|
|
386
401
|
});
|
|
387
|
-
return this._cachedUniforms = f,
|
|
402
|
+
return this._cachedUniforms = f, c.wireframe = be, c;
|
|
388
403
|
}
|
|
389
404
|
_setupMouseInteraction() {
|
|
390
405
|
if (!this._ref)
|
|
391
406
|
return;
|
|
392
|
-
const e = this._ref.width,
|
|
393
|
-
this._mouseFBO = new l.WebGLRenderTarget(e / 2,
|
|
394
|
-
const t =
|
|
407
|
+
const e = this._ref.width, s = this._ref.height;
|
|
408
|
+
this._mouseFBO = new l.WebGLRenderTarget(e / 2, s / 2), this._sceneMouse = new l.Scene();
|
|
409
|
+
const t = s / 2, f = e / s;
|
|
395
410
|
this._cameraMouse = new l.OrthographicCamera(
|
|
396
411
|
-t * f,
|
|
397
412
|
t * f,
|
|
@@ -400,52 +415,59 @@ class ze {
|
|
|
400
415
|
0,
|
|
401
416
|
1e4
|
|
402
417
|
), this._cameraMouse.position.set(0, 0, 100);
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
const
|
|
406
|
-
if (
|
|
407
|
-
const
|
|
408
|
-
|
|
418
|
+
const c = document.createElement("canvas");
|
|
419
|
+
c.width = 128, c.height = 128;
|
|
420
|
+
const o = c.getContext("2d");
|
|
421
|
+
if (o) {
|
|
422
|
+
const u = o.createRadialGradient(64, 64, 0, 64, 64, 64);
|
|
423
|
+
u.addColorStop(0, "rgba(255,255,255,0.8)"), u.addColorStop(0.5, "rgba(255,255,255,0.4)"), u.addColorStop(1, "rgba(255,255,255,0)"), o.fillStyle = u, o.fillRect(0, 0, 128, 128);
|
|
409
424
|
}
|
|
410
|
-
const
|
|
411
|
-
map:
|
|
425
|
+
const p = new l.CanvasTexture(c), g = new l.MeshBasicMaterial({
|
|
426
|
+
map: p,
|
|
412
427
|
transparent: !0,
|
|
413
428
|
opacity: 1,
|
|
414
429
|
depthTest: !1,
|
|
415
430
|
blending: l.AdditiveBlending
|
|
416
|
-
}),
|
|
417
|
-
for (let
|
|
418
|
-
const
|
|
419
|
-
|
|
431
|
+
}), d = new l.PlaneGeometry(200, 200), v = 50;
|
|
432
|
+
for (let u = 0; u < v; u++) {
|
|
433
|
+
const x = new l.Mesh(d, g.clone());
|
|
434
|
+
x.visible = !1, this._sceneMouse.add(x), this._mouseObjects.push({ mesh: x, active: !1 });
|
|
420
435
|
}
|
|
421
436
|
this._updateBrushScale(), this._ref.addEventListener("mousemove", this._onMouseMove.bind(this));
|
|
422
437
|
}
|
|
423
438
|
_onMouseMove(e) {
|
|
424
439
|
if (!this._ref || !this._sceneMouse)
|
|
425
440
|
return;
|
|
426
|
-
const
|
|
427
|
-
this.
|
|
428
|
-
|
|
429
|
-
|
|
441
|
+
const s = this._ref.getBoundingClientRect(), t = this._ref.width, f = this._ref.height;
|
|
442
|
+
this._pendingMousePosition = {
|
|
443
|
+
x: e.clientX - s.left - t / 2,
|
|
444
|
+
y: -(e.clientY - s.top - f / 2)
|
|
445
|
+
}, this._mouseUpdateScheduled || (this._mouseUpdateScheduled = !0, requestAnimationFrame(() => {
|
|
446
|
+
if (this._mouseUpdateScheduled = !1, !this._pendingMousePosition)
|
|
447
|
+
return;
|
|
448
|
+
this._mouse.x = this._pendingMousePosition.x, this._mouse.y = this._pendingMousePosition.y;
|
|
449
|
+
const c = this._mouseObjects[this._currentBrush];
|
|
450
|
+
c.mesh.scale.set(this._mouseBrushBaseScale, this._mouseBrushBaseScale, 1), c.active = !0, c.mesh.visible = !0, c.mesh.position.set(this._mouse.x, this._mouse.y, 0), c.mesh.rotation.z = Math.random() * Math.PI * 2, c.mesh.material instanceof l.MeshBasicMaterial && (c.mesh.material.opacity = 1), this._currentBrush = (this._currentBrush + 1) % this._mouseObjects.length, this._pendingMousePosition = null;
|
|
451
|
+
}));
|
|
430
452
|
}
|
|
431
453
|
_createProceduralTexture() {
|
|
432
|
-
const
|
|
433
|
-
|
|
434
|
-
const t =
|
|
454
|
+
const s = document.createElement("canvas");
|
|
455
|
+
s.width = 1024, s.height = 1024;
|
|
456
|
+
const t = s.getContext("2d", { willReadFrequently: !0 });
|
|
435
457
|
if (!t)
|
|
436
458
|
return new l.Texture();
|
|
437
459
|
let f = this._textureSeed;
|
|
438
|
-
const
|
|
439
|
-
function
|
|
460
|
+
const c = this._textureSeed;
|
|
461
|
+
function o() {
|
|
440
462
|
const a = Math.sin(f++) * 1e4;
|
|
441
463
|
return a - Math.floor(a);
|
|
442
464
|
}
|
|
443
|
-
const
|
|
444
|
-
f =
|
|
445
|
-
},
|
|
446
|
-
if (
|
|
465
|
+
const p = (a) => {
|
|
466
|
+
f = c + a;
|
|
467
|
+
}, g = this._colors.filter((a) => a.enabled).map((a) => a.color);
|
|
468
|
+
if (g.length === 0)
|
|
447
469
|
return new l.Texture();
|
|
448
|
-
function
|
|
470
|
+
function d(a) {
|
|
449
471
|
const n = parseInt(a.replace("#", ""), 16);
|
|
450
472
|
return {
|
|
451
473
|
r: n >> 16 & 255,
|
|
@@ -453,90 +475,99 @@ class ze {
|
|
|
453
475
|
b: n & 255
|
|
454
476
|
};
|
|
455
477
|
}
|
|
456
|
-
function
|
|
478
|
+
function v(a, n, h) {
|
|
457
479
|
return "#" + ((1 << 24) + (Math.round(a) << 16) + (Math.round(n) << 8) + Math.round(h)).toString(16).slice(1);
|
|
458
480
|
}
|
|
459
|
-
const
|
|
460
|
-
const a =
|
|
461
|
-
return
|
|
462
|
-
},
|
|
463
|
-
t.fillStyle =
|
|
464
|
-
const
|
|
465
|
-
|
|
481
|
+
const u = () => {
|
|
482
|
+
const a = g[Math.floor(o() * g.length)], n = g[Math.floor(o() * g.length)], h = o() * this._textureColorBlending, _ = d(a), S = d(n), B = _.r + (S.r - _.r) * h, N = _.g + (S.g - _.g) * h, V = _.b + (S.b - _.b) * h;
|
|
483
|
+
return v(B, N, V);
|
|
484
|
+
}, x = this._proceduralBackgroundColor || "#000000";
|
|
485
|
+
t.fillStyle = x, t.fillRect(0, 0, 1024, 1024);
|
|
486
|
+
const O = t.createLinearGradient(0, 0, 0, 1024);
|
|
487
|
+
O.addColorStop(0, u()), O.addColorStop(1, u()), t.fillStyle = O, t.fillRect(0, 0, 1024, 1024);
|
|
466
488
|
for (let a = 0; a < this._textureShapeTriangles; a++) {
|
|
467
|
-
t.fillStyle =
|
|
468
|
-
const n =
|
|
469
|
-
t.moveTo(n, h), t.lineTo(n + (
|
|
489
|
+
t.fillStyle = u(), t.beginPath();
|
|
490
|
+
const n = o() * 1024, h = o() * 1024, _ = 100 + o() * 300;
|
|
491
|
+
t.moveTo(n, h), t.lineTo(n + (o() - 0.5) * _, h + (o() - 0.5) * _), t.lineTo(n + (o() - 0.5) * _, h + (o() - 0.5) * _), t.fill();
|
|
470
492
|
}
|
|
471
493
|
for (let a = 0; a < this._textureShapeCircles; a++) {
|
|
472
|
-
t.strokeStyle =
|
|
473
|
-
const n =
|
|
494
|
+
t.strokeStyle = u(), t.lineWidth = 10 + o() * 50, t.beginPath();
|
|
495
|
+
const n = o() * 1024, h = o() * 1024, _ = 50 + o() * 150;
|
|
474
496
|
t.arc(n, h, _, 0, Math.PI * 2), t.stroke();
|
|
475
497
|
}
|
|
476
498
|
for (let a = 0; a < this._textureShapeBars; a++)
|
|
477
|
-
t.fillStyle =
|
|
499
|
+
t.fillStyle = u(), t.save(), t.translate(o() * 1024, o() * 1024), t.rotate(o() * Math.PI), t.fillRect(-150, -25, 300, 50), t.restore();
|
|
478
500
|
t.lineWidth = 15, t.lineCap = "round";
|
|
479
501
|
for (let a = 0; a < this._textureShapeSquiggles; a++) {
|
|
480
|
-
t.strokeStyle =
|
|
481
|
-
let n =
|
|
502
|
+
t.strokeStyle = u(), t.beginPath();
|
|
503
|
+
let n = o() * 1024, h = o() * 1024;
|
|
482
504
|
t.moveTo(n, h);
|
|
483
505
|
for (let _ = 0; _ < 4; _++)
|
|
484
506
|
t.bezierCurveTo(
|
|
485
|
-
n + (
|
|
486
|
-
h + (
|
|
487
|
-
n + (
|
|
488
|
-
h + (
|
|
489
|
-
n + (
|
|
490
|
-
h + (
|
|
491
|
-
), n += (
|
|
507
|
+
n + (o() - 0.5) * 300,
|
|
508
|
+
h + (o() - 0.5) * 300,
|
|
509
|
+
n + (o() - 0.5) * 300,
|
|
510
|
+
h + (o() - 0.5) * 300,
|
|
511
|
+
n + (o() - 0.5) * 300,
|
|
512
|
+
h + (o() - 0.5) * 300
|
|
513
|
+
), n += (o() - 0.5) * 300, h += (o() - 0.5) * 300;
|
|
492
514
|
t.stroke();
|
|
493
515
|
}
|
|
494
|
-
|
|
516
|
+
p(5e4);
|
|
495
517
|
const M = document.createElement("canvas");
|
|
496
518
|
M.width = 1024, M.height = 1024;
|
|
497
|
-
const
|
|
498
|
-
if (!
|
|
519
|
+
const z = M.getContext("2d", { willReadFrequently: !0 });
|
|
520
|
+
if (!z)
|
|
499
521
|
return new l.Texture();
|
|
500
|
-
|
|
501
|
-
let
|
|
502
|
-
const
|
|
503
|
-
for (;
|
|
504
|
-
if (
|
|
505
|
-
const n = this._textureVoidWidthMin +
|
|
506
|
-
|
|
522
|
+
z.fillStyle = x, z.fillRect(0, 0, 1024, 1024);
|
|
523
|
+
let y = 0;
|
|
524
|
+
const F = [];
|
|
525
|
+
for (; y < 1024; )
|
|
526
|
+
if (o() < this._textureVoidLikelihood) {
|
|
527
|
+
const n = this._textureVoidWidthMin + o() * (this._textureVoidWidthMax - this._textureVoidWidthMin);
|
|
528
|
+
F.push({ type: "void", x: y, width: n }), y += n;
|
|
507
529
|
} else {
|
|
508
|
-
const n = 50 +
|
|
509
|
-
|
|
530
|
+
const n = 50 + o() * 200;
|
|
531
|
+
F.push({ type: "matter", x: y, width: n }), y += n;
|
|
510
532
|
}
|
|
511
|
-
for (const a of
|
|
533
|
+
for (const a of F)
|
|
512
534
|
if (a.type === "matter") {
|
|
513
535
|
const n = a.x, h = Math.min(a.x + a.width, 1024);
|
|
514
536
|
let _ = n;
|
|
515
537
|
for (; _ < h; ) {
|
|
516
|
-
const
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
538
|
+
const S = (2 + o() * 20) / this._textureBandDensity, B = Math.floor(o() * 1024);
|
|
539
|
+
z.drawImage(
|
|
540
|
+
s,
|
|
541
|
+
B,
|
|
520
542
|
0,
|
|
521
|
-
|
|
543
|
+
S,
|
|
522
544
|
1024,
|
|
523
545
|
_,
|
|
524
546
|
0,
|
|
525
|
-
|
|
547
|
+
S,
|
|
526
548
|
1024
|
|
527
|
-
), _ +=
|
|
549
|
+
), _ += S;
|
|
528
550
|
}
|
|
529
551
|
}
|
|
530
|
-
const
|
|
531
|
-
return
|
|
552
|
+
const C = new l.CanvasTexture(M);
|
|
553
|
+
return C.minFilter = l.LinearMipmapLinearFilter, C.magFilter = l.LinearFilter, C.wrapS = l.RepeatWrapping, C.wrapT = l.RepeatWrapping, C.anisotropy = 16, C.needsUpdate = !0, C;
|
|
532
554
|
}
|
|
533
555
|
}
|
|
534
|
-
function
|
|
535
|
-
const
|
|
536
|
-
|
|
556
|
+
function K(r, e, s) {
|
|
557
|
+
const c = e * s / 1e6 * U * D / 1.5, o = e / s, p = Math.sqrt(c * o), g = c / p;
|
|
558
|
+
let d = -U / 2, v = Math.min((d + p) / 1.5, U / 2), u = D / 4, x = Math.max((u - g) / 2, -D / 4);
|
|
559
|
+
if (o < 1) {
|
|
560
|
+
const z = o;
|
|
561
|
+
d = d * z, v = v * z;
|
|
562
|
+
const y = 1.05;
|
|
563
|
+
d = d * y, v = v * y, u = u * y, x = x * y;
|
|
564
|
+
}
|
|
565
|
+
const O = -100, M = 1e3;
|
|
566
|
+
r instanceof l.OrthographicCamera ? (r.left = d, r.right = v, r.top = u, r.bottom = x, r.near = O, r.far = M, r.updateProjectionMatrix()) : r instanceof l.PerspectiveCamera && (r.aspect = e / s, r.updateProjectionMatrix());
|
|
537
567
|
}
|
|
538
|
-
|
|
539
|
-
|
|
568
|
+
let R = null, A = null;
|
|
569
|
+
function Ce() {
|
|
570
|
+
return R || (R = `
|
|
540
571
|
void main() {
|
|
541
572
|
vUv = uv;
|
|
542
573
|
|
|
@@ -613,10 +644,10 @@ void main() {
|
|
|
613
644
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0);
|
|
614
645
|
v_new_position = gl_Position;
|
|
615
646
|
}
|
|
616
|
-
|
|
647
|
+
`, R);
|
|
617
648
|
}
|
|
618
|
-
function
|
|
619
|
-
return `
|
|
649
|
+
function Me() {
|
|
650
|
+
return A || (A = `
|
|
620
651
|
float random(vec2 p) {
|
|
621
652
|
return fract(sin(dot(p, vec2(12.9898,78.233))) * 43758.5453);
|
|
622
653
|
}
|
|
@@ -698,9 +729,10 @@ void main() {
|
|
|
698
729
|
|
|
699
730
|
gl_FragColor = vec4(color, 1.0);
|
|
700
731
|
}
|
|
701
|
-
|
|
732
|
+
`, A);
|
|
702
733
|
}
|
|
703
|
-
|
|
734
|
+
let k = null;
|
|
735
|
+
const H = () => k || (k = `
|
|
704
736
|
precision highp float;
|
|
705
737
|
|
|
706
738
|
struct Color {
|
|
@@ -764,7 +796,9 @@ varying vec4 v_new_position;
|
|
|
764
796
|
varying vec3 v_color;
|
|
765
797
|
varying float v_displacement_amount;
|
|
766
798
|
|
|
767
|
-
`,
|
|
799
|
+
`, k);
|
|
800
|
+
let I = null;
|
|
801
|
+
const Y = () => I || (I = `
|
|
768
802
|
|
|
769
803
|
// 1. REPLACEMENT PERMUTE:
|
|
770
804
|
// Uses a hash function (fract/sin) instead of a modular lookup table.
|
|
@@ -917,7 +951,9 @@ float cnoise(vec3 P)
|
|
|
917
951
|
float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
|
|
918
952
|
return 2.2 * n_xyz;
|
|
919
953
|
}
|
|
920
|
-
`,
|
|
954
|
+
`, I);
|
|
955
|
+
let W = null;
|
|
956
|
+
const Z = () => W || (W = `
|
|
921
957
|
|
|
922
958
|
vec3 saturation(vec3 rgb, float adjustment) {
|
|
923
959
|
const vec3 W = vec3(0.2125, 0.7154, 0.0721);
|
|
@@ -960,36 +996,36 @@ vec3 hsv2rgb(vec3 c)
|
|
|
960
996
|
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
|
|
961
997
|
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
|
962
998
|
}
|
|
963
|
-
`,
|
|
964
|
-
r.id =
|
|
965
|
-
},
|
|
999
|
+
`, W), J = (r) => {
|
|
1000
|
+
r.id = Q, r.href = "https://neat.firecms.co", r.target = "_blank", r.style.position = "absolute", r.style.display = "block", r.style.bottom = "0", r.style.right = "0", r.style.padding = "10px", r.style.color = "#dcdcdc", r.style.opacity = "0.8", r.style.fontFamily = "sans-serif", r.style.fontSize = "16px", r.style.fontWeight = "bold", r.style.textDecoration = "none", r.style.zIndex = "10000", r.innerHTML = "NEAT";
|
|
1001
|
+
}, Pe = (r) => {
|
|
966
1002
|
const e = r.parentElement?.getElementsByTagName("a");
|
|
967
1003
|
if (e) {
|
|
968
1004
|
for (let t = 0; t < e.length; t++)
|
|
969
|
-
if (e[t].id ===
|
|
970
|
-
return
|
|
1005
|
+
if (e[t].id === Q)
|
|
1006
|
+
return J(e[t]), e[t];
|
|
971
1007
|
}
|
|
972
|
-
const
|
|
973
|
-
return
|
|
1008
|
+
const s = document.createElement("a");
|
|
1009
|
+
return J(s), r.parentElement?.appendChild(s), s;
|
|
974
1010
|
};
|
|
975
|
-
function
|
|
976
|
-
const r = new Date(), e = r.getMinutes(),
|
|
977
|
-
return e * 60 +
|
|
1011
|
+
function Oe() {
|
|
1012
|
+
const r = new Date(), e = r.getMinutes(), s = r.getSeconds();
|
|
1013
|
+
return e * 60 + s;
|
|
978
1014
|
}
|
|
979
|
-
function
|
|
1015
|
+
function Te(r = 6) {
|
|
980
1016
|
const e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
981
|
-
let
|
|
1017
|
+
let s = "";
|
|
982
1018
|
for (let t = 0; t < r; t++) {
|
|
983
1019
|
const f = Math.floor(Math.random() * e.length);
|
|
984
|
-
|
|
1020
|
+
s += e.charAt(f);
|
|
985
1021
|
}
|
|
986
|
-
return
|
|
1022
|
+
return s;
|
|
987
1023
|
}
|
|
988
|
-
function
|
|
989
|
-
const
|
|
990
|
-
|
|
1024
|
+
function Fe(r, e) {
|
|
1025
|
+
const s = document.createElement("a");
|
|
1026
|
+
s.download = e, s.href = r, document.body.appendChild(s), s.click(), document.body.removeChild(s);
|
|
991
1027
|
}
|
|
992
1028
|
export {
|
|
993
|
-
|
|
1029
|
+
Be as NeatGradient
|
|
994
1030
|
};
|
|
995
1031
|
//# sourceMappingURL=index.es.js.map
|