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