@mirage-engine/core 0.3.7 → 0.3.8
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 +9 -0
- package/dist/mirage-engine.js +595 -558
- package/dist/mirage-engine.umd.js +27 -14
- package/dist/src/types/attributes.d.ts +10 -0
- package/package.json +3 -3
- package/src/dom/Extractor.ts +18 -12
- package/src/renderer/Renderer.ts +2 -0
- package/src/types/attributes.ts +5 -0
package/dist/mirage-engine.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Be = Object.defineProperty, Oe = Object.defineProperties;
|
|
2
2
|
var Fe = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var ye = Object.getOwnPropertySymbols;
|
|
4
4
|
var _e = Object.prototype.hasOwnProperty, Ne = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var
|
|
5
|
+
var ae = (s, e, t) => e in s ? Be(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t, q = (s, e) => {
|
|
6
6
|
for (var t in e || (e = {}))
|
|
7
|
-
_e.call(e, t) &&
|
|
7
|
+
_e.call(e, t) && ae(s, t, e[t]);
|
|
8
8
|
if (ye)
|
|
9
9
|
for (var t of ye(e))
|
|
10
|
-
Ne.call(e, t) &&
|
|
10
|
+
Ne.call(e, t) && ae(s, t, e[t]);
|
|
11
11
|
return s;
|
|
12
|
-
},
|
|
13
|
-
var
|
|
14
|
-
var
|
|
12
|
+
}, be = (s, e) => Oe(s, Fe(e));
|
|
13
|
+
var f = (s, e, t) => (ae(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
14
|
+
var we = (s, e, t) => new Promise((r, i) => {
|
|
15
15
|
var a = (c) => {
|
|
16
16
|
try {
|
|
17
17
|
o(t.next(c));
|
|
18
18
|
} catch (l) {
|
|
19
|
-
|
|
19
|
+
i(l);
|
|
20
20
|
}
|
|
21
21
|
}, n = (c) => {
|
|
22
22
|
try {
|
|
23
23
|
o(t.throw(c));
|
|
24
24
|
} catch (l) {
|
|
25
|
-
|
|
25
|
+
i(l);
|
|
26
26
|
}
|
|
27
|
-
}, o = (c) => c.done ?
|
|
27
|
+
}, o = (c) => c.done ? r(c.value) : Promise.resolve(c.value).then(a, n);
|
|
28
28
|
o((t = t.apply(s, e)).next());
|
|
29
29
|
});
|
|
30
|
-
import * as
|
|
30
|
+
import * as y from "three";
|
|
31
31
|
const Re = {
|
|
32
32
|
INCLUDE_TREE: "include-tree",
|
|
33
33
|
EXCLUDE_TREE: "exclude-tree",
|
|
34
34
|
INCLUDE_SELF: "include-self",
|
|
35
35
|
EXCLUDE_SELF: "exclude-self",
|
|
36
36
|
END: "end"
|
|
37
|
-
},
|
|
37
|
+
}, P = {
|
|
38
38
|
NAME: "data-mirage-dom",
|
|
39
39
|
KEY: "mirageDom",
|
|
40
40
|
VALUES: {
|
|
@@ -48,13 +48,18 @@ const Re = {
|
|
|
48
48
|
CAPTURE_2: "2",
|
|
49
49
|
CAPTURE_3: "3",
|
|
50
50
|
CAPTURE_4: "4",
|
|
51
|
-
CAPTURE_5: "5"
|
|
52
|
-
|
|
51
|
+
CAPTURE_5: "5",
|
|
52
|
+
CAPTURE_6: "6",
|
|
53
|
+
CAPTURE_7: "7",
|
|
54
|
+
CAPTURE_8: "8",
|
|
55
|
+
CAPTURE_9: "9",
|
|
56
|
+
CAPTURE_10: "10"
|
|
57
|
+
}, U = {
|
|
53
58
|
NAME: "data-mirage-travel",
|
|
54
59
|
KEY: "mirageTravel",
|
|
55
60
|
VALUES: xe,
|
|
56
61
|
MAX_LAYERS: Object.keys(xe).length - 1
|
|
57
|
-
},
|
|
62
|
+
}, N = {
|
|
58
63
|
NAME: "data-mirage-filter",
|
|
59
64
|
KEY: "mirageFilter",
|
|
60
65
|
VALUES: Re
|
|
@@ -62,7 +67,7 @@ const Re = {
|
|
|
62
67
|
NAME: "data-mirage-select",
|
|
63
68
|
KEY: "mirageSelect",
|
|
64
69
|
VALUES: Re
|
|
65
|
-
},
|
|
70
|
+
}, ze = {
|
|
66
71
|
NAME: "data-mirage-shader",
|
|
67
72
|
KEY: "mirageShader"
|
|
68
73
|
}, at = {
|
|
@@ -71,7 +76,7 @@ const Re = {
|
|
|
71
76
|
VALUES: {
|
|
72
77
|
FRONT: "front"
|
|
73
78
|
}
|
|
74
|
-
},
|
|
79
|
+
}, re = 0, $ = 1, Z = 2, Xe = 4, ie = 8, ce = 16;
|
|
75
80
|
function Ve(s) {
|
|
76
81
|
const e = s.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
77
82
|
return e ? {
|
|
@@ -94,32 +99,32 @@ function Ye(s) {
|
|
|
94
99
|
}
|
|
95
100
|
class We {
|
|
96
101
|
constructor(e, t) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingStyles.size == 0 && (this.pendingMask |= $ |
|
|
102
|
+
f(this, "target");
|
|
103
|
+
f(this, "observer");
|
|
104
|
+
f(this, "pendingDeletions", /* @__PURE__ */ new Set());
|
|
105
|
+
f(this, "pendingStyles", /* @__PURE__ */ new Map());
|
|
106
|
+
f(this, "isDomDirty", !1);
|
|
107
|
+
f(this, "isRunning", !1);
|
|
108
|
+
f(this, "pendingMask", re);
|
|
109
|
+
f(this, "mutationTimer", null);
|
|
110
|
+
f(this, "cssTimer", null);
|
|
111
|
+
f(this, "resizeConfig");
|
|
112
|
+
f(this, "resizeTimer", null);
|
|
113
|
+
f(this, "isResizing", !1);
|
|
114
|
+
f(this, "lastScrollX", 0);
|
|
115
|
+
f(this, "lastScrollY", 0);
|
|
116
|
+
f(this, "scrollTimer", null);
|
|
117
|
+
f(this, "onBeforeRender", /* @__PURE__ */ new Set());
|
|
118
|
+
f(this, "onLayoutChange", /* @__PURE__ */ new Set());
|
|
119
|
+
f(this, "onStyleChange", /* @__PURE__ */ new Set());
|
|
120
|
+
f(this, "onScrollChange", /* @__PURE__ */ new Set());
|
|
121
|
+
f(this, "onRender", /* @__PURE__ */ new Set());
|
|
122
|
+
f(this, "onTransitionFinished", (e) => {
|
|
123
|
+
this.target.contains(e.target) && this.mutationTimer === null && (this.cssTimer && clearTimeout(this.cssTimer), this.pendingStyles.size == 0 && (this.pendingMask |= $ | Z, this.cssTimer = window.setTimeout(() => {
|
|
119
124
|
this.isDomDirty = !0, this.cssTimer = null;
|
|
120
125
|
}, 50)));
|
|
121
126
|
});
|
|
122
|
-
|
|
127
|
+
f(this, "onWindowResize", () => {
|
|
123
128
|
if (!this.resizeConfig.enabled) {
|
|
124
129
|
this.isDomDirty = !0;
|
|
125
130
|
return;
|
|
@@ -128,41 +133,41 @@ class We {
|
|
|
128
133
|
this.isDomDirty = !0, this.resizeConfig.onEnd && this.resizeConfig.onEnd(), this.isResizing = !1, this.resizeTimer = null;
|
|
129
134
|
}, this.resizeConfig.delay);
|
|
130
135
|
});
|
|
131
|
-
|
|
136
|
+
f(this, "renderLoop", () => {
|
|
132
137
|
if (!this.isRunning)
|
|
133
138
|
return;
|
|
134
|
-
this.onBeforeRender.forEach((
|
|
139
|
+
this.onBeforeRender.forEach((r) => r()), this.isDomDirty && (this.isDomDirty = !1, this.onLayoutChange.forEach((r) => r(this.pendingMask, this.pendingDeletions)), this.pendingDeletions.clear(), this.pendingMask = re);
|
|
135
140
|
const e = window.scrollX, t = window.scrollY;
|
|
136
|
-
(e !== this.lastScrollX || t !== this.lastScrollY) && (this.onScrollChange.forEach((
|
|
141
|
+
(e !== this.lastScrollX || t !== this.lastScrollY) && (this.onScrollChange.forEach((r) => r(e, t)), this.lastScrollX = e, this.lastScrollY = t, this.scrollTimer && clearTimeout(this.scrollTimer), this.scrollTimer = window.setTimeout(() => {
|
|
137
142
|
this.pendingMask |= $, this.isDomDirty = !0, this.scrollTimer = null;
|
|
138
|
-
}, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((
|
|
143
|
+
}, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((r) => r(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((r) => r()), requestAnimationFrame(this.renderLoop);
|
|
139
144
|
});
|
|
140
|
-
var
|
|
145
|
+
var i, a;
|
|
141
146
|
this.target = e;
|
|
142
|
-
const
|
|
143
|
-
|
|
147
|
+
const r = (i = t.resizeDebounce) != null ? i : !0;
|
|
148
|
+
r === !1 ? this.resizeConfig = { enabled: !1, delay: 0 } : r === !0 ? this.resizeConfig = { enabled: !0, delay: 150 } : this.resizeConfig = {
|
|
144
149
|
enabled: !0,
|
|
145
|
-
delay: (a =
|
|
146
|
-
onStart:
|
|
147
|
-
onEnd:
|
|
150
|
+
delay: (a = r.delay) != null ? a : 150,
|
|
151
|
+
onStart: r.onStart,
|
|
152
|
+
onEnd: r.onEnd
|
|
148
153
|
}, this.observer = new MutationObserver((n) => {
|
|
149
|
-
let o =
|
|
154
|
+
let o = re;
|
|
150
155
|
for (const c of n)
|
|
151
156
|
if (c.type === "childList")
|
|
152
|
-
o |=
|
|
157
|
+
o |= ie, c.removedNodes.length > 0 && c.removedNodes.forEach((l) => {
|
|
153
158
|
l instanceof HTMLElement && this.pendingDeletions.add(l);
|
|
154
159
|
});
|
|
155
160
|
else if (c.type === "attributes")
|
|
156
161
|
if (c.attributeName === "style") {
|
|
157
|
-
o |= $ |
|
|
162
|
+
o |= $ | Z;
|
|
158
163
|
const l = c.target, d = Ye(l.style);
|
|
159
164
|
this.pendingStyles.set(l, d);
|
|
160
165
|
} else
|
|
161
|
-
c.attributeName === "class" ? o |= $ |
|
|
166
|
+
c.attributeName === "class" ? o |= $ | Z : c.attributeName && c.attributeName.startsWith("data-") && (o |= $ | Z, c.attributeName.startsWith("data-mirage") && (o |= ie));
|
|
162
167
|
else
|
|
163
168
|
c.type === "characterData" && (o |= ce | $);
|
|
164
|
-
if (o !==
|
|
165
|
-
if (this.pendingMask |= o, o &
|
|
169
|
+
if (o !== re) {
|
|
170
|
+
if (this.pendingMask |= o, o & ie) {
|
|
166
171
|
this.clearTimers(), this.isDomDirty = !0;
|
|
167
172
|
return;
|
|
168
173
|
}
|
|
@@ -187,12 +192,12 @@ class We {
|
|
|
187
192
|
this.mutationTimer && (clearTimeout(this.mutationTimer), this.mutationTimer = null), this.cssTimer && (clearTimeout(this.cssTimer), this.cssTimer = null), this.scrollTimer && (clearTimeout(this.scrollTimer), this.scrollTimer = null);
|
|
188
193
|
}
|
|
189
194
|
}
|
|
190
|
-
const W = 1,
|
|
195
|
+
const W = 1, K = 2, ct = 0, D = {
|
|
191
196
|
BASE: 0,
|
|
192
197
|
SELECTED: 1,
|
|
193
198
|
getCaptureLayer: (s) => 31 - s,
|
|
194
199
|
HIDDEN: 31
|
|
195
|
-
},
|
|
200
|
+
}, Ee = Object.values(N.VALUES);
|
|
196
201
|
class Le {
|
|
197
202
|
/**
|
|
198
203
|
* Calculates or retrieves the exact alphabetic baseline (in pixels) for the given font.
|
|
@@ -208,31 +213,31 @@ class Le {
|
|
|
208
213
|
static calculateBaselineFromDOM(e) {
|
|
209
214
|
if (typeof document == "undefined")
|
|
210
215
|
return 0;
|
|
211
|
-
const t = document.createElement("div"),
|
|
212
|
-
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",
|
|
213
|
-
const a =
|
|
216
|
+
const t = document.createElement("div"), r = document.createElement("span"), i = document.createElement("img");
|
|
217
|
+
t.style.visibility = "hidden", t.style.position = "absolute", t.style.top = "0px", t.style.left = "0px", t.style.font = e, t.style.margin = "0", t.style.padding = "0", t.style.border = "none", r.style.margin = "0", r.style.padding = "0", r.style.border = "none", r.style.lineHeight = "normal", i.width = 1, i.height = 1, i.style.verticalAlign = "baseline", r.appendChild(document.createTextNode("Hidden Text")), t.appendChild(r), t.appendChild(i), document.body.appendChild(t);
|
|
218
|
+
const a = i.offsetTop - r.offsetTop;
|
|
214
219
|
return document.body.removeChild(t), a;
|
|
215
220
|
}
|
|
216
221
|
}
|
|
217
|
-
|
|
218
|
-
class He extends
|
|
219
|
-
constructor(t,
|
|
222
|
+
f(Le, "cache", /* @__PURE__ */ new Map());
|
|
223
|
+
class He extends y.MeshBasicMaterial {
|
|
224
|
+
constructor(t, r, i, a, n = 2) {
|
|
220
225
|
super({
|
|
221
226
|
transparent: !0,
|
|
222
|
-
side:
|
|
227
|
+
side: y.FrontSide,
|
|
223
228
|
color: 16777215
|
|
224
229
|
});
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
230
|
+
f(this, "canvas");
|
|
231
|
+
f(this, "ctx");
|
|
232
|
+
f(this, "qualityFactor");
|
|
228
233
|
if (this.canvas = document.createElement("canvas"), this.ctx = this.canvas.getContext("2d"), !this.ctx)
|
|
229
234
|
throw new Error("[Mirage] Failed to create canvas context");
|
|
230
|
-
this.qualityFactor = n, this.map = new
|
|
235
|
+
this.qualityFactor = n, this.map = new y.CanvasTexture(this.canvas), this.map.colorSpace = y.LinearSRGBColorSpace, this.map.minFilter = y.LinearFilter, this.map.magFilter = y.LinearFilter, this.updateText(t, r, i, a);
|
|
231
236
|
}
|
|
232
|
-
wrapText(t,
|
|
233
|
-
const
|
|
237
|
+
wrapText(t, r) {
|
|
238
|
+
const i = t.split(`
|
|
234
239
|
`), a = [];
|
|
235
|
-
return
|
|
240
|
+
return i.forEach((n) => {
|
|
236
241
|
const o = n.match(/[^\s\-]+\-?|\-|\s+/g) || [];
|
|
237
242
|
if (o.length === 0) {
|
|
238
243
|
a.push("");
|
|
@@ -241,51 +246,54 @@ class He extends b.MeshBasicMaterial {
|
|
|
241
246
|
let c = o[0];
|
|
242
247
|
for (let l = 1; l < o.length; l++) {
|
|
243
248
|
const d = o[l];
|
|
244
|
-
this.ctx.measureText(c + d).width <=
|
|
249
|
+
this.ctx.measureText(c + d).width <= r + 2 ? c += d : (c && a.push(c), c = d.trimStart());
|
|
245
250
|
}
|
|
246
251
|
c && a.push(c);
|
|
247
252
|
}), a;
|
|
248
253
|
}
|
|
249
|
-
updateText(t,
|
|
254
|
+
updateText(t, r, i, a, n) {
|
|
250
255
|
n !== void 0 && (this.qualityFactor = n);
|
|
251
|
-
const c = (window.devicePixelRatio || 1) * this.qualityFactor, l =
|
|
252
|
-
this.canvas.width !== l || this.canvas.height !== d ? (this.canvas.width = l, this.canvas.height = d) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(c, 0, 0, c, 0, 0), this.ctx.font =
|
|
253
|
-
const h = this.wrapText(t,
|
|
254
|
-
h.forEach((
|
|
255
|
-
const
|
|
256
|
-
let
|
|
257
|
-
|
|
256
|
+
const c = (window.devicePixelRatio || 1) * this.qualityFactor, l = i * c, d = a * c;
|
|
257
|
+
this.canvas.width !== l || this.canvas.height !== d ? (this.canvas.width = l, this.canvas.height = d) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(c, 0, 0, c, 0, 0), this.ctx.font = r.font, this.ctx.fillStyle = r.color, this.ctx.textBaseline = "alphabetic", this.ctx.globalAlpha = 1;
|
|
258
|
+
const h = this.wrapText(t, i), u = r.lineHeight, p = Le.getBaseline(r.font);
|
|
259
|
+
h.forEach((g, v) => {
|
|
260
|
+
const x = v * u + p;
|
|
261
|
+
let M = 0;
|
|
262
|
+
r.textAlign === "center" ? M = i / 2 : r.textAlign === "right" && (M = i), this.ctx.textAlign = r.textAlign, this.ctx.fillText(g, M, x);
|
|
258
263
|
}), this.map && (this.map.needsUpdate = !0);
|
|
259
264
|
}
|
|
260
265
|
dispose() {
|
|
261
266
|
this.map && this.map.dispose(), super.dispose();
|
|
262
267
|
}
|
|
263
268
|
}
|
|
264
|
-
function
|
|
265
|
-
|
|
269
|
+
function J(s, e = 0) {
|
|
270
|
+
if (typeof s == "number")
|
|
271
|
+
return s;
|
|
272
|
+
const t = parseFloat(s) || 0;
|
|
273
|
+
return typeof s == "string" && s.includes("%") ? t / 100 * e : t;
|
|
266
274
|
}
|
|
267
|
-
function
|
|
275
|
+
function ee(s) {
|
|
268
276
|
if (!s || s === "transparent")
|
|
269
|
-
return { color: new
|
|
277
|
+
return { color: new y.Color(16777215), alpha: 0 };
|
|
270
278
|
const e = s.match(
|
|
271
279
|
/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/
|
|
272
280
|
);
|
|
273
281
|
if (e) {
|
|
274
|
-
const t = parseInt(e[1], 10),
|
|
275
|
-
return { color: new
|
|
282
|
+
const t = parseInt(e[1], 10), r = parseInt(e[2], 10), i = parseInt(e[3], 10), a = e[4] !== void 0 ? parseFloat(e[4]) : 1;
|
|
283
|
+
return { color: new y.Color(`rgb(${t}, ${r}, ${i})`), alpha: a };
|
|
276
284
|
}
|
|
277
|
-
return { color: new
|
|
285
|
+
return { color: new y.Color(s), alpha: 1 };
|
|
278
286
|
}
|
|
279
287
|
function Pe(s) {
|
|
280
288
|
const e = [];
|
|
281
|
-
let t = "",
|
|
282
|
-
for (let
|
|
283
|
-
const a = s[
|
|
289
|
+
let t = "", r = 0;
|
|
290
|
+
for (let i = 0; i < s.length; i++) {
|
|
291
|
+
const a = s[i];
|
|
284
292
|
if (a === "(")
|
|
285
|
-
|
|
293
|
+
r++;
|
|
286
294
|
else if (a === ")")
|
|
287
|
-
|
|
288
|
-
else if (a === "," &&
|
|
295
|
+
r--;
|
|
296
|
+
else if (a === "," && r === 0) {
|
|
289
297
|
e.push(t.trim()), t = "";
|
|
290
298
|
continue;
|
|
291
299
|
}
|
|
@@ -299,24 +307,24 @@ function Ge(s) {
|
|
|
299
307
|
const e = s.match(/linear-gradient\((.*)\)/);
|
|
300
308
|
if (!e)
|
|
301
309
|
return null;
|
|
302
|
-
const t = e[1],
|
|
303
|
-
let
|
|
304
|
-
const n =
|
|
310
|
+
const t = e[1], r = Pe(t);
|
|
311
|
+
let i = Math.PI, a = 0;
|
|
312
|
+
const n = r[0].trim();
|
|
305
313
|
if (n.startsWith("to "))
|
|
306
|
-
n === "to top" ?
|
|
314
|
+
n === "to top" ? i = 0 : n === "to right" ? i = Math.PI / 2 : n === "to bottom" ? i = Math.PI : n === "to left" ? i = Math.PI * 1.5 : n === "to top right" || n === "to right top" ? i = Math.PI / 4 : n === "to bottom right" || n === "to right bottom" ? i = Math.PI * 0.75 : n === "to bottom left" || n === "to left bottom" ? i = Math.PI * 1.25 : (n === "to top left" || n === "to left top") && (i = Math.PI * 1.75), a = 1;
|
|
307
315
|
else if (n.endsWith("deg") || n.endsWith("rad") || n.endsWith("turn")) {
|
|
308
316
|
const c = parseFloat(n);
|
|
309
|
-
n.endsWith("deg") ?
|
|
317
|
+
n.endsWith("deg") ? i = c * (Math.PI / 180) : n.endsWith("rad") ? i = c : n.endsWith("turn") && (i = c * Math.PI * 2), a = 1;
|
|
310
318
|
}
|
|
311
319
|
const o = [];
|
|
312
|
-
for (let c = a; c <
|
|
313
|
-
const l =
|
|
320
|
+
for (let c = a; c < r.length && !(o.length >= 8); c++) {
|
|
321
|
+
const l = r[c].trim(), d = l.lastIndexOf(" ");
|
|
314
322
|
let h = l, u = null;
|
|
315
323
|
if (d !== -1 && !l.endsWith(")")) {
|
|
316
|
-
const
|
|
317
|
-
(
|
|
324
|
+
const g = l.substring(d + 1);
|
|
325
|
+
(g.endsWith("%") || g.endsWith("px") || !isNaN(parseFloat(g))) && (h = l.substring(0, d).trim(), u = g);
|
|
318
326
|
}
|
|
319
|
-
const p =
|
|
327
|
+
const p = ee(h);
|
|
320
328
|
o.push({
|
|
321
329
|
color: p.color,
|
|
322
330
|
alpha: p.alpha,
|
|
@@ -334,13 +342,13 @@ function Ge(s) {
|
|
|
334
342
|
const d = l - c;
|
|
335
343
|
if (d > 1) {
|
|
336
344
|
const h = o[c].stop, p = (o[l].stop - h) / d;
|
|
337
|
-
for (let
|
|
338
|
-
o[c +
|
|
345
|
+
for (let g = 1; g < d; g++)
|
|
346
|
+
o[c + g].stop = h + p * g;
|
|
339
347
|
}
|
|
340
348
|
c = l;
|
|
341
349
|
}
|
|
342
350
|
}
|
|
343
|
-
return { angle:
|
|
351
|
+
return { angle: i, stops: o };
|
|
344
352
|
}
|
|
345
353
|
const qe = `varying vec2 vUv;
|
|
346
354
|
varying vec4 vScreenPos;
|
|
@@ -431,6 +439,18 @@ void main() {
|
|
|
431
439
|
vec2 p = (vUv - 0.5) * uSize;
|
|
432
440
|
vec2 halfSize = uSize * 0.5;
|
|
433
441
|
|
|
442
|
+
// CSS Proportional Border-Radius Clamping
|
|
443
|
+
float tl = uBorderRadius.x;
|
|
444
|
+
float tr = uBorderRadius.y;
|
|
445
|
+
float br = uBorderRadius.z;
|
|
446
|
+
float bl = uBorderRadius.w;
|
|
447
|
+
float fTop = uSize.x / max(tl + tr, 0.0001);
|
|
448
|
+
float fBottom = uSize.x / max(bl + br, 0.0001);
|
|
449
|
+
float fLeft = uSize.y / max(tl + bl, 0.0001);
|
|
450
|
+
float fRight = uSize.y / max(tr + br, 0.0001);
|
|
451
|
+
float f = min(1.0, min(min(fTop, fBottom), min(fLeft, fRight)));
|
|
452
|
+
vec4 clampedRadius = uBorderRadius * f;
|
|
453
|
+
|
|
434
454
|
#INJECT_UV_MODIFIER
|
|
435
455
|
|
|
436
456
|
// color decision pipeline
|
|
@@ -444,9 +464,8 @@ void main() {
|
|
|
444
464
|
#INJECT_BASE_COLOR
|
|
445
465
|
|
|
446
466
|
// Hybrid SDF
|
|
447
|
-
vec2 xRadii = mix(
|
|
467
|
+
vec2 xRadii = mix(clampedRadius.xw, clampedRadius.yz, step(0.0, p.x));
|
|
448
468
|
float r = mix(xRadii.y, xRadii.x, step(0.0, p.y));
|
|
449
|
-
r = min(r, min(halfSize.x, halfSize.y));
|
|
450
469
|
|
|
451
470
|
float d = sdRoundedBox(p, halfSize, r);
|
|
452
471
|
|
|
@@ -484,88 +503,94 @@ uniform vec2 uTextureOffset;`, Ke = `vec2 screenUv = (vScreenPos.xy / vScreenPos
|
|
|
484
503
|
vec2 resultUv = screenUv;
|
|
485
504
|
|
|
486
505
|
`, Je = `vec4 texColor = texture2D(uTexture, resultUv);
|
|
487
|
-
baseColor = blendSrcOver(baseColor, texColor);`,
|
|
506
|
+
baseColor = blendSrcOver(baseColor, texColor);`, Ce = {
|
|
488
507
|
vertexShader: qe,
|
|
489
508
|
fragmentShader: $e
|
|
490
|
-
},
|
|
509
|
+
}, Te = {
|
|
491
510
|
declChunk: je,
|
|
492
511
|
uvChunk: Ke,
|
|
493
512
|
baseColorChunk: Je
|
|
494
513
|
};
|
|
495
|
-
function Qe(s, e, t,
|
|
496
|
-
var
|
|
497
|
-
const a =
|
|
514
|
+
function Qe(s, e, t, r = null, i) {
|
|
515
|
+
var E;
|
|
516
|
+
const a = r !== null || !!s.imageSrc;
|
|
498
517
|
let n = "";
|
|
499
518
|
const o = {};
|
|
500
|
-
if (
|
|
501
|
-
for (const [
|
|
502
|
-
typeof
|
|
503
|
-
`, o[
|
|
504
|
-
`, o[
|
|
505
|
-
`, o[
|
|
506
|
-
`, o[
|
|
507
|
-
`, o[
|
|
508
|
-
const c = (a ?
|
|
509
|
-
` + n,
|
|
510
|
-
`,
|
|
511
|
-
|
|
519
|
+
if (i != null && i.uniforms)
|
|
520
|
+
for (const [C, b] of Object.entries(i.uniforms))
|
|
521
|
+
typeof b == "number" ? (n += `uniform float ${C};
|
|
522
|
+
`, o[C] = { value: b }) : Array.isArray(b) ? b.length === 2 ? (n += `uniform vec2 ${C};
|
|
523
|
+
`, o[C] = { value: new y.Vector2(...b) }) : b.length === 3 ? (n += `uniform vec3 ${C};
|
|
524
|
+
`, o[C] = { value: new y.Vector3(...b) }) : b.length === 4 && (n += `uniform vec4 ${C};
|
|
525
|
+
`, o[C] = { value: new y.Vector4(...b) }) : (n += `uniform float ${C};
|
|
526
|
+
`, o[C] = { value: b });
|
|
527
|
+
const c = i !== void 0, l = (a || c ? Te.declChunk : "") + `
|
|
528
|
+
` + n, d = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
|
|
529
|
+
`, h = s.isTraveler ? `vec2 resultUv = screenUv;
|
|
530
|
+
` : `vec2 resultUv = vUv * uTextureRepeat + uTextureOffset;
|
|
531
|
+
`, u = a || c ? d + h + ((i == null ? void 0 : i.uvModifier) || "") : "", p = a || c ? Te.baseColorChunk : "", g = (i == null ? void 0 : i.colorModifier) || "", v = Ce.fragmentShader.replace("#INJECT_DECLARATIONS", l).replace("#INJECT_UV_MODIFIER", u).replace("#INJECT_BASE_COLOR", p).replace("#INJECT_COLOR_MODIFIER", g), x = ee(s.backgroundColor), M = ee(s.borderColor), A = {
|
|
532
|
+
uSize: { value: new y.Vector2(e, t) },
|
|
512
533
|
uBgColor: {
|
|
513
|
-
value: new
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
534
|
+
value: new y.Vector4(
|
|
535
|
+
x.color.r,
|
|
536
|
+
x.color.g,
|
|
537
|
+
x.color.b,
|
|
538
|
+
x.alpha
|
|
518
539
|
)
|
|
519
540
|
},
|
|
520
541
|
uBorderColor: {
|
|
521
|
-
value: new
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
542
|
+
value: new y.Vector4(
|
|
543
|
+
M.color.r,
|
|
544
|
+
M.color.g,
|
|
545
|
+
M.color.b,
|
|
546
|
+
M.alpha
|
|
526
547
|
)
|
|
527
548
|
},
|
|
528
|
-
uBorderRadius: { value: new
|
|
529
|
-
uBorderWidth: { value:
|
|
530
|
-
uOpacity: { value: (
|
|
549
|
+
uBorderRadius: { value: new y.Vector4(0, 0, 0, 0) },
|
|
550
|
+
uBorderWidth: { value: J(s.borderWidth) },
|
|
551
|
+
uOpacity: { value: (E = s.opacity) != null ? E : 1 },
|
|
531
552
|
uTexture: { value: null },
|
|
532
|
-
uTextureRepeat: { value: new
|
|
533
|
-
uTextureOffset: { value: new
|
|
553
|
+
uTextureRepeat: { value: new y.Vector2(1, 1) },
|
|
554
|
+
uTextureOffset: { value: new y.Vector2(0, 0) },
|
|
534
555
|
uGradientCount: { value: 0 },
|
|
535
556
|
uGradientAngle: { value: 0 },
|
|
536
557
|
uGradientColors: {
|
|
537
|
-
value: Array.from({ length: 8 }, () => new
|
|
558
|
+
value: Array.from({ length: 8 }, () => new y.Vector4(0, 0, 0, 0))
|
|
538
559
|
},
|
|
539
560
|
uGradientStops: { value: new Float32Array(8) }
|
|
540
561
|
};
|
|
541
|
-
Me(
|
|
542
|
-
const
|
|
543
|
-
uniforms: q(q({},
|
|
544
|
-
vertexShader:
|
|
545
|
-
fragmentShader:
|
|
562
|
+
Me(A.uBorderRadius.value, s.borderRadius, Math.min(e, t)), a && (A.uTexture.value = r);
|
|
563
|
+
const S = new y.ShaderMaterial({
|
|
564
|
+
uniforms: q(q({}, A), o),
|
|
565
|
+
vertexShader: Ce.vertexShader,
|
|
566
|
+
fragmentShader: v,
|
|
546
567
|
transparent: !0,
|
|
547
|
-
side:
|
|
568
|
+
side: y.FrontSide
|
|
548
569
|
// for better performance
|
|
549
570
|
});
|
|
550
|
-
return s.backgroundImage && le(
|
|
571
|
+
return s.backgroundImage && le(S, { backgroundImage: s.backgroundImage }), S;
|
|
551
572
|
}
|
|
552
|
-
function Ze(s, e, t,
|
|
553
|
-
const a =
|
|
573
|
+
function Ze(s, e, t, r, i) {
|
|
574
|
+
const a = J(e.borderWidth);
|
|
554
575
|
le(s, {
|
|
555
576
|
width: t,
|
|
556
|
-
height:
|
|
577
|
+
height: r,
|
|
557
578
|
borderRadius: e.borderRadius,
|
|
558
579
|
borderWidth: a,
|
|
559
580
|
backgroundColor: e.backgroundColor,
|
|
560
581
|
borderColor: e.borderColor,
|
|
561
582
|
opacity: e.opacity,
|
|
562
|
-
texture:
|
|
583
|
+
texture: i,
|
|
563
584
|
backgroundImage: e.backgroundImage
|
|
564
585
|
});
|
|
565
586
|
}
|
|
566
587
|
function le(s, e) {
|
|
567
|
-
var
|
|
568
|
-
if (e.width !== void 0 && e.height !== void 0 && s.uniforms.uSize.value.set(e.width, e.height), e.borderRadius !== void 0
|
|
588
|
+
var r, i, a;
|
|
589
|
+
if (e.width !== void 0 && e.height !== void 0 && s.uniforms.uSize.value.set(e.width, e.height), e.borderRadius !== void 0) {
|
|
590
|
+
const n = e.width !== void 0 && e.height !== void 0 ? Math.min(e.width, e.height) : Math.min(s.uniforms.uSize.value.x, s.uniforms.uSize.value.y);
|
|
591
|
+
Me(s.uniforms.uBorderRadius.value, e.borderRadius, n);
|
|
592
|
+
}
|
|
593
|
+
if (e.borderWidth !== void 0 && (s.uniforms.uBorderWidth.value = e.borderWidth), e.backgroundColor !== void 0)
|
|
569
594
|
if (Array.isArray(e.backgroundColor)) {
|
|
570
595
|
const n = s.uniforms.uBgColor.value.w;
|
|
571
596
|
s.uniforms.uBgColor.value.set(
|
|
@@ -575,7 +600,7 @@ function le(s, e) {
|
|
|
575
600
|
n
|
|
576
601
|
);
|
|
577
602
|
} else if (typeof e.backgroundColor == "string") {
|
|
578
|
-
const n =
|
|
603
|
+
const n = ee(e.backgroundColor);
|
|
579
604
|
s.uniforms.uBgColor.value.set(
|
|
580
605
|
n.color.r,
|
|
581
606
|
n.color.g,
|
|
@@ -601,7 +626,7 @@ function le(s, e) {
|
|
|
601
626
|
n
|
|
602
627
|
);
|
|
603
628
|
} else if (typeof e.borderColor == "string") {
|
|
604
|
-
const n =
|
|
629
|
+
const n = ee(e.borderColor);
|
|
605
630
|
s.uniforms.uBorderColor.value.set(
|
|
606
631
|
n.color.r,
|
|
607
632
|
n.color.g,
|
|
@@ -618,9 +643,9 @@ function le(s, e) {
|
|
|
618
643
|
);
|
|
619
644
|
}
|
|
620
645
|
e.opacity !== void 0 && (s.uniforms.uOpacity.value = e.opacity), e.bgOpacity !== void 0 && (s.uniforms.uBgColor.value.w = e.bgOpacity), e.borderOpacity !== void 0 && (s.uniforms.uBorderColor.value.w = e.borderOpacity), s.uniforms.uTexture && e.texture !== void 0 && (s.uniforms.uTexture.value = e.texture);
|
|
621
|
-
const t = e.texture !== void 0 ? e.texture : (
|
|
646
|
+
const t = e.texture !== void 0 ? e.texture : (r = s.uniforms.uTexture) == null ? void 0 : r.value;
|
|
622
647
|
if (t && (t.image instanceof ImageBitmap || t.image instanceof HTMLImageElement || t.image instanceof HTMLCanvasElement)) {
|
|
623
|
-
const n = t.image.naturalWidth || t.image.videoWidth || t.image.width, o = t.image.naturalHeight || t.image.videoHeight || t.image.height, c = (
|
|
648
|
+
const n = t.image.naturalWidth || t.image.videoWidth || t.image.width, o = t.image.naturalHeight || t.image.videoHeight || t.image.height, c = (i = e.width) != null ? i : s.uniforms.uSize.value.x, l = (a = e.height) != null ? a : s.uniforms.uSize.value.y;
|
|
624
649
|
if (n && o && c && l) {
|
|
625
650
|
const d = n / o, h = c / l;
|
|
626
651
|
if (d > h) {
|
|
@@ -654,8 +679,8 @@ function le(s, e) {
|
|
|
654
679
|
for (const n of Object.keys(e))
|
|
655
680
|
n !== "width" && n !== "height" && n !== "borderRadius" && n !== "borderWidth" && n !== "backgroundColor" && n !== "borderColor" && n !== "opacity" && n !== "bgOpacity" && n !== "borderOpacity" && n !== "texture" && n !== "backgroundImage" && s.uniforms[n] !== void 0 && (s.uniforms[n].value !== void 0 && s.uniforms[n].value !== null && typeof s.uniforms[n].value.set == "function" ? Array.isArray(e[n]) ? s.uniforms[n].value.set(...e[n]) : e[n] !== void 0 && (e[n].copy ? s.uniforms[n].value.copy(e[n]) : s.uniforms[n].value = e[n]) : s.uniforms[n].value = e[n]);
|
|
656
681
|
}
|
|
657
|
-
function Me(s, e) {
|
|
658
|
-
var
|
|
682
|
+
function Me(s, e, t = 0) {
|
|
683
|
+
var c, l, d, h;
|
|
659
684
|
if (e == null) {
|
|
660
685
|
s.set(0, 0, 0, 0);
|
|
661
686
|
return;
|
|
@@ -668,36 +693,36 @@ function Me(s, e) {
|
|
|
668
693
|
s.set(e[0], e[1], e[2], e[3]);
|
|
669
694
|
return;
|
|
670
695
|
}
|
|
671
|
-
const
|
|
672
|
-
s.set(i,
|
|
696
|
+
const r = e.split("/")[0].trim().split(/\s+/), i = J(r[0], t), a = J((c = r[1]) != null ? c : r[0], t), n = J((l = r[2]) != null ? l : r[0], t), o = J((h = (d = r[3]) != null ? d : r[1]) != null ? h : r[0], t);
|
|
697
|
+
s.set(i, a, n, o);
|
|
673
698
|
}
|
|
674
|
-
const
|
|
675
|
-
create(s, e, t,
|
|
699
|
+
const z = {
|
|
700
|
+
create(s, e, t, r, i, a = 2, n = null, o) {
|
|
676
701
|
return s === "BOX" ? Qe(
|
|
677
702
|
e,
|
|
678
|
-
i,
|
|
679
703
|
r,
|
|
704
|
+
i,
|
|
680
705
|
n,
|
|
681
706
|
o
|
|
682
707
|
) : s === "TEXT" ? new He(
|
|
683
708
|
t || "",
|
|
684
709
|
e,
|
|
685
|
-
i,
|
|
686
710
|
r,
|
|
711
|
+
i,
|
|
687
712
|
a
|
|
688
|
-
) : new
|
|
713
|
+
) : new y.MeshBasicMaterial({ visible: !1 });
|
|
689
714
|
},
|
|
690
|
-
update(s, e, t,
|
|
715
|
+
update(s, e, t, r, i, a, n = 2, o) {
|
|
691
716
|
e === "BOX" ? Ze(
|
|
692
717
|
s,
|
|
693
718
|
t,
|
|
694
|
-
|
|
719
|
+
i,
|
|
695
720
|
a,
|
|
696
721
|
o
|
|
697
722
|
) : e === "TEXT" && s.updateText(
|
|
698
|
-
|
|
723
|
+
r || "",
|
|
699
724
|
t,
|
|
700
|
-
|
|
725
|
+
i,
|
|
701
726
|
a,
|
|
702
727
|
n
|
|
703
728
|
);
|
|
@@ -708,16 +733,16 @@ const N = {
|
|
|
708
733
|
};
|
|
709
734
|
class et {
|
|
710
735
|
constructor(e, t = !0) {
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
736
|
+
f(this, "observer");
|
|
737
|
+
f(this, "textures", /* @__PURE__ */ new WeakMap());
|
|
738
|
+
f(this, "loadStatus", /* @__PURE__ */ new WeakMap());
|
|
739
|
+
f(this, "elementUrls", /* @__PURE__ */ new WeakMap());
|
|
740
|
+
f(this, "onUpdate");
|
|
716
741
|
this.onUpdate = e, t && (this.observer = new IntersectionObserver(
|
|
717
|
-
(
|
|
718
|
-
for (const
|
|
719
|
-
const a =
|
|
720
|
-
|
|
742
|
+
(r) => {
|
|
743
|
+
for (const i of r) {
|
|
744
|
+
const a = i.target;
|
|
745
|
+
i.isIntersecting ? this.loadTexture(a) : this.disposeTexture(a);
|
|
721
746
|
}
|
|
722
747
|
},
|
|
723
748
|
{ rootMargin: "300px" }
|
|
@@ -732,31 +757,31 @@ class et {
|
|
|
732
757
|
e.nodeType === Node.ELEMENT_NODE && this.observer && this.observer.unobserve(e), this.disposeTexture(e), this.elementUrls.delete(e), this.loadStatus.delete(e);
|
|
733
758
|
}
|
|
734
759
|
loadTexture(e) {
|
|
735
|
-
return
|
|
760
|
+
return we(this, null, function* () {
|
|
736
761
|
if (this.loadStatus.get(e) || this.textures.has(e))
|
|
737
762
|
return;
|
|
738
763
|
const t = this.elementUrls.get(e);
|
|
739
764
|
if (t) {
|
|
740
765
|
this.loadStatus.set(e, !0);
|
|
741
766
|
try {
|
|
742
|
-
let
|
|
767
|
+
let r;
|
|
743
768
|
if (t.startsWith("data:image/svg+xml"))
|
|
744
|
-
|
|
769
|
+
r = yield new Promise((a, n) => {
|
|
745
770
|
const o = new Image();
|
|
746
771
|
o.onload = () => a(o), o.onerror = n, o.src = t;
|
|
747
772
|
});
|
|
748
773
|
else {
|
|
749
774
|
const n = yield (yield fetch(t)).blob();
|
|
750
|
-
|
|
775
|
+
r = yield createImageBitmap(n, { imageOrientation: "flipY" });
|
|
751
776
|
}
|
|
752
777
|
if (this.elementUrls.get(e) !== t) {
|
|
753
|
-
"close" in
|
|
778
|
+
"close" in r && r.close();
|
|
754
779
|
return;
|
|
755
780
|
}
|
|
756
|
-
const
|
|
757
|
-
|
|
758
|
-
} catch (
|
|
759
|
-
console.warn("[MirageEngine] Failed to load texture:", t,
|
|
781
|
+
const i = new y.Texture(r);
|
|
782
|
+
r instanceof HTMLImageElement || (i.flipY = !1), i.colorSpace = y.LinearSRGBColorSpace, i.needsUpdate = !0, this.textures.set(e, i), this.onUpdate(e, i);
|
|
783
|
+
} catch (r) {
|
|
784
|
+
console.warn("[MirageEngine] Failed to load texture:", t, r);
|
|
760
785
|
} finally {
|
|
761
786
|
this.elementUrls.has(e) && this.loadStatus.set(e, !1);
|
|
762
787
|
}
|
|
@@ -775,68 +800,68 @@ class et {
|
|
|
775
800
|
}
|
|
776
801
|
}
|
|
777
802
|
class tt {
|
|
778
|
-
constructor(e, t,
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
{ length:
|
|
803
|
+
constructor(e, t, r, i) {
|
|
804
|
+
f(this, "canvas");
|
|
805
|
+
f(this, "scene");
|
|
806
|
+
f(this, "camera");
|
|
807
|
+
f(this, "renderer");
|
|
808
|
+
f(this, "renderTargets", []);
|
|
809
|
+
f(this, "renderOrder", 0);
|
|
810
|
+
f(this, "qualityFactor", 2);
|
|
811
|
+
f(this, "mode", "overlay");
|
|
812
|
+
f(this, "canvasSize", "viewport");
|
|
813
|
+
f(this, "clipArea", 1);
|
|
814
|
+
f(this, "targetLayer", "base");
|
|
815
|
+
f(this, "overscan", 200);
|
|
816
|
+
f(this, "target");
|
|
817
|
+
f(this, "mountContainer");
|
|
818
|
+
f(this, "registry");
|
|
819
|
+
f(this, "targetRect");
|
|
820
|
+
f(this, "travelersByLayer", Array.from(
|
|
821
|
+
{ length: U.MAX_LAYERS },
|
|
797
822
|
() => /* @__PURE__ */ new Set()
|
|
798
823
|
));
|
|
799
|
-
|
|
824
|
+
f(this, "textureManager");
|
|
800
825
|
// private meshMap: Map<HTMLElement, THREE.Mesh> = new Map();
|
|
801
|
-
|
|
826
|
+
f(this, "fixedMeshes", /* @__PURE__ */ new Set());
|
|
802
827
|
var o, c, l, d, h;
|
|
803
|
-
this.target = e, this.mountContainer =
|
|
804
|
-
const
|
|
805
|
-
|
|
806
|
-
}, this.isViewport), this.canvas = document.createElement("canvas"), this.scene = new
|
|
828
|
+
this.target = e, this.mountContainer = r, this.registry = i, this.mode = (o = t.mode) != null ? o : "overlay", this.canvasSize = (c = t.canvasSize) != null ? c : "viewport", this.clipArea = (l = t.travelerClipArea) != null ? l : 1, this.targetLayer = (d = t.layer) != null ? d : "base", this.textureManager = new et((u, p) => {
|
|
829
|
+
const g = this.registry.get(u);
|
|
830
|
+
g && g.material instanceof y.ShaderMaterial && z.forceUpdateUniforms(g.material, { texture: p });
|
|
831
|
+
}, this.isViewport), this.canvas = document.createElement("canvas"), this.scene = new y.Scene(), this.targetRect = this.target.getBoundingClientRect();
|
|
807
832
|
const a = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, n = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
|
|
808
|
-
this.camera = new
|
|
833
|
+
this.camera = new y.OrthographicCamera(
|
|
809
834
|
a / -2,
|
|
810
835
|
a / 2,
|
|
811
836
|
n / 2,
|
|
812
837
|
n / -2,
|
|
813
838
|
1,
|
|
814
839
|
1e3
|
|
815
|
-
), this.camera.position.z = 100, this.camera.layers.set(this.getSceneLayer()), this.renderer = new
|
|
840
|
+
), this.camera.position.z = 100, this.camera.layers.set(this.getSceneLayer()), this.renderer = new y.WebGLRenderer({
|
|
816
841
|
canvas: this.canvas,
|
|
817
842
|
alpha: !0,
|
|
818
843
|
antialias: !0
|
|
819
844
|
// [new]
|
|
820
845
|
// premultipliedAlpha: true
|
|
821
|
-
}),
|
|
846
|
+
}), y.ColorManagement.enabled = !1, this.renderer.outputColorSpace = y.LinearSRGBColorSpace, this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setSize(a, n), this.applyTextQuality((h = t.quality) != null ? h : "medium");
|
|
822
847
|
}
|
|
823
848
|
get isViewport() {
|
|
824
849
|
return this.mode === "overlay" && this.canvasSize === "viewport";
|
|
825
850
|
}
|
|
826
851
|
getSceneLayer() {
|
|
827
|
-
return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ?
|
|
852
|
+
return typeof this.targetLayer == "number" ? this.targetLayer : this.targetLayer === "selected" ? D.SELECTED : D.BASE;
|
|
828
853
|
}
|
|
829
854
|
createRenderTarget() {
|
|
830
|
-
for (let e = 0; e <
|
|
831
|
-
const t = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width,
|
|
855
|
+
for (let e = 0; e < U.MAX_LAYERS; e++) {
|
|
856
|
+
const t = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, r = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
|
|
832
857
|
this.renderTargets.push(
|
|
833
|
-
new
|
|
858
|
+
new y.WebGLRenderTarget(
|
|
834
859
|
t * this.qualityFactor,
|
|
835
|
-
|
|
860
|
+
r * this.qualityFactor,
|
|
836
861
|
{
|
|
837
|
-
minFilter:
|
|
838
|
-
magFilter:
|
|
839
|
-
format:
|
|
862
|
+
minFilter: y.LinearFilter,
|
|
863
|
+
magFilter: y.LinearFilter,
|
|
864
|
+
format: y.RGBAFormat,
|
|
840
865
|
stencilBuffer: !1,
|
|
841
866
|
depthBuffer: !0
|
|
842
867
|
}
|
|
@@ -872,15 +897,15 @@ class tt {
|
|
|
872
897
|
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");
|
|
873
898
|
}
|
|
874
899
|
updateUniforms(e, t) {
|
|
875
|
-
const
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
900
|
+
const r = this.registry.get(e);
|
|
901
|
+
r && (r.traverse((i) => {
|
|
902
|
+
i.isMesh && i.material && z.forceUpdateUniforms(
|
|
903
|
+
i.material,
|
|
879
904
|
t
|
|
880
905
|
);
|
|
881
|
-
}),
|
|
882
|
-
|
|
883
|
-
|
|
906
|
+
}), r.userData.nativeMesh && r.userData.nativeMesh.traverse((i) => {
|
|
907
|
+
i.isMesh && i.material && z.forceUpdateUniforms(
|
|
908
|
+
i.material,
|
|
884
909
|
t
|
|
885
910
|
);
|
|
886
911
|
}));
|
|
@@ -890,13 +915,13 @@ class tt {
|
|
|
890
915
|
}
|
|
891
916
|
setSize(e, t) {
|
|
892
917
|
this.renderer.setSize(e, t);
|
|
893
|
-
for (const
|
|
894
|
-
|
|
918
|
+
for (const r of this.renderTargets)
|
|
919
|
+
r.setSize(e * this.qualityFactor, t * this.qualityFactor);
|
|
895
920
|
this.camera.left = e / -2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = t / -2, this.camera.updateProjectionMatrix();
|
|
896
921
|
}
|
|
897
922
|
syncScene(e, t) {
|
|
898
|
-
const
|
|
899
|
-
c ? (this.targetRect =
|
|
923
|
+
const r = this.target.getBoundingClientRect(), i = this.isViewport ? window.innerWidth + this.overscan * 2 : r.width, a = this.isViewport ? window.innerHeight + this.overscan * 2 : r.height, n = this.isViewport ? this.canvas.clientWidth : this.targetRect.width, o = this.isViewport ? this.canvas.clientHeight : this.targetRect.height, c = Math.abs(i - n) > 0.1 || Math.abs(a - o) > 0.1, l = this.mode === "overlay" && (Math.abs(r.top - this.targetRect.top) > 0.1 || Math.abs(r.left - this.targetRect.left) > 0.1);
|
|
924
|
+
c ? (this.targetRect = r, this.setSize(i, a), this.updateCanvasLayout()) : l ? (this.targetRect = r, this.updateCanvasLayout()) : this.targetRect = r, this.renderOrder = 0, this.reconcileNode(e), t.size > 0 && t.forEach((d) => {
|
|
900
925
|
const h = this.registry.get(d);
|
|
901
926
|
if (h) {
|
|
902
927
|
this.scene.remove(h);
|
|
@@ -905,7 +930,7 @@ class tt {
|
|
|
905
930
|
this.fixedMeshes.delete(h), h.geometry.dispose(), h.userData.nativeMesh && (this.scene.remove(h.userData.nativeMesh), Array.isArray(h.userData.nativeMesh.material) ? h.userData.nativeMesh.material.forEach(
|
|
906
931
|
(u) => u.dispose()
|
|
907
932
|
) : h.userData.nativeMesh.material.dispose(), h.userData.nativeMesh.geometry.dispose()), h.traverse((u) => {
|
|
908
|
-
u instanceof
|
|
933
|
+
u instanceof y.Mesh && (u.geometry && u.geometry.dispose(), u.material && (Array.isArray(u.material) ? u.material.forEach((p) => p.dispose()) : u.material.dispose()));
|
|
909
934
|
}), this.registry.remove(d), this.textureManager.unregister(d);
|
|
910
935
|
}
|
|
911
936
|
});
|
|
@@ -915,11 +940,11 @@ class tt {
|
|
|
915
940
|
// => 이후 activeElements를 이용하여 mesh를 정리!!!+ map에서도 삭제
|
|
916
941
|
// private reconcileNode(node: SceneNode, activeElements: Set<HTMLElement>) {
|
|
917
942
|
reconcileNode(e) {
|
|
918
|
-
var
|
|
943
|
+
var i;
|
|
919
944
|
let t = this.registry.get(e.element);
|
|
920
|
-
const
|
|
921
|
-
if (t && t.userData.shaderHash !==
|
|
922
|
-
const a = new
|
|
945
|
+
const r = JSON.stringify(e.shaderHooks || null);
|
|
946
|
+
if (t && t.userData.shaderHash !== r && (this.scene.remove(t), t.geometry.dispose(), t.material instanceof y.Material && t.material.dispose(), this.registry.remove(e.element), t = void 0), !t) {
|
|
947
|
+
const a = new y.PlaneGeometry(1, 1), n = e.isTraveler ? (i = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : i.texture : this.textureManager.get(e.element), o = z.create(
|
|
923
948
|
"BOX",
|
|
924
949
|
e.styles,
|
|
925
950
|
"",
|
|
@@ -929,10 +954,10 @@ class tt {
|
|
|
929
954
|
n,
|
|
930
955
|
e.shaderHooks
|
|
931
956
|
);
|
|
932
|
-
t = new
|
|
957
|
+
t = new y.Mesh(a, o), e.type === "TEXT" && (t.name = "BG_MESH"), this.scene.add(t), this.registry.register(e.element, t), t.userData.baseMaterial = o, t.userData.domElement = e.element, t.userData.shaderHash = r;
|
|
933
958
|
}
|
|
934
959
|
if (this.updateMeshProperties(t, e), this.updateMeshLayers(t, e), e.isTraveler)
|
|
935
|
-
for (let a = 0; a <
|
|
960
|
+
for (let a = 0; a < U.MAX_LAYERS; a++)
|
|
936
961
|
a === e.captureLayer - 2 ? this.travelersByLayer[a].add(t) : this.travelersByLayer[a].delete(t);
|
|
937
962
|
else
|
|
938
963
|
for (const a of this.travelersByLayer)
|
|
@@ -947,179 +972,179 @@ class tt {
|
|
|
947
972
|
!0
|
|
948
973
|
));
|
|
949
974
|
}
|
|
950
|
-
reconcileTextChild(e, t,
|
|
975
|
+
reconcileTextChild(e, t, r) {
|
|
951
976
|
var l;
|
|
952
|
-
const
|
|
977
|
+
const i = t.textLines || [
|
|
953
978
|
{ text: t.textContent || "", rect: t.rect }
|
|
954
|
-
], a =
|
|
979
|
+
], a = r ? t.nativeStyles : t.textStyles, n = JSON.stringify(a) + t.textContent + i.map((d) => d.text).join("|"), o = (l = e.userData) == null ? void 0 : l.textChildStyleHash;
|
|
955
980
|
if (t.dirtyMask & ce || n !== o) {
|
|
956
981
|
e.children.filter(
|
|
957
|
-
(
|
|
958
|
-
).forEach((
|
|
959
|
-
var
|
|
960
|
-
const
|
|
961
|
-
(
|
|
982
|
+
(g) => g.name.startsWith("TEXT_CHILD")
|
|
983
|
+
).forEach((g) => {
|
|
984
|
+
var x;
|
|
985
|
+
const v = g;
|
|
986
|
+
(x = v.material.map) == null || x.dispose(), v.geometry.dispose(), e.remove(v);
|
|
962
987
|
});
|
|
963
988
|
const h = t.rect, u = h.x + h.width / 2, p = h.y + h.height / 2;
|
|
964
|
-
|
|
965
|
-
const
|
|
989
|
+
i.forEach((g, v) => {
|
|
990
|
+
const x = z.create(
|
|
966
991
|
"TEXT",
|
|
967
992
|
a,
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
993
|
+
g.text,
|
|
994
|
+
g.rect.width,
|
|
995
|
+
g.rect.height,
|
|
971
996
|
this.qualityFactor
|
|
972
|
-
),
|
|
973
|
-
|
|
974
|
-
const
|
|
975
|
-
|
|
976
|
-
const
|
|
977
|
-
|
|
997
|
+
), M = new y.PlaneGeometry(1, 1), A = new y.Mesh(M, x);
|
|
998
|
+
A.name = `TEXT_CHILD_${v}`;
|
|
999
|
+
const S = t.rect.width === 0 ? 1 : g.rect.width / t.rect.width, E = t.rect.height === 0 ? 1 : g.rect.height / t.rect.height;
|
|
1000
|
+
A.scale.set(S, E, 1);
|
|
1001
|
+
const C = g.rect.x + g.rect.width / 2, b = g.rect.y + g.rect.height / 2, O = C - u, X = -(b - p);
|
|
1002
|
+
A.position.set(
|
|
978
1003
|
t.rect.width === 0 ? 0 : O / t.rect.width,
|
|
979
1004
|
t.rect.height === 0 ? 0 : X / t.rect.height,
|
|
980
1005
|
5e-3
|
|
981
|
-
), e.add(
|
|
1006
|
+
), e.add(A);
|
|
982
1007
|
}), e.userData.textChildStyleHash = n;
|
|
983
1008
|
}
|
|
984
1009
|
e.children.forEach((d) => {
|
|
985
1010
|
if (!d.name.startsWith("TEXT_CHILD"))
|
|
986
1011
|
return;
|
|
987
|
-
const h = d, u = t.visibility & W ?
|
|
988
|
-
if (h.layers.set(u), t.visibility &
|
|
989
|
-
if (!
|
|
1012
|
+
const h = d, u = t.visibility & W ? D.BASE : D.HIDDEN;
|
|
1013
|
+
if (h.layers.set(u), t.visibility & K && h.layers.enable(D.SELECTED), t.visibility & W)
|
|
1014
|
+
if (!r && t.nativeLayer !== void 0 && t.nativeStyles !== void 0)
|
|
990
1015
|
for (let p = t.captureLayer; p < t.nativeLayer; p++)
|
|
991
|
-
h.layers.enable(
|
|
992
|
-
else if (
|
|
993
|
-
for (let p = Math.max(t.captureLayer, t.nativeLayer); p <=
|
|
994
|
-
h.layers.enable(
|
|
1016
|
+
h.layers.enable(D.getCaptureLayer(p));
|
|
1017
|
+
else if (r && t.nativeLayer !== void 0)
|
|
1018
|
+
for (let p = Math.max(t.captureLayer, t.nativeLayer); p <= U.MAX_LAYERS + 1; p++)
|
|
1019
|
+
h.layers.enable(D.getCaptureLayer(p));
|
|
995
1020
|
else
|
|
996
|
-
for (let p = t.captureLayer; p <=
|
|
997
|
-
h.layers.enable(
|
|
1021
|
+
for (let p = t.captureLayer; p <= U.MAX_LAYERS + 1; p++)
|
|
1022
|
+
h.layers.enable(D.getCaptureLayer(p));
|
|
998
1023
|
});
|
|
999
1024
|
}
|
|
1000
1025
|
updateMeshProperties(e, t) {
|
|
1001
|
-
var
|
|
1002
|
-
const { rect:
|
|
1003
|
-
e.material = e.userData.baseMaterial, e.scale.set(
|
|
1004
|
-
x:
|
|
1005
|
-
y:
|
|
1006
|
-
width:
|
|
1007
|
-
height:
|
|
1026
|
+
var S, E, C;
|
|
1027
|
+
const { rect: r, styles: i } = t, a = this.renderer.getPixelRatio(), n = this.renderer.domElement.width / a, o = this.renderer.domElement.height / a;
|
|
1028
|
+
e.material = e.userData.baseMaterial, e.scale.set(r.width, r.height, 1), e.userData.domRect = {
|
|
1029
|
+
x: r.x,
|
|
1030
|
+
y: r.y,
|
|
1031
|
+
width: r.width,
|
|
1032
|
+
height: r.height
|
|
1008
1033
|
};
|
|
1009
1034
|
const c = 1e-3;
|
|
1010
1035
|
this.renderOrder++;
|
|
1011
1036
|
const l = this.targetRect.left + window.scrollX, d = this.targetRect.top + window.scrollY;
|
|
1012
1037
|
let h, u;
|
|
1013
1038
|
if (this.isViewport)
|
|
1014
|
-
h =
|
|
1039
|
+
h = r.x - window.innerWidth / 2 + r.width / 2, u = -r.y + window.innerHeight / 2 - r.height / 2;
|
|
1015
1040
|
else {
|
|
1016
|
-
const
|
|
1017
|
-
h =
|
|
1041
|
+
const b = r.x - l, O = r.y - d;
|
|
1042
|
+
h = b - n / 2 + r.width / 2, u = -O + o / 2 - r.height / 2;
|
|
1018
1043
|
}
|
|
1019
1044
|
e.position.set(
|
|
1020
1045
|
h,
|
|
1021
1046
|
u,
|
|
1022
|
-
|
|
1047
|
+
i.zIndex + this.renderOrder * c
|
|
1023
1048
|
);
|
|
1024
|
-
const p =
|
|
1025
|
-
e.userData.basePosition = { x: h, y: u }, e.userData.originalBasePosition = { x: h, y: u }, e.userData.baseSize = { width:
|
|
1026
|
-
const
|
|
1027
|
-
let
|
|
1028
|
-
if (
|
|
1029
|
-
const
|
|
1030
|
-
|
|
1049
|
+
const p = r.x, g = r.y;
|
|
1050
|
+
e.userData.basePosition = { x: h, y: u }, e.userData.originalBasePosition = { x: h, y: u }, e.userData.baseSize = { width: r.width, height: r.height }, e.userData.baseDOM = { x: p, y: g }, e.userData.isFixed = t.isFixed, e.userData.initialScroll = { x: window.scrollX, y: window.scrollY };
|
|
1051
|
+
const v = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element, x = window.getComputedStyle(v);
|
|
1052
|
+
let M = 0, A = 0;
|
|
1053
|
+
if (x.transform && x.transform !== "none") {
|
|
1054
|
+
const b = new DOMMatrix(x.transform);
|
|
1055
|
+
M = b.m41, A = b.m42;
|
|
1031
1056
|
}
|
|
1032
|
-
if (e.userData.baseTransform = { x:
|
|
1057
|
+
if (e.userData.baseTransform = { x: M, y: A }, delete e.userData.originRatioX, delete e.userData.originRatioY, z.update(
|
|
1033
1058
|
e.userData.baseMaterial,
|
|
1034
1059
|
"BOX",
|
|
1035
|
-
|
|
1060
|
+
i,
|
|
1036
1061
|
"",
|
|
1037
|
-
|
|
1038
|
-
|
|
1062
|
+
r.width,
|
|
1063
|
+
r.height,
|
|
1039
1064
|
this.qualityFactor,
|
|
1040
|
-
t.isTraveler ? (
|
|
1065
|
+
t.isTraveler ? (S = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : S.texture : this.textureManager.get(t.element)
|
|
1041
1066
|
), t.nativeStyles && t.nativeRect) {
|
|
1042
1067
|
if (!e.userData.nativeMesh) {
|
|
1043
|
-
const
|
|
1068
|
+
const k = z.create(
|
|
1044
1069
|
"BOX",
|
|
1045
1070
|
t.nativeStyles,
|
|
1046
1071
|
"",
|
|
1047
1072
|
t.nativeRect.width,
|
|
1048
1073
|
t.nativeRect.height,
|
|
1049
1074
|
this.qualityFactor,
|
|
1050
|
-
t.isTraveler ? (
|
|
1075
|
+
t.isTraveler ? (E = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : E.texture : this.textureManager.get(t.element),
|
|
1051
1076
|
t.shaderHooks
|
|
1052
|
-
),
|
|
1053
|
-
t.type === "TEXT" && (
|
|
1077
|
+
), G = new y.Mesh(e.geometry, k);
|
|
1078
|
+
t.type === "TEXT" && (G.name = "BG_MESH"), this.scene.add(G), e.userData.nativeMesh = G;
|
|
1054
1079
|
}
|
|
1055
|
-
const
|
|
1080
|
+
const b = e.userData.nativeMesh;
|
|
1056
1081
|
let O, X;
|
|
1057
1082
|
if (this.isViewport)
|
|
1058
1083
|
O = t.nativeRect.x - window.innerWidth / 2 + t.nativeRect.width / 2, X = -t.nativeRect.y + window.innerHeight / 2 - t.nativeRect.height / 2;
|
|
1059
1084
|
else {
|
|
1060
|
-
const
|
|
1061
|
-
O =
|
|
1085
|
+
const k = t.nativeRect.x - l, G = t.nativeRect.y - d;
|
|
1086
|
+
O = k - n / 2 + t.nativeRect.width / 2, X = -G + o / 2 - t.nativeRect.height / 2;
|
|
1062
1087
|
}
|
|
1063
|
-
|
|
1088
|
+
b.scale.set(t.nativeRect.width, t.nativeRect.height, 1), b.position.set(
|
|
1064
1089
|
O,
|
|
1065
1090
|
X,
|
|
1066
1091
|
t.nativeStyles.zIndex + this.renderOrder * c
|
|
1067
|
-
),
|
|
1068
|
-
|
|
1092
|
+
), z.update(
|
|
1093
|
+
b.material,
|
|
1069
1094
|
"BOX",
|
|
1070
1095
|
t.nativeStyles,
|
|
1071
1096
|
"",
|
|
1072
1097
|
t.nativeRect.width,
|
|
1073
1098
|
t.nativeRect.height,
|
|
1074
1099
|
this.qualityFactor,
|
|
1075
|
-
t.isTraveler ? (
|
|
1100
|
+
t.isTraveler ? (C = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : C.texture : this.textureManager.get(t.element)
|
|
1076
1101
|
);
|
|
1077
1102
|
} else
|
|
1078
|
-
e.userData.nativeMesh && (this.scene.remove(e.userData.nativeMesh), e.userData.nativeMesh.material instanceof
|
|
1103
|
+
e.userData.nativeMesh && (this.scene.remove(e.userData.nativeMesh), e.userData.nativeMesh.material instanceof y.Material && e.userData.nativeMesh.material.dispose(), delete e.userData.nativeMesh);
|
|
1079
1104
|
}
|
|
1080
1105
|
updateMeshLayers(e, t) {
|
|
1081
|
-
const
|
|
1082
|
-
if (e.layers.set(
|
|
1083
|
-
const
|
|
1084
|
-
if (
|
|
1106
|
+
const r = t.visibility & W ? D.BASE : D.HIDDEN;
|
|
1107
|
+
if (e.layers.set(r), t.visibility & K && e.layers.enable(D.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
|
|
1108
|
+
const i = e.userData.nativeMesh;
|
|
1109
|
+
if (i.layers.set(D.HIDDEN), t.visibility & W) {
|
|
1085
1110
|
for (let a = t.captureLayer; a < t.nativeLayer; a++)
|
|
1086
|
-
e.layers.enable(
|
|
1087
|
-
for (let a = Math.max(t.captureLayer, t.nativeLayer); a <=
|
|
1088
|
-
|
|
1111
|
+
e.layers.enable(D.getCaptureLayer(a));
|
|
1112
|
+
for (let a = Math.max(t.captureLayer, t.nativeLayer); a <= U.MAX_LAYERS + 1; a++)
|
|
1113
|
+
i.layers.enable(D.getCaptureLayer(a));
|
|
1089
1114
|
}
|
|
1090
1115
|
} else if (t.visibility & W)
|
|
1091
|
-
for (let
|
|
1092
|
-
e.layers.enable(
|
|
1116
|
+
for (let i = t.captureLayer; i <= U.MAX_LAYERS + 1; i++)
|
|
1117
|
+
e.layers.enable(D.getCaptureLayer(i));
|
|
1093
1118
|
}
|
|
1094
|
-
captureRenderTarget(e, t,
|
|
1095
|
-
if (e.size === 0 || !
|
|
1119
|
+
captureRenderTarget(e, t, r) {
|
|
1120
|
+
if (e.size === 0 || !r)
|
|
1096
1121
|
return;
|
|
1097
|
-
const
|
|
1098
|
-
this.renderer.getClearColor(
|
|
1099
|
-
const n = new
|
|
1122
|
+
const i = new y.Color(), a = this.renderer.getClearAlpha();
|
|
1123
|
+
this.renderer.getClearColor(i), this.renderer.setClearColor(0, 0), this.renderer.setRenderTarget(r), this.renderer.clear(), this.renderer.autoClear = !1, this.renderer.setScissorTest(!0), this.camera.layers.set(t);
|
|
1124
|
+
const n = new y.Vector3(), o = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, c = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height, l = this.renderer.getPixelRatio();
|
|
1100
1125
|
for (const d of e) {
|
|
1101
1126
|
n.setFromMatrixPosition(d.matrixWorld), n.project(this.camera);
|
|
1102
1127
|
const h = (n.x + 1) / 2 * o, u = (n.y + 1) / 2 * c;
|
|
1103
|
-
let p = 0,
|
|
1104
|
-
typeof this.clipArea == "number" ?
|
|
1105
|
-
const
|
|
1106
|
-
this.renderer.setScissor(
|
|
1128
|
+
let p = 0, g = 1;
|
|
1129
|
+
typeof this.clipArea == "number" ? g = this.clipArea : this.clipArea.endsWith("%") ? g = parseFloat(this.clipArea) / 100 : this.clipArea.endsWith("px") && (p = parseFloat(this.clipArea));
|
|
1130
|
+
const v = d.scale.x * g + 0.5, x = d.scale.y * g + 0.5, M = h - v / 2, A = u - x / 2, S = (M * this.qualityFactor - p) / l, E = (A * this.qualityFactor - p) / l, C = (v * this.qualityFactor + p * 2) / l, b = (x * this.qualityFactor + p * 2) / l;
|
|
1131
|
+
this.renderer.setScissor(S, E, C, b), this.renderer.render(this.scene, this.camera);
|
|
1107
1132
|
}
|
|
1108
|
-
this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(
|
|
1133
|
+
this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(i, a);
|
|
1109
1134
|
}
|
|
1110
1135
|
render() {
|
|
1111
|
-
for (let e = 0; e <
|
|
1136
|
+
for (let e = 0; e < U.MAX_LAYERS; e++) {
|
|
1112
1137
|
const t = e + 1;
|
|
1113
1138
|
this.captureRenderTarget(
|
|
1114
1139
|
this.travelersByLayer[e],
|
|
1115
|
-
|
|
1140
|
+
D.getCaptureLayer(t),
|
|
1116
1141
|
this.renderTargets[e]
|
|
1117
1142
|
);
|
|
1118
1143
|
}
|
|
1119
1144
|
this.renderer.render(this.scene, this.camera);
|
|
1120
1145
|
}
|
|
1121
1146
|
syncMeshesByDOM() {
|
|
1122
|
-
const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY,
|
|
1147
|
+
const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, r = this.renderer.getPixelRatio(), i = this.renderer.domElement.width / r, a = this.renderer.domElement.height / r;
|
|
1123
1148
|
this.scene.children.forEach((n) => {
|
|
1124
1149
|
const o = n;
|
|
1125
1150
|
if (!o.userData || !o.userData.domElement)
|
|
@@ -1145,15 +1170,15 @@ class tt {
|
|
|
1145
1170
|
if (this.isViewport)
|
|
1146
1171
|
h = l.x - window.innerWidth / 2 + l.width / 2, u = -l.y + window.innerHeight / 2 - l.height / 2;
|
|
1147
1172
|
else {
|
|
1148
|
-
const p = l.x - e,
|
|
1149
|
-
h = p -
|
|
1173
|
+
const p = l.x - e, g = l.y - t;
|
|
1174
|
+
h = p - i / 2 + l.width / 2, u = -g + a / 2 - l.height / 2;
|
|
1150
1175
|
}
|
|
1151
|
-
if (o.position.setX(h), o.position.setY(u), o.scale.set(l.width, l.height, 1), o.material instanceof
|
|
1176
|
+
if (o.position.setX(h), o.position.setY(u), o.scale.set(l.width, l.height, 1), o.updateMatrixWorld(), o.material instanceof y.ShaderMaterial && z.forceUpdateUniforms(o.material, {
|
|
1152
1177
|
width: l.width,
|
|
1153
1178
|
height: l.height
|
|
1154
1179
|
}), o.userData.nativeMesh) {
|
|
1155
1180
|
const p = o.userData.nativeMesh;
|
|
1156
|
-
p.position.setX(h), p.position.setY(u), p.scale.set(l.width, l.height, 1);
|
|
1181
|
+
p.position.setX(h), p.position.setY(u), p.scale.set(l.width, l.height, 1), p.updateMatrixWorld();
|
|
1157
1182
|
}
|
|
1158
1183
|
}
|
|
1159
1184
|
});
|
|
@@ -1161,32 +1186,32 @@ class tt {
|
|
|
1161
1186
|
}
|
|
1162
1187
|
function rt(s) {
|
|
1163
1188
|
const e = s.textContent || "", t = [];
|
|
1164
|
-
let
|
|
1189
|
+
let r = "", i = null, a = -1;
|
|
1165
1190
|
const n = (l, d) => {
|
|
1166
1191
|
for (let h = 0; h < l.length; h++) {
|
|
1167
1192
|
const u = l[h], p = document.createRange();
|
|
1168
1193
|
p.setStart(s, d + h), p.setEnd(s, d + h + 1);
|
|
1169
|
-
const
|
|
1170
|
-
if (
|
|
1171
|
-
|
|
1194
|
+
const g = p.getBoundingClientRect();
|
|
1195
|
+
if (g.width === 0 && g.height === 0) {
|
|
1196
|
+
r += u;
|
|
1172
1197
|
continue;
|
|
1173
1198
|
}
|
|
1174
|
-
a === -1 || Math.abs(
|
|
1175
|
-
text:
|
|
1199
|
+
a === -1 || Math.abs(g.top - a) > g.height / 2 ? (r && i && t.push({
|
|
1200
|
+
text: r,
|
|
1176
1201
|
rect: {
|
|
1177
|
-
left:
|
|
1178
|
-
top:
|
|
1179
|
-
width:
|
|
1180
|
-
height:
|
|
1202
|
+
left: i.left,
|
|
1203
|
+
top: i.top,
|
|
1204
|
+
width: i.right - i.left,
|
|
1205
|
+
height: i.bottom - i.top
|
|
1181
1206
|
}
|
|
1182
|
-
}),
|
|
1183
|
-
left:
|
|
1184
|
-
top:
|
|
1185
|
-
right:
|
|
1186
|
-
bottom:
|
|
1187
|
-
}, a =
|
|
1188
|
-
|
|
1189
|
-
|
|
1207
|
+
}), r = u, i = {
|
|
1208
|
+
left: g.left,
|
|
1209
|
+
top: g.top,
|
|
1210
|
+
right: g.right,
|
|
1211
|
+
bottom: g.bottom
|
|
1212
|
+
}, a = g.top) : (r += u, i && (i.left = Math.min(i.left, g.left), i.top = Math.min(i.top, g.top), i.right = Math.max(i.right, g.right), i.bottom = Math.max(
|
|
1213
|
+
i.bottom,
|
|
1214
|
+
g.bottom
|
|
1190
1215
|
)));
|
|
1191
1216
|
}
|
|
1192
1217
|
}, o = e.match(/[^\s\-]+\-?|\-|\s+/g) || [];
|
|
@@ -1200,36 +1225,36 @@ function rt(s) {
|
|
|
1200
1225
|
else {
|
|
1201
1226
|
const u = h.length === 1 ? h[0] : d.getBoundingClientRect();
|
|
1202
1227
|
if (u.width === 0 && u.height === 0) {
|
|
1203
|
-
|
|
1228
|
+
r += l, c += l.length;
|
|
1204
1229
|
continue;
|
|
1205
1230
|
}
|
|
1206
|
-
a === -1 || Math.abs(u.top - a) > u.height / 2 ? (
|
|
1207
|
-
text:
|
|
1231
|
+
a === -1 || Math.abs(u.top - a) > u.height / 2 ? (r && i && t.push({
|
|
1232
|
+
text: r,
|
|
1208
1233
|
rect: {
|
|
1209
|
-
left:
|
|
1210
|
-
top:
|
|
1211
|
-
width:
|
|
1212
|
-
height:
|
|
1234
|
+
left: i.left,
|
|
1235
|
+
top: i.top,
|
|
1236
|
+
width: i.right - i.left,
|
|
1237
|
+
height: i.bottom - i.top
|
|
1213
1238
|
}
|
|
1214
|
-
}),
|
|
1239
|
+
}), r = l, i = {
|
|
1215
1240
|
left: u.left,
|
|
1216
1241
|
top: u.top,
|
|
1217
1242
|
right: u.right,
|
|
1218
1243
|
bottom: u.bottom
|
|
1219
|
-
}, a = u.top) : (
|
|
1220
|
-
|
|
1244
|
+
}, a = u.top) : (r += l, i && (i.left = Math.min(i.left, u.left), i.top = Math.min(i.top, u.top), i.right = Math.max(i.right, u.right), i.bottom = Math.max(
|
|
1245
|
+
i.bottom,
|
|
1221
1246
|
u.bottom
|
|
1222
1247
|
)));
|
|
1223
1248
|
}
|
|
1224
1249
|
c += l.length;
|
|
1225
1250
|
}
|
|
1226
|
-
return
|
|
1227
|
-
text:
|
|
1251
|
+
return r && i && t.push({
|
|
1252
|
+
text: r,
|
|
1228
1253
|
rect: {
|
|
1229
|
-
left:
|
|
1230
|
-
top:
|
|
1231
|
-
width:
|
|
1232
|
-
height:
|
|
1254
|
+
left: i.left,
|
|
1255
|
+
top: i.top,
|
|
1256
|
+
width: i.right - i.left,
|
|
1257
|
+
height: i.bottom - i.top
|
|
1233
1258
|
}
|
|
1234
1259
|
}), t.filter(
|
|
1235
1260
|
(l) => l.text.trim().length > 0 && l.rect.width > 0 && l.rect.height > 0
|
|
@@ -1239,8 +1264,8 @@ function Se(s) {
|
|
|
1239
1264
|
const e = parseFloat(s.fontSize);
|
|
1240
1265
|
let t = parseFloat(s.lineHeight);
|
|
1241
1266
|
isNaN(t) && (t = e * 1.2);
|
|
1242
|
-
let
|
|
1243
|
-
return isNaN(
|
|
1267
|
+
let r = parseFloat(s.letterSpacing);
|
|
1268
|
+
return isNaN(r) && (r = 0), {
|
|
1244
1269
|
font: `${s.fontStyle} ${s.fontWeight} ${s.fontSize} ${s.fontFamily}`,
|
|
1245
1270
|
fontSize: s.fontSize,
|
|
1246
1271
|
color: s.color,
|
|
@@ -1248,291 +1273,303 @@ function Se(s) {
|
|
|
1248
1273
|
textBaseline: "alphabetic",
|
|
1249
1274
|
direction: s.direction || "inherit",
|
|
1250
1275
|
lineHeight: t,
|
|
1251
|
-
letterSpacing:
|
|
1276
|
+
letterSpacing: r
|
|
1252
1277
|
};
|
|
1253
1278
|
}
|
|
1254
|
-
function Ae(s, e = $ |
|
|
1279
|
+
function Ae(s, e = $ | Z | Xe | ce | ie, t, r = 1, i = 0, a = 2, n, o) {
|
|
1255
1280
|
var de, ue, fe, ge, pe, me;
|
|
1256
1281
|
if (s.nodeType === Node.TEXT_NODE) {
|
|
1257
|
-
const
|
|
1258
|
-
if (!
|
|
1282
|
+
const m = s;
|
|
1283
|
+
if (!m.textContent || !m.textContent.trim())
|
|
1259
1284
|
return null;
|
|
1260
|
-
const
|
|
1261
|
-
if (
|
|
1285
|
+
const R = m.textContent.replace(/\s+/g, " ");
|
|
1286
|
+
if (R.length === 0)
|
|
1262
1287
|
return null;
|
|
1263
|
-
const
|
|
1264
|
-
if (
|
|
1288
|
+
const I = rt(m);
|
|
1289
|
+
if (I.length === 0)
|
|
1265
1290
|
return null;
|
|
1266
|
-
const
|
|
1267
|
-
if (!
|
|
1291
|
+
const F = m.parentElement, L = F ? window.getComputedStyle(F) : null;
|
|
1292
|
+
if (!L)
|
|
1268
1293
|
return null;
|
|
1269
|
-
const
|
|
1294
|
+
const V = Math.min(...I.map((w) => w.rect.left)), B = Math.min(...I.map((w) => w.rect.top)), H = Math.max(...I.map((w) => w.rect.left + w.rect.width)), T = Math.max(...I.map((w) => w.rect.top + w.rect.height));
|
|
1270
1295
|
return {
|
|
1271
1296
|
id: Math.random().toString(36).substring(2, 9),
|
|
1272
1297
|
type: "TEXT",
|
|
1273
|
-
element:
|
|
1298
|
+
element: m,
|
|
1274
1299
|
rect: {
|
|
1275
|
-
x:
|
|
1276
|
-
y:
|
|
1277
|
-
width:
|
|
1278
|
-
height:
|
|
1300
|
+
x: V + window.scrollX,
|
|
1301
|
+
y: B + window.scrollY,
|
|
1302
|
+
width: H - V,
|
|
1303
|
+
height: T - B
|
|
1279
1304
|
},
|
|
1280
1305
|
styles: {
|
|
1281
1306
|
backgroundColor: "transparent",
|
|
1282
1307
|
backgroundImage: "",
|
|
1283
|
-
opacity:
|
|
1284
|
-
zIndex: (isNaN(parseInt(
|
|
1308
|
+
opacity: F && F.dataset[P.KEY] === P.VALUES.HIDE ? 1 : parseFloat(L.opacity),
|
|
1309
|
+
zIndex: (isNaN(parseInt(L.zIndex)) ? 0 : parseInt(L.zIndex)) + i,
|
|
1285
1310
|
borderRadius: "0px",
|
|
1286
1311
|
borderColor: "transparent",
|
|
1287
1312
|
borderWidth: "0px",
|
|
1288
1313
|
isTraveler: !1
|
|
1289
1314
|
},
|
|
1290
|
-
textContent:
|
|
1291
|
-
textLines:
|
|
1292
|
-
text:
|
|
1315
|
+
textContent: R,
|
|
1316
|
+
textLines: I.map((w) => ({
|
|
1317
|
+
text: w.text.trim(),
|
|
1293
1318
|
rect: {
|
|
1294
|
-
x:
|
|
1295
|
-
y:
|
|
1296
|
-
width:
|
|
1297
|
-
height:
|
|
1319
|
+
x: w.rect.left + window.scrollX,
|
|
1320
|
+
y: w.rect.top + window.scrollY,
|
|
1321
|
+
width: w.rect.width,
|
|
1322
|
+
height: w.rect.height
|
|
1298
1323
|
}
|
|
1299
1324
|
})),
|
|
1300
|
-
textStyles: Se(
|
|
1325
|
+
textStyles: Se(L),
|
|
1301
1326
|
dirtyMask: e,
|
|
1302
1327
|
visibility: t,
|
|
1303
1328
|
isTraveler: !1,
|
|
1304
|
-
captureLayer:
|
|
1305
|
-
isFixed:
|
|
1329
|
+
captureLayer: r,
|
|
1330
|
+
isFixed: L.position === "fixed",
|
|
1306
1331
|
nativeLayer: n,
|
|
1307
1332
|
nativeStyles: o ? q(q({
|
|
1308
1333
|
backgroundColor: "transparent",
|
|
1309
1334
|
backgroundImage: "",
|
|
1310
|
-
opacity:
|
|
1311
|
-
zIndex: (isNaN(parseInt(
|
|
1335
|
+
opacity: F && F.dataset[P.KEY] === P.VALUES.HIDE ? 1 : parseFloat(L.opacity),
|
|
1336
|
+
zIndex: (isNaN(parseInt(L.zIndex)) ? 0 : parseInt(L.zIndex)) + i,
|
|
1312
1337
|
borderRadius: "0px",
|
|
1313
1338
|
borderColor: "transparent",
|
|
1314
1339
|
borderWidth: "0px",
|
|
1315
1340
|
isTraveler: !1
|
|
1316
|
-
}, Se(
|
|
1341
|
+
}, Se(L)), o) : void 0,
|
|
1317
1342
|
nativeRect: o ? {
|
|
1318
|
-
x:
|
|
1319
|
-
y:
|
|
1320
|
-
width:
|
|
1321
|
-
height:
|
|
1343
|
+
x: V + window.scrollX,
|
|
1344
|
+
y: B + window.scrollY,
|
|
1345
|
+
width: H - V,
|
|
1346
|
+
height: T - B
|
|
1322
1347
|
} : void 0,
|
|
1323
1348
|
children: []
|
|
1324
1349
|
};
|
|
1325
1350
|
}
|
|
1326
1351
|
if (s.nodeType !== Node.ELEMENT_NODE)
|
|
1327
1352
|
return null;
|
|
1328
|
-
const c = s, l = c.dataset[
|
|
1353
|
+
const c = s, l = c.dataset[N.KEY];
|
|
1329
1354
|
let d = t, h = t;
|
|
1330
1355
|
if (l) {
|
|
1331
|
-
const
|
|
1332
|
-
for (const
|
|
1333
|
-
if (!
|
|
1356
|
+
const m = new Set(l.split(/\s+/));
|
|
1357
|
+
for (const R of m)
|
|
1358
|
+
if (!Ee.includes(R))
|
|
1334
1359
|
throw new Error(
|
|
1335
|
-
`[MirageEngine] Invalid filter token: '${
|
|
1360
|
+
`[MirageEngine] Invalid filter token: '${R}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
|
|
1336
1361
|
);
|
|
1337
|
-
if (
|
|
1362
|
+
if (m.has(N.VALUES.END))
|
|
1338
1363
|
return null;
|
|
1339
|
-
if (
|
|
1364
|
+
if (m.has(N.VALUES.INCLUDE_TREE) && m.has(N.VALUES.EXCLUDE_TREE))
|
|
1340
1365
|
throw new Error(
|
|
1341
1366
|
"[MirageEngine] Conflicting filters: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
|
|
1342
1367
|
);
|
|
1343
|
-
if (
|
|
1368
|
+
if (m.has(N.VALUES.INCLUDE_SELF) && m.has(N.VALUES.EXCLUDE_SELF))
|
|
1344
1369
|
throw new Error(
|
|
1345
1370
|
"[MirageEngine] Conflicting filters: 'include-self' and 'exclude-self' cannot be used together on the same element."
|
|
1346
1371
|
);
|
|
1347
|
-
|
|
1372
|
+
m.has(N.VALUES.INCLUDE_TREE) ? d = d | W : m.has(N.VALUES.EXCLUDE_TREE) && (d = d & ~W), h = d, m.has(N.VALUES.INCLUDE_SELF) ? h = h | W : m.has(N.VALUES.EXCLUDE_SELF) && (h = h & ~W);
|
|
1348
1373
|
}
|
|
1349
1374
|
const u = c.dataset[Y.KEY];
|
|
1350
1375
|
if (u) {
|
|
1351
|
-
const
|
|
1352
|
-
for (const
|
|
1353
|
-
if (!
|
|
1376
|
+
const m = new Set(u.split(/\s+/));
|
|
1377
|
+
for (const R of m)
|
|
1378
|
+
if (!Ee.includes(R))
|
|
1354
1379
|
throw new Error(
|
|
1355
|
-
`[MirageEngine] Invalid select token: '${
|
|
1380
|
+
`[MirageEngine] Invalid select token: '${R}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
|
|
1356
1381
|
);
|
|
1357
|
-
if (
|
|
1382
|
+
if (m.has(Y.VALUES.END))
|
|
1358
1383
|
return null;
|
|
1359
|
-
if (
|
|
1384
|
+
if (m.has(Y.VALUES.INCLUDE_TREE) && m.has(Y.VALUES.EXCLUDE_TREE))
|
|
1360
1385
|
throw new Error(
|
|
1361
1386
|
"[MirageEngine] Conflicting selects: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
|
|
1362
1387
|
);
|
|
1363
|
-
if (
|
|
1388
|
+
if (m.has(Y.VALUES.INCLUDE_SELF) && m.has(Y.VALUES.EXCLUDE_SELF))
|
|
1364
1389
|
throw new Error(
|
|
1365
1390
|
"[MirageEngine] Conflicting selects: 'include-self' and 'exclude-self' cannot be used together on the same element."
|
|
1366
1391
|
);
|
|
1367
|
-
|
|
1392
|
+
m.has(Y.VALUES.INCLUDE_TREE) ? d = d | K : m.has(Y.VALUES.EXCLUDE_TREE) && (d = d & ~K), h = d, m.has(Y.VALUES.INCLUDE_SELF) ? h = h | K : m.has(Y.VALUES.EXCLUDE_SELF) && (h = h & ~K);
|
|
1368
1393
|
}
|
|
1369
|
-
const p = c.dataset[
|
|
1370
|
-
let
|
|
1394
|
+
const p = c.dataset[U.KEY];
|
|
1395
|
+
let g = !1, v = o ? q({}, o) : {}, x = n;
|
|
1371
1396
|
if (p) {
|
|
1372
|
-
let
|
|
1373
|
-
const
|
|
1374
|
-
let
|
|
1375
|
-
if (
|
|
1376
|
-
|
|
1377
|
-
const
|
|
1397
|
+
let m = 1;
|
|
1398
|
+
const R = p.indexOf("{"), I = p.lastIndexOf("}");
|
|
1399
|
+
let F = p;
|
|
1400
|
+
if (R !== -1 && I !== -1 && I > R) {
|
|
1401
|
+
F = p.substring(0, R).trim();
|
|
1402
|
+
const T = p.substring(R, I + 1);
|
|
1378
1403
|
try {
|
|
1379
|
-
|
|
1380
|
-
} catch (
|
|
1404
|
+
v = new Function("return " + T)();
|
|
1405
|
+
} catch (w) {
|
|
1381
1406
|
console.warn(
|
|
1382
|
-
`[MirageEngine] Failed to parse travel styles JSON: ${
|
|
1407
|
+
`[MirageEngine] Failed to parse travel styles JSON: ${T}`
|
|
1383
1408
|
);
|
|
1384
1409
|
}
|
|
1385
1410
|
}
|
|
1386
|
-
const
|
|
1387
|
-
let
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1411
|
+
const L = F.split(/\s+/);
|
|
1412
|
+
let V = !1;
|
|
1413
|
+
const B = L.indexOf(U.VALUES.TRAVELER);
|
|
1414
|
+
if (B !== -1) {
|
|
1415
|
+
g = !0, V = !0;
|
|
1416
|
+
const T = L[B + 1];
|
|
1417
|
+
if (T && !isNaN(parseInt(T, 10)))
|
|
1418
|
+
m = parseInt(T, 10);
|
|
1419
|
+
else {
|
|
1420
|
+
const w = L.find((j) => !isNaN(parseInt(j, 10)));
|
|
1421
|
+
w && (m = parseInt(w, 10));
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
const H = L.indexOf(U.VALUES.NATIVE);
|
|
1425
|
+
if (H !== -1) {
|
|
1426
|
+
const T = L[H + 1];
|
|
1427
|
+
if (T && !isNaN(parseInt(T, 10)))
|
|
1428
|
+
x = parseInt(T, 10);
|
|
1429
|
+
else if (!g) {
|
|
1430
|
+
const w = L.find((j) => !isNaN(parseInt(j, 10)));
|
|
1431
|
+
w && (x = parseInt(w, 10));
|
|
1432
|
+
}
|
|
1396
1433
|
}
|
|
1397
|
-
if (
|
|
1398
|
-
const
|
|
1399
|
-
if (
|
|
1434
|
+
if (V) {
|
|
1435
|
+
const T = m + 1;
|
|
1436
|
+
if (T < r)
|
|
1400
1437
|
throw new Error(
|
|
1401
|
-
`[MirageEngine] Traveler layer (${
|
|
1438
|
+
`[MirageEngine] Traveler layer (${m}) cannot be smaller than inherited capture layer (${r - 1}).`
|
|
1402
1439
|
);
|
|
1403
|
-
|
|
1440
|
+
r = Math.min(T, U.MAX_LAYERS + 1);
|
|
1404
1441
|
}
|
|
1405
1442
|
}
|
|
1406
|
-
const
|
|
1407
|
-
let
|
|
1408
|
-
|
|
1409
|
-
const
|
|
1410
|
-
if (
|
|
1443
|
+
const M = c.dataset[ze.KEY];
|
|
1444
|
+
let A;
|
|
1445
|
+
M && (A = JSON.parse(M));
|
|
1446
|
+
const S = c.getBoundingClientRect(), E = window.getComputedStyle(c);
|
|
1447
|
+
if (S.width === 0 || S.height === 0 || E.display === "none")
|
|
1411
1448
|
return null;
|
|
1412
|
-
let
|
|
1413
|
-
|
|
1414
|
-
const
|
|
1449
|
+
let C = c.getAttribute("data-mid");
|
|
1450
|
+
C || (C = Math.random().toString(36).substring(2, 11), c.setAttribute("data-mid", C));
|
|
1451
|
+
const b = parseInt(E.zIndex), O = (isNaN(b) ? 0 : b) + i;
|
|
1415
1452
|
let X;
|
|
1416
1453
|
if (c.tagName === "IMG")
|
|
1417
1454
|
X = c.src;
|
|
1418
1455
|
else if (c.tagName.toLowerCase() === "svg") {
|
|
1419
|
-
const
|
|
1420
|
-
const
|
|
1421
|
-
|
|
1422
|
-
const
|
|
1423
|
-
|
|
1424
|
-
const
|
|
1425
|
-
|
|
1426
|
-
const
|
|
1427
|
-
|
|
1428
|
-
for (let
|
|
1429
|
-
|
|
1456
|
+
const m = c.cloneNode(!0), R = v == null ? void 0 : v.color, I = v == null ? void 0 : v.fill, F = v == null ? void 0 : v.stroke, L = v == null ? void 0 : v.opacity, V = (w, j) => {
|
|
1457
|
+
const _ = window.getComputedStyle(w), Q = j, ke = _.fill === _.color, Ue = _.stroke === _.color, se = I || (ke ? R : void 0) || _.fill;
|
|
1458
|
+
se && se !== "none" && (Q.style.fill = se);
|
|
1459
|
+
const ne = F || (Ue ? R : void 0) || _.stroke;
|
|
1460
|
+
ne && ne !== "none" && (Q.style.stroke = ne), _.strokeWidth && _.strokeWidth !== "0px" && (Q.style.strokeWidth = _.strokeWidth);
|
|
1461
|
+
const ve = R || _.color;
|
|
1462
|
+
ve && (Q.style.color = ve);
|
|
1463
|
+
const oe = L || _.opacity;
|
|
1464
|
+
oe && oe !== "1" && (Q.style.opacity = oe);
|
|
1465
|
+
for (let te = 0; te < w.children.length; te++)
|
|
1466
|
+
V(w.children[te], j.children[te]);
|
|
1430
1467
|
};
|
|
1431
|
-
|
|
1432
|
-
const
|
|
1433
|
-
|
|
1434
|
-
let
|
|
1435
|
-
|
|
1468
|
+
V(c, m);
|
|
1469
|
+
const B = c.getBoundingClientRect(), H = window.devicePixelRatio * a;
|
|
1470
|
+
m.hasAttribute("viewBox") || m.setAttribute("viewBox", `0 0 ${B.width} ${B.height}`), m.setAttribute("width", (B.width * H).toString()), m.setAttribute("height", (B.height * H).toString());
|
|
1471
|
+
let T = new XMLSerializer().serializeToString(m);
|
|
1472
|
+
T.includes("xmlns=") || (T = T.replace(
|
|
1436
1473
|
"<svg",
|
|
1437
1474
|
'<svg xmlns="http://www.w3.org/2000/svg"'
|
|
1438
|
-
)), X = `data:image/svg+xml;utf8,${encodeURIComponent(
|
|
1439
|
-
} else if (
|
|
1440
|
-
const
|
|
1441
|
-
|
|
1442
|
-
}
|
|
1443
|
-
const
|
|
1444
|
-
backgroundColor:
|
|
1445
|
-
backgroundImage:
|
|
1446
|
-
opacity: c.dataset[
|
|
1475
|
+
)), X = `data:image/svg+xml;utf8,${encodeURIComponent(T)}`;
|
|
1476
|
+
} else if (E.backgroundImage && E.backgroundImage !== "none") {
|
|
1477
|
+
const m = E.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
|
|
1478
|
+
m && (X = m[1]);
|
|
1479
|
+
}
|
|
1480
|
+
const k = {
|
|
1481
|
+
backgroundColor: E.backgroundColor,
|
|
1482
|
+
backgroundImage: E.backgroundImage,
|
|
1483
|
+
opacity: c.dataset[P.KEY] === P.VALUES.HIDE ? 1 : parseFloat(E.opacity),
|
|
1447
1484
|
zIndex: O,
|
|
1448
|
-
borderRadius:
|
|
1449
|
-
borderColor:
|
|
1450
|
-
borderWidth:
|
|
1485
|
+
borderRadius: E.borderRadius,
|
|
1486
|
+
borderColor: E.borderColor,
|
|
1487
|
+
borderWidth: E.borderWidth,
|
|
1451
1488
|
imageSrc: X,
|
|
1452
|
-
isTraveler:
|
|
1453
|
-
},
|
|
1489
|
+
isTraveler: g
|
|
1490
|
+
}, G = k;
|
|
1454
1491
|
let De, Ie;
|
|
1455
1492
|
const he = [];
|
|
1456
|
-
return c.tagName.toLowerCase() !== "svg" && Array.from(c.childNodes).forEach((
|
|
1457
|
-
const
|
|
1458
|
-
|
|
1493
|
+
return c.tagName.toLowerCase() !== "svg" && Array.from(c.childNodes).forEach((m) => {
|
|
1494
|
+
const R = m.nodeType === Node.TEXT_NODE ? h : d, I = Ae(
|
|
1495
|
+
m,
|
|
1459
1496
|
e,
|
|
1460
|
-
|
|
1461
|
-
|
|
1497
|
+
R,
|
|
1498
|
+
r,
|
|
1462
1499
|
O,
|
|
1463
1500
|
a,
|
|
1464
|
-
|
|
1465
|
-
|
|
1501
|
+
m.nodeType === Node.TEXT_NODE ? x : void 0,
|
|
1502
|
+
m.nodeType === Node.TEXT_NODE && Object.keys(v).length > 0 ? v : void 0
|
|
1466
1503
|
);
|
|
1467
|
-
|
|
1504
|
+
I && he.push(I);
|
|
1468
1505
|
}), {
|
|
1469
|
-
id:
|
|
1506
|
+
id: C,
|
|
1470
1507
|
type: "BOX",
|
|
1471
1508
|
element: c,
|
|
1472
1509
|
rect: {
|
|
1473
|
-
x:
|
|
1474
|
-
y:
|
|
1475
|
-
width:
|
|
1476
|
-
height:
|
|
1510
|
+
x: S.left + window.scrollX,
|
|
1511
|
+
y: S.top + window.scrollY,
|
|
1512
|
+
width: S.width,
|
|
1513
|
+
height: S.height
|
|
1477
1514
|
},
|
|
1478
|
-
styles:
|
|
1515
|
+
styles: G,
|
|
1479
1516
|
textContent: De,
|
|
1480
1517
|
textStyles: Ie,
|
|
1481
1518
|
dirtyMask: e,
|
|
1482
1519
|
visibility: h,
|
|
1483
|
-
isTraveler:
|
|
1484
|
-
captureLayer:
|
|
1485
|
-
nativeLayer:
|
|
1486
|
-
nativeStyles:
|
|
1487
|
-
backgroundColor: (de =
|
|
1488
|
-
backgroundImage: (ue =
|
|
1489
|
-
opacity: (fe =
|
|
1490
|
-
zIndex:
|
|
1491
|
-
borderRadius: (ge =
|
|
1492
|
-
borderColor: (pe =
|
|
1493
|
-
borderWidth: (me =
|
|
1494
|
-
isTraveler:
|
|
1520
|
+
isTraveler: g,
|
|
1521
|
+
captureLayer: r,
|
|
1522
|
+
nativeLayer: x,
|
|
1523
|
+
nativeStyles: x !== void 0 ? be(q({}, k), {
|
|
1524
|
+
backgroundColor: (de = v.backgroundColor) != null ? de : k.backgroundColor,
|
|
1525
|
+
backgroundImage: (ue = v.backgroundImage) != null ? ue : k.backgroundImage,
|
|
1526
|
+
opacity: (fe = v.opacity) != null ? fe : k.opacity,
|
|
1527
|
+
zIndex: v.zIndex !== void 0 ? v.zIndex + O : k.zIndex,
|
|
1528
|
+
borderRadius: (ge = v.borderRadius) != null ? ge : k.borderRadius,
|
|
1529
|
+
borderColor: (pe = v.borderColor) != null ? pe : k.borderColor,
|
|
1530
|
+
borderWidth: (me = v.borderWidth) != null ? me : k.borderWidth,
|
|
1531
|
+
isTraveler: k.isTraveler
|
|
1495
1532
|
}) : void 0,
|
|
1496
|
-
nativeRect:
|
|
1497
|
-
x:
|
|
1498
|
-
y:
|
|
1499
|
-
width:
|
|
1500
|
-
height:
|
|
1533
|
+
nativeRect: x !== void 0 ? {
|
|
1534
|
+
x: v.x !== void 0 ? parseFloat(v.x) : S.left + window.scrollX,
|
|
1535
|
+
y: v.y !== void 0 ? parseFloat(v.y) : S.top + window.scrollY,
|
|
1536
|
+
width: v.width !== void 0 ? parseFloat(v.width) : S.width,
|
|
1537
|
+
height: v.height !== void 0 ? parseFloat(v.height) : S.height
|
|
1501
1538
|
} : void 0,
|
|
1502
|
-
isFixed:
|
|
1539
|
+
isFixed: E.position === "fixed",
|
|
1503
1540
|
children: he,
|
|
1504
|
-
shaderHooks:
|
|
1541
|
+
shaderHooks: A
|
|
1505
1542
|
};
|
|
1506
1543
|
}
|
|
1507
1544
|
function it(s, e) {
|
|
1508
|
-
e.size !== 0 && e.forEach((t,
|
|
1545
|
+
e.size !== 0 && e.forEach((t, r) => {
|
|
1509
1546
|
var a, n, o, c;
|
|
1510
|
-
const
|
|
1511
|
-
!
|
|
1547
|
+
const i = s.get(r);
|
|
1548
|
+
!i || !i.userData.basePosition || (z.forceUpdateUniforms(i.material, {
|
|
1512
1549
|
backgroundColor: t.backgroundColor,
|
|
1513
1550
|
backgroundImage: t.backgroundImage,
|
|
1514
1551
|
opacity: t.opacity,
|
|
1515
|
-
borderRadius: (n = t.borderRadius) != null ? n : (a =
|
|
1552
|
+
borderRadius: (n = t.borderRadius) != null ? n : (a = i.userData.baseStyles) == null ? void 0 : a.borderRadius
|
|
1516
1553
|
// width and height are no longer updated here, they are updated in syncMeshesByDOM
|
|
1517
|
-
}),
|
|
1554
|
+
}), i.userData.nativeMesh && z.forceUpdateUniforms(i.userData.nativeMesh.material, {
|
|
1518
1555
|
backgroundColor: t.backgroundColor,
|
|
1519
1556
|
backgroundImage: t.backgroundImage,
|
|
1520
1557
|
opacity: t.opacity,
|
|
1521
|
-
borderRadius: (c = t.borderRadius) != null ? c : (o =
|
|
1558
|
+
borderRadius: (c = t.borderRadius) != null ? c : (o = i.userData.baseStyles) == null ? void 0 : o.borderRadius
|
|
1522
1559
|
}));
|
|
1523
1560
|
});
|
|
1524
1561
|
}
|
|
1525
1562
|
class st {
|
|
1526
|
-
constructor(e, t,
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
this.target = e, this.renderer = t, this.registry =
|
|
1533
|
-
resizeDebounce:
|
|
1563
|
+
constructor(e, t, r, i) {
|
|
1564
|
+
f(this, "target");
|
|
1565
|
+
f(this, "renderer");
|
|
1566
|
+
f(this, "registry");
|
|
1567
|
+
f(this, "isTravelEnabled", !1);
|
|
1568
|
+
f(this, "tracker");
|
|
1569
|
+
this.target = e, this.renderer = t, this.registry = r, this.tracker = new We(e, {
|
|
1570
|
+
resizeDebounce: i.resizeDebounce
|
|
1534
1571
|
}), this.tracker.onLayoutChange.add((a, n) => {
|
|
1535
|
-
document.querySelector(`[${
|
|
1572
|
+
document.querySelector(`[${U.NAME}~='${U.VALUES.TRAVELER}']`) !== null && !this.isTravelEnabled && (this.isTravelEnabled = !0, this.renderer.createRenderTarget());
|
|
1536
1573
|
const c = Ae(
|
|
1537
1574
|
this.target,
|
|
1538
1575
|
a,
|
|
@@ -1557,7 +1594,7 @@ class st {
|
|
|
1557
1594
|
}
|
|
1558
1595
|
class nt {
|
|
1559
1596
|
constructor() {
|
|
1560
|
-
|
|
1597
|
+
f(this, "store");
|
|
1561
1598
|
this.store = /* @__PURE__ */ new WeakMap();
|
|
1562
1599
|
}
|
|
1563
1600
|
register(e, t) {
|
|
@@ -1582,26 +1619,26 @@ class nt {
|
|
|
1582
1619
|
}
|
|
1583
1620
|
class lt {
|
|
1584
1621
|
constructor(e, t) {
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
var
|
|
1622
|
+
f(this, "renderer");
|
|
1623
|
+
f(this, "syncer");
|
|
1624
|
+
f(this, "target");
|
|
1625
|
+
f(this, "registry");
|
|
1626
|
+
var i, a, n;
|
|
1590
1627
|
if (this.target = e, this.registry = new nt(), !document.getElementById("mirage-engine-styles")) {
|
|
1591
1628
|
const o = document.createElement("style");
|
|
1592
1629
|
o.id = "mirage-engine-styles", o.textContent = `
|
|
1593
|
-
[${
|
|
1630
|
+
[${P.NAME}="${P.VALUES.HIDE}"] {
|
|
1594
1631
|
opacity: 0 !important;
|
|
1595
1632
|
}
|
|
1596
1633
|
`, document.head.appendChild(o);
|
|
1597
1634
|
}
|
|
1598
|
-
let
|
|
1599
|
-
if (t.mode === "duplicate" ?
|
|
1635
|
+
let r;
|
|
1636
|
+
if (t.mode === "duplicate" ? r = (a = (i = t.container) != null ? i : this.target.parentElement) != null ? a : void 0 : r = (n = this.target.parentElement) != null ? n : void 0, !r)
|
|
1600
1637
|
throw new Error("[Mirage] Cannot find a container (parent or option).");
|
|
1601
1638
|
this.renderer = new tt(
|
|
1602
1639
|
this.target,
|
|
1603
1640
|
t,
|
|
1604
|
-
|
|
1641
|
+
r,
|
|
1605
1642
|
this.registry
|
|
1606
1643
|
), this.renderer.mount(), this.syncer = new st(this.target, this.renderer, this.registry, t);
|
|
1607
1644
|
}
|
|
@@ -1640,30 +1677,30 @@ class lt {
|
|
|
1640
1677
|
}), window.addEventListener("keyup", (a) => {
|
|
1641
1678
|
t[a.key] !== void 0 && (t[a.key] = !1);
|
|
1642
1679
|
});
|
|
1643
|
-
const
|
|
1644
|
-
requestAnimationFrame(
|
|
1680
|
+
const r = 2, i = () => {
|
|
1681
|
+
requestAnimationFrame(i), t.ArrowRight && e.position.setX(e.position.x + r), t.ArrowLeft && e.position.setX(e.position.x - r), t.ArrowUp && e.position.setY(e.position.y + r), t.ArrowDown && e.position.setY(e.position.y - r);
|
|
1645
1682
|
};
|
|
1646
|
-
|
|
1683
|
+
i();
|
|
1647
1684
|
}
|
|
1648
1685
|
}
|
|
1649
1686
|
export {
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1687
|
+
Ee as ALLOWED_FILTERS,
|
|
1688
|
+
P as ATTR_DOM,
|
|
1689
|
+
N as ATTR_FILTER,
|
|
1653
1690
|
at as ATTR_SANDWICH,
|
|
1654
1691
|
Y as ATTR_SELECT,
|
|
1655
|
-
|
|
1656
|
-
|
|
1692
|
+
ze as ATTR_SHADER,
|
|
1693
|
+
U as ATTR_TRAVEL,
|
|
1657
1694
|
ce as DIRTY_CONTENT,
|
|
1658
|
-
|
|
1695
|
+
re as DIRTY_NONE,
|
|
1659
1696
|
$ as DIRTY_RECT,
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1697
|
+
ie as DIRTY_STRUCTURE,
|
|
1698
|
+
Z as DIRTY_STYLE,
|
|
1699
|
+
Xe as DIRTY_ZINDEX,
|
|
1663
1700
|
ct as EXCLUDED,
|
|
1664
1701
|
lt as Engine,
|
|
1665
|
-
|
|
1666
|
-
|
|
1702
|
+
K as SELECT_LAYER,
|
|
1703
|
+
D as THREE_LAYERS,
|
|
1667
1704
|
xe as TRAVEL_VALUES,
|
|
1668
1705
|
We as Tracker,
|
|
1669
1706
|
W as USER_LAYER,
|