mirage-engine 0.3.13 → 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 +309 -296
- package/dist/mirage-engine.umd.js +11 -11
- package/package.json +2 -2
package/dist/mirage-engine.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
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 ? Oe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t,
|
|
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
12
|
}, xe = (s, e) => _e(s, Ne(e));
|
|
13
13
|
var u = (s, e, t) => (me(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
@@ -34,7 +34,7 @@ const Ae = {
|
|
|
34
34
|
INCLUDE_SELF: "include-self",
|
|
35
35
|
EXCLUDE_SELF: "exclude-self",
|
|
36
36
|
END: "end"
|
|
37
|
-
},
|
|
37
|
+
}, K = {
|
|
38
38
|
NAME: "data-mirage-dom",
|
|
39
39
|
KEY: "mirageDom",
|
|
40
40
|
VALUES: {
|
|
@@ -59,11 +59,11 @@ const Ae = {
|
|
|
59
59
|
KEY: "mirageTravel",
|
|
60
60
|
VALUES: Ce,
|
|
61
61
|
MAX_LAYERS: Object.keys(Ce).length - 1
|
|
62
|
-
},
|
|
62
|
+
}, W = {
|
|
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
|
|
@@ -76,7 +76,7 @@ const Ae = {
|
|
|
76
76
|
VALUES: {
|
|
77
77
|
FRONT: "front"
|
|
78
78
|
}
|
|
79
|
-
}, de = 0,
|
|
79
|
+
}, de = 0, Q = 1, ce = 2, Ye = 4, ue = 8, ve = 16;
|
|
80
80
|
function We(s) {
|
|
81
81
|
const e = s.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
82
82
|
return e ? {
|
|
@@ -120,7 +120,7 @@ class De {
|
|
|
120
120
|
u(this, "onScrollChange", /* @__PURE__ */ new Set());
|
|
121
121
|
u(this, "onRender", /* @__PURE__ */ new Set());
|
|
122
122
|
u(this, "onTransitionFinished", (e) => {
|
|
123
|
-
this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingStyles.size == 0 && (this.pendingMask |=
|
|
123
|
+
this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingStyles.size == 0 && (this.pendingMask |= Q | ce, this.cssTimer = window.setTimeout(() => {
|
|
124
124
|
this.isDomDirty = !0, this.cssTimer = null;
|
|
125
125
|
}, 50)));
|
|
126
126
|
});
|
|
@@ -139,7 +139,7 @@ class De {
|
|
|
139
139
|
this.onBeforeRender.forEach((r) => r()), this.isDomDirty && (this.isDomDirty = !1, this.onLayoutChange.forEach((r) => r(this.pendingMask, this.pendingDeletions)), this.pendingDeletions.clear(), this.pendingMask = de);
|
|
140
140
|
const e = window.scrollX, t = window.scrollY;
|
|
141
141
|
(e !== this.lastScrollX || t !== this.lastScrollY) && (this.onScrollChange.forEach((r) => r(e, t)), this.lastScrollX = e, this.lastScrollY = t, this.scrollTimer && clearTimeout(this.scrollTimer), this.scrollTimer = window.setTimeout(() => {
|
|
142
|
-
this.pendingMask |=
|
|
142
|
+
this.pendingMask |= Q, this.isDomDirty = !0, this.scrollTimer = null;
|
|
143
143
|
}, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((r) => r(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((r) => r()), requestAnimationFrame(this.renderLoop);
|
|
144
144
|
});
|
|
145
145
|
var i, l;
|
|
@@ -159,13 +159,13 @@ class De {
|
|
|
159
159
|
});
|
|
160
160
|
else if (o.type === "attributes")
|
|
161
161
|
if (o.attributeName === "style") {
|
|
162
|
-
a |=
|
|
162
|
+
a |= Q | ce;
|
|
163
163
|
const c = o.target, d = He(c.style);
|
|
164
164
|
this.pendingStyles.set(c, d);
|
|
165
165
|
} else
|
|
166
|
-
o.attributeName === "class" ? a |=
|
|
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
|
-
o.type === "characterData" && (a |= ve |
|
|
168
|
+
o.type === "characterData" && (a |= ve | Q);
|
|
169
169
|
if (a !== de) {
|
|
170
170
|
if (this.pendingMask |= a, a & ue) {
|
|
171
171
|
this.clearTimers(), this.isDomDirty = !0;
|
|
@@ -192,12 +192,12 @@ 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,
|
|
199
199
|
HIDDEN: 31
|
|
200
|
-
}, Te = Object.values(
|
|
200
|
+
}, Te = Object.values(W.VALUES);
|
|
201
201
|
class ke {
|
|
202
202
|
/**
|
|
203
203
|
* Calculates or retrieves the exact alphabetic baseline (in pixels) for the given font.
|
|
@@ -257,16 +257,16 @@ class Pe extends y.MeshBasicMaterial {
|
|
|
257
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
258
|
const h = this.wrapText(t, i), g = r.lineHeight, v = ke.getBaseline(r.font);
|
|
259
259
|
h.forEach((p, m) => {
|
|
260
|
-
const
|
|
261
|
-
let
|
|
262
|
-
r.textAlign === "center" ?
|
|
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;
|
|
@@ -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
518
|
const a = {};
|
|
519
519
|
if (i != null && i.uniforms)
|
|
520
|
-
for (const [S,
|
|
521
|
-
typeof
|
|
522
|
-
`, a[S] = { value:
|
|
523
|
-
`, a[S] = { value: new y.Vector2(...
|
|
524
|
-
`, a[S] = { value: new y.Vector3(...
|
|
525
|
-
`, a[S] = { value: new y.Vector4(...
|
|
526
|
-
`, a[S] = { value:
|
|
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
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
|
-
`, 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),
|
|
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:
|
|
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,
|
|
@@ -693,10 +693,10 @@ 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 =
|
|
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
697
|
s.set(i, l, n, a);
|
|
698
698
|
}
|
|
699
|
-
const
|
|
699
|
+
const V = {
|
|
700
700
|
create(s, e, t, r, i, l = 2, n = null, a) {
|
|
701
701
|
return s === "BOX" ? Ze(
|
|
702
702
|
e,
|
|
@@ -827,7 +827,7 @@ class rt {
|
|
|
827
827
|
var a, o, c, d, h;
|
|
828
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
829
|
const p = this.registry.get(g);
|
|
830
|
-
p && p.material instanceof y.ShaderMaterial &&
|
|
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,7 +849,7 @@ 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
855
|
for (let e = 0; e < O.MAX_LAYERS; e++) {
|
|
@@ -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
|
);
|
|
@@ -944,7 +944,7 @@ 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), a = e.isTraveler ? (i = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : i.texture : this.textureManager.get(e.element), o =
|
|
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
|
"",
|
|
@@ -981,29 +981,29 @@ class rt {
|
|
|
981
981
|
e.children.filter(
|
|
982
982
|
(p) => p.name.startsWith("TEXT_CHILD")
|
|
983
983
|
).forEach((p) => {
|
|
984
|
-
var
|
|
984
|
+
var E;
|
|
985
985
|
const m = p;
|
|
986
|
-
(
|
|
986
|
+
(E = m.material.map) == null || E.dispose(), m.geometry.dispose(), e.remove(m);
|
|
987
987
|
});
|
|
988
988
|
const h = t.rect, g = h.x + h.width / 2, v = h.y + h.height / 2;
|
|
989
989
|
i.forEach((p, m) => {
|
|
990
|
-
const
|
|
990
|
+
const E = V.create(
|
|
991
991
|
"TEXT",
|
|
992
992
|
l,
|
|
993
993
|
p.text,
|
|
994
994
|
p.rect.width,
|
|
995
995
|
p.rect.height,
|
|
996
996
|
this.qualityFactor
|
|
997
|
-
),
|
|
998
|
-
|
|
999
|
-
const
|
|
1000
|
-
|
|
1001
|
-
const S = p.rect.x + p.rect.width / 2,
|
|
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,21 +1011,21 @@ 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 g = t.visibility &
|
|
1017
|
-
if (h.layers.set(g), t.visibility &
|
|
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
1019
|
for (let v = t.captureLayer; v <= O.MAX_LAYERS + 1; v++)
|
|
1020
|
-
v !== t.nativeLayer && h.layers.enable(
|
|
1020
|
+
v !== t.nativeLayer && h.layers.enable(I.getCaptureLayer(v));
|
|
1021
1021
|
else
|
|
1022
1022
|
for (let v = t.captureLayer; v <= O.MAX_LAYERS + 1; v++)
|
|
1023
|
-
h.layers.enable(
|
|
1023
|
+
h.layers.enable(I.getCaptureLayer(v));
|
|
1024
1024
|
}
|
|
1025
1025
|
});
|
|
1026
1026
|
}
|
|
1027
1027
|
updateMeshProperties(e, t) {
|
|
1028
|
-
var
|
|
1028
|
+
var R, C, S;
|
|
1029
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,
|
|
@@ -1040,8 +1040,8 @@ class rt {
|
|
|
1040
1040
|
if (this.isViewport)
|
|
1041
1041
|
h = r.x - window.innerWidth / 2 + r.width / 2, g = -r.y + window.innerHeight / 2 - r.height / 2;
|
|
1042
1042
|
else {
|
|
1043
|
-
const
|
|
1044
|
-
h =
|
|
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,
|
|
@@ -1050,13 +1050,13 @@ class rt {
|
|
|
1050
1050
|
);
|
|
1051
1051
|
const v = r.x, p = r.y;
|
|
1052
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,
|
|
1054
|
-
let
|
|
1055
|
-
if (
|
|
1056
|
-
const
|
|
1057
|
-
|
|
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,73 +1064,73 @@ 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
|
-
const
|
|
1083
|
-
let
|
|
1082
|
+
const w = e.userData.nativeMesh;
|
|
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 f = parseFloat(
|
|
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
|
|
1098
|
-
if (
|
|
1099
|
-
let f = parseFloat(
|
|
1100
|
-
|
|
1097
|
+
const Z = N.match(/scaleX\(([\d.]+%?)\)/);
|
|
1098
|
+
if (Z) {
|
|
1099
|
+
let f = parseFloat(Z[1]);
|
|
1100
|
+
Z[1].includes("%") && (f /= 100), b *= f;
|
|
1101
1101
|
}
|
|
1102
|
-
const
|
|
1103
|
-
if (
|
|
1104
|
-
let f = parseFloat(
|
|
1105
|
-
|
|
1102
|
+
const ee = N.match(/scaleY\(([\d.]+%?)\)/);
|
|
1103
|
+
if (ee) {
|
|
1104
|
+
let f = parseFloat(ee[1]);
|
|
1105
|
+
ee[1].includes("%") && (f /= 100), U *= f;
|
|
1106
1106
|
}
|
|
1107
|
-
const
|
|
1108
|
-
if (
|
|
1109
|
-
const f =
|
|
1110
|
-
let
|
|
1111
|
-
f.includes("%") && (
|
|
1112
|
-
let F = parseFloat(
|
|
1113
|
-
|
|
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
1114
|
}
|
|
1115
|
-
const ne =
|
|
1115
|
+
const ne = N.match(/translateX\(([^)]+)\)/);
|
|
1116
1116
|
if (ne) {
|
|
1117
1117
|
const f = ne[1].trim();
|
|
1118
|
-
let
|
|
1119
|
-
f.includes("%") && (
|
|
1118
|
+
let x = parseFloat(f);
|
|
1119
|
+
f.includes("%") && (x = x / 100 * t.nativeRect.width), $ += x;
|
|
1120
1120
|
}
|
|
1121
|
-
const ae =
|
|
1121
|
+
const ae = N.match(/translateY\(([^)]+)\)/);
|
|
1122
1122
|
if (ae) {
|
|
1123
1123
|
const f = ae[1].trim();
|
|
1124
|
-
let
|
|
1125
|
-
f.includes("%") && (
|
|
1124
|
+
let x = parseFloat(f);
|
|
1125
|
+
f.includes("%") && (x = x / 100 * t.nativeRect.height), q -= x;
|
|
1126
1126
|
}
|
|
1127
1127
|
}
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1128
|
+
w.scale.set(b, U, 1), w.position.set(
|
|
1129
|
+
$,
|
|
1130
|
+
q,
|
|
1131
1131
|
t.nativeStyles.zIndex + this.renderOrder * o
|
|
1132
|
-
),
|
|
1133
|
-
|
|
1132
|
+
), V.update(
|
|
1133
|
+
w.material,
|
|
1134
1134
|
"BOX",
|
|
1135
1135
|
t.nativeStyles,
|
|
1136
1136
|
"",
|
|
@@ -1143,17 +1143,17 @@ class rt {
|
|
|
1143
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);
|
|
1144
1144
|
}
|
|
1145
1145
|
updateMeshLayers(e, t) {
|
|
1146
|
-
const r = t.visibility &
|
|
1147
|
-
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) {
|
|
1148
1148
|
const i = e.userData.nativeMesh;
|
|
1149
|
-
if (i.layers.set(
|
|
1150
|
-
i.layers.enable(
|
|
1149
|
+
if (i.layers.set(I.HIDDEN), t.visibility & H) {
|
|
1150
|
+
i.layers.enable(I.getCaptureLayer(t.nativeLayer));
|
|
1151
1151
|
for (let l = t.captureLayer; l <= O.MAX_LAYERS + 1; l++)
|
|
1152
|
-
l !== t.nativeLayer && e.layers.enable(
|
|
1152
|
+
l !== t.nativeLayer && e.layers.enable(I.getCaptureLayer(l));
|
|
1153
1153
|
}
|
|
1154
|
-
} else if (t.visibility &
|
|
1154
|
+
} else if (t.visibility & H)
|
|
1155
1155
|
for (let i = t.captureLayer; i <= O.MAX_LAYERS + 1; i++)
|
|
1156
|
-
e.layers.enable(
|
|
1156
|
+
e.layers.enable(I.getCaptureLayer(i));
|
|
1157
1157
|
}
|
|
1158
1158
|
captureRenderTarget(e, t, r) {
|
|
1159
1159
|
if (e.size === 0 || !r)
|
|
@@ -1166,8 +1166,8 @@ class rt {
|
|
|
1166
1166
|
const h = (n.x + 1) / 2 * a, g = (n.y + 1) / 2 * o;
|
|
1167
1167
|
let v = 0, p = 1;
|
|
1168
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,
|
|
1170
|
-
this.renderer.setScissor(
|
|
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);
|
|
1171
1171
|
}
|
|
1172
1172
|
this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(i, l);
|
|
1173
1173
|
}
|
|
@@ -1176,7 +1176,7 @@ class rt {
|
|
|
1176
1176
|
const t = e + 1;
|
|
1177
1177
|
this.captureRenderTarget(
|
|
1178
1178
|
this.travelersByLayer[e],
|
|
1179
|
-
|
|
1179
|
+
I.getCaptureLayer(t),
|
|
1180
1180
|
this.renderTargets[e]
|
|
1181
1181
|
);
|
|
1182
1182
|
}
|
|
@@ -1212,40 +1212,53 @@ class rt {
|
|
|
1212
1212
|
const v = c.x - e, p = c.y - t;
|
|
1213
1213
|
h = v - i / 2 + c.width / 2, g = -p + l / 2 - c.height / 2;
|
|
1214
1214
|
}
|
|
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 &&
|
|
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, {
|
|
1216
1216
|
width: c.width,
|
|
1217
1217
|
height: c.height
|
|
1218
1218
|
}), a.userData.nativeMesh) {
|
|
1219
1219
|
const v = a.userData.nativeMesh;
|
|
1220
|
-
let p = c.width, m = c.height,
|
|
1220
|
+
let p = c.width, m = c.height, E = h, M = g;
|
|
1221
1221
|
if (a.userData.nativeTransform) {
|
|
1222
|
-
const
|
|
1223
|
-
if (
|
|
1224
|
-
let
|
|
1225
|
-
|
|
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;
|
|
1226
1226
|
}
|
|
1227
|
-
const
|
|
1228
|
-
if (
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
R.includes("%") && (U = U / 100 * c.width);
|
|
1232
|
-
let G = parseFloat(A);
|
|
1233
|
-
A.includes("%") && (G = G / 100 * c.height), w += U, L -= G;
|
|
1227
|
+
const C = L.match(/scaleX\(([\d.]+%?)\)/);
|
|
1228
|
+
if (C) {
|
|
1229
|
+
let b = parseFloat(C[1]);
|
|
1230
|
+
C[1].includes("%") && (b /= 100), p *= b;
|
|
1234
1231
|
}
|
|
1235
|
-
const S =
|
|
1232
|
+
const S = L.match(/scaleY\(([\d.]+%?)\)/);
|
|
1236
1233
|
if (S) {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1234
|
+
let b = parseFloat(S[1]);
|
|
1235
|
+
S[1].includes("%") && (b /= 100), m *= b;
|
|
1236
|
+
}
|
|
1237
|
+
const w = L.match(/translate\(([^,]+),\s*([^)]+)\)/);
|
|
1238
|
+
if (w) {
|
|
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;
|
|
1240
1244
|
}
|
|
1241
|
-
const
|
|
1242
|
-
if (
|
|
1243
|
-
const
|
|
1244
|
-
let
|
|
1245
|
-
|
|
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;
|
|
1246
1256
|
}
|
|
1247
1257
|
}
|
|
1248
|
-
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
|
+
});
|
|
1249
1262
|
}
|
|
1250
1263
|
}
|
|
1251
1264
|
});
|
|
@@ -1343,283 +1356,283 @@ function Me(s) {
|
|
|
1343
1356
|
letterSpacing: r
|
|
1344
1357
|
};
|
|
1345
1358
|
}
|
|
1346
|
-
function Ue(s, e =
|
|
1347
|
-
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;
|
|
1348
1361
|
if (s.nodeType === Node.TEXT_NODE) {
|
|
1349
1362
|
const f = s;
|
|
1350
1363
|
if (!f.textContent || !f.textContent.trim())
|
|
1351
1364
|
return null;
|
|
1352
|
-
const
|
|
1353
|
-
if (
|
|
1365
|
+
const x = f.textContent.replace(/\s+/g, " ");
|
|
1366
|
+
if (x.length === 0)
|
|
1354
1367
|
return null;
|
|
1355
|
-
const
|
|
1356
|
-
if (
|
|
1368
|
+
const D = it(f);
|
|
1369
|
+
if (D.length === 0)
|
|
1357
1370
|
return null;
|
|
1358
|
-
const F = f.parentElement,
|
|
1359
|
-
if (!
|
|
1371
|
+
const F = f.parentElement, k = F ? window.getComputedStyle(F) : null;
|
|
1372
|
+
if (!k)
|
|
1360
1373
|
return null;
|
|
1361
|
-
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));
|
|
1362
1375
|
return {
|
|
1363
1376
|
id: Math.random().toString(36).substring(2, 9),
|
|
1364
1377
|
type: "TEXT",
|
|
1365
1378
|
element: f,
|
|
1366
1379
|
rect: {
|
|
1367
|
-
x:
|
|
1380
|
+
x: P + window.scrollX,
|
|
1368
1381
|
y: z + window.scrollY,
|
|
1369
|
-
width:
|
|
1370
|
-
height:
|
|
1382
|
+
width: j - P,
|
|
1383
|
+
height: A - z
|
|
1371
1384
|
},
|
|
1372
1385
|
styles: {
|
|
1373
1386
|
backgroundColor: "transparent",
|
|
1374
1387
|
backgroundImage: "",
|
|
1375
|
-
opacity: F && F.dataset[
|
|
1376
|
-
zIndex: (isNaN(parseInt(
|
|
1388
|
+
opacity: F && F.dataset[K.KEY] === K.VALUES.HIDE ? 1 : parseFloat(k.opacity),
|
|
1389
|
+
zIndex: (isNaN(parseInt(k.zIndex)) ? 0 : parseInt(k.zIndex)) + i,
|
|
1377
1390
|
borderRadius: "0px",
|
|
1378
1391
|
borderColor: "transparent",
|
|
1379
1392
|
borderWidth: "0px",
|
|
1380
1393
|
isTraveler: !1
|
|
1381
1394
|
},
|
|
1382
|
-
textContent:
|
|
1383
|
-
textLines:
|
|
1384
|
-
text:
|
|
1395
|
+
textContent: x,
|
|
1396
|
+
textLines: D.map((T) => ({
|
|
1397
|
+
text: T.text.trim(),
|
|
1385
1398
|
rect: {
|
|
1386
|
-
x:
|
|
1387
|
-
y:
|
|
1388
|
-
width:
|
|
1389
|
-
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
|
|
1390
1403
|
}
|
|
1391
1404
|
})),
|
|
1392
|
-
textStyles: Me(
|
|
1405
|
+
textStyles: Me(k),
|
|
1393
1406
|
dirtyMask: e,
|
|
1394
1407
|
visibility: t,
|
|
1395
1408
|
isTraveler: !1,
|
|
1396
1409
|
captureLayer: r,
|
|
1397
|
-
isFixed:
|
|
1410
|
+
isFixed: k.position === "fixed",
|
|
1398
1411
|
nativeLayer: n,
|
|
1399
|
-
nativeStyles: a ?
|
|
1412
|
+
nativeStyles: a ? J(J({
|
|
1400
1413
|
backgroundColor: "transparent",
|
|
1401
1414
|
backgroundImage: "",
|
|
1402
|
-
opacity: F && F.dataset[
|
|
1403
|
-
zIndex: (isNaN(parseInt(
|
|
1415
|
+
opacity: F && F.dataset[K.KEY] === K.VALUES.HIDE ? 1 : parseFloat(k.opacity),
|
|
1416
|
+
zIndex: (isNaN(parseInt(k.zIndex)) ? 0 : parseInt(k.zIndex)) + i,
|
|
1404
1417
|
borderRadius: "0px",
|
|
1405
1418
|
borderColor: "transparent",
|
|
1406
1419
|
borderWidth: "0px",
|
|
1407
1420
|
isTraveler: !1
|
|
1408
|
-
}, Me(
|
|
1421
|
+
}, Me(k)), a) : void 0,
|
|
1409
1422
|
nativeRect: a ? {
|
|
1410
|
-
x:
|
|
1423
|
+
x: P + window.scrollX,
|
|
1411
1424
|
y: z + window.scrollY,
|
|
1412
|
-
width:
|
|
1413
|
-
height:
|
|
1425
|
+
width: j - P,
|
|
1426
|
+
height: A - z
|
|
1414
1427
|
} : void 0,
|
|
1415
1428
|
children: []
|
|
1416
1429
|
};
|
|
1417
1430
|
}
|
|
1418
1431
|
if (s.nodeType !== Node.ELEMENT_NODE)
|
|
1419
1432
|
return null;
|
|
1420
|
-
const o = s, c = o.dataset[
|
|
1433
|
+
const o = s, c = o.dataset[W.KEY];
|
|
1421
1434
|
let d = t, h = t;
|
|
1422
1435
|
if (c) {
|
|
1423
1436
|
const f = new Set(c.split(/\s+/));
|
|
1424
|
-
for (const
|
|
1425
|
-
if (!Te.includes(
|
|
1437
|
+
for (const x of f)
|
|
1438
|
+
if (!Te.includes(x))
|
|
1426
1439
|
throw new Error(
|
|
1427
|
-
`[MirageEngine] Invalid filter token: '${
|
|
1440
|
+
`[MirageEngine] Invalid filter token: '${x}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
|
|
1428
1441
|
);
|
|
1429
|
-
if (f.has(
|
|
1442
|
+
if (f.has(W.VALUES.END))
|
|
1430
1443
|
return null;
|
|
1431
|
-
if (f.has(
|
|
1444
|
+
if (f.has(W.VALUES.INCLUDE_TREE) && f.has(W.VALUES.EXCLUDE_TREE))
|
|
1432
1445
|
throw new Error(
|
|
1433
1446
|
"[MirageEngine] Conflicting filters: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
|
|
1434
1447
|
);
|
|
1435
|
-
if (f.has(
|
|
1448
|
+
if (f.has(W.VALUES.INCLUDE_SELF) && f.has(W.VALUES.EXCLUDE_SELF))
|
|
1436
1449
|
throw new Error(
|
|
1437
1450
|
"[MirageEngine] Conflicting filters: 'include-self' and 'exclude-self' cannot be used together on the same element."
|
|
1438
1451
|
);
|
|
1439
|
-
f.has(
|
|
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);
|
|
1440
1453
|
}
|
|
1441
|
-
const g = o.dataset[
|
|
1454
|
+
const g = o.dataset[G.KEY];
|
|
1442
1455
|
if (g) {
|
|
1443
1456
|
const f = new Set(g.split(/\s+/));
|
|
1444
|
-
for (const
|
|
1445
|
-
if (!Te.includes(
|
|
1457
|
+
for (const x of f)
|
|
1458
|
+
if (!Te.includes(x))
|
|
1446
1459
|
throw new Error(
|
|
1447
|
-
`[MirageEngine] Invalid select token: '${
|
|
1460
|
+
`[MirageEngine] Invalid select token: '${x}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
|
|
1448
1461
|
);
|
|
1449
|
-
if (f.has(
|
|
1462
|
+
if (f.has(G.VALUES.END))
|
|
1450
1463
|
return null;
|
|
1451
|
-
if (f.has(
|
|
1464
|
+
if (f.has(G.VALUES.INCLUDE_TREE) && f.has(G.VALUES.EXCLUDE_TREE))
|
|
1452
1465
|
throw new Error(
|
|
1453
1466
|
"[MirageEngine] Conflicting selects: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
|
|
1454
1467
|
);
|
|
1455
|
-
if (f.has(
|
|
1468
|
+
if (f.has(G.VALUES.INCLUDE_SELF) && f.has(G.VALUES.EXCLUDE_SELF))
|
|
1456
1469
|
throw new Error(
|
|
1457
1470
|
"[MirageEngine] Conflicting selects: 'include-self' and 'exclude-self' cannot be used together on the same element."
|
|
1458
1471
|
);
|
|
1459
|
-
f.has(
|
|
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);
|
|
1460
1473
|
}
|
|
1461
1474
|
const v = o.dataset[O.KEY];
|
|
1462
|
-
let p = !1, m = a ?
|
|
1475
|
+
let p = !1, m = a ? J({}, a) : {}, E = n;
|
|
1463
1476
|
if (v) {
|
|
1464
1477
|
let f = 1;
|
|
1465
|
-
const
|
|
1478
|
+
const x = v.indexOf("{"), D = v.lastIndexOf("}");
|
|
1466
1479
|
let F = v;
|
|
1467
|
-
if (
|
|
1468
|
-
F = v.substring(0,
|
|
1469
|
-
const
|
|
1480
|
+
if (x !== -1 && D !== -1 && D > x) {
|
|
1481
|
+
F = v.substring(0, x).trim();
|
|
1482
|
+
const A = v.substring(x, D + 1);
|
|
1470
1483
|
try {
|
|
1471
|
-
m = new Function("return " +
|
|
1472
|
-
} catch (
|
|
1484
|
+
m = new Function("return " + A)();
|
|
1485
|
+
} catch (T) {
|
|
1473
1486
|
console.warn(
|
|
1474
|
-
`[MirageEngine] Failed to parse travel styles JSON: ${
|
|
1487
|
+
`[MirageEngine] Failed to parse travel styles JSON: ${A}`
|
|
1475
1488
|
);
|
|
1476
1489
|
}
|
|
1477
1490
|
}
|
|
1478
|
-
const
|
|
1479
|
-
let
|
|
1480
|
-
const z =
|
|
1491
|
+
const k = F.split(/\s+/);
|
|
1492
|
+
let P = !1;
|
|
1493
|
+
const z = k.indexOf(O.VALUES.TRAVELER);
|
|
1481
1494
|
if (z !== -1) {
|
|
1482
|
-
p = !0,
|
|
1483
|
-
const
|
|
1484
|
-
if (
|
|
1485
|
-
f = parseInt(
|
|
1495
|
+
p = !0, P = !0;
|
|
1496
|
+
const A = k[z + 1];
|
|
1497
|
+
if (A && !isNaN(parseInt(A, 10)))
|
|
1498
|
+
f = parseInt(A, 10);
|
|
1486
1499
|
else {
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1500
|
+
const T = k.find((re) => !isNaN(parseInt(re, 10)));
|
|
1501
|
+
T && (f = parseInt(T, 10));
|
|
1489
1502
|
}
|
|
1490
1503
|
}
|
|
1491
|
-
const
|
|
1492
|
-
if (
|
|
1493
|
-
const
|
|
1494
|
-
if (
|
|
1495
|
-
|
|
1504
|
+
const j = k.indexOf(O.VALUES.NATIVE);
|
|
1505
|
+
if (j !== -1) {
|
|
1506
|
+
const A = k[j + 1];
|
|
1507
|
+
if (A && !isNaN(parseInt(A, 10)))
|
|
1508
|
+
E = parseInt(A, 10);
|
|
1496
1509
|
else if (!p) {
|
|
1497
|
-
const
|
|
1498
|
-
|
|
1510
|
+
const T = k.find((re) => !isNaN(parseInt(re, 10)));
|
|
1511
|
+
T && (E = parseInt(T, 10));
|
|
1499
1512
|
}
|
|
1500
1513
|
}
|
|
1501
|
-
if (
|
|
1502
|
-
const
|
|
1503
|
-
if (
|
|
1514
|
+
if (P) {
|
|
1515
|
+
const A = f + 1;
|
|
1516
|
+
if (A < r)
|
|
1504
1517
|
throw new Error(
|
|
1505
1518
|
`[MirageEngine] Traveler layer (${f}) cannot be smaller than inherited capture layer (${r - 1}).`
|
|
1506
1519
|
);
|
|
1507
|
-
r = Math.min(
|
|
1520
|
+
r = Math.min(A, O.MAX_LAYERS + 1);
|
|
1508
1521
|
}
|
|
1509
1522
|
}
|
|
1510
|
-
const
|
|
1511
|
-
let
|
|
1512
|
-
|
|
1513
|
-
const
|
|
1514
|
-
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")
|
|
1515
1528
|
return null;
|
|
1516
1529
|
let S = o.getAttribute("data-mid");
|
|
1517
1530
|
S || (S = Math.random().toString(36).substring(2, 11), o.setAttribute("data-mid", S));
|
|
1518
|
-
const
|
|
1519
|
-
let
|
|
1531
|
+
const w = parseInt(C.zIndex), B = (isNaN(w) ? 0 : w) + i;
|
|
1532
|
+
let _;
|
|
1520
1533
|
if (o.tagName === "IMG")
|
|
1521
|
-
|
|
1534
|
+
_ = o.src;
|
|
1522
1535
|
else if (o.tagName.toLowerCase() === "svg") {
|
|
1523
|
-
const f = o.cloneNode(!0),
|
|
1524
|
-
const
|
|
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;
|
|
1525
1538
|
fe && fe !== "none" && (oe.style.fill = fe);
|
|
1526
|
-
const ge = F || (
|
|
1527
|
-
ge && ge !== "none" && (oe.style.stroke = ge),
|
|
1528
|
-
const be =
|
|
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;
|
|
1529
1542
|
be && (oe.style.color = be);
|
|
1530
|
-
const pe =
|
|
1543
|
+
const pe = k || Y.opacity;
|
|
1531
1544
|
pe && pe !== "1" && (oe.style.opacity = pe);
|
|
1532
|
-
for (let he = 0; he <
|
|
1533
|
-
|
|
1545
|
+
for (let he = 0; he < T.children.length; he++)
|
|
1546
|
+
P(T.children[he], re.children[he]);
|
|
1534
1547
|
};
|
|
1535
|
-
|
|
1536
|
-
const z = o.getBoundingClientRect(),
|
|
1537
|
-
f.hasAttribute("viewBox") || f.setAttribute("viewBox", `0 0 ${z.width} ${z.height}`), f.setAttribute("width", (z.width *
|
|
1538
|
-
let
|
|
1539
|
-
|
|
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(
|
|
1540
1553
|
"<svg",
|
|
1541
1554
|
'<svg xmlns="http://www.w3.org/2000/svg"'
|
|
1542
|
-
)),
|
|
1543
|
-
} else if (
|
|
1544
|
-
const f =
|
|
1545
|
-
f && (
|
|
1546
|
-
}
|
|
1547
|
-
const
|
|
1548
|
-
backgroundColor:
|
|
1549
|
-
backgroundImage:
|
|
1550
|
-
opacity: o.dataset[
|
|
1551
|
-
zIndex:
|
|
1552
|
-
borderRadius:
|
|
1553
|
-
borderColor:
|
|
1554
|
-
borderWidth:
|
|
1555
|
-
imageSrc:
|
|
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: _,
|
|
1556
1569
|
isTraveler: p
|
|
1557
|
-
},
|
|
1558
|
-
let
|
|
1559
|
-
const
|
|
1570
|
+
}, U = b;
|
|
1571
|
+
let $, q;
|
|
1572
|
+
const N = [];
|
|
1560
1573
|
return o.tagName.toLowerCase() !== "svg" && Array.from(o.childNodes).forEach((f) => {
|
|
1561
|
-
const
|
|
1574
|
+
const x = f.nodeType === Node.TEXT_NODE ? h : d, D = Ue(
|
|
1562
1575
|
f,
|
|
1563
1576
|
e,
|
|
1564
|
-
|
|
1577
|
+
x,
|
|
1565
1578
|
r,
|
|
1566
|
-
|
|
1579
|
+
B,
|
|
1567
1580
|
l,
|
|
1568
|
-
f.nodeType === Node.TEXT_NODE ?
|
|
1581
|
+
f.nodeType === Node.TEXT_NODE ? E : void 0,
|
|
1569
1582
|
f.nodeType === Node.TEXT_NODE && Object.keys(m).length > 0 ? m : void 0
|
|
1570
1583
|
);
|
|
1571
|
-
|
|
1584
|
+
D && N.push(D);
|
|
1572
1585
|
}), {
|
|
1573
1586
|
id: S,
|
|
1574
1587
|
type: "BOX",
|
|
1575
1588
|
element: o,
|
|
1576
1589
|
rect: {
|
|
1577
|
-
x:
|
|
1578
|
-
y:
|
|
1579
|
-
width:
|
|
1580
|
-
height:
|
|
1590
|
+
x: R.left + window.scrollX,
|
|
1591
|
+
y: R.top + window.scrollY,
|
|
1592
|
+
width: R.width,
|
|
1593
|
+
height: R.height
|
|
1581
1594
|
},
|
|
1582
|
-
styles:
|
|
1583
|
-
textContent:
|
|
1584
|
-
textStyles:
|
|
1595
|
+
styles: U,
|
|
1596
|
+
textContent: $,
|
|
1597
|
+
textStyles: q,
|
|
1585
1598
|
dirtyMask: e,
|
|
1586
1599
|
visibility: h,
|
|
1587
1600
|
isTraveler: p,
|
|
1588
1601
|
captureLayer: r,
|
|
1589
|
-
nativeLayer:
|
|
1590
|
-
nativeStyles:
|
|
1591
|
-
backgroundColor: (
|
|
1592
|
-
backgroundImage: (
|
|
1593
|
-
opacity: (
|
|
1594
|
-
zIndex: m.zIndex !== void 0 ? m.zIndex +
|
|
1595
|
-
borderRadius: (
|
|
1596
|
-
borderColor: (ne = m.borderColor) != null ? ne :
|
|
1597
|
-
borderWidth: (ae = m.borderWidth) != null ? ae :
|
|
1598
|
-
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,
|
|
1599
1612
|
transform: m.transform
|
|
1600
1613
|
}) : void 0,
|
|
1601
|
-
nativeRect:
|
|
1602
|
-
x: m.x !== void 0 ? parseFloat(m.x) :
|
|
1603
|
-
y: m.y !== void 0 ? parseFloat(m.y) :
|
|
1604
|
-
width: m.width !== void 0 ? parseFloat(m.width) :
|
|
1605
|
-
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
|
|
1606
1619
|
} : void 0,
|
|
1607
|
-
isFixed:
|
|
1608
|
-
children:
|
|
1609
|
-
shaderHooks:
|
|
1620
|
+
isFixed: C.position === "fixed",
|
|
1621
|
+
children: N,
|
|
1622
|
+
shaderHooks: L
|
|
1610
1623
|
};
|
|
1611
1624
|
}
|
|
1612
1625
|
function st(s, e) {
|
|
1613
1626
|
e.size !== 0 && e.forEach((t, r) => {
|
|
1614
1627
|
var l, n, a, o;
|
|
1615
1628
|
const i = s.get(r);
|
|
1616
|
-
!i || !i.userData.basePosition || (
|
|
1629
|
+
!i || !i.userData.basePosition || (V.forceUpdateUniforms(i.material, {
|
|
1617
1630
|
backgroundColor: t.backgroundColor,
|
|
1618
1631
|
backgroundImage: t.backgroundImage,
|
|
1619
1632
|
opacity: t.opacity,
|
|
1620
1633
|
borderRadius: (n = t.borderRadius) != null ? n : (l = i.userData.baseStyles) == null ? void 0 : l.borderRadius
|
|
1621
1634
|
// width and height are no longer updated here, they are updated in syncMeshesByDOM
|
|
1622
|
-
}), i.userData.nativeMesh &&
|
|
1635
|
+
}), i.userData.nativeMesh && V.forceUpdateUniforms(i.userData.nativeMesh.material, {
|
|
1623
1636
|
backgroundColor: t.backgroundColor,
|
|
1624
1637
|
backgroundImage: t.backgroundImage,
|
|
1625
1638
|
opacity: t.opacity,
|
|
@@ -1641,7 +1654,7 @@ class nt {
|
|
|
1641
1654
|
const o = Ue(
|
|
1642
1655
|
this.target,
|
|
1643
1656
|
l,
|
|
1644
|
-
|
|
1657
|
+
H,
|
|
1645
1658
|
1,
|
|
1646
1659
|
0,
|
|
1647
1660
|
this.renderer.qualityFactor
|
|
@@ -1695,7 +1708,7 @@ class ot {
|
|
|
1695
1708
|
if (this.target = e, this.registry = new at(), !document.getElementById("mirage-engine-styles")) {
|
|
1696
1709
|
const a = document.createElement("style");
|
|
1697
1710
|
a.id = "mirage-engine-styles", a.textContent = `
|
|
1698
|
-
[${
|
|
1711
|
+
[${K.NAME}="${K.VALUES.HIDE}"] {
|
|
1699
1712
|
opacity: 0 !important;
|
|
1700
1713
|
}
|
|
1701
1714
|
`, document.head.appendChild(a);
|