mirage-engine 0.3.16 → 0.3.18
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 +808 -771
- package/dist/mirage-engine.umd.js +16 -16
- package/package.json +3 -3
package/dist/mirage-engine.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var Xe = Object.defineProperty, Ve = Object.defineProperties;
|
|
2
|
+
var Ye = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var Ee = Object.getOwnPropertySymbols;
|
|
4
|
+
var Pe = Object.prototype.hasOwnProperty, We = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var ye = (s, e, t) => e in s ? Xe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, te = (s, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
10
|
-
|
|
7
|
+
Pe.call(e, t) && ye(s, t, e[t]);
|
|
8
|
+
if (Ee)
|
|
9
|
+
for (var t of Ee(e))
|
|
10
|
+
We.call(e, t) && ye(s, t, e[t]);
|
|
11
11
|
return s;
|
|
12
|
-
},
|
|
13
|
-
var u = (s, e, t) => (
|
|
14
|
-
var
|
|
15
|
-
var
|
|
12
|
+
}, Ce = (s, e) => Ve(s, Ye(e));
|
|
13
|
+
var u = (s, e, t) => (ye(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
14
|
+
var Te = (s, e, t) => new Promise((i, r) => {
|
|
15
|
+
var l = (c) => {
|
|
16
16
|
try {
|
|
17
|
-
o(t.next(
|
|
18
|
-
} catch (
|
|
19
|
-
|
|
17
|
+
o(t.next(c));
|
|
18
|
+
} catch (a) {
|
|
19
|
+
r(a);
|
|
20
20
|
}
|
|
21
|
-
}, n = (
|
|
21
|
+
}, n = (c) => {
|
|
22
22
|
try {
|
|
23
|
-
o(t.throw(
|
|
24
|
-
} catch (
|
|
25
|
-
|
|
23
|
+
o(t.throw(c));
|
|
24
|
+
} catch (a) {
|
|
25
|
+
r(a);
|
|
26
26
|
}
|
|
27
|
-
}, o = (
|
|
27
|
+
}, o = (c) => c.done ? i(c.value) : Promise.resolve(c.value).then(l, n);
|
|
28
28
|
o((t = t.apply(s, e)).next());
|
|
29
29
|
});
|
|
30
30
|
import * as w from "three";
|
|
31
|
-
const
|
|
31
|
+
const Ie = {
|
|
32
32
|
INCLUDE_TREE: "include-tree",
|
|
33
33
|
EXCLUDE_TREE: "exclude-tree",
|
|
34
34
|
INCLUDE_SELF: "include-self",
|
|
@@ -41,7 +41,7 @@ const Ae = {
|
|
|
41
41
|
HIDE: "hide",
|
|
42
42
|
SHOW: "show"
|
|
43
43
|
}
|
|
44
|
-
},
|
|
44
|
+
}, Re = {
|
|
45
45
|
TRAVELER: "traveler",
|
|
46
46
|
NATIVE: "native",
|
|
47
47
|
CAPTURE_1: "1",
|
|
@@ -54,42 +54,43 @@ const Ae = {
|
|
|
54
54
|
CAPTURE_8: "8",
|
|
55
55
|
CAPTURE_9: "9",
|
|
56
56
|
CAPTURE_10: "10"
|
|
57
|
-
},
|
|
57
|
+
}, N = {
|
|
58
58
|
NAME: "data-mirage-travel",
|
|
59
59
|
KEY: "mirageTravel",
|
|
60
|
-
VALUES:
|
|
61
|
-
MAX_LAYERS: Object.keys(
|
|
62
|
-
},
|
|
60
|
+
VALUES: Re,
|
|
61
|
+
MAX_LAYERS: Object.keys(Re).length - 1
|
|
62
|
+
}, H = {
|
|
63
63
|
NAME: "data-mirage-filter",
|
|
64
64
|
KEY: "mirageFilter",
|
|
65
|
-
VALUES:
|
|
66
|
-
},
|
|
65
|
+
VALUES: Ie
|
|
66
|
+
}, q = {
|
|
67
67
|
NAME: "data-mirage-select",
|
|
68
68
|
KEY: "mirageSelect",
|
|
69
|
-
VALUES:
|
|
70
|
-
},
|
|
69
|
+
VALUES: Ie
|
|
70
|
+
}, He = {
|
|
71
71
|
NAME: "data-mirage-shader",
|
|
72
72
|
KEY: "mirageShader"
|
|
73
|
-
},
|
|
73
|
+
}, Le = {
|
|
74
74
|
NAME: "data-mirage-sandwich",
|
|
75
75
|
KEY: "mirageSandwich",
|
|
76
76
|
VALUES: {
|
|
77
77
|
FRONT: "front"
|
|
78
78
|
}
|
|
79
|
-
},
|
|
80
|
-
function
|
|
81
|
-
const e = s.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
79
|
+
}, ge = 0, re = 1, ue = 2, Ge = 4, pe = 8, be = 16;
|
|
80
|
+
function $e(s) {
|
|
81
|
+
const e = s.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
|
|
82
82
|
return e ? {
|
|
83
83
|
r: parseInt(e[1]) / 255,
|
|
84
84
|
g: parseInt(e[2]) / 255,
|
|
85
|
-
b: parseInt(e[3]) / 255
|
|
86
|
-
|
|
85
|
+
b: parseInt(e[3]) / 255,
|
|
86
|
+
a: e[4] !== void 0 ? parseFloat(e[4]) : 1
|
|
87
|
+
} : { r: 1, g: 1, b: 1, a: 1 };
|
|
87
88
|
}
|
|
88
|
-
function
|
|
89
|
+
function qe(s) {
|
|
89
90
|
const e = {};
|
|
90
|
-
if (s.opacity && (e.opacity = parseFloat(s.opacity)), s.backgroundColor
|
|
91
|
-
const t =
|
|
92
|
-
e.backgroundColor = [t.r, t.g, t.b];
|
|
91
|
+
if (s.opacity && (e.opacity = parseFloat(s.opacity)), s.backgroundColor) {
|
|
92
|
+
const t = $e(s.backgroundColor);
|
|
93
|
+
e.backgroundColor = [t.r, t.g, t.b, t.a];
|
|
93
94
|
}
|
|
94
95
|
if (s.backgroundImage ? e.backgroundImage = s.backgroundImage : s.background && (e.backgroundImage = s.background), s.boxShadow && (e.boxShadow = s.boxShadow), s.borderRadius && (e.borderRadius = parseFloat(s.borderRadius)), s.width && (e.width = parseFloat(s.width)), s.height && (e.height = parseFloat(s.height)), s.transform && s.transform !== "none") {
|
|
95
96
|
const t = new DOMMatrix(s.transform);
|
|
@@ -97,7 +98,7 @@ function Ge(s) {
|
|
|
97
98
|
}
|
|
98
99
|
return e;
|
|
99
100
|
}
|
|
100
|
-
class
|
|
101
|
+
class Be {
|
|
101
102
|
constructor(e, t) {
|
|
102
103
|
u(this, "target");
|
|
103
104
|
u(this, "observer");
|
|
@@ -105,7 +106,7 @@ class ke {
|
|
|
105
106
|
u(this, "pendingStyles", /* @__PURE__ */ new Map());
|
|
106
107
|
u(this, "isDomDirty", !1);
|
|
107
108
|
u(this, "isRunning", !1);
|
|
108
|
-
u(this, "pendingMask",
|
|
109
|
+
u(this, "pendingMask", ge);
|
|
109
110
|
u(this, "mutationTimer", null);
|
|
110
111
|
u(this, "cssTimer", null);
|
|
111
112
|
u(this, "resizeConfig");
|
|
@@ -120,7 +121,7 @@ class ke {
|
|
|
120
121
|
u(this, "onScrollChange", /* @__PURE__ */ new Set());
|
|
121
122
|
u(this, "onRender", /* @__PURE__ */ new Set());
|
|
122
123
|
u(this, "onTransitionFinished", (e) => {
|
|
123
|
-
this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingStyles.size == 0 && (this.pendingMask |= re |
|
|
124
|
+
this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingStyles.size == 0 && (this.pendingMask |= re | ue, this.cssTimer = window.setTimeout(() => {
|
|
124
125
|
this.isDomDirty = !0, this.cssTimer = null;
|
|
125
126
|
}, 50)));
|
|
126
127
|
});
|
|
@@ -136,38 +137,38 @@ class ke {
|
|
|
136
137
|
u(this, "renderLoop", () => {
|
|
137
138
|
if (!this.isRunning)
|
|
138
139
|
return;
|
|
139
|
-
this.onBeforeRender.forEach((
|
|
140
|
+
this.onBeforeRender.forEach((i) => i()), this.isDomDirty && (this.isDomDirty = !1, this.onLayoutChange.forEach((i) => i(this.pendingMask, this.pendingDeletions)), this.pendingDeletions.clear(), this.pendingMask = ge);
|
|
140
141
|
const e = window.scrollX, t = window.scrollY;
|
|
141
|
-
(e !== this.lastScrollX || t !== this.lastScrollY) && (this.onScrollChange.forEach((
|
|
142
|
+
(e !== this.lastScrollX || t !== this.lastScrollY) && (this.onScrollChange.forEach((i) => i(e, t)), this.lastScrollX = e, this.lastScrollY = t, this.scrollTimer && clearTimeout(this.scrollTimer), this.scrollTimer = window.setTimeout(() => {
|
|
142
143
|
this.pendingMask |= re, this.isDomDirty = !0, this.scrollTimer = null;
|
|
143
|
-
}, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((
|
|
144
|
+
}, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((i) => i(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((i) => i()), requestAnimationFrame(this.renderLoop);
|
|
144
145
|
});
|
|
145
|
-
var
|
|
146
|
+
var r, l;
|
|
146
147
|
this.target = e;
|
|
147
|
-
const
|
|
148
|
-
|
|
148
|
+
const i = (r = t.resizeDebounce) != null ? r : !0;
|
|
149
|
+
i === !1 ? this.resizeConfig = { enabled: !1, delay: 0 } : i === !0 ? this.resizeConfig = { enabled: !0, delay: 150 } : this.resizeConfig = {
|
|
149
150
|
enabled: !0,
|
|
150
|
-
delay: (
|
|
151
|
-
onStart:
|
|
152
|
-
onEnd:
|
|
151
|
+
delay: (l = i.delay) != null ? l : 150,
|
|
152
|
+
onStart: i.onStart,
|
|
153
|
+
onEnd: i.onEnd
|
|
153
154
|
}, this.observer = new MutationObserver((n) => {
|
|
154
|
-
let o =
|
|
155
|
-
for (const
|
|
156
|
-
if (
|
|
157
|
-
o |=
|
|
158
|
-
|
|
155
|
+
let o = ge;
|
|
156
|
+
for (const c of n)
|
|
157
|
+
if (c.type === "childList")
|
|
158
|
+
o |= pe, c.removedNodes.length > 0 && c.removedNodes.forEach((a) => {
|
|
159
|
+
a instanceof HTMLElement && this.pendingDeletions.add(a);
|
|
159
160
|
});
|
|
160
|
-
else if (
|
|
161
|
-
if (
|
|
162
|
-
o |= re |
|
|
163
|
-
const
|
|
164
|
-
this.pendingStyles.set(
|
|
161
|
+
else if (c.type === "attributes")
|
|
162
|
+
if (c.attributeName === "style") {
|
|
163
|
+
o |= re | ue;
|
|
164
|
+
const a = c.target, f = qe(a.style);
|
|
165
|
+
this.pendingStyles.set(a, f);
|
|
165
166
|
} else
|
|
166
|
-
|
|
167
|
+
c.attributeName === "class" ? o |= re | ue : c.attributeName && c.attributeName.startsWith("data-") && (o |= re | ue, c.attributeName.startsWith("data-mirage") && (o |= pe));
|
|
167
168
|
else
|
|
168
|
-
|
|
169
|
-
if (o !==
|
|
170
|
-
if (this.pendingMask |= o, o &
|
|
169
|
+
c.type === "characterData" && (o |= be | re);
|
|
170
|
+
if (o !== ge) {
|
|
171
|
+
if (this.pendingMask |= o, o & pe) {
|
|
171
172
|
this.clearTimers(), this.isDomDirty = !0;
|
|
172
173
|
return;
|
|
173
174
|
}
|
|
@@ -192,13 +193,13 @@ class ke {
|
|
|
192
193
|
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
194
|
}
|
|
194
195
|
}
|
|
195
|
-
const
|
|
196
|
+
const G = 1, ae = 2, O = {
|
|
196
197
|
BASE: 0,
|
|
197
198
|
SELECTED: 1,
|
|
198
199
|
getCaptureLayer: (s) => 31 - s,
|
|
199
200
|
HIDDEN: 31
|
|
200
|
-
},
|
|
201
|
-
class
|
|
201
|
+
}, Me = Object.values(H.VALUES);
|
|
202
|
+
class Ue {
|
|
202
203
|
/**
|
|
203
204
|
* Calculates or retrieves the exact alphabetic baseline (in pixels) for the given font.
|
|
204
205
|
* @param font CSS font shorthand string (e.g., "400 16px Inter")
|
|
@@ -213,15 +214,15 @@ class Ie {
|
|
|
213
214
|
static calculateBaselineFromDOM(e) {
|
|
214
215
|
if (typeof document == "undefined")
|
|
215
216
|
return 0;
|
|
216
|
-
const t = document.createElement("div"),
|
|
217
|
-
t.style.visibility = "hidden", t.style.position = "absolute", t.style.top = "0px", t.style.left = "0px", t.style.font = e, t.style.margin = "0", t.style.padding = "0", t.style.border = "none",
|
|
218
|
-
const
|
|
219
|
-
return document.body.removeChild(t),
|
|
217
|
+
const t = document.createElement("div"), i = document.createElement("span"), r = document.createElement("img");
|
|
218
|
+
t.style.visibility = "hidden", t.style.position = "absolute", t.style.top = "0px", t.style.left = "0px", t.style.font = e, t.style.margin = "0", t.style.padding = "0", t.style.border = "none", i.style.margin = "0", i.style.padding = "0", i.style.border = "none", i.style.lineHeight = "normal", r.width = 1, r.height = 1, r.style.verticalAlign = "baseline", i.appendChild(document.createTextNode("Hidden Text")), t.appendChild(i), t.appendChild(r), document.body.appendChild(t);
|
|
219
|
+
const l = r.offsetTop - i.offsetTop;
|
|
220
|
+
return document.body.removeChild(t), l;
|
|
220
221
|
}
|
|
221
222
|
}
|
|
222
|
-
u(
|
|
223
|
-
class
|
|
224
|
-
constructor(t,
|
|
223
|
+
u(Ue, "cache", /* @__PURE__ */ new Map());
|
|
224
|
+
class je extends w.MeshBasicMaterial {
|
|
225
|
+
constructor(t, i, r, l, n = 2) {
|
|
225
226
|
super({
|
|
226
227
|
transparent: !0,
|
|
227
228
|
side: w.FrontSide,
|
|
@@ -232,41 +233,41 @@ class $e extends w.MeshBasicMaterial {
|
|
|
232
233
|
u(this, "qualityFactor");
|
|
233
234
|
if (this.canvas = document.createElement("canvas"), this.ctx = this.canvas.getContext("2d"), !this.ctx)
|
|
234
235
|
throw new Error("[Mirage] Failed to create canvas context");
|
|
235
|
-
this.qualityFactor = n, this.map = new w.CanvasTexture(this.canvas), this.map.colorSpace = w.LinearSRGBColorSpace, this.map.minFilter = w.LinearFilter, this.map.magFilter = w.LinearFilter, this.updateText(t,
|
|
236
|
+
this.qualityFactor = n, this.map = new w.CanvasTexture(this.canvas), this.map.colorSpace = w.LinearSRGBColorSpace, this.map.minFilter = w.LinearFilter, this.map.magFilter = w.LinearFilter, this.updateText(t, i, r, l);
|
|
236
237
|
}
|
|
237
|
-
wrapText(t,
|
|
238
|
-
const
|
|
239
|
-
`),
|
|
240
|
-
return
|
|
238
|
+
wrapText(t, i) {
|
|
239
|
+
const r = t.split(`
|
|
240
|
+
`), l = [];
|
|
241
|
+
return r.forEach((n) => {
|
|
241
242
|
const o = n.match(/[^\s\-]+\-?|\-|\s+/g) || [];
|
|
242
243
|
if (o.length === 0) {
|
|
243
|
-
|
|
244
|
+
l.push("");
|
|
244
245
|
return;
|
|
245
246
|
}
|
|
246
|
-
let
|
|
247
|
-
for (let
|
|
248
|
-
const
|
|
249
|
-
this.ctx.measureText(
|
|
247
|
+
let c = o[0];
|
|
248
|
+
for (let a = 1; a < o.length; a++) {
|
|
249
|
+
const f = o[a];
|
|
250
|
+
this.ctx.measureText(c + f).width <= i + 2 ? c += f : (c && l.push(c), c = f.trimStart());
|
|
250
251
|
}
|
|
251
|
-
|
|
252
|
-
}),
|
|
252
|
+
c && l.push(c);
|
|
253
|
+
}), l;
|
|
253
254
|
}
|
|
254
|
-
updateText(t,
|
|
255
|
+
updateText(t, i, r, l, n) {
|
|
255
256
|
n !== void 0 && (this.qualityFactor = n);
|
|
256
|
-
const
|
|
257
|
-
this.canvas.width !==
|
|
258
|
-
const h = this.wrapText(t,
|
|
259
|
-
h.forEach((
|
|
260
|
-
const
|
|
261
|
-
let
|
|
262
|
-
|
|
257
|
+
const c = (window.devicePixelRatio || 1) * this.qualityFactor, a = r * c, f = l * c;
|
|
258
|
+
this.canvas.width !== a || this.canvas.height !== f ? (this.canvas.width = a, this.canvas.height = f) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(c, 0, 0, c, 0, 0), this.ctx.font = i.font, this.ctx.fillStyle = i.color, this.ctx.textBaseline = "alphabetic", this.ctx.globalAlpha = 1;
|
|
259
|
+
const h = this.wrapText(t, r), d = i.lineHeight, p = Ue.getBaseline(i.font);
|
|
260
|
+
h.forEach((g, M) => {
|
|
261
|
+
const m = M * d + p;
|
|
262
|
+
let y = 0;
|
|
263
|
+
i.textAlign === "center" ? y = r / 2 : i.textAlign === "right" && (y = r), this.ctx.textAlign = i.textAlign, this.ctx.fillText(g, y, m);
|
|
263
264
|
}), this.map && (this.map.needsUpdate = !0);
|
|
264
265
|
}
|
|
265
266
|
dispose() {
|
|
266
267
|
this.map && this.map.dispose(), super.dispose();
|
|
267
268
|
}
|
|
268
269
|
}
|
|
269
|
-
function
|
|
270
|
+
function ce(s, e = 0) {
|
|
270
271
|
if (typeof s == "number")
|
|
271
272
|
return s;
|
|
272
273
|
const t = parseFloat(s) || 0;
|
|
@@ -279,100 +280,100 @@ function le(s) {
|
|
|
279
280
|
/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/
|
|
280
281
|
);
|
|
281
282
|
if (e) {
|
|
282
|
-
const t = parseInt(e[1], 10),
|
|
283
|
-
return { color: new w.Color(`rgb(${t}, ${
|
|
283
|
+
const t = parseInt(e[1], 10), i = parseInt(e[2], 10), r = parseInt(e[3], 10), l = e[4] !== void 0 ? parseFloat(e[4]) : 1;
|
|
284
|
+
return { color: new w.Color(`rgb(${t}, ${i}, ${r})`), alpha: l };
|
|
284
285
|
}
|
|
285
286
|
return { color: new w.Color(s), alpha: 1 };
|
|
286
287
|
}
|
|
287
|
-
function
|
|
288
|
+
function Oe(s) {
|
|
288
289
|
const e = [];
|
|
289
|
-
let t = "",
|
|
290
|
-
for (let
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
293
|
-
|
|
294
|
-
else if (
|
|
295
|
-
|
|
296
|
-
else if (
|
|
290
|
+
let t = "", i = 0;
|
|
291
|
+
for (let r = 0; r < s.length; r++) {
|
|
292
|
+
const l = s[r];
|
|
293
|
+
if (l === "(")
|
|
294
|
+
i++;
|
|
295
|
+
else if (l === ")")
|
|
296
|
+
i--;
|
|
297
|
+
else if (l === "," && i === 0) {
|
|
297
298
|
e.push(t.trim()), t = "";
|
|
298
299
|
continue;
|
|
299
300
|
}
|
|
300
|
-
t +=
|
|
301
|
+
t += l;
|
|
301
302
|
}
|
|
302
303
|
return t && e.push(t.trim()), e;
|
|
303
304
|
}
|
|
304
|
-
function
|
|
305
|
+
function Ke(s) {
|
|
305
306
|
if (!s || typeof s != "string" || !s.includes("linear-gradient"))
|
|
306
307
|
return null;
|
|
307
308
|
const e = s.match(/linear-gradient\((.*)\)/);
|
|
308
309
|
if (!e)
|
|
309
310
|
return null;
|
|
310
|
-
const t = e[1],
|
|
311
|
-
let
|
|
312
|
-
const n =
|
|
311
|
+
const t = e[1], i = Oe(t);
|
|
312
|
+
let r = Math.PI, l = 0;
|
|
313
|
+
const n = i[0].trim();
|
|
313
314
|
if (n.startsWith("to "))
|
|
314
|
-
n === "to top" ?
|
|
315
|
+
n === "to top" ? r = 0 : n === "to right" ? r = Math.PI / 2 : n === "to bottom" ? r = Math.PI : n === "to left" ? r = Math.PI * 1.5 : n === "to top right" || n === "to right top" ? r = Math.PI / 4 : n === "to bottom right" || n === "to right bottom" ? r = Math.PI * 0.75 : n === "to bottom left" || n === "to left bottom" ? r = Math.PI * 1.25 : (n === "to top left" || n === "to left top") && (r = Math.PI * 1.75), l = 1;
|
|
315
316
|
else if (n.endsWith("deg") || n.endsWith("rad") || n.endsWith("turn")) {
|
|
316
|
-
const
|
|
317
|
-
n.endsWith("deg") ?
|
|
317
|
+
const c = parseFloat(n);
|
|
318
|
+
n.endsWith("deg") ? r = c * (Math.PI / 180) : n.endsWith("rad") ? r = c : n.endsWith("turn") && (r = c * Math.PI * 2), l = 1;
|
|
318
319
|
}
|
|
319
320
|
const o = [];
|
|
320
|
-
for (let
|
|
321
|
-
const
|
|
322
|
-
let h =
|
|
323
|
-
if (
|
|
324
|
-
const
|
|
325
|
-
(
|
|
321
|
+
for (let c = l; c < i.length && !(o.length >= 8); c++) {
|
|
322
|
+
const a = i[c].trim(), f = a.lastIndexOf(" ");
|
|
323
|
+
let h = a, d = null;
|
|
324
|
+
if (f !== -1 && !a.endsWith(")")) {
|
|
325
|
+
const g = a.substring(f + 1);
|
|
326
|
+
(g.endsWith("%") || g.endsWith("px") || !isNaN(parseFloat(g))) && (h = a.substring(0, f).trim(), d = g);
|
|
326
327
|
}
|
|
327
|
-
const
|
|
328
|
+
const p = le(h);
|
|
328
329
|
o.push({
|
|
329
|
-
color:
|
|
330
|
-
alpha:
|
|
331
|
-
rawStop:
|
|
330
|
+
color: p.color,
|
|
331
|
+
alpha: p.alpha,
|
|
332
|
+
rawStop: d,
|
|
332
333
|
stop: 0
|
|
333
334
|
});
|
|
334
335
|
}
|
|
335
336
|
if (o.length > 0) {
|
|
336
|
-
for (let
|
|
337
|
-
o[
|
|
337
|
+
for (let a = 0; a < o.length; a++)
|
|
338
|
+
o[a].rawStop !== null && (o[a].stop = parseFloat(o[a].rawStop) / 100);
|
|
338
339
|
o[0].rawStop === null && (o[0].stop = 0), o.length > 1 && o[o.length - 1].rawStop === null && (o[o.length - 1].stop = 1);
|
|
339
|
-
let
|
|
340
|
-
for (let
|
|
341
|
-
if (o[
|
|
342
|
-
const
|
|
343
|
-
if (
|
|
344
|
-
const h = o[
|
|
345
|
-
for (let
|
|
346
|
-
o[
|
|
340
|
+
let c = 0;
|
|
341
|
+
for (let a = 1; a < o.length; a++)
|
|
342
|
+
if (o[a].rawStop !== null || a === o.length - 1) {
|
|
343
|
+
const f = a - c;
|
|
344
|
+
if (f > 1) {
|
|
345
|
+
const h = o[c].stop, p = (o[a].stop - h) / f;
|
|
346
|
+
for (let g = 1; g < f; g++)
|
|
347
|
+
o[c + g].stop = h + p * g;
|
|
347
348
|
}
|
|
348
|
-
|
|
349
|
+
c = a;
|
|
349
350
|
}
|
|
350
351
|
}
|
|
351
|
-
return { angle:
|
|
352
|
+
return { angle: r, stops: o };
|
|
352
353
|
}
|
|
353
|
-
function
|
|
354
|
+
function Je(s) {
|
|
354
355
|
if (!s || s === "none")
|
|
355
356
|
return null;
|
|
356
|
-
const e =
|
|
357
|
+
const e = Oe(s);
|
|
357
358
|
if (e.length === 0)
|
|
358
359
|
return null;
|
|
359
|
-
const t = e[0].trim(),
|
|
360
|
-
let
|
|
361
|
-
if (
|
|
362
|
-
const
|
|
363
|
-
(
|
|
360
|
+
const t = e[0].trim(), i = /(rgba?\([^)]+\)|#[0-9a-fA-F]+|[a-zA-Z]+)/, r = t.match(i);
|
|
361
|
+
let l = "transparent", n = t;
|
|
362
|
+
if (r && r[1] !== "inset") {
|
|
363
|
+
const p = r[1];
|
|
364
|
+
(p.startsWith("rgb") || p.startsWith("#") || p === "black" || p === "white" || p === "transparent") && (l = p, n = t.replace(p, "").trim());
|
|
364
365
|
}
|
|
365
366
|
n = n.replace("inset", "").trim();
|
|
366
|
-
const o = n.split(/\s+/).map((
|
|
367
|
-
return { offsetX:
|
|
367
|
+
const o = n.split(/\s+/).map((p) => parseFloat(p) || 0), c = o[0] || 0, a = o[1] || 0, f = o[2] || 0, h = o[3] || 0, d = le(l);
|
|
368
|
+
return { offsetX: c, offsetY: a, blurRadius: f, spreadRadius: h, color: d.color, alpha: d.alpha };
|
|
368
369
|
}
|
|
369
|
-
const
|
|
370
|
+
const Ze = `varying vec2 vUv;
|
|
370
371
|
varying vec4 vScreenPos;
|
|
371
372
|
void main() {
|
|
372
373
|
vUv = uv;
|
|
373
374
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
374
375
|
vScreenPos = gl_Position;
|
|
375
|
-
}`,
|
|
376
|
+
}`, Qe = `varying vec2 vUv;
|
|
376
377
|
uniform vec2 uSize;
|
|
377
378
|
uniform vec2 uMeshSize;
|
|
378
379
|
uniform vec4 uShadowColor;
|
|
@@ -531,40 +532,40 @@ void main() {
|
|
|
531
532
|
|
|
532
533
|
// #include <colorspace_fragment>
|
|
533
534
|
}
|
|
534
|
-
`,
|
|
535
|
+
`, et = `uniform sampler2D uTexture;
|
|
535
536
|
varying vec4 vScreenPos;
|
|
536
537
|
uniform vec2 uTextureRepeat;
|
|
537
|
-
uniform vec2 uTextureOffset;`,
|
|
538
|
+
uniform vec2 uTextureOffset;`, tt = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
|
|
538
539
|
vec2 resultUv = screenUv;
|
|
539
540
|
|
|
540
|
-
`,
|
|
541
|
-
baseColor = blendSrcOver(baseColor, texColor);`,
|
|
542
|
-
vertexShader:
|
|
543
|
-
fragmentShader:
|
|
544
|
-
},
|
|
545
|
-
declChunk:
|
|
546
|
-
uvChunk:
|
|
547
|
-
baseColorChunk:
|
|
541
|
+
`, rt = `vec4 texColor = texture2D(uTexture, resultUv);
|
|
542
|
+
baseColor = blendSrcOver(baseColor, texColor);`, De = {
|
|
543
|
+
vertexShader: Ze,
|
|
544
|
+
fragmentShader: Qe
|
|
545
|
+
}, Ae = {
|
|
546
|
+
declChunk: et,
|
|
547
|
+
uvChunk: tt,
|
|
548
|
+
baseColorChunk: rt
|
|
548
549
|
};
|
|
549
|
-
function
|
|
550
|
-
var
|
|
551
|
-
const
|
|
550
|
+
function it(s, e, t, i = null, r) {
|
|
551
|
+
var C;
|
|
552
|
+
const l = i !== null || !!s.imageSrc;
|
|
552
553
|
let n = "";
|
|
553
554
|
const o = {};
|
|
554
|
-
if (
|
|
555
|
-
for (const [
|
|
556
|
-
typeof
|
|
557
|
-
`, o[
|
|
558
|
-
`, o[
|
|
559
|
-
`, o[
|
|
560
|
-
`, o[
|
|
561
|
-
`, o[
|
|
562
|
-
const
|
|
563
|
-
` + n,
|
|
555
|
+
if (r != null && r.uniforms)
|
|
556
|
+
for (const [b, S] of Object.entries(r.uniforms))
|
|
557
|
+
typeof S == "number" ? (n += `uniform float ${b};
|
|
558
|
+
`, o[b] = { value: S }) : Array.isArray(S) ? S.length === 2 ? (n += `uniform vec2 ${b};
|
|
559
|
+
`, o[b] = { value: new w.Vector2(...S) }) : S.length === 3 ? (n += `uniform vec3 ${b};
|
|
560
|
+
`, o[b] = { value: new w.Vector3(...S) }) : S.length === 4 && (n += `uniform vec4 ${b};
|
|
561
|
+
`, o[b] = { value: new w.Vector4(...S) }) : (n += `uniform float ${b};
|
|
562
|
+
`, o[b] = { value: S });
|
|
563
|
+
const c = r !== void 0, a = (l || c ? Ae.declChunk : "") + `
|
|
564
|
+
` + n, f = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
|
|
564
565
|
`, h = s.isTraveler ? `vec2 resultUv = screenUv;
|
|
565
566
|
` : `vec2 localUv = (p / uSize) + 0.5;
|
|
566
567
|
vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
|
|
567
|
-
`,
|
|
568
|
+
`, d = l || c ? f + h + ((r == null ? void 0 : r.uvModifier) || "") : "", p = l || c ? Ae.baseColorChunk : "", g = (r == null ? void 0 : r.colorModifier) || "", M = De.fragmentShader.replace("#INJECT_DECLARATIONS", a).replace("#INJECT_UV_MODIFIER", d).replace("#INJECT_BASE_COLOR", p).replace("#INJECT_COLOR_MODIFIER", g), m = le(s.backgroundColor), y = le(s.borderColor), E = {
|
|
568
569
|
uSize: { value: new w.Vector2(e, t) },
|
|
569
570
|
uMeshSize: { value: new w.Vector2(e, t) },
|
|
570
571
|
uShadowColor: { value: new w.Vector4(0, 0, 0, 0) },
|
|
@@ -573,23 +574,23 @@ vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
|
|
|
573
574
|
uShadowSpread: { value: 0 },
|
|
574
575
|
uBgColor: {
|
|
575
576
|
value: new w.Vector4(
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
577
|
+
m.color.r,
|
|
578
|
+
m.color.g,
|
|
579
|
+
m.color.b,
|
|
580
|
+
m.alpha
|
|
580
581
|
)
|
|
581
582
|
},
|
|
582
583
|
uBorderColor: {
|
|
583
584
|
value: new w.Vector4(
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
585
|
+
y.color.r,
|
|
586
|
+
y.color.g,
|
|
587
|
+
y.color.b,
|
|
588
|
+
y.alpha
|
|
588
589
|
)
|
|
589
590
|
},
|
|
590
591
|
uBorderRadius: { value: new w.Vector4(0, 0, 0, 0) },
|
|
591
|
-
uBorderWidth: { value:
|
|
592
|
-
uOpacity: { value: (
|
|
592
|
+
uBorderWidth: { value: ce(s.borderWidth) },
|
|
593
|
+
uOpacity: { value: (C = s.opacity) != null ? C : 1 },
|
|
593
594
|
uTexture: { value: null },
|
|
594
595
|
uTextureRepeat: { value: new w.Vector2(1, 1) },
|
|
595
596
|
uTextureOffset: { value: new w.Vector2(0, 0) },
|
|
@@ -600,49 +601,49 @@ vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
|
|
|
600
601
|
},
|
|
601
602
|
uGradientStops: { value: new Float32Array(8) }
|
|
602
603
|
};
|
|
603
|
-
|
|
604
|
-
const
|
|
605
|
-
uniforms: te(te({},
|
|
606
|
-
vertexShader:
|
|
607
|
-
fragmentShader:
|
|
604
|
+
_e(E.uBorderRadius.value, s.borderRadius, Math.min(e, t)), l && (E.uTexture.value = i);
|
|
605
|
+
const A = new w.ShaderMaterial({
|
|
606
|
+
uniforms: te(te({}, E), o),
|
|
607
|
+
vertexShader: De.vertexShader,
|
|
608
|
+
fragmentShader: M,
|
|
608
609
|
transparent: !0,
|
|
609
610
|
side: w.FrontSide
|
|
610
611
|
// for better performance
|
|
611
612
|
});
|
|
612
|
-
return s.backgroundImage &&
|
|
613
|
+
return s.backgroundImage && xe(A, { backgroundImage: s.backgroundImage }), A;
|
|
613
614
|
}
|
|
614
|
-
function
|
|
615
|
-
const
|
|
616
|
-
|
|
615
|
+
function st(s, e, t, i, r) {
|
|
616
|
+
const l = ce(e.borderWidth);
|
|
617
|
+
xe(s, {
|
|
617
618
|
width: t,
|
|
618
|
-
height:
|
|
619
|
+
height: i,
|
|
619
620
|
borderRadius: e.borderRadius,
|
|
620
|
-
borderWidth:
|
|
621
|
+
borderWidth: l,
|
|
621
622
|
backgroundColor: e.backgroundColor,
|
|
622
623
|
borderColor: e.borderColor,
|
|
623
624
|
opacity: e.opacity,
|
|
624
|
-
texture:
|
|
625
|
+
texture: r,
|
|
625
626
|
backgroundImage: e.backgroundImage,
|
|
626
627
|
boxShadow: e.boxShadow
|
|
627
628
|
});
|
|
628
629
|
}
|
|
629
|
-
function
|
|
630
|
-
var
|
|
630
|
+
function xe(s, e) {
|
|
631
|
+
var i, r, l;
|
|
631
632
|
if (e.boxShadow !== void 0) {
|
|
632
|
-
const n =
|
|
633
|
+
const n = Je(e.boxShadow);
|
|
633
634
|
n ? (s.uniforms.uShadowColor.value.set(n.color.r, n.color.g, n.color.b, n.alpha), s.uniforms.uShadowOffset.value.set(n.offsetX, n.offsetY), s.uniforms.uShadowBlur.value = n.blurRadius, s.uniforms.uShadowSpread.value = n.spreadRadius, s.userData.shadowPadding = n.blurRadius + n.spreadRadius + Math.max(Math.abs(n.offsetX), Math.abs(n.offsetY))) : (s.uniforms.uShadowColor.value.w = 0, s.userData.shadowPadding = 0);
|
|
634
635
|
}
|
|
635
636
|
if (e.width !== void 0 && e.height !== void 0 && s.uniforms.uSize.value.set(e.width, e.height), s.uniforms.uMeshSize) {
|
|
636
|
-
const n = s.userData.shadowPadding || 0, o = e.width !== void 0 ? e.width : s.uniforms.uSize.value.x,
|
|
637
|
-
s.uniforms.uMeshSize.value.set(o + n * 2,
|
|
637
|
+
const n = s.userData.shadowPadding || 0, o = e.width !== void 0 ? e.width : s.uniforms.uSize.value.x, c = e.height !== void 0 ? e.height : s.uniforms.uSize.value.y;
|
|
638
|
+
s.uniforms.uMeshSize.value.set(o + n * 2, c + n * 2);
|
|
638
639
|
}
|
|
639
640
|
if (e.borderRadius !== void 0) {
|
|
640
641
|
const n = e.width !== void 0 && e.height !== void 0 ? Math.min(e.width, e.height) : Math.min(s.uniforms.uSize.value.x, s.uniforms.uSize.value.y);
|
|
641
|
-
|
|
642
|
+
_e(s.uniforms.uBorderRadius.value, e.borderRadius, n);
|
|
642
643
|
}
|
|
643
644
|
if (e.borderWidth !== void 0 && (s.uniforms.uBorderWidth.value = e.borderWidth), e.backgroundColor !== void 0)
|
|
644
645
|
if (Array.isArray(e.backgroundColor)) {
|
|
645
|
-
const n = s.uniforms.uBgColor.value.w;
|
|
646
|
+
const n = e.backgroundColor[3] !== void 0 ? e.backgroundColor[3] : s.uniforms.uBgColor.value.w;
|
|
646
647
|
s.uniforms.uBgColor.value.set(
|
|
647
648
|
e.backgroundColor[0],
|
|
648
649
|
e.backgroundColor[1],
|
|
@@ -693,34 +694,34 @@ function ye(s, e) {
|
|
|
693
694
|
);
|
|
694
695
|
}
|
|
695
696
|
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);
|
|
696
|
-
const t = e.texture !== void 0 ? e.texture : (
|
|
697
|
+
const t = e.texture !== void 0 ? e.texture : (i = s.uniforms.uTexture) == null ? void 0 : i.value;
|
|
697
698
|
if (t && (t.image instanceof ImageBitmap || t.image instanceof HTMLImageElement || t.image instanceof HTMLCanvasElement)) {
|
|
698
|
-
const n = t.image.naturalWidth || t.image.videoWidth || t.image.width, o = t.image.naturalHeight || t.image.videoHeight || t.image.height,
|
|
699
|
-
if (n && o &&
|
|
700
|
-
const
|
|
701
|
-
if (
|
|
702
|
-
const
|
|
703
|
-
s.uniforms.uTextureRepeat.value.set(
|
|
699
|
+
const n = t.image.naturalWidth || t.image.videoWidth || t.image.width, o = t.image.naturalHeight || t.image.videoHeight || t.image.height, c = (r = e.width) != null ? r : s.uniforms.uSize.value.x, a = (l = e.height) != null ? l : s.uniforms.uSize.value.y;
|
|
700
|
+
if (n && o && c && a) {
|
|
701
|
+
const f = n / o, h = c / a;
|
|
702
|
+
if (f > h) {
|
|
703
|
+
const d = h / f;
|
|
704
|
+
s.uniforms.uTextureRepeat.value.set(d, 1), s.uniforms.uTextureOffset.value.set((1 - d) / 2, 0);
|
|
704
705
|
} else {
|
|
705
|
-
const
|
|
706
|
-
s.uniforms.uTextureRepeat.value.set(1,
|
|
706
|
+
const d = f / h;
|
|
707
|
+
s.uniforms.uTextureRepeat.value.set(1, d), s.uniforms.uTextureOffset.value.set(0, (1 - d) / 2);
|
|
707
708
|
}
|
|
708
709
|
}
|
|
709
710
|
} else
|
|
710
711
|
s.uniforms.uTextureRepeat && (s.uniforms.uTextureRepeat.value.set(1, 1), s.uniforms.uTextureOffset.value.set(0, 0));
|
|
711
712
|
if (e.backgroundImage !== void 0) {
|
|
712
|
-
const n =
|
|
713
|
+
const n = Ke(e.backgroundImage);
|
|
713
714
|
if (n) {
|
|
714
715
|
s.uniforms.uGradientCount.value = n.stops.length, s.uniforms.uGradientAngle.value = n.angle;
|
|
715
716
|
for (let o = 0; o < 8; o++)
|
|
716
717
|
if (o < n.stops.length) {
|
|
717
|
-
const
|
|
718
|
+
const c = n.stops[o];
|
|
718
719
|
s.uniforms.uGradientColors.value[o].set(
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
), s.uniforms.uGradientStops.value[o] =
|
|
720
|
+
c.color.r,
|
|
721
|
+
c.color.g,
|
|
722
|
+
c.color.b,
|
|
723
|
+
c.alpha
|
|
724
|
+
), s.uniforms.uGradientStops.value[o] = c.stop;
|
|
724
725
|
} else
|
|
725
726
|
s.uniforms.uGradientColors.value[o].set(0, 0, 0, 0), s.uniforms.uGradientStops.value[o] = 1;
|
|
726
727
|
} else
|
|
@@ -729,8 +730,8 @@ function ye(s, e) {
|
|
|
729
730
|
for (const n of Object.keys(e))
|
|
730
731
|
n !== "width" && n !== "height" && n !== "borderRadius" && n !== "borderWidth" && n !== "backgroundColor" && n !== "borderColor" && n !== "opacity" && n !== "bgOpacity" && n !== "borderOpacity" && n !== "texture" && n !== "backgroundImage" && n !== "boxShadow" && 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]);
|
|
731
732
|
}
|
|
732
|
-
function
|
|
733
|
-
var
|
|
733
|
+
function _e(s, e, t = 0) {
|
|
734
|
+
var c, a, f, h;
|
|
734
735
|
if (e == null) {
|
|
735
736
|
s.set(0, 0, 0, 0);
|
|
736
737
|
return;
|
|
@@ -743,45 +744,45 @@ function Be(s, e, t = 0) {
|
|
|
743
744
|
s.set(e[0], e[1], e[2], e[3]);
|
|
744
745
|
return;
|
|
745
746
|
}
|
|
746
|
-
const
|
|
747
|
-
s.set(
|
|
747
|
+
const i = e.split("/")[0].trim().split(/\s+/), r = ce(i[0], t), l = ce((c = i[1]) != null ? c : i[0], t), n = ce((a = i[2]) != null ? a : i[0], t), o = ce((h = (f = i[3]) != null ? f : i[1]) != null ? h : i[0], t);
|
|
748
|
+
s.set(r, l, n, o);
|
|
748
749
|
}
|
|
749
|
-
const
|
|
750
|
-
create(s, e, t,
|
|
751
|
-
return s === "BOX" ?
|
|
750
|
+
const P = {
|
|
751
|
+
create(s, e, t, i, r, l = 2, n = null, o) {
|
|
752
|
+
return s === "BOX" ? it(
|
|
752
753
|
e,
|
|
753
|
-
r,
|
|
754
754
|
i,
|
|
755
|
+
r,
|
|
755
756
|
n,
|
|
756
757
|
o
|
|
757
|
-
) : s === "TEXT" ? new
|
|
758
|
+
) : s === "TEXT" ? new je(
|
|
758
759
|
t || "",
|
|
759
760
|
e,
|
|
760
|
-
r,
|
|
761
761
|
i,
|
|
762
|
-
|
|
762
|
+
r,
|
|
763
|
+
l
|
|
763
764
|
) : new w.MeshBasicMaterial({ visible: !1 });
|
|
764
765
|
},
|
|
765
|
-
update(s, e, t,
|
|
766
|
-
e === "BOX" ?
|
|
766
|
+
update(s, e, t, i, r, l, n = 2, o) {
|
|
767
|
+
e === "BOX" ? st(
|
|
767
768
|
s,
|
|
768
769
|
t,
|
|
769
|
-
|
|
770
|
-
|
|
770
|
+
r,
|
|
771
|
+
l,
|
|
771
772
|
o
|
|
772
773
|
) : e === "TEXT" && s.updateText(
|
|
773
|
-
|
|
774
|
+
i || "",
|
|
774
775
|
t,
|
|
775
|
-
|
|
776
|
-
|
|
776
|
+
r,
|
|
777
|
+
l,
|
|
777
778
|
n
|
|
778
779
|
);
|
|
779
780
|
},
|
|
780
781
|
forceUpdateUniforms(s, e) {
|
|
781
|
-
|
|
782
|
+
xe(s, e);
|
|
782
783
|
}
|
|
783
784
|
};
|
|
784
|
-
class
|
|
785
|
+
class nt {
|
|
785
786
|
constructor(e, t = !0) {
|
|
786
787
|
u(this, "observer");
|
|
787
788
|
u(this, "textures", /* @__PURE__ */ new WeakMap());
|
|
@@ -789,10 +790,10 @@ class it {
|
|
|
789
790
|
u(this, "elementUrls", /* @__PURE__ */ new WeakMap());
|
|
790
791
|
u(this, "onUpdate");
|
|
791
792
|
this.onUpdate = e, t && (this.observer = new IntersectionObserver(
|
|
792
|
-
(
|
|
793
|
-
for (const
|
|
794
|
-
const
|
|
795
|
-
|
|
793
|
+
(i) => {
|
|
794
|
+
for (const r of i) {
|
|
795
|
+
const l = r.target;
|
|
796
|
+
r.isIntersecting ? this.loadTexture(l) : this.disposeTexture(l);
|
|
796
797
|
}
|
|
797
798
|
},
|
|
798
799
|
{ rootMargin: "300px" }
|
|
@@ -807,31 +808,31 @@ class it {
|
|
|
807
808
|
e.nodeType === Node.ELEMENT_NODE && this.observer && this.observer.unobserve(e), this.disposeTexture(e), this.elementUrls.delete(e), this.loadStatus.delete(e);
|
|
808
809
|
}
|
|
809
810
|
loadTexture(e) {
|
|
810
|
-
return
|
|
811
|
+
return Te(this, null, function* () {
|
|
811
812
|
if (this.loadStatus.get(e) || this.textures.has(e))
|
|
812
813
|
return;
|
|
813
814
|
const t = this.elementUrls.get(e);
|
|
814
815
|
if (t) {
|
|
815
816
|
this.loadStatus.set(e, !0);
|
|
816
817
|
try {
|
|
817
|
-
let
|
|
818
|
+
let i;
|
|
818
819
|
if (t.startsWith("data:image/svg+xml"))
|
|
819
|
-
|
|
820
|
+
i = yield new Promise((l, n) => {
|
|
820
821
|
const o = new Image();
|
|
821
|
-
o.onload = () =>
|
|
822
|
+
o.onload = () => l(o), o.onerror = n, o.src = t;
|
|
822
823
|
});
|
|
823
824
|
else {
|
|
824
825
|
const n = yield (yield fetch(t)).blob();
|
|
825
|
-
|
|
826
|
+
i = yield createImageBitmap(n, { imageOrientation: "flipY" });
|
|
826
827
|
}
|
|
827
828
|
if (this.elementUrls.get(e) !== t) {
|
|
828
|
-
"close" in
|
|
829
|
+
"close" in i && i.close();
|
|
829
830
|
return;
|
|
830
831
|
}
|
|
831
|
-
const
|
|
832
|
-
|
|
833
|
-
} catch (
|
|
834
|
-
console.warn("[MirageEngine] Failed to load texture:", t,
|
|
832
|
+
const r = new w.Texture(i);
|
|
833
|
+
i instanceof HTMLImageElement || (r.flipY = !1), r.colorSpace = w.LinearSRGBColorSpace, r.needsUpdate = !0, this.textures.set(e, r), this.onUpdate(e, r);
|
|
834
|
+
} catch (i) {
|
|
835
|
+
console.warn("[MirageEngine] Failed to load texture:", t, i);
|
|
835
836
|
} finally {
|
|
836
837
|
this.elementUrls.has(e) && this.loadStatus.set(e, !1);
|
|
837
838
|
}
|
|
@@ -849,8 +850,8 @@ class it {
|
|
|
849
850
|
this.observer && this.observer.disconnect();
|
|
850
851
|
}
|
|
851
852
|
}
|
|
852
|
-
class
|
|
853
|
-
constructor(e, t,
|
|
853
|
+
class ot {
|
|
854
|
+
constructor(e, t, i, r) {
|
|
854
855
|
u(this, "canvas");
|
|
855
856
|
u(this, "scene");
|
|
856
857
|
u(this, "camera");
|
|
@@ -868,21 +869,21 @@ class st {
|
|
|
868
869
|
u(this, "registry");
|
|
869
870
|
u(this, "targetRect");
|
|
870
871
|
u(this, "travelersByLayer", Array.from(
|
|
871
|
-
{ length:
|
|
872
|
+
{ length: N.MAX_LAYERS },
|
|
872
873
|
() => /* @__PURE__ */ new Set()
|
|
873
874
|
));
|
|
874
875
|
u(this, "textureManager");
|
|
875
876
|
// private meshMap: Map<HTMLElement, THREE.Mesh> = new Map();
|
|
876
877
|
u(this, "fixedMeshes", /* @__PURE__ */ new Set());
|
|
877
|
-
var o,
|
|
878
|
-
this.target = e, this.mountContainer =
|
|
879
|
-
const
|
|
880
|
-
|
|
878
|
+
var o, c, a, f, h;
|
|
879
|
+
this.target = e, this.mountContainer = i, this.registry = r, this.mode = (o = t.mode) != null ? o : "overlay", this.canvasSize = (c = t.canvasSize) != null ? c : "viewport", this.clipArea = (a = t.travelerClipArea) != null ? a : 1, this.targetLayer = (f = t.layer) != null ? f : "base", this.textureManager = new nt((d, p) => {
|
|
880
|
+
const g = this.registry.get(d);
|
|
881
|
+
g && g.material instanceof w.ShaderMaterial && P.forceUpdateUniforms(g.material, { texture: p });
|
|
881
882
|
}, this.isViewport), this.canvas = document.createElement("canvas"), this.scene = new w.Scene(), this.targetRect = this.target.getBoundingClientRect();
|
|
882
|
-
const
|
|
883
|
+
const l = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, n = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
|
|
883
884
|
this.camera = new w.OrthographicCamera(
|
|
884
|
-
|
|
885
|
-
|
|
885
|
+
l / -2,
|
|
886
|
+
l / 2,
|
|
886
887
|
n / 2,
|
|
887
888
|
n / -2,
|
|
888
889
|
1,
|
|
@@ -893,7 +894,7 @@ class st {
|
|
|
893
894
|
antialias: !0
|
|
894
895
|
// [new]
|
|
895
896
|
// premultipliedAlpha: true
|
|
896
|
-
}), w.ColorManagement.enabled = !1, this.renderer.outputColorSpace = w.LinearSRGBColorSpace, this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setSize(
|
|
897
|
+
}), w.ColorManagement.enabled = !1, this.renderer.outputColorSpace = w.LinearSRGBColorSpace, this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setSize(l, n), this.applyTextQuality((h = t.quality) != null ? h : "medium");
|
|
897
898
|
}
|
|
898
899
|
get isViewport() {
|
|
899
900
|
return this.mode === "overlay" && this.canvasSize === "viewport";
|
|
@@ -902,12 +903,12 @@ class st {
|
|
|
902
903
|
return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ? O.SELECTED : O.BASE;
|
|
903
904
|
}
|
|
904
905
|
createRenderTarget() {
|
|
905
|
-
for (let e = 0; e <
|
|
906
|
-
const t = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width,
|
|
906
|
+
for (let e = 0; e < N.MAX_LAYERS; e++) {
|
|
907
|
+
const t = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, i = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
|
|
907
908
|
this.renderTargets.push(
|
|
908
909
|
new w.WebGLRenderTarget(
|
|
909
910
|
t * this.qualityFactor,
|
|
910
|
-
|
|
911
|
+
i * this.qualityFactor,
|
|
911
912
|
{
|
|
912
913
|
minFilter: w.LinearFilter,
|
|
913
914
|
magFilter: w.LinearFilter,
|
|
@@ -947,15 +948,15 @@ class st {
|
|
|
947
948
|
this.canvas.style.width = `${e}px`, this.canvas.style.height = `${t}px`, this.mode === "duplicate" ? (this.canvas.style.position = "", this.canvas.style.top = "", this.canvas.style.left = "", this.canvas.style.display = "block") : (this.canvas.style.position = this.isViewport ? "fixed" : "absolute", this.canvas.style.top = this.isViewport ? `-${this.overscan}px` : `${this.target.offsetTop}px`, this.canvas.style.left = this.isViewport ? `-${this.overscan}px` : `${this.target.offsetLeft}px`, this.canvas.style.display = "block");
|
|
948
949
|
}
|
|
949
950
|
updateUniforms(e, t) {
|
|
950
|
-
const
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
951
|
+
const i = this.registry.get(e);
|
|
952
|
+
i && (i.traverse((r) => {
|
|
953
|
+
r.isMesh && r.material && P.forceUpdateUniforms(
|
|
954
|
+
r.material,
|
|
954
955
|
t
|
|
955
956
|
);
|
|
956
|
-
}),
|
|
957
|
-
|
|
958
|
-
|
|
957
|
+
}), i.userData.nativeMesh && i.userData.nativeMesh.traverse((r) => {
|
|
958
|
+
r.isMesh && r.material && P.forceUpdateUniforms(
|
|
959
|
+
r.material,
|
|
959
960
|
t
|
|
960
961
|
);
|
|
961
962
|
}));
|
|
@@ -965,23 +966,23 @@ class st {
|
|
|
965
966
|
}
|
|
966
967
|
setSize(e, t) {
|
|
967
968
|
this.renderer.setSize(e, t);
|
|
968
|
-
for (const
|
|
969
|
-
|
|
969
|
+
for (const i of this.renderTargets)
|
|
970
|
+
i.setSize(e * this.qualityFactor, t * this.qualityFactor);
|
|
970
971
|
this.camera.left = e / -2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = t / -2, this.camera.updateProjectionMatrix();
|
|
971
972
|
}
|
|
972
973
|
syncScene(e, t) {
|
|
973
|
-
const
|
|
974
|
-
|
|
975
|
-
const h = this.registry.get(
|
|
974
|
+
const i = this.target.getBoundingClientRect(), r = this.isViewport ? window.innerWidth + this.overscan * 2 : i.width, l = this.isViewport ? window.innerHeight + this.overscan * 2 : i.height, n = this.isViewport ? this.canvas.clientWidth : this.targetRect.width, o = this.isViewport ? this.canvas.clientHeight : this.targetRect.height, c = Math.abs(r - n) > 0.1 || Math.abs(l - o) > 0.1, a = this.mode === "overlay" && (Math.abs(i.top - this.targetRect.top) > 0.1 || Math.abs(i.left - this.targetRect.left) > 0.1);
|
|
975
|
+
c ? (this.targetRect = i, this.setSize(r, l), this.updateCanvasLayout()) : a ? (this.targetRect = i, this.updateCanvasLayout()) : this.targetRect = i, this.renderOrder = 0, this.reconcileNode(e), t.size > 0 && t.forEach((f) => {
|
|
976
|
+
const h = this.registry.get(f);
|
|
976
977
|
if (h) {
|
|
977
978
|
this.scene.remove(h);
|
|
978
|
-
for (const
|
|
979
|
-
|
|
979
|
+
for (const d of this.travelersByLayer)
|
|
980
|
+
d.delete(h);
|
|
980
981
|
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(
|
|
981
|
-
(
|
|
982
|
-
) : h.userData.nativeMesh.material.dispose(), h.userData.nativeMesh.geometry.dispose()), h.traverse((
|
|
983
|
-
|
|
984
|
-
}), this.registry.remove(
|
|
982
|
+
(d) => d.dispose()
|
|
983
|
+
) : h.userData.nativeMesh.material.dispose(), h.userData.nativeMesh.geometry.dispose()), h.traverse((d) => {
|
|
984
|
+
d instanceof w.Mesh && (d.geometry && d.geometry.dispose(), d.material && (Array.isArray(d.material) ? d.material.forEach((p) => p.dispose()) : d.material.dispose()));
|
|
985
|
+
}), this.registry.remove(f), this.textureManager.unregister(f);
|
|
985
986
|
}
|
|
986
987
|
});
|
|
987
988
|
}
|
|
@@ -990,11 +991,11 @@ class st {
|
|
|
990
991
|
// => 이후 activeElements를 이용하여 mesh를 정리!!!+ map에서도 삭제
|
|
991
992
|
// private reconcileNode(node: SceneNode, activeElements: Set<HTMLElement>) {
|
|
992
993
|
reconcileNode(e) {
|
|
993
|
-
var
|
|
994
|
+
var r, l;
|
|
994
995
|
let t = this.registry.get(e.element);
|
|
995
|
-
const
|
|
996
|
-
if (t && t.userData.shaderHash !==
|
|
997
|
-
const n = new w.PlaneGeometry(1, 1), o = e.isTraveler ? (
|
|
996
|
+
const i = JSON.stringify(e.shaderHooks || null);
|
|
997
|
+
if (t && t.userData.shaderHash !== i && (this.scene.remove(t), t.geometry.dispose(), t.material instanceof w.Material && t.material.dispose(), this.registry.remove(e.element), t = void 0), !t) {
|
|
998
|
+
const n = new w.PlaneGeometry(1, 1), o = e.isTraveler ? (r = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : r.texture : this.textureManager.get(e.element), c = P.create(
|
|
998
999
|
"BOX",
|
|
999
1000
|
e.styles,
|
|
1000
1001
|
"",
|
|
@@ -1004,10 +1005,10 @@ class st {
|
|
|
1004
1005
|
o,
|
|
1005
1006
|
e.shaderHooks
|
|
1006
1007
|
);
|
|
1007
|
-
t = new w.Mesh(n,
|
|
1008
|
+
t = new w.Mesh(n, c), e.type === "TEXT" && (t.name = "BG_MESH"), this.scene.add(t), this.registry.register(e.element, t), t.userData.baseMaterial = c, t.userData.domElement = e.element, t.userData.shaderHash = i;
|
|
1008
1009
|
}
|
|
1009
|
-
if ((
|
|
1010
|
-
for (let n = 0; n <
|
|
1010
|
+
if (t.userData.clipElements = e.clipElements, (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)
|
|
1011
|
+
for (let n = 0; n < N.MAX_LAYERS; n++)
|
|
1011
1012
|
n === e.captureLayer - 2 ? this.travelersByLayer[n].add(t) : this.travelersByLayer[n].delete(t);
|
|
1012
1013
|
else
|
|
1013
1014
|
for (const n of this.travelersByLayer)
|
|
@@ -1022,387 +1023,420 @@ class st {
|
|
|
1022
1023
|
!0
|
|
1023
1024
|
));
|
|
1024
1025
|
}
|
|
1025
|
-
reconcileTextChild(e, t,
|
|
1026
|
-
var
|
|
1027
|
-
const
|
|
1026
|
+
reconcileTextChild(e, t, i) {
|
|
1027
|
+
var a;
|
|
1028
|
+
const r = t.textLines || [
|
|
1028
1029
|
{ text: t.textContent || "", rect: t.rect }
|
|
1029
|
-
],
|
|
1030
|
-
if (t.dirtyMask &
|
|
1030
|
+
], l = i ? t.nativeStyles : t.textStyles, n = JSON.stringify(l) + t.textContent + r.map((f) => f.text).join("|"), o = (a = e.userData) == null ? void 0 : a.textChildStyleHash;
|
|
1031
|
+
if (t.dirtyMask & be || n !== o) {
|
|
1031
1032
|
e.children.filter(
|
|
1032
|
-
(
|
|
1033
|
-
).forEach((
|
|
1034
|
-
var
|
|
1035
|
-
const
|
|
1036
|
-
(
|
|
1033
|
+
(g) => g.name.startsWith("TEXT_CHILD")
|
|
1034
|
+
).forEach((g) => {
|
|
1035
|
+
var m;
|
|
1036
|
+
const M = g;
|
|
1037
|
+
(m = M.material.map) == null || m.dispose(), M.geometry.dispose(), e.remove(M);
|
|
1037
1038
|
});
|
|
1038
|
-
const h = t.rect,
|
|
1039
|
-
|
|
1040
|
-
const
|
|
1039
|
+
const h = t.rect, d = h.x + h.width / 2, p = h.y + h.height / 2;
|
|
1040
|
+
r.forEach((g, M) => {
|
|
1041
|
+
const m = P.create(
|
|
1041
1042
|
"TEXT",
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1043
|
+
l,
|
|
1044
|
+
g.text,
|
|
1045
|
+
g.rect.width,
|
|
1046
|
+
g.rect.height,
|
|
1046
1047
|
this.qualityFactor
|
|
1047
|
-
),
|
|
1048
|
-
|
|
1049
|
-
const
|
|
1050
|
-
|
|
1051
|
-
const
|
|
1052
|
-
|
|
1053
|
-
t.rect.width === 0 ? 0 :
|
|
1054
|
-
t.rect.height === 0 ? 0 :
|
|
1048
|
+
), y = new w.PlaneGeometry(1, 1), E = new w.Mesh(y, m);
|
|
1049
|
+
E.name = `TEXT_CHILD_${M}`;
|
|
1050
|
+
const A = t.rect.width === 0 ? 1 : g.rect.width / t.rect.width, C = t.rect.height === 0 ? 1 : g.rect.height / t.rect.height;
|
|
1051
|
+
E.scale.set(A, C, 1);
|
|
1052
|
+
const b = g.rect.x + g.rect.width / 2, S = g.rect.y + g.rect.height / 2, z = b - d, X = -(S - p);
|
|
1053
|
+
E.position.set(
|
|
1054
|
+
t.rect.width === 0 ? 0 : z / t.rect.width,
|
|
1055
|
+
t.rect.height === 0 ? 0 : X / t.rect.height,
|
|
1055
1056
|
5e-3
|
|
1056
|
-
), e.add(
|
|
1057
|
+
), e.add(E);
|
|
1057
1058
|
}), e.userData.textChildStyleHash = n;
|
|
1058
1059
|
}
|
|
1059
|
-
e.children.forEach((
|
|
1060
|
-
if (!
|
|
1060
|
+
e.children.forEach((f) => {
|
|
1061
|
+
if (!f.name.startsWith("TEXT_CHILD"))
|
|
1061
1062
|
return;
|
|
1062
|
-
const h =
|
|
1063
|
-
if (
|
|
1064
|
-
h.layers.set(O.HIDDEN), t.visibility &
|
|
1063
|
+
const h = f;
|
|
1064
|
+
if (i && t.nativeLayer !== void 0)
|
|
1065
|
+
h.layers.set(O.HIDDEN), t.visibility & G && h.layers.enable(O.getCaptureLayer(t.nativeLayer));
|
|
1065
1066
|
else {
|
|
1066
|
-
const
|
|
1067
|
-
if (h.layers.set(
|
|
1068
|
-
if (!
|
|
1069
|
-
for (let
|
|
1070
|
-
|
|
1067
|
+
const d = t.visibility & G ? O.BASE : O.HIDDEN;
|
|
1068
|
+
if (h.layers.set(d), t.visibility & ae && h.layers.enable(O.SELECTED), t.visibility & G)
|
|
1069
|
+
if (!i && t.nativeLayer !== void 0 && t.nativeStyles !== void 0)
|
|
1070
|
+
for (let p = t.captureLayer; p <= N.MAX_LAYERS + 1; p++)
|
|
1071
|
+
p !== t.nativeLayer && h.layers.enable(O.getCaptureLayer(p));
|
|
1071
1072
|
else
|
|
1072
|
-
for (let
|
|
1073
|
-
h.layers.enable(O.getCaptureLayer(
|
|
1073
|
+
for (let p = t.captureLayer; p <= N.MAX_LAYERS + 1; p++)
|
|
1074
|
+
h.layers.enable(O.getCaptureLayer(p));
|
|
1074
1075
|
}
|
|
1075
1076
|
});
|
|
1076
1077
|
}
|
|
1077
1078
|
updateMeshProperties(e, t) {
|
|
1078
|
-
var
|
|
1079
|
-
const { rect:
|
|
1079
|
+
var C, b, S, z, X;
|
|
1080
|
+
const { rect: i, styles: r } = t, l = this.renderer.getPixelRatio(), n = this.renderer.domElement.width / l, o = this.renderer.domElement.height / l;
|
|
1080
1081
|
e.material = e.userData.baseMaterial;
|
|
1081
|
-
let
|
|
1082
|
-
e.scale.set(
|
|
1083
|
-
x:
|
|
1084
|
-
y:
|
|
1085
|
-
width:
|
|
1086
|
-
height:
|
|
1082
|
+
let c = ((C = e.material.userData) == null ? void 0 : C.shadowPadding) || 0;
|
|
1083
|
+
e.scale.set(i.width + c * 2, i.height + c * 2, 1), e.userData.domRect = {
|
|
1084
|
+
x: i.x,
|
|
1085
|
+
y: i.y,
|
|
1086
|
+
width: i.width,
|
|
1087
|
+
height: i.height
|
|
1087
1088
|
};
|
|
1088
|
-
const
|
|
1089
|
+
const a = 1e-3;
|
|
1089
1090
|
this.renderOrder++;
|
|
1090
|
-
const
|
|
1091
|
-
let
|
|
1091
|
+
const f = this.targetRect.left + window.scrollX, h = this.targetRect.top + window.scrollY;
|
|
1092
|
+
let d, p;
|
|
1092
1093
|
if (this.isViewport)
|
|
1093
|
-
|
|
1094
|
+
d = i.x - window.innerWidth / 2 + i.width / 2, p = -i.y + window.innerHeight / 2 - i.height / 2;
|
|
1094
1095
|
else {
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1096
|
+
const B = i.x - f, k = i.y - h;
|
|
1097
|
+
d = B - n / 2 + i.width / 2, p = -k + o / 2 - i.height / 2;
|
|
1097
1098
|
}
|
|
1098
1099
|
e.position.set(
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1100
|
+
d,
|
|
1101
|
+
p,
|
|
1102
|
+
r.zIndex + this.renderOrder * a
|
|
1102
1103
|
);
|
|
1103
|
-
const
|
|
1104
|
-
e.userData.basePosition = { x:
|
|
1105
|
-
const
|
|
1106
|
-
let
|
|
1107
|
-
if (
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1104
|
+
const g = i.x, M = i.y;
|
|
1105
|
+
e.userData.basePosition = { x: d, y: p }, e.userData.originalBasePosition = { x: d, y: p }, e.userData.baseSize = { width: i.width, height: i.height }, e.userData.baseDOM = { x: g, y: M }, e.userData.isFixed = t.isFixed, e.userData.initialScroll = { x: window.scrollX, y: window.scrollY };
|
|
1106
|
+
const m = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element, y = window.getComputedStyle(m);
|
|
1107
|
+
let E = 0, A = 0;
|
|
1108
|
+
if (y.transform && y.transform !== "none") {
|
|
1109
|
+
const B = new DOMMatrix(y.transform);
|
|
1110
|
+
E = B.m41, A = B.m42;
|
|
1110
1111
|
}
|
|
1111
|
-
if (e.userData.baseTransform = { x:
|
|
1112
|
+
if (e.userData.baseTransform = { x: E, y: A }, delete e.userData.originRatioX, delete e.userData.originRatioY, P.update(
|
|
1112
1113
|
e.userData.baseMaterial,
|
|
1113
1114
|
"BOX",
|
|
1114
|
-
|
|
1115
|
+
r,
|
|
1115
1116
|
"",
|
|
1116
|
-
|
|
1117
|
-
|
|
1117
|
+
i.width,
|
|
1118
|
+
i.height,
|
|
1118
1119
|
this.qualityFactor,
|
|
1119
|
-
t.isTraveler ? (
|
|
1120
|
+
t.isTraveler ? (b = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : b.texture : this.textureManager.get(t.element)
|
|
1120
1121
|
), t.nativeStyles && t.nativeRect) {
|
|
1121
1122
|
if (!e.userData.nativeMesh) {
|
|
1122
|
-
const
|
|
1123
|
+
const U = P.create(
|
|
1123
1124
|
"BOX",
|
|
1124
1125
|
t.nativeStyles,
|
|
1125
1126
|
"",
|
|
1126
1127
|
t.nativeRect.width,
|
|
1127
1128
|
t.nativeRect.height,
|
|
1128
1129
|
this.qualityFactor,
|
|
1129
|
-
t.isTraveler ? (
|
|
1130
|
+
t.isTraveler ? (S = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : S.texture : this.textureManager.get(t.element),
|
|
1130
1131
|
t.shaderHooks
|
|
1131
|
-
),
|
|
1132
|
-
t.type === "TEXT" && (
|
|
1132
|
+
), V = new w.Mesh(e.geometry, U);
|
|
1133
|
+
t.type === "TEXT" && (V.name = "BG_MESH"), this.scene.add(V), e.userData.nativeMesh = V;
|
|
1133
1134
|
}
|
|
1134
|
-
const
|
|
1135
|
-
let
|
|
1135
|
+
const B = e.userData.nativeMesh;
|
|
1136
|
+
let k, j;
|
|
1136
1137
|
if (this.isViewport)
|
|
1137
|
-
|
|
1138
|
+
k = t.nativeRect.x - window.innerWidth / 2 + t.nativeRect.width / 2, j = -t.nativeRect.y + window.innerHeight / 2 - t.nativeRect.height / 2;
|
|
1138
1139
|
else {
|
|
1139
|
-
const
|
|
1140
|
-
|
|
1140
|
+
const U = t.nativeRect.x - f, V = t.nativeRect.y - h;
|
|
1141
|
+
k = U - n / 2 + t.nativeRect.width / 2, j = -V + o / 2 - t.nativeRect.height / 2;
|
|
1141
1142
|
}
|
|
1142
|
-
let
|
|
1143
|
+
let J = t.nativeRect.width, Z = t.nativeRect.height, L = k, _ = j;
|
|
1143
1144
|
if (t.nativeStyles.transform) {
|
|
1144
|
-
const
|
|
1145
|
-
if (
|
|
1146
|
-
let
|
|
1147
|
-
|
|
1145
|
+
const U = t.nativeStyles.transform, V = U.match(/scale\(([\d.]+%?)\)/);
|
|
1146
|
+
if (V) {
|
|
1147
|
+
let x = parseFloat(V[1]);
|
|
1148
|
+
V[1].includes("%") && (x /= 100), J *= x, Z *= x;
|
|
1148
1149
|
}
|
|
1149
|
-
const ie =
|
|
1150
|
+
const ie = U.match(/scaleX\(([\d.]+%?)\)/);
|
|
1150
1151
|
if (ie) {
|
|
1151
|
-
let
|
|
1152
|
-
ie[1].includes("%") && (
|
|
1152
|
+
let x = parseFloat(ie[1]);
|
|
1153
|
+
ie[1].includes("%") && (x /= 100), J *= x;
|
|
1153
1154
|
}
|
|
1154
|
-
const se =
|
|
1155
|
+
const se = U.match(/scaleY\(([\d.]+%?)\)/);
|
|
1155
1156
|
if (se) {
|
|
1156
|
-
let
|
|
1157
|
-
se[1].includes("%") && (
|
|
1157
|
+
let x = parseFloat(se[1]);
|
|
1158
|
+
se[1].includes("%") && (x /= 100), Z *= x;
|
|
1158
1159
|
}
|
|
1159
|
-
const
|
|
1160
|
-
if (
|
|
1161
|
-
const
|
|
1162
|
-
let _ = parseFloat(b);
|
|
1163
|
-
b.includes("%") && (_ = _ / 100 * t.nativeRect.width);
|
|
1160
|
+
const ne = U.match(/translate\(([^,]+),\s*([^)]+)\)/);
|
|
1161
|
+
if (ne) {
|
|
1162
|
+
const x = ne[1].trim(), T = ne[2].trim();
|
|
1164
1163
|
let F = parseFloat(x);
|
|
1165
|
-
x.includes("%") && (F = F / 100 * t.nativeRect.
|
|
1164
|
+
x.includes("%") && (F = F / 100 * t.nativeRect.width);
|
|
1165
|
+
let D = parseFloat(T);
|
|
1166
|
+
T.includes("%") && (D = D / 100 * t.nativeRect.height), L += F, _ -= D;
|
|
1166
1167
|
}
|
|
1167
|
-
const
|
|
1168
|
-
if (
|
|
1169
|
-
const
|
|
1170
|
-
let
|
|
1171
|
-
|
|
1168
|
+
const he = U.match(/translateX\(([^)]+)\)/);
|
|
1169
|
+
if (he) {
|
|
1170
|
+
const x = he[1].trim();
|
|
1171
|
+
let T = parseFloat(x);
|
|
1172
|
+
x.includes("%") && (T = T / 100 * t.nativeRect.width), L += T;
|
|
1172
1173
|
}
|
|
1173
|
-
const
|
|
1174
|
-
if (
|
|
1175
|
-
const
|
|
1176
|
-
let
|
|
1177
|
-
|
|
1174
|
+
const v = U.match(/translateY\(([^)]+)\)/);
|
|
1175
|
+
if (v) {
|
|
1176
|
+
const x = v[1].trim();
|
|
1177
|
+
let T = parseFloat(x);
|
|
1178
|
+
x.includes("%") && (T = T / 100 * t.nativeRect.height), _ -= T;
|
|
1178
1179
|
}
|
|
1179
1180
|
}
|
|
1180
|
-
let K = ((
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
t.nativeStyles.zIndex + this.renderOrder *
|
|
1185
|
-
),
|
|
1186
|
-
|
|
1181
|
+
let K = ((z = B.material.userData) == null ? void 0 : z.shadowPadding) || 0;
|
|
1182
|
+
B.scale.set(J + K * 2, Z + K * 2, 1), B.position.set(
|
|
1183
|
+
L,
|
|
1184
|
+
_,
|
|
1185
|
+
t.nativeStyles.zIndex + this.renderOrder * a
|
|
1186
|
+
), P.update(
|
|
1187
|
+
B.material,
|
|
1187
1188
|
"BOX",
|
|
1188
1189
|
t.nativeStyles,
|
|
1189
1190
|
"",
|
|
1190
1191
|
t.nativeRect.width,
|
|
1191
1192
|
t.nativeRect.height,
|
|
1192
1193
|
this.qualityFactor,
|
|
1193
|
-
t.isTraveler ? (
|
|
1194
|
+
t.isTraveler ? (X = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : X.texture : this.textureManager.get(t.element)
|
|
1194
1195
|
);
|
|
1195
1196
|
} else
|
|
1196
1197
|
e.userData.nativeMesh && (this.scene.remove(e.userData.nativeMesh), e.userData.nativeMesh.material instanceof w.Material && e.userData.nativeMesh.material.dispose(), delete e.userData.nativeMesh);
|
|
1197
1198
|
}
|
|
1198
1199
|
updateMeshLayers(e, t) {
|
|
1199
|
-
const
|
|
1200
|
-
if (e.layers.set(
|
|
1201
|
-
const
|
|
1202
|
-
if (
|
|
1203
|
-
|
|
1204
|
-
for (let
|
|
1205
|
-
|
|
1200
|
+
const i = t.visibility & G ? O.BASE : O.HIDDEN;
|
|
1201
|
+
if (e.layers.set(i), t.visibility & ae && e.layers.enable(O.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
|
|
1202
|
+
const r = e.userData.nativeMesh;
|
|
1203
|
+
if (r.layers.set(O.HIDDEN), t.visibility & G) {
|
|
1204
|
+
r.layers.enable(O.getCaptureLayer(t.nativeLayer));
|
|
1205
|
+
for (let l = t.captureLayer; l <= N.MAX_LAYERS + 1; l++)
|
|
1206
|
+
l !== t.nativeLayer && e.layers.enable(O.getCaptureLayer(l));
|
|
1206
1207
|
}
|
|
1207
|
-
} else if (t.visibility &
|
|
1208
|
-
for (let
|
|
1209
|
-
e.layers.enable(O.getCaptureLayer(
|
|
1208
|
+
} else if (t.visibility & G)
|
|
1209
|
+
for (let r = t.captureLayer; r <= N.MAX_LAYERS + 1; r++)
|
|
1210
|
+
e.layers.enable(O.getCaptureLayer(r));
|
|
1210
1211
|
}
|
|
1211
|
-
captureRenderTarget(e, t,
|
|
1212
|
-
if (e.size === 0 || !
|
|
1212
|
+
captureRenderTarget(e, t, i) {
|
|
1213
|
+
if (e.size === 0 || !i)
|
|
1213
1214
|
return;
|
|
1214
|
-
const
|
|
1215
|
-
this.renderer.getClearColor(
|
|
1216
|
-
const n = new w.Vector3(), o = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width,
|
|
1217
|
-
for (const
|
|
1218
|
-
n.setFromMatrixPosition(
|
|
1219
|
-
const h = (n.x + 1) / 2 * o,
|
|
1220
|
-
let
|
|
1221
|
-
typeof this.clipArea == "number" ?
|
|
1222
|
-
const
|
|
1223
|
-
this.renderer.setScissor(
|
|
1215
|
+
const r = new w.Color(), l = this.renderer.getClearAlpha();
|
|
1216
|
+
this.renderer.getClearColor(r), this.renderer.setClearColor(0, 0), this.renderer.setRenderTarget(i), this.renderer.clear(), this.renderer.autoClear = !1, this.renderer.setScissorTest(!0), this.camera.layers.set(t);
|
|
1217
|
+
const n = new w.Vector3(), o = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, c = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height, a = this.renderer.getPixelRatio();
|
|
1218
|
+
for (const f of e) {
|
|
1219
|
+
n.setFromMatrixPosition(f.matrixWorld), n.project(this.camera);
|
|
1220
|
+
const h = (n.x + 1) / 2 * o, d = (n.y + 1) / 2 * c;
|
|
1221
|
+
let p = 0, g = 1;
|
|
1222
|
+
typeof this.clipArea == "number" ? g = this.clipArea : this.clipArea.endsWith("%") ? g = parseFloat(this.clipArea) / 100 : this.clipArea.endsWith("px") && (p = parseFloat(this.clipArea));
|
|
1223
|
+
const M = f.scale.x * g + 0.5, m = f.scale.y * g + 0.5, y = h - M / 2, E = d - m / 2, A = (y * this.qualityFactor - p) / a, C = (E * this.qualityFactor - p) / a, b = (M * this.qualityFactor + p * 2) / a, S = (m * this.qualityFactor + p * 2) / a;
|
|
1224
|
+
this.renderer.setScissor(A, C, b, S), this.renderer.render(this.scene, this.camera);
|
|
1224
1225
|
}
|
|
1225
|
-
this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(
|
|
1226
|
+
this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(r, l);
|
|
1226
1227
|
}
|
|
1227
1228
|
render() {
|
|
1228
|
-
for (let
|
|
1229
|
-
const
|
|
1229
|
+
for (let o = 0; o < N.MAX_LAYERS; o++) {
|
|
1230
|
+
const c = o + 1;
|
|
1230
1231
|
this.captureRenderTarget(
|
|
1231
|
-
this.travelersByLayer[
|
|
1232
|
-
O.getCaptureLayer(
|
|
1233
|
-
this.renderTargets[
|
|
1232
|
+
this.travelersByLayer[o],
|
|
1233
|
+
O.getCaptureLayer(c),
|
|
1234
|
+
this.renderTargets[o]
|
|
1234
1235
|
);
|
|
1235
1236
|
}
|
|
1236
|
-
this.renderer.
|
|
1237
|
+
const e = this.renderer.getContext(), t = this.renderer.getPixelRatio(), i = this.renderer.domElement.height / t, r = this.renderer.domElement, l = r.getBoundingClientRect().top, n = r.getBoundingClientRect().left;
|
|
1238
|
+
this.scene.children.forEach((o) => {
|
|
1239
|
+
var f;
|
|
1240
|
+
const c = o, a = (f = c.userData) == null ? void 0 : f.scissorRect;
|
|
1241
|
+
if (a && a.width > 0 && a.height > 0) {
|
|
1242
|
+
const h = Math.floor((a.x - n) * t), d = Math.floor(
|
|
1243
|
+
(i - (a.y - l + a.height)) * t
|
|
1244
|
+
), p = Math.ceil(a.width * t), g = Math.ceil(a.height * t);
|
|
1245
|
+
c.onBeforeRender = () => {
|
|
1246
|
+
e.enable(e.SCISSOR_TEST), e.scissor(h, d, p, g);
|
|
1247
|
+
}, c.onAfterRender = () => {
|
|
1248
|
+
e.disable(e.SCISSOR_TEST);
|
|
1249
|
+
};
|
|
1250
|
+
} else
|
|
1251
|
+
c.onBeforeRender && c.__hasScissorHook && (c.onBeforeRender = () => {
|
|
1252
|
+
}, c.onAfterRender = () => {
|
|
1253
|
+
}, c.__hasScissorHook = !1);
|
|
1254
|
+
a && (c.__hasScissorHook = !0);
|
|
1255
|
+
}), this.renderer.render(this.scene, this.camera);
|
|
1237
1256
|
}
|
|
1238
1257
|
syncMeshesByDOM() {
|
|
1239
|
-
const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY,
|
|
1258
|
+
const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, i = this.renderer.getPixelRatio(), r = this.renderer.domElement.width / i, l = this.renderer.domElement.height / i;
|
|
1240
1259
|
this.scene.children.forEach((n) => {
|
|
1241
|
-
var h,
|
|
1260
|
+
var h, d;
|
|
1242
1261
|
const o = n;
|
|
1243
1262
|
if (!o.userData || !o.userData.domElement)
|
|
1244
1263
|
return;
|
|
1245
|
-
const
|
|
1246
|
-
if (!
|
|
1264
|
+
const c = o.userData.domElement;
|
|
1265
|
+
if (!c.isConnected)
|
|
1247
1266
|
return;
|
|
1248
|
-
let
|
|
1249
|
-
if (
|
|
1250
|
-
const
|
|
1251
|
-
|
|
1267
|
+
let a;
|
|
1268
|
+
if (c.nodeType === Node.TEXT_NODE) {
|
|
1269
|
+
const p = document.createRange();
|
|
1270
|
+
p.selectNode(c), a = p.getBoundingClientRect();
|
|
1252
1271
|
} else
|
|
1253
|
-
|
|
1254
|
-
const
|
|
1255
|
-
if (!
|
|
1272
|
+
a = c.getBoundingClientRect();
|
|
1273
|
+
const f = o.userData.domRect;
|
|
1274
|
+
if (!f || Math.abs(a.x - f.x) > 0.5 || Math.abs(a.y - f.y) > 0.5 || Math.abs(a.width - f.width) > 0.5 || Math.abs(a.height - f.height) > 0.5) {
|
|
1256
1275
|
o.userData.domRect = {
|
|
1257
|
-
x:
|
|
1258
|
-
y:
|
|
1259
|
-
width:
|
|
1260
|
-
height:
|
|
1276
|
+
x: a.x,
|
|
1277
|
+
y: a.y,
|
|
1278
|
+
width: a.width,
|
|
1279
|
+
height: a.height
|
|
1261
1280
|
};
|
|
1262
|
-
|
|
1281
|
+
const p = o.userData.clipElements;
|
|
1282
|
+
if (p && p.length > 0) {
|
|
1283
|
+
let y = -1 / 0, E = -1 / 0, A = 1 / 0, C = 1 / 0;
|
|
1284
|
+
for (const b of p) {
|
|
1285
|
+
const S = b.getBoundingClientRect();
|
|
1286
|
+
y = Math.max(y, S.left), E = Math.max(E, S.top), A = Math.min(A, S.right), C = Math.min(C, S.bottom);
|
|
1287
|
+
}
|
|
1288
|
+
o.userData.scissorRect = {
|
|
1289
|
+
x: y,
|
|
1290
|
+
y: E,
|
|
1291
|
+
width: Math.max(0, A - y),
|
|
1292
|
+
height: Math.max(0, C - E)
|
|
1293
|
+
};
|
|
1294
|
+
} else
|
|
1295
|
+
o.userData.scissorRect = void 0;
|
|
1296
|
+
let g, M;
|
|
1263
1297
|
if (this.isViewport)
|
|
1264
|
-
g =
|
|
1298
|
+
g = a.x - window.innerWidth / 2 + a.width / 2, M = -a.y + window.innerHeight / 2 - a.height / 2;
|
|
1265
1299
|
else {
|
|
1266
|
-
const y =
|
|
1267
|
-
g = y -
|
|
1300
|
+
const y = a.x - e, E = a.y - t;
|
|
1301
|
+
g = y - r / 2 + a.width / 2, M = -E + l / 2 - a.height / 2;
|
|
1268
1302
|
}
|
|
1269
|
-
o.position.setX(g), o.position.setY(
|
|
1270
|
-
let
|
|
1271
|
-
if (o.scale.set(
|
|
1272
|
-
width:
|
|
1273
|
-
height:
|
|
1303
|
+
o.position.setX(g), o.position.setY(M);
|
|
1304
|
+
let m = ((h = o.material.userData) == null ? void 0 : h.shadowPadding) || 0;
|
|
1305
|
+
if (o.scale.set(a.width + m * 2, a.height + m * 2, 1), o.updateMatrixWorld(), o.material instanceof w.ShaderMaterial && P.forceUpdateUniforms(o.material, {
|
|
1306
|
+
width: a.width,
|
|
1307
|
+
height: a.height
|
|
1274
1308
|
}), o.userData.nativeMesh) {
|
|
1275
1309
|
const y = o.userData.nativeMesh;
|
|
1276
|
-
let
|
|
1310
|
+
let E = a.width, A = a.height, C = g, b = M;
|
|
1277
1311
|
if (o.userData.nativeTransform) {
|
|
1278
|
-
const
|
|
1279
|
-
if (
|
|
1280
|
-
let
|
|
1281
|
-
|
|
1312
|
+
const z = o.userData.nativeTransform, X = z.match(/scale\(([\d.]+%?)\)/);
|
|
1313
|
+
if (X) {
|
|
1314
|
+
let L = parseFloat(X[1]);
|
|
1315
|
+
X[1].includes("%") && (L /= 100), E *= L, A *= L;
|
|
1282
1316
|
}
|
|
1283
|
-
const
|
|
1284
|
-
if (
|
|
1285
|
-
let
|
|
1286
|
-
|
|
1317
|
+
const B = z.match(/scaleX\(([\d.]+%?)\)/);
|
|
1318
|
+
if (B) {
|
|
1319
|
+
let L = parseFloat(B[1]);
|
|
1320
|
+
B[1].includes("%") && (L /= 100), E *= L;
|
|
1287
1321
|
}
|
|
1288
|
-
const
|
|
1289
|
-
if (
|
|
1290
|
-
let
|
|
1291
|
-
|
|
1322
|
+
const k = z.match(/scaleY\(([\d.]+%?)\)/);
|
|
1323
|
+
if (k) {
|
|
1324
|
+
let L = parseFloat(k[1]);
|
|
1325
|
+
k[1].includes("%") && (L /= 100), A *= L;
|
|
1292
1326
|
}
|
|
1293
|
-
const
|
|
1294
|
-
if (
|
|
1295
|
-
const
|
|
1296
|
-
let
|
|
1297
|
-
|
|
1298
|
-
let
|
|
1299
|
-
|
|
1327
|
+
const j = z.match(/translate\(([^,]+),\s*([^)]+)\)/);
|
|
1328
|
+
if (j) {
|
|
1329
|
+
const L = j[1].trim(), _ = j[2].trim();
|
|
1330
|
+
let K = parseFloat(L);
|
|
1331
|
+
L.includes("%") && (K = K / 100 * a.width);
|
|
1332
|
+
let U = parseFloat(_);
|
|
1333
|
+
_.includes("%") && (U = U / 100 * a.height), C += K, b -= U;
|
|
1300
1334
|
}
|
|
1301
|
-
const J =
|
|
1335
|
+
const J = z.match(/translateX\(([^)]+)\)/);
|
|
1302
1336
|
if (J) {
|
|
1303
|
-
const
|
|
1304
|
-
let
|
|
1305
|
-
|
|
1337
|
+
const L = J[1].trim();
|
|
1338
|
+
let _ = parseFloat(L);
|
|
1339
|
+
L.includes("%") && (_ = _ / 100 * a.width), C += _;
|
|
1306
1340
|
}
|
|
1307
|
-
const Z =
|
|
1341
|
+
const Z = z.match(/translateY\(([^)]+)\)/);
|
|
1308
1342
|
if (Z) {
|
|
1309
|
-
const
|
|
1310
|
-
let
|
|
1311
|
-
|
|
1343
|
+
const L = Z[1].trim();
|
|
1344
|
+
let _ = parseFloat(L);
|
|
1345
|
+
L.includes("%") && (_ = _ / 100 * a.height), b -= _;
|
|
1312
1346
|
}
|
|
1313
1347
|
}
|
|
1314
|
-
let
|
|
1315
|
-
y.position.setX(
|
|
1316
|
-
width:
|
|
1317
|
-
height:
|
|
1348
|
+
let S = ((d = y.material.userData) == null ? void 0 : d.shadowPadding) || 0;
|
|
1349
|
+
y.position.setX(C), y.position.setY(b), y.scale.set(E + S * 2, A + S * 2, 1), y.updateMatrixWorld(), y.material instanceof w.ShaderMaterial && P.forceUpdateUniforms(y.material, {
|
|
1350
|
+
width: E,
|
|
1351
|
+
height: A
|
|
1318
1352
|
});
|
|
1319
1353
|
}
|
|
1320
1354
|
}
|
|
1321
1355
|
});
|
|
1322
1356
|
}
|
|
1323
1357
|
}
|
|
1324
|
-
function
|
|
1358
|
+
function at(s) {
|
|
1325
1359
|
const e = s.textContent || "", t = [];
|
|
1326
|
-
let
|
|
1327
|
-
const n = (
|
|
1328
|
-
for (let h = 0; h <
|
|
1329
|
-
const
|
|
1330
|
-
|
|
1331
|
-
const
|
|
1332
|
-
if (
|
|
1333
|
-
|
|
1360
|
+
let i = "", r = null, l = -1;
|
|
1361
|
+
const n = (a, f) => {
|
|
1362
|
+
for (let h = 0; h < a.length; h++) {
|
|
1363
|
+
const d = a[h], p = document.createRange();
|
|
1364
|
+
p.setStart(s, f + h), p.setEnd(s, f + h + 1);
|
|
1365
|
+
const g = p.getBoundingClientRect();
|
|
1366
|
+
if (g.width === 0 && g.height === 0) {
|
|
1367
|
+
i += d;
|
|
1334
1368
|
continue;
|
|
1335
1369
|
}
|
|
1336
|
-
|
|
1337
|
-
text:
|
|
1370
|
+
l === -1 || Math.abs(g.top - l) > g.height / 2 ? (i && r && t.push({
|
|
1371
|
+
text: i,
|
|
1338
1372
|
rect: {
|
|
1339
|
-
left:
|
|
1340
|
-
top:
|
|
1341
|
-
width:
|
|
1342
|
-
height:
|
|
1373
|
+
left: r.left,
|
|
1374
|
+
top: r.top,
|
|
1375
|
+
width: r.right - r.left,
|
|
1376
|
+
height: r.bottom - r.top
|
|
1343
1377
|
}
|
|
1344
|
-
}),
|
|
1345
|
-
left:
|
|
1346
|
-
top:
|
|
1347
|
-
right:
|
|
1348
|
-
bottom:
|
|
1349
|
-
},
|
|
1350
|
-
|
|
1351
|
-
|
|
1378
|
+
}), i = d, r = {
|
|
1379
|
+
left: g.left,
|
|
1380
|
+
top: g.top,
|
|
1381
|
+
right: g.right,
|
|
1382
|
+
bottom: g.bottom
|
|
1383
|
+
}, l = g.top) : (i += d, r && (r.left = Math.min(r.left, g.left), r.top = Math.min(r.top, g.top), r.right = Math.max(r.right, g.right), r.bottom = Math.max(
|
|
1384
|
+
r.bottom,
|
|
1385
|
+
g.bottom
|
|
1352
1386
|
)));
|
|
1353
1387
|
}
|
|
1354
1388
|
}, o = e.match(/[^\s\-]+\-?|\-|\s+/g) || [];
|
|
1355
|
-
let
|
|
1356
|
-
for (const
|
|
1357
|
-
const
|
|
1358
|
-
|
|
1359
|
-
const h =
|
|
1389
|
+
let c = 0;
|
|
1390
|
+
for (const a of o) {
|
|
1391
|
+
const f = document.createRange();
|
|
1392
|
+
f.setStart(s, c), f.setEnd(s, c + a.length);
|
|
1393
|
+
const h = f.getClientRects();
|
|
1360
1394
|
if (h.length > 1)
|
|
1361
|
-
n(
|
|
1395
|
+
n(a, c);
|
|
1362
1396
|
else {
|
|
1363
|
-
const
|
|
1364
|
-
if (
|
|
1365
|
-
|
|
1397
|
+
const d = h.length === 1 ? h[0] : f.getBoundingClientRect();
|
|
1398
|
+
if (d.width === 0 && d.height === 0) {
|
|
1399
|
+
i += a, c += a.length;
|
|
1366
1400
|
continue;
|
|
1367
1401
|
}
|
|
1368
|
-
|
|
1369
|
-
text:
|
|
1402
|
+
l === -1 || Math.abs(d.top - l) > d.height / 2 ? (i && r && t.push({
|
|
1403
|
+
text: i,
|
|
1370
1404
|
rect: {
|
|
1371
|
-
left:
|
|
1372
|
-
top:
|
|
1373
|
-
width:
|
|
1374
|
-
height:
|
|
1405
|
+
left: r.left,
|
|
1406
|
+
top: r.top,
|
|
1407
|
+
width: r.right - r.left,
|
|
1408
|
+
height: r.bottom - r.top
|
|
1375
1409
|
}
|
|
1376
|
-
}),
|
|
1377
|
-
left:
|
|
1378
|
-
top:
|
|
1379
|
-
right:
|
|
1380
|
-
bottom:
|
|
1381
|
-
},
|
|
1382
|
-
|
|
1383
|
-
|
|
1410
|
+
}), i = a, r = {
|
|
1411
|
+
left: d.left,
|
|
1412
|
+
top: d.top,
|
|
1413
|
+
right: d.right,
|
|
1414
|
+
bottom: d.bottom
|
|
1415
|
+
}, l = d.top) : (i += a, r && (r.left = Math.min(r.left, d.left), r.top = Math.min(r.top, d.top), r.right = Math.max(r.right, d.right), r.bottom = Math.max(
|
|
1416
|
+
r.bottom,
|
|
1417
|
+
d.bottom
|
|
1384
1418
|
)));
|
|
1385
1419
|
}
|
|
1386
|
-
|
|
1420
|
+
c += a.length;
|
|
1387
1421
|
}
|
|
1388
|
-
return
|
|
1389
|
-
text:
|
|
1422
|
+
return i && r && t.push({
|
|
1423
|
+
text: i,
|
|
1390
1424
|
rect: {
|
|
1391
|
-
left:
|
|
1392
|
-
top:
|
|
1393
|
-
width:
|
|
1394
|
-
height:
|
|
1425
|
+
left: r.left,
|
|
1426
|
+
top: r.top,
|
|
1427
|
+
width: r.right - r.left,
|
|
1428
|
+
height: r.bottom - r.top
|
|
1395
1429
|
}
|
|
1396
1430
|
}), t.filter(
|
|
1397
|
-
(
|
|
1431
|
+
(a) => a.text.trim().length > 0 && a.rect.width > 0 && a.rect.height > 0
|
|
1398
1432
|
);
|
|
1399
1433
|
}
|
|
1400
|
-
function
|
|
1434
|
+
function ke(s) {
|
|
1401
1435
|
const e = parseFloat(s.fontSize);
|
|
1402
1436
|
let t = parseFloat(s.lineHeight);
|
|
1403
1437
|
isNaN(t) && (t = e * 1.2);
|
|
1404
|
-
let
|
|
1405
|
-
return isNaN(
|
|
1438
|
+
let i = parseFloat(s.letterSpacing);
|
|
1439
|
+
return isNaN(i) && (i = 0), {
|
|
1406
1440
|
font: `${s.fontStyle} ${s.fontWeight} ${s.fontSize} ${s.fontFamily}`,
|
|
1407
1441
|
fontSize: s.fontSize,
|
|
1408
1442
|
color: s.color,
|
|
@@ -1410,319 +1444,322 @@ function De(s) {
|
|
|
1410
1444
|
textBaseline: "alphabetic",
|
|
1411
1445
|
direction: s.direction || "inherit",
|
|
1412
1446
|
lineHeight: t,
|
|
1413
|
-
letterSpacing:
|
|
1447
|
+
letterSpacing: i
|
|
1414
1448
|
};
|
|
1415
1449
|
}
|
|
1416
|
-
function
|
|
1417
|
-
var
|
|
1450
|
+
function Fe(s, e = re | ue | Ge | be | pe, t, i = 1, r = 0, l = 2, n, o, c) {
|
|
1451
|
+
var K, U, V, ie, se, ne, he;
|
|
1418
1452
|
if (s.nodeType === Node.TEXT_NODE) {
|
|
1419
|
-
const
|
|
1420
|
-
if (!
|
|
1453
|
+
const v = s;
|
|
1454
|
+
if (!v.textContent || !v.textContent.trim())
|
|
1421
1455
|
return null;
|
|
1422
|
-
const
|
|
1423
|
-
if (
|
|
1456
|
+
const x = v.textContent.replace(/\s+/g, " ");
|
|
1457
|
+
if (x.length === 0)
|
|
1424
1458
|
return null;
|
|
1425
|
-
const
|
|
1426
|
-
if (
|
|
1459
|
+
const T = at(v);
|
|
1460
|
+
if (T.length === 0)
|
|
1427
1461
|
return null;
|
|
1428
|
-
const
|
|
1429
|
-
if (!
|
|
1462
|
+
const F = v.parentElement, D = F ? window.getComputedStyle(F) : null;
|
|
1463
|
+
if (!D)
|
|
1430
1464
|
return null;
|
|
1431
|
-
const
|
|
1465
|
+
const $ = Math.min(...T.map((R) => R.rect.left)), Y = Math.min(...T.map((R) => R.rect.top)), Q = Math.max(...T.map((R) => R.rect.left + R.rect.width)), I = Math.max(...T.map((R) => R.rect.top + R.rect.height));
|
|
1432
1466
|
return {
|
|
1433
1467
|
id: Math.random().toString(36).substring(2, 9),
|
|
1434
1468
|
type: "TEXT",
|
|
1435
|
-
element:
|
|
1469
|
+
element: v,
|
|
1436
1470
|
rect: {
|
|
1437
|
-
x:
|
|
1438
|
-
y:
|
|
1439
|
-
width: Q -
|
|
1440
|
-
height: I -
|
|
1471
|
+
x: $ + window.scrollX,
|
|
1472
|
+
y: Y + window.scrollY,
|
|
1473
|
+
width: Q - $,
|
|
1474
|
+
height: I - Y
|
|
1441
1475
|
},
|
|
1442
1476
|
styles: {
|
|
1443
1477
|
backgroundColor: "transparent",
|
|
1444
1478
|
backgroundImage: "",
|
|
1445
|
-
opacity:
|
|
1446
|
-
zIndex: (isNaN(parseInt(
|
|
1479
|
+
opacity: F && F.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(D.opacity),
|
|
1480
|
+
zIndex: (isNaN(parseInt(D.zIndex)) ? 0 : parseInt(D.zIndex)) + r,
|
|
1447
1481
|
borderRadius: "0px",
|
|
1448
1482
|
borderColor: "transparent",
|
|
1449
1483
|
borderWidth: "0px",
|
|
1450
1484
|
isTraveler: !1
|
|
1451
1485
|
},
|
|
1452
|
-
textContent:
|
|
1453
|
-
textLines:
|
|
1454
|
-
text:
|
|
1486
|
+
textContent: x,
|
|
1487
|
+
textLines: T.map((R) => ({
|
|
1488
|
+
text: R.text.trim(),
|
|
1455
1489
|
rect: {
|
|
1456
|
-
x:
|
|
1457
|
-
y:
|
|
1458
|
-
width:
|
|
1459
|
-
height:
|
|
1490
|
+
x: R.rect.left + window.scrollX,
|
|
1491
|
+
y: R.rect.top + window.scrollY,
|
|
1492
|
+
width: R.rect.width,
|
|
1493
|
+
height: R.rect.height
|
|
1460
1494
|
}
|
|
1461
1495
|
})),
|
|
1462
|
-
textStyles:
|
|
1496
|
+
textStyles: ke(D),
|
|
1463
1497
|
dirtyMask: e,
|
|
1464
1498
|
visibility: t,
|
|
1465
1499
|
isTraveler: !1,
|
|
1466
|
-
captureLayer:
|
|
1467
|
-
isFixed:
|
|
1500
|
+
captureLayer: i,
|
|
1501
|
+
isFixed: D.position === "fixed",
|
|
1468
1502
|
nativeLayer: n,
|
|
1469
1503
|
nativeStyles: o ? te(te({
|
|
1470
1504
|
backgroundColor: "transparent",
|
|
1471
1505
|
backgroundImage: "",
|
|
1472
|
-
opacity:
|
|
1473
|
-
zIndex: (isNaN(parseInt(
|
|
1506
|
+
opacity: F && F.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(D.opacity),
|
|
1507
|
+
zIndex: (isNaN(parseInt(D.zIndex)) ? 0 : parseInt(D.zIndex)) + r,
|
|
1474
1508
|
borderRadius: "0px",
|
|
1475
1509
|
borderColor: "transparent",
|
|
1476
1510
|
borderWidth: "0px",
|
|
1477
1511
|
isTraveler: !1
|
|
1478
|
-
},
|
|
1512
|
+
}, ke(D)), o) : void 0,
|
|
1479
1513
|
nativeRect: o ? {
|
|
1480
|
-
x:
|
|
1481
|
-
y:
|
|
1482
|
-
width: Q -
|
|
1483
|
-
height: I -
|
|
1514
|
+
x: $ + window.scrollX,
|
|
1515
|
+
y: Y + window.scrollY,
|
|
1516
|
+
width: Q - $,
|
|
1517
|
+
height: I - Y
|
|
1484
1518
|
} : void 0,
|
|
1519
|
+
clipElements: c,
|
|
1485
1520
|
children: []
|
|
1486
1521
|
};
|
|
1487
1522
|
}
|
|
1488
1523
|
if (s.nodeType !== Node.ELEMENT_NODE)
|
|
1489
1524
|
return null;
|
|
1490
|
-
const a = s,
|
|
1491
|
-
let
|
|
1492
|
-
if (
|
|
1493
|
-
const
|
|
1494
|
-
for (const
|
|
1495
|
-
if (!
|
|
1525
|
+
const a = s, f = a.dataset[H.KEY];
|
|
1526
|
+
let h = t, d = t;
|
|
1527
|
+
if (f) {
|
|
1528
|
+
const v = new Set(f.split(/\s+/));
|
|
1529
|
+
for (const x of v)
|
|
1530
|
+
if (!Me.includes(x))
|
|
1496
1531
|
throw new Error(
|
|
1497
|
-
`[MirageEngine] Invalid filter token: '${
|
|
1532
|
+
`[MirageEngine] Invalid filter token: '${x}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
|
|
1498
1533
|
);
|
|
1499
|
-
if (
|
|
1534
|
+
if (v.has(H.VALUES.END))
|
|
1500
1535
|
return null;
|
|
1501
|
-
if (
|
|
1536
|
+
if (v.has(H.VALUES.INCLUDE_TREE) && v.has(H.VALUES.EXCLUDE_TREE))
|
|
1502
1537
|
throw new Error(
|
|
1503
1538
|
"[MirageEngine] Conflicting filters: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
|
|
1504
1539
|
);
|
|
1505
|
-
if (
|
|
1540
|
+
if (v.has(H.VALUES.INCLUDE_SELF) && v.has(H.VALUES.EXCLUDE_SELF))
|
|
1506
1541
|
throw new Error(
|
|
1507
1542
|
"[MirageEngine] Conflicting filters: 'include-self' and 'exclude-self' cannot be used together on the same element."
|
|
1508
1543
|
);
|
|
1509
|
-
|
|
1544
|
+
v.has(H.VALUES.INCLUDE_TREE) ? h = h | G : v.has(H.VALUES.EXCLUDE_TREE) && (h = h & ~G), d = h, v.has(H.VALUES.INCLUDE_SELF) ? d = d | G : v.has(H.VALUES.EXCLUDE_SELF) && (d = d & ~G);
|
|
1510
1545
|
}
|
|
1511
|
-
const
|
|
1512
|
-
if (
|
|
1513
|
-
const
|
|
1514
|
-
for (const
|
|
1515
|
-
if (!
|
|
1546
|
+
const p = a.dataset[q.KEY];
|
|
1547
|
+
if (p) {
|
|
1548
|
+
const v = new Set(p.split(/\s+/));
|
|
1549
|
+
for (const x of v)
|
|
1550
|
+
if (!Me.includes(x))
|
|
1516
1551
|
throw new Error(
|
|
1517
|
-
`[MirageEngine] Invalid select token: '${
|
|
1552
|
+
`[MirageEngine] Invalid select token: '${x}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
|
|
1518
1553
|
);
|
|
1519
|
-
if (
|
|
1554
|
+
if (v.has(q.VALUES.END))
|
|
1520
1555
|
return null;
|
|
1521
|
-
if (
|
|
1556
|
+
if (v.has(q.VALUES.INCLUDE_TREE) && v.has(q.VALUES.EXCLUDE_TREE))
|
|
1522
1557
|
throw new Error(
|
|
1523
1558
|
"[MirageEngine] Conflicting selects: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
|
|
1524
1559
|
);
|
|
1525
|
-
if (
|
|
1560
|
+
if (v.has(q.VALUES.INCLUDE_SELF) && v.has(q.VALUES.EXCLUDE_SELF))
|
|
1526
1561
|
throw new Error(
|
|
1527
1562
|
"[MirageEngine] Conflicting selects: 'include-self' and 'exclude-self' cannot be used together on the same element."
|
|
1528
1563
|
);
|
|
1529
|
-
|
|
1564
|
+
v.has(q.VALUES.INCLUDE_TREE) ? h = h | ae : v.has(q.VALUES.EXCLUDE_TREE) && (h = h & ~ae), d = h, v.has(q.VALUES.INCLUDE_SELF) ? d = d | ae : v.has(q.VALUES.EXCLUDE_SELF) && (d = d & ~ae);
|
|
1530
1565
|
}
|
|
1531
|
-
const g = a.dataset[
|
|
1532
|
-
let
|
|
1566
|
+
const g = a.dataset[N.KEY];
|
|
1567
|
+
let M = !1, m = o ? te({}, o) : {}, y = n;
|
|
1533
1568
|
if (g) {
|
|
1534
|
-
let
|
|
1535
|
-
const
|
|
1536
|
-
let
|
|
1537
|
-
if (
|
|
1538
|
-
|
|
1539
|
-
const I = g.substring(
|
|
1569
|
+
let v = 1;
|
|
1570
|
+
const x = g.indexOf("{"), T = g.lastIndexOf("}");
|
|
1571
|
+
let F = g;
|
|
1572
|
+
if (x !== -1 && T !== -1 && T > x) {
|
|
1573
|
+
F = g.substring(0, x).trim();
|
|
1574
|
+
const I = g.substring(x, T + 1);
|
|
1540
1575
|
try {
|
|
1541
|
-
|
|
1542
|
-
} catch (
|
|
1576
|
+
m = new Function("return " + I)();
|
|
1577
|
+
} catch (R) {
|
|
1543
1578
|
console.warn(
|
|
1544
1579
|
`[MirageEngine] Failed to parse travel styles JSON: ${I}`
|
|
1545
1580
|
);
|
|
1546
1581
|
}
|
|
1547
1582
|
}
|
|
1548
|
-
const
|
|
1549
|
-
let
|
|
1550
|
-
const
|
|
1551
|
-
if (
|
|
1552
|
-
|
|
1553
|
-
const I =
|
|
1583
|
+
const D = F.split(/\s+/);
|
|
1584
|
+
let $ = !1;
|
|
1585
|
+
const Y = D.indexOf(N.VALUES.TRAVELER);
|
|
1586
|
+
if (Y !== -1) {
|
|
1587
|
+
M = !0, $ = !0;
|
|
1588
|
+
const I = D[Y + 1];
|
|
1554
1589
|
if (I && !isNaN(parseInt(I, 10)))
|
|
1555
|
-
|
|
1590
|
+
v = parseInt(I, 10);
|
|
1556
1591
|
else {
|
|
1557
|
-
const
|
|
1558
|
-
|
|
1592
|
+
const R = D.find((oe) => !isNaN(parseInt(oe, 10)));
|
|
1593
|
+
R && (v = parseInt(R, 10));
|
|
1559
1594
|
}
|
|
1560
1595
|
}
|
|
1561
|
-
const Q =
|
|
1596
|
+
const Q = D.indexOf(N.VALUES.NATIVE);
|
|
1562
1597
|
if (Q !== -1) {
|
|
1563
|
-
const I =
|
|
1598
|
+
const I = D[Q + 1];
|
|
1564
1599
|
if (I && !isNaN(parseInt(I, 10)))
|
|
1565
1600
|
y = parseInt(I, 10);
|
|
1566
|
-
else if (!
|
|
1567
|
-
const
|
|
1568
|
-
|
|
1601
|
+
else if (!M) {
|
|
1602
|
+
const R = D.find((oe) => !isNaN(parseInt(oe, 10)));
|
|
1603
|
+
R && (y = parseInt(R, 10));
|
|
1569
1604
|
}
|
|
1570
1605
|
}
|
|
1571
|
-
if (
|
|
1572
|
-
const I =
|
|
1573
|
-
if (I <
|
|
1606
|
+
if ($) {
|
|
1607
|
+
const I = v + 1;
|
|
1608
|
+
if (I < i)
|
|
1574
1609
|
throw new Error(
|
|
1575
|
-
`[MirageEngine] Traveler layer (${
|
|
1610
|
+
`[MirageEngine] Traveler layer (${v}) cannot be smaller than inherited capture layer (${i - 1}).`
|
|
1576
1611
|
);
|
|
1577
|
-
|
|
1612
|
+
i = Math.min(I, N.MAX_LAYERS + 1);
|
|
1578
1613
|
}
|
|
1579
1614
|
}
|
|
1580
|
-
const
|
|
1581
|
-
let
|
|
1582
|
-
|
|
1583
|
-
const
|
|
1584
|
-
if (
|
|
1615
|
+
const E = a.dataset[He.KEY];
|
|
1616
|
+
let A;
|
|
1617
|
+
E && (A = JSON.parse(E));
|
|
1618
|
+
const C = a.getBoundingClientRect(), b = window.getComputedStyle(a);
|
|
1619
|
+
if (C.width === 0 || C.height === 0 || b.display === "none")
|
|
1585
1620
|
return null;
|
|
1586
|
-
let
|
|
1587
|
-
|
|
1588
|
-
const
|
|
1589
|
-
let
|
|
1621
|
+
let S = a.getAttribute("data-mid");
|
|
1622
|
+
S || (S = Math.random().toString(36).substring(2, 11), a.setAttribute("data-mid", S));
|
|
1623
|
+
const z = parseInt(b.zIndex), X = (isNaN(z) ? 0 : z) + r;
|
|
1624
|
+
let B;
|
|
1590
1625
|
if (a.tagName === "IMG")
|
|
1591
|
-
|
|
1626
|
+
B = a.src;
|
|
1592
1627
|
else if (a.tagName.toLowerCase() === "svg") {
|
|
1593
|
-
const
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1596
|
-
const
|
|
1597
|
-
|
|
1598
|
-
const
|
|
1599
|
-
|
|
1600
|
-
const
|
|
1601
|
-
|
|
1602
|
-
for (let
|
|
1603
|
-
|
|
1628
|
+
const v = a.cloneNode(!0), x = m == null ? void 0 : m.color, T = m == null ? void 0 : m.fill, F = m == null ? void 0 : m.stroke, D = m == null ? void 0 : m.opacity, $ = (R, oe) => {
|
|
1629
|
+
const W = window.getComputedStyle(R), de = oe, ze = W.fill === W.color, Ne = W.stroke === W.color, me = T || (ze ? x : void 0) || W.fill;
|
|
1630
|
+
me && me !== "none" && (de.style.fill = me);
|
|
1631
|
+
const ve = F || (Ne ? x : void 0) || W.stroke;
|
|
1632
|
+
ve && ve !== "none" && (de.style.stroke = ve), W.strokeWidth && W.strokeWidth !== "0px" && (de.style.strokeWidth = W.strokeWidth);
|
|
1633
|
+
const Se = x || W.color;
|
|
1634
|
+
Se && (de.style.color = Se);
|
|
1635
|
+
const we = D || W.opacity;
|
|
1636
|
+
we && we !== "1" && (de.style.opacity = we);
|
|
1637
|
+
for (let fe = 0; fe < R.children.length; fe++)
|
|
1638
|
+
$(R.children[fe], oe.children[fe]);
|
|
1604
1639
|
};
|
|
1605
|
-
|
|
1606
|
-
const
|
|
1607
|
-
|
|
1608
|
-
let I = new XMLSerializer().serializeToString(
|
|
1640
|
+
$(a, v);
|
|
1641
|
+
const Y = a.getBoundingClientRect(), Q = window.devicePixelRatio * l;
|
|
1642
|
+
v.hasAttribute("viewBox") || v.setAttribute("viewBox", `0 0 ${Y.width} ${Y.height}`), v.setAttribute("width", (Y.width * Q).toString()), v.setAttribute("height", (Y.height * Q).toString());
|
|
1643
|
+
let I = new XMLSerializer().serializeToString(v);
|
|
1609
1644
|
I.includes("xmlns=") || (I = I.replace(
|
|
1610
1645
|
"<svg",
|
|
1611
1646
|
'<svg xmlns="http://www.w3.org/2000/svg"'
|
|
1612
|
-
)),
|
|
1613
|
-
} else if (
|
|
1614
|
-
const
|
|
1615
|
-
|
|
1616
|
-
}
|
|
1617
|
-
const
|
|
1618
|
-
backgroundColor:
|
|
1619
|
-
backgroundImage:
|
|
1620
|
-
opacity: a.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(
|
|
1621
|
-
zIndex:
|
|
1622
|
-
borderRadius:
|
|
1623
|
-
borderColor:
|
|
1624
|
-
borderWidth:
|
|
1625
|
-
boxShadow:
|
|
1626
|
-
imageSrc:
|
|
1627
|
-
isTraveler:
|
|
1628
|
-
},
|
|
1647
|
+
)), B = `data:image/svg+xml;utf8,${encodeURIComponent(I)}`;
|
|
1648
|
+
} else if (b.backgroundImage && b.backgroundImage !== "none") {
|
|
1649
|
+
const v = b.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
|
|
1650
|
+
v && (B = v[1]);
|
|
1651
|
+
}
|
|
1652
|
+
const k = {
|
|
1653
|
+
backgroundColor: b.backgroundColor,
|
|
1654
|
+
backgroundImage: b.backgroundImage,
|
|
1655
|
+
opacity: a.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(b.opacity),
|
|
1656
|
+
zIndex: X,
|
|
1657
|
+
borderRadius: b.borderRadius,
|
|
1658
|
+
borderColor: b.borderColor,
|
|
1659
|
+
borderWidth: b.borderWidth,
|
|
1660
|
+
boxShadow: b.boxShadow,
|
|
1661
|
+
imageSrc: B,
|
|
1662
|
+
isTraveler: M
|
|
1663
|
+
}, j = k;
|
|
1629
1664
|
let J, Z;
|
|
1630
|
-
const
|
|
1631
|
-
return a.tagName.toLowerCase() !== "svg" && Array.from(a.childNodes).forEach((
|
|
1632
|
-
const
|
|
1633
|
-
|
|
1665
|
+
const L = [], _ = b.overflow === "hidden" ? [...c || [], a] : c;
|
|
1666
|
+
return a.tagName.toLowerCase() !== "svg" && Array.from(a.childNodes).forEach((v) => {
|
|
1667
|
+
const x = v.nodeType === Node.TEXT_NODE ? d : h, T = Fe(
|
|
1668
|
+
v,
|
|
1634
1669
|
e,
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1670
|
+
x,
|
|
1671
|
+
i,
|
|
1672
|
+
X,
|
|
1673
|
+
l,
|
|
1674
|
+
v.nodeType === Node.TEXT_NODE ? y : void 0,
|
|
1675
|
+
v.nodeType === Node.TEXT_NODE && Object.keys(m).length > 0 ? m : void 0,
|
|
1676
|
+
_
|
|
1641
1677
|
);
|
|
1642
|
-
|
|
1678
|
+
T && L.push(T);
|
|
1643
1679
|
}), {
|
|
1644
|
-
id:
|
|
1680
|
+
id: S,
|
|
1645
1681
|
type: "BOX",
|
|
1646
1682
|
element: a,
|
|
1647
1683
|
rect: {
|
|
1648
|
-
x:
|
|
1649
|
-
y:
|
|
1650
|
-
width:
|
|
1651
|
-
height:
|
|
1684
|
+
x: C.left + window.scrollX,
|
|
1685
|
+
y: C.top + window.scrollY,
|
|
1686
|
+
width: C.width,
|
|
1687
|
+
height: C.height
|
|
1652
1688
|
},
|
|
1653
|
-
styles:
|
|
1689
|
+
styles: j,
|
|
1654
1690
|
textContent: J,
|
|
1655
1691
|
textStyles: Z,
|
|
1656
1692
|
dirtyMask: e,
|
|
1657
|
-
visibility:
|
|
1658
|
-
isTraveler:
|
|
1659
|
-
captureLayer:
|
|
1693
|
+
visibility: d,
|
|
1694
|
+
isTraveler: M,
|
|
1695
|
+
captureLayer: i,
|
|
1660
1696
|
nativeLayer: y,
|
|
1661
|
-
nativeStyles: y !== void 0 ?
|
|
1662
|
-
backgroundColor: (
|
|
1663
|
-
backgroundImage: (
|
|
1664
|
-
opacity: (
|
|
1665
|
-
zIndex:
|
|
1666
|
-
borderRadius: (
|
|
1667
|
-
borderColor: (
|
|
1668
|
-
borderWidth: (
|
|
1669
|
-
boxShadow: (
|
|
1670
|
-
isTraveler:
|
|
1671
|
-
transform:
|
|
1697
|
+
nativeStyles: y !== void 0 ? Ce(te({}, k), {
|
|
1698
|
+
backgroundColor: (K = m.backgroundColor) != null ? K : k.backgroundColor,
|
|
1699
|
+
backgroundImage: (U = m.backgroundImage) != null ? U : k.backgroundImage,
|
|
1700
|
+
opacity: (V = m.opacity) != null ? V : k.opacity,
|
|
1701
|
+
zIndex: m.zIndex !== void 0 ? m.zIndex + X : k.zIndex,
|
|
1702
|
+
borderRadius: (ie = m.borderRadius) != null ? ie : k.borderRadius,
|
|
1703
|
+
borderColor: (se = m.borderColor) != null ? se : k.borderColor,
|
|
1704
|
+
borderWidth: (ne = m.borderWidth) != null ? ne : k.borderWidth,
|
|
1705
|
+
boxShadow: (he = m.boxShadow) != null ? he : k.boxShadow,
|
|
1706
|
+
isTraveler: k.isTraveler,
|
|
1707
|
+
transform: m.transform
|
|
1672
1708
|
}) : void 0,
|
|
1673
1709
|
nativeRect: y !== void 0 ? {
|
|
1674
|
-
x:
|
|
1675
|
-
y:
|
|
1676
|
-
width:
|
|
1677
|
-
height:
|
|
1710
|
+
x: m.x !== void 0 ? parseFloat(m.x) : C.left + window.scrollX,
|
|
1711
|
+
y: m.y !== void 0 ? parseFloat(m.y) : C.top + window.scrollY,
|
|
1712
|
+
width: m.width !== void 0 ? parseFloat(m.width) : C.width,
|
|
1713
|
+
height: m.height !== void 0 ? parseFloat(m.height) : C.height
|
|
1678
1714
|
} : void 0,
|
|
1679
|
-
isFixed:
|
|
1680
|
-
|
|
1681
|
-
|
|
1715
|
+
isFixed: b.position === "fixed",
|
|
1716
|
+
clipElements: c,
|
|
1717
|
+
children: L,
|
|
1718
|
+
shaderHooks: A
|
|
1682
1719
|
};
|
|
1683
1720
|
}
|
|
1684
|
-
function
|
|
1685
|
-
e.size !== 0 && e.forEach((t,
|
|
1686
|
-
var
|
|
1687
|
-
const
|
|
1688
|
-
!
|
|
1721
|
+
function ct(s, e) {
|
|
1722
|
+
e.size !== 0 && e.forEach((t, i) => {
|
|
1723
|
+
var l, n, o, c;
|
|
1724
|
+
const r = s.get(i);
|
|
1725
|
+
!r || !r.userData.basePosition || (P.forceUpdateUniforms(r.material, {
|
|
1689
1726
|
backgroundColor: t.backgroundColor,
|
|
1690
1727
|
backgroundImage: t.backgroundImage,
|
|
1691
1728
|
boxShadow: t.boxShadow,
|
|
1692
1729
|
opacity: t.opacity,
|
|
1693
|
-
borderRadius: (n = t.borderRadius) != null ? n : (
|
|
1730
|
+
borderRadius: (n = t.borderRadius) != null ? n : (l = r.userData.baseStyles) == null ? void 0 : l.borderRadius
|
|
1694
1731
|
// width and height are no longer updated here, they are updated in syncMeshesByDOM
|
|
1695
|
-
}),
|
|
1732
|
+
}), r.userData.nativeMesh && P.forceUpdateUniforms(r.userData.nativeMesh.material, {
|
|
1696
1733
|
backgroundColor: t.backgroundColor,
|
|
1697
1734
|
backgroundImage: t.backgroundImage,
|
|
1698
1735
|
boxShadow: t.boxShadow,
|
|
1699
1736
|
opacity: t.opacity,
|
|
1700
|
-
borderRadius: (
|
|
1737
|
+
borderRadius: (c = t.borderRadius) != null ? c : (o = r.userData.baseStyles) == null ? void 0 : o.borderRadius
|
|
1701
1738
|
}));
|
|
1702
1739
|
});
|
|
1703
1740
|
}
|
|
1704
|
-
class
|
|
1705
|
-
constructor(e, t,
|
|
1741
|
+
class lt {
|
|
1742
|
+
constructor(e, t, i, r) {
|
|
1706
1743
|
u(this, "target");
|
|
1707
1744
|
u(this, "renderer");
|
|
1708
1745
|
u(this, "registry");
|
|
1709
1746
|
u(this, "isTravelEnabled", !1);
|
|
1710
1747
|
u(this, "tracker");
|
|
1711
|
-
this.target = e, this.renderer = t, this.registry =
|
|
1712
|
-
resizeDebounce:
|
|
1713
|
-
}), this.tracker.onLayoutChange.add((
|
|
1714
|
-
document.querySelector(`[${
|
|
1715
|
-
const
|
|
1748
|
+
this.target = e, this.renderer = t, this.registry = i, this.tracker = new Be(e, {
|
|
1749
|
+
resizeDebounce: r.resizeDebounce
|
|
1750
|
+
}), this.tracker.onLayoutChange.add((l, n) => {
|
|
1751
|
+
document.querySelector(`[${N.NAME}~='${N.VALUES.TRAVELER}']`) !== null && !this.isTravelEnabled && (this.isTravelEnabled = !0, this.renderer.createRenderTarget());
|
|
1752
|
+
const c = Fe(
|
|
1716
1753
|
this.target,
|
|
1717
|
-
|
|
1718
|
-
|
|
1754
|
+
l,
|
|
1755
|
+
G,
|
|
1719
1756
|
1,
|
|
1720
1757
|
0,
|
|
1721
1758
|
this.renderer.qualityFactor
|
|
1722
1759
|
);
|
|
1723
|
-
|
|
1724
|
-
}), this.tracker.onStyleChange.add((
|
|
1725
|
-
|
|
1760
|
+
c && this.renderer.syncScene(c, n);
|
|
1761
|
+
}), this.tracker.onStyleChange.add((l) => {
|
|
1762
|
+
ct(this.registry, l);
|
|
1726
1763
|
}), this.tracker.onRender.add(() => {
|
|
1727
1764
|
this.renderer.syncMeshesByDOM(), this.renderer.render();
|
|
1728
1765
|
});
|
|
@@ -1734,7 +1771,7 @@ class at {
|
|
|
1734
1771
|
this.tracker.stop();
|
|
1735
1772
|
}
|
|
1736
1773
|
}
|
|
1737
|
-
class
|
|
1774
|
+
class ht {
|
|
1738
1775
|
constructor() {
|
|
1739
1776
|
u(this, "store");
|
|
1740
1777
|
this.store = /* @__PURE__ */ new WeakMap();
|
|
@@ -1759,14 +1796,14 @@ class lt {
|
|
|
1759
1796
|
this.store.delete(e);
|
|
1760
1797
|
}
|
|
1761
1798
|
}
|
|
1762
|
-
class
|
|
1799
|
+
class dt {
|
|
1763
1800
|
constructor(e, t) {
|
|
1764
1801
|
u(this, "renderer");
|
|
1765
1802
|
u(this, "syncer");
|
|
1766
1803
|
u(this, "target");
|
|
1767
1804
|
u(this, "registry");
|
|
1768
|
-
var
|
|
1769
|
-
if (this.target = e, this.registry = new
|
|
1805
|
+
var r, l, n;
|
|
1806
|
+
if (this.target = e, this.registry = new ht(), !document.getElementById("mirage-engine-styles")) {
|
|
1770
1807
|
const o = document.createElement("style");
|
|
1771
1808
|
o.id = "mirage-engine-styles", o.textContent = `
|
|
1772
1809
|
[${ee.NAME}="${ee.VALUES.HIDE}"] {
|
|
@@ -1774,15 +1811,15 @@ class ct {
|
|
|
1774
1811
|
}
|
|
1775
1812
|
`, document.head.appendChild(o);
|
|
1776
1813
|
}
|
|
1777
|
-
let
|
|
1778
|
-
if (t.mode === "duplicate" ?
|
|
1814
|
+
let i;
|
|
1815
|
+
if (t.mode === "duplicate" ? i = (l = (r = t.container) != null ? r : this.target.parentElement) != null ? l : void 0 : i = (n = this.target.parentElement) != null ? n : void 0, !i)
|
|
1779
1816
|
throw new Error("[Mirage] Cannot find a container (parent or option).");
|
|
1780
|
-
this.renderer = new
|
|
1817
|
+
this.renderer = new ot(
|
|
1781
1818
|
this.target,
|
|
1782
1819
|
t,
|
|
1783
|
-
|
|
1820
|
+
i,
|
|
1784
1821
|
this.registry
|
|
1785
|
-
), this.renderer.mount(), this.syncer = new
|
|
1822
|
+
), this.renderer.mount(), this.syncer = new lt(this.target, this.renderer, this.registry, t);
|
|
1786
1823
|
}
|
|
1787
1824
|
start() {
|
|
1788
1825
|
this.syncer.start();
|
|
@@ -1814,18 +1851,18 @@ class ct {
|
|
|
1814
1851
|
ArrowUp: !1,
|
|
1815
1852
|
ArrowDown: !1
|
|
1816
1853
|
};
|
|
1817
|
-
window.addEventListener("keydown", (
|
|
1818
|
-
t[
|
|
1819
|
-
}), window.addEventListener("keyup", (
|
|
1820
|
-
t[
|
|
1854
|
+
window.addEventListener("keydown", (l) => {
|
|
1855
|
+
t[l.key] !== void 0 && (t[l.key] = !0);
|
|
1856
|
+
}), window.addEventListener("keyup", (l) => {
|
|
1857
|
+
t[l.key] !== void 0 && (t[l.key] = !1);
|
|
1821
1858
|
});
|
|
1822
|
-
const
|
|
1823
|
-
requestAnimationFrame(
|
|
1859
|
+
const i = 2, r = () => {
|
|
1860
|
+
requestAnimationFrame(r), t.ArrowRight && e.position.setX(e.position.x + i), t.ArrowLeft && e.position.setX(e.position.x - i), t.ArrowUp && e.position.setY(e.position.y + i), t.ArrowDown && e.position.setY(e.position.y - i);
|
|
1824
1861
|
};
|
|
1825
|
-
|
|
1862
|
+
r();
|
|
1826
1863
|
}
|
|
1827
1864
|
}
|
|
1828
|
-
class
|
|
1865
|
+
class ut {
|
|
1829
1866
|
constructor(e = {}) {
|
|
1830
1867
|
u(this, "frontSelector");
|
|
1831
1868
|
u(this, "midLayerElement");
|
|
@@ -1834,7 +1871,7 @@ class ht {
|
|
|
1834
1871
|
u(this, "midLayer", null);
|
|
1835
1872
|
u(this, "frontLayer", null);
|
|
1836
1873
|
u(this, "tracker", null);
|
|
1837
|
-
this.frontSelector = e.frontSelector || ".front", this.midLayerElement = e.midLayerElement || null, this.items = [], this.isInitialized = !1, this.tracker = new
|
|
1874
|
+
this.frontSelector = e.frontSelector || ".front", this.midLayerElement = e.midLayerElement || null, this.items = [], this.isInitialized = !1, this.tracker = new Be(document.body, e.trackerConfig || { resizeDebounce: !0 });
|
|
1838
1875
|
}
|
|
1839
1876
|
init() {
|
|
1840
1877
|
var e;
|
|
@@ -1864,48 +1901,48 @@ class ht {
|
|
|
1864
1901
|
const e = document.querySelectorAll(this.frontSelector);
|
|
1865
1902
|
this.frontLayer && e.forEach((t) => {
|
|
1866
1903
|
var n;
|
|
1867
|
-
const
|
|
1868
|
-
|
|
1869
|
-
display:
|
|
1870
|
-
width: `${
|
|
1871
|
-
height: `${
|
|
1904
|
+
const i = t.getBoundingClientRect(), r = window.getComputedStyle(t), l = document.createElement("div");
|
|
1905
|
+
l.className = "sand-placeholder", Object.assign(l.style, {
|
|
1906
|
+
display: r.display === "inline" ? "inline-block" : r.display,
|
|
1907
|
+
width: `${i.width}px`,
|
|
1908
|
+
height: `${i.height}px`,
|
|
1872
1909
|
boxSizing: "border-box",
|
|
1873
|
-
marginTop:
|
|
1874
|
-
marginBottom:
|
|
1875
|
-
marginLeft:
|
|
1876
|
-
marginRight:
|
|
1910
|
+
marginTop: r.marginTop,
|
|
1911
|
+
marginBottom: r.marginBottom,
|
|
1912
|
+
marginLeft: r.marginLeft,
|
|
1913
|
+
marginRight: r.marginRight,
|
|
1877
1914
|
visibility: "hidden",
|
|
1878
1915
|
pointerEvents: "none"
|
|
1879
|
-
}), (n = t.parentNode) == null || n.insertBefore(
|
|
1916
|
+
}), (n = t.parentNode) == null || n.insertBefore(l, t), this.frontLayer.appendChild(t), Object.assign(t.style, {
|
|
1880
1917
|
position: "fixed",
|
|
1881
1918
|
margin: "0",
|
|
1882
1919
|
boxSizing: "border-box",
|
|
1883
|
-
width: `${
|
|
1884
|
-
height: `${
|
|
1920
|
+
width: `${i.width}px`,
|
|
1921
|
+
height: `${i.height}px`,
|
|
1885
1922
|
pointerEvents: "auto"
|
|
1886
|
-
}), this.items.push({ placeholder:
|
|
1923
|
+
}), this.items.push({ placeholder: l, original: t });
|
|
1887
1924
|
});
|
|
1888
1925
|
}
|
|
1889
1926
|
setupHooks() {
|
|
1890
1927
|
this.tracker && this.tracker.onBeforeRender.add(() => {
|
|
1891
1928
|
const e = this.items.map(({ placeholder: t }) => t.getBoundingClientRect());
|
|
1892
|
-
this.items.forEach(({ original: t },
|
|
1893
|
-
const
|
|
1894
|
-
t.style.top = `${
|
|
1929
|
+
this.items.forEach(({ original: t }, i) => {
|
|
1930
|
+
const r = e[i];
|
|
1931
|
+
t.style.top = `${r.top}px`, t.style.left = `${r.left}px`, t.style.width = `${r.width}px`, t.style.height = `${r.height}px`;
|
|
1895
1932
|
});
|
|
1896
1933
|
});
|
|
1897
1934
|
}
|
|
1898
1935
|
}
|
|
1899
|
-
class
|
|
1936
|
+
class gt {
|
|
1900
1937
|
constructor(e, t) {
|
|
1901
1938
|
u(this, "_engine");
|
|
1902
1939
|
u(this, "_sandwich");
|
|
1903
1940
|
if (!e)
|
|
1904
1941
|
throw new Error("[Mirage] Target element is required.");
|
|
1905
|
-
if (this._engine = new
|
|
1906
|
-
const
|
|
1907
|
-
this._sandwich = new
|
|
1908
|
-
frontSelector:
|
|
1942
|
+
if (this._engine = new dt(e, t), t.sandwich !== !1) {
|
|
1943
|
+
const i = typeof t.sandwich == "object" ? t.sandwich : {};
|
|
1944
|
+
this._sandwich = new ut({
|
|
1945
|
+
frontSelector: i.frontSelector || `[${Le.NAME}='${Le.VALUES.FRONT}']`
|
|
1909
1946
|
}), this._sandwich.useTracker(this._engine.getTracker());
|
|
1910
1947
|
}
|
|
1911
1948
|
}
|
|
@@ -1932,5 +1969,5 @@ class ut {
|
|
|
1932
1969
|
}
|
|
1933
1970
|
}
|
|
1934
1971
|
export {
|
|
1935
|
-
|
|
1972
|
+
gt as Mirage
|
|
1936
1973
|
};
|