mirage-engine 0.3.12 → 0.3.14
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/mirage-engine.js +502 -479
- package/dist/mirage-engine.umd.js +11 -11
- package/package.json +2 -2
package/dist/mirage-engine.js
CHANGED
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Oe = Object.defineProperty, _e = Object.defineProperties;
|
|
2
2
|
var Ne = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var we = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var me = (s, e, t) => e in s ?
|
|
4
|
+
var Xe = Object.prototype.hasOwnProperty, ze = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var me = (s, e, t) => e in s ? Oe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, J = (s, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
7
|
+
Xe.call(e, t) && me(s, t, e[t]);
|
|
8
8
|
if (we)
|
|
9
9
|
for (var t of we(e))
|
|
10
|
-
|
|
10
|
+
ze.call(e, t) && me(s, t, e[t]);
|
|
11
11
|
return s;
|
|
12
|
-
}, xe = (s, e) =>
|
|
12
|
+
}, xe = (s, e) => _e(s, Ne(e));
|
|
13
13
|
var u = (s, e, t) => (me(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
14
14
|
var Ee = (s, e, t) => new Promise((r, i) => {
|
|
15
|
-
var l = (
|
|
15
|
+
var l = (o) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
17
|
+
a(t.next(o));
|
|
18
18
|
} catch (c) {
|
|
19
19
|
i(c);
|
|
20
20
|
}
|
|
21
|
-
}, n = (
|
|
21
|
+
}, n = (o) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
a(t.throw(o));
|
|
24
24
|
} catch (c) {
|
|
25
25
|
i(c);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, a = (o) => o.done ? r(o.value) : Promise.resolve(o.value).then(l, n);
|
|
28
|
+
a((t = t.apply(s, e)).next());
|
|
29
29
|
});
|
|
30
30
|
import * as y from "three";
|
|
31
31
|
const Ae = {
|
|
@@ -54,7 +54,7 @@ const Ae = {
|
|
|
54
54
|
CAPTURE_8: "8",
|
|
55
55
|
CAPTURE_9: "9",
|
|
56
56
|
CAPTURE_10: "10"
|
|
57
|
-
},
|
|
57
|
+
}, O = {
|
|
58
58
|
NAME: "data-mirage-travel",
|
|
59
59
|
KEY: "mirageTravel",
|
|
60
60
|
VALUES: Ce,
|
|
@@ -63,7 +63,7 @@ const Ae = {
|
|
|
63
63
|
NAME: "data-mirage-filter",
|
|
64
64
|
KEY: "mirageFilter",
|
|
65
65
|
VALUES: Ae
|
|
66
|
-
},
|
|
66
|
+
}, G = {
|
|
67
67
|
NAME: "data-mirage-select",
|
|
68
68
|
KEY: "mirageSelect",
|
|
69
69
|
VALUES: Ae
|
|
@@ -151,23 +151,23 @@ class De {
|
|
|
151
151
|
onStart: r.onStart,
|
|
152
152
|
onEnd: r.onEnd
|
|
153
153
|
}, this.observer = new MutationObserver((n) => {
|
|
154
|
-
let
|
|
155
|
-
for (const
|
|
156
|
-
if (
|
|
157
|
-
|
|
154
|
+
let a = de;
|
|
155
|
+
for (const o of n)
|
|
156
|
+
if (o.type === "childList")
|
|
157
|
+
a |= ue, o.removedNodes.length > 0 && o.removedNodes.forEach((c) => {
|
|
158
158
|
c instanceof HTMLElement && this.pendingDeletions.add(c);
|
|
159
159
|
});
|
|
160
|
-
else if (
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
const c =
|
|
160
|
+
else if (o.type === "attributes")
|
|
161
|
+
if (o.attributeName === "style") {
|
|
162
|
+
a |= Q | ce;
|
|
163
|
+
const c = o.target, d = He(c.style);
|
|
164
164
|
this.pendingStyles.set(c, d);
|
|
165
165
|
} else
|
|
166
|
-
|
|
166
|
+
o.attributeName === "class" ? a |= Q | ce : o.attributeName && o.attributeName.startsWith("data-") && (a |= Q | ce, o.attributeName.startsWith("data-mirage") && (a |= ue));
|
|
167
167
|
else
|
|
168
|
-
|
|
169
|
-
if (
|
|
170
|
-
if (this.pendingMask |=
|
|
168
|
+
o.type === "characterData" && (a |= ve | Q);
|
|
169
|
+
if (a !== de) {
|
|
170
|
+
if (this.pendingMask |= a, a & ue) {
|
|
171
171
|
this.clearTimers(), this.isDomDirty = !0;
|
|
172
172
|
return;
|
|
173
173
|
}
|
|
@@ -192,7 +192,7 @@ class De {
|
|
|
192
192
|
this.mutationTimer && (clearTimeout(this.mutationTimer), this.mutationTimer = null), this.cssTimer && (clearTimeout(this.cssTimer), this.cssTimer = null), this.scrollTimer && (clearTimeout(this.scrollTimer), this.scrollTimer = null);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
const
|
|
195
|
+
const H = 1, ie = 2, I = {
|
|
196
196
|
BASE: 0,
|
|
197
197
|
SELECTED: 1,
|
|
198
198
|
getCaptureLayer: (s) => 31 - s,
|
|
@@ -238,35 +238,35 @@ class Pe extends y.MeshBasicMaterial {
|
|
|
238
238
|
const i = t.split(`
|
|
239
239
|
`), l = [];
|
|
240
240
|
return i.forEach((n) => {
|
|
241
|
-
const
|
|
242
|
-
if (
|
|
241
|
+
const a = n.match(/[^\s\-]+\-?|\-|\s+/g) || [];
|
|
242
|
+
if (a.length === 0) {
|
|
243
243
|
l.push("");
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
|
-
let
|
|
247
|
-
for (let c = 1; c <
|
|
248
|
-
const d =
|
|
249
|
-
this.ctx.measureText(
|
|
246
|
+
let o = a[0];
|
|
247
|
+
for (let c = 1; c < a.length; c++) {
|
|
248
|
+
const d = a[c];
|
|
249
|
+
this.ctx.measureText(o + d).width <= r + 2 ? o += d : (o && l.push(o), o = d.trimStart());
|
|
250
250
|
}
|
|
251
|
-
|
|
251
|
+
o && l.push(o);
|
|
252
252
|
}), l;
|
|
253
253
|
}
|
|
254
254
|
updateText(t, r, i, l, n) {
|
|
255
255
|
n !== void 0 && (this.qualityFactor = n);
|
|
256
|
-
const
|
|
257
|
-
this.canvas.width !== c || this.canvas.height !== d ? (this.canvas.width = c, this.canvas.height = d) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(
|
|
258
|
-
const h = this.wrapText(t, i),
|
|
259
|
-
h.forEach((
|
|
260
|
-
const
|
|
261
|
-
let
|
|
262
|
-
r.textAlign === "center" ?
|
|
256
|
+
const o = (window.devicePixelRatio || 1) * this.qualityFactor, c = i * o, d = l * o;
|
|
257
|
+
this.canvas.width !== c || this.canvas.height !== d ? (this.canvas.width = c, this.canvas.height = d) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(o, 0, 0, o, 0, 0), this.ctx.font = r.font, this.ctx.fillStyle = r.color, this.ctx.textBaseline = "alphabetic", this.ctx.globalAlpha = 1;
|
|
258
|
+
const h = this.wrapText(t, i), g = r.lineHeight, v = ke.getBaseline(r.font);
|
|
259
|
+
h.forEach((p, m) => {
|
|
260
|
+
const E = m * g + v;
|
|
261
|
+
let M = 0;
|
|
262
|
+
r.textAlign === "center" ? M = i / 2 : r.textAlign === "right" && (M = i), this.ctx.textAlign = r.textAlign, this.ctx.fillText(p, M, E);
|
|
263
263
|
}), this.map && (this.map.needsUpdate = !0);
|
|
264
264
|
}
|
|
265
265
|
dispose() {
|
|
266
266
|
this.map && this.map.dispose(), super.dispose();
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
-
function
|
|
269
|
+
function se(s, e = 0) {
|
|
270
270
|
if (typeof s == "number")
|
|
271
271
|
return s;
|
|
272
272
|
const t = parseFloat(s) || 0;
|
|
@@ -313,42 +313,42 @@ function $e(s) {
|
|
|
313
313
|
if (n.startsWith("to "))
|
|
314
314
|
n === "to top" ? i = 0 : n === "to right" ? i = Math.PI / 2 : n === "to bottom" ? i = Math.PI : n === "to left" ? i = Math.PI * 1.5 : n === "to top right" || n === "to right top" ? i = Math.PI / 4 : n === "to bottom right" || n === "to right bottom" ? i = Math.PI * 0.75 : n === "to bottom left" || n === "to left bottom" ? i = Math.PI * 1.25 : (n === "to top left" || n === "to left top") && (i = Math.PI * 1.75), l = 1;
|
|
315
315
|
else if (n.endsWith("deg") || n.endsWith("rad") || n.endsWith("turn")) {
|
|
316
|
-
const
|
|
317
|
-
n.endsWith("deg") ? i =
|
|
316
|
+
const o = parseFloat(n);
|
|
317
|
+
n.endsWith("deg") ? i = o * (Math.PI / 180) : n.endsWith("rad") ? i = o : n.endsWith("turn") && (i = o * Math.PI * 2), l = 1;
|
|
318
318
|
}
|
|
319
|
-
const
|
|
320
|
-
for (let
|
|
321
|
-
const c = r[
|
|
322
|
-
let h = c,
|
|
319
|
+
const a = [];
|
|
320
|
+
for (let o = l; o < r.length && !(a.length >= 8); o++) {
|
|
321
|
+
const c = r[o].trim(), d = c.lastIndexOf(" ");
|
|
322
|
+
let h = c, g = null;
|
|
323
323
|
if (d !== -1 && !c.endsWith(")")) {
|
|
324
|
-
const
|
|
325
|
-
(
|
|
324
|
+
const p = c.substring(d + 1);
|
|
325
|
+
(p.endsWith("%") || p.endsWith("px") || !isNaN(parseFloat(p))) && (h = c.substring(0, d).trim(), g = p);
|
|
326
326
|
}
|
|
327
327
|
const v = le(h);
|
|
328
|
-
|
|
328
|
+
a.push({
|
|
329
329
|
color: v.color,
|
|
330
330
|
alpha: v.alpha,
|
|
331
|
-
rawStop:
|
|
331
|
+
rawStop: g,
|
|
332
332
|
stop: 0
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
|
-
if (
|
|
336
|
-
for (let c = 0; c <
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
let
|
|
340
|
-
for (let c = 1; c <
|
|
341
|
-
if (
|
|
342
|
-
const d = c -
|
|
335
|
+
if (a.length > 0) {
|
|
336
|
+
for (let c = 0; c < a.length; c++)
|
|
337
|
+
a[c].rawStop !== null && (a[c].stop = parseFloat(a[c].rawStop) / 100);
|
|
338
|
+
a[0].rawStop === null && (a[0].stop = 0), a.length > 1 && a[a.length - 1].rawStop === null && (a[a.length - 1].stop = 1);
|
|
339
|
+
let o = 0;
|
|
340
|
+
for (let c = 1; c < a.length; c++)
|
|
341
|
+
if (a[c].rawStop !== null || c === a.length - 1) {
|
|
342
|
+
const d = c - o;
|
|
343
343
|
if (d > 1) {
|
|
344
|
-
const h = o
|
|
345
|
-
for (let
|
|
346
|
-
o
|
|
344
|
+
const h = a[o].stop, v = (a[c].stop - h) / d;
|
|
345
|
+
for (let p = 1; p < d; p++)
|
|
346
|
+
a[o + p].stop = h + v * p;
|
|
347
347
|
}
|
|
348
|
-
|
|
348
|
+
o = c;
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
|
-
return { angle: i, stops:
|
|
351
|
+
return { angle: i, stops: a };
|
|
352
352
|
}
|
|
353
353
|
const qe = `varying vec2 vUv;
|
|
354
354
|
varying vec4 vScreenPos;
|
|
@@ -512,43 +512,43 @@ baseColor = blendSrcOver(baseColor, texColor);`, Re = {
|
|
|
512
512
|
baseColorChunk: Qe
|
|
513
513
|
};
|
|
514
514
|
function Ze(s, e, t, r = null, i) {
|
|
515
|
-
var
|
|
515
|
+
var C;
|
|
516
516
|
const l = r !== null || !!s.imageSrc;
|
|
517
517
|
let n = "";
|
|
518
|
-
const
|
|
518
|
+
const a = {};
|
|
519
519
|
if (i != null && i.uniforms)
|
|
520
|
-
for (const [
|
|
521
|
-
typeof w == "number" ? (n += `uniform float ${
|
|
522
|
-
`,
|
|
523
|
-
`,
|
|
524
|
-
`,
|
|
525
|
-
`,
|
|
526
|
-
`,
|
|
527
|
-
const
|
|
520
|
+
for (const [S, w] of Object.entries(i.uniforms))
|
|
521
|
+
typeof w == "number" ? (n += `uniform float ${S};
|
|
522
|
+
`, a[S] = { value: w }) : Array.isArray(w) ? w.length === 2 ? (n += `uniform vec2 ${S};
|
|
523
|
+
`, a[S] = { value: new y.Vector2(...w) }) : w.length === 3 ? (n += `uniform vec3 ${S};
|
|
524
|
+
`, a[S] = { value: new y.Vector3(...w) }) : w.length === 4 && (n += `uniform vec4 ${S};
|
|
525
|
+
`, a[S] = { value: new y.Vector4(...w) }) : (n += `uniform float ${S};
|
|
526
|
+
`, a[S] = { value: w });
|
|
527
|
+
const o = i !== void 0, c = (l || o ? Le.declChunk : "") + `
|
|
528
528
|
` + n, d = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
|
|
529
529
|
`, h = s.isTraveler ? `vec2 resultUv = screenUv;
|
|
530
530
|
` : `vec2 resultUv = vUv * uTextureRepeat + uTextureOffset;
|
|
531
|
-
`,
|
|
531
|
+
`, g = l || o ? d + h + ((i == null ? void 0 : i.uvModifier) || "") : "", v = l || o ? Le.baseColorChunk : "", p = (i == null ? void 0 : i.colorModifier) || "", m = Re.fragmentShader.replace("#INJECT_DECLARATIONS", c).replace("#INJECT_UV_MODIFIER", g).replace("#INJECT_BASE_COLOR", v).replace("#INJECT_COLOR_MODIFIER", p), E = le(s.backgroundColor), M = le(s.borderColor), L = {
|
|
532
532
|
uSize: { value: new y.Vector2(e, t) },
|
|
533
533
|
uBgColor: {
|
|
534
534
|
value: new y.Vector4(
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
535
|
+
E.color.r,
|
|
536
|
+
E.color.g,
|
|
537
|
+
E.color.b,
|
|
538
|
+
E.alpha
|
|
539
539
|
)
|
|
540
540
|
},
|
|
541
541
|
uBorderColor: {
|
|
542
542
|
value: new y.Vector4(
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
543
|
+
M.color.r,
|
|
544
|
+
M.color.g,
|
|
545
|
+
M.color.b,
|
|
546
|
+
M.alpha
|
|
547
547
|
)
|
|
548
548
|
},
|
|
549
549
|
uBorderRadius: { value: new y.Vector4(0, 0, 0, 0) },
|
|
550
|
-
uBorderWidth: { value:
|
|
551
|
-
uOpacity: { value: (
|
|
550
|
+
uBorderWidth: { value: se(s.borderWidth) },
|
|
551
|
+
uOpacity: { value: (C = s.opacity) != null ? C : 1 },
|
|
552
552
|
uTexture: { value: null },
|
|
553
553
|
uTextureRepeat: { value: new y.Vector2(1, 1) },
|
|
554
554
|
uTextureOffset: { value: new y.Vector2(0, 0) },
|
|
@@ -559,19 +559,19 @@ function Ze(s, e, t, r = null, i) {
|
|
|
559
559
|
},
|
|
560
560
|
uGradientStops: { value: new Float32Array(8) }
|
|
561
561
|
};
|
|
562
|
-
Ie(
|
|
563
|
-
const
|
|
564
|
-
uniforms: J(J({},
|
|
562
|
+
Ie(L.uBorderRadius.value, s.borderRadius, Math.min(e, t)), l && (L.uTexture.value = r);
|
|
563
|
+
const R = new y.ShaderMaterial({
|
|
564
|
+
uniforms: J(J({}, L), a),
|
|
565
565
|
vertexShader: Re.vertexShader,
|
|
566
566
|
fragmentShader: m,
|
|
567
567
|
transparent: !0,
|
|
568
568
|
side: y.FrontSide
|
|
569
569
|
// for better performance
|
|
570
570
|
});
|
|
571
|
-
return s.backgroundImage && ye(
|
|
571
|
+
return s.backgroundImage && ye(R, { backgroundImage: s.backgroundImage }), R;
|
|
572
572
|
}
|
|
573
573
|
function et(s, e, t, r, i) {
|
|
574
|
-
const l =
|
|
574
|
+
const l = se(e.borderWidth);
|
|
575
575
|
ye(s, {
|
|
576
576
|
width: t,
|
|
577
577
|
height: r,
|
|
@@ -645,15 +645,15 @@ function ye(s, e) {
|
|
|
645
645
|
e.opacity !== void 0 && (s.uniforms.uOpacity.value = e.opacity), e.bgOpacity !== void 0 && (s.uniforms.uBgColor.value.w = e.bgOpacity), e.borderOpacity !== void 0 && (s.uniforms.uBorderColor.value.w = e.borderOpacity), s.uniforms.uTexture && e.texture !== void 0 && (s.uniforms.uTexture.value = e.texture);
|
|
646
646
|
const t = e.texture !== void 0 ? e.texture : (r = s.uniforms.uTexture) == null ? void 0 : r.value;
|
|
647
647
|
if (t && (t.image instanceof ImageBitmap || t.image instanceof HTMLImageElement || t.image instanceof HTMLCanvasElement)) {
|
|
648
|
-
const n = t.image.naturalWidth || t.image.videoWidth || t.image.width,
|
|
649
|
-
if (n &&
|
|
650
|
-
const d = n /
|
|
648
|
+
const n = t.image.naturalWidth || t.image.videoWidth || t.image.width, a = t.image.naturalHeight || t.image.videoHeight || t.image.height, o = (i = e.width) != null ? i : s.uniforms.uSize.value.x, c = (l = e.height) != null ? l : s.uniforms.uSize.value.y;
|
|
649
|
+
if (n && a && o && c) {
|
|
650
|
+
const d = n / a, h = o / c;
|
|
651
651
|
if (d > h) {
|
|
652
|
-
const
|
|
653
|
-
s.uniforms.uTextureRepeat.value.set(
|
|
652
|
+
const g = h / d;
|
|
653
|
+
s.uniforms.uTextureRepeat.value.set(g, 1), s.uniforms.uTextureOffset.value.set((1 - g) / 2, 0);
|
|
654
654
|
} else {
|
|
655
|
-
const
|
|
656
|
-
s.uniforms.uTextureRepeat.value.set(1,
|
|
655
|
+
const g = d / h;
|
|
656
|
+
s.uniforms.uTextureRepeat.value.set(1, g), s.uniforms.uTextureOffset.value.set(0, (1 - g) / 2);
|
|
657
657
|
}
|
|
658
658
|
}
|
|
659
659
|
} else
|
|
@@ -662,17 +662,17 @@ function ye(s, e) {
|
|
|
662
662
|
const n = $e(e.backgroundImage);
|
|
663
663
|
if (n) {
|
|
664
664
|
s.uniforms.uGradientCount.value = n.stops.length, s.uniforms.uGradientAngle.value = n.angle;
|
|
665
|
-
for (let
|
|
666
|
-
if (
|
|
667
|
-
const
|
|
668
|
-
s.uniforms.uGradientColors.value[
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
), s.uniforms.uGradientStops.value[
|
|
665
|
+
for (let a = 0; a < 8; a++)
|
|
666
|
+
if (a < n.stops.length) {
|
|
667
|
+
const o = n.stops[a];
|
|
668
|
+
s.uniforms.uGradientColors.value[a].set(
|
|
669
|
+
o.color.r,
|
|
670
|
+
o.color.g,
|
|
671
|
+
o.color.b,
|
|
672
|
+
o.alpha
|
|
673
|
+
), s.uniforms.uGradientStops.value[a] = o.stop;
|
|
674
674
|
} else
|
|
675
|
-
s.uniforms.uGradientColors.value[
|
|
675
|
+
s.uniforms.uGradientColors.value[a].set(0, 0, 0, 0), s.uniforms.uGradientStops.value[a] = 1;
|
|
676
676
|
} else
|
|
677
677
|
s.uniforms.uGradientCount.value = 0;
|
|
678
678
|
}
|
|
@@ -680,7 +680,7 @@ function ye(s, e) {
|
|
|
680
680
|
n !== "width" && n !== "height" && n !== "borderRadius" && n !== "borderWidth" && n !== "backgroundColor" && n !== "borderColor" && n !== "opacity" && n !== "bgOpacity" && n !== "borderOpacity" && n !== "texture" && n !== "backgroundImage" && s.uniforms[n] !== void 0 && (s.uniforms[n].value !== void 0 && s.uniforms[n].value !== null && typeof s.uniforms[n].value.set == "function" ? Array.isArray(e[n]) ? s.uniforms[n].value.set(...e[n]) : e[n] !== void 0 && (e[n].copy ? s.uniforms[n].value.copy(e[n]) : s.uniforms[n].value = e[n]) : s.uniforms[n].value = e[n]);
|
|
681
681
|
}
|
|
682
682
|
function Ie(s, e, t = 0) {
|
|
683
|
-
var
|
|
683
|
+
var o, c, d, h;
|
|
684
684
|
if (e == null) {
|
|
685
685
|
s.set(0, 0, 0, 0);
|
|
686
686
|
return;
|
|
@@ -693,17 +693,17 @@ function Ie(s, e, t = 0) {
|
|
|
693
693
|
s.set(e[0], e[1], e[2], e[3]);
|
|
694
694
|
return;
|
|
695
695
|
}
|
|
696
|
-
const r = e.split("/")[0].trim().split(/\s+/), i =
|
|
697
|
-
s.set(i, l, n,
|
|
696
|
+
const r = e.split("/")[0].trim().split(/\s+/), i = se(r[0], t), l = se((o = r[1]) != null ? o : r[0], t), n = se((c = r[2]) != null ? c : r[0], t), a = se((h = (d = r[3]) != null ? d : r[1]) != null ? h : r[0], t);
|
|
697
|
+
s.set(i, l, n, a);
|
|
698
698
|
}
|
|
699
|
-
const
|
|
700
|
-
create(s, e, t, r, i, l = 2, n = null,
|
|
699
|
+
const V = {
|
|
700
|
+
create(s, e, t, r, i, l = 2, n = null, a) {
|
|
701
701
|
return s === "BOX" ? Ze(
|
|
702
702
|
e,
|
|
703
703
|
r,
|
|
704
704
|
i,
|
|
705
705
|
n,
|
|
706
|
-
|
|
706
|
+
a
|
|
707
707
|
) : s === "TEXT" ? new Pe(
|
|
708
708
|
t || "",
|
|
709
709
|
e,
|
|
@@ -712,13 +712,13 @@ const H = {
|
|
|
712
712
|
l
|
|
713
713
|
) : new y.MeshBasicMaterial({ visible: !1 });
|
|
714
714
|
},
|
|
715
|
-
update(s, e, t, r, i, l, n = 2,
|
|
715
|
+
update(s, e, t, r, i, l, n = 2, a) {
|
|
716
716
|
e === "BOX" ? et(
|
|
717
717
|
s,
|
|
718
718
|
t,
|
|
719
719
|
i,
|
|
720
720
|
l,
|
|
721
|
-
|
|
721
|
+
a
|
|
722
722
|
) : e === "TEXT" && s.updateText(
|
|
723
723
|
r || "",
|
|
724
724
|
t,
|
|
@@ -767,8 +767,8 @@ class tt {
|
|
|
767
767
|
let r;
|
|
768
768
|
if (t.startsWith("data:image/svg+xml"))
|
|
769
769
|
r = yield new Promise((l, n) => {
|
|
770
|
-
const
|
|
771
|
-
|
|
770
|
+
const a = new Image();
|
|
771
|
+
a.onload = () => l(a), a.onerror = n, a.src = t;
|
|
772
772
|
});
|
|
773
773
|
else {
|
|
774
774
|
const n = yield (yield fetch(t)).blob();
|
|
@@ -818,16 +818,16 @@ class rt {
|
|
|
818
818
|
u(this, "registry");
|
|
819
819
|
u(this, "targetRect");
|
|
820
820
|
u(this, "travelersByLayer", Array.from(
|
|
821
|
-
{ length:
|
|
821
|
+
{ length: O.MAX_LAYERS },
|
|
822
822
|
() => /* @__PURE__ */ new Set()
|
|
823
823
|
));
|
|
824
824
|
u(this, "textureManager");
|
|
825
825
|
// private meshMap: Map<HTMLElement, THREE.Mesh> = new Map();
|
|
826
826
|
u(this, "fixedMeshes", /* @__PURE__ */ new Set());
|
|
827
|
-
var
|
|
828
|
-
this.target = e, this.mountContainer = r, this.registry = i, this.mode = (
|
|
829
|
-
const
|
|
830
|
-
|
|
827
|
+
var a, o, c, d, h;
|
|
828
|
+
this.target = e, this.mountContainer = r, this.registry = i, this.mode = (a = t.mode) != null ? a : "overlay", this.canvasSize = (o = t.canvasSize) != null ? o : "viewport", this.clipArea = (c = t.travelerClipArea) != null ? c : 1, this.targetLayer = (d = t.layer) != null ? d : "base", this.textureManager = new tt((g, v) => {
|
|
829
|
+
const p = this.registry.get(g);
|
|
830
|
+
p && p.material instanceof y.ShaderMaterial && V.forceUpdateUniforms(p.material, { texture: v });
|
|
831
831
|
}, this.isViewport), this.canvas = document.createElement("canvas"), this.scene = new y.Scene(), this.targetRect = this.target.getBoundingClientRect();
|
|
832
832
|
const l = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, n = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
|
|
833
833
|
this.camera = new y.OrthographicCamera(
|
|
@@ -849,10 +849,10 @@ class rt {
|
|
|
849
849
|
return this.mode === "overlay" && this.canvasSize === "viewport";
|
|
850
850
|
}
|
|
851
851
|
getSceneLayer() {
|
|
852
|
-
return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ?
|
|
852
|
+
return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ? I.SELECTED : I.BASE;
|
|
853
853
|
}
|
|
854
854
|
createRenderTarget() {
|
|
855
|
-
for (let e = 0; e <
|
|
855
|
+
for (let e = 0; e < O.MAX_LAYERS; e++) {
|
|
856
856
|
const t = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, r = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
|
|
857
857
|
this.renderTargets.push(
|
|
858
858
|
new y.WebGLRenderTarget(
|
|
@@ -899,12 +899,12 @@ class rt {
|
|
|
899
899
|
updateUniforms(e, t) {
|
|
900
900
|
const r = this.registry.get(e);
|
|
901
901
|
r && (r.traverse((i) => {
|
|
902
|
-
i.isMesh && i.material &&
|
|
902
|
+
i.isMesh && i.material && V.forceUpdateUniforms(
|
|
903
903
|
i.material,
|
|
904
904
|
t
|
|
905
905
|
);
|
|
906
906
|
}), r.userData.nativeMesh && r.userData.nativeMesh.traverse((i) => {
|
|
907
|
-
i.isMesh && i.material &&
|
|
907
|
+
i.isMesh && i.material && V.forceUpdateUniforms(
|
|
908
908
|
i.material,
|
|
909
909
|
t
|
|
910
910
|
);
|
|
@@ -920,17 +920,17 @@ class rt {
|
|
|
920
920
|
this.camera.left = e / -2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = t / -2, this.camera.updateProjectionMatrix();
|
|
921
921
|
}
|
|
922
922
|
syncScene(e, t) {
|
|
923
|
-
const r = this.target.getBoundingClientRect(), i = this.isViewport ? window.innerWidth + this.overscan * 2 : r.width, l = this.isViewport ? window.innerHeight + this.overscan * 2 : r.height, n = this.isViewport ? this.canvas.clientWidth : this.targetRect.width,
|
|
924
|
-
|
|
923
|
+
const r = this.target.getBoundingClientRect(), i = this.isViewport ? window.innerWidth + this.overscan * 2 : r.width, l = this.isViewport ? window.innerHeight + this.overscan * 2 : r.height, n = this.isViewport ? this.canvas.clientWidth : this.targetRect.width, a = this.isViewport ? this.canvas.clientHeight : this.targetRect.height, o = Math.abs(i - n) > 0.1 || Math.abs(l - a) > 0.1, c = this.mode === "overlay" && (Math.abs(r.top - this.targetRect.top) > 0.1 || Math.abs(r.left - this.targetRect.left) > 0.1);
|
|
924
|
+
o ? (this.targetRect = r, this.setSize(i, l), this.updateCanvasLayout()) : c ? (this.targetRect = r, this.updateCanvasLayout()) : this.targetRect = r, this.renderOrder = 0, this.reconcileNode(e), t.size > 0 && t.forEach((d) => {
|
|
925
925
|
const h = this.registry.get(d);
|
|
926
926
|
if (h) {
|
|
927
927
|
this.scene.remove(h);
|
|
928
|
-
for (const
|
|
929
|
-
|
|
928
|
+
for (const g of this.travelersByLayer)
|
|
929
|
+
g.delete(h);
|
|
930
930
|
this.fixedMeshes.delete(h), h.geometry.dispose(), h.userData.nativeMesh && (this.scene.remove(h.userData.nativeMesh), Array.isArray(h.userData.nativeMesh.material) ? h.userData.nativeMesh.material.forEach(
|
|
931
|
-
(
|
|
932
|
-
) : h.userData.nativeMesh.material.dispose(), h.userData.nativeMesh.geometry.dispose()), h.traverse((
|
|
933
|
-
|
|
931
|
+
(g) => g.dispose()
|
|
932
|
+
) : h.userData.nativeMesh.material.dispose(), h.userData.nativeMesh.geometry.dispose()), h.traverse((g) => {
|
|
933
|
+
g instanceof y.Mesh && (g.geometry && g.geometry.dispose(), g.material && (Array.isArray(g.material) ? g.material.forEach((v) => v.dispose()) : g.material.dispose()));
|
|
934
934
|
}), this.registry.remove(d), this.textureManager.unregister(d);
|
|
935
935
|
}
|
|
936
936
|
});
|
|
@@ -944,20 +944,20 @@ class rt {
|
|
|
944
944
|
let t = this.registry.get(e.element);
|
|
945
945
|
const r = JSON.stringify(e.shaderHooks || null);
|
|
946
946
|
if (t && t.userData.shaderHash !== r && (this.scene.remove(t), t.geometry.dispose(), t.material instanceof y.Material && t.material.dispose(), this.registry.remove(e.element), t = void 0), !t) {
|
|
947
|
-
const n = new y.PlaneGeometry(1, 1),
|
|
947
|
+
const n = new y.PlaneGeometry(1, 1), a = e.isTraveler ? (i = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : i.texture : this.textureManager.get(e.element), o = V.create(
|
|
948
948
|
"BOX",
|
|
949
949
|
e.styles,
|
|
950
950
|
"",
|
|
951
951
|
e.rect.width,
|
|
952
952
|
e.rect.height,
|
|
953
953
|
this.qualityFactor,
|
|
954
|
-
|
|
954
|
+
a,
|
|
955
955
|
e.shaderHooks
|
|
956
956
|
);
|
|
957
|
-
t = new y.Mesh(n,
|
|
957
|
+
t = new y.Mesh(n, o), e.type === "TEXT" && (t.name = "BG_MESH"), this.scene.add(t), this.registry.register(e.element, t), t.userData.baseMaterial = o, t.userData.domElement = e.element, t.userData.shaderHash = r;
|
|
958
958
|
}
|
|
959
959
|
if ((l = e.nativeStyles) != null && l.transform ? t.userData.nativeTransform = e.nativeStyles.transform : t.userData.nativeTransform = void 0, this.updateMeshProperties(t, e), this.updateMeshLayers(t, e), e.isTraveler)
|
|
960
|
-
for (let n = 0; n <
|
|
960
|
+
for (let n = 0; n < O.MAX_LAYERS; n++)
|
|
961
961
|
n === e.captureLayer - 2 ? this.travelersByLayer[n].add(t) : this.travelersByLayer[n].delete(t);
|
|
962
962
|
else
|
|
963
963
|
for (const n of this.travelersByLayer)
|
|
@@ -976,34 +976,34 @@ class rt {
|
|
|
976
976
|
var c;
|
|
977
977
|
const i = t.textLines || [
|
|
978
978
|
{ text: t.textContent || "", rect: t.rect }
|
|
979
|
-
], l = r ? t.nativeStyles : t.textStyles, n = JSON.stringify(l) + t.textContent + i.map((d) => d.text).join("|"),
|
|
980
|
-
if (t.dirtyMask & ve || n !==
|
|
979
|
+
], l = r ? t.nativeStyles : t.textStyles, n = JSON.stringify(l) + t.textContent + i.map((d) => d.text).join("|"), a = (c = e.userData) == null ? void 0 : c.textChildStyleHash;
|
|
980
|
+
if (t.dirtyMask & ve || n !== a) {
|
|
981
981
|
e.children.filter(
|
|
982
|
-
(
|
|
983
|
-
).forEach((
|
|
984
|
-
var
|
|
985
|
-
const m =
|
|
986
|
-
(
|
|
982
|
+
(p) => p.name.startsWith("TEXT_CHILD")
|
|
983
|
+
).forEach((p) => {
|
|
984
|
+
var E;
|
|
985
|
+
const m = p;
|
|
986
|
+
(E = m.material.map) == null || E.dispose(), m.geometry.dispose(), e.remove(m);
|
|
987
987
|
});
|
|
988
|
-
const h = t.rect,
|
|
989
|
-
i.forEach((
|
|
990
|
-
const
|
|
988
|
+
const h = t.rect, g = h.x + h.width / 2, v = h.y + h.height / 2;
|
|
989
|
+
i.forEach((p, m) => {
|
|
990
|
+
const E = V.create(
|
|
991
991
|
"TEXT",
|
|
992
992
|
l,
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
993
|
+
p.text,
|
|
994
|
+
p.rect.width,
|
|
995
|
+
p.rect.height,
|
|
996
996
|
this.qualityFactor
|
|
997
|
-
),
|
|
998
|
-
|
|
999
|
-
const
|
|
1000
|
-
|
|
1001
|
-
const
|
|
1002
|
-
|
|
1003
|
-
t.rect.width === 0 ? 0 :
|
|
1004
|
-
t.rect.height === 0 ? 0 :
|
|
997
|
+
), M = new y.PlaneGeometry(1, 1), L = new y.Mesh(M, E);
|
|
998
|
+
L.name = `TEXT_CHILD_${m}`;
|
|
999
|
+
const R = t.rect.width === 0 ? 1 : p.rect.width / t.rect.width, C = t.rect.height === 0 ? 1 : p.rect.height / t.rect.height;
|
|
1000
|
+
L.scale.set(R, C, 1);
|
|
1001
|
+
const S = p.rect.x + p.rect.width / 2, w = p.rect.y + p.rect.height / 2, B = S - g, _ = -(w - v);
|
|
1002
|
+
L.position.set(
|
|
1003
|
+
t.rect.width === 0 ? 0 : B / t.rect.width,
|
|
1004
|
+
t.rect.height === 0 ? 0 : _ / t.rect.height,
|
|
1005
1005
|
5e-3
|
|
1006
|
-
), e.add(
|
|
1006
|
+
), e.add(L);
|
|
1007
1007
|
}), e.userData.textChildStyleHash = n;
|
|
1008
1008
|
}
|
|
1009
1009
|
e.children.forEach((d) => {
|
|
@@ -1011,52 +1011,52 @@ class rt {
|
|
|
1011
1011
|
return;
|
|
1012
1012
|
const h = d;
|
|
1013
1013
|
if (r && t.nativeLayer !== void 0)
|
|
1014
|
-
h.layers.set(
|
|
1014
|
+
h.layers.set(I.HIDDEN), t.visibility & H && h.layers.enable(I.getCaptureLayer(t.nativeLayer));
|
|
1015
1015
|
else {
|
|
1016
|
-
const
|
|
1017
|
-
if (h.layers.set(
|
|
1016
|
+
const g = t.visibility & H ? I.BASE : I.HIDDEN;
|
|
1017
|
+
if (h.layers.set(g), t.visibility & ie && h.layers.enable(I.SELECTED), t.visibility & H)
|
|
1018
1018
|
if (!r && t.nativeLayer !== void 0 && t.nativeStyles !== void 0)
|
|
1019
|
-
for (let v = t.captureLayer; v <=
|
|
1020
|
-
v !== t.nativeLayer && h.layers.enable(
|
|
1019
|
+
for (let v = t.captureLayer; v <= O.MAX_LAYERS + 1; v++)
|
|
1020
|
+
v !== t.nativeLayer && h.layers.enable(I.getCaptureLayer(v));
|
|
1021
1021
|
else
|
|
1022
|
-
for (let v = t.captureLayer; v <=
|
|
1023
|
-
h.layers.enable(
|
|
1022
|
+
for (let v = t.captureLayer; v <= O.MAX_LAYERS + 1; v++)
|
|
1023
|
+
h.layers.enable(I.getCaptureLayer(v));
|
|
1024
1024
|
}
|
|
1025
1025
|
});
|
|
1026
1026
|
}
|
|
1027
1027
|
updateMeshProperties(e, t) {
|
|
1028
|
-
var
|
|
1029
|
-
const { rect: r, styles: i } = t, l = this.renderer.getPixelRatio(), n = this.renderer.domElement.width / l,
|
|
1028
|
+
var R, C, S;
|
|
1029
|
+
const { rect: r, styles: i } = t, l = this.renderer.getPixelRatio(), n = this.renderer.domElement.width / l, a = this.renderer.domElement.height / l;
|
|
1030
1030
|
e.material = e.userData.baseMaterial, e.scale.set(r.width, r.height, 1), e.userData.domRect = {
|
|
1031
1031
|
x: r.x,
|
|
1032
1032
|
y: r.y,
|
|
1033
1033
|
width: r.width,
|
|
1034
1034
|
height: r.height
|
|
1035
1035
|
};
|
|
1036
|
-
const
|
|
1036
|
+
const o = 1e-3;
|
|
1037
1037
|
this.renderOrder++;
|
|
1038
1038
|
const c = this.targetRect.left + window.scrollX, d = this.targetRect.top + window.scrollY;
|
|
1039
|
-
let h,
|
|
1039
|
+
let h, g;
|
|
1040
1040
|
if (this.isViewport)
|
|
1041
|
-
h = r.x - window.innerWidth / 2 + r.width / 2,
|
|
1041
|
+
h = r.x - window.innerWidth / 2 + r.width / 2, g = -r.y + window.innerHeight / 2 - r.height / 2;
|
|
1042
1042
|
else {
|
|
1043
|
-
const w = r.x - c,
|
|
1044
|
-
h = w - n / 2 + r.width / 2,
|
|
1043
|
+
const w = r.x - c, B = r.y - d;
|
|
1044
|
+
h = w - n / 2 + r.width / 2, g = -B + a / 2 - r.height / 2;
|
|
1045
1045
|
}
|
|
1046
1046
|
e.position.set(
|
|
1047
1047
|
h,
|
|
1048
|
-
|
|
1049
|
-
i.zIndex + this.renderOrder *
|
|
1048
|
+
g,
|
|
1049
|
+
i.zIndex + this.renderOrder * o
|
|
1050
1050
|
);
|
|
1051
|
-
const v = r.x,
|
|
1052
|
-
e.userData.basePosition = { x: h, y:
|
|
1053
|
-
const m = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element,
|
|
1054
|
-
let
|
|
1055
|
-
if (
|
|
1056
|
-
const w = new DOMMatrix(
|
|
1057
|
-
|
|
1051
|
+
const v = r.x, p = r.y;
|
|
1052
|
+
e.userData.basePosition = { x: h, y: g }, e.userData.originalBasePosition = { x: h, y: g }, e.userData.baseSize = { width: r.width, height: r.height }, e.userData.baseDOM = { x: v, y: p }, e.userData.isFixed = t.isFixed, e.userData.initialScroll = { x: window.scrollX, y: window.scrollY };
|
|
1053
|
+
const m = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element, E = window.getComputedStyle(m);
|
|
1054
|
+
let M = 0, L = 0;
|
|
1055
|
+
if (E.transform && E.transform !== "none") {
|
|
1056
|
+
const w = new DOMMatrix(E.transform);
|
|
1057
|
+
M = w.m41, L = w.m42;
|
|
1058
1058
|
}
|
|
1059
|
-
if (e.userData.baseTransform = { x:
|
|
1059
|
+
if (e.userData.baseTransform = { x: M, y: L }, delete e.userData.originRatioX, delete e.userData.originRatioY, V.update(
|
|
1060
1060
|
e.userData.baseMaterial,
|
|
1061
1061
|
"BOX",
|
|
1062
1062
|
i,
|
|
@@ -1064,62 +1064,72 @@ class rt {
|
|
|
1064
1064
|
r.width,
|
|
1065
1065
|
r.height,
|
|
1066
1066
|
this.qualityFactor,
|
|
1067
|
-
t.isTraveler ? (
|
|
1067
|
+
t.isTraveler ? (R = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : R.texture : this.textureManager.get(t.element)
|
|
1068
1068
|
), t.nativeStyles && t.nativeRect) {
|
|
1069
1069
|
if (!e.userData.nativeMesh) {
|
|
1070
|
-
const
|
|
1070
|
+
const N = V.create(
|
|
1071
1071
|
"BOX",
|
|
1072
1072
|
t.nativeStyles,
|
|
1073
1073
|
"",
|
|
1074
1074
|
t.nativeRect.width,
|
|
1075
1075
|
t.nativeRect.height,
|
|
1076
1076
|
this.qualityFactor,
|
|
1077
|
-
t.isTraveler ? (
|
|
1077
|
+
t.isTraveler ? (C = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : C.texture : this.textureManager.get(t.element),
|
|
1078
1078
|
t.shaderHooks
|
|
1079
|
-
),
|
|
1080
|
-
t.type === "TEXT" && (
|
|
1079
|
+
), X = new y.Mesh(e.geometry, N);
|
|
1080
|
+
t.type === "TEXT" && (X.name = "BG_MESH"), this.scene.add(X), e.userData.nativeMesh = X;
|
|
1081
1081
|
}
|
|
1082
1082
|
const w = e.userData.nativeMesh;
|
|
1083
|
-
let
|
|
1083
|
+
let B, _;
|
|
1084
1084
|
if (this.isViewport)
|
|
1085
|
-
|
|
1085
|
+
B = t.nativeRect.x - window.innerWidth / 2 + t.nativeRect.width / 2, _ = -t.nativeRect.y + window.innerHeight / 2 - t.nativeRect.height / 2;
|
|
1086
1086
|
else {
|
|
1087
|
-
const
|
|
1088
|
-
|
|
1087
|
+
const N = t.nativeRect.x - c, X = t.nativeRect.y - d;
|
|
1088
|
+
B = N - n / 2 + t.nativeRect.width / 2, _ = -X + a / 2 - t.nativeRect.height / 2;
|
|
1089
1089
|
}
|
|
1090
|
-
let
|
|
1090
|
+
let b = t.nativeRect.width, U = t.nativeRect.height, $ = B, q = _;
|
|
1091
1091
|
if (t.nativeStyles.transform) {
|
|
1092
|
-
const
|
|
1093
|
-
if (
|
|
1094
|
-
let
|
|
1095
|
-
|
|
1092
|
+
const N = t.nativeStyles.transform, X = N.match(/scale\(([\d.]+%?)\)/);
|
|
1093
|
+
if (X) {
|
|
1094
|
+
let f = parseFloat(X[1]);
|
|
1095
|
+
X[1].includes("%") && (f /= 100), b *= f, U *= f;
|
|
1096
1096
|
}
|
|
1097
|
-
const Z =
|
|
1097
|
+
const Z = N.match(/scaleX\(([\d.]+%?)\)/);
|
|
1098
1098
|
if (Z) {
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1099
|
+
let f = parseFloat(Z[1]);
|
|
1100
|
+
Z[1].includes("%") && (f /= 100), b *= f;
|
|
1101
|
+
}
|
|
1102
|
+
const ee = N.match(/scaleY\(([\d.]+%?)\)/);
|
|
1103
|
+
if (ee) {
|
|
1104
|
+
let f = parseFloat(ee[1]);
|
|
1105
|
+
ee[1].includes("%") && (f /= 100), U *= f;
|
|
1104
1106
|
}
|
|
1105
|
-
const
|
|
1107
|
+
const te = N.match(/translate\(([^,]+),\s*([^)]+)\)/);
|
|
1108
|
+
if (te) {
|
|
1109
|
+
const f = te[1].trim(), x = te[2].trim();
|
|
1110
|
+
let D = parseFloat(f);
|
|
1111
|
+
f.includes("%") && (D = D / 100 * t.nativeRect.width);
|
|
1112
|
+
let F = parseFloat(x);
|
|
1113
|
+
x.includes("%") && (F = F / 100 * t.nativeRect.height), $ += D, q -= F;
|
|
1114
|
+
}
|
|
1115
|
+
const ne = N.match(/translateX\(([^)]+)\)/);
|
|
1106
1116
|
if (ne) {
|
|
1107
|
-
const
|
|
1108
|
-
let
|
|
1109
|
-
|
|
1117
|
+
const f = ne[1].trim();
|
|
1118
|
+
let x = parseFloat(f);
|
|
1119
|
+
f.includes("%") && (x = x / 100 * t.nativeRect.width), $ += x;
|
|
1110
1120
|
}
|
|
1111
|
-
const
|
|
1112
|
-
if (
|
|
1113
|
-
const
|
|
1114
|
-
let
|
|
1115
|
-
|
|
1121
|
+
const ae = N.match(/translateY\(([^)]+)\)/);
|
|
1122
|
+
if (ae) {
|
|
1123
|
+
const f = ae[1].trim();
|
|
1124
|
+
let x = parseFloat(f);
|
|
1125
|
+
f.includes("%") && (x = x / 100 * t.nativeRect.height), q -= x;
|
|
1116
1126
|
}
|
|
1117
1127
|
}
|
|
1118
|
-
w.scale.set(
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
t.nativeStyles.zIndex + this.renderOrder *
|
|
1122
|
-
),
|
|
1128
|
+
w.scale.set(b, U, 1), w.position.set(
|
|
1129
|
+
$,
|
|
1130
|
+
q,
|
|
1131
|
+
t.nativeStyles.zIndex + this.renderOrder * o
|
|
1132
|
+
), V.update(
|
|
1123
1133
|
w.material,
|
|
1124
1134
|
"BOX",
|
|
1125
1135
|
t.nativeStyles,
|
|
@@ -1127,46 +1137,46 @@ class rt {
|
|
|
1127
1137
|
t.nativeRect.width,
|
|
1128
1138
|
t.nativeRect.height,
|
|
1129
1139
|
this.qualityFactor,
|
|
1130
|
-
t.isTraveler ? (
|
|
1140
|
+
t.isTraveler ? (S = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : S.texture : this.textureManager.get(t.element)
|
|
1131
1141
|
);
|
|
1132
1142
|
} else
|
|
1133
1143
|
e.userData.nativeMesh && (this.scene.remove(e.userData.nativeMesh), e.userData.nativeMesh.material instanceof y.Material && e.userData.nativeMesh.material.dispose(), delete e.userData.nativeMesh);
|
|
1134
1144
|
}
|
|
1135
1145
|
updateMeshLayers(e, t) {
|
|
1136
|
-
const r = t.visibility &
|
|
1137
|
-
if (e.layers.set(r), t.visibility &
|
|
1146
|
+
const r = t.visibility & H ? I.BASE : I.HIDDEN;
|
|
1147
|
+
if (e.layers.set(r), t.visibility & ie && e.layers.enable(I.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
|
|
1138
1148
|
const i = e.userData.nativeMesh;
|
|
1139
|
-
if (i.layers.set(
|
|
1140
|
-
i.layers.enable(
|
|
1141
|
-
for (let l = t.captureLayer; l <=
|
|
1142
|
-
l !== t.nativeLayer && e.layers.enable(
|
|
1149
|
+
if (i.layers.set(I.HIDDEN), t.visibility & H) {
|
|
1150
|
+
i.layers.enable(I.getCaptureLayer(t.nativeLayer));
|
|
1151
|
+
for (let l = t.captureLayer; l <= O.MAX_LAYERS + 1; l++)
|
|
1152
|
+
l !== t.nativeLayer && e.layers.enable(I.getCaptureLayer(l));
|
|
1143
1153
|
}
|
|
1144
|
-
} else if (t.visibility &
|
|
1145
|
-
for (let i = t.captureLayer; i <=
|
|
1146
|
-
e.layers.enable(
|
|
1154
|
+
} else if (t.visibility & H)
|
|
1155
|
+
for (let i = t.captureLayer; i <= O.MAX_LAYERS + 1; i++)
|
|
1156
|
+
e.layers.enable(I.getCaptureLayer(i));
|
|
1147
1157
|
}
|
|
1148
1158
|
captureRenderTarget(e, t, r) {
|
|
1149
1159
|
if (e.size === 0 || !r)
|
|
1150
1160
|
return;
|
|
1151
1161
|
const i = new y.Color(), l = this.renderer.getClearAlpha();
|
|
1152
1162
|
this.renderer.getClearColor(i), this.renderer.setClearColor(0, 0), this.renderer.setRenderTarget(r), this.renderer.clear(), this.renderer.autoClear = !1, this.renderer.setScissorTest(!0), this.camera.layers.set(t);
|
|
1153
|
-
const n = new y.Vector3(),
|
|
1163
|
+
const n = new y.Vector3(), a = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, o = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height, c = this.renderer.getPixelRatio();
|
|
1154
1164
|
for (const d of e) {
|
|
1155
1165
|
n.setFromMatrixPosition(d.matrixWorld), n.project(this.camera);
|
|
1156
|
-
const h = (n.x + 1) / 2 *
|
|
1157
|
-
let v = 0,
|
|
1158
|
-
typeof this.clipArea == "number" ?
|
|
1159
|
-
const m = d.scale.x *
|
|
1160
|
-
this.renderer.setScissor(
|
|
1166
|
+
const h = (n.x + 1) / 2 * a, g = (n.y + 1) / 2 * o;
|
|
1167
|
+
let v = 0, p = 1;
|
|
1168
|
+
typeof this.clipArea == "number" ? p = this.clipArea : this.clipArea.endsWith("%") ? p = parseFloat(this.clipArea) / 100 : this.clipArea.endsWith("px") && (v = parseFloat(this.clipArea));
|
|
1169
|
+
const m = d.scale.x * p + 0.5, E = d.scale.y * p + 0.5, M = h - m / 2, L = g - E / 2, R = (M * this.qualityFactor - v) / c, C = (L * this.qualityFactor - v) / c, S = (m * this.qualityFactor + v * 2) / c, w = (E * this.qualityFactor + v * 2) / c;
|
|
1170
|
+
this.renderer.setScissor(R, C, S, w), this.renderer.render(this.scene, this.camera);
|
|
1161
1171
|
}
|
|
1162
1172
|
this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(i, l);
|
|
1163
1173
|
}
|
|
1164
1174
|
render() {
|
|
1165
|
-
for (let e = 0; e <
|
|
1175
|
+
for (let e = 0; e < O.MAX_LAYERS; e++) {
|
|
1166
1176
|
const t = e + 1;
|
|
1167
1177
|
this.captureRenderTarget(
|
|
1168
1178
|
this.travelersByLayer[e],
|
|
1169
|
-
|
|
1179
|
+
I.getCaptureLayer(t),
|
|
1170
1180
|
this.renderTargets[e]
|
|
1171
1181
|
);
|
|
1172
1182
|
}
|
|
@@ -1175,67 +1185,80 @@ class rt {
|
|
|
1175
1185
|
syncMeshesByDOM() {
|
|
1176
1186
|
const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, r = this.renderer.getPixelRatio(), i = this.renderer.domElement.width / r, l = this.renderer.domElement.height / r;
|
|
1177
1187
|
this.scene.children.forEach((n) => {
|
|
1178
|
-
const
|
|
1179
|
-
if (!
|
|
1188
|
+
const a = n;
|
|
1189
|
+
if (!a.userData || !a.userData.domElement)
|
|
1180
1190
|
return;
|
|
1181
|
-
const
|
|
1182
|
-
if (!
|
|
1191
|
+
const o = a.userData.domElement;
|
|
1192
|
+
if (!o.isConnected)
|
|
1183
1193
|
return;
|
|
1184
1194
|
let c;
|
|
1185
|
-
if (
|
|
1195
|
+
if (o.nodeType === Node.TEXT_NODE) {
|
|
1186
1196
|
const h = document.createRange();
|
|
1187
|
-
h.selectNode(
|
|
1197
|
+
h.selectNode(o), c = h.getBoundingClientRect();
|
|
1188
1198
|
} else
|
|
1189
|
-
c =
|
|
1190
|
-
const d =
|
|
1199
|
+
c = o.getBoundingClientRect();
|
|
1200
|
+
const d = a.userData.domRect;
|
|
1191
1201
|
if (!d || Math.abs(c.x - d.x) > 0.5 || Math.abs(c.y - d.y) > 0.5 || Math.abs(c.width - d.width) > 0.5 || Math.abs(c.height - d.height) > 0.5) {
|
|
1192
|
-
|
|
1202
|
+
a.userData.domRect = {
|
|
1193
1203
|
x: c.x,
|
|
1194
1204
|
y: c.y,
|
|
1195
1205
|
width: c.width,
|
|
1196
1206
|
height: c.height
|
|
1197
1207
|
};
|
|
1198
|
-
let h,
|
|
1208
|
+
let h, g;
|
|
1199
1209
|
if (this.isViewport)
|
|
1200
|
-
h = c.x - window.innerWidth / 2 + c.width / 2,
|
|
1210
|
+
h = c.x - window.innerWidth / 2 + c.width / 2, g = -c.y + window.innerHeight / 2 - c.height / 2;
|
|
1201
1211
|
else {
|
|
1202
|
-
const v = c.x - e,
|
|
1203
|
-
h = v - i / 2 + c.width / 2,
|
|
1212
|
+
const v = c.x - e, p = c.y - t;
|
|
1213
|
+
h = v - i / 2 + c.width / 2, g = -p + l / 2 - c.height / 2;
|
|
1204
1214
|
}
|
|
1205
|
-
if (
|
|
1215
|
+
if (a.position.setX(h), a.position.setY(g), a.scale.set(c.width, c.height, 1), a.updateMatrixWorld(), a.material instanceof y.ShaderMaterial && V.forceUpdateUniforms(a.material, {
|
|
1206
1216
|
width: c.width,
|
|
1207
1217
|
height: c.height
|
|
1208
|
-
}),
|
|
1209
|
-
const v =
|
|
1210
|
-
let
|
|
1211
|
-
if (
|
|
1212
|
-
const
|
|
1213
|
-
if (
|
|
1214
|
-
let
|
|
1215
|
-
|
|
1218
|
+
}), a.userData.nativeMesh) {
|
|
1219
|
+
const v = a.userData.nativeMesh;
|
|
1220
|
+
let p = c.width, m = c.height, E = h, M = g;
|
|
1221
|
+
if (a.userData.nativeTransform) {
|
|
1222
|
+
const L = a.userData.nativeTransform, R = L.match(/scale\(([\d.]+%?)\)/);
|
|
1223
|
+
if (R) {
|
|
1224
|
+
let b = parseFloat(R[1]);
|
|
1225
|
+
R[1].includes("%") && (b /= 100), p *= b, m *= b;
|
|
1216
1226
|
}
|
|
1217
|
-
const
|
|
1218
|
-
if (x) {
|
|
1219
|
-
const T = x[1].trim(), A = x[2].trim();
|
|
1220
|
-
let I = parseFloat(T);
|
|
1221
|
-
T.includes("%") && (I = I / 100 * c.width);
|
|
1222
|
-
let q = parseFloat(A);
|
|
1223
|
-
A.includes("%") && (q = q / 100 * c.height), b += I, L -= q;
|
|
1224
|
-
}
|
|
1225
|
-
const C = M.match(/translateX\(([^)]+)\)/);
|
|
1227
|
+
const C = L.match(/scaleX\(([\d.]+%?)\)/);
|
|
1226
1228
|
if (C) {
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1229
|
+
let b = parseFloat(C[1]);
|
|
1230
|
+
C[1].includes("%") && (b /= 100), p *= b;
|
|
1231
|
+
}
|
|
1232
|
+
const S = L.match(/scaleY\(([\d.]+%?)\)/);
|
|
1233
|
+
if (S) {
|
|
1234
|
+
let b = parseFloat(S[1]);
|
|
1235
|
+
S[1].includes("%") && (b /= 100), m *= b;
|
|
1230
1236
|
}
|
|
1231
|
-
const w =
|
|
1237
|
+
const w = L.match(/translate\(([^,]+),\s*([^)]+)\)/);
|
|
1232
1238
|
if (w) {
|
|
1233
|
-
const
|
|
1234
|
-
let
|
|
1235
|
-
|
|
1239
|
+
const b = w[1].trim(), U = w[2].trim();
|
|
1240
|
+
let $ = parseFloat(b);
|
|
1241
|
+
b.includes("%") && ($ = $ / 100 * c.width);
|
|
1242
|
+
let q = parseFloat(U);
|
|
1243
|
+
U.includes("%") && (q = q / 100 * c.height), E += $, M -= q;
|
|
1244
|
+
}
|
|
1245
|
+
const B = L.match(/translateX\(([^)]+)\)/);
|
|
1246
|
+
if (B) {
|
|
1247
|
+
const b = B[1].trim();
|
|
1248
|
+
let U = parseFloat(b);
|
|
1249
|
+
b.includes("%") && (U = U / 100 * c.width), E += U;
|
|
1250
|
+
}
|
|
1251
|
+
const _ = L.match(/translateY\(([^)]+)\)/);
|
|
1252
|
+
if (_) {
|
|
1253
|
+
const b = _[1].trim();
|
|
1254
|
+
let U = parseFloat(b);
|
|
1255
|
+
b.includes("%") && (U = U / 100 * c.height), M -= U;
|
|
1236
1256
|
}
|
|
1237
1257
|
}
|
|
1238
|
-
v.position.setX(
|
|
1258
|
+
v.position.setX(E), v.position.setY(M), v.scale.set(p, m, 1), v.updateMatrixWorld(), v.material instanceof y.ShaderMaterial && V.forceUpdateUniforms(v.material, {
|
|
1259
|
+
width: p,
|
|
1260
|
+
height: m
|
|
1261
|
+
});
|
|
1239
1262
|
}
|
|
1240
1263
|
}
|
|
1241
1264
|
});
|
|
@@ -1246,14 +1269,14 @@ function it(s) {
|
|
|
1246
1269
|
let r = "", i = null, l = -1;
|
|
1247
1270
|
const n = (c, d) => {
|
|
1248
1271
|
for (let h = 0; h < c.length; h++) {
|
|
1249
|
-
const
|
|
1272
|
+
const g = c[h], v = document.createRange();
|
|
1250
1273
|
v.setStart(s, d + h), v.setEnd(s, d + h + 1);
|
|
1251
|
-
const
|
|
1252
|
-
if (
|
|
1253
|
-
r +=
|
|
1274
|
+
const p = v.getBoundingClientRect();
|
|
1275
|
+
if (p.width === 0 && p.height === 0) {
|
|
1276
|
+
r += g;
|
|
1254
1277
|
continue;
|
|
1255
1278
|
}
|
|
1256
|
-
l === -1 || Math.abs(
|
|
1279
|
+
l === -1 || Math.abs(p.top - l) > p.height / 2 ? (r && i && t.push({
|
|
1257
1280
|
text: r,
|
|
1258
1281
|
rect: {
|
|
1259
1282
|
left: i.left,
|
|
@@ -1261,31 +1284,31 @@ function it(s) {
|
|
|
1261
1284
|
width: i.right - i.left,
|
|
1262
1285
|
height: i.bottom - i.top
|
|
1263
1286
|
}
|
|
1264
|
-
}), r =
|
|
1265
|
-
left:
|
|
1266
|
-
top:
|
|
1267
|
-
right:
|
|
1268
|
-
bottom:
|
|
1269
|
-
}, l =
|
|
1287
|
+
}), r = g, i = {
|
|
1288
|
+
left: p.left,
|
|
1289
|
+
top: p.top,
|
|
1290
|
+
right: p.right,
|
|
1291
|
+
bottom: p.bottom
|
|
1292
|
+
}, l = p.top) : (r += g, i && (i.left = Math.min(i.left, p.left), i.top = Math.min(i.top, p.top), i.right = Math.max(i.right, p.right), i.bottom = Math.max(
|
|
1270
1293
|
i.bottom,
|
|
1271
|
-
|
|
1294
|
+
p.bottom
|
|
1272
1295
|
)));
|
|
1273
1296
|
}
|
|
1274
|
-
},
|
|
1275
|
-
let
|
|
1276
|
-
for (const c of
|
|
1297
|
+
}, a = e.match(/[^\s\-]+\-?|\-|\s+/g) || [];
|
|
1298
|
+
let o = 0;
|
|
1299
|
+
for (const c of a) {
|
|
1277
1300
|
const d = document.createRange();
|
|
1278
|
-
d.setStart(s,
|
|
1301
|
+
d.setStart(s, o), d.setEnd(s, o + c.length);
|
|
1279
1302
|
const h = d.getClientRects();
|
|
1280
1303
|
if (h.length > 1)
|
|
1281
|
-
n(c,
|
|
1304
|
+
n(c, o);
|
|
1282
1305
|
else {
|
|
1283
|
-
const
|
|
1284
|
-
if (
|
|
1285
|
-
r += c,
|
|
1306
|
+
const g = h.length === 1 ? h[0] : d.getBoundingClientRect();
|
|
1307
|
+
if (g.width === 0 && g.height === 0) {
|
|
1308
|
+
r += c, o += c.length;
|
|
1286
1309
|
continue;
|
|
1287
1310
|
}
|
|
1288
|
-
l === -1 || Math.abs(
|
|
1311
|
+
l === -1 || Math.abs(g.top - l) > g.height / 2 ? (r && i && t.push({
|
|
1289
1312
|
text: r,
|
|
1290
1313
|
rect: {
|
|
1291
1314
|
left: i.left,
|
|
@@ -1294,16 +1317,16 @@ function it(s) {
|
|
|
1294
1317
|
height: i.bottom - i.top
|
|
1295
1318
|
}
|
|
1296
1319
|
}), r = c, i = {
|
|
1297
|
-
left:
|
|
1298
|
-
top:
|
|
1299
|
-
right:
|
|
1300
|
-
bottom:
|
|
1301
|
-
}, l =
|
|
1320
|
+
left: g.left,
|
|
1321
|
+
top: g.top,
|
|
1322
|
+
right: g.right,
|
|
1323
|
+
bottom: g.bottom
|
|
1324
|
+
}, l = g.top) : (r += c, i && (i.left = Math.min(i.left, g.left), i.top = Math.min(i.top, g.top), i.right = Math.max(i.right, g.right), i.bottom = Math.max(
|
|
1302
1325
|
i.bottom,
|
|
1303
|
-
|
|
1326
|
+
g.bottom
|
|
1304
1327
|
)));
|
|
1305
1328
|
}
|
|
1306
|
-
|
|
1329
|
+
o += c.length;
|
|
1307
1330
|
}
|
|
1308
1331
|
return r && i && t.push({
|
|
1309
1332
|
text: r,
|
|
@@ -1333,50 +1356,50 @@ function Me(s) {
|
|
|
1333
1356
|
letterSpacing: r
|
|
1334
1357
|
};
|
|
1335
1358
|
}
|
|
1336
|
-
function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, l = 2, n,
|
|
1337
|
-
var
|
|
1359
|
+
function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, l = 2, n, a) {
|
|
1360
|
+
var X, Z, ee, te, ne, ae;
|
|
1338
1361
|
if (s.nodeType === Node.TEXT_NODE) {
|
|
1339
|
-
const
|
|
1340
|
-
if (!
|
|
1362
|
+
const f = s;
|
|
1363
|
+
if (!f.textContent || !f.textContent.trim())
|
|
1341
1364
|
return null;
|
|
1342
|
-
const
|
|
1343
|
-
if (
|
|
1365
|
+
const x = f.textContent.replace(/\s+/g, " ");
|
|
1366
|
+
if (x.length === 0)
|
|
1344
1367
|
return null;
|
|
1345
|
-
const
|
|
1346
|
-
if (
|
|
1368
|
+
const D = it(f);
|
|
1369
|
+
if (D.length === 0)
|
|
1347
1370
|
return null;
|
|
1348
|
-
const
|
|
1371
|
+
const F = f.parentElement, k = F ? window.getComputedStyle(F) : null;
|
|
1349
1372
|
if (!k)
|
|
1350
1373
|
return null;
|
|
1351
|
-
const
|
|
1374
|
+
const P = Math.min(...D.map((T) => T.rect.left)), z = Math.min(...D.map((T) => T.rect.top)), j = Math.max(...D.map((T) => T.rect.left + T.rect.width)), A = Math.max(...D.map((T) => T.rect.top + T.rect.height));
|
|
1352
1375
|
return {
|
|
1353
1376
|
id: Math.random().toString(36).substring(2, 9),
|
|
1354
1377
|
type: "TEXT",
|
|
1355
|
-
element:
|
|
1378
|
+
element: f,
|
|
1356
1379
|
rect: {
|
|
1357
|
-
x:
|
|
1380
|
+
x: P + window.scrollX,
|
|
1358
1381
|
y: z + window.scrollY,
|
|
1359
|
-
width: j -
|
|
1360
|
-
height:
|
|
1382
|
+
width: j - P,
|
|
1383
|
+
height: A - z
|
|
1361
1384
|
},
|
|
1362
1385
|
styles: {
|
|
1363
1386
|
backgroundColor: "transparent",
|
|
1364
1387
|
backgroundImage: "",
|
|
1365
|
-
opacity:
|
|
1388
|
+
opacity: F && F.dataset[K.KEY] === K.VALUES.HIDE ? 1 : parseFloat(k.opacity),
|
|
1366
1389
|
zIndex: (isNaN(parseInt(k.zIndex)) ? 0 : parseInt(k.zIndex)) + i,
|
|
1367
1390
|
borderRadius: "0px",
|
|
1368
1391
|
borderColor: "transparent",
|
|
1369
1392
|
borderWidth: "0px",
|
|
1370
1393
|
isTraveler: !1
|
|
1371
1394
|
},
|
|
1372
|
-
textContent:
|
|
1373
|
-
textLines:
|
|
1374
|
-
text:
|
|
1395
|
+
textContent: x,
|
|
1396
|
+
textLines: D.map((T) => ({
|
|
1397
|
+
text: T.text.trim(),
|
|
1375
1398
|
rect: {
|
|
1376
|
-
x:
|
|
1377
|
-
y:
|
|
1378
|
-
width:
|
|
1379
|
-
height:
|
|
1399
|
+
x: T.rect.left + window.scrollX,
|
|
1400
|
+
y: T.rect.top + window.scrollY,
|
|
1401
|
+
width: T.rect.width,
|
|
1402
|
+
height: T.rect.height
|
|
1380
1403
|
}
|
|
1381
1404
|
})),
|
|
1382
1405
|
textStyles: Me(k),
|
|
@@ -1386,234 +1409,234 @@ function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, l = 2, n, o) {
|
|
|
1386
1409
|
captureLayer: r,
|
|
1387
1410
|
isFixed: k.position === "fixed",
|
|
1388
1411
|
nativeLayer: n,
|
|
1389
|
-
nativeStyles:
|
|
1412
|
+
nativeStyles: a ? J(J({
|
|
1390
1413
|
backgroundColor: "transparent",
|
|
1391
1414
|
backgroundImage: "",
|
|
1392
|
-
opacity:
|
|
1415
|
+
opacity: F && F.dataset[K.KEY] === K.VALUES.HIDE ? 1 : parseFloat(k.opacity),
|
|
1393
1416
|
zIndex: (isNaN(parseInt(k.zIndex)) ? 0 : parseInt(k.zIndex)) + i,
|
|
1394
1417
|
borderRadius: "0px",
|
|
1395
1418
|
borderColor: "transparent",
|
|
1396
1419
|
borderWidth: "0px",
|
|
1397
1420
|
isTraveler: !1
|
|
1398
|
-
}, Me(k)),
|
|
1399
|
-
nativeRect:
|
|
1400
|
-
x:
|
|
1421
|
+
}, Me(k)), a) : void 0,
|
|
1422
|
+
nativeRect: a ? {
|
|
1423
|
+
x: P + window.scrollX,
|
|
1401
1424
|
y: z + window.scrollY,
|
|
1402
|
-
width: j -
|
|
1403
|
-
height:
|
|
1425
|
+
width: j - P,
|
|
1426
|
+
height: A - z
|
|
1404
1427
|
} : void 0,
|
|
1405
1428
|
children: []
|
|
1406
1429
|
};
|
|
1407
1430
|
}
|
|
1408
1431
|
if (s.nodeType !== Node.ELEMENT_NODE)
|
|
1409
1432
|
return null;
|
|
1410
|
-
const
|
|
1433
|
+
const o = s, c = o.dataset[W.KEY];
|
|
1411
1434
|
let d = t, h = t;
|
|
1412
1435
|
if (c) {
|
|
1413
|
-
const
|
|
1414
|
-
for (const
|
|
1415
|
-
if (!Te.includes(
|
|
1436
|
+
const f = new Set(c.split(/\s+/));
|
|
1437
|
+
for (const x of f)
|
|
1438
|
+
if (!Te.includes(x))
|
|
1416
1439
|
throw new Error(
|
|
1417
|
-
`[MirageEngine] Invalid filter token: '${
|
|
1440
|
+
`[MirageEngine] Invalid filter token: '${x}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
|
|
1418
1441
|
);
|
|
1419
|
-
if (
|
|
1442
|
+
if (f.has(W.VALUES.END))
|
|
1420
1443
|
return null;
|
|
1421
|
-
if (
|
|
1444
|
+
if (f.has(W.VALUES.INCLUDE_TREE) && f.has(W.VALUES.EXCLUDE_TREE))
|
|
1422
1445
|
throw new Error(
|
|
1423
1446
|
"[MirageEngine] Conflicting filters: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
|
|
1424
1447
|
);
|
|
1425
|
-
if (
|
|
1448
|
+
if (f.has(W.VALUES.INCLUDE_SELF) && f.has(W.VALUES.EXCLUDE_SELF))
|
|
1426
1449
|
throw new Error(
|
|
1427
1450
|
"[MirageEngine] Conflicting filters: 'include-self' and 'exclude-self' cannot be used together on the same element."
|
|
1428
1451
|
);
|
|
1429
|
-
|
|
1452
|
+
f.has(W.VALUES.INCLUDE_TREE) ? d = d | H : f.has(W.VALUES.EXCLUDE_TREE) && (d = d & ~H), h = d, f.has(W.VALUES.INCLUDE_SELF) ? h = h | H : f.has(W.VALUES.EXCLUDE_SELF) && (h = h & ~H);
|
|
1430
1453
|
}
|
|
1431
|
-
const
|
|
1432
|
-
if (
|
|
1433
|
-
const
|
|
1434
|
-
for (const
|
|
1435
|
-
if (!Te.includes(
|
|
1454
|
+
const g = o.dataset[G.KEY];
|
|
1455
|
+
if (g) {
|
|
1456
|
+
const f = new Set(g.split(/\s+/));
|
|
1457
|
+
for (const x of f)
|
|
1458
|
+
if (!Te.includes(x))
|
|
1436
1459
|
throw new Error(
|
|
1437
|
-
`[MirageEngine] Invalid select token: '${
|
|
1460
|
+
`[MirageEngine] Invalid select token: '${x}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
|
|
1438
1461
|
);
|
|
1439
|
-
if (
|
|
1462
|
+
if (f.has(G.VALUES.END))
|
|
1440
1463
|
return null;
|
|
1441
|
-
if (
|
|
1464
|
+
if (f.has(G.VALUES.INCLUDE_TREE) && f.has(G.VALUES.EXCLUDE_TREE))
|
|
1442
1465
|
throw new Error(
|
|
1443
1466
|
"[MirageEngine] Conflicting selects: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
|
|
1444
1467
|
);
|
|
1445
|
-
if (
|
|
1468
|
+
if (f.has(G.VALUES.INCLUDE_SELF) && f.has(G.VALUES.EXCLUDE_SELF))
|
|
1446
1469
|
throw new Error(
|
|
1447
1470
|
"[MirageEngine] Conflicting selects: 'include-self' and 'exclude-self' cannot be used together on the same element."
|
|
1448
1471
|
);
|
|
1449
|
-
|
|
1472
|
+
f.has(G.VALUES.INCLUDE_TREE) ? d = d | ie : f.has(G.VALUES.EXCLUDE_TREE) && (d = d & ~ie), h = d, f.has(G.VALUES.INCLUDE_SELF) ? h = h | ie : f.has(G.VALUES.EXCLUDE_SELF) && (h = h & ~ie);
|
|
1450
1473
|
}
|
|
1451
|
-
const v =
|
|
1452
|
-
let
|
|
1474
|
+
const v = o.dataset[O.KEY];
|
|
1475
|
+
let p = !1, m = a ? J({}, a) : {}, E = n;
|
|
1453
1476
|
if (v) {
|
|
1454
|
-
let
|
|
1455
|
-
const
|
|
1456
|
-
let
|
|
1457
|
-
if (
|
|
1458
|
-
|
|
1459
|
-
const
|
|
1477
|
+
let f = 1;
|
|
1478
|
+
const x = v.indexOf("{"), D = v.lastIndexOf("}");
|
|
1479
|
+
let F = v;
|
|
1480
|
+
if (x !== -1 && D !== -1 && D > x) {
|
|
1481
|
+
F = v.substring(0, x).trim();
|
|
1482
|
+
const A = v.substring(x, D + 1);
|
|
1460
1483
|
try {
|
|
1461
|
-
m = new Function("return " +
|
|
1462
|
-
} catch (
|
|
1484
|
+
m = new Function("return " + A)();
|
|
1485
|
+
} catch (T) {
|
|
1463
1486
|
console.warn(
|
|
1464
|
-
`[MirageEngine] Failed to parse travel styles JSON: ${
|
|
1487
|
+
`[MirageEngine] Failed to parse travel styles JSON: ${A}`
|
|
1465
1488
|
);
|
|
1466
1489
|
}
|
|
1467
1490
|
}
|
|
1468
|
-
const k =
|
|
1469
|
-
let
|
|
1470
|
-
const z = k.indexOf(
|
|
1491
|
+
const k = F.split(/\s+/);
|
|
1492
|
+
let P = !1;
|
|
1493
|
+
const z = k.indexOf(O.VALUES.TRAVELER);
|
|
1471
1494
|
if (z !== -1) {
|
|
1472
|
-
|
|
1473
|
-
const
|
|
1474
|
-
if (
|
|
1475
|
-
|
|
1495
|
+
p = !0, P = !0;
|
|
1496
|
+
const A = k[z + 1];
|
|
1497
|
+
if (A && !isNaN(parseInt(A, 10)))
|
|
1498
|
+
f = parseInt(A, 10);
|
|
1476
1499
|
else {
|
|
1477
|
-
const
|
|
1478
|
-
|
|
1500
|
+
const T = k.find((re) => !isNaN(parseInt(re, 10)));
|
|
1501
|
+
T && (f = parseInt(T, 10));
|
|
1479
1502
|
}
|
|
1480
1503
|
}
|
|
1481
|
-
const j = k.indexOf(
|
|
1504
|
+
const j = k.indexOf(O.VALUES.NATIVE);
|
|
1482
1505
|
if (j !== -1) {
|
|
1483
|
-
const
|
|
1484
|
-
if (
|
|
1485
|
-
|
|
1486
|
-
else if (!
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1506
|
+
const A = k[j + 1];
|
|
1507
|
+
if (A && !isNaN(parseInt(A, 10)))
|
|
1508
|
+
E = parseInt(A, 10);
|
|
1509
|
+
else if (!p) {
|
|
1510
|
+
const T = k.find((re) => !isNaN(parseInt(re, 10)));
|
|
1511
|
+
T && (E = parseInt(T, 10));
|
|
1489
1512
|
}
|
|
1490
1513
|
}
|
|
1491
|
-
if (
|
|
1492
|
-
const
|
|
1493
|
-
if (
|
|
1514
|
+
if (P) {
|
|
1515
|
+
const A = f + 1;
|
|
1516
|
+
if (A < r)
|
|
1494
1517
|
throw new Error(
|
|
1495
|
-
`[MirageEngine] Traveler layer (${
|
|
1518
|
+
`[MirageEngine] Traveler layer (${f}) cannot be smaller than inherited capture layer (${r - 1}).`
|
|
1496
1519
|
);
|
|
1497
|
-
r = Math.min(
|
|
1520
|
+
r = Math.min(A, O.MAX_LAYERS + 1);
|
|
1498
1521
|
}
|
|
1499
1522
|
}
|
|
1500
|
-
const
|
|
1501
|
-
let
|
|
1502
|
-
|
|
1503
|
-
const
|
|
1504
|
-
if (
|
|
1523
|
+
const M = o.dataset[Ve.KEY];
|
|
1524
|
+
let L;
|
|
1525
|
+
M && (L = JSON.parse(M));
|
|
1526
|
+
const R = o.getBoundingClientRect(), C = window.getComputedStyle(o);
|
|
1527
|
+
if (R.width === 0 || R.height === 0 || C.display === "none")
|
|
1505
1528
|
return null;
|
|
1506
|
-
let
|
|
1507
|
-
|
|
1508
|
-
const w = parseInt(
|
|
1509
|
-
let
|
|
1510
|
-
if (
|
|
1511
|
-
|
|
1512
|
-
else if (
|
|
1513
|
-
const
|
|
1514
|
-
const Y = window.getComputedStyle(
|
|
1515
|
-
fe && fe !== "none" && (
|
|
1516
|
-
const ge =
|
|
1517
|
-
ge && ge !== "none" && (
|
|
1518
|
-
const be =
|
|
1519
|
-
be && (
|
|
1529
|
+
let S = o.getAttribute("data-mid");
|
|
1530
|
+
S || (S = Math.random().toString(36).substring(2, 11), o.setAttribute("data-mid", S));
|
|
1531
|
+
const w = parseInt(C.zIndex), B = (isNaN(w) ? 0 : w) + i;
|
|
1532
|
+
let _;
|
|
1533
|
+
if (o.tagName === "IMG")
|
|
1534
|
+
_ = o.src;
|
|
1535
|
+
else if (o.tagName.toLowerCase() === "svg") {
|
|
1536
|
+
const f = o.cloneNode(!0), x = m == null ? void 0 : m.color, D = m == null ? void 0 : m.fill, F = m == null ? void 0 : m.stroke, k = m == null ? void 0 : m.opacity, P = (T, re) => {
|
|
1537
|
+
const Y = window.getComputedStyle(T), oe = re, Fe = Y.fill === Y.color, Be = Y.stroke === Y.color, fe = D || (Fe ? x : void 0) || Y.fill;
|
|
1538
|
+
fe && fe !== "none" && (oe.style.fill = fe);
|
|
1539
|
+
const ge = F || (Be ? x : void 0) || Y.stroke;
|
|
1540
|
+
ge && ge !== "none" && (oe.style.stroke = ge), Y.strokeWidth && Y.strokeWidth !== "0px" && (oe.style.strokeWidth = Y.strokeWidth);
|
|
1541
|
+
const be = x || Y.color;
|
|
1542
|
+
be && (oe.style.color = be);
|
|
1520
1543
|
const pe = k || Y.opacity;
|
|
1521
|
-
pe && pe !== "1" && (
|
|
1522
|
-
for (let he = 0; he <
|
|
1523
|
-
|
|
1544
|
+
pe && pe !== "1" && (oe.style.opacity = pe);
|
|
1545
|
+
for (let he = 0; he < T.children.length; he++)
|
|
1546
|
+
P(T.children[he], re.children[he]);
|
|
1524
1547
|
};
|
|
1525
|
-
|
|
1526
|
-
const z =
|
|
1527
|
-
|
|
1528
|
-
let
|
|
1529
|
-
|
|
1548
|
+
P(o, f);
|
|
1549
|
+
const z = o.getBoundingClientRect(), j = window.devicePixelRatio * l;
|
|
1550
|
+
f.hasAttribute("viewBox") || f.setAttribute("viewBox", `0 0 ${z.width} ${z.height}`), f.setAttribute("width", (z.width * j).toString()), f.setAttribute("height", (z.height * j).toString());
|
|
1551
|
+
let A = new XMLSerializer().serializeToString(f);
|
|
1552
|
+
A.includes("xmlns=") || (A = A.replace(
|
|
1530
1553
|
"<svg",
|
|
1531
1554
|
'<svg xmlns="http://www.w3.org/2000/svg"'
|
|
1532
|
-
)),
|
|
1533
|
-
} else if (
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1536
|
-
}
|
|
1537
|
-
const
|
|
1538
|
-
backgroundColor:
|
|
1539
|
-
backgroundImage:
|
|
1540
|
-
opacity:
|
|
1541
|
-
zIndex:
|
|
1542
|
-
borderRadius:
|
|
1543
|
-
borderColor:
|
|
1544
|
-
borderWidth:
|
|
1545
|
-
imageSrc:
|
|
1546
|
-
isTraveler:
|
|
1547
|
-
},
|
|
1548
|
-
let
|
|
1549
|
-
const
|
|
1550
|
-
return
|
|
1551
|
-
const
|
|
1552
|
-
|
|
1555
|
+
)), _ = `data:image/svg+xml;utf8,${encodeURIComponent(A)}`;
|
|
1556
|
+
} else if (C.backgroundImage && C.backgroundImage !== "none") {
|
|
1557
|
+
const f = C.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
|
|
1558
|
+
f && (_ = f[1]);
|
|
1559
|
+
}
|
|
1560
|
+
const b = {
|
|
1561
|
+
backgroundColor: C.backgroundColor,
|
|
1562
|
+
backgroundImage: C.backgroundImage,
|
|
1563
|
+
opacity: o.dataset[K.KEY] === K.VALUES.HIDE ? 1 : parseFloat(C.opacity),
|
|
1564
|
+
zIndex: B,
|
|
1565
|
+
borderRadius: C.borderRadius,
|
|
1566
|
+
borderColor: C.borderColor,
|
|
1567
|
+
borderWidth: C.borderWidth,
|
|
1568
|
+
imageSrc: _,
|
|
1569
|
+
isTraveler: p
|
|
1570
|
+
}, U = b;
|
|
1571
|
+
let $, q;
|
|
1572
|
+
const N = [];
|
|
1573
|
+
return o.tagName.toLowerCase() !== "svg" && Array.from(o.childNodes).forEach((f) => {
|
|
1574
|
+
const x = f.nodeType === Node.TEXT_NODE ? h : d, D = Ue(
|
|
1575
|
+
f,
|
|
1553
1576
|
e,
|
|
1554
|
-
|
|
1577
|
+
x,
|
|
1555
1578
|
r,
|
|
1556
|
-
|
|
1579
|
+
B,
|
|
1557
1580
|
l,
|
|
1558
|
-
|
|
1559
|
-
|
|
1581
|
+
f.nodeType === Node.TEXT_NODE ? E : void 0,
|
|
1582
|
+
f.nodeType === Node.TEXT_NODE && Object.keys(m).length > 0 ? m : void 0
|
|
1560
1583
|
);
|
|
1561
|
-
|
|
1584
|
+
D && N.push(D);
|
|
1562
1585
|
}), {
|
|
1563
|
-
id:
|
|
1586
|
+
id: S,
|
|
1564
1587
|
type: "BOX",
|
|
1565
|
-
element:
|
|
1588
|
+
element: o,
|
|
1566
1589
|
rect: {
|
|
1567
|
-
x:
|
|
1568
|
-
y:
|
|
1569
|
-
width:
|
|
1570
|
-
height:
|
|
1590
|
+
x: R.left + window.scrollX,
|
|
1591
|
+
y: R.top + window.scrollY,
|
|
1592
|
+
width: R.width,
|
|
1593
|
+
height: R.height
|
|
1571
1594
|
},
|
|
1572
|
-
styles:
|
|
1573
|
-
textContent:
|
|
1574
|
-
textStyles:
|
|
1595
|
+
styles: U,
|
|
1596
|
+
textContent: $,
|
|
1597
|
+
textStyles: q,
|
|
1575
1598
|
dirtyMask: e,
|
|
1576
1599
|
visibility: h,
|
|
1577
|
-
isTraveler:
|
|
1600
|
+
isTraveler: p,
|
|
1578
1601
|
captureLayer: r,
|
|
1579
|
-
nativeLayer:
|
|
1580
|
-
nativeStyles:
|
|
1581
|
-
backgroundColor: (
|
|
1582
|
-
backgroundImage: (Z = m.backgroundImage) != null ? Z :
|
|
1583
|
-
opacity: (
|
|
1584
|
-
zIndex: m.zIndex !== void 0 ? m.zIndex +
|
|
1585
|
-
borderRadius: (
|
|
1586
|
-
borderColor: (
|
|
1587
|
-
borderWidth: (
|
|
1588
|
-
isTraveler:
|
|
1602
|
+
nativeLayer: E,
|
|
1603
|
+
nativeStyles: E !== void 0 ? xe(J({}, b), {
|
|
1604
|
+
backgroundColor: (X = m.backgroundColor) != null ? X : b.backgroundColor,
|
|
1605
|
+
backgroundImage: (Z = m.backgroundImage) != null ? Z : b.backgroundImage,
|
|
1606
|
+
opacity: (ee = m.opacity) != null ? ee : b.opacity,
|
|
1607
|
+
zIndex: m.zIndex !== void 0 ? m.zIndex + B : b.zIndex,
|
|
1608
|
+
borderRadius: (te = m.borderRadius) != null ? te : b.borderRadius,
|
|
1609
|
+
borderColor: (ne = m.borderColor) != null ? ne : b.borderColor,
|
|
1610
|
+
borderWidth: (ae = m.borderWidth) != null ? ae : b.borderWidth,
|
|
1611
|
+
isTraveler: b.isTraveler,
|
|
1589
1612
|
transform: m.transform
|
|
1590
1613
|
}) : void 0,
|
|
1591
|
-
nativeRect:
|
|
1592
|
-
x: m.x !== void 0 ? parseFloat(m.x) :
|
|
1593
|
-
y: m.y !== void 0 ? parseFloat(m.y) :
|
|
1594
|
-
width: m.width !== void 0 ? parseFloat(m.width) :
|
|
1595
|
-
height: m.height !== void 0 ? parseFloat(m.height) :
|
|
1614
|
+
nativeRect: E !== void 0 ? {
|
|
1615
|
+
x: m.x !== void 0 ? parseFloat(m.x) : R.left + window.scrollX,
|
|
1616
|
+
y: m.y !== void 0 ? parseFloat(m.y) : R.top + window.scrollY,
|
|
1617
|
+
width: m.width !== void 0 ? parseFloat(m.width) : R.width,
|
|
1618
|
+
height: m.height !== void 0 ? parseFloat(m.height) : R.height
|
|
1596
1619
|
} : void 0,
|
|
1597
|
-
isFixed:
|
|
1598
|
-
children:
|
|
1599
|
-
shaderHooks:
|
|
1620
|
+
isFixed: C.position === "fixed",
|
|
1621
|
+
children: N,
|
|
1622
|
+
shaderHooks: L
|
|
1600
1623
|
};
|
|
1601
1624
|
}
|
|
1602
1625
|
function st(s, e) {
|
|
1603
1626
|
e.size !== 0 && e.forEach((t, r) => {
|
|
1604
|
-
var l, n,
|
|
1627
|
+
var l, n, a, o;
|
|
1605
1628
|
const i = s.get(r);
|
|
1606
|
-
!i || !i.userData.basePosition || (
|
|
1629
|
+
!i || !i.userData.basePosition || (V.forceUpdateUniforms(i.material, {
|
|
1607
1630
|
backgroundColor: t.backgroundColor,
|
|
1608
1631
|
backgroundImage: t.backgroundImage,
|
|
1609
1632
|
opacity: t.opacity,
|
|
1610
1633
|
borderRadius: (n = t.borderRadius) != null ? n : (l = i.userData.baseStyles) == null ? void 0 : l.borderRadius
|
|
1611
1634
|
// width and height are no longer updated here, they are updated in syncMeshesByDOM
|
|
1612
|
-
}), i.userData.nativeMesh &&
|
|
1635
|
+
}), i.userData.nativeMesh && V.forceUpdateUniforms(i.userData.nativeMesh.material, {
|
|
1613
1636
|
backgroundColor: t.backgroundColor,
|
|
1614
1637
|
backgroundImage: t.backgroundImage,
|
|
1615
1638
|
opacity: t.opacity,
|
|
1616
|
-
borderRadius: (
|
|
1639
|
+
borderRadius: (o = t.borderRadius) != null ? o : (a = i.userData.baseStyles) == null ? void 0 : a.borderRadius
|
|
1617
1640
|
}));
|
|
1618
1641
|
});
|
|
1619
1642
|
}
|
|
@@ -1627,16 +1650,16 @@ class nt {
|
|
|
1627
1650
|
this.target = e, this.renderer = t, this.registry = r, this.tracker = new De(e, {
|
|
1628
1651
|
resizeDebounce: i.resizeDebounce
|
|
1629
1652
|
}), this.tracker.onLayoutChange.add((l, n) => {
|
|
1630
|
-
document.querySelector(`[${
|
|
1631
|
-
const
|
|
1653
|
+
document.querySelector(`[${O.NAME}~='${O.VALUES.TRAVELER}']`) !== null && !this.isTravelEnabled && (this.isTravelEnabled = !0, this.renderer.createRenderTarget());
|
|
1654
|
+
const o = Ue(
|
|
1632
1655
|
this.target,
|
|
1633
1656
|
l,
|
|
1634
|
-
|
|
1657
|
+
H,
|
|
1635
1658
|
1,
|
|
1636
1659
|
0,
|
|
1637
1660
|
this.renderer.qualityFactor
|
|
1638
1661
|
);
|
|
1639
|
-
|
|
1662
|
+
o && this.renderer.syncScene(o, n);
|
|
1640
1663
|
}), this.tracker.onStyleChange.add((l) => {
|
|
1641
1664
|
st(this.registry, l);
|
|
1642
1665
|
}), this.tracker.onRender.add(() => {
|
|
@@ -1650,7 +1673,7 @@ class nt {
|
|
|
1650
1673
|
this.tracker.stop();
|
|
1651
1674
|
}
|
|
1652
1675
|
}
|
|
1653
|
-
class
|
|
1676
|
+
class at {
|
|
1654
1677
|
constructor() {
|
|
1655
1678
|
u(this, "store");
|
|
1656
1679
|
this.store = /* @__PURE__ */ new WeakMap();
|
|
@@ -1675,20 +1698,20 @@ class ot {
|
|
|
1675
1698
|
this.store.delete(e);
|
|
1676
1699
|
}
|
|
1677
1700
|
}
|
|
1678
|
-
class
|
|
1701
|
+
class ot {
|
|
1679
1702
|
constructor(e, t) {
|
|
1680
1703
|
u(this, "renderer");
|
|
1681
1704
|
u(this, "syncer");
|
|
1682
1705
|
u(this, "target");
|
|
1683
1706
|
u(this, "registry");
|
|
1684
1707
|
var i, l, n;
|
|
1685
|
-
if (this.target = e, this.registry = new
|
|
1686
|
-
const
|
|
1687
|
-
|
|
1708
|
+
if (this.target = e, this.registry = new at(), !document.getElementById("mirage-engine-styles")) {
|
|
1709
|
+
const a = document.createElement("style");
|
|
1710
|
+
a.id = "mirage-engine-styles", a.textContent = `
|
|
1688
1711
|
[${K.NAME}="${K.VALUES.HIDE}"] {
|
|
1689
1712
|
opacity: 0 !important;
|
|
1690
1713
|
}
|
|
1691
|
-
`, document.head.appendChild(
|
|
1714
|
+
`, document.head.appendChild(a);
|
|
1692
1715
|
}
|
|
1693
1716
|
let r;
|
|
1694
1717
|
if (t.mode === "duplicate" ? r = (l = (i = t.container) != null ? i : this.target.parentElement) != null ? l : void 0 : r = (n = this.target.parentElement) != null ? n : void 0, !r)
|
|
@@ -1818,7 +1841,7 @@ class ht {
|
|
|
1818
1841
|
u(this, "_sandwich");
|
|
1819
1842
|
if (!e)
|
|
1820
1843
|
throw new Error("[Mirage] Target element is required.");
|
|
1821
|
-
if (this._engine = new
|
|
1844
|
+
if (this._engine = new ot(e, t), t.sandwich !== !1) {
|
|
1822
1845
|
const r = typeof t.sandwich == "object" ? t.sandwich : {};
|
|
1823
1846
|
this._sandwich = new ct({
|
|
1824
1847
|
frontSelector: r.frontSelector || `[${Se.NAME}='${Se.VALUES.FRONT}']`
|