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