@mirage-engine/core 0.3.18 → 0.3.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/mirage-engine.js +346 -342
- package/dist/mirage-engine.umd.js +11 -10
- package/package.json +3 -3
- package/src/renderer/Renderer.ts +22 -12
package/dist/mirage-engine.js
CHANGED
|
@@ -12,20 +12,20 @@ var be = (i, e, t) => e in i ? Xe(i, e, { enumerable: !0, configurable: !0, writ
|
|
|
12
12
|
}, Ce = (i, e) => Ne(i, ze(e));
|
|
13
13
|
var g = (i, e, t) => (be(i, typeof e != "symbol" ? e + "" : e, t), t);
|
|
14
14
|
var Te = (i, e, t) => new Promise((r, s) => {
|
|
15
|
-
var
|
|
15
|
+
var c = (l) => {
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
} catch (
|
|
19
|
-
s(
|
|
17
|
+
a(t.next(l));
|
|
18
|
+
} catch (n) {
|
|
19
|
+
s(n);
|
|
20
20
|
}
|
|
21
|
-
}, o = (
|
|
21
|
+
}, o = (l) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch (
|
|
25
|
-
s(
|
|
23
|
+
a(t.throw(l));
|
|
24
|
+
} catch (n) {
|
|
25
|
+
s(n);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
|
|
27
|
+
}, a = (l) => l.done ? r(l.value) : Promise.resolve(l.value).then(c, o);
|
|
28
|
+
a((t = t.apply(i, e)).next());
|
|
29
29
|
});
|
|
30
30
|
import * as w from "three";
|
|
31
31
|
const Ie = {
|
|
@@ -67,7 +67,7 @@ const Ie = {
|
|
|
67
67
|
NAME: "data-mirage-select",
|
|
68
68
|
KEY: "mirageSelect",
|
|
69
69
|
VALUES: Ie
|
|
70
|
-
},
|
|
70
|
+
}, We = {
|
|
71
71
|
NAME: "data-mirage-shader",
|
|
72
72
|
KEY: "mirageShader"
|
|
73
73
|
}, dt = {
|
|
@@ -76,7 +76,7 @@ const Ie = {
|
|
|
76
76
|
VALUES: {
|
|
77
77
|
FRONT: "front"
|
|
78
78
|
}
|
|
79
|
-
}, ge = 0, re = 1, ue = 2,
|
|
79
|
+
}, ge = 0, re = 1, ue = 2, Pe = 4, pe = 8, ye = 16;
|
|
80
80
|
function He(i) {
|
|
81
81
|
const e = i.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/);
|
|
82
82
|
return e ? {
|
|
@@ -143,32 +143,32 @@ class qe {
|
|
|
143
143
|
this.pendingMask |= re, this.isDomDirty = !0, this.scrollTimer = null;
|
|
144
144
|
}, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((r) => r(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((r) => r()), requestAnimationFrame(this.renderLoop);
|
|
145
145
|
});
|
|
146
|
-
var s,
|
|
146
|
+
var s, c;
|
|
147
147
|
this.target = e;
|
|
148
148
|
const r = (s = t.resizeDebounce) != null ? s : !0;
|
|
149
149
|
r === !1 ? this.resizeConfig = { enabled: !1, delay: 0 } : r === !0 ? this.resizeConfig = { enabled: !0, delay: 150 } : this.resizeConfig = {
|
|
150
150
|
enabled: !0,
|
|
151
|
-
delay: (
|
|
151
|
+
delay: (c = r.delay) != null ? c : 150,
|
|
152
152
|
onStart: r.onStart,
|
|
153
153
|
onEnd: r.onEnd
|
|
154
154
|
}, this.observer = new MutationObserver((o) => {
|
|
155
|
-
let
|
|
156
|
-
for (const
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
155
|
+
let a = ge;
|
|
156
|
+
for (const l of o)
|
|
157
|
+
if (l.type === "childList")
|
|
158
|
+
a |= pe, l.removedNodes.length > 0 && l.removedNodes.forEach((n) => {
|
|
159
|
+
n instanceof HTMLElement && this.pendingDeletions.add(n);
|
|
160
160
|
});
|
|
161
|
-
else if (
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
this.pendingStyles.set(
|
|
161
|
+
else if (l.type === "attributes")
|
|
162
|
+
if (l.attributeName === "style") {
|
|
163
|
+
a |= re | ue;
|
|
164
|
+
const n = l.target, u = Ge(n.style);
|
|
165
|
+
this.pendingStyles.set(n, u);
|
|
166
166
|
} else
|
|
167
|
-
|
|
167
|
+
l.attributeName === "class" ? a |= re | ue : l.attributeName && l.attributeName.startsWith("data-") && (a |= re | ue, l.attributeName.startsWith("data-mirage") && (a |= pe));
|
|
168
168
|
else
|
|
169
|
-
|
|
170
|
-
if (
|
|
171
|
-
if (this.pendingMask |=
|
|
169
|
+
l.type === "characterData" && (a |= ye | re);
|
|
170
|
+
if (a !== ge) {
|
|
171
|
+
if (this.pendingMask |= a, a & pe) {
|
|
172
172
|
this.clearTimers(), this.isDomDirty = !0;
|
|
173
173
|
return;
|
|
174
174
|
}
|
|
@@ -216,13 +216,13 @@ class ke {
|
|
|
216
216
|
return 0;
|
|
217
217
|
const t = document.createElement("div"), r = document.createElement("span"), s = document.createElement("img");
|
|
218
218
|
t.style.visibility = "hidden", t.style.position = "absolute", t.style.top = "0px", t.style.left = "0px", t.style.font = e, t.style.margin = "0", t.style.padding = "0", t.style.border = "none", r.style.margin = "0", r.style.padding = "0", r.style.border = "none", r.style.lineHeight = "normal", s.width = 1, s.height = 1, s.style.verticalAlign = "baseline", r.appendChild(document.createTextNode("Hidden Text")), t.appendChild(r), t.appendChild(s), document.body.appendChild(t);
|
|
219
|
-
const
|
|
220
|
-
return document.body.removeChild(t),
|
|
219
|
+
const c = s.offsetTop - r.offsetTop;
|
|
220
|
+
return document.body.removeChild(t), c;
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
g(ke, "cache", /* @__PURE__ */ new Map());
|
|
224
224
|
class $e extends w.MeshBasicMaterial {
|
|
225
|
-
constructor(t, r, s,
|
|
225
|
+
constructor(t, r, s, c, o = 2) {
|
|
226
226
|
super({
|
|
227
227
|
transparent: !0,
|
|
228
228
|
side: w.FrontSide,
|
|
@@ -233,55 +233,55 @@ class $e extends w.MeshBasicMaterial {
|
|
|
233
233
|
g(this, "qualityFactor");
|
|
234
234
|
if (this.canvas = document.createElement("canvas"), this.ctx = this.canvas.getContext("2d"), !this.ctx)
|
|
235
235
|
throw new Error("[Mirage] Failed to create canvas context");
|
|
236
|
-
this.qualityFactor = o, this.map = new w.CanvasTexture(this.canvas), this.map.colorSpace = w.LinearSRGBColorSpace, this.map.minFilter = w.LinearFilter, this.map.magFilter = w.LinearFilter, this.updateText(t, r, s,
|
|
236
|
+
this.qualityFactor = o, this.map = new w.CanvasTexture(this.canvas), this.map.colorSpace = w.LinearSRGBColorSpace, this.map.minFilter = w.LinearFilter, this.map.magFilter = w.LinearFilter, this.updateText(t, r, s, c);
|
|
237
237
|
}
|
|
238
238
|
wrapText(t, r) {
|
|
239
239
|
const s = t.split(`
|
|
240
|
-
`),
|
|
240
|
+
`), c = [];
|
|
241
241
|
return s.forEach((o) => {
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
|
|
242
|
+
const a = o.match(/[^\s\-]+\-?|\-|\s+/g) || [];
|
|
243
|
+
if (a.length === 0) {
|
|
244
|
+
c.push("");
|
|
245
245
|
return;
|
|
246
246
|
}
|
|
247
|
-
let
|
|
248
|
-
for (let
|
|
249
|
-
const u = n
|
|
250
|
-
this.ctx.measureText(
|
|
247
|
+
let l = a[0];
|
|
248
|
+
for (let n = 1; n < a.length; n++) {
|
|
249
|
+
const u = a[n];
|
|
250
|
+
this.ctx.measureText(l + u).width <= r + 2 ? l += u : (l && c.push(l), l = u.trimStart());
|
|
251
251
|
}
|
|
252
|
-
|
|
253
|
-
}),
|
|
252
|
+
l && c.push(l);
|
|
253
|
+
}), c;
|
|
254
254
|
}
|
|
255
|
-
updateText(t, r, s,
|
|
255
|
+
updateText(t, r, s, c, o) {
|
|
256
256
|
o !== void 0 && (this.qualityFactor = o);
|
|
257
|
-
const
|
|
258
|
-
this.canvas.width !==
|
|
257
|
+
const l = (window.devicePixelRatio || 1) * this.qualityFactor, n = s * l, u = c * l;
|
|
258
|
+
this.canvas.width !== n || this.canvas.height !== u ? (this.canvas.width = n, this.canvas.height = u) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(l, 0, 0, l, 0, 0), this.ctx.font = r.font, this.ctx.fillStyle = r.color, this.ctx.textBaseline = "alphabetic", this.ctx.globalAlpha = 1;
|
|
259
259
|
const h = this.wrapText(t, s), d = r.lineHeight, p = ke.getBaseline(r.font);
|
|
260
260
|
h.forEach((f, L) => {
|
|
261
261
|
const m = L * d + p;
|
|
262
|
-
let
|
|
263
|
-
r.textAlign === "center" ?
|
|
262
|
+
let y = 0;
|
|
263
|
+
r.textAlign === "center" ? y = s / 2 : r.textAlign === "right" && (y = s), this.ctx.textAlign = r.textAlign, this.ctx.fillText(f, y, m);
|
|
264
264
|
}), this.map && (this.map.needsUpdate = !0);
|
|
265
265
|
}
|
|
266
266
|
dispose() {
|
|
267
267
|
this.map && this.map.dispose(), super.dispose();
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
-
function
|
|
270
|
+
function le(i, e = 0) {
|
|
271
271
|
if (typeof i == "number")
|
|
272
272
|
return i;
|
|
273
273
|
const t = parseFloat(i) || 0;
|
|
274
274
|
return typeof i == "string" && i.includes("%") ? t / 100 * e : t;
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function ce(i) {
|
|
277
277
|
if (!i || i === "transparent")
|
|
278
278
|
return { color: new w.Color(16777215), alpha: 0 };
|
|
279
279
|
const e = i.match(
|
|
280
280
|
/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/
|
|
281
281
|
);
|
|
282
282
|
if (e) {
|
|
283
|
-
const t = parseInt(e[1], 10), r = parseInt(e[2], 10), s = parseInt(e[3], 10),
|
|
284
|
-
return { color: new w.Color(`rgb(${t}, ${r}, ${s})`), alpha:
|
|
283
|
+
const t = parseInt(e[1], 10), r = parseInt(e[2], 10), s = parseInt(e[3], 10), c = e[4] !== void 0 ? parseFloat(e[4]) : 1;
|
|
284
|
+
return { color: new w.Color(`rgb(${t}, ${r}, ${s})`), alpha: c };
|
|
285
285
|
}
|
|
286
286
|
return { color: new w.Color(i), alpha: 1 };
|
|
287
287
|
}
|
|
@@ -289,16 +289,16 @@ function Ue(i) {
|
|
|
289
289
|
const e = [];
|
|
290
290
|
let t = "", r = 0;
|
|
291
291
|
for (let s = 0; s < i.length; s++) {
|
|
292
|
-
const
|
|
293
|
-
if (
|
|
292
|
+
const c = i[s];
|
|
293
|
+
if (c === "(")
|
|
294
294
|
r++;
|
|
295
|
-
else if (
|
|
295
|
+
else if (c === ")")
|
|
296
296
|
r--;
|
|
297
|
-
else if (
|
|
297
|
+
else if (c === "," && r === 0) {
|
|
298
298
|
e.push(t.trim()), t = "";
|
|
299
299
|
continue;
|
|
300
300
|
}
|
|
301
|
-
t +=
|
|
301
|
+
t += c;
|
|
302
302
|
}
|
|
303
303
|
return t && e.push(t.trim()), e;
|
|
304
304
|
}
|
|
@@ -309,47 +309,47 @@ function je(i) {
|
|
|
309
309
|
if (!e)
|
|
310
310
|
return null;
|
|
311
311
|
const t = e[1], r = Ue(t);
|
|
312
|
-
let s = Math.PI,
|
|
312
|
+
let s = Math.PI, c = 0;
|
|
313
313
|
const o = r[0].trim();
|
|
314
314
|
if (o.startsWith("to "))
|
|
315
|
-
o === "to top" ? s = 0 : o === "to right" ? s = Math.PI / 2 : o === "to bottom" ? s = Math.PI : o === "to left" ? s = Math.PI * 1.5 : o === "to top right" || o === "to right top" ? s = Math.PI / 4 : o === "to bottom right" || o === "to right bottom" ? s = Math.PI * 0.75 : o === "to bottom left" || o === "to left bottom" ? s = Math.PI * 1.25 : (o === "to top left" || o === "to left top") && (s = Math.PI * 1.75),
|
|
315
|
+
o === "to top" ? s = 0 : o === "to right" ? s = Math.PI / 2 : o === "to bottom" ? s = Math.PI : o === "to left" ? s = Math.PI * 1.5 : o === "to top right" || o === "to right top" ? s = Math.PI / 4 : o === "to bottom right" || o === "to right bottom" ? s = Math.PI * 0.75 : o === "to bottom left" || o === "to left bottom" ? s = Math.PI * 1.25 : (o === "to top left" || o === "to left top") && (s = Math.PI * 1.75), c = 1;
|
|
316
316
|
else if (o.endsWith("deg") || o.endsWith("rad") || o.endsWith("turn")) {
|
|
317
|
-
const
|
|
318
|
-
o.endsWith("deg") ? s =
|
|
319
|
-
}
|
|
320
|
-
const
|
|
321
|
-
for (let
|
|
322
|
-
const
|
|
323
|
-
let h =
|
|
324
|
-
if (u !== -1 && !
|
|
325
|
-
const f =
|
|
326
|
-
(f.endsWith("%") || f.endsWith("px") || !isNaN(parseFloat(f))) && (h =
|
|
317
|
+
const l = parseFloat(o);
|
|
318
|
+
o.endsWith("deg") ? s = l * (Math.PI / 180) : o.endsWith("rad") ? s = l : o.endsWith("turn") && (s = l * Math.PI * 2), c = 1;
|
|
319
|
+
}
|
|
320
|
+
const a = [];
|
|
321
|
+
for (let l = c; l < r.length && !(a.length >= 8); l++) {
|
|
322
|
+
const n = r[l].trim(), u = n.lastIndexOf(" ");
|
|
323
|
+
let h = n, d = null;
|
|
324
|
+
if (u !== -1 && !n.endsWith(")")) {
|
|
325
|
+
const f = n.substring(u + 1);
|
|
326
|
+
(f.endsWith("%") || f.endsWith("px") || !isNaN(parseFloat(f))) && (h = n.substring(0, u).trim(), d = f);
|
|
327
327
|
}
|
|
328
|
-
const p =
|
|
329
|
-
|
|
328
|
+
const p = ce(h);
|
|
329
|
+
a.push({
|
|
330
330
|
color: p.color,
|
|
331
331
|
alpha: p.alpha,
|
|
332
332
|
rawStop: d,
|
|
333
333
|
stop: 0
|
|
334
334
|
});
|
|
335
335
|
}
|
|
336
|
-
if (
|
|
337
|
-
for (let
|
|
338
|
-
n
|
|
339
|
-
|
|
340
|
-
let
|
|
341
|
-
for (let
|
|
342
|
-
if (n
|
|
343
|
-
const u =
|
|
336
|
+
if (a.length > 0) {
|
|
337
|
+
for (let n = 0; n < a.length; n++)
|
|
338
|
+
a[n].rawStop !== null && (a[n].stop = parseFloat(a[n].rawStop) / 100);
|
|
339
|
+
a[0].rawStop === null && (a[0].stop = 0), a.length > 1 && a[a.length - 1].rawStop === null && (a[a.length - 1].stop = 1);
|
|
340
|
+
let l = 0;
|
|
341
|
+
for (let n = 1; n < a.length; n++)
|
|
342
|
+
if (a[n].rawStop !== null || n === a.length - 1) {
|
|
343
|
+
const u = n - l;
|
|
344
344
|
if (u > 1) {
|
|
345
|
-
const h =
|
|
345
|
+
const h = a[l].stop, p = (a[n].stop - h) / u;
|
|
346
346
|
for (let f = 1; f < u; f++)
|
|
347
|
-
|
|
347
|
+
a[l + f].stop = h + p * f;
|
|
348
348
|
}
|
|
349
|
-
|
|
349
|
+
l = n;
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
|
-
return { angle: s, stops:
|
|
352
|
+
return { angle: s, stops: a };
|
|
353
353
|
}
|
|
354
354
|
function Ke(i) {
|
|
355
355
|
if (!i || i === "none")
|
|
@@ -358,14 +358,14 @@ function Ke(i) {
|
|
|
358
358
|
if (e.length === 0)
|
|
359
359
|
return null;
|
|
360
360
|
const t = e[0].trim(), r = /(rgba?\([^)]+\)|#[0-9a-fA-F]+|[a-zA-Z]+)/, s = t.match(r);
|
|
361
|
-
let
|
|
361
|
+
let c = "transparent", o = t;
|
|
362
362
|
if (s && s[1] !== "inset") {
|
|
363
363
|
const p = s[1];
|
|
364
|
-
(p.startsWith("rgb") || p.startsWith("#") || p === "black" || p === "white" || p === "transparent") && (
|
|
364
|
+
(p.startsWith("rgb") || p.startsWith("#") || p === "black" || p === "white" || p === "transparent") && (c = p, o = t.replace(p, "").trim());
|
|
365
365
|
}
|
|
366
366
|
o = o.replace("inset", "").trim();
|
|
367
|
-
const
|
|
368
|
-
return { offsetX:
|
|
367
|
+
const a = o.split(/\s+/).map((p) => parseFloat(p) || 0), l = a[0] || 0, n = a[1] || 0, u = a[2] || 0, h = a[3] || 0, d = ce(c);
|
|
368
|
+
return { offsetX: l, offsetY: n, blurRadius: u, spreadRadius: h, color: d.color, alpha: d.alpha };
|
|
369
369
|
}
|
|
370
370
|
const Je = `varying vec2 vUv;
|
|
371
371
|
varying vec4 vScreenPos;
|
|
@@ -549,23 +549,24 @@ baseColor = blendSrcOver(baseColor, texColor);`, Le = {
|
|
|
549
549
|
};
|
|
550
550
|
function rt(i, e, t, r = null, s) {
|
|
551
551
|
var C;
|
|
552
|
-
const
|
|
552
|
+
const c = r !== null || !!i.imageSrc;
|
|
553
553
|
let o = "";
|
|
554
|
-
const
|
|
554
|
+
const a = {};
|
|
555
555
|
if (s != null && s.uniforms)
|
|
556
|
-
for (const [
|
|
557
|
-
typeof S == "number" ? (o += `uniform float ${
|
|
558
|
-
`,
|
|
559
|
-
`,
|
|
560
|
-
`,
|
|
561
|
-
`,
|
|
562
|
-
`,
|
|
563
|
-
|
|
556
|
+
for (const [b, S] of Object.entries(s.uniforms))
|
|
557
|
+
typeof S == "number" ? (o += `uniform float ${b};
|
|
558
|
+
`, a[b] = { value: S }) : Array.isArray(S) ? S.length === 2 ? (o += `uniform vec2 ${b};
|
|
559
|
+
`, a[b] = { value: new w.Vector2(...S) }) : S.length === 3 ? (o += `uniform vec3 ${b};
|
|
560
|
+
`, a[b] = { value: new w.Vector3(...S) }) : S.length === 4 && (o += `uniform vec4 ${b};
|
|
561
|
+
`, a[b] = { value: new w.Vector4(...S) }) : S && typeof S == "object" && S.type ? (o += `uniform ${S.type} ${b};
|
|
562
|
+
`, a[b] = S) : (o += `uniform float ${b};
|
|
563
|
+
`, a[b] = { value: S });
|
|
564
|
+
const l = s !== void 0, n = (c || l ? De.declChunk : "") + `
|
|
564
565
|
` + o, u = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
|
|
565
566
|
`, h = i.isTraveler ? `vec2 resultUv = screenUv;
|
|
566
567
|
` : `vec2 localUv = (p / uSize) + 0.5;
|
|
567
568
|
vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
|
|
568
|
-
`, d =
|
|
569
|
+
`, d = c || l ? u + h + ((s == null ? void 0 : s.uvModifier) || "") : "", p = c || l ? De.baseColorChunk : "", f = (s == null ? void 0 : s.colorModifier) || "", L = Le.fragmentShader.replace("#INJECT_DECLARATIONS", n).replace("#INJECT_UV_MODIFIER", d).replace("#INJECT_BASE_COLOR", p).replace("#INJECT_COLOR_MODIFIER", f), m = ce(i.backgroundColor), y = ce(i.borderColor), E = {
|
|
569
570
|
uSize: { value: new w.Vector2(e, t) },
|
|
570
571
|
uMeshSize: { value: new w.Vector2(e, t) },
|
|
571
572
|
uShadowColor: { value: new w.Vector4(0, 0, 0, 0) },
|
|
@@ -582,14 +583,14 @@ vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
|
|
|
582
583
|
},
|
|
583
584
|
uBorderColor: {
|
|
584
585
|
value: new w.Vector4(
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
586
|
+
y.color.r,
|
|
587
|
+
y.color.g,
|
|
588
|
+
y.color.b,
|
|
589
|
+
y.alpha
|
|
589
590
|
)
|
|
590
591
|
},
|
|
591
592
|
uBorderRadius: { value: new w.Vector4(0, 0, 0, 0) },
|
|
592
|
-
uBorderWidth: { value:
|
|
593
|
+
uBorderWidth: { value: le(i.borderWidth) },
|
|
593
594
|
uOpacity: { value: (C = i.opacity) != null ? C : 1 },
|
|
594
595
|
uTexture: { value: null },
|
|
595
596
|
uTextureRepeat: { value: new w.Vector2(1, 1) },
|
|
@@ -601,9 +602,9 @@ vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
|
|
|
601
602
|
},
|
|
602
603
|
uGradientStops: { value: new Float32Array(8) }
|
|
603
604
|
};
|
|
604
|
-
Be(E.uBorderRadius.value, i.borderRadius, Math.min(e, t)),
|
|
605
|
+
Be(E.uBorderRadius.value, i.borderRadius, Math.min(e, t)), c && (E.uTexture.value = r);
|
|
605
606
|
const A = new w.ShaderMaterial({
|
|
606
|
-
uniforms: te(te({}, E),
|
|
607
|
+
uniforms: te(te({}, E), a),
|
|
607
608
|
vertexShader: Le.vertexShader,
|
|
608
609
|
fragmentShader: L,
|
|
609
610
|
transparent: !0,
|
|
@@ -613,12 +614,12 @@ vec2 resultUv = localUv * uTextureRepeat + uTextureOffset;
|
|
|
613
614
|
return i.backgroundImage && xe(A, { backgroundImage: i.backgroundImage }), A;
|
|
614
615
|
}
|
|
615
616
|
function it(i, e, t, r, s) {
|
|
616
|
-
const
|
|
617
|
+
const c = le(e.borderWidth);
|
|
617
618
|
xe(i, {
|
|
618
619
|
width: t,
|
|
619
620
|
height: r,
|
|
620
621
|
borderRadius: e.borderRadius,
|
|
621
|
-
borderWidth:
|
|
622
|
+
borderWidth: c,
|
|
622
623
|
backgroundColor: e.backgroundColor,
|
|
623
624
|
borderColor: e.borderColor,
|
|
624
625
|
opacity: e.opacity,
|
|
@@ -628,14 +629,14 @@ function it(i, e, t, r, s) {
|
|
|
628
629
|
});
|
|
629
630
|
}
|
|
630
631
|
function xe(i, e) {
|
|
631
|
-
var r, s,
|
|
632
|
+
var r, s, c;
|
|
632
633
|
if (e.boxShadow !== void 0) {
|
|
633
634
|
const o = Ke(e.boxShadow);
|
|
634
635
|
o ? (i.uniforms.uShadowColor.value.set(o.color.r, o.color.g, o.color.b, o.alpha), i.uniforms.uShadowOffset.value.set(o.offsetX, o.offsetY), i.uniforms.uShadowBlur.value = o.blurRadius, i.uniforms.uShadowSpread.value = o.spreadRadius, i.userData.shadowPadding = o.blurRadius + o.spreadRadius + Math.max(Math.abs(o.offsetX), Math.abs(o.offsetY))) : (i.uniforms.uShadowColor.value.w = 0, i.userData.shadowPadding = 0);
|
|
635
636
|
}
|
|
636
637
|
if (e.width !== void 0 && e.height !== void 0 && i.uniforms.uSize.value.set(e.width, e.height), i.uniforms.uMeshSize) {
|
|
637
|
-
const o = i.userData.shadowPadding || 0,
|
|
638
|
-
i.uniforms.uMeshSize.value.set(
|
|
638
|
+
const o = i.userData.shadowPadding || 0, a = e.width !== void 0 ? e.width : i.uniforms.uSize.value.x, l = e.height !== void 0 ? e.height : i.uniforms.uSize.value.y;
|
|
639
|
+
i.uniforms.uMeshSize.value.set(a + o * 2, l + o * 2);
|
|
639
640
|
}
|
|
640
641
|
if (e.borderRadius !== void 0) {
|
|
641
642
|
const o = e.width !== void 0 && e.height !== void 0 ? Math.min(e.width, e.height) : Math.min(i.uniforms.uSize.value.x, i.uniforms.uSize.value.y);
|
|
@@ -651,7 +652,7 @@ function xe(i, e) {
|
|
|
651
652
|
o
|
|
652
653
|
);
|
|
653
654
|
} else if (typeof e.backgroundColor == "string") {
|
|
654
|
-
const o =
|
|
655
|
+
const o = ce(e.backgroundColor);
|
|
655
656
|
i.uniforms.uBgColor.value.set(
|
|
656
657
|
o.color.r,
|
|
657
658
|
o.color.g,
|
|
@@ -677,7 +678,7 @@ function xe(i, e) {
|
|
|
677
678
|
o
|
|
678
679
|
);
|
|
679
680
|
} else if (typeof e.borderColor == "string") {
|
|
680
|
-
const o =
|
|
681
|
+
const o = ce(e.borderColor);
|
|
681
682
|
i.uniforms.uBorderColor.value.set(
|
|
682
683
|
o.color.r,
|
|
683
684
|
o.color.g,
|
|
@@ -696,9 +697,9 @@ function xe(i, e) {
|
|
|
696
697
|
e.opacity !== void 0 && (i.uniforms.uOpacity.value = e.opacity), e.bgOpacity !== void 0 && (i.uniforms.uBgColor.value.w = e.bgOpacity), e.borderOpacity !== void 0 && (i.uniforms.uBorderColor.value.w = e.borderOpacity), i.uniforms.uTexture && e.texture !== void 0 && (i.uniforms.uTexture.value = e.texture);
|
|
697
698
|
const t = e.texture !== void 0 ? e.texture : (r = i.uniforms.uTexture) == null ? void 0 : r.value;
|
|
698
699
|
if (t && (t.image instanceof ImageBitmap || t.image instanceof HTMLImageElement || t.image instanceof HTMLCanvasElement)) {
|
|
699
|
-
const o = t.image.naturalWidth || t.image.videoWidth || t.image.width,
|
|
700
|
-
if (o &&
|
|
701
|
-
const u = o /
|
|
700
|
+
const o = t.image.naturalWidth || t.image.videoWidth || t.image.width, a = t.image.naturalHeight || t.image.videoHeight || t.image.height, l = (s = e.width) != null ? s : i.uniforms.uSize.value.x, n = (c = e.height) != null ? c : i.uniforms.uSize.value.y;
|
|
701
|
+
if (o && a && l && n) {
|
|
702
|
+
const u = o / a, h = l / n;
|
|
702
703
|
if (u > h) {
|
|
703
704
|
const d = h / u;
|
|
704
705
|
i.uniforms.uTextureRepeat.value.set(d, 1), i.uniforms.uTextureOffset.value.set((1 - d) / 2, 0);
|
|
@@ -713,17 +714,17 @@ function xe(i, e) {
|
|
|
713
714
|
const o = je(e.backgroundImage);
|
|
714
715
|
if (o) {
|
|
715
716
|
i.uniforms.uGradientCount.value = o.stops.length, i.uniforms.uGradientAngle.value = o.angle;
|
|
716
|
-
for (let
|
|
717
|
-
if (
|
|
718
|
-
const
|
|
719
|
-
i.uniforms.uGradientColors.value[
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
), i.uniforms.uGradientStops.value[
|
|
717
|
+
for (let a = 0; a < 8; a++)
|
|
718
|
+
if (a < o.stops.length) {
|
|
719
|
+
const l = o.stops[a];
|
|
720
|
+
i.uniforms.uGradientColors.value[a].set(
|
|
721
|
+
l.color.r,
|
|
722
|
+
l.color.g,
|
|
723
|
+
l.color.b,
|
|
724
|
+
l.alpha
|
|
725
|
+
), i.uniforms.uGradientStops.value[a] = l.stop;
|
|
725
726
|
} else
|
|
726
|
-
i.uniforms.uGradientColors.value[
|
|
727
|
+
i.uniforms.uGradientColors.value[a].set(0, 0, 0, 0), i.uniforms.uGradientStops.value[a] = 1;
|
|
727
728
|
} else
|
|
728
729
|
i.uniforms.uGradientCount.value = 0;
|
|
729
730
|
}
|
|
@@ -731,7 +732,7 @@ function xe(i, e) {
|
|
|
731
732
|
o !== "width" && o !== "height" && o !== "borderRadius" && o !== "borderWidth" && o !== "backgroundColor" && o !== "borderColor" && o !== "opacity" && o !== "bgOpacity" && o !== "borderOpacity" && o !== "texture" && o !== "backgroundImage" && o !== "boxShadow" && i.uniforms[o] !== void 0 && (i.uniforms[o].value !== void 0 && i.uniforms[o].value !== null && typeof i.uniforms[o].value.set == "function" ? Array.isArray(e[o]) ? i.uniforms[o].value.set(...e[o]) : e[o] !== void 0 && (e[o].copy ? i.uniforms[o].value.copy(e[o]) : i.uniforms[o].value = e[o]) : i.uniforms[o].value = e[o]);
|
|
732
733
|
}
|
|
733
734
|
function Be(i, e, t = 0) {
|
|
734
|
-
var
|
|
735
|
+
var l, n, u, h;
|
|
735
736
|
if (e == null) {
|
|
736
737
|
i.set(0, 0, 0, 0);
|
|
737
738
|
return;
|
|
@@ -744,37 +745,37 @@ function Be(i, e, t = 0) {
|
|
|
744
745
|
i.set(e[0], e[1], e[2], e[3]);
|
|
745
746
|
return;
|
|
746
747
|
}
|
|
747
|
-
const r = e.split("/")[0].trim().split(/\s+/), s =
|
|
748
|
-
i.set(s,
|
|
748
|
+
const r = e.split("/")[0].trim().split(/\s+/), s = le(r[0], t), c = le((l = r[1]) != null ? l : r[0], t), o = le((n = r[2]) != null ? n : r[0], t), a = le((h = (u = r[3]) != null ? u : r[1]) != null ? h : r[0], t);
|
|
749
|
+
i.set(s, c, o, a);
|
|
749
750
|
}
|
|
750
|
-
const
|
|
751
|
-
create(i, e, t, r, s,
|
|
751
|
+
const W = {
|
|
752
|
+
create(i, e, t, r, s, c = 2, o = null, a) {
|
|
752
753
|
return i === "BOX" ? rt(
|
|
753
754
|
e,
|
|
754
755
|
r,
|
|
755
756
|
s,
|
|
756
757
|
o,
|
|
757
|
-
|
|
758
|
+
a
|
|
758
759
|
) : i === "TEXT" ? new $e(
|
|
759
760
|
t || "",
|
|
760
761
|
e,
|
|
761
762
|
r,
|
|
762
763
|
s,
|
|
763
|
-
|
|
764
|
+
c
|
|
764
765
|
) : new w.MeshBasicMaterial({ visible: !1 });
|
|
765
766
|
},
|
|
766
|
-
update(i, e, t, r, s,
|
|
767
|
+
update(i, e, t, r, s, c, o = 2, a) {
|
|
767
768
|
e === "BOX" ? it(
|
|
768
769
|
i,
|
|
769
770
|
t,
|
|
770
771
|
s,
|
|
771
|
-
|
|
772
|
-
|
|
772
|
+
c,
|
|
773
|
+
a
|
|
773
774
|
) : e === "TEXT" && i.updateText(
|
|
774
775
|
r || "",
|
|
775
776
|
t,
|
|
776
777
|
s,
|
|
777
|
-
|
|
778
|
+
c,
|
|
778
779
|
o
|
|
779
780
|
);
|
|
780
781
|
},
|
|
@@ -792,8 +793,8 @@ class st {
|
|
|
792
793
|
this.onUpdate = e, t && (this.observer = new IntersectionObserver(
|
|
793
794
|
(r) => {
|
|
794
795
|
for (const s of r) {
|
|
795
|
-
const
|
|
796
|
-
s.isIntersecting ? this.loadTexture(
|
|
796
|
+
const c = s.target;
|
|
797
|
+
s.isIntersecting ? this.loadTexture(c) : this.disposeTexture(c);
|
|
797
798
|
}
|
|
798
799
|
},
|
|
799
800
|
{ rootMargin: "300px" }
|
|
@@ -817,9 +818,9 @@ class st {
|
|
|
817
818
|
try {
|
|
818
819
|
let r;
|
|
819
820
|
if (t.startsWith("data:image/svg+xml"))
|
|
820
|
-
r = yield new Promise((
|
|
821
|
-
const
|
|
822
|
-
|
|
821
|
+
r = yield new Promise((c, o) => {
|
|
822
|
+
const a = new Image();
|
|
823
|
+
a.onload = () => c(a), a.onerror = o, a.src = t;
|
|
823
824
|
});
|
|
824
825
|
else {
|
|
825
826
|
const o = yield (yield fetch(t)).blob();
|
|
@@ -875,15 +876,15 @@ class ot {
|
|
|
875
876
|
g(this, "textureManager");
|
|
876
877
|
// private meshMap: Map<HTMLElement, THREE.Mesh> = new Map();
|
|
877
878
|
g(this, "fixedMeshes", /* @__PURE__ */ new Set());
|
|
878
|
-
var
|
|
879
|
-
this.target = e, this.mountContainer = r, this.registry = s, this.mode = (
|
|
879
|
+
var a, l, n, u, h;
|
|
880
|
+
this.target = e, this.mountContainer = r, this.registry = s, this.mode = (a = t.mode) != null ? a : "overlay", this.canvasSize = (l = t.canvasSize) != null ? l : "viewport", this.clipArea = (n = t.travelerClipArea) != null ? n : 1, this.targetLayer = (u = t.layer) != null ? u : "base", this.textureManager = new st((d, p) => {
|
|
880
881
|
const f = this.registry.get(d);
|
|
881
|
-
f && f.material instanceof w.ShaderMaterial &&
|
|
882
|
+
f && f.material instanceof w.ShaderMaterial && W.forceUpdateUniforms(f.material, { texture: p });
|
|
882
883
|
}, this.isViewport), this.canvas = document.createElement("canvas"), this.scene = new w.Scene(), this.targetRect = this.target.getBoundingClientRect();
|
|
883
|
-
const
|
|
884
|
+
const c = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, o = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
|
|
884
885
|
this.camera = new w.OrthographicCamera(
|
|
885
|
-
|
|
886
|
-
|
|
886
|
+
c / -2,
|
|
887
|
+
c / 2,
|
|
887
888
|
o / 2,
|
|
888
889
|
o / -2,
|
|
889
890
|
1,
|
|
@@ -894,7 +895,7 @@ class ot {
|
|
|
894
895
|
antialias: !0
|
|
895
896
|
// [new]
|
|
896
897
|
// premultipliedAlpha: true
|
|
897
|
-
}), w.ColorManagement.enabled = !1, this.renderer.outputColorSpace = w.LinearSRGBColorSpace, this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setSize(
|
|
898
|
+
}), w.ColorManagement.enabled = !1, this.renderer.outputColorSpace = w.LinearSRGBColorSpace, this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setSize(c, o), this.applyTextQuality((h = t.quality) != null ? h : "medium");
|
|
898
899
|
}
|
|
899
900
|
get isViewport() {
|
|
900
901
|
return this.mode === "overlay" && this.canvasSize === "viewport";
|
|
@@ -950,12 +951,12 @@ class ot {
|
|
|
950
951
|
updateUniforms(e, t) {
|
|
951
952
|
const r = this.registry.get(e);
|
|
952
953
|
r && (r.traverse((s) => {
|
|
953
|
-
s.isMesh && s.material &&
|
|
954
|
+
s.isMesh && s.material && W.forceUpdateUniforms(
|
|
954
955
|
s.material,
|
|
955
956
|
t
|
|
956
957
|
);
|
|
957
958
|
}), r.userData.nativeMesh && r.userData.nativeMesh.traverse((s) => {
|
|
958
|
-
s.isMesh && s.material &&
|
|
959
|
+
s.isMesh && s.material && W.forceUpdateUniforms(
|
|
959
960
|
s.material,
|
|
960
961
|
t
|
|
961
962
|
);
|
|
@@ -971,8 +972,8 @@ class ot {
|
|
|
971
972
|
this.camera.left = e / -2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = t / -2, this.camera.updateProjectionMatrix();
|
|
972
973
|
}
|
|
973
974
|
syncScene(e, t) {
|
|
974
|
-
const r = this.target.getBoundingClientRect(), s = this.isViewport ? window.innerWidth + this.overscan * 2 : r.width,
|
|
975
|
-
|
|
975
|
+
const r = this.target.getBoundingClientRect(), s = this.isViewport ? window.innerWidth + this.overscan * 2 : r.width, c = this.isViewport ? window.innerHeight + this.overscan * 2 : r.height, o = this.isViewport ? this.canvas.clientWidth : this.targetRect.width, a = this.isViewport ? this.canvas.clientHeight : this.targetRect.height, l = Math.abs(s - o) > 0.1 || Math.abs(c - a) > 0.1, n = this.mode === "overlay" && (Math.abs(r.top - this.targetRect.top) > 0.1 || Math.abs(r.left - this.targetRect.left) > 0.1);
|
|
976
|
+
l ? (this.targetRect = r, this.setSize(s, c), this.updateCanvasLayout()) : n ? (this.targetRect = r, this.updateCanvasLayout()) : this.targetRect = r, this.renderOrder = 0, this.reconcileNode(e), t.size > 0 && t.forEach((u) => {
|
|
976
977
|
const h = this.registry.get(u);
|
|
977
978
|
if (h) {
|
|
978
979
|
this.scene.remove(h);
|
|
@@ -991,23 +992,23 @@ class ot {
|
|
|
991
992
|
// => 이후 activeElements를 이용하여 mesh를 정리!!!+ map에서도 삭제
|
|
992
993
|
// private reconcileNode(node: SceneNode, activeElements: Set<HTMLElement>) {
|
|
993
994
|
reconcileNode(e) {
|
|
994
|
-
var s,
|
|
995
|
+
var s, c;
|
|
995
996
|
let t = this.registry.get(e.element);
|
|
996
997
|
const r = JSON.stringify(e.shaderHooks || null);
|
|
997
998
|
if (t && t.userData.shaderHash !== r && (this.scene.remove(t), t.geometry.dispose(), t.material instanceof w.Material && t.material.dispose(), this.registry.remove(e.element), t = void 0), !t) {
|
|
998
|
-
const o = new w.PlaneGeometry(1, 1),
|
|
999
|
+
const o = new w.PlaneGeometry(1, 1), a = e.isTraveler ? (s = this.renderTargets[e.captureLayer - 2]) == null ? void 0 : s.texture : this.textureManager.get(e.element), l = W.create(
|
|
999
1000
|
"BOX",
|
|
1000
1001
|
e.styles,
|
|
1001
1002
|
"",
|
|
1002
1003
|
e.rect.width,
|
|
1003
1004
|
e.rect.height,
|
|
1004
1005
|
this.qualityFactor,
|
|
1005
|
-
|
|
1006
|
+
a,
|
|
1006
1007
|
e.shaderHooks
|
|
1007
1008
|
);
|
|
1008
|
-
t = new w.Mesh(o,
|
|
1009
|
+
t = new w.Mesh(o, l), e.type === "TEXT" && (t.name = "BG_MESH"), this.scene.add(t), this.registry.register(e.element, t), t.userData.baseMaterial = l, t.userData.domElement = e.element, t.userData.shaderHash = r;
|
|
1009
1010
|
}
|
|
1010
|
-
if (t.userData.clipElements = e.clipElements, (
|
|
1011
|
+
if (t.userData.clipElements = e.clipElements, (c = e.nativeStyles) != null && c.transform ? t.userData.nativeTransform = e.nativeStyles.transform : t.userData.nativeTransform = void 0, this.updateMeshProperties(t, e), this.updateMeshLayers(t, e), e.isTraveler)
|
|
1011
1012
|
for (let o = 0; o < N.MAX_LAYERS; o++)
|
|
1012
1013
|
o === e.captureLayer - 2 ? this.travelersByLayer[o].add(t) : this.travelersByLayer[o].delete(t);
|
|
1013
1014
|
else
|
|
@@ -1024,11 +1025,11 @@ class ot {
|
|
|
1024
1025
|
));
|
|
1025
1026
|
}
|
|
1026
1027
|
reconcileTextChild(e, t, r) {
|
|
1027
|
-
var
|
|
1028
|
+
var n;
|
|
1028
1029
|
const s = t.textLines || [
|
|
1029
1030
|
{ text: t.textContent || "", rect: t.rect }
|
|
1030
|
-
],
|
|
1031
|
-
if (t.dirtyMask & ye || o !==
|
|
1031
|
+
], c = r ? t.nativeStyles : t.textStyles, o = JSON.stringify(c) + t.textContent + s.map((u) => u.text).join("|"), a = (n = e.userData) == null ? void 0 : n.textChildStyleHash;
|
|
1032
|
+
if (t.dirtyMask & ye || o !== a) {
|
|
1032
1033
|
e.children.filter(
|
|
1033
1034
|
(f) => f.name.startsWith("TEXT_CHILD")
|
|
1034
1035
|
).forEach((f) => {
|
|
@@ -1038,18 +1039,18 @@ class ot {
|
|
|
1038
1039
|
});
|
|
1039
1040
|
const h = t.rect, d = h.x + h.width / 2, p = h.y + h.height / 2;
|
|
1040
1041
|
s.forEach((f, L) => {
|
|
1041
|
-
const m =
|
|
1042
|
+
const m = W.create(
|
|
1042
1043
|
"TEXT",
|
|
1043
|
-
|
|
1044
|
+
c,
|
|
1044
1045
|
f.text,
|
|
1045
1046
|
f.rect.width,
|
|
1046
1047
|
f.rect.height,
|
|
1047
1048
|
this.qualityFactor
|
|
1048
|
-
),
|
|
1049
|
+
), y = new w.PlaneGeometry(1, 1), E = new w.Mesh(y, m);
|
|
1049
1050
|
E.name = `TEXT_CHILD_${L}`;
|
|
1050
1051
|
const A = t.rect.width === 0 ? 1 : f.rect.width / t.rect.width, C = t.rect.height === 0 ? 1 : f.rect.height / t.rect.height;
|
|
1051
1052
|
E.scale.set(A, C, 1);
|
|
1052
|
-
const
|
|
1053
|
+
const b = f.rect.x + f.rect.width / 2, S = f.rect.y + f.rect.height / 2, X = b - d, z = -(S - p);
|
|
1053
1054
|
E.position.set(
|
|
1054
1055
|
t.rect.width === 0 ? 0 : X / t.rect.width,
|
|
1055
1056
|
t.rect.height === 0 ? 0 : z / t.rect.height,
|
|
@@ -1076,17 +1077,17 @@ class ot {
|
|
|
1076
1077
|
});
|
|
1077
1078
|
}
|
|
1078
1079
|
updateMeshProperties(e, t) {
|
|
1079
|
-
var C,
|
|
1080
|
-
const { rect: r, styles: s } = t,
|
|
1080
|
+
var C, b, S, X, z;
|
|
1081
|
+
const { rect: r, styles: s } = t, c = this.renderer.getPixelRatio(), o = this.renderer.domElement.width / c, a = this.renderer.domElement.height / c;
|
|
1081
1082
|
e.material = e.userData.baseMaterial;
|
|
1082
|
-
let
|
|
1083
|
-
e.scale.set(r.width +
|
|
1083
|
+
let l = ((C = e.material.userData) == null ? void 0 : C.shadowPadding) || 0;
|
|
1084
|
+
e.scale.set(r.width + l * 2, r.height + l * 2, 1), e.userData.domRect = {
|
|
1084
1085
|
x: r.x,
|
|
1085
1086
|
y: r.y,
|
|
1086
1087
|
width: r.width,
|
|
1087
1088
|
height: r.height
|
|
1088
1089
|
};
|
|
1089
|
-
const
|
|
1090
|
+
const n = 1e-3;
|
|
1090
1091
|
this.renderOrder++;
|
|
1091
1092
|
const u = this.targetRect.left + window.scrollX, h = this.targetRect.top + window.scrollY;
|
|
1092
1093
|
let d, p;
|
|
@@ -1094,22 +1095,22 @@ class ot {
|
|
|
1094
1095
|
d = r.x - window.innerWidth / 2 + r.width / 2, p = -r.y + window.innerHeight / 2 - r.height / 2;
|
|
1095
1096
|
else {
|
|
1096
1097
|
const U = r.x - u, I = r.y - h;
|
|
1097
|
-
d = U - o / 2 + r.width / 2, p = -I +
|
|
1098
|
+
d = U - o / 2 + r.width / 2, p = -I + a / 2 - r.height / 2;
|
|
1098
1099
|
}
|
|
1099
1100
|
e.position.set(
|
|
1100
1101
|
d,
|
|
1101
1102
|
p,
|
|
1102
|
-
s.zIndex + this.renderOrder *
|
|
1103
|
+
s.zIndex + this.renderOrder * n
|
|
1103
1104
|
);
|
|
1104
1105
|
const f = r.x, L = r.y;
|
|
1105
1106
|
e.userData.basePosition = { x: d, y: p }, e.userData.originalBasePosition = { x: d, y: p }, e.userData.baseSize = { width: r.width, height: r.height }, e.userData.baseDOM = { x: f, y: L }, e.userData.isFixed = t.isFixed, e.userData.initialScroll = { x: window.scrollX, y: window.scrollY };
|
|
1106
|
-
const m = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element,
|
|
1107
|
+
const m = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element, y = window.getComputedStyle(m);
|
|
1107
1108
|
let E = 0, A = 0;
|
|
1108
|
-
if (
|
|
1109
|
-
const U = new DOMMatrix(
|
|
1109
|
+
if (y.transform && y.transform !== "none") {
|
|
1110
|
+
const U = new DOMMatrix(y.transform);
|
|
1110
1111
|
E = U.m41, A = U.m42;
|
|
1111
1112
|
}
|
|
1112
|
-
if (e.userData.baseTransform = { x: E, y: A }, delete e.userData.originRatioX, delete e.userData.originRatioY,
|
|
1113
|
+
if (e.userData.baseTransform = { x: E, y: A }, delete e.userData.originRatioX, delete e.userData.originRatioY, W.update(
|
|
1113
1114
|
e.userData.baseMaterial,
|
|
1114
1115
|
"BOX",
|
|
1115
1116
|
s,
|
|
@@ -1117,10 +1118,10 @@ class ot {
|
|
|
1117
1118
|
r.width,
|
|
1118
1119
|
r.height,
|
|
1119
1120
|
this.qualityFactor,
|
|
1120
|
-
t.isTraveler ? (
|
|
1121
|
+
t.isTraveler ? (b = this.renderTargets[t.captureLayer - 2]) == null ? void 0 : b.texture : this.textureManager.get(t.element)
|
|
1121
1122
|
), t.nativeStyles && t.nativeRect) {
|
|
1122
1123
|
if (!e.userData.nativeMesh) {
|
|
1123
|
-
const B =
|
|
1124
|
+
const B = W.create(
|
|
1124
1125
|
"BOX",
|
|
1125
1126
|
t.nativeStyles,
|
|
1126
1127
|
"",
|
|
@@ -1138,7 +1139,7 @@ class ot {
|
|
|
1138
1139
|
I = t.nativeRect.x - window.innerWidth / 2 + t.nativeRect.width / 2, j = -t.nativeRect.y + window.innerHeight / 2 - t.nativeRect.height / 2;
|
|
1139
1140
|
else {
|
|
1140
1141
|
const B = t.nativeRect.x - u, V = t.nativeRect.y - h;
|
|
1141
|
-
I = B - o / 2 + t.nativeRect.width / 2, j = -V +
|
|
1142
|
+
I = B - o / 2 + t.nativeRect.width / 2, j = -V + a / 2 - t.nativeRect.height / 2;
|
|
1142
1143
|
}
|
|
1143
1144
|
let J = t.nativeRect.width, Z = t.nativeRect.height, M = I, O = j;
|
|
1144
1145
|
if (t.nativeStyles.transform) {
|
|
@@ -1182,8 +1183,8 @@ class ot {
|
|
|
1182
1183
|
U.scale.set(J + K * 2, Z + K * 2, 1), U.position.set(
|
|
1183
1184
|
M,
|
|
1184
1185
|
O,
|
|
1185
|
-
t.nativeStyles.zIndex + this.renderOrder *
|
|
1186
|
-
),
|
|
1186
|
+
t.nativeStyles.zIndex + this.renderOrder * n
|
|
1187
|
+
), W.update(
|
|
1187
1188
|
U.material,
|
|
1188
1189
|
"BOX",
|
|
1189
1190
|
t.nativeStyles,
|
|
@@ -1202,8 +1203,8 @@ class ot {
|
|
|
1202
1203
|
const s = e.userData.nativeMesh;
|
|
1203
1204
|
if (s.layers.set(F.HIDDEN), t.visibility & G) {
|
|
1204
1205
|
s.layers.enable(F.getCaptureLayer(t.nativeLayer));
|
|
1205
|
-
for (let
|
|
1206
|
-
|
|
1206
|
+
for (let c = t.captureLayer; c <= N.MAX_LAYERS + 1; c++)
|
|
1207
|
+
c !== t.nativeLayer && e.layers.enable(F.getCaptureLayer(c));
|
|
1207
1208
|
}
|
|
1208
1209
|
} else if (t.visibility & G)
|
|
1209
1210
|
for (let s = t.captureLayer; s <= N.MAX_LAYERS + 1; s++)
|
|
@@ -1212,104 +1213,107 @@ class ot {
|
|
|
1212
1213
|
captureRenderTarget(e, t, r) {
|
|
1213
1214
|
if (e.size === 0 || !r)
|
|
1214
1215
|
return;
|
|
1215
|
-
const s = new w.Color(),
|
|
1216
|
+
const s = new w.Color(), c = this.renderer.getClearAlpha();
|
|
1216
1217
|
this.renderer.getClearColor(s), this.renderer.setClearColor(0, 0), this.renderer.setRenderTarget(r), this.renderer.clear(), this.renderer.autoClear = !1, this.renderer.setScissorTest(!0), this.camera.layers.set(t);
|
|
1217
|
-
const o = new w.Vector3(),
|
|
1218
|
+
const o = new w.Vector3(), a = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, l = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height, n = this.renderer.getPixelRatio();
|
|
1218
1219
|
for (const u of e) {
|
|
1219
1220
|
o.setFromMatrixPosition(u.matrixWorld), o.project(this.camera);
|
|
1220
|
-
const h = (o.x + 1) / 2 *
|
|
1221
|
+
const h = (o.x + 1) / 2 * a, d = (o.y + 1) / 2 * l;
|
|
1221
1222
|
let p = 0, f = 1;
|
|
1222
1223
|
typeof this.clipArea == "number" ? f = this.clipArea : this.clipArea.endsWith("%") ? f = parseFloat(this.clipArea) / 100 : this.clipArea.endsWith("px") && (p = parseFloat(this.clipArea));
|
|
1223
|
-
const L = u.scale.x * f + 0.5, m = u.scale.y * f + 0.5,
|
|
1224
|
-
this.renderer.setScissor(A, C,
|
|
1224
|
+
const L = u.scale.x * f + 0.5, m = u.scale.y * f + 0.5, y = h - L / 2, E = d - m / 2, A = (y * this.qualityFactor - p) / n, C = (E * this.qualityFactor - p) / n, b = (L * this.qualityFactor + p * 2) / n, S = (m * this.qualityFactor + p * 2) / n;
|
|
1225
|
+
this.renderer.setScissor(A, C, b, S), this.renderer.render(this.scene, this.camera);
|
|
1225
1226
|
}
|
|
1226
|
-
this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(s,
|
|
1227
|
+
this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(s, c);
|
|
1227
1228
|
}
|
|
1228
1229
|
render() {
|
|
1229
|
-
for (let
|
|
1230
|
-
const
|
|
1230
|
+
for (let l = 0; l < N.MAX_LAYERS; l++) {
|
|
1231
|
+
const n = l + 1;
|
|
1231
1232
|
this.captureRenderTarget(
|
|
1232
|
-
this.travelersByLayer[
|
|
1233
|
-
F.getCaptureLayer(
|
|
1234
|
-
this.renderTargets[
|
|
1233
|
+
this.travelersByLayer[l],
|
|
1234
|
+
F.getCaptureLayer(n),
|
|
1235
|
+
this.renderTargets[l]
|
|
1235
1236
|
);
|
|
1236
1237
|
}
|
|
1237
|
-
const e = this.renderer.getContext(), t = this.renderer.getPixelRatio(), r = this.renderer.domElement.height / t, s = this.renderer.domElement,
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
(
|
|
1244
|
-
|
|
1245
|
-
c.onBeforeRender = () => {
|
|
1246
|
-
e.enable(e.SCISSOR_TEST), e.scissor(h, d, p, f);
|
|
1247
|
-
}, c.onAfterRender = () => {
|
|
1238
|
+
const e = this.renderer.getContext(), t = this.renderer.getPixelRatio(), r = this.renderer.domElement.height / t, s = this.renderer.domElement, c = s.getBoundingClientRect().top, o = s.getBoundingClientRect().left, a = (l, n) => {
|
|
1239
|
+
if (n && n.width > 0 && n.height > 0) {
|
|
1240
|
+
const u = Math.floor((n.x - o) * t), h = Math.floor(
|
|
1241
|
+
(r - (n.y - c + n.height)) * t
|
|
1242
|
+
), d = Math.ceil(n.width * t), p = Math.ceil(n.height * t);
|
|
1243
|
+
l.onBeforeRender = () => {
|
|
1244
|
+
e.enable(e.SCISSOR_TEST), e.scissor(u, h, d, p);
|
|
1245
|
+
}, l.onAfterRender = () => {
|
|
1248
1246
|
e.disable(e.SCISSOR_TEST);
|
|
1249
|
-
};
|
|
1247
|
+
}, l.__hasScissorHook = !0;
|
|
1250
1248
|
} else
|
|
1251
|
-
|
|
1252
|
-
},
|
|
1253
|
-
},
|
|
1254
|
-
|
|
1249
|
+
l.__hasScissorHook && (l.onBeforeRender = () => {
|
|
1250
|
+
}, l.onAfterRender = () => {
|
|
1251
|
+
}, l.__hasScissorHook = !1);
|
|
1252
|
+
};
|
|
1253
|
+
this.scene.children.forEach((l) => {
|
|
1254
|
+
var h;
|
|
1255
|
+
const n = l, u = (h = n.userData) == null ? void 0 : h.scissorRect;
|
|
1256
|
+
a(n, u), n.children.forEach((d) => {
|
|
1257
|
+
d.name.startsWith("TEXT_CHILD") && a(d, u);
|
|
1258
|
+
});
|
|
1255
1259
|
}), this.renderer.render(this.scene, this.camera);
|
|
1256
1260
|
}
|
|
1257
1261
|
syncMeshesByDOM() {
|
|
1258
|
-
const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, r = this.renderer.getPixelRatio(), s = this.renderer.domElement.width / r,
|
|
1262
|
+
const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, r = this.renderer.getPixelRatio(), s = this.renderer.domElement.width / r, c = this.renderer.domElement.height / r;
|
|
1259
1263
|
this.scene.children.forEach((o) => {
|
|
1260
1264
|
var h, d;
|
|
1261
|
-
const
|
|
1262
|
-
if (!
|
|
1265
|
+
const a = o;
|
|
1266
|
+
if (!a.userData || !a.userData.domElement)
|
|
1263
1267
|
return;
|
|
1264
|
-
const
|
|
1265
|
-
if (!
|
|
1268
|
+
const l = a.userData.domElement;
|
|
1269
|
+
if (!l.isConnected)
|
|
1266
1270
|
return;
|
|
1267
|
-
let
|
|
1268
|
-
if (
|
|
1271
|
+
let n;
|
|
1272
|
+
if (l.nodeType === Node.TEXT_NODE) {
|
|
1269
1273
|
const p = document.createRange();
|
|
1270
|
-
p.selectNode(
|
|
1274
|
+
p.selectNode(l), n = p.getBoundingClientRect();
|
|
1271
1275
|
} else
|
|
1272
|
-
|
|
1273
|
-
const u =
|
|
1274
|
-
if (!u || Math.abs(
|
|
1275
|
-
|
|
1276
|
-
x:
|
|
1277
|
-
y:
|
|
1278
|
-
width:
|
|
1279
|
-
height:
|
|
1276
|
+
n = l.getBoundingClientRect();
|
|
1277
|
+
const u = a.userData.domRect;
|
|
1278
|
+
if (!u || Math.abs(n.x - u.x) > 0.5 || Math.abs(n.y - u.y) > 0.5 || Math.abs(n.width - u.width) > 0.5 || Math.abs(n.height - u.height) > 0.5) {
|
|
1279
|
+
a.userData.domRect = {
|
|
1280
|
+
x: n.x,
|
|
1281
|
+
y: n.y,
|
|
1282
|
+
width: n.width,
|
|
1283
|
+
height: n.height
|
|
1280
1284
|
};
|
|
1281
|
-
const p =
|
|
1285
|
+
const p = a.userData.clipElements;
|
|
1282
1286
|
if (p && p.length > 0) {
|
|
1283
|
-
let
|
|
1284
|
-
for (const
|
|
1285
|
-
const S =
|
|
1286
|
-
|
|
1287
|
+
let y = -1 / 0, E = -1 / 0, A = 1 / 0, C = 1 / 0;
|
|
1288
|
+
for (const b of p) {
|
|
1289
|
+
const S = b.getBoundingClientRect();
|
|
1290
|
+
y = Math.max(y, S.left), E = Math.max(E, S.top), A = Math.min(A, S.right), C = Math.min(C, S.bottom);
|
|
1287
1291
|
}
|
|
1288
|
-
|
|
1289
|
-
x:
|
|
1292
|
+
a.userData.scissorRect = {
|
|
1293
|
+
x: y,
|
|
1290
1294
|
y: E,
|
|
1291
|
-
width: Math.max(0, A -
|
|
1295
|
+
width: Math.max(0, A - y),
|
|
1292
1296
|
height: Math.max(0, C - E)
|
|
1293
1297
|
};
|
|
1294
1298
|
} else
|
|
1295
|
-
|
|
1299
|
+
a.userData.scissorRect = void 0;
|
|
1296
1300
|
let f, L;
|
|
1297
1301
|
if (this.isViewport)
|
|
1298
|
-
f =
|
|
1302
|
+
f = n.x - window.innerWidth / 2 + n.width / 2, L = -n.y + window.innerHeight / 2 - n.height / 2;
|
|
1299
1303
|
else {
|
|
1300
|
-
const
|
|
1301
|
-
f =
|
|
1304
|
+
const y = n.x - e, E = n.y - t;
|
|
1305
|
+
f = y - s / 2 + n.width / 2, L = -E + c / 2 - n.height / 2;
|
|
1302
1306
|
}
|
|
1303
|
-
|
|
1304
|
-
let m = ((h =
|
|
1305
|
-
if (
|
|
1306
|
-
width:
|
|
1307
|
-
height:
|
|
1308
|
-
}),
|
|
1309
|
-
const
|
|
1310
|
-
let E =
|
|
1311
|
-
if (
|
|
1312
|
-
const X =
|
|
1307
|
+
a.position.setX(f), a.position.setY(L);
|
|
1308
|
+
let m = ((h = a.material.userData) == null ? void 0 : h.shadowPadding) || 0;
|
|
1309
|
+
if (a.scale.set(n.width + m * 2, n.height + m * 2, 1), a.updateMatrixWorld(), a.material instanceof w.ShaderMaterial && W.forceUpdateUniforms(a.material, {
|
|
1310
|
+
width: n.width,
|
|
1311
|
+
height: n.height
|
|
1312
|
+
}), a.userData.nativeMesh) {
|
|
1313
|
+
const y = a.userData.nativeMesh;
|
|
1314
|
+
let E = n.width, A = n.height, C = f, b = L;
|
|
1315
|
+
if (a.userData.nativeTransform) {
|
|
1316
|
+
const X = a.userData.nativeTransform, z = X.match(/scale\(([\d.]+%?)\)/);
|
|
1313
1317
|
if (z) {
|
|
1314
1318
|
let M = parseFloat(z[1]);
|
|
1315
1319
|
z[1].includes("%") && (M /= 100), E *= M, A *= M;
|
|
@@ -1328,25 +1332,25 @@ class ot {
|
|
|
1328
1332
|
if (j) {
|
|
1329
1333
|
const M = j[1].trim(), O = j[2].trim();
|
|
1330
1334
|
let K = parseFloat(M);
|
|
1331
|
-
M.includes("%") && (K = K / 100 *
|
|
1335
|
+
M.includes("%") && (K = K / 100 * n.width);
|
|
1332
1336
|
let B = parseFloat(O);
|
|
1333
|
-
O.includes("%") && (B = B / 100 *
|
|
1337
|
+
O.includes("%") && (B = B / 100 * n.height), C += K, b -= B;
|
|
1334
1338
|
}
|
|
1335
1339
|
const J = X.match(/translateX\(([^)]+)\)/);
|
|
1336
1340
|
if (J) {
|
|
1337
1341
|
const M = J[1].trim();
|
|
1338
1342
|
let O = parseFloat(M);
|
|
1339
|
-
M.includes("%") && (O = O / 100 *
|
|
1343
|
+
M.includes("%") && (O = O / 100 * n.width), C += O;
|
|
1340
1344
|
}
|
|
1341
1345
|
const Z = X.match(/translateY\(([^)]+)\)/);
|
|
1342
1346
|
if (Z) {
|
|
1343
1347
|
const M = Z[1].trim();
|
|
1344
1348
|
let O = parseFloat(M);
|
|
1345
|
-
M.includes("%") && (O = O / 100 *
|
|
1349
|
+
M.includes("%") && (O = O / 100 * n.height), b -= O;
|
|
1346
1350
|
}
|
|
1347
1351
|
}
|
|
1348
|
-
let S = ((d =
|
|
1349
|
-
|
|
1352
|
+
let S = ((d = y.material.userData) == null ? void 0 : d.shadowPadding) || 0;
|
|
1353
|
+
y.position.setX(C), y.position.setY(b), y.scale.set(E + S * 2, A + S * 2, 1), y.updateMatrixWorld(), y.material instanceof w.ShaderMaterial && W.forceUpdateUniforms(y.material, {
|
|
1350
1354
|
width: E,
|
|
1351
1355
|
height: A
|
|
1352
1356
|
});
|
|
@@ -1357,17 +1361,17 @@ class ot {
|
|
|
1357
1361
|
}
|
|
1358
1362
|
function nt(i) {
|
|
1359
1363
|
const e = i.textContent || "", t = [];
|
|
1360
|
-
let r = "", s = null,
|
|
1361
|
-
const o = (
|
|
1362
|
-
for (let h = 0; h <
|
|
1363
|
-
const d =
|
|
1364
|
+
let r = "", s = null, c = -1;
|
|
1365
|
+
const o = (n, u) => {
|
|
1366
|
+
for (let h = 0; h < n.length; h++) {
|
|
1367
|
+
const d = n[h], p = document.createRange();
|
|
1364
1368
|
p.setStart(i, u + h), p.setEnd(i, u + h + 1);
|
|
1365
1369
|
const f = p.getBoundingClientRect();
|
|
1366
1370
|
if (f.width === 0 && f.height === 0) {
|
|
1367
1371
|
r += d;
|
|
1368
1372
|
continue;
|
|
1369
1373
|
}
|
|
1370
|
-
|
|
1374
|
+
c === -1 || Math.abs(f.top - c) > f.height / 2 ? (r && s && t.push({
|
|
1371
1375
|
text: r,
|
|
1372
1376
|
rect: {
|
|
1373
1377
|
left: s.left,
|
|
@@ -1380,26 +1384,26 @@ function nt(i) {
|
|
|
1380
1384
|
top: f.top,
|
|
1381
1385
|
right: f.right,
|
|
1382
1386
|
bottom: f.bottom
|
|
1383
|
-
},
|
|
1387
|
+
}, c = f.top) : (r += d, s && (s.left = Math.min(s.left, f.left), s.top = Math.min(s.top, f.top), s.right = Math.max(s.right, f.right), s.bottom = Math.max(
|
|
1384
1388
|
s.bottom,
|
|
1385
1389
|
f.bottom
|
|
1386
1390
|
)));
|
|
1387
1391
|
}
|
|
1388
|
-
},
|
|
1389
|
-
let
|
|
1390
|
-
for (const
|
|
1392
|
+
}, a = e.match(/[^\s\-]+\-?|\-|\s+/g) || [];
|
|
1393
|
+
let l = 0;
|
|
1394
|
+
for (const n of a) {
|
|
1391
1395
|
const u = document.createRange();
|
|
1392
|
-
u.setStart(i,
|
|
1396
|
+
u.setStart(i, l), u.setEnd(i, l + n.length);
|
|
1393
1397
|
const h = u.getClientRects();
|
|
1394
1398
|
if (h.length > 1)
|
|
1395
|
-
o(
|
|
1399
|
+
o(n, l);
|
|
1396
1400
|
else {
|
|
1397
1401
|
const d = h.length === 1 ? h[0] : u.getBoundingClientRect();
|
|
1398
1402
|
if (d.width === 0 && d.height === 0) {
|
|
1399
|
-
r +=
|
|
1403
|
+
r += n, l += n.length;
|
|
1400
1404
|
continue;
|
|
1401
1405
|
}
|
|
1402
|
-
|
|
1406
|
+
c === -1 || Math.abs(d.top - c) > d.height / 2 ? (r && s && t.push({
|
|
1403
1407
|
text: r,
|
|
1404
1408
|
rect: {
|
|
1405
1409
|
left: s.left,
|
|
@@ -1407,17 +1411,17 @@ function nt(i) {
|
|
|
1407
1411
|
width: s.right - s.left,
|
|
1408
1412
|
height: s.bottom - s.top
|
|
1409
1413
|
}
|
|
1410
|
-
}), r =
|
|
1414
|
+
}), r = n, s = {
|
|
1411
1415
|
left: d.left,
|
|
1412
1416
|
top: d.top,
|
|
1413
1417
|
right: d.right,
|
|
1414
1418
|
bottom: d.bottom
|
|
1415
|
-
},
|
|
1419
|
+
}, c = d.top) : (r += n, s && (s.left = Math.min(s.left, d.left), s.top = Math.min(s.top, d.top), s.right = Math.max(s.right, d.right), s.bottom = Math.max(
|
|
1416
1420
|
s.bottom,
|
|
1417
1421
|
d.bottom
|
|
1418
1422
|
)));
|
|
1419
1423
|
}
|
|
1420
|
-
|
|
1424
|
+
l += n.length;
|
|
1421
1425
|
}
|
|
1422
1426
|
return r && s && t.push({
|
|
1423
1427
|
text: r,
|
|
@@ -1428,7 +1432,7 @@ function nt(i) {
|
|
|
1428
1432
|
height: s.bottom - s.top
|
|
1429
1433
|
}
|
|
1430
1434
|
}), t.filter(
|
|
1431
|
-
(
|
|
1435
|
+
(n) => n.text.trim().length > 0 && n.rect.width > 0 && n.rect.height > 0
|
|
1432
1436
|
);
|
|
1433
1437
|
}
|
|
1434
1438
|
function Ae(i) {
|
|
@@ -1447,7 +1451,7 @@ function Ae(i) {
|
|
|
1447
1451
|
letterSpacing: r
|
|
1448
1452
|
};
|
|
1449
1453
|
}
|
|
1450
|
-
function Fe(i, e = re | ue |
|
|
1454
|
+
function Fe(i, e = re | ue | Pe | ye | pe, t, r = 1, s = 0, c = 2, o, a, l) {
|
|
1451
1455
|
var K, B, V, ie, se, oe, he;
|
|
1452
1456
|
if (i.nodeType === Node.TEXT_NODE) {
|
|
1453
1457
|
const v = i;
|
|
@@ -1500,7 +1504,7 @@ function Fe(i, e = re | ue | We | ye | pe, t, r = 1, s = 0, l = 2, o, n, c) {
|
|
|
1500
1504
|
captureLayer: r,
|
|
1501
1505
|
isFixed: D.position === "fixed",
|
|
1502
1506
|
nativeLayer: o,
|
|
1503
|
-
nativeStyles:
|
|
1507
|
+
nativeStyles: a ? te(te({
|
|
1504
1508
|
backgroundColor: "transparent",
|
|
1505
1509
|
backgroundImage: "",
|
|
1506
1510
|
opacity: _ && _.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(D.opacity),
|
|
@@ -1509,20 +1513,20 @@ function Fe(i, e = re | ue | We | ye | pe, t, r = 1, s = 0, l = 2, o, n, c) {
|
|
|
1509
1513
|
borderColor: "transparent",
|
|
1510
1514
|
borderWidth: "0px",
|
|
1511
1515
|
isTraveler: !1
|
|
1512
|
-
}, Ae(D)),
|
|
1513
|
-
nativeRect:
|
|
1516
|
+
}, Ae(D)), a) : void 0,
|
|
1517
|
+
nativeRect: a ? {
|
|
1514
1518
|
x: q + window.scrollX,
|
|
1515
1519
|
y: Y + window.scrollY,
|
|
1516
1520
|
width: Q - q,
|
|
1517
1521
|
height: k - Y
|
|
1518
1522
|
} : void 0,
|
|
1519
|
-
clipElements:
|
|
1523
|
+
clipElements: l,
|
|
1520
1524
|
children: []
|
|
1521
1525
|
};
|
|
1522
1526
|
}
|
|
1523
1527
|
if (i.nodeType !== Node.ELEMENT_NODE)
|
|
1524
1528
|
return null;
|
|
1525
|
-
const
|
|
1529
|
+
const n = i, u = n.dataset[H.KEY];
|
|
1526
1530
|
let h = t, d = t;
|
|
1527
1531
|
if (u) {
|
|
1528
1532
|
const v = new Set(u.split(/\s+/));
|
|
@@ -1543,7 +1547,7 @@ function Fe(i, e = re | ue | We | ye | pe, t, r = 1, s = 0, l = 2, o, n, c) {
|
|
|
1543
1547
|
);
|
|
1544
1548
|
v.has(H.VALUES.INCLUDE_TREE) ? h = h | G : v.has(H.VALUES.EXCLUDE_TREE) && (h = h & ~G), d = h, v.has(H.VALUES.INCLUDE_SELF) ? d = d | G : v.has(H.VALUES.EXCLUDE_SELF) && (d = d & ~G);
|
|
1545
1549
|
}
|
|
1546
|
-
const p =
|
|
1550
|
+
const p = n.dataset[$.KEY];
|
|
1547
1551
|
if (p) {
|
|
1548
1552
|
const v = new Set(p.split(/\s+/));
|
|
1549
1553
|
for (const x of v)
|
|
@@ -1563,8 +1567,8 @@ function Fe(i, e = re | ue | We | ye | pe, t, r = 1, s = 0, l = 2, o, n, c) {
|
|
|
1563
1567
|
);
|
|
1564
1568
|
v.has($.VALUES.INCLUDE_TREE) ? h = h | ae : v.has($.VALUES.EXCLUDE_TREE) && (h = h & ~ae), d = h, v.has($.VALUES.INCLUDE_SELF) ? d = d | ae : v.has($.VALUES.EXCLUDE_SELF) && (d = d & ~ae);
|
|
1565
1569
|
}
|
|
1566
|
-
const f =
|
|
1567
|
-
let L = !1, m =
|
|
1570
|
+
const f = n.dataset[N.KEY];
|
|
1571
|
+
let L = !1, m = a ? te({}, a) : {}, y = o;
|
|
1568
1572
|
if (f) {
|
|
1569
1573
|
let v = 1;
|
|
1570
1574
|
const x = f.indexOf("{"), T = f.lastIndexOf("}");
|
|
@@ -1597,10 +1601,10 @@ function Fe(i, e = re | ue | We | ye | pe, t, r = 1, s = 0, l = 2, o, n, c) {
|
|
|
1597
1601
|
if (Q !== -1) {
|
|
1598
1602
|
const k = D[Q + 1];
|
|
1599
1603
|
if (k && !isNaN(parseInt(k, 10)))
|
|
1600
|
-
|
|
1604
|
+
y = parseInt(k, 10);
|
|
1601
1605
|
else if (!L) {
|
|
1602
1606
|
const R = D.find((ne) => !isNaN(parseInt(ne, 10)));
|
|
1603
|
-
R && (
|
|
1607
|
+
R && (y = parseInt(R, 10));
|
|
1604
1608
|
}
|
|
1605
1609
|
}
|
|
1606
1610
|
if (q) {
|
|
@@ -1612,66 +1616,66 @@ function Fe(i, e = re | ue | We | ye | pe, t, r = 1, s = 0, l = 2, o, n, c) {
|
|
|
1612
1616
|
r = Math.min(k, N.MAX_LAYERS + 1);
|
|
1613
1617
|
}
|
|
1614
1618
|
}
|
|
1615
|
-
const E =
|
|
1619
|
+
const E = n.dataset[We.KEY];
|
|
1616
1620
|
let A;
|
|
1617
1621
|
E && (A = JSON.parse(E));
|
|
1618
|
-
const C =
|
|
1619
|
-
if (C.width === 0 || C.height === 0 ||
|
|
1622
|
+
const C = n.getBoundingClientRect(), b = window.getComputedStyle(n);
|
|
1623
|
+
if (C.width === 0 || C.height === 0 || b.display === "none")
|
|
1620
1624
|
return null;
|
|
1621
|
-
let S =
|
|
1622
|
-
S || (S = Math.random().toString(36).substring(2, 11),
|
|
1623
|
-
const X = parseInt(
|
|
1625
|
+
let S = n.getAttribute("data-mid");
|
|
1626
|
+
S || (S = Math.random().toString(36).substring(2, 11), n.setAttribute("data-mid", S));
|
|
1627
|
+
const X = parseInt(b.zIndex), z = (isNaN(X) ? 0 : X) + s;
|
|
1624
1628
|
let U;
|
|
1625
|
-
if (
|
|
1626
|
-
U =
|
|
1627
|
-
else if (
|
|
1628
|
-
const v =
|
|
1629
|
-
const
|
|
1629
|
+
if (n.tagName === "IMG")
|
|
1630
|
+
U = n.src;
|
|
1631
|
+
else if (n.tagName.toLowerCase() === "svg") {
|
|
1632
|
+
const v = n.cloneNode(!0), x = m == null ? void 0 : m.color, T = m == null ? void 0 : m.fill, _ = m == null ? void 0 : m.stroke, D = m == null ? void 0 : m.opacity, q = (R, ne) => {
|
|
1633
|
+
const P = window.getComputedStyle(R), de = ne, Oe = P.fill === P.color, _e = P.stroke === P.color, me = T || (Oe ? x : void 0) || P.fill;
|
|
1630
1634
|
me && me !== "none" && (de.style.fill = me);
|
|
1631
|
-
const ve = _ || (_e ? x : void 0) ||
|
|
1632
|
-
ve && ve !== "none" && (de.style.stroke = ve),
|
|
1633
|
-
const Se = x ||
|
|
1635
|
+
const ve = _ || (_e ? x : void 0) || P.stroke;
|
|
1636
|
+
ve && ve !== "none" && (de.style.stroke = ve), P.strokeWidth && P.strokeWidth !== "0px" && (de.style.strokeWidth = P.strokeWidth);
|
|
1637
|
+
const Se = x || P.color;
|
|
1634
1638
|
Se && (de.style.color = Se);
|
|
1635
|
-
const we = D ||
|
|
1639
|
+
const we = D || P.opacity;
|
|
1636
1640
|
we && we !== "1" && (de.style.opacity = we);
|
|
1637
1641
|
for (let fe = 0; fe < R.children.length; fe++)
|
|
1638
1642
|
q(R.children[fe], ne.children[fe]);
|
|
1639
1643
|
};
|
|
1640
|
-
q(
|
|
1641
|
-
const Y =
|
|
1644
|
+
q(n, v);
|
|
1645
|
+
const Y = n.getBoundingClientRect(), Q = window.devicePixelRatio * c;
|
|
1642
1646
|
v.hasAttribute("viewBox") || v.setAttribute("viewBox", `0 0 ${Y.width} ${Y.height}`), v.setAttribute("width", (Y.width * Q).toString()), v.setAttribute("height", (Y.height * Q).toString());
|
|
1643
1647
|
let k = new XMLSerializer().serializeToString(v);
|
|
1644
1648
|
k.includes("xmlns=") || (k = k.replace(
|
|
1645
1649
|
"<svg",
|
|
1646
1650
|
'<svg xmlns="http://www.w3.org/2000/svg"'
|
|
1647
1651
|
)), U = `data:image/svg+xml;utf8,${encodeURIComponent(k)}`;
|
|
1648
|
-
} else if (
|
|
1649
|
-
const v =
|
|
1652
|
+
} else if (b.backgroundImage && b.backgroundImage !== "none") {
|
|
1653
|
+
const v = b.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
|
|
1650
1654
|
v && (U = v[1]);
|
|
1651
1655
|
}
|
|
1652
1656
|
const I = {
|
|
1653
|
-
backgroundColor:
|
|
1654
|
-
backgroundImage:
|
|
1655
|
-
opacity:
|
|
1657
|
+
backgroundColor: b.backgroundColor,
|
|
1658
|
+
backgroundImage: b.backgroundImage,
|
|
1659
|
+
opacity: n.dataset[ee.KEY] === ee.VALUES.HIDE ? 1 : parseFloat(b.opacity),
|
|
1656
1660
|
zIndex: z,
|
|
1657
|
-
borderRadius:
|
|
1658
|
-
borderColor:
|
|
1659
|
-
borderWidth:
|
|
1660
|
-
boxShadow:
|
|
1661
|
+
borderRadius: b.borderRadius,
|
|
1662
|
+
borderColor: b.borderColor,
|
|
1663
|
+
borderWidth: b.borderWidth,
|
|
1664
|
+
boxShadow: b.boxShadow,
|
|
1661
1665
|
imageSrc: U,
|
|
1662
1666
|
isTraveler: L
|
|
1663
1667
|
}, j = I;
|
|
1664
1668
|
let J, Z;
|
|
1665
|
-
const M = [], O =
|
|
1666
|
-
return
|
|
1669
|
+
const M = [], O = b.overflow === "hidden" ? [...l || [], n] : l;
|
|
1670
|
+
return n.tagName.toLowerCase() !== "svg" && Array.from(n.childNodes).forEach((v) => {
|
|
1667
1671
|
const x = v.nodeType === Node.TEXT_NODE ? d : h, T = Fe(
|
|
1668
1672
|
v,
|
|
1669
1673
|
e,
|
|
1670
1674
|
x,
|
|
1671
1675
|
r,
|
|
1672
1676
|
z,
|
|
1673
|
-
|
|
1674
|
-
v.nodeType === Node.TEXT_NODE ?
|
|
1677
|
+
c,
|
|
1678
|
+
v.nodeType === Node.TEXT_NODE ? y : void 0,
|
|
1675
1679
|
v.nodeType === Node.TEXT_NODE && Object.keys(m).length > 0 ? m : void 0,
|
|
1676
1680
|
O
|
|
1677
1681
|
);
|
|
@@ -1679,7 +1683,7 @@ function Fe(i, e = re | ue | We | ye | pe, t, r = 1, s = 0, l = 2, o, n, c) {
|
|
|
1679
1683
|
}), {
|
|
1680
1684
|
id: S,
|
|
1681
1685
|
type: "BOX",
|
|
1682
|
-
element:
|
|
1686
|
+
element: n,
|
|
1683
1687
|
rect: {
|
|
1684
1688
|
x: C.left + window.scrollX,
|
|
1685
1689
|
y: C.top + window.scrollY,
|
|
@@ -1693,8 +1697,8 @@ function Fe(i, e = re | ue | We | ye | pe, t, r = 1, s = 0, l = 2, o, n, c) {
|
|
|
1693
1697
|
visibility: d,
|
|
1694
1698
|
isTraveler: L,
|
|
1695
1699
|
captureLayer: r,
|
|
1696
|
-
nativeLayer:
|
|
1697
|
-
nativeStyles:
|
|
1700
|
+
nativeLayer: y,
|
|
1701
|
+
nativeStyles: y !== void 0 ? Ce(te({}, I), {
|
|
1698
1702
|
backgroundColor: (K = m.backgroundColor) != null ? K : I.backgroundColor,
|
|
1699
1703
|
backgroundImage: (B = m.backgroundImage) != null ? B : I.backgroundImage,
|
|
1700
1704
|
opacity: (V = m.opacity) != null ? V : I.opacity,
|
|
@@ -1706,39 +1710,39 @@ function Fe(i, e = re | ue | We | ye | pe, t, r = 1, s = 0, l = 2, o, n, c) {
|
|
|
1706
1710
|
isTraveler: I.isTraveler,
|
|
1707
1711
|
transform: m.transform
|
|
1708
1712
|
}) : void 0,
|
|
1709
|
-
nativeRect:
|
|
1713
|
+
nativeRect: y !== void 0 ? {
|
|
1710
1714
|
x: m.x !== void 0 ? parseFloat(m.x) : C.left + window.scrollX,
|
|
1711
1715
|
y: m.y !== void 0 ? parseFloat(m.y) : C.top + window.scrollY,
|
|
1712
1716
|
width: m.width !== void 0 ? parseFloat(m.width) : C.width,
|
|
1713
1717
|
height: m.height !== void 0 ? parseFloat(m.height) : C.height
|
|
1714
1718
|
} : void 0,
|
|
1715
|
-
isFixed:
|
|
1716
|
-
clipElements:
|
|
1719
|
+
isFixed: b.position === "fixed",
|
|
1720
|
+
clipElements: l,
|
|
1717
1721
|
children: M,
|
|
1718
1722
|
shaderHooks: A
|
|
1719
1723
|
};
|
|
1720
1724
|
}
|
|
1721
1725
|
function at(i, e) {
|
|
1722
1726
|
e.size !== 0 && e.forEach((t, r) => {
|
|
1723
|
-
var
|
|
1727
|
+
var c, o, a, l;
|
|
1724
1728
|
const s = i.get(r);
|
|
1725
|
-
!s || !s.userData.basePosition || (
|
|
1729
|
+
!s || !s.userData.basePosition || (W.forceUpdateUniforms(s.material, {
|
|
1726
1730
|
backgroundColor: t.backgroundColor,
|
|
1727
1731
|
backgroundImage: t.backgroundImage,
|
|
1728
1732
|
boxShadow: t.boxShadow,
|
|
1729
1733
|
opacity: t.opacity,
|
|
1730
|
-
borderRadius: (o = t.borderRadius) != null ? o : (
|
|
1734
|
+
borderRadius: (o = t.borderRadius) != null ? o : (c = s.userData.baseStyles) == null ? void 0 : c.borderRadius
|
|
1731
1735
|
// width and height are no longer updated here, they are updated in syncMeshesByDOM
|
|
1732
|
-
}), s.userData.nativeMesh &&
|
|
1736
|
+
}), s.userData.nativeMesh && W.forceUpdateUniforms(s.userData.nativeMesh.material, {
|
|
1733
1737
|
backgroundColor: t.backgroundColor,
|
|
1734
1738
|
backgroundImage: t.backgroundImage,
|
|
1735
1739
|
boxShadow: t.boxShadow,
|
|
1736
1740
|
opacity: t.opacity,
|
|
1737
|
-
borderRadius: (
|
|
1741
|
+
borderRadius: (l = t.borderRadius) != null ? l : (a = s.userData.baseStyles) == null ? void 0 : a.borderRadius
|
|
1738
1742
|
}));
|
|
1739
1743
|
});
|
|
1740
1744
|
}
|
|
1741
|
-
class
|
|
1745
|
+
class lt {
|
|
1742
1746
|
constructor(e, t, r, s) {
|
|
1743
1747
|
g(this, "target");
|
|
1744
1748
|
g(this, "renderer");
|
|
@@ -1747,19 +1751,19 @@ class ct {
|
|
|
1747
1751
|
g(this, "tracker");
|
|
1748
1752
|
this.target = e, this.renderer = t, this.registry = r, this.tracker = new qe(e, {
|
|
1749
1753
|
resizeDebounce: s.resizeDebounce
|
|
1750
|
-
}), this.tracker.onLayoutChange.add((
|
|
1754
|
+
}), this.tracker.onLayoutChange.add((c, o) => {
|
|
1751
1755
|
document.querySelector(`[${N.NAME}~='${N.VALUES.TRAVELER}']`) !== null && !this.isTravelEnabled && (this.isTravelEnabled = !0, this.renderer.createRenderTarget());
|
|
1752
|
-
const
|
|
1756
|
+
const l = Fe(
|
|
1753
1757
|
this.target,
|
|
1754
|
-
|
|
1758
|
+
c,
|
|
1755
1759
|
G,
|
|
1756
1760
|
1,
|
|
1757
1761
|
0,
|
|
1758
1762
|
this.renderer.qualityFactor
|
|
1759
1763
|
);
|
|
1760
|
-
|
|
1761
|
-
}), this.tracker.onStyleChange.add((
|
|
1762
|
-
at(this.registry,
|
|
1764
|
+
l && this.renderer.syncScene(l, o);
|
|
1765
|
+
}), this.tracker.onStyleChange.add((c) => {
|
|
1766
|
+
at(this.registry, c);
|
|
1763
1767
|
}), this.tracker.onRender.add(() => {
|
|
1764
1768
|
this.renderer.syncMeshesByDOM(), this.renderer.render();
|
|
1765
1769
|
});
|
|
@@ -1771,7 +1775,7 @@ class ct {
|
|
|
1771
1775
|
this.tracker.stop();
|
|
1772
1776
|
}
|
|
1773
1777
|
}
|
|
1774
|
-
class
|
|
1778
|
+
class ct {
|
|
1775
1779
|
constructor() {
|
|
1776
1780
|
g(this, "store");
|
|
1777
1781
|
this.store = /* @__PURE__ */ new WeakMap();
|
|
@@ -1802,24 +1806,24 @@ class ft {
|
|
|
1802
1806
|
g(this, "syncer");
|
|
1803
1807
|
g(this, "target");
|
|
1804
1808
|
g(this, "registry");
|
|
1805
|
-
var s,
|
|
1806
|
-
if (this.target = e, this.registry = new
|
|
1807
|
-
const
|
|
1808
|
-
|
|
1809
|
+
var s, c, o;
|
|
1810
|
+
if (this.target = e, this.registry = new ct(), !document.getElementById("mirage-engine-styles")) {
|
|
1811
|
+
const a = document.createElement("style");
|
|
1812
|
+
a.id = "mirage-engine-styles", a.textContent = `
|
|
1809
1813
|
[${ee.NAME}="${ee.VALUES.HIDE}"] {
|
|
1810
1814
|
opacity: 0 !important;
|
|
1811
1815
|
}
|
|
1812
|
-
`, document.head.appendChild(
|
|
1816
|
+
`, document.head.appendChild(a);
|
|
1813
1817
|
}
|
|
1814
1818
|
let r;
|
|
1815
|
-
if (t.mode === "duplicate" ? r = (
|
|
1819
|
+
if (t.mode === "duplicate" ? r = (c = (s = t.container) != null ? s : this.target.parentElement) != null ? c : void 0 : r = (o = this.target.parentElement) != null ? o : void 0, !r)
|
|
1816
1820
|
throw new Error("[Mirage] Cannot find a container (parent or option).");
|
|
1817
1821
|
this.renderer = new ot(
|
|
1818
1822
|
this.target,
|
|
1819
1823
|
t,
|
|
1820
1824
|
r,
|
|
1821
1825
|
this.registry
|
|
1822
|
-
), this.renderer.mount(), this.syncer = new
|
|
1826
|
+
), this.renderer.mount(), this.syncer = new lt(this.target, this.renderer, this.registry, t);
|
|
1823
1827
|
}
|
|
1824
1828
|
start() {
|
|
1825
1829
|
this.syncer.start();
|
|
@@ -1851,10 +1855,10 @@ class ft {
|
|
|
1851
1855
|
ArrowUp: !1,
|
|
1852
1856
|
ArrowDown: !1
|
|
1853
1857
|
};
|
|
1854
|
-
window.addEventListener("keydown", (
|
|
1855
|
-
t[
|
|
1856
|
-
}), window.addEventListener("keyup", (
|
|
1857
|
-
t[
|
|
1858
|
+
window.addEventListener("keydown", (c) => {
|
|
1859
|
+
t[c.key] !== void 0 && (t[c.key] = !0);
|
|
1860
|
+
}), window.addEventListener("keyup", (c) => {
|
|
1861
|
+
t[c.key] !== void 0 && (t[c.key] = !1);
|
|
1858
1862
|
});
|
|
1859
1863
|
const r = 2, s = () => {
|
|
1860
1864
|
requestAnimationFrame(s), t.ArrowRight && e.position.setX(e.position.x + r), t.ArrowLeft && e.position.setX(e.position.x - r), t.ArrowUp && e.position.setY(e.position.y + r), t.ArrowDown && e.position.setY(e.position.y - r);
|
|
@@ -1868,14 +1872,14 @@ export {
|
|
|
1868
1872
|
H as ATTR_FILTER,
|
|
1869
1873
|
dt as ATTR_SANDWICH,
|
|
1870
1874
|
$ as ATTR_SELECT,
|
|
1871
|
-
|
|
1875
|
+
We as ATTR_SHADER,
|
|
1872
1876
|
N as ATTR_TRAVEL,
|
|
1873
1877
|
ye as DIRTY_CONTENT,
|
|
1874
1878
|
ge as DIRTY_NONE,
|
|
1875
1879
|
re as DIRTY_RECT,
|
|
1876
1880
|
pe as DIRTY_STRUCTURE,
|
|
1877
1881
|
ue as DIRTY_STYLE,
|
|
1878
|
-
|
|
1882
|
+
Pe as DIRTY_ZINDEX,
|
|
1879
1883
|
ut as EXCLUDED,
|
|
1880
1884
|
ft as Engine,
|
|
1881
1885
|
ae as SELECT_LAYER,
|