layershift 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -9
- package/dist/components/layershift.js +28 -28
- package/dist/npm/layershift.es.js +286 -289
- package/dist/types/components/layershift/global.d.ts +3 -1
- package/dist/types/components/layershift/layershift-element.d.ts +0 -1
- package/dist/types/components/layershift/layershift-element.d.ts.map +1 -1
- package/dist/types/components/layershift/lifecycle.d.ts +1 -1
- package/dist/types/components/layershift/portal-element.d.ts +0 -1
- package/dist/types/components/layershift/portal-element.d.ts.map +1 -1
- package/dist/types/components/layershift/types.d.ts +6 -2
- package/dist/types/components/layershift/types.d.ts.map +1 -1
- package/dist/types/depth/precomputed-depth.d.ts +4 -8
- package/dist/types/depth/precomputed-depth.d.ts.map +1 -1
- package/dist/types/shared/filter-config.d.ts +0 -1
- package/dist/types/shared/filter-config.d.ts.map +1 -1
- package/package.json +11 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
class Vt {
|
|
2
2
|
constructor(t) {
|
|
3
3
|
this.depthData = t;
|
|
4
|
-
const e = t.
|
|
4
|
+
const e = t.width * t.height;
|
|
5
5
|
this.uint8Output = new Uint8Array(e);
|
|
6
6
|
}
|
|
7
7
|
uint8Output;
|
|
@@ -10,7 +10,7 @@ class Vt {
|
|
|
10
10
|
lastNextFrameIndex = -1;
|
|
11
11
|
lastLerpFactor = -1;
|
|
12
12
|
sample(t) {
|
|
13
|
-
const e =
|
|
13
|
+
const e = ne(t * this.depthData.fps, 0, this.depthData.frameCount - 1), n = Math.floor(e), i = Math.min(n + 1, this.depthData.frameCount - 1), r = e - n, o = n !== this.lastFrameIndex || i !== this.lastNextFrameIndex, l = Math.abs(r - this.lastLerpFactor) > 1e-3;
|
|
14
14
|
if (!o && !l)
|
|
15
15
|
return this.uint8Output;
|
|
16
16
|
this.lastFrameIndex = n, this.lastNextFrameIndex = i, this.lastLerpFactor = r;
|
|
@@ -20,27 +20,11 @@ class Vt {
|
|
|
20
20
|
return this.uint8Output;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
async function kt(s, t, e) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
ee(s)
|
|
27
|
-
]);
|
|
28
|
-
return ne(i, n);
|
|
23
|
+
async function kt(s, t = 512, e = 512, n = 5, i) {
|
|
24
|
+
const r = await te(s);
|
|
25
|
+
return ee(r, t, e, n);
|
|
29
26
|
}
|
|
30
|
-
async function te(s) {
|
|
31
|
-
const t = await fetch(s);
|
|
32
|
-
if (!t.ok)
|
|
33
|
-
throw new Error(`Failed to fetch depth metadata (${t.status} ${t.statusText}).`);
|
|
34
|
-
const e = await t.json();
|
|
35
|
-
return ie(e), {
|
|
36
|
-
frameCount: e.frameCount,
|
|
37
|
-
fps: e.fps,
|
|
38
|
-
width: e.width,
|
|
39
|
-
height: e.height,
|
|
40
|
-
sourceFps: e.sourceFps
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
async function ee(s, t) {
|
|
27
|
+
async function te(s, t) {
|
|
44
28
|
const e = await fetch(s);
|
|
45
29
|
if (!e.ok)
|
|
46
30
|
throw new Error(`Failed to fetch depth data (${e.status} ${e.statusText}).`);
|
|
@@ -63,42 +47,35 @@ async function ee(s, t) {
|
|
|
63
47
|
l.set(h, a), a += h.byteLength;
|
|
64
48
|
return l;
|
|
65
49
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (s.byteLength !==
|
|
50
|
+
function ee(s, t, e, n) {
|
|
51
|
+
const i = t * e;
|
|
52
|
+
if (i === 0)
|
|
53
|
+
throw new Error("Depth frame dimensions must be non-zero.");
|
|
54
|
+
if (s.byteLength % i !== 0)
|
|
71
55
|
throw new Error(
|
|
72
|
-
`Depth data byte length
|
|
56
|
+
`Depth data byte length (${s.byteLength}) is not evenly divisible by frame size (${i} = ${t}×${e}).`
|
|
73
57
|
);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
);
|
|
78
|
-
const o = s.subarray(4), l = new Array(n);
|
|
79
|
-
for (let a = 0; a < n; a += 1) {
|
|
80
|
-
const h = a * i;
|
|
81
|
-
l[a] = o.subarray(h, h + i);
|
|
58
|
+
const r = s.byteLength / i, o = new Array(r);
|
|
59
|
+
for (let l = 0; l < r; l += 1) {
|
|
60
|
+
const a = l * i;
|
|
61
|
+
o[l] = s.subarray(a, a + i);
|
|
82
62
|
}
|
|
83
|
-
return {
|
|
84
|
-
}
|
|
85
|
-
function ie(s) {
|
|
86
|
-
if (!s || typeof s.frameCount != "number" || typeof s.fps != "number" || typeof s.width != "number" || typeof s.height != "number" || typeof s.sourceFps != "number")
|
|
87
|
-
throw new Error("Depth metadata is malformed.");
|
|
88
|
-
if (!Number.isFinite(s.frameCount) || !Number.isFinite(s.fps) || !Number.isFinite(s.width) || !Number.isFinite(s.height) || !Number.isFinite(s.sourceFps) || s.frameCount <= 0 || s.fps <= 0 || s.width <= 0 || s.height <= 0 || s.sourceFps <= 0)
|
|
89
|
-
throw new Error("Depth metadata contains invalid numeric values.");
|
|
63
|
+
return { width: t, height: e, fps: n, frameCount: r, frames: o };
|
|
90
64
|
}
|
|
91
|
-
function
|
|
65
|
+
function X(s, t) {
|
|
92
66
|
const e = new Uint8Array(s * t);
|
|
93
67
|
return e.fill(128), {
|
|
94
|
-
|
|
68
|
+
width: s,
|
|
69
|
+
height: t,
|
|
70
|
+
fps: 1,
|
|
71
|
+
frameCount: 1,
|
|
95
72
|
frames: [e]
|
|
96
73
|
};
|
|
97
74
|
}
|
|
98
|
-
function
|
|
75
|
+
function ne(s, t, e) {
|
|
99
76
|
return Math.min(e, Math.max(t, s));
|
|
100
77
|
}
|
|
101
|
-
const
|
|
78
|
+
const ie = {
|
|
102
79
|
parallaxStrength: 0.05,
|
|
103
80
|
contrastLow: 0.05,
|
|
104
81
|
contrastHigh: 0.95,
|
|
@@ -108,11 +85,11 @@ const se = {
|
|
|
108
85
|
pomSteps: 16,
|
|
109
86
|
overscanPadding: 0.08
|
|
110
87
|
};
|
|
111
|
-
function
|
|
88
|
+
function re(s, t, e) {
|
|
112
89
|
const n = new Float32Array(256);
|
|
113
90
|
if (s.length === 0 || t <= 0 || e <= 0)
|
|
114
91
|
return Pt(n);
|
|
115
|
-
const i =
|
|
92
|
+
const i = oe(s.length), r = t * e;
|
|
116
93
|
let o = 0;
|
|
117
94
|
const l = new Uint32Array(256);
|
|
118
95
|
for (const m of i) {
|
|
@@ -139,24 +116,24 @@ function oe(s, t, e) {
|
|
|
139
116
|
const T = m / 255 - d;
|
|
140
117
|
y += n[m] * T * T;
|
|
141
118
|
}
|
|
142
|
-
const
|
|
119
|
+
const b = Math.sqrt(y), E = p - c, g = x - f, v = ae(n);
|
|
143
120
|
return {
|
|
144
121
|
mean: d,
|
|
145
|
-
stdDev:
|
|
122
|
+
stdDev: b,
|
|
146
123
|
p5: c,
|
|
147
124
|
p25: f,
|
|
148
125
|
median: u,
|
|
149
126
|
p75: x,
|
|
150
127
|
p95: p,
|
|
151
|
-
effectiveRange:
|
|
128
|
+
effectiveRange: E,
|
|
152
129
|
iqr: g,
|
|
153
130
|
bimodality: v,
|
|
154
131
|
histogram: n
|
|
155
132
|
};
|
|
156
133
|
}
|
|
157
|
-
function
|
|
134
|
+
function se(s) {
|
|
158
135
|
if (s.effectiveRange < 0.05 || s.stdDev < 0.02)
|
|
159
|
-
return { ...
|
|
136
|
+
return { ...ie };
|
|
160
137
|
const t = s.effectiveRange - 0.5, e = s.bimodality - 0.4, n = H(
|
|
161
138
|
0.05 - t * 0.03 + e * 0.01,
|
|
162
139
|
0.035,
|
|
@@ -173,7 +150,7 @@ function ae(s) {
|
|
|
173
150
|
overscanPadding: f
|
|
174
151
|
};
|
|
175
152
|
}
|
|
176
|
-
function
|
|
153
|
+
function oe(s) {
|
|
177
154
|
if (s <= 0) return [];
|
|
178
155
|
if (s === 1) return [0];
|
|
179
156
|
const t = s - 1, e = [
|
|
@@ -193,7 +170,7 @@ function nt(s, t) {
|
|
|
193
170
|
return e / 255;
|
|
194
171
|
return 1;
|
|
195
172
|
}
|
|
196
|
-
function
|
|
173
|
+
function ae(s) {
|
|
197
174
|
const t = new Float32Array(256);
|
|
198
175
|
for (let u = 0; u < 256; u += 1) {
|
|
199
176
|
let x = 0, p = 0;
|
|
@@ -268,7 +245,7 @@ function pt(s, t, e) {
|
|
|
268
245
|
n[i] = s.getUniformLocation(t, i);
|
|
269
246
|
return n;
|
|
270
247
|
}
|
|
271
|
-
const
|
|
248
|
+
const le = new Float32Array([
|
|
272
249
|
-1,
|
|
273
250
|
-1,
|
|
274
251
|
1,
|
|
@@ -283,7 +260,7 @@ function Ot(s, t) {
|
|
|
283
260
|
if (!e) throw new Error("Failed to create VAO.");
|
|
284
261
|
s.bindVertexArray(e);
|
|
285
262
|
const n = s.createBuffer();
|
|
286
|
-
s.bindBuffer(s.ARRAY_BUFFER, n), s.bufferData(s.ARRAY_BUFFER,
|
|
263
|
+
s.bindBuffer(s.ARRAY_BUFFER, n), s.bufferData(s.ARRAY_BUFFER, le, s.STATIC_DRAW);
|
|
287
264
|
const i = s.getAttribLocation(t, "aPosition");
|
|
288
265
|
return s.enableVertexAttribArray(i), s.vertexAttribPointer(i, 2, s.FLOAT, !1, 0, 0), s.bindVertexArray(null), e;
|
|
289
266
|
}
|
|
@@ -372,7 +349,7 @@ function Dt(s, t, e, n, i, r) {
|
|
|
372
349
|
};
|
|
373
350
|
return r.width > 0 && r.height > 0 && f.resize(s, r.width, r.height), f;
|
|
374
351
|
}
|
|
375
|
-
const
|
|
352
|
+
const ue = {
|
|
376
353
|
high: {
|
|
377
354
|
dprCap: 2,
|
|
378
355
|
depthMaxDim: 512,
|
|
@@ -395,7 +372,7 @@ const he = {
|
|
|
395
372
|
jfaDivisor: 4
|
|
396
373
|
}
|
|
397
374
|
};
|
|
398
|
-
function
|
|
375
|
+
function ce(s) {
|
|
399
376
|
let t = "unknown";
|
|
400
377
|
const e = s.getExtension("WEBGL_debug_renderer_info");
|
|
401
378
|
e && (t = s.getParameter(e.UNMASKED_RENDERER_WEBGL) || "unknown");
|
|
@@ -410,7 +387,7 @@ function fe(s) {
|
|
|
410
387
|
isMobile: a && h
|
|
411
388
|
};
|
|
412
389
|
}
|
|
413
|
-
const
|
|
390
|
+
const he = [
|
|
414
391
|
"mali-4",
|
|
415
392
|
"mali-t",
|
|
416
393
|
"adreno 3",
|
|
@@ -423,7 +400,7 @@ const de = [
|
|
|
423
400
|
"llvmpipe",
|
|
424
401
|
"swiftshader",
|
|
425
402
|
"software"
|
|
426
|
-
],
|
|
403
|
+
], fe = [
|
|
427
404
|
"nvidia",
|
|
428
405
|
"geforce",
|
|
429
406
|
"radeon rx",
|
|
@@ -435,14 +412,14 @@ const de = [
|
|
|
435
412
|
"mali-g7",
|
|
436
413
|
"mali-g6"
|
|
437
414
|
];
|
|
438
|
-
function
|
|
415
|
+
function de(s) {
|
|
439
416
|
let t = 0;
|
|
440
|
-
const e = s.gpuRenderer.toLowerCase(), n =
|
|
417
|
+
const e = s.gpuRenderer.toLowerCase(), n = he.some((r) => e.includes(r)), i = fe.some((r) => e.includes(r));
|
|
441
418
|
return n && (t -= 30), i && (t += 20), s.maxTextureSize >= 16384 ? t += 10 : s.maxTextureSize >= 8192 ? t += 5 : s.maxTextureSize <= 4096 && (t -= 15), s.hardwareConcurrency >= 8 ? t += 5 : s.hardwareConcurrency >= 4 ? t += 0 : s.hardwareConcurrency > 0 && s.hardwareConcurrency < 4 && (t -= 10), s.deviceMemory >= 8 ? t += 5 : s.deviceMemory >= 4 ? t += 0 : s.deviceMemory > 0 && s.deviceMemory < 4 && (t -= 15), s.isMobile && (t -= 10), t >= 0 ? "high" : t >= -25 ? "medium" : "low";
|
|
442
419
|
}
|
|
443
|
-
function
|
|
444
|
-
const e = t && t !== "auto" ? t :
|
|
445
|
-
return { tier: e, ...
|
|
420
|
+
function Xt(s, t) {
|
|
421
|
+
const e = t && t !== "auto" ? t : de(ce(s));
|
|
422
|
+
return { tier: e, ...ue[e] };
|
|
446
423
|
}
|
|
447
424
|
class gt {
|
|
448
425
|
static RESIZE_DEBOUNCE_MS = 100;
|
|
@@ -628,7 +605,7 @@ class gt {
|
|
|
628
605
|
l /= h, a /= h, this.uvOffset = [(1 - l) / 2, (1 - a) / 2], this.uvScale = [l, a], this.isCameraSource && (this.uvOffset[0] += this.uvScale[0], this.uvScale[0] = -this.uvScale[0]);
|
|
629
606
|
}
|
|
630
607
|
}
|
|
631
|
-
const
|
|
608
|
+
const me = `#version 300 es
|
|
632
609
|
in vec2 aPosition;
|
|
633
610
|
|
|
634
611
|
// UV coordinates for cover-fit + overscan.
|
|
@@ -657,7 +634,7 @@ void main() {
|
|
|
657
634
|
vUv = aPosition * 0.5 + 0.5;
|
|
658
635
|
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
659
636
|
}
|
|
660
|
-
`,
|
|
637
|
+
`, pe = `#version 300 es
|
|
661
638
|
precision highp float;
|
|
662
639
|
|
|
663
640
|
// BILATERAL_RADIUS is injected as a #define at compile time.
|
|
@@ -695,7 +672,7 @@ void main() {
|
|
|
695
672
|
|
|
696
673
|
fragColor = vec4(totalDepth / totalWeight, 0.0, 0.0, 1.0);
|
|
697
674
|
}
|
|
698
|
-
`,
|
|
675
|
+
`, ge = `#version 300 es
|
|
699
676
|
precision highp float;
|
|
700
677
|
|
|
701
678
|
// ---- Uniforms ----
|
|
@@ -1147,18 +1124,18 @@ void main() {
|
|
|
1147
1124
|
tiltHalfTanFov: Math.tan(50 * Math.PI / 360),
|
|
1148
1125
|
tiltTransitionWidth: 0.3 * 4.5,
|
|
1149
1126
|
tiltPeakIntensity: 0.8
|
|
1150
|
-
},
|
|
1127
|
+
}, ve = ["uRawDepth", "uTexelSize", "uSpatialSigma2"], xe = {
|
|
1151
1128
|
2: 2.25,
|
|
1152
1129
|
// 1.5²
|
|
1153
1130
|
1: 0.5625
|
|
1154
1131
|
// 0.75²
|
|
1155
1132
|
};
|
|
1156
|
-
function
|
|
1157
|
-
const e =
|
|
1133
|
+
function Te(s, t) {
|
|
1134
|
+
const e = pe.replace(
|
|
1158
1135
|
"#version 300 es",
|
|
1159
1136
|
`#version 300 es
|
|
1160
1137
|
#define BILATERAL_RADIUS ${t}`
|
|
1161
|
-
), n = G(s, s.VERTEX_SHADER, bt), i = G(s, s.FRAGMENT_SHADER, e), r = mt(s, n, i), o = pt(s, r,
|
|
1138
|
+
), n = G(s, s.VERTEX_SHADER, bt), i = G(s, s.FRAGMENT_SHADER, e), r = mt(s, n, i), o = pt(s, r, ve), l = xe[t] ?? 2.25;
|
|
1162
1139
|
let a = null;
|
|
1163
1140
|
const h = {
|
|
1164
1141
|
name: "bilateral-filter",
|
|
@@ -1179,7 +1156,7 @@ function be(s, t) {
|
|
|
1179
1156
|
0
|
|
1180
1157
|
), c.bindFramebuffer(c.FRAMEBUFFER, null), c.useProgram(r), c.uniform1i(o.uRawDepth, 2), c.uniform2f(o.uTexelSize, 1 / u, 1 / x), c.uniform1f(o.uSpatialSigma2, l);
|
|
1181
1158
|
},
|
|
1182
|
-
execute(c, f, u, x, p, d, y,
|
|
1159
|
+
execute(c, f, u, x, p, d, y, b) {
|
|
1183
1160
|
a && (c.activeTexture(c.TEXTURE2), c.bindTexture(c.TEXTURE_2D, u), c.texSubImage2D(
|
|
1184
1161
|
c.TEXTURE_2D,
|
|
1185
1162
|
0,
|
|
@@ -1190,7 +1167,7 @@ function be(s, t) {
|
|
|
1190
1167
|
c.RED,
|
|
1191
1168
|
c.UNSIGNED_BYTE,
|
|
1192
1169
|
x
|
|
1193
|
-
), c.bindFramebuffer(c.FRAMEBUFFER, a), c.viewport(0, 0, p, d), c.useProgram(r), c.bindVertexArray(f), c.drawArrays(c.TRIANGLE_STRIP, 0, 4), c.bindFramebuffer(c.FRAMEBUFFER, null), c.viewport(0, 0, y,
|
|
1170
|
+
), c.bindFramebuffer(c.FRAMEBUFFER, a), c.viewport(0, 0, p, d), c.useProgram(r), c.bindVertexArray(f), c.drawArrays(c.TRIANGLE_STRIP, 0, 4), c.bindFramebuffer(c.FRAMEBUFFER, null), c.viewport(0, 0, y, b));
|
|
1194
1171
|
},
|
|
1195
1172
|
dispose(c) {
|
|
1196
1173
|
a && (c.deleteFramebuffer(a), a = null, h.fbo = null), c.deleteProgram(r);
|
|
@@ -1198,7 +1175,7 @@ function be(s, t) {
|
|
|
1198
1175
|
};
|
|
1199
1176
|
return h;
|
|
1200
1177
|
}
|
|
1201
|
-
const
|
|
1178
|
+
const Ee = [
|
|
1202
1179
|
"uImage",
|
|
1203
1180
|
"uDepth",
|
|
1204
1181
|
"uOffset",
|
|
@@ -1237,13 +1214,13 @@ const Se = [
|
|
|
1237
1214
|
"uTiltPeakIntensity",
|
|
1238
1215
|
"uTiltPlaneNormal",
|
|
1239
1216
|
"uTiltPlaneD"
|
|
1240
|
-
],
|
|
1241
|
-
function
|
|
1242
|
-
const t =
|
|
1217
|
+
], be = 64;
|
|
1218
|
+
function Se(s) {
|
|
1219
|
+
const t = ge.replace(
|
|
1243
1220
|
"#version 300 es",
|
|
1244
1221
|
`#version 300 es
|
|
1245
|
-
#define MAX_POM_STEPS ${
|
|
1246
|
-
), e = G(s, s.VERTEX_SHADER,
|
|
1222
|
+
#define MAX_POM_STEPS ${be}`
|
|
1223
|
+
), e = G(s, s.VERTEX_SHADER, me), n = G(s, s.FRAGMENT_SHADER, t), i = mt(s, e, n), r = pt(s, i, Ee);
|
|
1247
1224
|
return {
|
|
1248
1225
|
name: "depth-effect",
|
|
1249
1226
|
program: i,
|
|
@@ -1259,7 +1236,7 @@ function we(s) {
|
|
|
1259
1236
|
}
|
|
1260
1237
|
};
|
|
1261
1238
|
}
|
|
1262
|
-
class
|
|
1239
|
+
class ye extends gt {
|
|
1263
1240
|
// ---- Shared GPU resources ----
|
|
1264
1241
|
gl = null;
|
|
1265
1242
|
quadVao = null;
|
|
@@ -1318,7 +1295,7 @@ class Re extends gt {
|
|
|
1318
1295
|
powerPreference: "high-performance"
|
|
1319
1296
|
});
|
|
1320
1297
|
if (!n) throw new Error("WebGL 2 is not supported.");
|
|
1321
|
-
this.gl = n, this.qualityParams =
|
|
1298
|
+
this.gl = n, this.qualityParams = Xt(n, e.quality), "drawingBufferColorSpace" in n && (n.drawingBufferColorSpace = "srgb"), n.clearColor(0, 0, 0, 1), n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL, !0), this.initGPUResources(), this.setupResizeHandling();
|
|
1322
1299
|
}
|
|
1323
1300
|
/**
|
|
1324
1301
|
* Set up the scene: create video texture, depth textures + FBO, and
|
|
@@ -1397,7 +1374,7 @@ class Re extends gt {
|
|
|
1397
1374
|
initGPUResources() {
|
|
1398
1375
|
const t = this.gl;
|
|
1399
1376
|
if (!t) return;
|
|
1400
|
-
this.bilateralPass =
|
|
1377
|
+
this.bilateralPass = Te(t, this.qualityParams.bilateralRadius), this.effectPass = Se(t);
|
|
1401
1378
|
const e = Ft.replace(
|
|
1402
1379
|
"#version 300 es",
|
|
1403
1380
|
`#version 300 es
|
|
@@ -1565,9 +1542,9 @@ async function ht(s, t = {}) {
|
|
|
1565
1542
|
loop: n = !0,
|
|
1566
1543
|
muted: i = !0
|
|
1567
1544
|
} = t, r = document.createElement("video");
|
|
1568
|
-
return r.crossOrigin = "anonymous", r.setAttribute("crossorigin", "anonymous"), r.playsInline = !0, r.setAttribute("playsinline", ""), r.setAttribute("webkit-playsinline", "true"), r.muted = i, r.defaultMuted = i, i && r.setAttribute("muted", ""), r.loop = n, r.preload = "auto", r.style.display = "none", r.src = s, e.appendChild(r), await Gt(r), new
|
|
1545
|
+
return r.crossOrigin = "anonymous", r.setAttribute("crossorigin", "anonymous"), r.playsInline = !0, r.setAttribute("playsinline", ""), r.setAttribute("webkit-playsinline", "true"), r.muted = i, r.defaultMuted = i, i && r.setAttribute("muted", ""), r.loop = n, r.preload = "auto", r.style.display = "none", r.src = s, e.appendChild(r), await Gt(r), new we(r);
|
|
1569
1546
|
}
|
|
1570
|
-
class
|
|
1547
|
+
class we {
|
|
1571
1548
|
constructor(t) {
|
|
1572
1549
|
this.video = t;
|
|
1573
1550
|
}
|
|
@@ -1621,9 +1598,9 @@ async function ft(s, t = {}) {
|
|
|
1621
1598
|
return;
|
|
1622
1599
|
}
|
|
1623
1600
|
e.addEventListener("load", () => n(), { once: !0 }), e.addEventListener("error", () => i(new Error(`Failed to load image: ${s}`)), { once: !0 });
|
|
1624
|
-
}), new
|
|
1601
|
+
}), new Re(e);
|
|
1625
1602
|
}
|
|
1626
|
-
class
|
|
1603
|
+
class Re {
|
|
1627
1604
|
constructor(t) {
|
|
1628
1605
|
this.img = t;
|
|
1629
1606
|
}
|
|
@@ -1645,11 +1622,11 @@ class Pe {
|
|
|
1645
1622
|
this.img.removeAttribute("src");
|
|
1646
1623
|
}
|
|
1647
1624
|
}
|
|
1648
|
-
async function
|
|
1625
|
+
async function Nt(s = { video: !0 }, t = {}) {
|
|
1649
1626
|
const { parent: e = document.body } = t, n = await navigator.mediaDevices.getUserMedia(s), i = document.createElement("video");
|
|
1650
|
-
return i.playsInline = !0, i.setAttribute("playsinline", ""), i.muted = !0, i.defaultMuted = !0, i.style.display = "none", i.srcObject = n, e.appendChild(i), await Gt(i), await i.play(), new
|
|
1627
|
+
return i.playsInline = !0, i.setAttribute("playsinline", ""), i.muted = !0, i.defaultMuted = !0, i.style.display = "none", i.srcObject = n, e.appendChild(i), await Gt(i), await i.play(), new Ae(i, n);
|
|
1651
1628
|
}
|
|
1652
|
-
class
|
|
1629
|
+
class Ae {
|
|
1653
1630
|
constructor(t, e) {
|
|
1654
1631
|
this.video = t, this.stream = e;
|
|
1655
1632
|
}
|
|
@@ -1708,10 +1685,10 @@ async function Gt(s) {
|
|
|
1708
1685
|
});
|
|
1709
1686
|
}
|
|
1710
1687
|
const Z = 518;
|
|
1711
|
-
async function
|
|
1688
|
+
async function Pe() {
|
|
1712
1689
|
return await import("onnxruntime-web/webgpu");
|
|
1713
1690
|
}
|
|
1714
|
-
class
|
|
1691
|
+
class De {
|
|
1715
1692
|
constructor(t, e) {
|
|
1716
1693
|
this.depthWidth = t, this.depthHeight = e;
|
|
1717
1694
|
const n = t * e;
|
|
@@ -1750,13 +1727,13 @@ class Ce {
|
|
|
1750
1727
|
* (GPU-accelerated on main thread), falls back to WASM EP.
|
|
1751
1728
|
*/
|
|
1752
1729
|
async init(t, e) {
|
|
1753
|
-
const n = await
|
|
1730
|
+
const n = await Pe();
|
|
1754
1731
|
if (this.ort = n, this.captureCanvas = document.createElement("canvas"), this.captureCanvas.width = Z, this.captureCanvas.height = Z, this.captureCtx = this.captureCanvas.getContext("2d", {
|
|
1755
1732
|
willReadFrequently: !0
|
|
1756
1733
|
}), !this.captureCtx)
|
|
1757
1734
|
throw new Error("[DepthEstimator] Failed to create 2D canvas context.");
|
|
1758
1735
|
e?.({ receivedBytes: 0, totalBytes: null, fraction: 0, label: "Downloading depth model…" });
|
|
1759
|
-
const i = await
|
|
1736
|
+
const i = await Fe(t, e);
|
|
1760
1737
|
e?.({ receivedBytes: i.byteLength, totalBytes: i.byteLength, fraction: 1, label: "Initialising depth model…" });
|
|
1761
1738
|
let r;
|
|
1762
1739
|
try {
|
|
@@ -1879,10 +1856,10 @@ class Ce {
|
|
|
1879
1856
|
}
|
|
1880
1857
|
}
|
|
1881
1858
|
async function dt(s, t, e, n) {
|
|
1882
|
-
const i = new
|
|
1859
|
+
const i = new De(t, e);
|
|
1883
1860
|
return await i.init(s, n), i;
|
|
1884
1861
|
}
|
|
1885
|
-
async function
|
|
1862
|
+
async function Fe(s, t) {
|
|
1886
1863
|
const e = await fetch(s);
|
|
1887
1864
|
if (!e.ok)
|
|
1888
1865
|
throw new Error(`[DepthEstimator] Failed to fetch model (${e.status} ${e.statusText}).`);
|
|
@@ -2064,7 +2041,9 @@ class xt extends HTMLElement {
|
|
|
2064
2041
|
return [
|
|
2065
2042
|
"src",
|
|
2066
2043
|
"depth-src",
|
|
2067
|
-
"depth-
|
|
2044
|
+
"depth-width",
|
|
2045
|
+
"depth-height",
|
|
2046
|
+
"depth-fps",
|
|
2068
2047
|
"depth-model",
|
|
2069
2048
|
"source-type",
|
|
2070
2049
|
"config",
|
|
@@ -2080,10 +2059,10 @@ class xt extends HTMLElement {
|
|
|
2080
2059
|
"muted"
|
|
2081
2060
|
];
|
|
2082
2061
|
}
|
|
2083
|
-
reinitAttributes = ["src", "depth-src", "depth-
|
|
2062
|
+
reinitAttributes = ["src", "depth-src", "depth-width", "depth-height", "depth-fps", "depth-model", "source-type", "config"];
|
|
2084
2063
|
canInit() {
|
|
2085
2064
|
if (this.sourceType === "camera") return !0;
|
|
2086
|
-
const t = !!this.getAttribute("src"), e = !!this.getAttribute("depth-src")
|
|
2065
|
+
const t = !!this.getAttribute("src"), e = !!this.getAttribute("depth-src"), n = !!this.getAttribute("depth-model");
|
|
2087
2066
|
return t && (e || n);
|
|
2088
2067
|
}
|
|
2089
2068
|
shadow;
|
|
@@ -2279,7 +2258,7 @@ class xt extends HTMLElement {
|
|
|
2279
2258
|
this.emit("layershift-effect:model-progress", m);
|
|
2280
2259
|
};
|
|
2281
2260
|
if (e) {
|
|
2282
|
-
if (i = await
|
|
2261
|
+
if (i = await Nt(
|
|
2283
2262
|
{ video: { facingMode: "user" } },
|
|
2284
2263
|
{ parent: this.shadow }
|
|
2285
2264
|
), t.aborted) {
|
|
@@ -2291,28 +2270,33 @@ class xt extends HTMLElement {
|
|
|
2291
2270
|
o.dispose(), i.dispose();
|
|
2292
2271
|
return;
|
|
2293
2272
|
}
|
|
2294
|
-
r =
|
|
2273
|
+
r = X($, K);
|
|
2295
2274
|
} else
|
|
2296
|
-
r =
|
|
2275
|
+
r = X(i.width, i.height);
|
|
2297
2276
|
} else {
|
|
2298
|
-
const m = this.getAttribute("src"), T = this.getAttribute("depth-src"), w =
|
|
2299
|
-
if (
|
|
2300
|
-
const [
|
|
2301
|
-
|
|
2277
|
+
const m = this.getAttribute("src"), T = this.getAttribute("depth-src"), w = !!T, A = this.sourceType === "image" || /\.(jpe?g|png|webp|gif|avif|bmp)(\?|$)/i.test(m);
|
|
2278
|
+
if (w) {
|
|
2279
|
+
const [P, F] = await Promise.all([
|
|
2280
|
+
A ? ft(m) : ht(m, {
|
|
2302
2281
|
parent: this.shadow,
|
|
2303
2282
|
loop: this.shouldLoop,
|
|
2304
2283
|
muted: this.shouldMute
|
|
2305
2284
|
}),
|
|
2306
|
-
kt(
|
|
2285
|
+
kt(
|
|
2286
|
+
T,
|
|
2287
|
+
this.getAttrFloat("depth-width", 512),
|
|
2288
|
+
this.getAttrFloat("depth-height", 512),
|
|
2289
|
+
this.getAttrFloat("depth-fps", 5)
|
|
2290
|
+
)
|
|
2307
2291
|
]);
|
|
2308
2292
|
if (t.aborted) {
|
|
2309
|
-
|
|
2293
|
+
P.dispose();
|
|
2310
2294
|
return;
|
|
2311
2295
|
}
|
|
2312
|
-
i =
|
|
2296
|
+
i = P, r = F;
|
|
2313
2297
|
} else if (n) {
|
|
2314
|
-
const [
|
|
2315
|
-
|
|
2298
|
+
const [P, F] = await Promise.all([
|
|
2299
|
+
A ? ft(m) : ht(m, {
|
|
2316
2300
|
parent: this.shadow,
|
|
2317
2301
|
loop: this.shouldLoop,
|
|
2318
2302
|
muted: this.shouldMute
|
|
@@ -2320,30 +2304,33 @@ class xt extends HTMLElement {
|
|
|
2320
2304
|
dt(n, $, K, l)
|
|
2321
2305
|
]);
|
|
2322
2306
|
if (t.aborted) {
|
|
2323
|
-
|
|
2307
|
+
P.dispose(), F.dispose();
|
|
2324
2308
|
return;
|
|
2325
2309
|
}
|
|
2326
|
-
if (i =
|
|
2327
|
-
const
|
|
2328
|
-
if (
|
|
2329
|
-
const
|
|
2310
|
+
if (i = P, o = F, A || !i.isLive) {
|
|
2311
|
+
const _ = i.getImageSource();
|
|
2312
|
+
if (_) {
|
|
2313
|
+
const I = await o.submitFrameAndWait(_);
|
|
2330
2314
|
r = {
|
|
2331
|
-
|
|
2332
|
-
|
|
2315
|
+
width: $,
|
|
2316
|
+
height: K,
|
|
2317
|
+
fps: 1,
|
|
2318
|
+
frameCount: 1,
|
|
2319
|
+
frames: [I]
|
|
2333
2320
|
};
|
|
2334
2321
|
} else
|
|
2335
|
-
r =
|
|
2322
|
+
r = X($, K);
|
|
2336
2323
|
} else
|
|
2337
|
-
r =
|
|
2324
|
+
r = X($, K);
|
|
2338
2325
|
} else
|
|
2339
|
-
throw new Error("Either depth-src
|
|
2326
|
+
throw new Error("Either depth-src or depth-model must be provided.");
|
|
2340
2327
|
}
|
|
2341
2328
|
this.source = i, this.depthEstimator = o, this.loopCount = 0, this.attachSourceEventListeners(i);
|
|
2342
|
-
const a =
|
|
2329
|
+
const a = re(
|
|
2343
2330
|
r.frames,
|
|
2344
|
-
r.
|
|
2345
|
-
r.
|
|
2346
|
-
), h =
|
|
2331
|
+
r.width,
|
|
2332
|
+
r.height
|
|
2333
|
+
), h = se(a);
|
|
2347
2334
|
this.depthFallback = {
|
|
2348
2335
|
contrastLow: h.contrastLow,
|
|
2349
2336
|
contrastHigh: h.contrastHigh,
|
|
@@ -2388,21 +2375,21 @@ class xt extends HTMLElement {
|
|
|
2388
2375
|
}, u = Lt(p.channels), x = p.motion;
|
|
2389
2376
|
} else
|
|
2390
2377
|
f = this.buildLegacyConfig(h, i.width);
|
|
2391
|
-
this.renderer = new
|
|
2378
|
+
this.renderer = new ye(this.container, f), this.renderer.initialize(i, r.width, r.height), u && this.renderer.updateCurveLUTs(
|
|
2392
2379
|
u.displacementLUT,
|
|
2393
2380
|
u.blurLUT,
|
|
2394
2381
|
u.glowLUT,
|
|
2395
2382
|
u.colorShiftLUT,
|
|
2396
2383
|
u.colorShiftParams ?? void 0
|
|
2397
2384
|
);
|
|
2398
|
-
const d = x.tiltPlaneInput ?? !1, y = x.tiltPitchSensitivity ?? 0.35,
|
|
2385
|
+
const d = x.tiltPlaneInput ?? !1, y = x.tiltPitchSensitivity ?? 0.35, b = x.tiltYawSensitivity ?? 0.15, g = p?.channels.find((m) => m.channel === "blur" && m.enabled)?.params?.focalCenter ?? 0.5, v = o;
|
|
2399
2386
|
if (this.renderer.start(
|
|
2400
2387
|
i,
|
|
2401
2388
|
c,
|
|
2402
2389
|
() => {
|
|
2403
2390
|
const m = this._input;
|
|
2404
2391
|
if (d) {
|
|
2405
|
-
const A = m.y * y, P = m.x *
|
|
2392
|
+
const A = m.y * y, P = m.x * b, F = Math.cos(A), _ = Math.sin(A), I = Math.cos(P), S = Math.sin(P) * F, D = -_, U = I * F, M = 0.5 + g * (5 - 0.5);
|
|
2406
2393
|
return {
|
|
2407
2394
|
x: m.x * 0.3,
|
|
2408
2395
|
y: m.y * 0.3,
|
|
@@ -2581,34 +2568,34 @@ class Rt {
|
|
|
2581
2568
|
this.maskTex && (t.deleteTexture(this.maskTex), this.maskTex = null), this.maskFbo && (t.deleteFramebuffer(this.maskFbo), this.maskFbo = null), this.pingTex && (t.deleteTexture(this.pingTex), this.pingTex = null), this.pingFbo && (t.deleteFramebuffer(this.pingFbo), this.pingFbo = null), this.pongTex && (t.deleteTexture(this.pongTex), this.pongTex = null), this.pongFbo && (t.deleteFramebuffer(this.pongFbo), this.pongFbo = null), this.distTex && (t.deleteTexture(this.distTex), this.distTex = null), this.distFbo && (t.deleteFramebuffer(this.distFbo), this.distFbo = null), this._width = 0, this._height = 0, this._dirty = !0;
|
|
2582
2569
|
}
|
|
2583
2570
|
}
|
|
2584
|
-
const
|
|
2571
|
+
const Ce = `#version 300 es
|
|
2585
2572
|
in vec2 aPosition;
|
|
2586
2573
|
uniform vec2 uMeshScale;
|
|
2587
2574
|
void main() {
|
|
2588
2575
|
gl_Position = vec4(aPosition * uMeshScale, 0.0, 1.0);
|
|
2589
2576
|
}
|
|
2590
|
-
`,
|
|
2577
|
+
`, Ue = `#version 300 es
|
|
2591
2578
|
precision lowp float;
|
|
2592
2579
|
out vec4 fragColor;
|
|
2593
2580
|
void main() { fragColor = vec4(0.0); }
|
|
2594
|
-
`,
|
|
2581
|
+
`, Le = `#version 300 es
|
|
2595
2582
|
in vec2 aPosition;
|
|
2596
2583
|
uniform vec2 uMeshScale;
|
|
2597
2584
|
void main() {
|
|
2598
2585
|
gl_Position = vec4(aPosition * uMeshScale, 0.0, 1.0);
|
|
2599
2586
|
}
|
|
2600
|
-
`,
|
|
2587
|
+
`, _e = `#version 300 es
|
|
2601
2588
|
precision lowp float;
|
|
2602
2589
|
out vec4 fragColor;
|
|
2603
2590
|
void main() { fragColor = vec4(1.0); }
|
|
2604
|
-
`,
|
|
2591
|
+
`, Ie = `#version 300 es
|
|
2605
2592
|
in vec2 aPosition;
|
|
2606
2593
|
out vec2 vUv;
|
|
2607
2594
|
void main() {
|
|
2608
2595
|
vUv = aPosition * 0.5 + 0.5;
|
|
2609
2596
|
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
2610
2597
|
}
|
|
2611
|
-
`,
|
|
2598
|
+
`, Me = `#version 300 es
|
|
2612
2599
|
precision highp float;
|
|
2613
2600
|
uniform sampler2D uMask;
|
|
2614
2601
|
uniform vec2 uTexelSize;
|
|
@@ -2633,14 +2620,14 @@ void main() {
|
|
|
2633
2620
|
fragSeed = vec2(-1.0);
|
|
2634
2621
|
}
|
|
2635
2622
|
}
|
|
2636
|
-
`,
|
|
2623
|
+
`, Be = `#version 300 es
|
|
2637
2624
|
in vec2 aPosition;
|
|
2638
2625
|
out vec2 vUv;
|
|
2639
2626
|
void main() {
|
|
2640
2627
|
vUv = aPosition * 0.5 + 0.5;
|
|
2641
2628
|
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
2642
2629
|
}
|
|
2643
|
-
`,
|
|
2630
|
+
`, Ve = `#version 300 es
|
|
2644
2631
|
precision highp float;
|
|
2645
2632
|
uniform sampler2D uSeedTex;
|
|
2646
2633
|
uniform float uStepSize;
|
|
@@ -2669,14 +2656,14 @@ void main() {
|
|
|
2669
2656
|
|
|
2670
2657
|
fragSeed = bestSeed;
|
|
2671
2658
|
}
|
|
2672
|
-
`,
|
|
2659
|
+
`, ke = `#version 300 es
|
|
2673
2660
|
in vec2 aPosition;
|
|
2674
2661
|
out vec2 vUv;
|
|
2675
2662
|
void main() {
|
|
2676
2663
|
vUv = aPosition * 0.5 + 0.5;
|
|
2677
2664
|
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
2678
2665
|
}
|
|
2679
|
-
`,
|
|
2666
|
+
`, Oe = `#version 300 es
|
|
2680
2667
|
precision highp float;
|
|
2681
2668
|
uniform sampler2D uSeedTex;
|
|
2682
2669
|
uniform sampler2D uMask;
|
|
@@ -2701,7 +2688,7 @@ void main() {
|
|
|
2701
2688
|
float normalized = clamp(d / max(uBevelWidth, 0.001), 0.0, 1.0);
|
|
2702
2689
|
fragDist = vec4(normalized, 0.0, 0.0, 1.0);
|
|
2703
2690
|
}
|
|
2704
|
-
`,
|
|
2691
|
+
`, He = `#version 300 es
|
|
2705
2692
|
in vec2 aPosition;
|
|
2706
2693
|
uniform vec2 uUvOffset;
|
|
2707
2694
|
uniform vec2 uUvScale;
|
|
@@ -2713,7 +2700,7 @@ void main() {
|
|
|
2713
2700
|
vScreenUv = baseUv;
|
|
2714
2701
|
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
2715
2702
|
}
|
|
2716
|
-
`,
|
|
2703
|
+
`, Xe = `#version 300 es
|
|
2717
2704
|
precision highp float;
|
|
2718
2705
|
|
|
2719
2706
|
#define MAX_POM_STEPS 32
|
|
@@ -2844,14 +2831,14 @@ void main() {
|
|
|
2844
2831
|
// Write lens-transformed depth to second attachment for boundary effects
|
|
2845
2832
|
fragDepth = vec4(lensD, 0.0, 0.0, 1.0);
|
|
2846
2833
|
}
|
|
2847
|
-
`,
|
|
2834
|
+
`, Ne = `#version 300 es
|
|
2848
2835
|
in vec2 aPosition;
|
|
2849
2836
|
out vec2 vUv;
|
|
2850
2837
|
void main() {
|
|
2851
2838
|
vUv = aPosition * 0.5 + 0.5;
|
|
2852
2839
|
gl_Position = vec4(aPosition, 0.0, 1.0);
|
|
2853
2840
|
}
|
|
2854
|
-
`,
|
|
2841
|
+
`, Ge = `#version 300 es
|
|
2855
2842
|
precision highp float;
|
|
2856
2843
|
uniform sampler2D uInteriorColor;
|
|
2857
2844
|
uniform sampler2D uDistField;
|
|
@@ -2881,7 +2868,7 @@ void main() {
|
|
|
2881
2868
|
|
|
2882
2869
|
fragColor = vec4(toSRGB(linear), color.a);
|
|
2883
2870
|
}
|
|
2884
|
-
`,
|
|
2871
|
+
`, We = `#version 300 es
|
|
2885
2872
|
in vec2 aPosition;
|
|
2886
2873
|
in vec2 aNormal;
|
|
2887
2874
|
uniform float uRimWidth;
|
|
@@ -2904,7 +2891,7 @@ void main() {
|
|
|
2904
2891
|
|
|
2905
2892
|
gl_Position = vec4(pos, 0.0, 1.0);
|
|
2906
2893
|
}
|
|
2907
|
-
`,
|
|
2894
|
+
`, ze = `#version 300 es
|
|
2908
2895
|
precision highp float;
|
|
2909
2896
|
|
|
2910
2897
|
uniform sampler2D uInteriorColor;
|
|
@@ -3006,7 +2993,7 @@ void main() {
|
|
|
3006
2993
|
|
|
3007
2994
|
fragColor = vec4(color * alpha, alpha);
|
|
3008
2995
|
}
|
|
3009
|
-
`,
|
|
2996
|
+
`, qe = `#version 300 es
|
|
3010
2997
|
in vec2 aPosition;
|
|
3011
2998
|
in vec3 aNormal3;
|
|
3012
2999
|
in float aLerpT; // 0 = inner (at silhouette), 1 = outer edge
|
|
@@ -3022,7 +3009,7 @@ void main() {
|
|
|
3022
3009
|
vLerpT = aLerpT;
|
|
3023
3010
|
gl_Position = vec4(sp, 0.0, 1.0);
|
|
3024
3011
|
}
|
|
3025
|
-
`,
|
|
3012
|
+
`, Ye = `#version 300 es
|
|
3026
3013
|
precision highp float;
|
|
3027
3014
|
uniform vec3 uLightDir3;
|
|
3028
3015
|
uniform vec3 uChamferColor;
|
|
@@ -3090,7 +3077,7 @@ void main() {
|
|
|
3090
3077
|
fragColor = vec4(toSRGB(lit), 1.0);
|
|
3091
3078
|
}
|
|
3092
3079
|
`;
|
|
3093
|
-
function
|
|
3080
|
+
function je(s) {
|
|
3094
3081
|
const t = [];
|
|
3095
3082
|
let e = 0;
|
|
3096
3083
|
for (let n = 0; n < s.length - 2; n += 2) {
|
|
@@ -3129,7 +3116,7 @@ function $e(s) {
|
|
|
3129
3116
|
count: e
|
|
3130
3117
|
};
|
|
3131
3118
|
}
|
|
3132
|
-
function
|
|
3119
|
+
function Ze(s, t, e, n, i) {
|
|
3133
3120
|
if (n <= 0)
|
|
3134
3121
|
return { vertices: new Float32Array(0), count: 0 };
|
|
3135
3122
|
const r = i * Math.PI / 180, o = -Math.cos(r), l = Math.sin(r), a = [];
|
|
@@ -3143,17 +3130,17 @@ function Ke(s, t, e, n, i) {
|
|
|
3143
3130
|
const w = f + T * 2, A = s[w], P = s[w + 1], F = s[w + 2], _ = s[w + 3];
|
|
3144
3131
|
y += A * _ - F * P;
|
|
3145
3132
|
}
|
|
3146
|
-
const
|
|
3133
|
+
const b = y >= 0 ? 1 : -1, E = [], g = [];
|
|
3147
3134
|
for (let T = 0; T < d; T++) {
|
|
3148
3135
|
const w = f + T * 2, A = s[w + 2] - s[w], P = s[w + 3] - s[w + 1], F = Math.sqrt(A * A + P * P);
|
|
3149
|
-
F < 1e-8 ? (
|
|
3136
|
+
F < 1e-8 ? (E.push(T > 0 ? E[T - 1] : 0), g.push(T > 0 ? g[T - 1] : 0)) : (E.push(-P / F * b), g.push(A / F * b));
|
|
3150
3137
|
}
|
|
3151
3138
|
const v = [], m = [];
|
|
3152
3139
|
for (let T = 0; T < d; T++) {
|
|
3153
3140
|
const w = (T - 1 + d) % d;
|
|
3154
|
-
let A =
|
|
3141
|
+
let A = E[w] + E[T], P = g[w] + g[T];
|
|
3155
3142
|
const F = Math.sqrt(A * A + P * P);
|
|
3156
|
-
F > 1e-8 ? (A /= F, P /= F) : (A =
|
|
3143
|
+
F > 1e-8 ? (A /= F, P /= F) : (A = E[T], P = g[T]), v.push(A), m.push(P);
|
|
3157
3144
|
}
|
|
3158
3145
|
for (let T = 0; T < d; T++) {
|
|
3159
3146
|
const w = T, A = (T + 1) % d, P = f + T * 2, F = f + (T + 1) % d * 2, _ = s[P], I = s[P + 1], C = s[F], S = s[F + 1], D = v[w] * l, U = m[w] * l, M = o, k = v[A] * l, j = m[A] * l, et = o, at = _ + v[w] * n, At = I + m[w] * n, Jt = C + v[A] * n, Qt = S + m[A] * n;
|
|
@@ -3165,7 +3152,7 @@ function Ke(s, t, e, n, i) {
|
|
|
3165
3152
|
count: h
|
|
3166
3153
|
};
|
|
3167
3154
|
}
|
|
3168
|
-
class
|
|
3155
|
+
class $e extends gt {
|
|
3169
3156
|
gl = null;
|
|
3170
3157
|
// Render passes (each owns its program + cached uniforms)
|
|
3171
3158
|
stencilPass = null;
|
|
@@ -3223,7 +3210,7 @@ class Je extends gt {
|
|
|
3223
3210
|
powerPreference: "high-performance"
|
|
3224
3211
|
});
|
|
3225
3212
|
if (!o) throw new Error("WebGL 2 is not supported.");
|
|
3226
|
-
this.gl = o, this.qualityParams =
|
|
3213
|
+
this.gl = o, this.qualityParams = Xt(o, e.quality), "drawingBufferColorSpace" in o && (o.drawingBufferColorSpace = "srgb"), this.hasColorBufferFloat = !!o.getExtension("EXT_color_buffer_float"), o.clearColor(0, 0, 0, 0), o.pixelStorei(o.UNPACK_FLIP_Y_WEBGL, !0), this.initGPUResources(), this.setupResizeHandling();
|
|
3227
3214
|
}
|
|
3228
3215
|
initialize(t, e, n, i) {
|
|
3229
3216
|
const r = this.gl;
|
|
@@ -3257,7 +3244,7 @@ class Je extends gt {
|
|
|
3257
3244
|
uploadBoundaryMesh(t) {
|
|
3258
3245
|
const e = this.gl;
|
|
3259
3246
|
if (!e || !this.boundaryPass) return;
|
|
3260
|
-
const n =
|
|
3247
|
+
const n = je(t.edgeVertices);
|
|
3261
3248
|
if (n.count === 0) return;
|
|
3262
3249
|
this.boundaryVao = e.createVertexArray(), e.bindVertexArray(this.boundaryVao);
|
|
3263
3250
|
const i = e.createBuffer();
|
|
@@ -3270,7 +3257,7 @@ class Je extends gt {
|
|
|
3270
3257
|
uploadChamferMesh(t) {
|
|
3271
3258
|
const e = this.gl;
|
|
3272
3259
|
if (!e || !this.chamferPass || this.config.chamferWidth <= 0) return;
|
|
3273
|
-
const n =
|
|
3260
|
+
const n = Ze(
|
|
3274
3261
|
t.edgeVertices,
|
|
3275
3262
|
t.contourOffsets,
|
|
3276
3263
|
t.contourIsHole,
|
|
@@ -3328,7 +3315,7 @@ class Je extends gt {
|
|
|
3328
3315
|
// -----------------------------------------------------------------------
|
|
3329
3316
|
initGPUResources() {
|
|
3330
3317
|
const t = this.gl;
|
|
3331
|
-
t && (this.stencilPass = O(t, "stencil",
|
|
3318
|
+
t && (this.stencilPass = O(t, "stencil", Ce, Ue, ["uMeshScale"]), this.maskPass = O(t, "mask", Le, _e, ["uMeshScale"]), this.jfaSeedPass = O(t, "jfa-seed", Ie, Me, ["uMask", "uTexelSize"]), this.jfaFloodPass = O(t, "jfa-flood", Be, Ve, ["uSeedTex", "uStepSize"]), this.jfaDistPass = O(t, "jfa-dist", ke, Oe, ["uSeedTex", "uMask", "uBevelWidth"]), this.interiorPass = O(t, "interior", He, Xe, [
|
|
3332
3319
|
"uImage",
|
|
3333
3320
|
"uDepth",
|
|
3334
3321
|
"uOffset",
|
|
@@ -3349,12 +3336,12 @@ class Je extends gt {
|
|
|
3349
3336
|
"uBrightnessBias",
|
|
3350
3337
|
"uUvOffset",
|
|
3351
3338
|
"uUvScale"
|
|
3352
|
-
]), this.compositePass = O(t, "composite",
|
|
3339
|
+
]), this.compositePass = O(t, "composite", Ne, Ge, [
|
|
3353
3340
|
"uInteriorColor",
|
|
3354
3341
|
"uDistField",
|
|
3355
3342
|
"uEdgeOcclusionWidth",
|
|
3356
3343
|
"uEdgeOcclusionStrength"
|
|
3357
|
-
]), this.boundaryPass = O(t, "boundary",
|
|
3344
|
+
]), this.boundaryPass = O(t, "boundary", We, ze, [
|
|
3358
3345
|
"uInteriorColor",
|
|
3359
3346
|
"uInteriorDepth",
|
|
3360
3347
|
"uDistField",
|
|
@@ -3371,7 +3358,7 @@ class Je extends gt {
|
|
|
3371
3358
|
"uEdgeColor",
|
|
3372
3359
|
"uLightDir",
|
|
3373
3360
|
"uBevelIntensity"
|
|
3374
|
-
]), this.chamferPass = O(t, "chamfer",
|
|
3361
|
+
]), this.chamferPass = O(t, "chamfer", qe, Ye, [
|
|
3375
3362
|
"uMeshScale",
|
|
3376
3363
|
"uLightDir3",
|
|
3377
3364
|
"uChamferColor",
|
|
@@ -3504,13 +3491,13 @@ async function Tt(s) {
|
|
|
3504
3491
|
if (!t.ok)
|
|
3505
3492
|
throw new Error(`Failed to fetch SVG: ${t.status} ${t.statusText}`);
|
|
3506
3493
|
const e = await t.text();
|
|
3507
|
-
return
|
|
3494
|
+
return Ke(e);
|
|
3508
3495
|
}
|
|
3509
|
-
function
|
|
3496
|
+
function Ke(s) {
|
|
3510
3497
|
const n = new DOMParser().parseFromString(s, "image/svg+xml").querySelector("svg");
|
|
3511
3498
|
if (!n)
|
|
3512
3499
|
throw new Error("No <svg> element found in document.");
|
|
3513
|
-
const i =
|
|
3500
|
+
const i = Je(n);
|
|
3514
3501
|
if (i.length === 0)
|
|
3515
3502
|
throw new Error("No path data found in SVG.");
|
|
3516
3503
|
let r = 1 / 0, o = 1 / 0, l = -1 / 0, a = -1 / 0;
|
|
@@ -3522,15 +3509,15 @@ function Qe(s) {
|
|
|
3522
3509
|
for (let D = 0; D < C.length; D += 2)
|
|
3523
3510
|
S.push((C[D] - f) * x), S.push(-((C[D + 1] - u) * x));
|
|
3524
3511
|
return S;
|
|
3525
|
-
}), y =
|
|
3512
|
+
}), y = an(d), b = [], E = [];
|
|
3526
3513
|
for (const C of y) {
|
|
3527
|
-
const { flatCoords: S, holeIndices: D } =
|
|
3514
|
+
const { flatCoords: S, holeIndices: D } = on(C), U = ln(S, D), M = b.length / 2;
|
|
3528
3515
|
for (const k of U)
|
|
3529
|
-
|
|
3516
|
+
E.push(k + M);
|
|
3530
3517
|
for (const k of S)
|
|
3531
|
-
|
|
3518
|
+
b.push(k);
|
|
3532
3519
|
}
|
|
3533
|
-
const g =
|
|
3520
|
+
const g = b, v = E, m = [], T = [], w = [], A = zt(d);
|
|
3534
3521
|
for (let C = 0; C < d.length; C++) {
|
|
3535
3522
|
const S = d[C];
|
|
3536
3523
|
T.push(m.length), w.push(A[C]);
|
|
@@ -3551,12 +3538,12 @@ function Qe(s) {
|
|
|
3551
3538
|
aspect: p
|
|
3552
3539
|
};
|
|
3553
3540
|
}
|
|
3554
|
-
function
|
|
3541
|
+
function Je(s) {
|
|
3555
3542
|
const t = [];
|
|
3556
3543
|
return s.querySelectorAll("path").forEach((a) => {
|
|
3557
3544
|
const h = a.getAttribute("d");
|
|
3558
3545
|
if (!h) return;
|
|
3559
|
-
const c =
|
|
3546
|
+
const c = en(h);
|
|
3560
3547
|
t.push(...c);
|
|
3561
3548
|
}), s.querySelectorAll("polygon").forEach((a) => {
|
|
3562
3549
|
const h = a.getAttribute("points");
|
|
@@ -3573,10 +3560,10 @@ function tn(s) {
|
|
|
3573
3560
|
f > 0 && u > 0 && t.push([h, c, h + f, c, h + f, c + u, h, c + u]);
|
|
3574
3561
|
}), s.querySelectorAll("circle").forEach((a) => {
|
|
3575
3562
|
const h = parseFloat(a.getAttribute("cx") || "0"), c = parseFloat(a.getAttribute("cy") || "0"), f = parseFloat(a.getAttribute("r") || "0");
|
|
3576
|
-
f > 0 && t.push(
|
|
3563
|
+
f > 0 && t.push(Qe(h, c, f));
|
|
3577
3564
|
}), s.querySelectorAll("ellipse").forEach((a) => {
|
|
3578
3565
|
const h = parseFloat(a.getAttribute("cx") || "0"), c = parseFloat(a.getAttribute("cy") || "0"), f = parseFloat(a.getAttribute("rx") || "0"), u = parseFloat(a.getAttribute("ry") || "0");
|
|
3579
|
-
f > 0 && u > 0 && t.push(
|
|
3566
|
+
f > 0 && u > 0 && t.push(tn(h, c, f, u));
|
|
3580
3567
|
}), t;
|
|
3581
3568
|
}
|
|
3582
3569
|
function _t(s) {
|
|
@@ -3587,7 +3574,7 @@ function _t(s) {
|
|
|
3587
3574
|
}
|
|
3588
3575
|
return t;
|
|
3589
3576
|
}
|
|
3590
|
-
function
|
|
3577
|
+
function Qe(s, t, e, n = 64) {
|
|
3591
3578
|
const i = [];
|
|
3592
3579
|
for (let r = 0; r < n; r++) {
|
|
3593
3580
|
const o = 2 * Math.PI * r / n;
|
|
@@ -3595,7 +3582,7 @@ function en(s, t, e, n = 64) {
|
|
|
3595
3582
|
}
|
|
3596
3583
|
return i;
|
|
3597
3584
|
}
|
|
3598
|
-
function
|
|
3585
|
+
function tn(s, t, e, n, i = 64) {
|
|
3599
3586
|
const r = [];
|
|
3600
3587
|
for (let o = 0; o < i; o++) {
|
|
3601
3588
|
const l = 2 * Math.PI * o / i;
|
|
@@ -3603,10 +3590,10 @@ function nn(s, t, e, n, i = 64) {
|
|
|
3603
3590
|
}
|
|
3604
3591
|
return r;
|
|
3605
3592
|
}
|
|
3606
|
-
function
|
|
3593
|
+
function en(s) {
|
|
3607
3594
|
const t = [];
|
|
3608
3595
|
let e = [], n = 0, i = 0, r = 0, o = 0, l = 0, a = 0, h = "";
|
|
3609
|
-
const c =
|
|
3596
|
+
const c = nn(s);
|
|
3610
3597
|
let f = 0;
|
|
3611
3598
|
function u() {
|
|
3612
3599
|
return f >= c.length ? 0 : parseFloat(c[f++]);
|
|
@@ -3619,8 +3606,8 @@ function rn(s) {
|
|
|
3619
3606
|
switch (p.toUpperCase()) {
|
|
3620
3607
|
case "M": {
|
|
3621
3608
|
e.length > 0 && t.push(e), e = [];
|
|
3622
|
-
const
|
|
3623
|
-
n =
|
|
3609
|
+
const b = u() + (d ? n : 0), E = u() + (d ? i : 0);
|
|
3610
|
+
n = b, i = E, r = b, o = E, e.push(n, i), l = n, a = i;
|
|
3624
3611
|
break;
|
|
3625
3612
|
}
|
|
3626
3613
|
case "L": {
|
|
@@ -3636,28 +3623,28 @@ function rn(s) {
|
|
|
3636
3623
|
break;
|
|
3637
3624
|
}
|
|
3638
3625
|
case "C": {
|
|
3639
|
-
const
|
|
3640
|
-
it(e, n, i,
|
|
3626
|
+
const b = u() + (d ? n : 0), E = u() + (d ? i : 0), g = u() + (d ? n : 0), v = u() + (d ? i : 0), m = u() + (d ? n : 0), T = u() + (d ? i : 0);
|
|
3627
|
+
it(e, n, i, b, E, g, v, m, T), n = m, i = T, l = g, a = v;
|
|
3641
3628
|
break;
|
|
3642
3629
|
}
|
|
3643
3630
|
case "S": {
|
|
3644
|
-
const
|
|
3645
|
-
it(e, n, i,
|
|
3631
|
+
const b = 2 * n - l, E = 2 * i - a, g = u() + (d ? n : 0), v = u() + (d ? i : 0), m = u() + (d ? n : 0), T = u() + (d ? i : 0);
|
|
3632
|
+
it(e, n, i, b, E, g, v, m, T), n = m, i = T, l = g, a = v;
|
|
3646
3633
|
break;
|
|
3647
3634
|
}
|
|
3648
3635
|
case "Q": {
|
|
3649
|
-
const
|
|
3650
|
-
It(e, n, i,
|
|
3636
|
+
const b = u() + (d ? n : 0), E = u() + (d ? i : 0), g = u() + (d ? n : 0), v = u() + (d ? i : 0);
|
|
3637
|
+
It(e, n, i, b, E, g, v), n = g, i = v, l = b, a = E;
|
|
3651
3638
|
break;
|
|
3652
3639
|
}
|
|
3653
3640
|
case "T": {
|
|
3654
|
-
const
|
|
3655
|
-
It(e, n, i,
|
|
3641
|
+
const b = 2 * n - l, E = 2 * i - a, g = u() + (d ? n : 0), v = u() + (d ? i : 0);
|
|
3642
|
+
It(e, n, i, b, E, g, v), n = g, i = v, l = b, a = E;
|
|
3656
3643
|
break;
|
|
3657
3644
|
}
|
|
3658
3645
|
case "A": {
|
|
3659
|
-
const
|
|
3660
|
-
|
|
3646
|
+
const b = u(), E = u(), g = u(), v = u(), m = u(), T = u() + (d ? n : 0), w = u() + (d ? i : 0);
|
|
3647
|
+
sn(e, n, i, b, E, g, !!v, !!m, T, w), n = T, i = w, l = n, a = i;
|
|
3661
3648
|
break;
|
|
3662
3649
|
}
|
|
3663
3650
|
case "Z": {
|
|
@@ -3672,14 +3659,14 @@ function rn(s) {
|
|
|
3672
3659
|
}
|
|
3673
3660
|
return e.length >= 6 && t.push(e), t;
|
|
3674
3661
|
}
|
|
3675
|
-
function
|
|
3662
|
+
function nn(s) {
|
|
3676
3663
|
const t = [], e = /([a-zA-Z])|([+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?)/g;
|
|
3677
3664
|
let n;
|
|
3678
3665
|
for (; (n = e.exec(s)) !== null; )
|
|
3679
3666
|
t.push(n[0]);
|
|
3680
3667
|
return t;
|
|
3681
3668
|
}
|
|
3682
|
-
const
|
|
3669
|
+
const rn = 0.5;
|
|
3683
3670
|
function it(s, t, e, n, i, r, o, l, a, h = 0) {
|
|
3684
3671
|
if (h > 12) {
|
|
3685
3672
|
s.push(l, a);
|
|
@@ -3691,38 +3678,38 @@ function it(s, t, e, n, i, r, o, l, a, h = 0) {
|
|
|
3691
3678
|
return;
|
|
3692
3679
|
}
|
|
3693
3680
|
const x = Math.abs((n - l) * f - (i - a) * c) / u, p = Math.abs((r - l) * f - (o - a) * c) / u;
|
|
3694
|
-
if (x + p <
|
|
3681
|
+
if (x + p < rn) {
|
|
3695
3682
|
s.push(l, a);
|
|
3696
3683
|
return;
|
|
3697
3684
|
}
|
|
3698
|
-
const d = (t + n) / 2, y = (e + i) / 2,
|
|
3685
|
+
const d = (t + n) / 2, y = (e + i) / 2, b = (n + r) / 2, E = (i + o) / 2, g = (r + l) / 2, v = (o + a) / 2, m = (d + b) / 2, T = (y + E) / 2, w = (b + g) / 2, A = (E + v) / 2, P = (m + w) / 2, F = (T + A) / 2;
|
|
3699
3686
|
it(s, t, e, d, y, m, T, P, F, h + 1), it(s, P, F, w, A, g, v, l, a, h + 1);
|
|
3700
3687
|
}
|
|
3701
3688
|
function It(s, t, e, n, i, r, o) {
|
|
3702
3689
|
const l = t + 0.6666666666666666 * (n - t), a = e + 2 / 3 * (i - e), h = r + 2 / 3 * (n - r), c = o + 2 / 3 * (i - o);
|
|
3703
3690
|
it(s, t, e, l, a, h, c, r, o);
|
|
3704
3691
|
}
|
|
3705
|
-
function
|
|
3692
|
+
function sn(s, t, e, n, i, r, o, l, a, h) {
|
|
3706
3693
|
if (n === 0 || i === 0) {
|
|
3707
3694
|
s.push(a, h);
|
|
3708
3695
|
return;
|
|
3709
3696
|
}
|
|
3710
3697
|
let c = Math.abs(n), f = Math.abs(i);
|
|
3711
|
-
const u = r * Math.PI / 180, x = Math.cos(u), p = Math.sin(u), d = (t - a) / 2, y = (e - h) / 2,
|
|
3712
|
-
let g =
|
|
3698
|
+
const u = r * Math.PI / 180, x = Math.cos(u), p = Math.sin(u), d = (t - a) / 2, y = (e - h) / 2, b = x * d + p * y, E = -p * d + x * y;
|
|
3699
|
+
let g = b * b / (c * c) + E * E / (f * f);
|
|
3713
3700
|
if (g > 1) {
|
|
3714
3701
|
const U = Math.sqrt(g);
|
|
3715
3702
|
c *= U, f *= U, g = 1;
|
|
3716
3703
|
}
|
|
3717
|
-
const v = c * c, m = f * f, T =
|
|
3704
|
+
const v = c * c, m = f * f, T = b * b, w = E * E;
|
|
3718
3705
|
let A = Math.max(0, (v * m - v * w - m * T) / (v * w + m * T));
|
|
3719
3706
|
A = Math.sqrt(A), o === l && (A = -A);
|
|
3720
|
-
const P = A * (c *
|
|
3707
|
+
const P = A * (c * E) / f, F = A * -(f * b) / c, _ = x * P - p * F + (t + a) / 2, I = p * P + x * F + (e + h) / 2, C = Mt(1, 0, (b - P) / c, (E - F) / f);
|
|
3721
3708
|
let S = Mt(
|
|
3722
|
-
(
|
|
3723
|
-
(
|
|
3724
|
-
(-
|
|
3725
|
-
(-
|
|
3709
|
+
(b - P) / c,
|
|
3710
|
+
(E - F) / f,
|
|
3711
|
+
(-b - P) / c,
|
|
3712
|
+
(-E - F) / f
|
|
3726
3713
|
);
|
|
3727
3714
|
!l && S > 0 && (S -= 2 * Math.PI), l && S < 0 && (S += 2 * Math.PI);
|
|
3728
3715
|
const D = Math.max(4, Math.ceil(Math.abs(S) / (Math.PI / 16)));
|
|
@@ -3735,7 +3722,7 @@ function Mt(s, t, e, n) {
|
|
|
3735
3722
|
const i = s * n - t * e < 0 ? -1 : 1, r = s * e + t * n, o = Math.sqrt(s * s + t * t), l = Math.sqrt(e * e + n * n), a = r / (o * l);
|
|
3736
3723
|
return i * Math.acos(Math.max(-1, Math.min(1, a)));
|
|
3737
3724
|
}
|
|
3738
|
-
function
|
|
3725
|
+
function on(s) {
|
|
3739
3726
|
const t = [], e = [];
|
|
3740
3727
|
for (let n = 0; n < s.length; n++) {
|
|
3741
3728
|
n > 0 && e.push(t.length / 2);
|
|
@@ -3755,7 +3742,7 @@ function zt(s) {
|
|
|
3755
3742
|
}
|
|
3756
3743
|
return n;
|
|
3757
3744
|
}
|
|
3758
|
-
function
|
|
3745
|
+
function an(s) {
|
|
3759
3746
|
if (s.length <= 1)
|
|
3760
3747
|
return [s];
|
|
3761
3748
|
const t = zt(s), e = s.map((o, l) => {
|
|
@@ -3798,12 +3785,12 @@ function Yt(s, t, e) {
|
|
|
3798
3785
|
}
|
|
3799
3786
|
return n;
|
|
3800
3787
|
}
|
|
3801
|
-
function
|
|
3788
|
+
function ln(s, t, e = 2) {
|
|
3802
3789
|
const n = t && t.length > 0, i = n ? t[0] * e : s.length;
|
|
3803
3790
|
let r = jt(s, 0, i, e, !0);
|
|
3804
3791
|
const o = [];
|
|
3805
3792
|
if (!r || r.next === r.prev) return o;
|
|
3806
|
-
n && (r =
|
|
3793
|
+
n && (r = dn(s, t, r, e));
|
|
3807
3794
|
let l = 1 / 0, a = 1 / 0, h = -1 / 0, c = -1 / 0, f = 0;
|
|
3808
3795
|
if (s.length > 80 * e) {
|
|
3809
3796
|
for (let u = 0; u < i; u += e) {
|
|
@@ -3816,7 +3803,7 @@ function cn(s, t, e = 2) {
|
|
|
3816
3803
|
}
|
|
3817
3804
|
function jt(s, t, e, n, i) {
|
|
3818
3805
|
let r = null;
|
|
3819
|
-
if (i ===
|
|
3806
|
+
if (i === yn(s, t, e, n) > 0)
|
|
3820
3807
|
for (let o = t; o < e; o += n)
|
|
3821
3808
|
r = Bt(o, s[o], s[o + 1], r);
|
|
3822
3809
|
else
|
|
@@ -3838,20 +3825,20 @@ function Y(s, t) {
|
|
|
3838
3825
|
}
|
|
3839
3826
|
function rt(s, t, e, n, i, r, o) {
|
|
3840
3827
|
if (!s) return;
|
|
3841
|
-
!o && r &&
|
|
3828
|
+
!o && r && vn(s, n, i, r);
|
|
3842
3829
|
let l = s, a, h;
|
|
3843
3830
|
for (; s.prev !== s.next; ) {
|
|
3844
|
-
if (a = s.prev, h = s.next, r ?
|
|
3831
|
+
if (a = s.prev, h = s.next, r ? cn(s, n, i, r) : un(s)) {
|
|
3845
3832
|
t.push(a.i / e, s.i / e, h.i / e), ot(s), s = h.next, l = h.next;
|
|
3846
3833
|
continue;
|
|
3847
3834
|
}
|
|
3848
3835
|
if (s = h, s === l) {
|
|
3849
|
-
o ? o === 1 ? (s =
|
|
3836
|
+
o ? o === 1 ? (s = hn(Y(s), t, e), rt(s, t, e, n, i, r, 2)) : o === 2 && fn(s, t, e, n, i, r) : rt(Y(s), t, e, n, i, r, 1);
|
|
3850
3837
|
break;
|
|
3851
3838
|
}
|
|
3852
3839
|
}
|
|
3853
3840
|
}
|
|
3854
|
-
function
|
|
3841
|
+
function un(s) {
|
|
3855
3842
|
const t = s.prev, e = s, n = s.next;
|
|
3856
3843
|
if (L(t, e, n) >= 0) return !1;
|
|
3857
3844
|
const i = t.x, r = e.x, o = n.x, l = t.y, a = e.y, h = n.y, c = i < r ? i < o ? i : o : r < o ? r : o, f = l < a ? l < h ? l : h : a < h ? a : h, u = i > r ? i > o ? i : o : r > o ? r : o, x = l > a ? l > h ? l : h : a > h ? a : h;
|
|
@@ -3863,26 +3850,26 @@ function hn(s) {
|
|
|
3863
3850
|
}
|
|
3864
3851
|
return !0;
|
|
3865
3852
|
}
|
|
3866
|
-
function
|
|
3853
|
+
function cn(s, t, e, n) {
|
|
3867
3854
|
const i = s.prev, r = s, o = s.next;
|
|
3868
3855
|
if (L(i, r, o) >= 0) return !1;
|
|
3869
|
-
const l = i.x, a = r.x, h = o.x, c = i.y, f = r.y, u = o.y, x = l < a ? l < h ? l : h : a < h ? a : h, p = c < f ? c < u ? c : u : f < u ? f : u, d = l > a ? l > h ? l : h : a > h ? a : h, y = c > f ? c > u ? c : u : f > u ? f : u,
|
|
3856
|
+
const l = i.x, a = r.x, h = o.x, c = i.y, f = r.y, u = o.y, x = l < a ? l < h ? l : h : a < h ? a : h, p = c < f ? c < u ? c : u : f < u ? f : u, d = l > a ? l > h ? l : h : a > h ? a : h, y = c > f ? c > u ? c : u : f > u ? f : u, b = yt(x, p, t, e, n), E = yt(d, y, t, e, n);
|
|
3870
3857
|
let g = s.prevZ, v = s.nextZ;
|
|
3871
|
-
for (; g && g.z >=
|
|
3858
|
+
for (; g && g.z >= b && v && v.z <= E; ) {
|
|
3872
3859
|
if (g.x >= x && g.x <= d && g.y >= p && g.y <= y && g !== i && g !== o && tt(l, c, a, f, h, u, g.x, g.y) && L(g.prev, g, g.next) >= 0 || (g = g.prevZ, v.x >= x && v.x <= d && v.y >= p && v.y <= y && v !== i && v !== o && tt(l, c, a, f, h, u, v.x, v.y) && L(v.prev, v, v.next) >= 0)) return !1;
|
|
3873
3860
|
v = v.nextZ;
|
|
3874
3861
|
}
|
|
3875
|
-
for (; g && g.z >=
|
|
3862
|
+
for (; g && g.z >= b; ) {
|
|
3876
3863
|
if (g.x >= x && g.x <= d && g.y >= p && g.y <= y && g !== i && g !== o && tt(l, c, a, f, h, u, g.x, g.y) && L(g.prev, g, g.next) >= 0) return !1;
|
|
3877
3864
|
g = g.prevZ;
|
|
3878
3865
|
}
|
|
3879
|
-
for (; v && v.z <=
|
|
3866
|
+
for (; v && v.z <= E; ) {
|
|
3880
3867
|
if (v.x >= x && v.x <= d && v.y >= p && v.y <= y && v !== i && v !== o && tt(l, c, a, f, h, u, v.x, v.y) && L(v.prev, v, v.next) >= 0) return !1;
|
|
3881
3868
|
v = v.nextZ;
|
|
3882
3869
|
}
|
|
3883
3870
|
return !0;
|
|
3884
3871
|
}
|
|
3885
|
-
function
|
|
3872
|
+
function hn(s, t, e) {
|
|
3886
3873
|
let n = s;
|
|
3887
3874
|
do {
|
|
3888
3875
|
const i = n.prev, r = n.next.next;
|
|
@@ -3890,12 +3877,12 @@ function dn(s, t, e) {
|
|
|
3890
3877
|
} while (n !== s);
|
|
3891
3878
|
return Y(n);
|
|
3892
3879
|
}
|
|
3893
|
-
function
|
|
3880
|
+
function fn(s, t, e, n, i, r) {
|
|
3894
3881
|
let o = s;
|
|
3895
3882
|
do {
|
|
3896
3883
|
let l = o.next.next;
|
|
3897
3884
|
for (; l !== o.prev; ) {
|
|
3898
|
-
if (o.i !== l.i &&
|
|
3885
|
+
if (o.i !== l.i && En(o, l)) {
|
|
3899
3886
|
let a = $t(o, l);
|
|
3900
3887
|
o = Y(o, o.next), a = Y(a, a.next), rt(o, t, e, n, i, r, 0), rt(a, t, e, n, i, r, 0);
|
|
3901
3888
|
return;
|
|
@@ -3905,24 +3892,24 @@ function mn(s, t, e, n, i, r) {
|
|
|
3905
3892
|
o = o.next;
|
|
3906
3893
|
} while (o !== s);
|
|
3907
3894
|
}
|
|
3908
|
-
function
|
|
3895
|
+
function dn(s, t, e, n) {
|
|
3909
3896
|
const i = [];
|
|
3910
3897
|
for (let r = 0; r < t.length; r++) {
|
|
3911
3898
|
const o = t[r] * n, l = r < t.length - 1 ? t[r + 1] * n : s.length, a = jt(s, o, l, n, !1);
|
|
3912
|
-
a && (a === a.next && (a.steiner = !0), i.push(
|
|
3899
|
+
a && (a === a.next && (a.steiner = !0), i.push(Tn(a)));
|
|
3913
3900
|
}
|
|
3914
3901
|
i.sort((r, o) => r.x - o.x);
|
|
3915
3902
|
for (const r of i)
|
|
3916
|
-
e =
|
|
3903
|
+
e = mn(r, e);
|
|
3917
3904
|
return e;
|
|
3918
3905
|
}
|
|
3919
|
-
function
|
|
3920
|
-
const e =
|
|
3906
|
+
function mn(s, t) {
|
|
3907
|
+
const e = pn(s, t);
|
|
3921
3908
|
if (!e) return t;
|
|
3922
3909
|
const n = $t(e, s);
|
|
3923
3910
|
return Y(n, n.next), Y(e, e.next);
|
|
3924
3911
|
}
|
|
3925
|
-
function
|
|
3912
|
+
function pn(s, t) {
|
|
3926
3913
|
let e = t;
|
|
3927
3914
|
const n = s.x, i = s.y;
|
|
3928
3915
|
let r = -1 / 0, o = null;
|
|
@@ -3941,23 +3928,23 @@ function vn(s, t) {
|
|
|
3941
3928
|
do {
|
|
3942
3929
|
if (n >= e.x && e.x >= a && n !== e.x && tt(i < h ? n : r, i, a, h, i < h ? r : n, i, e.x, e.y)) {
|
|
3943
3930
|
const f = Math.abs(i - e.y) / (n - e.x);
|
|
3944
|
-
st(e, s) && (f < c || f === c && (e.x > o.x ||
|
|
3931
|
+
st(e, s) && (f < c || f === c && (e.x > o.x || gn(o, e))) && (o = e, c = f);
|
|
3945
3932
|
}
|
|
3946
3933
|
e = e.next;
|
|
3947
3934
|
} while (e !== l);
|
|
3948
3935
|
return o;
|
|
3949
3936
|
}
|
|
3950
|
-
function
|
|
3937
|
+
function gn(s, t) {
|
|
3951
3938
|
return L(s.prev, s, t.prev) < 0 && L(t.next, s, s.next) < 0;
|
|
3952
3939
|
}
|
|
3953
|
-
function
|
|
3940
|
+
function vn(s, t, e, n) {
|
|
3954
3941
|
let i = s;
|
|
3955
3942
|
do
|
|
3956
3943
|
i.z === 0 && (i.z = yt(i.x, i.y, t, e, n)), i.prevZ = i.prev, i.nextZ = i.next, i = i.next;
|
|
3957
3944
|
while (i !== s);
|
|
3958
|
-
i.prevZ.nextZ = null, i.prevZ = null,
|
|
3945
|
+
i.prevZ.nextZ = null, i.prevZ = null, xn(i);
|
|
3959
3946
|
}
|
|
3960
|
-
function
|
|
3947
|
+
function xn(s) {
|
|
3961
3948
|
let t = 1, e;
|
|
3962
3949
|
do {
|
|
3963
3950
|
let n = s;
|
|
@@ -3983,7 +3970,7 @@ function yt(s, t, e, n, i) {
|
|
|
3983
3970
|
let r = (s - e) * i | 0, o = (t - n) * i | 0;
|
|
3984
3971
|
return r = (r | r << 8) & 16711935, r = (r | r << 4) & 252645135, r = (r | r << 2) & 858993459, r = (r | r << 1) & 1431655765, o = (o | o << 8) & 16711935, o = (o | o << 4) & 252645135, o = (o | o << 2) & 858993459, o = (o | o << 1) & 1431655765, r | o << 1;
|
|
3985
3972
|
}
|
|
3986
|
-
function
|
|
3973
|
+
function Tn(s) {
|
|
3987
3974
|
let t = s, e = s;
|
|
3988
3975
|
do
|
|
3989
3976
|
(t.x < e.x || t.x === e.x && t.y < e.y) && (e = t), t = t.next;
|
|
@@ -3993,8 +3980,8 @@ function bn(s) {
|
|
|
3993
3980
|
function tt(s, t, e, n, i, r, o, l) {
|
|
3994
3981
|
return (i - o) * (t - l) - (s - o) * (r - l) >= 0 && (s - o) * (n - l) - (e - o) * (t - l) >= 0 && (e - o) * (r - l) - (i - o) * (n - l) >= 0;
|
|
3995
3982
|
}
|
|
3996
|
-
function
|
|
3997
|
-
return s.next.i !== t.i && s.prev.i !== t.i && !
|
|
3983
|
+
function En(s, t) {
|
|
3984
|
+
return s.next.i !== t.i && s.prev.i !== t.i && !bn(s, t) && (st(s, t) && st(t, s) && Sn(s, t) && (L(s.prev, s, t.prev) !== 0 || L(s, t.prev, t) !== 0) || vt(s, t) && L(s.prev, s, s.next) > 0 && L(t.prev, t, t.next) > 0);
|
|
3998
3985
|
}
|
|
3999
3986
|
function L(s, t, e) {
|
|
4000
3987
|
return (t.y - s.y) * (e.x - t.x) - (t.x - s.x) * (e.y - t.y);
|
|
@@ -4012,7 +3999,7 @@ function ut(s, t, e) {
|
|
|
4012
3999
|
function ct(s) {
|
|
4013
4000
|
return s > 0 ? 1 : s < 0 ? -1 : 0;
|
|
4014
4001
|
}
|
|
4015
|
-
function
|
|
4002
|
+
function bn(s, t) {
|
|
4016
4003
|
let e = s;
|
|
4017
4004
|
do {
|
|
4018
4005
|
if (e.i !== s.i && e.next.i !== s.i && e.i !== t.i && e.next.i !== t.i && Zt(e, e.next, s, t)) return !0;
|
|
@@ -4023,7 +4010,7 @@ function yn(s, t) {
|
|
|
4023
4010
|
function st(s, t) {
|
|
4024
4011
|
return L(s.prev, s, s.next) < 0 ? L(s, t, s.next) >= 0 && L(s, s.prev, t) >= 0 : L(s, t, s.prev) < 0 || L(s, s.next, t) < 0;
|
|
4025
4012
|
}
|
|
4026
|
-
function
|
|
4013
|
+
function Sn(s, t) {
|
|
4027
4014
|
let e = s, n = !1;
|
|
4028
4015
|
const i = (s.x + t.x) / 2, r = (s.y + t.y) / 2;
|
|
4029
4016
|
do
|
|
@@ -4055,7 +4042,7 @@ function wt(s, t, e) {
|
|
|
4055
4042
|
steiner: !1
|
|
4056
4043
|
};
|
|
4057
4044
|
}
|
|
4058
|
-
function
|
|
4045
|
+
function yn(s, t, e, n) {
|
|
4059
4046
|
let i = 0;
|
|
4060
4047
|
for (let r = t, o = e - n; r < e; r += n)
|
|
4061
4048
|
i += (s[o] - s[r]) * (s[r + 1] + s[o + 1]), o = r;
|
|
@@ -4123,7 +4110,9 @@ class Et extends HTMLElement {
|
|
|
4123
4110
|
return [
|
|
4124
4111
|
"src",
|
|
4125
4112
|
"depth-src",
|
|
4126
|
-
"depth-
|
|
4113
|
+
"depth-width",
|
|
4114
|
+
"depth-height",
|
|
4115
|
+
"depth-fps",
|
|
4127
4116
|
"depth-model",
|
|
4128
4117
|
"logo-src",
|
|
4129
4118
|
"source-type",
|
|
@@ -4174,11 +4163,11 @@ class Et extends HTMLElement {
|
|
|
4174
4163
|
"muted"
|
|
4175
4164
|
];
|
|
4176
4165
|
}
|
|
4177
|
-
reinitAttributes = ["src", "depth-src", "depth-
|
|
4166
|
+
reinitAttributes = ["src", "depth-src", "depth-width", "depth-height", "depth-fps", "depth-model", "logo-src", "source-type"];
|
|
4178
4167
|
canInit() {
|
|
4179
4168
|
const t = !!this.getAttribute("logo-src");
|
|
4180
4169
|
if (this.sourceType === "camera") return t;
|
|
4181
|
-
const e = !!this.getAttribute("src"), n = !!this.getAttribute("depth-src")
|
|
4170
|
+
const e = !!this.getAttribute("src"), n = !!this.getAttribute("depth-src"), i = !!this.getAttribute("depth-model");
|
|
4182
4171
|
return e && t && (n || i);
|
|
4183
4172
|
}
|
|
4184
4173
|
_input = { x: 0, y: 0 };
|
|
@@ -4214,7 +4203,7 @@ class Et extends HTMLElement {
|
|
|
4214
4203
|
}
|
|
4215
4204
|
getAttrColor(t, e) {
|
|
4216
4205
|
const n = this.getAttribute(t) ?? e;
|
|
4217
|
-
return
|
|
4206
|
+
return wn(n);
|
|
4218
4207
|
}
|
|
4219
4208
|
getAttrVec3(t, e) {
|
|
4220
4209
|
const i = (this.getAttribute(t) ?? e).split(",").map((o) => parseFloat(o.trim()));
|
|
@@ -4450,7 +4439,7 @@ class Et extends HTMLElement {
|
|
|
4450
4439
|
};
|
|
4451
4440
|
if (n) {
|
|
4452
4441
|
const [d, y] = await Promise.all([
|
|
4453
|
-
|
|
4442
|
+
Nt(
|
|
4454
4443
|
{ video: { facingMode: "user" } },
|
|
4455
4444
|
{ parent: this.shadow }
|
|
4456
4445
|
),
|
|
@@ -4465,29 +4454,34 @@ class Et extends HTMLElement {
|
|
|
4465
4454
|
a.dispose(), r.dispose();
|
|
4466
4455
|
return;
|
|
4467
4456
|
}
|
|
4468
|
-
o =
|
|
4457
|
+
o = X(J, Q);
|
|
4469
4458
|
} else
|
|
4470
|
-
o =
|
|
4459
|
+
o = X(r.width, r.height);
|
|
4471
4460
|
} else {
|
|
4472
|
-
const d = this.getAttribute("src"), y = this.getAttribute("depth-src"),
|
|
4461
|
+
const d = this.getAttribute("src"), y = this.getAttribute("depth-src"), b = !!y, E = this.sourceType === "image" || /\.(jpe?g|png|webp|gif|avif|bmp)(\?|$)/i.test(d);
|
|
4473
4462
|
if (b) {
|
|
4474
|
-
const [v, m
|
|
4475
|
-
|
|
4463
|
+
const [g, v, m] = await Promise.all([
|
|
4464
|
+
E ? ft(d) : ht(d, {
|
|
4476
4465
|
parent: this.shadow,
|
|
4477
4466
|
loop: this.shouldLoop,
|
|
4478
4467
|
muted: this.shouldMute
|
|
4479
4468
|
}),
|
|
4480
|
-
kt(
|
|
4469
|
+
kt(
|
|
4470
|
+
y,
|
|
4471
|
+
this.getAttrFloat("depth-width", 512),
|
|
4472
|
+
this.getAttrFloat("depth-height", 512),
|
|
4473
|
+
this.getAttrFloat("depth-fps", 5)
|
|
4474
|
+
),
|
|
4481
4475
|
Tt(e)
|
|
4482
4476
|
]);
|
|
4483
4477
|
if (t.aborted) {
|
|
4484
|
-
|
|
4478
|
+
g.dispose();
|
|
4485
4479
|
return;
|
|
4486
4480
|
}
|
|
4487
|
-
r =
|
|
4481
|
+
r = g, o = v, l = m;
|
|
4488
4482
|
} else if (i) {
|
|
4489
|
-
const [v, m
|
|
4490
|
-
|
|
4483
|
+
const [g, v, m] = await Promise.all([
|
|
4484
|
+
E ? ft(d) : ht(d, {
|
|
4491
4485
|
parent: this.shadow,
|
|
4492
4486
|
loop: this.shouldLoop,
|
|
4493
4487
|
muted: this.shouldMute
|
|
@@ -4496,23 +4490,26 @@ class Et extends HTMLElement {
|
|
|
4496
4490
|
Tt(e)
|
|
4497
4491
|
]);
|
|
4498
4492
|
if (t.aborted) {
|
|
4499
|
-
|
|
4493
|
+
g.dispose(), v.dispose();
|
|
4500
4494
|
return;
|
|
4501
4495
|
}
|
|
4502
|
-
if (r =
|
|
4503
|
-
const
|
|
4504
|
-
if (
|
|
4505
|
-
const
|
|
4496
|
+
if (r = g, a = v, l = m, E || !r.isLive) {
|
|
4497
|
+
const T = r.getImageSource();
|
|
4498
|
+
if (T) {
|
|
4499
|
+
const w = await a.submitFrameAndWait(T);
|
|
4506
4500
|
o = {
|
|
4507
|
-
|
|
4508
|
-
|
|
4501
|
+
width: J,
|
|
4502
|
+
height: Q,
|
|
4503
|
+
fps: 1,
|
|
4504
|
+
frameCount: 1,
|
|
4505
|
+
frames: [w]
|
|
4509
4506
|
};
|
|
4510
4507
|
} else
|
|
4511
|
-
o =
|
|
4508
|
+
o = X(J, Q);
|
|
4512
4509
|
} else
|
|
4513
|
-
o =
|
|
4510
|
+
o = X(J, Q);
|
|
4514
4511
|
} else
|
|
4515
|
-
throw new Error("Either depth-src
|
|
4512
|
+
throw new Error("Either depth-src or depth-model must be provided.");
|
|
4516
4513
|
}
|
|
4517
4514
|
this.source = r, this.depthEstimator = a, this.mesh = l, this.loopCount = 0, this.attachSourceEventListeners(r);
|
|
4518
4515
|
const c = this.container?.clientWidth || r.width, f = this.parallaxMax / Math.max(c, 1);
|
|
@@ -4565,7 +4562,7 @@ class Et extends HTMLElement {
|
|
|
4565
4562
|
lightDirection: this.lightDirection3
|
|
4566
4563
|
};
|
|
4567
4564
|
if (t.aborted) return;
|
|
4568
|
-
this.renderer = new
|
|
4565
|
+
this.renderer = new $e(this.container, x), this.renderer.initialize(r, o.width, o.height, l);
|
|
4569
4566
|
const p = a;
|
|
4570
4567
|
if (this.renderer.start(
|
|
4571
4568
|
r,
|
|
@@ -4573,8 +4570,8 @@ class Et extends HTMLElement {
|
|
|
4573
4570
|
() => ({ x: this._input.x, y: this._input.y }),
|
|
4574
4571
|
(d, y) => {
|
|
4575
4572
|
if (p) {
|
|
4576
|
-
const
|
|
4577
|
-
|
|
4573
|
+
const b = r.getImageSource();
|
|
4574
|
+
b && p.submitFrame(b);
|
|
4578
4575
|
}
|
|
4579
4576
|
this.emit("layershift-portal:frame", {
|
|
4580
4577
|
currentTime: d,
|
|
@@ -4602,7 +4599,7 @@ class Et extends HTMLElement {
|
|
|
4602
4599
|
this.renderer?.dispose(), this.renderer = null, this.depthEstimator?.dispose(), this.depthEstimator = null, this.source?.dispose(), this.source = null, this.mesh = null, this.loopCount = 0, this.container = null;
|
|
4603
4600
|
}
|
|
4604
4601
|
}
|
|
4605
|
-
function
|
|
4602
|
+
function wn(s) {
|
|
4606
4603
|
const t = s.replace("#", "");
|
|
4607
4604
|
if (t.length === 3) {
|
|
4608
4605
|
const e = parseInt(t[0] + t[0], 16) / 255, n = parseInt(t[1] + t[1], 16) / 255, i = parseInt(t[2] + t[2], 16) / 255;
|
|
@@ -4620,13 +4617,13 @@ function V(s, t, e) {
|
|
|
4620
4617
|
function W(s, t, e) {
|
|
4621
4618
|
return s + (t - s) * e;
|
|
4622
4619
|
}
|
|
4623
|
-
const
|
|
4624
|
-
function
|
|
4620
|
+
const N = 100, Kt = 0.06;
|
|
4621
|
+
function Rn(s, t) {
|
|
4625
4622
|
const e = t?.sensitivityX ?? 1, n = t?.sensitivityY ?? 1, i = t?.lerpFactor ?? 0.08;
|
|
4626
4623
|
let r = 0, o = 0, l = 0, a = 0, h = 0, c = !0;
|
|
4627
4624
|
const f = (p) => {
|
|
4628
|
-
const d = s.getBoundingClientRect(), y = (p.clientX - d.left) / d.width * 2 - 1,
|
|
4629
|
-
r = V(y, -1, 1), o = V(
|
|
4625
|
+
const d = s.getBoundingClientRect(), y = (p.clientX - d.left) / d.width * 2 - 1, b = (p.clientY - d.top) / d.height * 2 - 1;
|
|
4626
|
+
r = V(y, -1, 1), o = V(b, -1, 1);
|
|
4630
4627
|
}, u = () => {
|
|
4631
4628
|
r = 0, o = 0;
|
|
4632
4629
|
}, x = () => {
|
|
@@ -4636,17 +4633,17 @@ function Pn(s, t) {
|
|
|
4636
4633
|
c = !1, cancelAnimationFrame(h), s.removeEventListener("mousemove", f), s.removeEventListener("mouseleave", u);
|
|
4637
4634
|
};
|
|
4638
4635
|
}
|
|
4639
|
-
function
|
|
4636
|
+
function An(s, t) {
|
|
4640
4637
|
const e = t?.sensitivityX ?? 1, n = t?.sensitivityY ?? 1, i = t?.lerpFactor ?? 0.08;
|
|
4641
4638
|
let r = 0, o = 0, l = 0, a = 0, h = 0, c = 0, f = 0, u = !0;
|
|
4642
|
-
const x = (
|
|
4643
|
-
const
|
|
4644
|
-
|
|
4645
|
-
}, p = (
|
|
4646
|
-
const
|
|
4647
|
-
if (!
|
|
4648
|
-
const g =
|
|
4649
|
-
r = V(g /
|
|
4639
|
+
const x = (b) => {
|
|
4640
|
+
const E = b.touches[0];
|
|
4641
|
+
E && (h = E.clientX - l * N, c = E.clientY - a * N, r = l, o = a);
|
|
4642
|
+
}, p = (b) => {
|
|
4643
|
+
const E = b.touches[0];
|
|
4644
|
+
if (!E) return;
|
|
4645
|
+
const g = E.clientX - h, v = E.clientY - c;
|
|
4646
|
+
r = V(g / N, -1, 1), o = V(v / N, -1, 1);
|
|
4650
4647
|
}, d = () => {
|
|
4651
4648
|
r = 0, o = 0;
|
|
4652
4649
|
}, y = () => {
|
|
@@ -4656,7 +4653,7 @@ function Dn(s, t) {
|
|
|
4656
4653
|
u = !1, cancelAnimationFrame(f), s.removeEventListener("touchstart", x), s.removeEventListener("touchmove", p), s.removeEventListener("touchend", d), s.removeEventListener("touchcancel", d);
|
|
4657
4654
|
};
|
|
4658
4655
|
}
|
|
4659
|
-
function
|
|
4656
|
+
function Pn(s, t) {
|
|
4660
4657
|
const e = t?.sensitivityX ?? 1, n = t?.sensitivityY ?? 1, i = t?.lerpFactor ?? Kt;
|
|
4661
4658
|
let r = 0, o = 0, l = 0, a = 0, h = 0, c = !0, f = !1;
|
|
4662
4659
|
const u = (y) => {
|
|
@@ -4673,9 +4670,9 @@ function Fn(s, t) {
|
|
|
4673
4670
|
c = !1, cancelAnimationFrame(h), f && (window.removeEventListener("deviceorientation", u), f = !1);
|
|
4674
4671
|
};
|
|
4675
4672
|
}
|
|
4676
|
-
function
|
|
4673
|
+
function Dn(s, t) {
|
|
4677
4674
|
const e = t?.sensitivityX ?? 1, n = t?.sensitivityY ?? 1, i = t?.lerpFactor ?? 0.08, r = t?.lerpFactor ?? Kt;
|
|
4678
|
-
let o = 0, l = 0, a = 0, h = 0, c = 0, f = 0, u = 0, x = 0, p = !1, d = !1, y = !1,
|
|
4675
|
+
let o = 0, l = 0, a = 0, h = 0, c = 0, f = 0, u = 0, x = 0, p = !1, d = !1, y = !1, b = 0, E = 0, g = 0, v = !0;
|
|
4679
4676
|
const m = (S) => {
|
|
4680
4677
|
const D = s.getBoundingClientRect(), U = (S.clientX - D.left) / D.width * 2 - 1, M = (S.clientY - D.top) / D.height * 2 - 1;
|
|
4681
4678
|
o = V(U, -1, 1), l = V(M, -1, 1);
|
|
@@ -4683,12 +4680,12 @@ function Cn(s, t) {
|
|
|
4683
4680
|
o = 0, l = 0;
|
|
4684
4681
|
}, w = (S) => {
|
|
4685
4682
|
const D = S.touches[0];
|
|
4686
|
-
D && (p = !0,
|
|
4683
|
+
D && (p = !0, b = D.clientX - u * N, E = D.clientY - x * N, a = u, h = x, !d && !y && I());
|
|
4687
4684
|
}, A = (S) => {
|
|
4688
4685
|
const D = S.touches[0];
|
|
4689
4686
|
if (!D) return;
|
|
4690
|
-
const U = D.clientX -
|
|
4691
|
-
a = V(U /
|
|
4687
|
+
const U = D.clientX - b, M = D.clientY - E;
|
|
4688
|
+
a = V(U / N, -1, 1), h = V(M / N, -1, 1);
|
|
4692
4689
|
}, P = () => {
|
|
4693
4690
|
p = !1, a = 0, h = 0;
|
|
4694
4691
|
}, F = (S) => {
|
|
@@ -4716,8 +4713,8 @@ customElements.get(Et.TAG_NAME) || customElements.define(Et.TAG_NAME, Et);
|
|
|
4716
4713
|
export {
|
|
4717
4714
|
xt as LayershiftElement,
|
|
4718
4715
|
Et as LayershiftPortalElement,
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4716
|
+
Pn as connectGyro,
|
|
4717
|
+
Rn as connectMouse,
|
|
4718
|
+
Dn as connectPointer,
|
|
4719
|
+
An as connectTouch
|
|
4723
4720
|
};
|