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