@d3p1/img2pxl 1.21.2 → 1.21.3
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/img2pxl.js +46 -39
- package/dist/img2pxl.js.map +1 -1
- package/dist/img2pxl.umd.cjs +8 -2
- package/dist/img2pxl.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/img2pxl.js
CHANGED
|
@@ -84,7 +84,7 @@ class Ee {
|
|
|
84
84
|
* @param {number} displacementFrequency
|
|
85
85
|
* @param {number} displacementAmplitude
|
|
86
86
|
*/
|
|
87
|
-
constructor(e, t, s, r,
|
|
87
|
+
constructor(e, t, s, r, m, h = 0.1, c = 5, u = 5, D = 50) {
|
|
88
88
|
a(this, X);
|
|
89
89
|
/**
|
|
90
90
|
* @type {Image}
|
|
@@ -102,7 +102,7 @@ class Ee {
|
|
|
102
102
|
* @type {Pane}
|
|
103
103
|
*/
|
|
104
104
|
a(this, x);
|
|
105
|
-
l(this, p, e), l(this, R, t), l(this, b, s), l(this, x, r), n(this, X, qe).call(this,
|
|
105
|
+
l(this, p, e), l(this, R, t), l(this, b, s), l(this, x, r), n(this, X, qe).call(this, m, h, c, u, D), n(this, X, ve).call(this);
|
|
106
106
|
}
|
|
107
107
|
/**
|
|
108
108
|
* Update
|
|
@@ -184,8 +184,8 @@ p = new WeakMap(), R = new WeakMap(), b = new WeakMap(), x = new WeakMap(), X =
|
|
|
184
184
|
* @param {number} displacementAmplitude
|
|
185
185
|
* @returns {void}
|
|
186
186
|
*/
|
|
187
|
-
qe = function(e, t, s, r,
|
|
188
|
-
i(this, b).scene.add(i(this, p).points), n(this, X, ce).call(this), n(this, X, he).call(this, e, t, s, r,
|
|
187
|
+
qe = function(e, t, s, r, m) {
|
|
188
|
+
i(this, b).scene.add(i(this, p).points), n(this, X, ce).call(this), n(this, X, he).call(this, e, t, s, r, m);
|
|
189
189
|
}, /**
|
|
190
190
|
* Init pointer
|
|
191
191
|
*
|
|
@@ -211,13 +211,13 @@ ve = function() {
|
|
|
211
211
|
* uniforms will be undefined until first render of the scene
|
|
212
212
|
* {@link https://github.com/mrdoob/three.js/pull/10960}
|
|
213
213
|
*/
|
|
214
|
-
he = function(e, t, s, r,
|
|
214
|
+
he = function(e, t, s, r, m) {
|
|
215
215
|
const c = new d.TextureLoader().load(e);
|
|
216
216
|
c.wrapS = d.RepeatWrapping, i(this, p).points.material.onBeforeCompile = (u) => {
|
|
217
217
|
u.uniforms.uTime = new d.Uniform(0), u.uniforms.uDisFrequency = new d.Uniform(
|
|
218
218
|
r
|
|
219
219
|
), u.uniforms.uDisAmplitude = new d.Uniform(
|
|
220
|
-
|
|
220
|
+
m
|
|
221
221
|
), u.uniforms.uDisTexture = new d.Uniform(
|
|
222
222
|
i(this, R).canvas.texture
|
|
223
223
|
), u.uniforms.uNoiseFrequency = new d.Uniform(t), u.uniforms.uNoiseAmplitude = new d.Uniform(s), u.uniforms.uNoiseTexture = new d.Uniform(c), u.vertexShader = u.vertexShader.replace(
|
|
@@ -342,13 +342,13 @@ fe = function() {
|
|
|
342
342
|
* @link https://discourse.threejs.org/t/mapping-orthographiccamera-world-units-to-pixels/10142
|
|
343
343
|
*/
|
|
344
344
|
Ue = function() {
|
|
345
|
-
const e = -this.renderer.domElement.width / 2, t = this.renderer.domElement.width / 2, s = this.renderer.domElement.height / 2, r = -this.renderer.domElement.height / 2,
|
|
345
|
+
const e = -this.renderer.domElement.width / 2, t = this.renderer.domElement.width / 2, s = this.renderer.domElement.height / 2, r = -this.renderer.domElement.height / 2, m = 0.1, h = 1;
|
|
346
346
|
this.camera = new d.OrthographicCamera(
|
|
347
347
|
e,
|
|
348
348
|
t,
|
|
349
349
|
s,
|
|
350
350
|
r,
|
|
351
|
-
|
|
351
|
+
m,
|
|
352
352
|
h
|
|
353
353
|
), this.scene.add(this.camera), this.camera.position.z = h - 0.1;
|
|
354
354
|
}, /**
|
|
@@ -390,9 +390,15 @@ void main() {
|
|
|
390
390
|
gl_PointSize = uPointSize;
|
|
391
391
|
|
|
392
392
|
vColor = texture(uImageTexture, uv);
|
|
393
|
-
}`, Ge = `
|
|
393
|
+
}`, Ge = `uniform float uAlphaTest;
|
|
394
|
+
|
|
395
|
+
varying vec4 vColor;
|
|
394
396
|
|
|
395
397
|
void main() {
|
|
398
|
+
if (vColor.a < uAlphaTest) {
|
|
399
|
+
discard;
|
|
400
|
+
}
|
|
401
|
+
|
|
396
402
|
gl_FragColor = vColor;
|
|
397
403
|
|
|
398
404
|
#include <tonemapping_fragment>
|
|
@@ -410,7 +416,7 @@ let Be = (me = class {
|
|
|
410
416
|
* @param {number} pointSize
|
|
411
417
|
* @param {number} alphaTest
|
|
412
418
|
*/
|
|
413
|
-
constructor(e, t, s, r,
|
|
419
|
+
constructor(e, t, s, r, m, h = 1, c = 0.1) {
|
|
414
420
|
a(this, F);
|
|
415
421
|
/**
|
|
416
422
|
* @type {THREE.Points}
|
|
@@ -428,7 +434,7 @@ let Be = (me = class {
|
|
|
428
434
|
* @type {Pane}
|
|
429
435
|
*/
|
|
430
436
|
a(this, L);
|
|
431
|
-
l(this, P, e), l(this, L, t), n(this, F, be).call(this, s, r,
|
|
437
|
+
l(this, P, e), l(this, L, t), n(this, F, be).call(this, s, r, m, h, c);
|
|
432
438
|
}
|
|
433
439
|
/**
|
|
434
440
|
* Enable debug mode
|
|
@@ -477,7 +483,7 @@ let Be = (me = class {
|
|
|
477
483
|
* @param {number} alphaTest
|
|
478
484
|
* @returns {void}
|
|
479
485
|
*/
|
|
480
|
-
be = function(e, t, s, r,
|
|
486
|
+
be = function(e, t, s, r, m) {
|
|
481
487
|
const h = new d.TextureLoader();
|
|
482
488
|
l(this, N, h.load(e));
|
|
483
489
|
const c = n(this, F, re).call(this, t, s), u = new d.ShaderMaterial({
|
|
@@ -485,11 +491,12 @@ be = function(e, t, s, r, q) {
|
|
|
485
491
|
fragmentShader: Ge,
|
|
486
492
|
uniforms: {
|
|
487
493
|
uImageTexture: new d.Uniform(i(this, N)),
|
|
488
|
-
uPointSize: new d.Uniform(r)
|
|
494
|
+
uPointSize: new d.Uniform(r),
|
|
495
|
+
uAlphaTest: new d.Uniform(m)
|
|
489
496
|
},
|
|
490
497
|
transparent: !0,
|
|
491
498
|
depthWrite: !1,
|
|
492
|
-
alphaTest:
|
|
499
|
+
alphaTest: m
|
|
493
500
|
});
|
|
494
501
|
this.points = new d.Points(c, u);
|
|
495
502
|
}, /**
|
|
@@ -675,7 +682,7 @@ class Ae {
|
|
|
675
682
|
* @param {number} pointerImageSize
|
|
676
683
|
* @param {number} pointerTrailingFactor
|
|
677
684
|
*/
|
|
678
|
-
constructor(e, t, s, r,
|
|
685
|
+
constructor(e, t, s, r, m = 0.1, h = 0.05) {
|
|
679
686
|
a(this, U);
|
|
680
687
|
/**
|
|
681
688
|
* @type {Pane}
|
|
@@ -715,7 +722,7 @@ class Ae {
|
|
|
715
722
|
* pixels' displacement
|
|
716
723
|
*/
|
|
717
724
|
a(this, j);
|
|
718
|
-
l(this, M, e), l(this, j, h), n(this, U, ze).call(this, t, s), n(this, U, we).call(this, r,
|
|
725
|
+
l(this, M, e), l(this, j, h), n(this, U, ze).call(this, t, s), n(this, U, we).call(this, r, m);
|
|
719
726
|
}
|
|
720
727
|
/**
|
|
721
728
|
* Update
|
|
@@ -967,7 +974,7 @@ ge = function(e) {
|
|
|
967
974
|
);
|
|
968
975
|
l(this, Q, e);
|
|
969
976
|
};
|
|
970
|
-
var z,
|
|
977
|
+
var z, q, w, S, g, G, I, C, V, oe, le, xe, de, Ne, Le, Te, Oe;
|
|
971
978
|
class ni {
|
|
972
979
|
/**
|
|
973
980
|
* Constructor
|
|
@@ -1028,7 +1035,7 @@ class ni {
|
|
|
1028
1035
|
/**
|
|
1029
1036
|
* @type {ImageManager}
|
|
1030
1037
|
*/
|
|
1031
|
-
a(this,
|
|
1038
|
+
a(this, q);
|
|
1032
1039
|
/**
|
|
1033
1040
|
* @type {Timer}
|
|
1034
1041
|
*/
|
|
@@ -1088,7 +1095,7 @@ class ni {
|
|
|
1088
1095
|
* @type {Function}
|
|
1089
1096
|
*/
|
|
1090
1097
|
a(this, C);
|
|
1091
|
-
l(this, S, e), l(this, g, e.isDebugging ?? !1), l(this,
|
|
1098
|
+
l(this, S, e), l(this, g, e.isDebugging ?? !1), l(this, q, new ei(e.images)), n(this, V, oe).call(this);
|
|
1092
1099
|
}
|
|
1093
1100
|
/**
|
|
1094
1101
|
* Debug
|
|
@@ -1107,17 +1114,17 @@ class ni {
|
|
|
1107
1114
|
cancelAnimationFrame(i(this, G)), window.removeEventListener("keydown", i(this, I)), window.removeEventListener("resize", i(this, C)), i(this, w).dispose(), i(this, z).dispose(), this.rendererManager.dispose(), this.debugManager.dispose(), this.debugManager.element.remove();
|
|
1108
1115
|
}
|
|
1109
1116
|
}
|
|
1110
|
-
z = new WeakMap(),
|
|
1117
|
+
z = new WeakMap(), q = new WeakMap(), w = new WeakMap(), S = new WeakMap(), g = new WeakMap(), G = new WeakMap(), I = new WeakMap(), C = new WeakMap(), V = new WeakSet(), /**
|
|
1111
1118
|
* Init
|
|
1112
1119
|
*
|
|
1113
1120
|
* @returns {void}
|
|
1114
1121
|
*/
|
|
1115
1122
|
oe = function() {
|
|
1116
1123
|
this.rendererManager = new Ye(
|
|
1117
|
-
i(this,
|
|
1118
|
-
i(this,
|
|
1124
|
+
i(this, q).currentImage.width,
|
|
1125
|
+
i(this, q).currentImage.height
|
|
1119
1126
|
), l(this, w, new Je()), n(this, V, Te).call(this), n(this, V, Le).call(this), i(this, S).containerSelector && n(this, V, Oe).call(this, i(this, S).containerSelector), l(this, I, n(this, V, xe).bind(this)), window.addEventListener("keydown", i(this, I)), i(this, g) ? n(this, V, de).call(this) : n(this, V, Ne).call(this), l(this, C, () => {
|
|
1120
|
-
i(this,
|
|
1127
|
+
i(this, q).update() && (this.dispose(), n(this, V, oe).call(this));
|
|
1121
1128
|
}), window.addEventListener("resize", i(this, C)), n(this, V, le).call(this);
|
|
1122
1129
|
}, /**
|
|
1123
1130
|
* Render
|
|
@@ -1148,7 +1155,7 @@ de = function() {
|
|
|
1148
1155
|
e.on("click", () => {
|
|
1149
1156
|
const t = this.debugManager.exportState();
|
|
1150
1157
|
if (t.children && t.children instanceof Array) {
|
|
1151
|
-
const s = t.children[0], r = s.children[0].binding.value,
|
|
1158
|
+
const s = t.children[0], r = s.children[0].binding.value, m = s.children[1].binding.value, h = t.children[2], c = h.children[0].binding.value, u = h.children[1].binding.value, B = t.children[3].children[0].binding.value, E = t.children[4], H = E.children[0].binding.value, A = E.children[1].binding.value, Y = t.children[5], _ = Y.children[0].binding.value, $ = Y.children[1].binding.value, ee = `{
|
|
1152
1159
|
images: {
|
|
1153
1160
|
0: {
|
|
1154
1161
|
src: <image-src>,
|
|
@@ -1178,7 +1185,7 @@ de = function() {
|
|
|
1178
1185
|
pointer: {
|
|
1179
1186
|
size: ${r},
|
|
1180
1187
|
trailing: {
|
|
1181
|
-
factor: ${
|
|
1188
|
+
factor: ${m}
|
|
1182
1189
|
}
|
|
1183
1190
|
}
|
|
1184
1191
|
}`;
|
|
@@ -1202,35 +1209,35 @@ Ne = function() {
|
|
|
1202
1209
|
* @returns {void}
|
|
1203
1210
|
*/
|
|
1204
1211
|
Le = function() {
|
|
1205
|
-
var e, t, s, r,
|
|
1212
|
+
var e, t, s, r, m, h, c, u, D, B, E, H, A, Y, _, $, ee, pe;
|
|
1206
1213
|
l(this, z, new Ee(
|
|
1207
1214
|
new Be(
|
|
1208
1215
|
this.rendererManager,
|
|
1209
1216
|
this.debugManager,
|
|
1210
|
-
i(this,
|
|
1211
|
-
i(this,
|
|
1212
|
-
i(this,
|
|
1213
|
-
((e = i(this,
|
|
1214
|
-
((t = i(this,
|
|
1217
|
+
i(this, q).currentImage.src,
|
|
1218
|
+
i(this, q).currentImage.resolution.width,
|
|
1219
|
+
i(this, q).currentImage.resolution.height,
|
|
1220
|
+
((e = i(this, q).currentImage.pixel) == null ? void 0 : e.size) ?? 1,
|
|
1221
|
+
((t = i(this, q).currentImage.pixel) == null ? void 0 : t.alphaTest) ?? 0.1
|
|
1215
1222
|
),
|
|
1216
1223
|
new He(
|
|
1217
1224
|
this.rendererManager,
|
|
1218
1225
|
new Ae(
|
|
1219
1226
|
this.debugManager,
|
|
1220
|
-
i(this,
|
|
1221
|
-
i(this,
|
|
1227
|
+
i(this, q).currentImage.resolution.width,
|
|
1228
|
+
i(this, q).currentImage.resolution.height,
|
|
1222
1229
|
((s = i(this, S).pointer) == null ? void 0 : s.src) ?? _e,
|
|
1223
1230
|
((r = i(this, S).pointer) == null ? void 0 : r.size) ?? 0.15,
|
|
1224
|
-
((h = (
|
|
1231
|
+
((h = (m = i(this, S).pointer) == null ? void 0 : m.trailing) == null ? void 0 : h.factor) ?? 0.01
|
|
1225
1232
|
)
|
|
1226
1233
|
),
|
|
1227
1234
|
this.rendererManager,
|
|
1228
1235
|
this.debugManager,
|
|
1229
|
-
((u = (c = i(this,
|
|
1230
|
-
((B = (D = i(this,
|
|
1231
|
-
((H = (E = i(this,
|
|
1232
|
-
((_ = (Y = (A = i(this,
|
|
1233
|
-
((pe = (ee = ($ = i(this,
|
|
1236
|
+
((u = (c = i(this, q).currentImage.motion) == null ? void 0 : c.noise) == null ? void 0 : u.src) ?? $e,
|
|
1237
|
+
((B = (D = i(this, q).currentImage.motion) == null ? void 0 : D.noise) == null ? void 0 : B.frequency) ?? 0.05,
|
|
1238
|
+
((H = (E = i(this, q).currentImage.motion) == null ? void 0 : E.noise) == null ? void 0 : H.amplitude) ?? 3,
|
|
1239
|
+
((_ = (Y = (A = i(this, q).currentImage.pixel) == null ? void 0 : A.motion) == null ? void 0 : Y.displacement) == null ? void 0 : _.frequency) ?? 5,
|
|
1240
|
+
((pe = (ee = ($ = i(this, q).currentImage.pixel) == null ? void 0 : $.motion) == null ? void 0 : ee.displacement) == null ? void 0 : pe.amplitude) ?? 4
|
|
1234
1241
|
));
|
|
1235
1242
|
}, /**
|
|
1236
1243
|
* Init debug manager
|