@mirage-engine/core 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/CHANGELOG.md +16 -0
- package/dist/mirage-engine.js +846 -807
- package/dist/mirage-engine.umd.js +16 -16
- package/dist/src/dom/Extractor.d.ts +1 -1
- package/dist/src/types/common.d.ts +1 -0
- package/package.json +2 -2
- package/src/dom/Extractor.ts +9 -0
- package/src/renderer/Renderer.ts +82 -0
- package/src/types/common.ts +1 -0
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, Ne = Object.defineProperties;
|
|
2
|
+
var ze = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var Ee = Object.getOwnPropertySymbols;
|
|
4
|
+
var Ve = Object.prototype.hasOwnProperty, Ye = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var be = (i, e, t) => e in i ? Xe(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, te = (i, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var t of
|
|
10
|
-
|
|
11
|
-
return
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var c = (
|
|
7
|
+
Ve.call(e, t) && be(i, t, e[t]);
|
|
8
|
+
if (Ee)
|
|
9
|
+
for (var t of Ee(e))
|
|
10
|
+
Ye.call(e, t) && be(i, t, e[t]);
|
|
11
|
+
return i;
|
|
12
|
+
}, Ce = (i, e) => Ne(i, ze(e));
|
|
13
|
+
var g = (i, e, t) => (be(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
14
|
+
var Te = (i, e, t) => new Promise((r, s) => {
|
|
15
|
+
var c = (l) => {
|
|
16
16
|
try {
|
|
17
|
-
a(t.next(
|
|
18
|
-
} catch (
|
|
19
|
-
s(
|
|
17
|
+
a(t.next(l));
|
|
18
|
+
} catch (n) {
|
|
19
|
+
s(n);
|
|
20
20
|
}
|
|
21
|
-
}, o = (
|
|
21
|
+
}, o = (l) => {
|
|
22
22
|
try {
|
|
23
|
-
a(t.throw(
|
|
24
|
-
} catch (
|
|
25
|
-
s(
|
|
23
|
+
a(t.throw(l));
|
|
24
|
+
} catch (n) {
|
|
25
|
+
s(n);
|
|
26
26
|
}
|
|
27
|
-
}, a = (
|
|
28
|
-
a((t = t.apply(
|
|
27
|
+
}, a = (l) => l.done ? r(l.value) : Promise.resolve(l.value).then(c, o);
|
|
28
|
+
a((t = t.apply(i, 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 De = {
|
|
|
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,31 +54,31 @@ const De = {
|
|
|
54
54
|
CAPTURE_8: "8",
|
|
55
55
|
CAPTURE_9: "9",
|
|
56
56
|
CAPTURE_10: "10"
|
|
57
|
-
},
|
|
57
|
+
}, N = {
|
|
58
58
|
NAME: "data-mirage-travel",
|
|
59
59
|
KEY: "mirageTravel",
|
|
60
|
-
VALUES:
|
|
61
|
-
MAX_LAYERS: Object.keys(
|
|
62
|
-
},
|
|
60
|
+
VALUES: Re,
|
|
61
|
+
MAX_LAYERS: Object.keys(Re).length - 1
|
|
62
|
+
}, H = {
|
|
63
63
|
NAME: "data-mirage-filter",
|
|
64
64
|
KEY: "mirageFilter",
|
|
65
|
-
VALUES:
|
|
66
|
-
},
|
|
65
|
+
VALUES: Ie
|
|
66
|
+
}, $ = {
|
|
67
67
|
NAME: "data-mirage-select",
|
|
68
68
|
KEY: "mirageSelect",
|
|
69
|
-
VALUES:
|
|
70
|
-
},
|
|
69
|
+
VALUES: Ie
|
|
70
|
+
}, We = {
|
|
71
71
|
NAME: "data-mirage-shader",
|
|
72
72
|
KEY: "mirageShader"
|
|
73
|
-
},
|
|
73
|
+
}, dt = {
|
|
74
74
|
NAME: "data-mirage-sandwich",
|
|
75
75
|
KEY: "mirageSandwich",
|
|
76
76
|
VALUES: {
|
|
77
77
|
FRONT: "front"
|
|
78
78
|
}
|
|
79
|
-
},
|
|
80
|
-
function
|
|
81
|
-
const e =
|
|
79
|
+
}, ge = 0, re = 1, ue = 2, Pe = 4, pe = 8, ye = 16;
|
|
80
|
+
function He(i) {
|
|
81
|
+
const e = i.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
|
|
82
82
|
return e ? {
|
|
83
83
|
r: parseInt(e[1]) / 255,
|
|
84
84
|
g: parseInt(e[2]) / 255,
|
|
@@ -86,46 +86,46 @@ function We(r) {
|
|
|
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 Ge(i) {
|
|
90
90
|
const e = {};
|
|
91
|
-
if (
|
|
92
|
-
const t =
|
|
91
|
+
if (i.opacity && (e.opacity = parseFloat(i.opacity)), i.backgroundColor) {
|
|
92
|
+
const t = He(i.backgroundColor);
|
|
93
93
|
e.backgroundColor = [t.r, t.g, t.b, t.a];
|
|
94
94
|
}
|
|
95
|
-
if (
|
|
96
|
-
const t = new DOMMatrix(
|
|
95
|
+
if (i.backgroundImage ? e.backgroundImage = i.backgroundImage : i.background && (e.backgroundImage = i.background), i.boxShadow && (e.boxShadow = i.boxShadow), i.borderRadius && (e.borderRadius = parseFloat(i.borderRadius)), i.width && (e.width = parseFloat(i.width)), i.height && (e.height = parseFloat(i.height)), i.transform && i.transform !== "none") {
|
|
96
|
+
const t = new DOMMatrix(i.transform);
|
|
97
97
|
e.x = t.m41, e.y = t.m42, e.z = t.m43;
|
|
98
98
|
}
|
|
99
99
|
return e;
|
|
100
100
|
}
|
|
101
|
-
class
|
|
101
|
+
class qe {
|
|
102
102
|
constructor(e, t) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingStyles.size == 0 && (this.pendingMask |= re |
|
|
103
|
+
g(this, "target");
|
|
104
|
+
g(this, "observer");
|
|
105
|
+
g(this, "pendingDeletions", /* @__PURE__ */ new Set());
|
|
106
|
+
g(this, "pendingStyles", /* @__PURE__ */ new Map());
|
|
107
|
+
g(this, "isDomDirty", !1);
|
|
108
|
+
g(this, "isRunning", !1);
|
|
109
|
+
g(this, "pendingMask", ge);
|
|
110
|
+
g(this, "mutationTimer", null);
|
|
111
|
+
g(this, "cssTimer", null);
|
|
112
|
+
g(this, "resizeConfig");
|
|
113
|
+
g(this, "resizeTimer", null);
|
|
114
|
+
g(this, "isResizing", !1);
|
|
115
|
+
g(this, "lastScrollX", 0);
|
|
116
|
+
g(this, "lastScrollY", 0);
|
|
117
|
+
g(this, "scrollTimer", null);
|
|
118
|
+
g(this, "onBeforeRender", /* @__PURE__ */ new Set());
|
|
119
|
+
g(this, "onLayoutChange", /* @__PURE__ */ new Set());
|
|
120
|
+
g(this, "onStyleChange", /* @__PURE__ */ new Set());
|
|
121
|
+
g(this, "onScrollChange", /* @__PURE__ */ new Set());
|
|
122
|
+
g(this, "onRender", /* @__PURE__ */ new Set());
|
|
123
|
+
g(this, "onTransitionFinished", (e) => {
|
|
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
|
});
|
|
128
|
-
|
|
128
|
+
g(this, "onWindowResize", () => {
|
|
129
129
|
if (!this.resizeConfig.enabled) {
|
|
130
130
|
this.isDomDirty = !0;
|
|
131
131
|
return;
|
|
@@ -134,41 +134,41 @@ class He {
|
|
|
134
134
|
this.isDomDirty = !0, this.resizeConfig.onEnd && this.resizeConfig.onEnd(), this.isResizing = !1, this.resizeTimer = null;
|
|
135
135
|
}, this.resizeConfig.delay);
|
|
136
136
|
});
|
|
137
|
-
|
|
137
|
+
g(this, "renderLoop", () => {
|
|
138
138
|
if (!this.isRunning)
|
|
139
139
|
return;
|
|
140
|
-
this.onBeforeRender.forEach((
|
|
140
|
+
this.onBeforeRender.forEach((r) => r()), this.isDomDirty && (this.isDomDirty = !1, this.onLayoutChange.forEach((r) => r(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((r) => r(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((r) => r(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((r) => r()), requestAnimationFrame(this.renderLoop);
|
|
145
145
|
});
|
|
146
146
|
var s, c;
|
|
147
147
|
this.target = e;
|
|
148
|
-
const
|
|
149
|
-
|
|
148
|
+
const r = (s = t.resizeDebounce) != null ? s : !0;
|
|
149
|
+
r === !1 ? this.resizeConfig = { enabled: !1, delay: 0 } : r === !0 ? this.resizeConfig = { enabled: !0, delay: 150 } : this.resizeConfig = {
|
|
150
150
|
enabled: !0,
|
|
151
|
-
delay: (c =
|
|
152
|
-
onStart:
|
|
153
|
-
onEnd:
|
|
151
|
+
delay: (c = r.delay) != null ? c : 150,
|
|
152
|
+
onStart: r.onStart,
|
|
153
|
+
onEnd: r.onEnd
|
|
154
154
|
}, this.observer = new MutationObserver((o) => {
|
|
155
|
-
let a =
|
|
156
|
-
for (const
|
|
157
|
-
if (
|
|
158
|
-
a |=
|
|
159
|
-
|
|
155
|
+
let a = ge;
|
|
156
|
+
for (const l of o)
|
|
157
|
+
if (l.type === "childList")
|
|
158
|
+
a |= pe, l.removedNodes.length > 0 && l.removedNodes.forEach((n) => {
|
|
159
|
+
n instanceof HTMLElement && this.pendingDeletions.add(n);
|
|
160
160
|
});
|
|
161
|
-
else if (
|
|
162
|
-
if (
|
|
163
|
-
a |= re |
|
|
164
|
-
const
|
|
165
|
-
this.pendingStyles.set(
|
|
161
|
+
else if (l.type === "attributes")
|
|
162
|
+
if (l.attributeName === "style") {
|
|
163
|
+
a |= re | ue;
|
|
164
|
+
const n = l.target, u = Ge(n.style);
|
|
165
|
+
this.pendingStyles.set(n, u);
|
|
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 (a !==
|
|
171
|
-
if (this.pendingMask |= a, a &
|
|
169
|
+
l.type === "characterData" && (a |= ye | 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 He {
|
|
|
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, ut = 0, F = {
|
|
197
197
|
BASE: 0,
|
|
198
198
|
SELECTED: 1,
|
|
199
|
-
getCaptureLayer: (
|
|
199
|
+
getCaptureLayer: (i) => 31 - i,
|
|
200
200
|
HIDDEN: 31
|
|
201
|
-
},
|
|
202
|
-
class
|
|
201
|
+
}, Me = Object.values(H.VALUES);
|
|
202
|
+
class ke {
|
|
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,28 +214,28 @@ class Ae {
|
|
|
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 = s.offsetTop -
|
|
217
|
+
const t = document.createElement("div"), r = document.createElement("span"), s = 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", r.style.margin = "0", r.style.padding = "0", r.style.border = "none", r.style.lineHeight = "normal", s.width = 1, s.height = 1, s.style.verticalAlign = "baseline", r.appendChild(document.createTextNode("Hidden Text")), t.appendChild(r), t.appendChild(s), document.body.appendChild(t);
|
|
219
|
+
const c = s.offsetTop - r.offsetTop;
|
|
220
220
|
return document.body.removeChild(t), c;
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
|
-
|
|
224
|
-
class
|
|
225
|
-
constructor(t,
|
|
223
|
+
g(ke, "cache", /* @__PURE__ */ new Map());
|
|
224
|
+
class $e extends w.MeshBasicMaterial {
|
|
225
|
+
constructor(t, r, s, c, o = 2) {
|
|
226
226
|
super({
|
|
227
227
|
transparent: !0,
|
|
228
228
|
side: w.FrontSide,
|
|
229
229
|
color: 16777215
|
|
230
230
|
});
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
231
|
+
g(this, "canvas");
|
|
232
|
+
g(this, "ctx");
|
|
233
|
+
g(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 = o, 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 = o, 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, r, s, c);
|
|
237
237
|
}
|
|
238
|
-
wrapText(t,
|
|
238
|
+
wrapText(t, r) {
|
|
239
239
|
const s = t.split(`
|
|
240
240
|
`), c = [];
|
|
241
241
|
return s.forEach((o) => {
|
|
@@ -244,57 +244,57 @@ class Ge extends w.MeshBasicMaterial {
|
|
|
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 n = 1; n < a.length; n++) {
|
|
249
|
+
const u = a[n];
|
|
250
|
+
this.ctx.measureText(l + u).width <= r + 2 ? l += u : (l && c.push(l), l = u.trimStart());
|
|
251
251
|
}
|
|
252
|
-
|
|
252
|
+
l && c.push(l);
|
|
253
253
|
}), c;
|
|
254
254
|
}
|
|
255
|
-
updateText(t,
|
|
255
|
+
updateText(t, r, s, c, o) {
|
|
256
256
|
o !== void 0 && (this.qualityFactor = o);
|
|
257
|
-
const
|
|
258
|
-
this.canvas.width !==
|
|
259
|
-
const h = this.wrapText(t, s),
|
|
260
|
-
h.forEach((
|
|
261
|
-
const
|
|
262
|
-
let
|
|
263
|
-
|
|
257
|
+
const l = (window.devicePixelRatio || 1) * this.qualityFactor, n = s * l, u = c * l;
|
|
258
|
+
this.canvas.width !== n || this.canvas.height !== u ? (this.canvas.width = n, this.canvas.height = u) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(l, 0, 0, l, 0, 0), this.ctx.font = r.font, this.ctx.fillStyle = r.color, this.ctx.textBaseline = "alphabetic", this.ctx.globalAlpha = 1;
|
|
259
|
+
const h = this.wrapText(t, s), d = r.lineHeight, p = ke.getBaseline(r.font);
|
|
260
|
+
h.forEach((f, L) => {
|
|
261
|
+
const m = L * d + p;
|
|
262
|
+
let b = 0;
|
|
263
|
+
r.textAlign === "center" ? b = s / 2 : r.textAlign === "right" && (b = s), this.ctx.textAlign = r.textAlign, this.ctx.fillText(f, b, 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
|
|
271
|
-
if (typeof
|
|
272
|
-
return
|
|
273
|
-
const t = parseFloat(
|
|
274
|
-
return typeof
|
|
270
|
+
function le(i, e = 0) {
|
|
271
|
+
if (typeof i == "number")
|
|
272
|
+
return i;
|
|
273
|
+
const t = parseFloat(i) || 0;
|
|
274
|
+
return typeof i == "string" && i.includes("%") ? t / 100 * e : t;
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
if (!
|
|
276
|
+
function ce(i) {
|
|
277
|
+
if (!i || i === "transparent")
|
|
278
278
|
return { color: new w.Color(16777215), alpha: 0 };
|
|
279
|
-
const e =
|
|
279
|
+
const e = i.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), r = parseInt(e[2], 10), s = parseInt(e[3], 10), c = e[4] !== void 0 ? parseFloat(e[4]) : 1;
|
|
284
|
+
return { color: new w.Color(`rgb(${t}, ${r}, ${s})`), alpha: c };
|
|
285
285
|
}
|
|
286
|
-
return { color: new w.Color(
|
|
286
|
+
return { color: new w.Color(i), alpha: 1 };
|
|
287
287
|
}
|
|
288
|
-
function
|
|
288
|
+
function Ue(i) {
|
|
289
289
|
const e = [];
|
|
290
|
-
let t = "",
|
|
291
|
-
for (let s = 0; s <
|
|
292
|
-
const c =
|
|
290
|
+
let t = "", r = 0;
|
|
291
|
+
for (let s = 0; s < i.length; s++) {
|
|
292
|
+
const c = i[s];
|
|
293
293
|
if (c === "(")
|
|
294
|
-
|
|
294
|
+
r++;
|
|
295
295
|
else if (c === ")")
|
|
296
|
-
|
|
297
|
-
else if (c === "," &&
|
|
296
|
+
r--;
|
|
297
|
+
else if (c === "," && r === 0) {
|
|
298
298
|
e.push(t.trim()), t = "";
|
|
299
299
|
continue;
|
|
300
300
|
}
|
|
@@ -302,78 +302,78 @@ function Ie(r) {
|
|
|
302
302
|
}
|
|
303
303
|
return t && e.push(t.trim()), e;
|
|
304
304
|
}
|
|
305
|
-
function
|
|
306
|
-
if (!
|
|
305
|
+
function je(i) {
|
|
306
|
+
if (!i || typeof i != "string" || !i.includes("linear-gradient"))
|
|
307
307
|
return null;
|
|
308
|
-
const e =
|
|
308
|
+
const e = i.match(/linear-gradient\((.*)\)/);
|
|
309
309
|
if (!e)
|
|
310
310
|
return null;
|
|
311
|
-
const t = e[1],
|
|
311
|
+
const t = e[1], r = Ue(t);
|
|
312
312
|
let s = Math.PI, c = 0;
|
|
313
|
-
const o =
|
|
313
|
+
const o = r[0].trim();
|
|
314
314
|
if (o.startsWith("to "))
|
|
315
315
|
o === "to top" ? s = 0 : o === "to right" ? s = Math.PI / 2 : o === "to bottom" ? s = Math.PI : o === "to left" ? s = Math.PI * 1.5 : o === "to top right" || o === "to right top" ? s = Math.PI / 4 : o === "to bottom right" || o === "to right bottom" ? s = Math.PI * 0.75 : o === "to bottom left" || o === "to left bottom" ? s = Math.PI * 1.25 : (o === "to top left" || o === "to left top") && (s = Math.PI * 1.75), c = 1;
|
|
316
316
|
else if (o.endsWith("deg") || o.endsWith("rad") || o.endsWith("turn")) {
|
|
317
|
-
const
|
|
318
|
-
o.endsWith("deg") ? s =
|
|
317
|
+
const l = parseFloat(o);
|
|
318
|
+
o.endsWith("deg") ? s = l * (Math.PI / 180) : o.endsWith("rad") ? s = l : o.endsWith("turn") && (s = l * Math.PI * 2), c = 1;
|
|
319
319
|
}
|
|
320
320
|
const a = [];
|
|
321
|
-
for (let
|
|
322
|
-
const
|
|
323
|
-
let h =
|
|
324
|
-
if (
|
|
325
|
-
const
|
|
326
|
-
(
|
|
321
|
+
for (let l = c; l < r.length && !(a.length >= 8); l++) {
|
|
322
|
+
const n = r[l].trim(), u = n.lastIndexOf(" ");
|
|
323
|
+
let h = n, d = null;
|
|
324
|
+
if (u !== -1 && !n.endsWith(")")) {
|
|
325
|
+
const f = n.substring(u + 1);
|
|
326
|
+
(f.endsWith("%") || f.endsWith("px") || !isNaN(parseFloat(f))) && (h = n.substring(0, u).trim(), d = f);
|
|
327
327
|
}
|
|
328
|
-
const
|
|
328
|
+
const p = ce(h);
|
|
329
329
|
a.push({
|
|
330
|
-
color:
|
|
331
|
-
alpha:
|
|
332
|
-
rawStop:
|
|
330
|
+
color: p.color,
|
|
331
|
+
alpha: p.alpha,
|
|
332
|
+
rawStop: d,
|
|
333
333
|
stop: 0
|
|
334
334
|
});
|
|
335
335
|
}
|
|
336
336
|
if (a.length > 0) {
|
|
337
|
-
for (let
|
|
338
|
-
a[
|
|
337
|
+
for (let n = 0; n < a.length; n++)
|
|
338
|
+
a[n].rawStop !== null && (a[n].stop = parseFloat(a[n].rawStop) / 100);
|
|
339
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
|
|
341
|
-
for (let
|
|
342
|
-
if (a[
|
|
343
|
-
const
|
|
344
|
-
if (
|
|
345
|
-
const h = a[
|
|
346
|
-
for (let
|
|
347
|
-
a[
|
|
340
|
+
let l = 0;
|
|
341
|
+
for (let n = 1; n < a.length; n++)
|
|
342
|
+
if (a[n].rawStop !== null || n === a.length - 1) {
|
|
343
|
+
const u = n - l;
|
|
344
|
+
if (u > 1) {
|
|
345
|
+
const h = a[l].stop, p = (a[n].stop - h) / u;
|
|
346
|
+
for (let f = 1; f < u; f++)
|
|
347
|
+
a[l + f].stop = h + p * f;
|
|
348
348
|
}
|
|
349
|
-
|
|
349
|
+
l = n;
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
return { angle: s, stops: a };
|
|
353
353
|
}
|
|
354
|
-
function
|
|
355
|
-
if (!
|
|
354
|
+
function Ke(i) {
|
|
355
|
+
if (!i || i === "none")
|
|
356
356
|
return null;
|
|
357
|
-
const e =
|
|
357
|
+
const e = Ue(i);
|
|
358
358
|
if (e.length === 0)
|
|
359
359
|
return null;
|
|
360
|
-
const t = e[0].trim(),
|
|
360
|
+
const t = e[0].trim(), r = /(rgba?\([^)]+\)|#[0-9a-fA-F]+|[a-zA-Z]+)/, s = t.match(r);
|
|
361
361
|
let c = "transparent", o = t;
|
|
362
362
|
if (s && s[1] !== "inset") {
|
|
363
|
-
const
|
|
364
|
-
(
|
|
363
|
+
const p = s[1];
|
|
364
|
+
(p.startsWith("rgb") || p.startsWith("#") || p === "black" || p === "white" || p === "transparent") && (c = p, o = t.replace(p, "").trim());
|
|
365
365
|
}
|
|
366
366
|
o = o.replace("inset", "").trim();
|
|
367
|
-
const a = o.split(/\s+/).map((
|
|
368
|
-
return { offsetX:
|
|
367
|
+
const a = o.split(/\s+/).map((p) => parseFloat(p) || 0), l = a[0] || 0, n = a[1] || 0, u = a[2] || 0, h = a[3] || 0, d = ce(c);
|
|
368
|
+
return { offsetX: l, offsetY: n, blurRadius: u, spreadRadius: h, color: d.color, alpha: d.alpha };
|
|
369
369
|
}
|
|
370
|
-
const
|
|
370
|
+
const Je = `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
|
+
}`, Ze = `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
|
+
`, Qe = `uniform sampler2D uTexture;
|
|
536
536
|
varying vec4 vScreenPos;
|
|
537
537
|
uniform vec2 uTextureRepeat;
|
|
538
|
-
uniform vec2 uTextureOffset;`,
|
|
538
|
+
uniform vec2 uTextureOffset;`, et = `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
|
+
`, tt = `vec4 texColor = texture2D(uTexture, resultUv);
|
|
542
|
+
baseColor = blendSrcOver(baseColor, texColor);`, Le = {
|
|
543
|
+
vertexShader: Je,
|
|
544
|
+
fragmentShader: Ze
|
|
545
|
+
}, De = {
|
|
546
|
+
declChunk: Qe,
|
|
547
|
+
uvChunk: et,
|
|
548
|
+
baseColorChunk: tt
|
|
549
549
|
};
|
|
550
|
-
function
|
|
551
|
-
var
|
|
552
|
-
const c =
|
|
550
|
+
function rt(i, e, t, r = null, s) {
|
|
551
|
+
var C;
|
|
552
|
+
const c = r !== null || !!i.imageSrc;
|
|
553
553
|
let o = "";
|
|
554
554
|
const a = {};
|
|
555
555
|
if (s != null && s.uniforms)
|
|
556
|
-
for (const [
|
|
557
|
-
typeof
|
|
558
|
-
`, a[
|
|
559
|
-
`, a[
|
|
560
|
-
`, a[
|
|
561
|
-
`, a[
|
|
562
|
-
`, a[
|
|
563
|
-
const
|
|
564
|
-
` + o,
|
|
565
|
-
`, h =
|
|
556
|
+
for (const [y, S] of Object.entries(s.uniforms))
|
|
557
|
+
typeof S == "number" ? (o += `uniform float ${y};
|
|
558
|
+
`, a[y] = { value: S }) : Array.isArray(S) ? S.length === 2 ? (o += `uniform vec2 ${y};
|
|
559
|
+
`, a[y] = { value: new w.Vector2(...S) }) : S.length === 3 ? (o += `uniform vec3 ${y};
|
|
560
|
+
`, a[y] = { value: new w.Vector3(...S) }) : S.length === 4 && (o += `uniform vec4 ${y};
|
|
561
|
+
`, a[y] = { value: new w.Vector4(...S) }) : (o += `uniform float ${y};
|
|
562
|
+
`, a[y] = { value: S });
|
|
563
|
+
const l = s !== void 0, n = (c || l ? De.declChunk : "") + `
|
|
564
|
+
` + o, u = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
|
|
565
|
+
`, h = i.isTraveler ? `vec2 resultUv = screenUv;
|
|
566
566
|
` : `vec2 localUv = (p / uSize) + 0.5;
|
|
567
567
|
vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
|
|
568
|
-
`,
|
|
568
|
+
`, d = c || l ? u + h + ((s == null ? void 0 : s.uvModifier) || "") : "", p = c || l ? De.baseColorChunk : "", f = (s == null ? void 0 : s.colorModifier) || "", L = Le.fragmentShader.replace("#INJECT_DECLARATIONS", n).replace("#INJECT_UV_MODIFIER", d).replace("#INJECT_BASE_COLOR", p).replace("#INJECT_COLOR_MODIFIER", f), m = ce(i.backgroundColor), b = ce(i.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
|
+
b.color.r,
|
|
586
|
+
b.color.g,
|
|
587
|
+
b.color.b,
|
|
588
|
+
b.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(i.borderWidth) },
|
|
593
|
+
uOpacity: { value: (C = i.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,22 +601,22 @@ 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
|
+
Be(E.uBorderRadius.value, i.borderRadius, Math.min(e, t)), c && (E.uTexture.value = r);
|
|
605
|
+
const A = new w.ShaderMaterial({
|
|
606
|
+
uniforms: te(te({}, E), a),
|
|
607
|
+
vertexShader: Le.vertexShader,
|
|
608
|
+
fragmentShader: L,
|
|
609
609
|
transparent: !0,
|
|
610
610
|
side: w.FrontSide
|
|
611
611
|
// for better performance
|
|
612
612
|
});
|
|
613
|
-
return
|
|
613
|
+
return i.backgroundImage && xe(A, { backgroundImage: i.backgroundImage }), A;
|
|
614
614
|
}
|
|
615
|
-
function
|
|
616
|
-
const c =
|
|
617
|
-
|
|
615
|
+
function it(i, e, t, r, s) {
|
|
616
|
+
const c = le(e.borderWidth);
|
|
617
|
+
xe(i, {
|
|
618
618
|
width: t,
|
|
619
|
-
height:
|
|
619
|
+
height: r,
|
|
620
620
|
borderRadius: e.borderRadius,
|
|
621
621
|
borderWidth: c,
|
|
622
622
|
backgroundColor: e.backgroundColor,
|
|
@@ -627,40 +627,40 @@ function tt(r, e, t, i, s) {
|
|
|
627
627
|
boxShadow: e.boxShadow
|
|
628
628
|
});
|
|
629
629
|
}
|
|
630
|
-
function
|
|
631
|
-
var
|
|
630
|
+
function xe(i, e) {
|
|
631
|
+
var r, s, c;
|
|
632
632
|
if (e.boxShadow !== void 0) {
|
|
633
|
-
const o =
|
|
634
|
-
o ? (
|
|
633
|
+
const o = Ke(e.boxShadow);
|
|
634
|
+
o ? (i.uniforms.uShadowColor.value.set(o.color.r, o.color.g, o.color.b, o.alpha), i.uniforms.uShadowOffset.value.set(o.offsetX, o.offsetY), i.uniforms.uShadowBlur.value = o.blurRadius, i.uniforms.uShadowSpread.value = o.spreadRadius, i.userData.shadowPadding = o.blurRadius + o.spreadRadius + Math.max(Math.abs(o.offsetX), Math.abs(o.offsetY))) : (i.uniforms.uShadowColor.value.w = 0, i.userData.shadowPadding = 0);
|
|
635
635
|
}
|
|
636
|
-
if (e.width !== void 0 && e.height !== void 0 &&
|
|
637
|
-
const o =
|
|
638
|
-
|
|
636
|
+
if (e.width !== void 0 && e.height !== void 0 && i.uniforms.uSize.value.set(e.width, e.height), i.uniforms.uMeshSize) {
|
|
637
|
+
const o = i.userData.shadowPadding || 0, a = e.width !== void 0 ? e.width : i.uniforms.uSize.value.x, l = e.height !== void 0 ? e.height : i.uniforms.uSize.value.y;
|
|
638
|
+
i.uniforms.uMeshSize.value.set(a + o * 2, l + o * 2);
|
|
639
639
|
}
|
|
640
640
|
if (e.borderRadius !== void 0) {
|
|
641
|
-
const o = e.width !== void 0 && e.height !== void 0 ? Math.min(e.width, e.height) : Math.min(
|
|
642
|
-
|
|
641
|
+
const o = e.width !== void 0 && e.height !== void 0 ? Math.min(e.width, e.height) : Math.min(i.uniforms.uSize.value.x, i.uniforms.uSize.value.y);
|
|
642
|
+
Be(i.uniforms.uBorderRadius.value, e.borderRadius, o);
|
|
643
643
|
}
|
|
644
|
-
if (e.borderWidth !== void 0 && (
|
|
644
|
+
if (e.borderWidth !== void 0 && (i.uniforms.uBorderWidth.value = e.borderWidth), e.backgroundColor !== void 0)
|
|
645
645
|
if (Array.isArray(e.backgroundColor)) {
|
|
646
|
-
const o = e.backgroundColor[3] !== void 0 ? e.backgroundColor[3] :
|
|
647
|
-
|
|
646
|
+
const o = e.backgroundColor[3] !== void 0 ? e.backgroundColor[3] : i.uniforms.uBgColor.value.w;
|
|
647
|
+
i.uniforms.uBgColor.value.set(
|
|
648
648
|
e.backgroundColor[0],
|
|
649
649
|
e.backgroundColor[1],
|
|
650
650
|
e.backgroundColor[2],
|
|
651
651
|
o
|
|
652
652
|
);
|
|
653
653
|
} else if (typeof e.backgroundColor == "string") {
|
|
654
|
-
const o =
|
|
655
|
-
|
|
654
|
+
const o = ce(e.backgroundColor);
|
|
655
|
+
i.uniforms.uBgColor.value.set(
|
|
656
656
|
o.color.r,
|
|
657
657
|
o.color.g,
|
|
658
658
|
o.color.b,
|
|
659
659
|
o.alpha
|
|
660
660
|
);
|
|
661
661
|
} else {
|
|
662
|
-
const o =
|
|
663
|
-
|
|
662
|
+
const o = i.uniforms.uBgColor.value.w;
|
|
663
|
+
i.uniforms.uBgColor.value.set(
|
|
664
664
|
e.backgroundColor.r,
|
|
665
665
|
e.backgroundColor.g,
|
|
666
666
|
e.backgroundColor.b,
|
|
@@ -669,129 +669,129 @@ function be(r, e) {
|
|
|
669
669
|
}
|
|
670
670
|
if (e.borderColor !== void 0)
|
|
671
671
|
if (Array.isArray(e.borderColor)) {
|
|
672
|
-
const o =
|
|
673
|
-
|
|
672
|
+
const o = i.uniforms.uBorderColor.value.w;
|
|
673
|
+
i.uniforms.uBorderColor.value.set(
|
|
674
674
|
e.borderColor[0],
|
|
675
675
|
e.borderColor[1],
|
|
676
676
|
e.borderColor[2],
|
|
677
677
|
o
|
|
678
678
|
);
|
|
679
679
|
} else if (typeof e.borderColor == "string") {
|
|
680
|
-
const o =
|
|
681
|
-
|
|
680
|
+
const o = ce(e.borderColor);
|
|
681
|
+
i.uniforms.uBorderColor.value.set(
|
|
682
682
|
o.color.r,
|
|
683
683
|
o.color.g,
|
|
684
684
|
o.color.b,
|
|
685
685
|
o.alpha
|
|
686
686
|
);
|
|
687
687
|
} else {
|
|
688
|
-
const o =
|
|
689
|
-
|
|
688
|
+
const o = i.uniforms.uBorderColor.value.w;
|
|
689
|
+
i.uniforms.uBorderColor.value.set(
|
|
690
690
|
e.borderColor.r,
|
|
691
691
|
e.borderColor.g,
|
|
692
692
|
e.borderColor.b,
|
|
693
693
|
o
|
|
694
694
|
);
|
|
695
695
|
}
|
|
696
|
-
e.opacity !== void 0 && (
|
|
697
|
-
const t = e.texture !== void 0 ? e.texture : (
|
|
696
|
+
e.opacity !== void 0 && (i.uniforms.uOpacity.value = e.opacity), e.bgOpacity !== void 0 && (i.uniforms.uBgColor.value.w = e.bgOpacity), e.borderOpacity !== void 0 && (i.uniforms.uBorderColor.value.w = e.borderOpacity), i.uniforms.uTexture && e.texture !== void 0 && (i.uniforms.uTexture.value = e.texture);
|
|
697
|
+
const t = e.texture !== void 0 ? e.texture : (r = i.uniforms.uTexture) == null ? void 0 : r.value;
|
|
698
698
|
if (t && (t.image instanceof ImageBitmap || t.image instanceof HTMLImageElement || t.image instanceof HTMLCanvasElement)) {
|
|
699
|
-
const o = t.image.naturalWidth || t.image.videoWidth || t.image.width, a = t.image.naturalHeight || t.image.videoHeight || t.image.height,
|
|
700
|
-
if (o && a &&
|
|
701
|
-
const
|
|
702
|
-
if (
|
|
703
|
-
const
|
|
704
|
-
|
|
699
|
+
const o = t.image.naturalWidth || t.image.videoWidth || t.image.width, a = t.image.naturalHeight || t.image.videoHeight || t.image.height, l = (s = e.width) != null ? s : i.uniforms.uSize.value.x, n = (c = e.height) != null ? c : i.uniforms.uSize.value.y;
|
|
700
|
+
if (o && a && l && n) {
|
|
701
|
+
const u = o / a, h = l / n;
|
|
702
|
+
if (u > h) {
|
|
703
|
+
const d = h / u;
|
|
704
|
+
i.uniforms.uTextureRepeat.value.set(d, 1), i.uniforms.uTextureOffset.value.set((1 - d) / 2, 0);
|
|
705
705
|
} else {
|
|
706
|
-
const
|
|
707
|
-
|
|
706
|
+
const d = u / h;
|
|
707
|
+
i.uniforms.uTextureRepeat.value.set(1, d), i.uniforms.uTextureOffset.value.set(0, (1 - d) / 2);
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
710
|
} else
|
|
711
|
-
|
|
711
|
+
i.uniforms.uTextureRepeat && (i.uniforms.uTextureRepeat.value.set(1, 1), i.uniforms.uTextureOffset.value.set(0, 0));
|
|
712
712
|
if (e.backgroundImage !== void 0) {
|
|
713
|
-
const o =
|
|
713
|
+
const o = je(e.backgroundImage);
|
|
714
714
|
if (o) {
|
|
715
|
-
|
|
715
|
+
i.uniforms.uGradientCount.value = o.stops.length, i.uniforms.uGradientAngle.value = o.angle;
|
|
716
716
|
for (let a = 0; a < 8; a++)
|
|
717
717
|
if (a < o.stops.length) {
|
|
718
|
-
const
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
),
|
|
718
|
+
const l = o.stops[a];
|
|
719
|
+
i.uniforms.uGradientColors.value[a].set(
|
|
720
|
+
l.color.r,
|
|
721
|
+
l.color.g,
|
|
722
|
+
l.color.b,
|
|
723
|
+
l.alpha
|
|
724
|
+
), i.uniforms.uGradientStops.value[a] = l.stop;
|
|
725
725
|
} else
|
|
726
|
-
|
|
726
|
+
i.uniforms.uGradientColors.value[a].set(0, 0, 0, 0), i.uniforms.uGradientStops.value[a] = 1;
|
|
727
727
|
} else
|
|
728
|
-
|
|
728
|
+
i.uniforms.uGradientCount.value = 0;
|
|
729
729
|
}
|
|
730
730
|
for (const o of Object.keys(e))
|
|
731
|
-
o !== "width" && o !== "height" && o !== "borderRadius" && o !== "borderWidth" && o !== "backgroundColor" && o !== "borderColor" && o !== "opacity" && o !== "bgOpacity" && o !== "borderOpacity" && o !== "texture" && o !== "backgroundImage" && o !== "boxShadow" &&
|
|
731
|
+
o !== "width" && o !== "height" && o !== "borderRadius" && o !== "borderWidth" && o !== "backgroundColor" && o !== "borderColor" && o !== "opacity" && o !== "bgOpacity" && o !== "borderOpacity" && o !== "texture" && o !== "backgroundImage" && o !== "boxShadow" && i.uniforms[o] !== void 0 && (i.uniforms[o].value !== void 0 && i.uniforms[o].value !== null && typeof i.uniforms[o].value.set == "function" ? Array.isArray(e[o]) ? i.uniforms[o].value.set(...e[o]) : e[o] !== void 0 && (e[o].copy ? i.uniforms[o].value.copy(e[o]) : i.uniforms[o].value = e[o]) : i.uniforms[o].value = e[o]);
|
|
732
732
|
}
|
|
733
|
-
function
|
|
734
|
-
var
|
|
733
|
+
function Be(i, e, t = 0) {
|
|
734
|
+
var l, n, u, h;
|
|
735
735
|
if (e == null) {
|
|
736
|
-
|
|
736
|
+
i.set(0, 0, 0, 0);
|
|
737
737
|
return;
|
|
738
738
|
}
|
|
739
739
|
if (typeof e == "number") {
|
|
740
|
-
|
|
740
|
+
i.set(e, e, e, e);
|
|
741
741
|
return;
|
|
742
742
|
}
|
|
743
743
|
if (Array.isArray(e)) {
|
|
744
|
-
|
|
744
|
+
i.set(e[0], e[1], e[2], e[3]);
|
|
745
745
|
return;
|
|
746
746
|
}
|
|
747
|
-
const
|
|
748
|
-
|
|
747
|
+
const r = e.split("/")[0].trim().split(/\s+/), s = le(r[0], t), c = le((l = r[1]) != null ? l : r[0], t), o = le((n = r[2]) != null ? n : r[0], t), a = le((h = (u = r[3]) != null ? u : r[1]) != null ? h : r[0], t);
|
|
748
|
+
i.set(s, c, o, a);
|
|
749
749
|
}
|
|
750
750
|
const W = {
|
|
751
|
-
create(
|
|
752
|
-
return
|
|
751
|
+
create(i, e, t, r, s, c = 2, o = null, a) {
|
|
752
|
+
return i === "BOX" ? rt(
|
|
753
753
|
e,
|
|
754
|
-
|
|
754
|
+
r,
|
|
755
755
|
s,
|
|
756
756
|
o,
|
|
757
757
|
a
|
|
758
|
-
) :
|
|
758
|
+
) : i === "TEXT" ? new $e(
|
|
759
759
|
t || "",
|
|
760
760
|
e,
|
|
761
|
-
|
|
761
|
+
r,
|
|
762
762
|
s,
|
|
763
763
|
c
|
|
764
764
|
) : new w.MeshBasicMaterial({ visible: !1 });
|
|
765
765
|
},
|
|
766
|
-
update(
|
|
767
|
-
e === "BOX" ?
|
|
768
|
-
|
|
766
|
+
update(i, e, t, r, s, c, o = 2, a) {
|
|
767
|
+
e === "BOX" ? it(
|
|
768
|
+
i,
|
|
769
769
|
t,
|
|
770
770
|
s,
|
|
771
771
|
c,
|
|
772
772
|
a
|
|
773
|
-
) : e === "TEXT" &&
|
|
774
|
-
|
|
773
|
+
) : e === "TEXT" && i.updateText(
|
|
774
|
+
r || "",
|
|
775
775
|
t,
|
|
776
776
|
s,
|
|
777
777
|
c,
|
|
778
778
|
o
|
|
779
779
|
);
|
|
780
780
|
},
|
|
781
|
-
forceUpdateUniforms(
|
|
782
|
-
|
|
781
|
+
forceUpdateUniforms(i, e) {
|
|
782
|
+
xe(i, e);
|
|
783
783
|
}
|
|
784
784
|
};
|
|
785
|
-
class
|
|
785
|
+
class st {
|
|
786
786
|
constructor(e, t = !0) {
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
787
|
+
g(this, "observer");
|
|
788
|
+
g(this, "textures", /* @__PURE__ */ new WeakMap());
|
|
789
|
+
g(this, "loadStatus", /* @__PURE__ */ new WeakMap());
|
|
790
|
+
g(this, "elementUrls", /* @__PURE__ */ new WeakMap());
|
|
791
|
+
g(this, "onUpdate");
|
|
792
792
|
this.onUpdate = e, t && (this.observer = new IntersectionObserver(
|
|
793
|
-
(
|
|
794
|
-
for (const s of
|
|
793
|
+
(r) => {
|
|
794
|
+
for (const s of r) {
|
|
795
795
|
const c = s.target;
|
|
796
796
|
s.isIntersecting ? this.loadTexture(c) : this.disposeTexture(c);
|
|
797
797
|
}
|
|
@@ -808,31 +808,31 @@ class rt {
|
|
|
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 r;
|
|
819
819
|
if (t.startsWith("data:image/svg+xml"))
|
|
820
|
-
|
|
820
|
+
r = yield new Promise((c, o) => {
|
|
821
821
|
const a = new Image();
|
|
822
822
|
a.onload = () => c(a), a.onerror = o, a.src = t;
|
|
823
823
|
});
|
|
824
824
|
else {
|
|
825
825
|
const o = yield (yield fetch(t)).blob();
|
|
826
|
-
|
|
826
|
+
r = yield createImageBitmap(o, { imageOrientation: "flipY" });
|
|
827
827
|
}
|
|
828
828
|
if (this.elementUrls.get(e) !== t) {
|
|
829
|
-
"close" in
|
|
829
|
+
"close" in r && r.close();
|
|
830
830
|
return;
|
|
831
831
|
}
|
|
832
|
-
const s = new w.Texture(
|
|
833
|
-
|
|
834
|
-
} catch (
|
|
835
|
-
console.warn("[MirageEngine] Failed to load texture:", t,
|
|
832
|
+
const s = new w.Texture(r);
|
|
833
|
+
r instanceof HTMLImageElement || (s.flipY = !1), s.colorSpace = w.LinearSRGBColorSpace, s.needsUpdate = !0, this.textures.set(e, s), this.onUpdate(e, s);
|
|
834
|
+
} catch (r) {
|
|
835
|
+
console.warn("[MirageEngine] Failed to load texture:", t, r);
|
|
836
836
|
} finally {
|
|
837
837
|
this.elementUrls.has(e) && this.loadStatus.set(e, !1);
|
|
838
838
|
}
|
|
@@ -850,35 +850,35 @@ class rt {
|
|
|
850
850
|
this.observer && this.observer.disconnect();
|
|
851
851
|
}
|
|
852
852
|
}
|
|
853
|
-
class
|
|
854
|
-
constructor(e, t,
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
{ length:
|
|
853
|
+
class ot {
|
|
854
|
+
constructor(e, t, r, s) {
|
|
855
|
+
g(this, "canvas");
|
|
856
|
+
g(this, "scene");
|
|
857
|
+
g(this, "camera");
|
|
858
|
+
g(this, "renderer");
|
|
859
|
+
g(this, "renderTargets", []);
|
|
860
|
+
g(this, "renderOrder", 0);
|
|
861
|
+
g(this, "qualityFactor", 2);
|
|
862
|
+
g(this, "mode", "overlay");
|
|
863
|
+
g(this, "canvasSize", "viewport");
|
|
864
|
+
g(this, "clipArea", 1);
|
|
865
|
+
g(this, "targetLayer", "base");
|
|
866
|
+
g(this, "overscan", 200);
|
|
867
|
+
g(this, "target");
|
|
868
|
+
g(this, "mountContainer");
|
|
869
|
+
g(this, "registry");
|
|
870
|
+
g(this, "targetRect");
|
|
871
|
+
g(this, "travelersByLayer", Array.from(
|
|
872
|
+
{ length: N.MAX_LAYERS },
|
|
873
873
|
() => /* @__PURE__ */ new Set()
|
|
874
874
|
));
|
|
875
|
-
|
|
875
|
+
g(this, "textureManager");
|
|
876
876
|
// private meshMap: Map<HTMLElement, THREE.Mesh> = new Map();
|
|
877
|
-
|
|
878
|
-
var a,
|
|
879
|
-
this.target = e, this.mountContainer =
|
|
880
|
-
const
|
|
881
|
-
|
|
877
|
+
g(this, "fixedMeshes", /* @__PURE__ */ new Set());
|
|
878
|
+
var a, l, n, u, h;
|
|
879
|
+
this.target = e, this.mountContainer = r, this.registry = s, this.mode = (a = t.mode) != null ? a : "overlay", this.canvasSize = (l = t.canvasSize) != null ? l : "viewport", this.clipArea = (n = t.travelerClipArea) != null ? n : 1, this.targetLayer = (u = t.layer) != null ? u : "base", this.textureManager = new st((d, p) => {
|
|
880
|
+
const f = this.registry.get(d);
|
|
881
|
+
f && f.material instanceof w.ShaderMaterial && W.forceUpdateUniforms(f.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, o = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
|
|
884
884
|
this.camera = new w.OrthographicCamera(
|
|
@@ -900,15 +900,15 @@ class it {
|
|
|
900
900
|
return this.mode === "overlay" && this.canvasSize === "viewport";
|
|
901
901
|
}
|
|
902
902
|
getSceneLayer() {
|
|
903
|
-
return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ?
|
|
903
|
+
return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ? F.SELECTED : F.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, r = 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
|
+
r * this.qualityFactor,
|
|
912
912
|
{
|
|
913
913
|
minFilter: w.LinearFilter,
|
|
914
914
|
magFilter: w.LinearFilter,
|
|
@@ -948,13 +948,13 @@ class it {
|
|
|
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
|
-
|
|
951
|
+
const r = this.registry.get(e);
|
|
952
|
+
r && (r.traverse((s) => {
|
|
953
953
|
s.isMesh && s.material && W.forceUpdateUniforms(
|
|
954
954
|
s.material,
|
|
955
955
|
t
|
|
956
956
|
);
|
|
957
|
-
}),
|
|
957
|
+
}), r.userData.nativeMesh && r.userData.nativeMesh.traverse((s) => {
|
|
958
958
|
s.isMesh && s.material && W.forceUpdateUniforms(
|
|
959
959
|
s.material,
|
|
960
960
|
t
|
|
@@ -966,23 +966,23 @@ class it {
|
|
|
966
966
|
}
|
|
967
967
|
setSize(e, t) {
|
|
968
968
|
this.renderer.setSize(e, t);
|
|
969
|
-
for (const
|
|
970
|
-
|
|
969
|
+
for (const r of this.renderTargets)
|
|
970
|
+
r.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 r = this.target.getBoundingClientRect(), s = this.isViewport ? window.innerWidth + this.overscan * 2 : r.width, c = this.isViewport ? window.innerHeight + this.overscan * 2 : r.height, o = this.isViewport ? this.canvas.clientWidth : this.targetRect.width, a = this.isViewport ? this.canvas.clientHeight : this.targetRect.height, l = Math.abs(s - o) > 0.1 || Math.abs(c - a) > 0.1, n = this.mode === "overlay" && (Math.abs(r.top - this.targetRect.top) > 0.1 || Math.abs(r.left - this.targetRect.left) > 0.1);
|
|
975
|
+
l ? (this.targetRect = r, this.setSize(s, c), this.updateCanvasLayout()) : n ? (this.targetRect = r, this.updateCanvasLayout()) : this.targetRect = r, this.renderOrder = 0, this.reconcileNode(e), t.size > 0 && t.forEach((u) => {
|
|
976
|
+
const h = this.registry.get(u);
|
|
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(u), this.textureManager.unregister(u);
|
|
986
986
|
}
|
|
987
987
|
});
|
|
988
988
|
}
|
|
@@ -993,9 +993,9 @@ class it {
|
|
|
993
993
|
reconcileNode(e) {
|
|
994
994
|
var s, c;
|
|
995
995
|
let t = this.registry.get(e.element);
|
|
996
|
-
const
|
|
997
|
-
if (t && t.userData.shaderHash !==
|
|
998
|
-
const o = new w.PlaneGeometry(1, 1), a = e.isTraveler ? (s = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : s.texture : this.textureManager.get(e.element),
|
|
996
|
+
const r = JSON.stringify(e.shaderHooks || null);
|
|
997
|
+
if (t && t.userData.shaderHash !== r && (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 o = new w.PlaneGeometry(1, 1), a = e.isTraveler ? (s = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : s.texture : this.textureManager.get(e.element), l = W.create(
|
|
999
999
|
"BOX",
|
|
1000
1000
|
e.styles,
|
|
1001
1001
|
"",
|
|
@@ -1005,10 +1005,10 @@ class it {
|
|
|
1005
1005
|
a,
|
|
1006
1006
|
e.shaderHooks
|
|
1007
1007
|
);
|
|
1008
|
-
t = new w.Mesh(o,
|
|
1008
|
+
t = new w.Mesh(o, 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 = r;
|
|
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 o = 0; o <
|
|
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 o = 0; o < N.MAX_LAYERS; o++)
|
|
1012
1012
|
o === e.captureLayer - 2 ? this.travelersByLayer[o].add(t) : this.travelersByLayer[o].delete(t);
|
|
1013
1013
|
else
|
|
1014
1014
|
for (const o of this.travelersByLayer)
|
|
@@ -1023,371 +1023,407 @@ class it {
|
|
|
1023
1023
|
!0
|
|
1024
1024
|
));
|
|
1025
1025
|
}
|
|
1026
|
-
reconcileTextChild(e, t,
|
|
1027
|
-
var
|
|
1026
|
+
reconcileTextChild(e, t, r) {
|
|
1027
|
+
var n;
|
|
1028
1028
|
const s = t.textLines || [
|
|
1029
1029
|
{ text: t.textContent || "", rect: t.rect }
|
|
1030
|
-
], c =
|
|
1031
|
-
if (t.dirtyMask &
|
|
1030
|
+
], c = r ? t.nativeStyles : t.textStyles, o = JSON.stringify(c) + t.textContent + s.map((u) => u.text).join("|"), a = (n = e.userData) == null ? void 0 : n.textChildStyleHash;
|
|
1031
|
+
if (t.dirtyMask & ye || o !== a) {
|
|
1032
1032
|
e.children.filter(
|
|
1033
|
-
(
|
|
1034
|
-
).forEach((
|
|
1035
|
-
var
|
|
1036
|
-
const
|
|
1037
|
-
(
|
|
1033
|
+
(f) => f.name.startsWith("TEXT_CHILD")
|
|
1034
|
+
).forEach((f) => {
|
|
1035
|
+
var m;
|
|
1036
|
+
const L = f;
|
|
1037
|
+
(m = L.material.map) == null || m.dispose(), L.geometry.dispose(), e.remove(L);
|
|
1038
1038
|
});
|
|
1039
|
-
const h = t.rect,
|
|
1040
|
-
s.forEach((
|
|
1041
|
-
const
|
|
1039
|
+
const h = t.rect, d = h.x + h.width / 2, p = h.y + h.height / 2;
|
|
1040
|
+
s.forEach((f, L) => {
|
|
1041
|
+
const m = W.create(
|
|
1042
1042
|
"TEXT",
|
|
1043
1043
|
c,
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1044
|
+
f.text,
|
|
1045
|
+
f.rect.width,
|
|
1046
|
+
f.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
|
+
), b = new w.PlaneGeometry(1, 1), E = new w.Mesh(b, m);
|
|
1049
|
+
E.name = `TEXT_CHILD_${L}`;
|
|
1050
|
+
const A = t.rect.width === 0 ? 1 : f.rect.width / t.rect.width, C = t.rect.height === 0 ? 1 : f.rect.height / t.rect.height;
|
|
1051
|
+
E.scale.set(A, C, 1);
|
|
1052
|
+
const y = f.rect.x + f.rect.width / 2, S = f.rect.y + f.rect.height / 2, X = y - d, z = -(S - p);
|
|
1053
|
+
E.position.set(
|
|
1054
|
+
t.rect.width === 0 ? 0 : X / t.rect.width,
|
|
1055
|
+
t.rect.height === 0 ? 0 : z / t.rect.height,
|
|
1056
1056
|
5e-3
|
|
1057
|
-
), e.add(
|
|
1057
|
+
), e.add(E);
|
|
1058
1058
|
}), e.userData.textChildStyleHash = o;
|
|
1059
1059
|
}
|
|
1060
|
-
e.children.forEach((
|
|
1061
|
-
if (!
|
|
1060
|
+
e.children.forEach((u) => {
|
|
1061
|
+
if (!u.name.startsWith("TEXT_CHILD"))
|
|
1062
1062
|
return;
|
|
1063
|
-
const h =
|
|
1064
|
-
if (
|
|
1065
|
-
h.layers.set(
|
|
1063
|
+
const h = u;
|
|
1064
|
+
if (r && t.nativeLayer !== void 0)
|
|
1065
|
+
h.layers.set(F.HIDDEN), t.visibility & G && h.layers.enable(F.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 ? F.BASE : F.HIDDEN;
|
|
1068
|
+
if (h.layers.set(d), t.visibility & ae && h.layers.enable(F.SELECTED), t.visibility & G)
|
|
1069
|
+
if (!r && 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(F.getCaptureLayer(p));
|
|
1072
1072
|
else
|
|
1073
|
-
for (let
|
|
1074
|
-
h.layers.enable(
|
|
1073
|
+
for (let p = t.captureLayer; p <= N.MAX_LAYERS + 1; p++)
|
|
1074
|
+
h.layers.enable(F.getCaptureLayer(p));
|
|
1075
1075
|
}
|
|
1076
1076
|
});
|
|
1077
1077
|
}
|
|
1078
1078
|
updateMeshProperties(e, t) {
|
|
1079
|
-
var
|
|
1080
|
-
const { rect:
|
|
1079
|
+
var C, y, S, X, z;
|
|
1080
|
+
const { rect: r, styles: s } = t, c = this.renderer.getPixelRatio(), o = 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(r.width + l * 2, r.height + l * 2, 1), e.userData.domRect = {
|
|
1084
|
+
x: r.x,
|
|
1085
|
+
y: r.y,
|
|
1086
|
+
width: r.width,
|
|
1087
|
+
height: r.height
|
|
1088
1088
|
};
|
|
1089
|
-
const
|
|
1089
|
+
const n = 1e-3;
|
|
1090
1090
|
this.renderOrder++;
|
|
1091
|
-
const
|
|
1092
|
-
let
|
|
1091
|
+
const u = this.targetRect.left + window.scrollX, h = this.targetRect.top + window.scrollY;
|
|
1092
|
+
let d, p;
|
|
1093
1093
|
if (this.isViewport)
|
|
1094
|
-
|
|
1094
|
+
d = r.x - window.innerWidth / 2 + r.width / 2, p = -r.y + window.innerHeight / 2 - r.height / 2;
|
|
1095
1095
|
else {
|
|
1096
|
-
const
|
|
1097
|
-
|
|
1096
|
+
const U = r.x - u, I = r.y - h;
|
|
1097
|
+
d = U - o / 2 + r.width / 2, p = -I + a / 2 - r.height / 2;
|
|
1098
1098
|
}
|
|
1099
1099
|
e.position.set(
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
s.zIndex + this.renderOrder *
|
|
1100
|
+
d,
|
|
1101
|
+
p,
|
|
1102
|
+
s.zIndex + this.renderOrder * n
|
|
1103
1103
|
);
|
|
1104
|
-
const
|
|
1105
|
-
e.userData.basePosition = { x:
|
|
1106
|
-
const
|
|
1107
|
-
let
|
|
1108
|
-
if (
|
|
1109
|
-
const
|
|
1110
|
-
|
|
1104
|
+
const f = r.x, L = r.y;
|
|
1105
|
+
e.userData.basePosition = { x: d, y: p }, e.userData.originalBasePosition = { x: d, y: p }, e.userData.baseSize = { width: r.width, height: r.height }, e.userData.baseDOM = { x: f, y: L }, 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, b = window.getComputedStyle(m);
|
|
1107
|
+
let E = 0, A = 0;
|
|
1108
|
+
if (b.transform && b.transform !== "none") {
|
|
1109
|
+
const U = new DOMMatrix(b.transform);
|
|
1110
|
+
E = U.m41, A = U.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
|
s,
|
|
1116
1116
|
"",
|
|
1117
|
-
|
|
1118
|
-
|
|
1117
|
+
r.width,
|
|
1118
|
+
r.height,
|
|
1119
1119
|
this.qualityFactor,
|
|
1120
|
-
t.isTraveler ? (
|
|
1120
|
+
t.isTraveler ? (y = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : y.texture : this.textureManager.get(t.element)
|
|
1121
1121
|
), t.nativeStyles && t.nativeRect) {
|
|
1122
1122
|
if (!e.userData.nativeMesh) {
|
|
1123
|
-
const
|
|
1123
|
+
const B = 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, B);
|
|
1133
|
+
t.type === "TEXT" && (V.name = "BG_MESH"), this.scene.add(V), e.userData.nativeMesh = V;
|
|
1134
1134
|
}
|
|
1135
|
-
const
|
|
1136
|
-
let
|
|
1135
|
+
const U = e.userData.nativeMesh;
|
|
1136
|
+
let I, j;
|
|
1137
1137
|
if (this.isViewport)
|
|
1138
|
-
|
|
1138
|
+
I = 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 B = t.nativeRect.x - u, V = t.nativeRect.y - h;
|
|
1141
|
+
I = B - o / 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, M = I, O = j;
|
|
1144
1144
|
if (t.nativeStyles.transform) {
|
|
1145
|
-
const
|
|
1146
|
-
if (
|
|
1147
|
-
let
|
|
1148
|
-
|
|
1145
|
+
const B = t.nativeStyles.transform, V = B.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 = B.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 = B.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
|
|
1164
|
-
|
|
1165
|
-
let
|
|
1166
|
-
|
|
1160
|
+
const oe = B.match(/translate\(([^,]+),\s*([^)]+)\)/);
|
|
1161
|
+
if (oe) {
|
|
1162
|
+
const x = oe[1].trim(), T = oe[2].trim();
|
|
1163
|
+
let _ = parseFloat(x);
|
|
1164
|
+
x.includes("%") && (_ = _ / 100 * t.nativeRect.width);
|
|
1165
|
+
let D = parseFloat(T);
|
|
1166
|
+
T.includes("%") && (D = D / 100 * t.nativeRect.height), M += _, O -= D;
|
|
1167
1167
|
}
|
|
1168
|
-
const
|
|
1169
|
-
if (
|
|
1170
|
-
const
|
|
1171
|
-
let
|
|
1172
|
-
|
|
1168
|
+
const he = B.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), M += T;
|
|
1173
1173
|
}
|
|
1174
|
-
const
|
|
1175
|
-
if (
|
|
1176
|
-
const
|
|
1177
|
-
let
|
|
1178
|
-
|
|
1174
|
+
const v = B.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), O -= T;
|
|
1179
1179
|
}
|
|
1180
1180
|
}
|
|
1181
|
-
let K = ((
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
t.nativeStyles.zIndex + this.renderOrder *
|
|
1181
|
+
let K = ((X = U.material.userData) == null ? void 0 : X.shadowPadding) || 0;
|
|
1182
|
+
U.scale.set(J + K * 2, Z + K * 2, 1), U.position.set(
|
|
1183
|
+
M,
|
|
1184
|
+
O,
|
|
1185
|
+
t.nativeStyles.zIndex + this.renderOrder * n
|
|
1186
1186
|
), W.update(
|
|
1187
|
-
|
|
1187
|
+
U.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 ? (z = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : z.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(
|
|
1200
|
+
const r = t.visibility & G ? F.BASE : F.HIDDEN;
|
|
1201
|
+
if (e.layers.set(r), t.visibility & ae && e.layers.enable(F.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
|
|
1202
1202
|
const s = e.userData.nativeMesh;
|
|
1203
|
-
if (s.layers.set(
|
|
1204
|
-
s.layers.enable(
|
|
1205
|
-
for (let c = t.captureLayer; c <=
|
|
1206
|
-
c !== t.nativeLayer && e.layers.enable(
|
|
1203
|
+
if (s.layers.set(F.HIDDEN), t.visibility & G) {
|
|
1204
|
+
s.layers.enable(F.getCaptureLayer(t.nativeLayer));
|
|
1205
|
+
for (let c = t.captureLayer; c <= N.MAX_LAYERS + 1; c++)
|
|
1206
|
+
c !== t.nativeLayer && e.layers.enable(F.getCaptureLayer(c));
|
|
1207
1207
|
}
|
|
1208
|
-
} else if (t.visibility &
|
|
1209
|
-
for (let s = t.captureLayer; s <=
|
|
1210
|
-
e.layers.enable(
|
|
1208
|
+
} else if (t.visibility & G)
|
|
1209
|
+
for (let s = t.captureLayer; s <= N.MAX_LAYERS + 1; s++)
|
|
1210
|
+
e.layers.enable(F.getCaptureLayer(s));
|
|
1211
1211
|
}
|
|
1212
|
-
captureRenderTarget(e, t,
|
|
1213
|
-
if (e.size === 0 || !
|
|
1212
|
+
captureRenderTarget(e, t, r) {
|
|
1213
|
+
if (e.size === 0 || !r)
|
|
1214
1214
|
return;
|
|
1215
1215
|
const s = new w.Color(), c = this.renderer.getClearAlpha();
|
|
1216
|
-
this.renderer.getClearColor(s), this.renderer.setClearColor(0, 0), this.renderer.setRenderTarget(
|
|
1217
|
-
const o = new w.Vector3(), a = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width,
|
|
1218
|
-
for (const
|
|
1219
|
-
o.setFromMatrixPosition(
|
|
1220
|
-
const h = (o.x + 1) / 2 * a,
|
|
1221
|
-
let
|
|
1222
|
-
typeof this.clipArea == "number" ?
|
|
1223
|
-
const
|
|
1224
|
-
this.renderer.setScissor(
|
|
1216
|
+
this.renderer.getClearColor(s), 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);
|
|
1217
|
+
const o = 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, n = this.renderer.getPixelRatio();
|
|
1218
|
+
for (const u of e) {
|
|
1219
|
+
o.setFromMatrixPosition(u.matrixWorld), o.project(this.camera);
|
|
1220
|
+
const h = (o.x + 1) / 2 * a, d = (o.y + 1) / 2 * l;
|
|
1221
|
+
let p = 0, f = 1;
|
|
1222
|
+
typeof this.clipArea == "number" ? f = this.clipArea : this.clipArea.endsWith("%") ? f = parseFloat(this.clipArea) / 100 : this.clipArea.endsWith("px") && (p = parseFloat(this.clipArea));
|
|
1223
|
+
const L = u.scale.x * f + 0.5, m = u.scale.y * f + 0.5, b = h - L / 2, E = d - m / 2, A = (b * this.qualityFactor - p) / n, C = (E * this.qualityFactor - p) / n, y = (L * this.qualityFactor + p * 2) / n, S = (m * this.qualityFactor + p * 2) / n;
|
|
1224
|
+
this.renderer.setScissor(A, C, y, S), this.renderer.render(this.scene, this.camera);
|
|
1225
1225
|
}
|
|
1226
1226
|
this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(s, c);
|
|
1227
1227
|
}
|
|
1228
1228
|
render() {
|
|
1229
|
-
for (let
|
|
1230
|
-
const
|
|
1229
|
+
for (let l = 0; l < N.MAX_LAYERS; l++) {
|
|
1230
|
+
const n = l + 1;
|
|
1231
1231
|
this.captureRenderTarget(
|
|
1232
|
-
this.travelersByLayer[
|
|
1233
|
-
|
|
1234
|
-
this.renderTargets[
|
|
1232
|
+
this.travelersByLayer[l],
|
|
1233
|
+
F.getCaptureLayer(n),
|
|
1234
|
+
this.renderTargets[l]
|
|
1235
1235
|
);
|
|
1236
1236
|
}
|
|
1237
|
-
this.renderer.
|
|
1237
|
+
const e = this.renderer.getContext(), t = this.renderer.getPixelRatio(), r = this.renderer.domElement.height / t, s = this.renderer.domElement, c = s.getBoundingClientRect().top, o = s.getBoundingClientRect().left, a = (l, n) => {
|
|
1238
|
+
if (n && n.width > 0 && n.height > 0) {
|
|
1239
|
+
const u = Math.floor((n.x - o) * t), h = Math.floor(
|
|
1240
|
+
(r - (n.y - c + n.height)) * t
|
|
1241
|
+
), d = Math.ceil(n.width * t), p = Math.ceil(n.height * t);
|
|
1242
|
+
l.onBeforeRender = () => {
|
|
1243
|
+
e.enable(e.SCISSOR_TEST), e.scissor(u, 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 n = l, u = (h = n.userData) == null ? void 0 : h.scissorRect;
|
|
1255
|
+
a(n, u), n.children.forEach((d) => {
|
|
1256
|
+
d.name.startsWith("TEXT_CHILD") && a(d, u);
|
|
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, r = this.renderer.getPixelRatio(), s = this.renderer.domElement.width / r, c = this.renderer.domElement.height / r;
|
|
1241
1262
|
this.scene.children.forEach((o) => {
|
|
1242
|
-
var h,
|
|
1263
|
+
var h, d;
|
|
1243
1264
|
const a = o;
|
|
1244
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 n;
|
|
1271
|
+
if (l.nodeType === Node.TEXT_NODE) {
|
|
1272
|
+
const p = document.createRange();
|
|
1273
|
+
p.selectNode(l), n = p.getBoundingClientRect();
|
|
1253
1274
|
} else
|
|
1254
|
-
|
|
1255
|
-
const
|
|
1256
|
-
if (!
|
|
1275
|
+
n = l.getBoundingClientRect();
|
|
1276
|
+
const u = a.userData.domRect;
|
|
1277
|
+
if (!u || Math.abs(n.x - u.x) > 0.5 || Math.abs(n.y - u.y) > 0.5 || Math.abs(n.width - u.width) > 0.5 || Math.abs(n.height - u.height) > 0.5) {
|
|
1257
1278
|
a.userData.domRect = {
|
|
1258
|
-
x:
|
|
1259
|
-
y:
|
|
1260
|
-
width:
|
|
1261
|
-
height:
|
|
1279
|
+
x: n.x,
|
|
1280
|
+
y: n.y,
|
|
1281
|
+
width: n.width,
|
|
1282
|
+
height: n.height
|
|
1262
1283
|
};
|
|
1263
|
-
|
|
1284
|
+
const p = a.userData.clipElements;
|
|
1285
|
+
if (p && p.length > 0) {
|
|
1286
|
+
let b = -1 / 0, E = -1 / 0, A = 1 / 0, C = 1 / 0;
|
|
1287
|
+
for (const y of p) {
|
|
1288
|
+
const S = y.getBoundingClientRect();
|
|
1289
|
+
b = Math.max(b, 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: b,
|
|
1293
|
+
y: E,
|
|
1294
|
+
width: Math.max(0, A - b),
|
|
1295
|
+
height: Math.max(0, C - E)
|
|
1296
|
+
};
|
|
1297
|
+
} else
|
|
1298
|
+
a.userData.scissorRect = void 0;
|
|
1299
|
+
let f, L;
|
|
1264
1300
|
if (this.isViewport)
|
|
1265
|
-
f =
|
|
1301
|
+
f = n.x - window.innerWidth / 2 + n.width / 2, L = -n.y + window.innerHeight / 2 - n.height / 2;
|
|
1266
1302
|
else {
|
|
1267
|
-
const b =
|
|
1268
|
-
f = b - s / 2 +
|
|
1303
|
+
const b = n.x - e, E = n.y - t;
|
|
1304
|
+
f = b - s / 2 + n.width / 2, L = -E + c / 2 - n.height / 2;
|
|
1269
1305
|
}
|
|
1270
|
-
a.position.setX(f), a.position.setY(
|
|
1271
|
-
let
|
|
1272
|
-
if (a.scale.set(
|
|
1273
|
-
width:
|
|
1274
|
-
height:
|
|
1306
|
+
a.position.setX(f), a.position.setY(L);
|
|
1307
|
+
let m = ((h = a.material.userData) == null ? void 0 : h.shadowPadding) || 0;
|
|
1308
|
+
if (a.scale.set(n.width + m * 2, n.height + m * 2, 1), a.updateMatrixWorld(), a.material instanceof w.ShaderMaterial && W.forceUpdateUniforms(a.material, {
|
|
1309
|
+
width: n.width,
|
|
1310
|
+
height: n.height
|
|
1275
1311
|
}), a.userData.nativeMesh) {
|
|
1276
1312
|
const b = a.userData.nativeMesh;
|
|
1277
|
-
let
|
|
1313
|
+
let E = n.width, A = n.height, C = f, y = L;
|
|
1278
1314
|
if (a.userData.nativeTransform) {
|
|
1279
|
-
const
|
|
1280
|
-
if (
|
|
1281
|
-
let
|
|
1282
|
-
|
|
1315
|
+
const X = a.userData.nativeTransform, z = X.match(/scale\(([\d.]+%?)\)/);
|
|
1316
|
+
if (z) {
|
|
1317
|
+
let M = parseFloat(z[1]);
|
|
1318
|
+
z[1].includes("%") && (M /= 100), E *= M, A *= M;
|
|
1283
1319
|
}
|
|
1284
|
-
const
|
|
1285
|
-
if (
|
|
1286
|
-
let
|
|
1287
|
-
|
|
1320
|
+
const U = X.match(/scaleX\(([\d.]+%?)\)/);
|
|
1321
|
+
if (U) {
|
|
1322
|
+
let M = parseFloat(U[1]);
|
|
1323
|
+
U[1].includes("%") && (M /= 100), E *= M;
|
|
1288
1324
|
}
|
|
1289
|
-
const
|
|
1290
|
-
if (
|
|
1291
|
-
let
|
|
1292
|
-
|
|
1325
|
+
const I = X.match(/scaleY\(([\d.]+%?)\)/);
|
|
1326
|
+
if (I) {
|
|
1327
|
+
let M = parseFloat(I[1]);
|
|
1328
|
+
I[1].includes("%") && (M /= 100), A *= M;
|
|
1293
1329
|
}
|
|
1294
|
-
const
|
|
1295
|
-
if (
|
|
1296
|
-
const
|
|
1297
|
-
let
|
|
1298
|
-
|
|
1299
|
-
let
|
|
1300
|
-
|
|
1330
|
+
const j = X.match(/translate\(([^,]+),\s*([^)]+)\)/);
|
|
1331
|
+
if (j) {
|
|
1332
|
+
const M = j[1].trim(), O = j[2].trim();
|
|
1333
|
+
let K = parseFloat(M);
|
|
1334
|
+
M.includes("%") && (K = K / 100 * n.width);
|
|
1335
|
+
let B = parseFloat(O);
|
|
1336
|
+
O.includes("%") && (B = B / 100 * n.height), C += K, y -= B;
|
|
1301
1337
|
}
|
|
1302
|
-
const J =
|
|
1338
|
+
const J = X.match(/translateX\(([^)]+)\)/);
|
|
1303
1339
|
if (J) {
|
|
1304
|
-
const
|
|
1305
|
-
let
|
|
1306
|
-
|
|
1340
|
+
const M = J[1].trim();
|
|
1341
|
+
let O = parseFloat(M);
|
|
1342
|
+
M.includes("%") && (O = O / 100 * n.width), C += O;
|
|
1307
1343
|
}
|
|
1308
|
-
const Z =
|
|
1344
|
+
const Z = X.match(/translateY\(([^)]+)\)/);
|
|
1309
1345
|
if (Z) {
|
|
1310
|
-
const
|
|
1311
|
-
let
|
|
1312
|
-
|
|
1346
|
+
const M = Z[1].trim();
|
|
1347
|
+
let O = parseFloat(M);
|
|
1348
|
+
M.includes("%") && (O = O / 100 * n.height), y -= O;
|
|
1313
1349
|
}
|
|
1314
1350
|
}
|
|
1315
|
-
let
|
|
1316
|
-
b.position.setX(
|
|
1317
|
-
width:
|
|
1318
|
-
height:
|
|
1351
|
+
let S = ((d = b.material.userData) == null ? void 0 : d.shadowPadding) || 0;
|
|
1352
|
+
b.position.setX(C), b.position.setY(y), b.scale.set(E + S * 2, A + S * 2, 1), b.updateMatrixWorld(), b.material instanceof w.ShaderMaterial && W.forceUpdateUniforms(b.material, {
|
|
1353
|
+
width: E,
|
|
1354
|
+
height: A
|
|
1319
1355
|
});
|
|
1320
1356
|
}
|
|
1321
1357
|
}
|
|
1322
1358
|
});
|
|
1323
1359
|
}
|
|
1324
1360
|
}
|
|
1325
|
-
function
|
|
1326
|
-
const e =
|
|
1327
|
-
let
|
|
1328
|
-
const o = (
|
|
1329
|
-
for (let h = 0; h <
|
|
1330
|
-
const
|
|
1331
|
-
|
|
1332
|
-
const
|
|
1333
|
-
if (
|
|
1334
|
-
|
|
1361
|
+
function nt(i) {
|
|
1362
|
+
const e = i.textContent || "", t = [];
|
|
1363
|
+
let r = "", s = null, c = -1;
|
|
1364
|
+
const o = (n, u) => {
|
|
1365
|
+
for (let h = 0; h < n.length; h++) {
|
|
1366
|
+
const d = n[h], p = document.createRange();
|
|
1367
|
+
p.setStart(i, u + h), p.setEnd(i, u + h + 1);
|
|
1368
|
+
const f = p.getBoundingClientRect();
|
|
1369
|
+
if (f.width === 0 && f.height === 0) {
|
|
1370
|
+
r += d;
|
|
1335
1371
|
continue;
|
|
1336
1372
|
}
|
|
1337
|
-
c === -1 || Math.abs(
|
|
1338
|
-
text:
|
|
1373
|
+
c === -1 || Math.abs(f.top - c) > f.height / 2 ? (r && s && t.push({
|
|
1374
|
+
text: r,
|
|
1339
1375
|
rect: {
|
|
1340
1376
|
left: s.left,
|
|
1341
1377
|
top: s.top,
|
|
1342
1378
|
width: s.right - s.left,
|
|
1343
1379
|
height: s.bottom - s.top
|
|
1344
1380
|
}
|
|
1345
|
-
}),
|
|
1346
|
-
left:
|
|
1347
|
-
top:
|
|
1348
|
-
right:
|
|
1349
|
-
bottom:
|
|
1350
|
-
}, c =
|
|
1381
|
+
}), r = d, s = {
|
|
1382
|
+
left: f.left,
|
|
1383
|
+
top: f.top,
|
|
1384
|
+
right: f.right,
|
|
1385
|
+
bottom: f.bottom
|
|
1386
|
+
}, c = f.top) : (r += d, s && (s.left = Math.min(s.left, f.left), s.top = Math.min(s.top, f.top), s.right = Math.max(s.right, f.right), s.bottom = Math.max(
|
|
1351
1387
|
s.bottom,
|
|
1352
|
-
|
|
1388
|
+
f.bottom
|
|
1353
1389
|
)));
|
|
1354
1390
|
}
|
|
1355
1391
|
}, a = e.match(/[^\s\-]+\-?|\-|\s+/g) || [];
|
|
1356
|
-
let
|
|
1357
|
-
for (const
|
|
1358
|
-
const
|
|
1359
|
-
|
|
1360
|
-
const h =
|
|
1392
|
+
let l = 0;
|
|
1393
|
+
for (const n of a) {
|
|
1394
|
+
const u = document.createRange();
|
|
1395
|
+
u.setStart(i, l), u.setEnd(i, l + n.length);
|
|
1396
|
+
const h = u.getClientRects();
|
|
1361
1397
|
if (h.length > 1)
|
|
1362
|
-
o(
|
|
1398
|
+
o(n, l);
|
|
1363
1399
|
else {
|
|
1364
|
-
const
|
|
1365
|
-
if (
|
|
1366
|
-
|
|
1400
|
+
const d = h.length === 1 ? h[0] : u.getBoundingClientRect();
|
|
1401
|
+
if (d.width === 0 && d.height === 0) {
|
|
1402
|
+
r += n, l += n.length;
|
|
1367
1403
|
continue;
|
|
1368
1404
|
}
|
|
1369
|
-
c === -1 || Math.abs(
|
|
1370
|
-
text:
|
|
1405
|
+
c === -1 || Math.abs(d.top - c) > d.height / 2 ? (r && s && t.push({
|
|
1406
|
+
text: r,
|
|
1371
1407
|
rect: {
|
|
1372
1408
|
left: s.left,
|
|
1373
1409
|
top: s.top,
|
|
1374
1410
|
width: s.right - s.left,
|
|
1375
1411
|
height: s.bottom - s.top
|
|
1376
1412
|
}
|
|
1377
|
-
}),
|
|
1378
|
-
left:
|
|
1379
|
-
top:
|
|
1380
|
-
right:
|
|
1381
|
-
bottom:
|
|
1382
|
-
}, c =
|
|
1413
|
+
}), r = n, s = {
|
|
1414
|
+
left: d.left,
|
|
1415
|
+
top: d.top,
|
|
1416
|
+
right: d.right,
|
|
1417
|
+
bottom: d.bottom
|
|
1418
|
+
}, c = d.top) : (r += n, s && (s.left = Math.min(s.left, d.left), s.top = Math.min(s.top, d.top), s.right = Math.max(s.right, d.right), s.bottom = Math.max(
|
|
1383
1419
|
s.bottom,
|
|
1384
|
-
|
|
1420
|
+
d.bottom
|
|
1385
1421
|
)));
|
|
1386
1422
|
}
|
|
1387
|
-
|
|
1423
|
+
l += n.length;
|
|
1388
1424
|
}
|
|
1389
|
-
return
|
|
1390
|
-
text:
|
|
1425
|
+
return r && s && t.push({
|
|
1426
|
+
text: r,
|
|
1391
1427
|
rect: {
|
|
1392
1428
|
left: s.left,
|
|
1393
1429
|
top: s.top,
|
|
@@ -1395,297 +1431,300 @@ function st(r) {
|
|
|
1395
1431
|
height: s.bottom - s.top
|
|
1396
1432
|
}
|
|
1397
1433
|
}), t.filter(
|
|
1398
|
-
(
|
|
1434
|
+
(n) => n.text.trim().length > 0 && n.rect.width > 0 && n.rect.height > 0
|
|
1399
1435
|
);
|
|
1400
1436
|
}
|
|
1401
|
-
function
|
|
1402
|
-
const e = parseFloat(
|
|
1403
|
-
let t = parseFloat(
|
|
1437
|
+
function Ae(i) {
|
|
1438
|
+
const e = parseFloat(i.fontSize);
|
|
1439
|
+
let t = parseFloat(i.lineHeight);
|
|
1404
1440
|
isNaN(t) && (t = e * 1.2);
|
|
1405
|
-
let
|
|
1406
|
-
return isNaN(
|
|
1407
|
-
font: `${
|
|
1408
|
-
fontSize:
|
|
1409
|
-
color:
|
|
1410
|
-
textAlign:
|
|
1441
|
+
let r = parseFloat(i.letterSpacing);
|
|
1442
|
+
return isNaN(r) && (r = 0), {
|
|
1443
|
+
font: `${i.fontStyle} ${i.fontWeight} ${i.fontSize} ${i.fontFamily}`,
|
|
1444
|
+
fontSize: i.fontSize,
|
|
1445
|
+
color: i.color,
|
|
1446
|
+
textAlign: i.textAlign || "start",
|
|
1411
1447
|
textBaseline: "alphabetic",
|
|
1412
|
-
direction:
|
|
1448
|
+
direction: i.direction || "inherit",
|
|
1413
1449
|
lineHeight: t,
|
|
1414
|
-
letterSpacing:
|
|
1450
|
+
letterSpacing: r
|
|
1415
1451
|
};
|
|
1416
1452
|
}
|
|
1417
|
-
function
|
|
1418
|
-
var
|
|
1419
|
-
if (
|
|
1420
|
-
const
|
|
1421
|
-
if (!
|
|
1453
|
+
function Fe(i, e = re | ue | Pe | ye | pe, t, r = 1, s = 0, c = 2, o, a, l) {
|
|
1454
|
+
var K, B, V, ie, se, oe, he;
|
|
1455
|
+
if (i.nodeType === Node.TEXT_NODE) {
|
|
1456
|
+
const v = i;
|
|
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 = nt(v);
|
|
1463
|
+
if (T.length === 0)
|
|
1428
1464
|
return null;
|
|
1429
|
-
const
|
|
1430
|
-
if (!
|
|
1465
|
+
const _ = v.parentElement, D = _ ? window.getComputedStyle(_) : null;
|
|
1466
|
+
if (!D)
|
|
1431
1467
|
return null;
|
|
1432
|
-
const
|
|
1468
|
+
const q = 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)), k = 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: k -
|
|
1474
|
+
x: q + window.scrollX,
|
|
1475
|
+
y: Y + window.scrollY,
|
|
1476
|
+
width: Q - q,
|
|
1477
|
+
height: k - Y
|
|
1442
1478
|
},
|
|
1443
1479
|
styles: {
|
|
1444
1480
|
backgroundColor: "transparent",
|
|
1445
1481
|
backgroundImage: "",
|
|
1446
|
-
opacity:
|
|
1447
|
-
zIndex: (isNaN(parseInt(
|
|
1482
|
+
opacity: _ && _.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(D.opacity),
|
|
1483
|
+
zIndex: (isNaN(parseInt(D.zIndex)) ? 0 : parseInt(D.zIndex)) + s,
|
|
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: Ae(D),
|
|
1464
1500
|
dirtyMask: e,
|
|
1465
1501
|
visibility: t,
|
|
1466
1502
|
isTraveler: !1,
|
|
1467
|
-
captureLayer:
|
|
1468
|
-
isFixed:
|
|
1503
|
+
captureLayer: r,
|
|
1504
|
+
isFixed: D.position === "fixed",
|
|
1469
1505
|
nativeLayer: o,
|
|
1470
1506
|
nativeStyles: a ? te(te({
|
|
1471
1507
|
backgroundColor: "transparent",
|
|
1472
1508
|
backgroundImage: "",
|
|
1473
|
-
opacity:
|
|
1474
|
-
zIndex: (isNaN(parseInt(
|
|
1509
|
+
opacity: _ && _.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(D.opacity),
|
|
1510
|
+
zIndex: (isNaN(parseInt(D.zIndex)) ? 0 : parseInt(D.zIndex)) + s,
|
|
1475
1511
|
borderRadius: "0px",
|
|
1476
1512
|
borderColor: "transparent",
|
|
1477
1513
|
borderWidth: "0px",
|
|
1478
1514
|
isTraveler: !1
|
|
1479
|
-
},
|
|
1515
|
+
}, Ae(D)), a) : void 0,
|
|
1480
1516
|
nativeRect: a ? {
|
|
1481
|
-
x:
|
|
1482
|
-
y:
|
|
1483
|
-
width: Q -
|
|
1484
|
-
height: k -
|
|
1517
|
+
x: q + window.scrollX,
|
|
1518
|
+
y: Y + window.scrollY,
|
|
1519
|
+
width: Q - q,
|
|
1520
|
+
height: k - Y
|
|
1485
1521
|
} : void 0,
|
|
1522
|
+
clipElements: l,
|
|
1486
1523
|
children: []
|
|
1487
1524
|
};
|
|
1488
1525
|
}
|
|
1489
|
-
if (
|
|
1526
|
+
if (i.nodeType !== Node.ELEMENT_NODE)
|
|
1490
1527
|
return null;
|
|
1491
|
-
const n =
|
|
1492
|
-
let
|
|
1493
|
-
if (
|
|
1494
|
-
const
|
|
1495
|
-
for (const
|
|
1496
|
-
if (!
|
|
1528
|
+
const n = i, u = n.dataset[H.KEY];
|
|
1529
|
+
let h = t, d = t;
|
|
1530
|
+
if (u) {
|
|
1531
|
+
const v = new Set(u.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(H.VALUES.END))
|
|
1501
1538
|
return null;
|
|
1502
|
-
if (
|
|
1539
|
+
if (v.has(H.VALUES.INCLUDE_TREE) && v.has(H.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(H.VALUES.INCLUDE_SELF) && v.has(H.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(H.VALUES.INCLUDE_TREE) ? h = h | G : v.has(H.VALUES.EXCLUDE_TREE) && (h = h & ~G), d = h, v.has(H.VALUES.INCLUDE_SELF) ? d = d | G : v.has(H.VALUES.EXCLUDE_SELF) && (d = d & ~G);
|
|
1511
1548
|
}
|
|
1512
|
-
const
|
|
1513
|
-
if (
|
|
1514
|
-
const
|
|
1515
|
-
for (const
|
|
1516
|
-
if (!
|
|
1549
|
+
const p = n.dataset[$.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($.VALUES.END))
|
|
1521
1558
|
return null;
|
|
1522
|
-
if (
|
|
1559
|
+
if (v.has($.VALUES.INCLUDE_TREE) && v.has($.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($.VALUES.INCLUDE_SELF) && v.has($.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($.VALUES.INCLUDE_TREE) ? h = h | ae : v.has($.VALUES.EXCLUDE_TREE) && (h = h & ~ae), d = h, v.has($.VALUES.INCLUDE_SELF) ? d = d | ae : v.has($.VALUES.EXCLUDE_SELF) && (d = d & ~ae);
|
|
1531
1568
|
}
|
|
1532
|
-
const f = n.dataset[
|
|
1533
|
-
let
|
|
1569
|
+
const f = n.dataset[N.KEY];
|
|
1570
|
+
let L = !1, m = a ? te({}, a) : {}, b = o;
|
|
1534
1571
|
if (f) {
|
|
1535
|
-
let
|
|
1536
|
-
const
|
|
1537
|
-
let
|
|
1538
|
-
if (
|
|
1539
|
-
|
|
1540
|
-
const k = f.substring(
|
|
1572
|
+
let v = 1;
|
|
1573
|
+
const x = f.indexOf("{"), T = f.lastIndexOf("}");
|
|
1574
|
+
let _ = f;
|
|
1575
|
+
if (x !== -1 && T !== -1 && T > x) {
|
|
1576
|
+
_ = f.substring(0, x).trim();
|
|
1577
|
+
const k = f.substring(x, T + 1);
|
|
1541
1578
|
try {
|
|
1542
|
-
|
|
1543
|
-
} catch (
|
|
1579
|
+
m = new Function("return " + k)();
|
|
1580
|
+
} catch (R) {
|
|
1544
1581
|
console.warn(
|
|
1545
1582
|
`[MirageEngine] Failed to parse travel styles JSON: ${k}`
|
|
1546
1583
|
);
|
|
1547
1584
|
}
|
|
1548
1585
|
}
|
|
1549
|
-
const
|
|
1550
|
-
let
|
|
1551
|
-
const
|
|
1552
|
-
if (
|
|
1553
|
-
|
|
1554
|
-
const k =
|
|
1586
|
+
const D = _.split(/\s+/);
|
|
1587
|
+
let q = !1;
|
|
1588
|
+
const Y = D.indexOf(N.VALUES.TRAVELER);
|
|
1589
|
+
if (Y !== -1) {
|
|
1590
|
+
L = !0, q = !0;
|
|
1591
|
+
const k = D[Y + 1];
|
|
1555
1592
|
if (k && !isNaN(parseInt(k, 10)))
|
|
1556
|
-
|
|
1593
|
+
v = parseInt(k, 10);
|
|
1557
1594
|
else {
|
|
1558
|
-
const
|
|
1559
|
-
|
|
1595
|
+
const R = D.find((ne) => !isNaN(parseInt(ne, 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 k =
|
|
1601
|
+
const k = D[Q + 1];
|
|
1565
1602
|
if (k && !isNaN(parseInt(k, 10)))
|
|
1566
1603
|
b = parseInt(k, 10);
|
|
1567
|
-
else if (!
|
|
1568
|
-
const
|
|
1569
|
-
|
|
1604
|
+
else if (!L) {
|
|
1605
|
+
const R = D.find((ne) => !isNaN(parseInt(ne, 10)));
|
|
1606
|
+
R && (b = parseInt(R, 10));
|
|
1570
1607
|
}
|
|
1571
1608
|
}
|
|
1572
|
-
if (
|
|
1573
|
-
const k =
|
|
1574
|
-
if (k <
|
|
1609
|
+
if (q) {
|
|
1610
|
+
const k = v + 1;
|
|
1611
|
+
if (k < r)
|
|
1575
1612
|
throw new Error(
|
|
1576
|
-
`[MirageEngine] Traveler layer (${
|
|
1613
|
+
`[MirageEngine] Traveler layer (${v}) cannot be smaller than inherited capture layer (${r - 1}).`
|
|
1577
1614
|
);
|
|
1578
|
-
|
|
1615
|
+
r = Math.min(k, N.MAX_LAYERS + 1);
|
|
1579
1616
|
}
|
|
1580
1617
|
}
|
|
1581
|
-
const
|
|
1582
|
-
let
|
|
1583
|
-
|
|
1584
|
-
const
|
|
1585
|
-
if (
|
|
1618
|
+
const E = n.dataset[We.KEY];
|
|
1619
|
+
let A;
|
|
1620
|
+
E && (A = JSON.parse(E));
|
|
1621
|
+
const C = n.getBoundingClientRect(), y = window.getComputedStyle(n);
|
|
1622
|
+
if (C.width === 0 || C.height === 0 || y.display === "none")
|
|
1586
1623
|
return null;
|
|
1587
|
-
let
|
|
1588
|
-
|
|
1589
|
-
const
|
|
1590
|
-
let
|
|
1624
|
+
let S = n.getAttribute("data-mid");
|
|
1625
|
+
S || (S = Math.random().toString(36).substring(2, 11), n.setAttribute("data-mid", S));
|
|
1626
|
+
const X = parseInt(y.zIndex), z = (isNaN(X) ? 0 : X) + s;
|
|
1627
|
+
let U;
|
|
1591
1628
|
if (n.tagName === "IMG")
|
|
1592
|
-
|
|
1629
|
+
U = n.src;
|
|
1593
1630
|
else if (n.tagName.toLowerCase() === "svg") {
|
|
1594
|
-
const
|
|
1595
|
-
const
|
|
1596
|
-
|
|
1597
|
-
const
|
|
1598
|
-
|
|
1599
|
-
const
|
|
1600
|
-
|
|
1601
|
-
const
|
|
1602
|
-
|
|
1603
|
-
for (let
|
|
1604
|
-
|
|
1631
|
+
const v = n.cloneNode(!0), x = m == null ? void 0 : m.color, T = m == null ? void 0 : m.fill, _ = m == null ? void 0 : m.stroke, D = m == null ? void 0 : m.opacity, q = (R, ne) => {
|
|
1632
|
+
const P = window.getComputedStyle(R), de = ne, Oe = P.fill === P.color, _e = P.stroke === P.color, me = T || (Oe ? x : void 0) || P.fill;
|
|
1633
|
+
me && me !== "none" && (de.style.fill = me);
|
|
1634
|
+
const ve = _ || (_e ? x : void 0) || P.stroke;
|
|
1635
|
+
ve && ve !== "none" && (de.style.stroke = ve), P.strokeWidth && P.strokeWidth !== "0px" && (de.style.strokeWidth = P.strokeWidth);
|
|
1636
|
+
const Se = x || P.color;
|
|
1637
|
+
Se && (de.style.color = Se);
|
|
1638
|
+
const we = D || P.opacity;
|
|
1639
|
+
we && we !== "1" && (de.style.opacity = we);
|
|
1640
|
+
for (let fe = 0; fe < R.children.length; fe++)
|
|
1641
|
+
q(R.children[fe], ne.children[fe]);
|
|
1605
1642
|
};
|
|
1606
|
-
|
|
1607
|
-
const
|
|
1608
|
-
|
|
1609
|
-
let k = new XMLSerializer().serializeToString(
|
|
1643
|
+
q(n, v);
|
|
1644
|
+
const Y = n.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 k = new XMLSerializer().serializeToString(v);
|
|
1610
1647
|
k.includes("xmlns=") || (k = k.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: n.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(
|
|
1622
|
-
zIndex:
|
|
1623
|
-
borderRadius:
|
|
1624
|
-
borderColor:
|
|
1625
|
-
borderWidth:
|
|
1626
|
-
boxShadow:
|
|
1627
|
-
imageSrc:
|
|
1628
|
-
isTraveler:
|
|
1629
|
-
},
|
|
1650
|
+
)), U = `data:image/svg+xml;utf8,${encodeURIComponent(k)}`;
|
|
1651
|
+
} else if (y.backgroundImage && y.backgroundImage !== "none") {
|
|
1652
|
+
const v = y.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
|
|
1653
|
+
v && (U = v[1]);
|
|
1654
|
+
}
|
|
1655
|
+
const I = {
|
|
1656
|
+
backgroundColor: y.backgroundColor,
|
|
1657
|
+
backgroundImage: y.backgroundImage,
|
|
1658
|
+
opacity: n.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(y.opacity),
|
|
1659
|
+
zIndex: z,
|
|
1660
|
+
borderRadius: y.borderRadius,
|
|
1661
|
+
borderColor: y.borderColor,
|
|
1662
|
+
borderWidth: y.borderWidth,
|
|
1663
|
+
boxShadow: y.boxShadow,
|
|
1664
|
+
imageSrc: U,
|
|
1665
|
+
isTraveler: L
|
|
1666
|
+
}, j = I;
|
|
1630
1667
|
let J, Z;
|
|
1631
|
-
const
|
|
1632
|
-
return n.tagName.toLowerCase() !== "svg" && Array.from(n.childNodes).forEach((
|
|
1633
|
-
const
|
|
1634
|
-
|
|
1668
|
+
const M = [], O = y.overflow === "hidden" ? [...l || [], n] : l;
|
|
1669
|
+
return n.tagName.toLowerCase() !== "svg" && Array.from(n.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
|
+
r,
|
|
1675
|
+
z,
|
|
1639
1676
|
c,
|
|
1640
|
-
|
|
1641
|
-
|
|
1677
|
+
v.nodeType === Node.TEXT_NODE ? b : void 0,
|
|
1678
|
+
v.nodeType === Node.TEXT_NODE && Object.keys(m).length > 0 ? m : void 0,
|
|
1679
|
+
O
|
|
1642
1680
|
);
|
|
1643
|
-
|
|
1681
|
+
T && M.push(T);
|
|
1644
1682
|
}), {
|
|
1645
|
-
id:
|
|
1683
|
+
id: S,
|
|
1646
1684
|
type: "BOX",
|
|
1647
1685
|
element: n,
|
|
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: L,
|
|
1698
|
+
captureLayer: r,
|
|
1661
1699
|
nativeLayer: b,
|
|
1662
|
-
nativeStyles: b !== void 0 ?
|
|
1663
|
-
backgroundColor: (
|
|
1664
|
-
backgroundImage: (
|
|
1665
|
-
opacity: (
|
|
1666
|
-
zIndex:
|
|
1667
|
-
borderRadius: (
|
|
1668
|
-
borderColor: (
|
|
1669
|
-
borderWidth: (
|
|
1670
|
-
boxShadow: (
|
|
1671
|
-
isTraveler:
|
|
1672
|
-
transform:
|
|
1700
|
+
nativeStyles: b !== void 0 ? Ce(te({}, I), {
|
|
1701
|
+
backgroundColor: (K = m.backgroundColor) != null ? K : I.backgroundColor,
|
|
1702
|
+
backgroundImage: (B = m.backgroundImage) != null ? B : I.backgroundImage,
|
|
1703
|
+
opacity: (V = m.opacity) != null ? V : I.opacity,
|
|
1704
|
+
zIndex: m.zIndex !== void 0 ? m.zIndex + z : I.zIndex,
|
|
1705
|
+
borderRadius: (ie = m.borderRadius) != null ? ie : I.borderRadius,
|
|
1706
|
+
borderColor: (se = m.borderColor) != null ? se : I.borderColor,
|
|
1707
|
+
borderWidth: (oe = m.borderWidth) != null ? oe : I.borderWidth,
|
|
1708
|
+
boxShadow: (he = m.boxShadow) != null ? he : I.boxShadow,
|
|
1709
|
+
isTraveler: I.isTraveler,
|
|
1710
|
+
transform: m.transform
|
|
1673
1711
|
}) : void 0,
|
|
1674
1712
|
nativeRect: b !== 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: y.position === "fixed",
|
|
1719
|
+
clipElements: l,
|
|
1720
|
+
children: M,
|
|
1721
|
+
shaderHooks: A
|
|
1683
1722
|
};
|
|
1684
1723
|
}
|
|
1685
|
-
function
|
|
1686
|
-
e.size !== 0 && e.forEach((t,
|
|
1687
|
-
var c, o, a,
|
|
1688
|
-
const s =
|
|
1724
|
+
function at(i, e) {
|
|
1725
|
+
e.size !== 0 && e.forEach((t, r) => {
|
|
1726
|
+
var c, o, a, l;
|
|
1727
|
+
const s = i.get(r);
|
|
1689
1728
|
!s || !s.userData.basePosition || (W.forceUpdateUniforms(s.material, {
|
|
1690
1729
|
backgroundColor: t.backgroundColor,
|
|
1691
1730
|
backgroundImage: t.backgroundImage,
|
|
@@ -1698,32 +1737,32 @@ function ot(r, e) {
|
|
|
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 = s.userData.baseStyles) == null ? void 0 : a.borderRadius
|
|
1702
1741
|
}));
|
|
1703
1742
|
});
|
|
1704
1743
|
}
|
|
1705
|
-
class
|
|
1706
|
-
constructor(e, t,
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
this.target = e, this.renderer = t, this.registry =
|
|
1744
|
+
class lt {
|
|
1745
|
+
constructor(e, t, r, s) {
|
|
1746
|
+
g(this, "target");
|
|
1747
|
+
g(this, "renderer");
|
|
1748
|
+
g(this, "registry");
|
|
1749
|
+
g(this, "isTravelEnabled", !1);
|
|
1750
|
+
g(this, "tracker");
|
|
1751
|
+
this.target = e, this.renderer = t, this.registry = r, this.tracker = new qe(e, {
|
|
1713
1752
|
resizeDebounce: s.resizeDebounce
|
|
1714
1753
|
}), this.tracker.onLayoutChange.add((c, o) => {
|
|
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, o);
|
|
1725
1764
|
}), this.tracker.onStyleChange.add((c) => {
|
|
1726
|
-
|
|
1765
|
+
at(this.registry, c);
|
|
1727
1766
|
}), this.tracker.onRender.add(() => {
|
|
1728
1767
|
this.renderer.syncMeshesByDOM(), this.renderer.render();
|
|
1729
1768
|
});
|
|
@@ -1735,9 +1774,9 @@ class at {
|
|
|
1735
1774
|
this.tracker.stop();
|
|
1736
1775
|
}
|
|
1737
1776
|
}
|
|
1738
|
-
class
|
|
1777
|
+
class ct {
|
|
1739
1778
|
constructor() {
|
|
1740
|
-
|
|
1779
|
+
g(this, "store");
|
|
1741
1780
|
this.store = /* @__PURE__ */ new WeakMap();
|
|
1742
1781
|
}
|
|
1743
1782
|
register(e, t) {
|
|
@@ -1760,14 +1799,14 @@ class nt {
|
|
|
1760
1799
|
this.store.delete(e);
|
|
1761
1800
|
}
|
|
1762
1801
|
}
|
|
1763
|
-
class
|
|
1802
|
+
class ft {
|
|
1764
1803
|
constructor(e, t) {
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1804
|
+
g(this, "renderer");
|
|
1805
|
+
g(this, "syncer");
|
|
1806
|
+
g(this, "target");
|
|
1807
|
+
g(this, "registry");
|
|
1769
1808
|
var s, c, o;
|
|
1770
|
-
if (this.target = e, this.registry = new
|
|
1809
|
+
if (this.target = e, this.registry = new ct(), !document.getElementById("mirage-engine-styles")) {
|
|
1771
1810
|
const a = document.createElement("style");
|
|
1772
1811
|
a.id = "mirage-engine-styles", a.textContent = `
|
|
1773
1812
|
[${ee.NAME}="${ee.VALUES.HIDE}"] {
|
|
@@ -1775,15 +1814,15 @@ class dt {
|
|
|
1775
1814
|
}
|
|
1776
1815
|
`, document.head.appendChild(a);
|
|
1777
1816
|
}
|
|
1778
|
-
let
|
|
1779
|
-
if (t.mode === "duplicate" ?
|
|
1817
|
+
let r;
|
|
1818
|
+
if (t.mode === "duplicate" ? r = (c = (s = t.container) != null ? s : this.target.parentElement) != null ? c : void 0 : r = (o = this.target.parentElement) != null ? o : void 0, !r)
|
|
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
|
+
r,
|
|
1785
1824
|
this.registry
|
|
1786
|
-
), this.renderer.mount(), this.syncer = new
|
|
1825
|
+
), this.renderer.mount(), this.syncer = new lt(this.target, this.renderer, this.registry, t);
|
|
1787
1826
|
}
|
|
1788
1827
|
start() {
|
|
1789
1828
|
this.syncer.start();
|
|
@@ -1820,32 +1859,32 @@ class dt {
|
|
|
1820
1859
|
}), window.addEventListener("keyup", (c) => {
|
|
1821
1860
|
t[c.key] !== void 0 && (t[c.key] = !1);
|
|
1822
1861
|
});
|
|
1823
|
-
const
|
|
1824
|
-
requestAnimationFrame(s), t.ArrowRight && e.position.setX(e.position.x +
|
|
1862
|
+
const r = 2, s = () => {
|
|
1863
|
+
requestAnimationFrame(s), 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);
|
|
1825
1864
|
};
|
|
1826
1865
|
s();
|
|
1827
1866
|
}
|
|
1828
1867
|
}
|
|
1829
1868
|
export {
|
|
1830
|
-
|
|
1869
|
+
Me as ALLOWED_FILTERS,
|
|
1831
1870
|
ee as ATTR_DOM,
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1871
|
+
H as ATTR_FILTER,
|
|
1872
|
+
dt as ATTR_SANDWICH,
|
|
1873
|
+
$ as ATTR_SELECT,
|
|
1874
|
+
We as ATTR_SHADER,
|
|
1875
|
+
N as ATTR_TRAVEL,
|
|
1876
|
+
ye as DIRTY_CONTENT,
|
|
1877
|
+
ge as DIRTY_NONE,
|
|
1839
1878
|
re as DIRTY_RECT,
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1879
|
+
pe as DIRTY_STRUCTURE,
|
|
1880
|
+
ue as DIRTY_STYLE,
|
|
1881
|
+
Pe as DIRTY_ZINDEX,
|
|
1882
|
+
ut as EXCLUDED,
|
|
1883
|
+
ft as Engine,
|
|
1845
1884
|
ae as SELECT_LAYER,
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1885
|
+
F as THREE_LAYERS,
|
|
1886
|
+
Re as TRAVEL_VALUES,
|
|
1887
|
+
qe as Tracker,
|
|
1888
|
+
G as USER_LAYER,
|
|
1889
|
+
Ge as extractFromStyle
|
|
1851
1890
|
};
|