mirage-engine 0.3.11 → 0.3.12
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 +264 -263
- package/dist/mirage-engine.umd.js +7 -7
- package/package.json +2 -2
package/dist/mirage-engine.js
CHANGED
|
@@ -12,19 +12,19 @@ var me = (s, e, t) => e in s ? _e(s, e, { enumerable: !0, configurable: !0, writ
|
|
|
12
12
|
}, xe = (s, e) => Fe(s, Ne(e));
|
|
13
13
|
var u = (s, e, t) => (me(s, typeof e != "symbol" ? e + "" : e, t), t);
|
|
14
14
|
var Ee = (s, e, t) => new Promise((r, i) => {
|
|
15
|
-
var
|
|
15
|
+
var l = (a) => {
|
|
16
16
|
try {
|
|
17
17
|
o(t.next(a));
|
|
18
|
-
} catch (
|
|
19
|
-
i(
|
|
18
|
+
} catch (c) {
|
|
19
|
+
i(c);
|
|
20
20
|
}
|
|
21
21
|
}, n = (a) => {
|
|
22
22
|
try {
|
|
23
23
|
o(t.throw(a));
|
|
24
|
-
} catch (
|
|
25
|
-
i(
|
|
24
|
+
} catch (c) {
|
|
25
|
+
i(c);
|
|
26
26
|
}
|
|
27
|
-
}, o = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(
|
|
27
|
+
}, o = (a) => a.done ? r(a.value) : Promise.resolve(a.value).then(l, n);
|
|
28
28
|
o((t = t.apply(s, e)).next());
|
|
29
29
|
});
|
|
30
30
|
import * as y from "three";
|
|
@@ -63,7 +63,7 @@ const Ae = {
|
|
|
63
63
|
NAME: "data-mirage-filter",
|
|
64
64
|
KEY: "mirageFilter",
|
|
65
65
|
VALUES: Ae
|
|
66
|
-
},
|
|
66
|
+
}, $ = {
|
|
67
67
|
NAME: "data-mirage-select",
|
|
68
68
|
KEY: "mirageSelect",
|
|
69
69
|
VALUES: Ae
|
|
@@ -142,26 +142,26 @@ class De {
|
|
|
142
142
|
this.pendingMask |= Q, this.isDomDirty = !0, this.scrollTimer = null;
|
|
143
143
|
}, 150)), this.pendingStyles.size > 0 && (this.onStyleChange.forEach((r) => r(this.pendingStyles)), this.pendingStyles.clear()), this.onRender.forEach((r) => r()), requestAnimationFrame(this.renderLoop);
|
|
144
144
|
});
|
|
145
|
-
var i,
|
|
145
|
+
var i, l;
|
|
146
146
|
this.target = e;
|
|
147
147
|
const r = (i = t.resizeDebounce) != null ? i : !0;
|
|
148
148
|
r === !1 ? this.resizeConfig = { enabled: !1, delay: 0 } : r === !0 ? this.resizeConfig = { enabled: !0, delay: 150 } : this.resizeConfig = {
|
|
149
149
|
enabled: !0,
|
|
150
|
-
delay: (
|
|
150
|
+
delay: (l = r.delay) != null ? l : 150,
|
|
151
151
|
onStart: r.onStart,
|
|
152
152
|
onEnd: r.onEnd
|
|
153
153
|
}, this.observer = new MutationObserver((n) => {
|
|
154
154
|
let o = de;
|
|
155
155
|
for (const a of n)
|
|
156
156
|
if (a.type === "childList")
|
|
157
|
-
o |= ue, a.removedNodes.length > 0 && a.removedNodes.forEach((
|
|
158
|
-
|
|
157
|
+
o |= ue, a.removedNodes.length > 0 && a.removedNodes.forEach((c) => {
|
|
158
|
+
c instanceof HTMLElement && this.pendingDeletions.add(c);
|
|
159
159
|
});
|
|
160
160
|
else if (a.type === "attributes")
|
|
161
161
|
if (a.attributeName === "style") {
|
|
162
162
|
o |= Q | ce;
|
|
163
|
-
const
|
|
164
|
-
this.pendingStyles.set(
|
|
163
|
+
const c = a.target, d = He(c.style);
|
|
164
|
+
this.pendingStyles.set(c, d);
|
|
165
165
|
} else
|
|
166
166
|
a.attributeName === "class" ? o |= Q | ce : a.attributeName && a.attributeName.startsWith("data-") && (o |= Q | ce, a.attributeName.startsWith("data-mirage") && (o |= ue));
|
|
167
167
|
else
|
|
@@ -192,7 +192,7 @@ 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 P = 1, te = 2, U = {
|
|
196
196
|
BASE: 0,
|
|
197
197
|
SELECTED: 1,
|
|
198
198
|
getCaptureLayer: (s) => 31 - s,
|
|
@@ -215,13 +215,13 @@ class ke {
|
|
|
215
215
|
return 0;
|
|
216
216
|
const t = document.createElement("div"), r = document.createElement("span"), i = document.createElement("img");
|
|
217
217
|
t.style.visibility = "hidden", t.style.position = "absolute", t.style.top = "0px", t.style.left = "0px", t.style.font = e, t.style.margin = "0", t.style.padding = "0", t.style.border = "none", r.style.margin = "0", r.style.padding = "0", r.style.border = "none", r.style.lineHeight = "normal", i.width = 1, i.height = 1, i.style.verticalAlign = "baseline", r.appendChild(document.createTextNode("Hidden Text")), t.appendChild(r), t.appendChild(i), document.body.appendChild(t);
|
|
218
|
-
const
|
|
219
|
-
return document.body.removeChild(t),
|
|
218
|
+
const l = i.offsetTop - r.offsetTop;
|
|
219
|
+
return document.body.removeChild(t), l;
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
u(ke, "cache", /* @__PURE__ */ new Map());
|
|
223
223
|
class Pe extends y.MeshBasicMaterial {
|
|
224
|
-
constructor(t, r, i,
|
|
224
|
+
constructor(t, r, i, l, n = 2) {
|
|
225
225
|
super({
|
|
226
226
|
transparent: !0,
|
|
227
227
|
side: y.FrontSide,
|
|
@@ -232,32 +232,32 @@ class Pe extends y.MeshBasicMaterial {
|
|
|
232
232
|
u(this, "qualityFactor");
|
|
233
233
|
if (this.canvas = document.createElement("canvas"), this.ctx = this.canvas.getContext("2d"), !this.ctx)
|
|
234
234
|
throw new Error("[Mirage] Failed to create canvas context");
|
|
235
|
-
this.qualityFactor = n, this.map = new y.CanvasTexture(this.canvas), this.map.colorSpace = y.LinearSRGBColorSpace, this.map.minFilter = y.LinearFilter, this.map.magFilter = y.LinearFilter, this.updateText(t, r, i,
|
|
235
|
+
this.qualityFactor = n, this.map = new y.CanvasTexture(this.canvas), this.map.colorSpace = y.LinearSRGBColorSpace, this.map.minFilter = y.LinearFilter, this.map.magFilter = y.LinearFilter, this.updateText(t, r, i, l);
|
|
236
236
|
}
|
|
237
237
|
wrapText(t, r) {
|
|
238
238
|
const i = t.split(`
|
|
239
|
-
`),
|
|
239
|
+
`), l = [];
|
|
240
240
|
return i.forEach((n) => {
|
|
241
241
|
const o = n.match(/[^\s\-]+\-?|\-|\s+/g) || [];
|
|
242
242
|
if (o.length === 0) {
|
|
243
|
-
|
|
243
|
+
l.push("");
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
246
|
let a = o[0];
|
|
247
|
-
for (let
|
|
248
|
-
const d = o[
|
|
249
|
-
this.ctx.measureText(a + d).width <= r + 2 ? a += d : (a &&
|
|
247
|
+
for (let c = 1; c < o.length; c++) {
|
|
248
|
+
const d = o[c];
|
|
249
|
+
this.ctx.measureText(a + d).width <= r + 2 ? a += d : (a && l.push(a), a = d.trimStart());
|
|
250
250
|
}
|
|
251
|
-
a &&
|
|
252
|
-
}),
|
|
251
|
+
a && l.push(a);
|
|
252
|
+
}), l;
|
|
253
253
|
}
|
|
254
|
-
updateText(t, r, i,
|
|
254
|
+
updateText(t, r, i, l, n) {
|
|
255
255
|
n !== void 0 && (this.qualityFactor = n);
|
|
256
|
-
const a = (window.devicePixelRatio || 1) * this.qualityFactor,
|
|
257
|
-
this.canvas.width !==
|
|
258
|
-
const h = this.wrapText(t, i), f = r.lineHeight,
|
|
259
|
-
h.forEach((g,
|
|
260
|
-
const b =
|
|
256
|
+
const a = (window.devicePixelRatio || 1) * this.qualityFactor, c = i * a, d = l * a;
|
|
257
|
+
this.canvas.width !== c || this.canvas.height !== d ? (this.canvas.width = c, this.canvas.height = d) : this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height), this.ctx.setTransform(a, 0, 0, a, 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, v = ke.getBaseline(r.font);
|
|
259
|
+
h.forEach((g, m) => {
|
|
260
|
+
const b = m * f + v;
|
|
261
261
|
let L = 0;
|
|
262
262
|
r.textAlign === "center" ? L = i / 2 : r.textAlign === "right" && (L = i), this.ctx.textAlign = r.textAlign, this.ctx.fillText(g, L, b);
|
|
263
263
|
}), this.map && (this.map.needsUpdate = !0);
|
|
@@ -279,8 +279,8 @@ function le(s) {
|
|
|
279
279
|
/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)/
|
|
280
280
|
);
|
|
281
281
|
if (e) {
|
|
282
|
-
const t = parseInt(e[1], 10), r = parseInt(e[2], 10), i = parseInt(e[3], 10),
|
|
283
|
-
return { color: new y.Color(`rgb(${t}, ${r}, ${i})`), alpha:
|
|
282
|
+
const t = parseInt(e[1], 10), r = parseInt(e[2], 10), i = parseInt(e[3], 10), l = e[4] !== void 0 ? parseFloat(e[4]) : 1;
|
|
283
|
+
return { color: new y.Color(`rgb(${t}, ${r}, ${i})`), alpha: l };
|
|
284
284
|
}
|
|
285
285
|
return { color: new y.Color(s), alpha: 1 };
|
|
286
286
|
}
|
|
@@ -288,16 +288,16 @@ function Ge(s) {
|
|
|
288
288
|
const e = [];
|
|
289
289
|
let t = "", r = 0;
|
|
290
290
|
for (let i = 0; i < s.length; i++) {
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
291
|
+
const l = s[i];
|
|
292
|
+
if (l === "(")
|
|
293
293
|
r++;
|
|
294
|
-
else if (
|
|
294
|
+
else if (l === ")")
|
|
295
295
|
r--;
|
|
296
|
-
else if (
|
|
296
|
+
else if (l === "," && r === 0) {
|
|
297
297
|
e.push(t.trim()), t = "";
|
|
298
298
|
continue;
|
|
299
299
|
}
|
|
300
|
-
t +=
|
|
300
|
+
t += l;
|
|
301
301
|
}
|
|
302
302
|
return t && e.push(t.trim()), e;
|
|
303
303
|
}
|
|
@@ -308,44 +308,44 @@ function $e(s) {
|
|
|
308
308
|
if (!e)
|
|
309
309
|
return null;
|
|
310
310
|
const t = e[1], r = Ge(t);
|
|
311
|
-
let i = Math.PI,
|
|
311
|
+
let i = Math.PI, l = 0;
|
|
312
312
|
const n = r[0].trim();
|
|
313
313
|
if (n.startsWith("to "))
|
|
314
|
-
n === "to top" ? i = 0 : n === "to right" ? i = Math.PI / 2 : n === "to bottom" ? i = Math.PI : n === "to left" ? i = Math.PI * 1.5 : n === "to top right" || n === "to right top" ? i = Math.PI / 4 : n === "to bottom right" || n === "to right bottom" ? i = Math.PI * 0.75 : n === "to bottom left" || n === "to left bottom" ? i = Math.PI * 1.25 : (n === "to top left" || n === "to left top") && (i = Math.PI * 1.75),
|
|
314
|
+
n === "to top" ? i = 0 : n === "to right" ? i = Math.PI / 2 : n === "to bottom" ? i = Math.PI : n === "to left" ? i = Math.PI * 1.5 : n === "to top right" || n === "to right top" ? i = Math.PI / 4 : n === "to bottom right" || n === "to right bottom" ? i = Math.PI * 0.75 : n === "to bottom left" || n === "to left bottom" ? i = Math.PI * 1.25 : (n === "to top left" || n === "to left top") && (i = Math.PI * 1.75), l = 1;
|
|
315
315
|
else if (n.endsWith("deg") || n.endsWith("rad") || n.endsWith("turn")) {
|
|
316
316
|
const a = parseFloat(n);
|
|
317
|
-
n.endsWith("deg") ? i = a * (Math.PI / 180) : n.endsWith("rad") ? i = a : n.endsWith("turn") && (i = a * Math.PI * 2),
|
|
317
|
+
n.endsWith("deg") ? i = a * (Math.PI / 180) : n.endsWith("rad") ? i = a : n.endsWith("turn") && (i = a * Math.PI * 2), l = 1;
|
|
318
318
|
}
|
|
319
319
|
const o = [];
|
|
320
|
-
for (let a =
|
|
321
|
-
const
|
|
322
|
-
let h =
|
|
323
|
-
if (d !== -1 && !
|
|
324
|
-
const g =
|
|
325
|
-
(g.endsWith("%") || g.endsWith("px") || !isNaN(parseFloat(g))) && (h =
|
|
320
|
+
for (let a = l; a < r.length && !(o.length >= 8); a++) {
|
|
321
|
+
const c = r[a].trim(), d = c.lastIndexOf(" ");
|
|
322
|
+
let h = c, f = null;
|
|
323
|
+
if (d !== -1 && !c.endsWith(")")) {
|
|
324
|
+
const g = c.substring(d + 1);
|
|
325
|
+
(g.endsWith("%") || g.endsWith("px") || !isNaN(parseFloat(g))) && (h = c.substring(0, d).trim(), f = g);
|
|
326
326
|
}
|
|
327
|
-
const
|
|
327
|
+
const v = le(h);
|
|
328
328
|
o.push({
|
|
329
|
-
color:
|
|
330
|
-
alpha:
|
|
329
|
+
color: v.color,
|
|
330
|
+
alpha: v.alpha,
|
|
331
331
|
rawStop: f,
|
|
332
332
|
stop: 0
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
335
|
if (o.length > 0) {
|
|
336
|
-
for (let
|
|
337
|
-
o[
|
|
336
|
+
for (let c = 0; c < o.length; c++)
|
|
337
|
+
o[c].rawStop !== null && (o[c].stop = parseFloat(o[c].rawStop) / 100);
|
|
338
338
|
o[0].rawStop === null && (o[0].stop = 0), o.length > 1 && o[o.length - 1].rawStop === null && (o[o.length - 1].stop = 1);
|
|
339
339
|
let a = 0;
|
|
340
|
-
for (let
|
|
341
|
-
if (o[
|
|
342
|
-
const d =
|
|
340
|
+
for (let c = 1; c < o.length; c++)
|
|
341
|
+
if (o[c].rawStop !== null || c === o.length - 1) {
|
|
342
|
+
const d = c - a;
|
|
343
343
|
if (d > 1) {
|
|
344
|
-
const h = o[a].stop,
|
|
344
|
+
const h = o[a].stop, v = (o[c].stop - h) / d;
|
|
345
345
|
for (let g = 1; g < d; g++)
|
|
346
|
-
o[a + g].stop = h +
|
|
346
|
+
o[a + g].stop = h + v * g;
|
|
347
347
|
}
|
|
348
|
-
a =
|
|
348
|
+
a = c;
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
return { angle: i, stops: o };
|
|
@@ -513,7 +513,7 @@ baseColor = blendSrcOver(baseColor, texColor);`, Re = {
|
|
|
513
513
|
};
|
|
514
514
|
function Ze(s, e, t, r = null, i) {
|
|
515
515
|
var x;
|
|
516
|
-
const
|
|
516
|
+
const l = r !== null || !!s.imageSrc;
|
|
517
517
|
let n = "";
|
|
518
518
|
const o = {};
|
|
519
519
|
if (i != null && i.uniforms)
|
|
@@ -524,11 +524,11 @@ function Ze(s, e, t, r = null, i) {
|
|
|
524
524
|
`, o[C] = { value: new y.Vector3(...w) }) : w.length === 4 && (n += `uniform vec4 ${C};
|
|
525
525
|
`, o[C] = { value: new y.Vector4(...w) }) : (n += `uniform float ${C};
|
|
526
526
|
`, o[C] = { value: w });
|
|
527
|
-
const a = i !== void 0,
|
|
527
|
+
const a = i !== void 0, c = (l || a ? Le.declChunk : "") + `
|
|
528
528
|
` + n, d = `vec2 screenUv = (vScreenPos.xy / vScreenPos.w) * 0.5 + 0.5;
|
|
529
529
|
`, h = s.isTraveler ? `vec2 resultUv = screenUv;
|
|
530
530
|
` : `vec2 resultUv = vUv * uTextureRepeat + uTextureOffset;
|
|
531
|
-
`, f =
|
|
531
|
+
`, f = l || a ? d + h + ((i == null ? void 0 : i.uvModifier) || "") : "", v = l || a ? Le.baseColorChunk : "", g = (i == null ? void 0 : i.colorModifier) || "", m = Re.fragmentShader.replace("#INJECT_DECLARATIONS", c).replace("#INJECT_UV_MODIFIER", f).replace("#INJECT_BASE_COLOR", v).replace("#INJECT_COLOR_MODIFIER", g), b = le(s.backgroundColor), L = le(s.borderColor), M = {
|
|
532
532
|
uSize: { value: new y.Vector2(e, t) },
|
|
533
533
|
uBgColor: {
|
|
534
534
|
value: new y.Vector4(
|
|
@@ -559,11 +559,11 @@ function Ze(s, e, t, r = null, i) {
|
|
|
559
559
|
},
|
|
560
560
|
uGradientStops: { value: new Float32Array(8) }
|
|
561
561
|
};
|
|
562
|
-
Ie(M.uBorderRadius.value, s.borderRadius, Math.min(e, t)),
|
|
562
|
+
Ie(M.uBorderRadius.value, s.borderRadius, Math.min(e, t)), l && (M.uTexture.value = r);
|
|
563
563
|
const S = new y.ShaderMaterial({
|
|
564
564
|
uniforms: J(J({}, M), o),
|
|
565
565
|
vertexShader: Re.vertexShader,
|
|
566
|
-
fragmentShader:
|
|
566
|
+
fragmentShader: m,
|
|
567
567
|
transparent: !0,
|
|
568
568
|
side: y.FrontSide
|
|
569
569
|
// for better performance
|
|
@@ -571,12 +571,12 @@ function Ze(s, e, t, r = null, i) {
|
|
|
571
571
|
return s.backgroundImage && ye(S, { backgroundImage: s.backgroundImage }), S;
|
|
572
572
|
}
|
|
573
573
|
function et(s, e, t, r, i) {
|
|
574
|
-
const
|
|
574
|
+
const l = re(e.borderWidth);
|
|
575
575
|
ye(s, {
|
|
576
576
|
width: t,
|
|
577
577
|
height: r,
|
|
578
578
|
borderRadius: e.borderRadius,
|
|
579
|
-
borderWidth:
|
|
579
|
+
borderWidth: l,
|
|
580
580
|
backgroundColor: e.backgroundColor,
|
|
581
581
|
borderColor: e.borderColor,
|
|
582
582
|
opacity: e.opacity,
|
|
@@ -585,7 +585,7 @@ function et(s, e, t, r, i) {
|
|
|
585
585
|
});
|
|
586
586
|
}
|
|
587
587
|
function ye(s, e) {
|
|
588
|
-
var r, i,
|
|
588
|
+
var r, i, l;
|
|
589
589
|
if (e.width !== void 0 && e.height !== void 0 && s.uniforms.uSize.value.set(e.width, e.height), e.borderRadius !== void 0) {
|
|
590
590
|
const n = e.width !== void 0 && e.height !== void 0 ? Math.min(e.width, e.height) : Math.min(s.uniforms.uSize.value.x, s.uniforms.uSize.value.y);
|
|
591
591
|
Ie(s.uniforms.uBorderRadius.value, e.borderRadius, n);
|
|
@@ -645,9 +645,9 @@ function ye(s, e) {
|
|
|
645
645
|
e.opacity !== void 0 && (s.uniforms.uOpacity.value = e.opacity), e.bgOpacity !== void 0 && (s.uniforms.uBgColor.value.w = e.bgOpacity), e.borderOpacity !== void 0 && (s.uniforms.uBorderColor.value.w = e.borderOpacity), s.uniforms.uTexture && e.texture !== void 0 && (s.uniforms.uTexture.value = e.texture);
|
|
646
646
|
const t = e.texture !== void 0 ? e.texture : (r = s.uniforms.uTexture) == null ? void 0 : r.value;
|
|
647
647
|
if (t && (t.image instanceof ImageBitmap || t.image instanceof HTMLImageElement || t.image instanceof HTMLCanvasElement)) {
|
|
648
|
-
const n = t.image.naturalWidth || t.image.videoWidth || t.image.width, o = t.image.naturalHeight || t.image.videoHeight || t.image.height, a = (i = e.width) != null ? i : s.uniforms.uSize.value.x,
|
|
649
|
-
if (n && o && a &&
|
|
650
|
-
const d = n / o, h = a /
|
|
648
|
+
const n = t.image.naturalWidth || t.image.videoWidth || t.image.width, o = t.image.naturalHeight || t.image.videoHeight || t.image.height, a = (i = e.width) != null ? i : s.uniforms.uSize.value.x, c = (l = e.height) != null ? l : s.uniforms.uSize.value.y;
|
|
649
|
+
if (n && o && a && c) {
|
|
650
|
+
const d = n / o, h = a / c;
|
|
651
651
|
if (d > h) {
|
|
652
652
|
const f = h / d;
|
|
653
653
|
s.uniforms.uTextureRepeat.value.set(f, 1), s.uniforms.uTextureOffset.value.set((1 - f) / 2, 0);
|
|
@@ -680,7 +680,7 @@ function ye(s, e) {
|
|
|
680
680
|
n !== "width" && n !== "height" && n !== "borderRadius" && n !== "borderWidth" && n !== "backgroundColor" && n !== "borderColor" && n !== "opacity" && n !== "bgOpacity" && n !== "borderOpacity" && n !== "texture" && n !== "backgroundImage" && s.uniforms[n] !== void 0 && (s.uniforms[n].value !== void 0 && s.uniforms[n].value !== null && typeof s.uniforms[n].value.set == "function" ? Array.isArray(e[n]) ? s.uniforms[n].value.set(...e[n]) : e[n] !== void 0 && (e[n].copy ? s.uniforms[n].value.copy(e[n]) : s.uniforms[n].value = e[n]) : s.uniforms[n].value = e[n]);
|
|
681
681
|
}
|
|
682
682
|
function Ie(s, e, t = 0) {
|
|
683
|
-
var a,
|
|
683
|
+
var a, c, d, h;
|
|
684
684
|
if (e == null) {
|
|
685
685
|
s.set(0, 0, 0, 0);
|
|
686
686
|
return;
|
|
@@ -693,11 +693,11 @@ function Ie(s, e, t = 0) {
|
|
|
693
693
|
s.set(e[0], e[1], e[2], e[3]);
|
|
694
694
|
return;
|
|
695
695
|
}
|
|
696
|
-
const r = e.split("/")[0].trim().split(/\s+/), i = re(r[0], t),
|
|
697
|
-
s.set(i,
|
|
696
|
+
const r = e.split("/")[0].trim().split(/\s+/), i = re(r[0], t), l = re((a = r[1]) != null ? a : r[0], t), n = re((c = r[2]) != null ? c : r[0], t), o = re((h = (d = r[3]) != null ? d : r[1]) != null ? h : r[0], t);
|
|
697
|
+
s.set(i, l, n, o);
|
|
698
698
|
}
|
|
699
699
|
const H = {
|
|
700
|
-
create(s, e, t, r, i,
|
|
700
|
+
create(s, e, t, r, i, l = 2, n = null, o) {
|
|
701
701
|
return s === "BOX" ? Ze(
|
|
702
702
|
e,
|
|
703
703
|
r,
|
|
@@ -709,21 +709,21 @@ const H = {
|
|
|
709
709
|
e,
|
|
710
710
|
r,
|
|
711
711
|
i,
|
|
712
|
-
|
|
712
|
+
l
|
|
713
713
|
) : new y.MeshBasicMaterial({ visible: !1 });
|
|
714
714
|
},
|
|
715
|
-
update(s, e, t, r, i,
|
|
715
|
+
update(s, e, t, r, i, l, n = 2, o) {
|
|
716
716
|
e === "BOX" ? et(
|
|
717
717
|
s,
|
|
718
718
|
t,
|
|
719
719
|
i,
|
|
720
|
-
|
|
720
|
+
l,
|
|
721
721
|
o
|
|
722
722
|
) : e === "TEXT" && s.updateText(
|
|
723
723
|
r || "",
|
|
724
724
|
t,
|
|
725
725
|
i,
|
|
726
|
-
|
|
726
|
+
l,
|
|
727
727
|
n
|
|
728
728
|
);
|
|
729
729
|
},
|
|
@@ -741,8 +741,8 @@ class tt {
|
|
|
741
741
|
this.onUpdate = e, t && (this.observer = new IntersectionObserver(
|
|
742
742
|
(r) => {
|
|
743
743
|
for (const i of r) {
|
|
744
|
-
const
|
|
745
|
-
i.isIntersecting ? this.loadTexture(
|
|
744
|
+
const l = i.target;
|
|
745
|
+
i.isIntersecting ? this.loadTexture(l) : this.disposeTexture(l);
|
|
746
746
|
}
|
|
747
747
|
},
|
|
748
748
|
{ rootMargin: "300px" }
|
|
@@ -766,9 +766,9 @@ class tt {
|
|
|
766
766
|
try {
|
|
767
767
|
let r;
|
|
768
768
|
if (t.startsWith("data:image/svg+xml"))
|
|
769
|
-
r = yield new Promise((
|
|
769
|
+
r = yield new Promise((l, n) => {
|
|
770
770
|
const o = new Image();
|
|
771
|
-
o.onload = () =>
|
|
771
|
+
o.onload = () => l(o), o.onerror = n, o.src = t;
|
|
772
772
|
});
|
|
773
773
|
else {
|
|
774
774
|
const n = yield (yield fetch(t)).blob();
|
|
@@ -824,15 +824,15 @@ class rt {
|
|
|
824
824
|
u(this, "textureManager");
|
|
825
825
|
// private meshMap: Map<HTMLElement, THREE.Mesh> = new Map();
|
|
826
826
|
u(this, "fixedMeshes", /* @__PURE__ */ new Set());
|
|
827
|
-
var o, a,
|
|
828
|
-
this.target = e, this.mountContainer = r, this.registry = i, this.mode = (o = t.mode) != null ? o : "overlay", this.canvasSize = (a = t.canvasSize) != null ? a : "viewport", this.clipArea = (
|
|
827
|
+
var o, a, c, d, h;
|
|
828
|
+
this.target = e, this.mountContainer = r, this.registry = i, this.mode = (o = t.mode) != null ? o : "overlay", this.canvasSize = (a = t.canvasSize) != null ? a : "viewport", this.clipArea = (c = t.travelerClipArea) != null ? c : 1, this.targetLayer = (d = t.layer) != null ? d : "base", this.textureManager = new tt((f, v) => {
|
|
829
829
|
const g = this.registry.get(f);
|
|
830
|
-
g && g.material instanceof y.ShaderMaterial && H.forceUpdateUniforms(g.material, { texture:
|
|
830
|
+
g && g.material instanceof y.ShaderMaterial && H.forceUpdateUniforms(g.material, { texture: v });
|
|
831
831
|
}, this.isViewport), this.canvas = document.createElement("canvas"), this.scene = new y.Scene(), this.targetRect = this.target.getBoundingClientRect();
|
|
832
|
-
const
|
|
832
|
+
const l = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, n = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height;
|
|
833
833
|
this.camera = new y.OrthographicCamera(
|
|
834
|
-
|
|
835
|
-
|
|
834
|
+
l / -2,
|
|
835
|
+
l / 2,
|
|
836
836
|
n / 2,
|
|
837
837
|
n / -2,
|
|
838
838
|
1,
|
|
@@ -843,7 +843,7 @@ class rt {
|
|
|
843
843
|
antialias: !0
|
|
844
844
|
// [new]
|
|
845
845
|
// premultipliedAlpha: true
|
|
846
|
-
}), y.ColorManagement.enabled = !1, this.renderer.outputColorSpace = y.LinearSRGBColorSpace, this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setSize(
|
|
846
|
+
}), y.ColorManagement.enabled = !1, this.renderer.outputColorSpace = y.LinearSRGBColorSpace, this.renderer.setPixelRatio(window.devicePixelRatio), this.renderer.setSize(l, n), this.applyTextQuality((h = t.quality) != null ? h : "medium");
|
|
847
847
|
}
|
|
848
848
|
get isViewport() {
|
|
849
849
|
return this.mode === "overlay" && this.canvasSize === "viewport";
|
|
@@ -920,8 +920,8 @@ class rt {
|
|
|
920
920
|
this.camera.left = e / -2, this.camera.right = e / 2, this.camera.top = t / 2, this.camera.bottom = t / -2, this.camera.updateProjectionMatrix();
|
|
921
921
|
}
|
|
922
922
|
syncScene(e, t) {
|
|
923
|
-
const r = this.target.getBoundingClientRect(), i = this.isViewport ? window.innerWidth + this.overscan * 2 : r.width,
|
|
924
|
-
a ? (this.targetRect = r, this.setSize(i,
|
|
923
|
+
const r = this.target.getBoundingClientRect(), i = this.isViewport ? window.innerWidth + this.overscan * 2 : r.width, l = this.isViewport ? window.innerHeight + this.overscan * 2 : r.height, n = this.isViewport ? this.canvas.clientWidth : this.targetRect.width, o = this.isViewport ? this.canvas.clientHeight : this.targetRect.height, a = Math.abs(i - n) > 0.1 || Math.abs(l - o) > 0.1, c = this.mode === "overlay" && (Math.abs(r.top - this.targetRect.top) > 0.1 || Math.abs(r.left - this.targetRect.left) > 0.1);
|
|
924
|
+
a ? (this.targetRect = r, this.setSize(i, l), this.updateCanvasLayout()) : c ? (this.targetRect = r, this.updateCanvasLayout()) : this.targetRect = r, this.renderOrder = 0, this.reconcileNode(e), t.size > 0 && t.forEach((d) => {
|
|
925
925
|
const h = this.registry.get(d);
|
|
926
926
|
if (h) {
|
|
927
927
|
this.scene.remove(h);
|
|
@@ -930,7 +930,7 @@ class rt {
|
|
|
930
930
|
this.fixedMeshes.delete(h), h.geometry.dispose(), h.userData.nativeMesh && (this.scene.remove(h.userData.nativeMesh), Array.isArray(h.userData.nativeMesh.material) ? h.userData.nativeMesh.material.forEach(
|
|
931
931
|
(f) => f.dispose()
|
|
932
932
|
) : h.userData.nativeMesh.material.dispose(), h.userData.nativeMesh.geometry.dispose()), h.traverse((f) => {
|
|
933
|
-
f instanceof y.Mesh && (f.geometry && f.geometry.dispose(), f.material && (Array.isArray(f.material) ? f.material.forEach((
|
|
933
|
+
f instanceof y.Mesh && (f.geometry && f.geometry.dispose(), f.material && (Array.isArray(f.material) ? f.material.forEach((v) => v.dispose()) : f.material.dispose()));
|
|
934
934
|
}), this.registry.remove(d), this.textureManager.unregister(d);
|
|
935
935
|
}
|
|
936
936
|
});
|
|
@@ -940,7 +940,7 @@ class rt {
|
|
|
940
940
|
// => 이후 activeElements를 이용하여 mesh를 정리!!!+ map에서도 삭제
|
|
941
941
|
// private reconcileNode(node: SceneNode, activeElements: Set<HTMLElement>) {
|
|
942
942
|
reconcileNode(e) {
|
|
943
|
-
var i,
|
|
943
|
+
var i, l;
|
|
944
944
|
let t = this.registry.get(e.element);
|
|
945
945
|
const r = JSON.stringify(e.shaderHooks || null);
|
|
946
946
|
if (t && t.userData.shaderHash !== r && (this.scene.remove(t), t.geometry.dispose(), t.material instanceof y.Material && t.material.dispose(), this.registry.remove(e.element), t = void 0), !t) {
|
|
@@ -956,7 +956,7 @@ class rt {
|
|
|
956
956
|
);
|
|
957
957
|
t = new y.Mesh(n, a), e.type === "TEXT" && (t.name = "BG_MESH"), this.scene.add(t), this.registry.register(e.element, t), t.userData.baseMaterial = a, t.userData.domElement = e.element, t.userData.shaderHash = r;
|
|
958
958
|
}
|
|
959
|
-
if ((
|
|
959
|
+
if ((l = e.nativeStyles) != null && l.transform ? t.userData.nativeTransform = e.nativeStyles.transform : t.userData.nativeTransform = void 0, this.updateMeshProperties(t, e), this.updateMeshLayers(t, e), e.isTraveler)
|
|
960
960
|
for (let n = 0; n < _.MAX_LAYERS; n++)
|
|
961
961
|
n === e.captureLayer - 2 ? this.travelersByLayer[n].add(t) : this.travelersByLayer[n].delete(t);
|
|
962
962
|
else
|
|
@@ -973,32 +973,32 @@ class rt {
|
|
|
973
973
|
));
|
|
974
974
|
}
|
|
975
975
|
reconcileTextChild(e, t, r) {
|
|
976
|
-
var
|
|
976
|
+
var c;
|
|
977
977
|
const i = t.textLines || [
|
|
978
978
|
{ text: t.textContent || "", rect: t.rect }
|
|
979
|
-
],
|
|
979
|
+
], l = r ? t.nativeStyles : t.textStyles, n = JSON.stringify(l) + t.textContent + i.map((d) => d.text).join("|"), o = (c = e.userData) == null ? void 0 : c.textChildStyleHash;
|
|
980
980
|
if (t.dirtyMask & ve || n !== o) {
|
|
981
981
|
e.children.filter(
|
|
982
982
|
(g) => g.name.startsWith("TEXT_CHILD")
|
|
983
983
|
).forEach((g) => {
|
|
984
984
|
var b;
|
|
985
|
-
const
|
|
986
|
-
(b =
|
|
985
|
+
const m = g;
|
|
986
|
+
(b = m.material.map) == null || b.dispose(), m.geometry.dispose(), e.remove(m);
|
|
987
987
|
});
|
|
988
|
-
const h = t.rect, f = h.x + h.width / 2,
|
|
989
|
-
i.forEach((g,
|
|
988
|
+
const h = t.rect, f = h.x + h.width / 2, v = h.y + h.height / 2;
|
|
989
|
+
i.forEach((g, m) => {
|
|
990
990
|
const b = H.create(
|
|
991
991
|
"TEXT",
|
|
992
|
-
|
|
992
|
+
l,
|
|
993
993
|
g.text,
|
|
994
994
|
g.rect.width,
|
|
995
995
|
g.rect.height,
|
|
996
996
|
this.qualityFactor
|
|
997
997
|
), L = new y.PlaneGeometry(1, 1), M = new y.Mesh(L, b);
|
|
998
|
-
M.name = `TEXT_CHILD_${
|
|
998
|
+
M.name = `TEXT_CHILD_${m}`;
|
|
999
999
|
const S = t.rect.width === 0 ? 1 : g.rect.width / t.rect.width, x = t.rect.height === 0 ? 1 : g.rect.height / t.rect.height;
|
|
1000
1000
|
M.scale.set(S, x, 1);
|
|
1001
|
-
const C = g.rect.x + g.rect.width / 2, w = g.rect.y + g.rect.height / 2, T = C - f, A = -(w -
|
|
1001
|
+
const C = g.rect.x + g.rect.width / 2, w = g.rect.y + g.rect.height / 2, T = C - f, A = -(w - v);
|
|
1002
1002
|
M.position.set(
|
|
1003
1003
|
t.rect.width === 0 ? 0 : T / t.rect.width,
|
|
1004
1004
|
t.rect.height === 0 ? 0 : A / t.rect.height,
|
|
@@ -1009,22 +1009,24 @@ class rt {
|
|
|
1009
1009
|
e.children.forEach((d) => {
|
|
1010
1010
|
if (!d.name.startsWith("TEXT_CHILD"))
|
|
1011
1011
|
return;
|
|
1012
|
-
const h = d
|
|
1013
|
-
if (
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1012
|
+
const h = d;
|
|
1013
|
+
if (r && t.nativeLayer !== void 0)
|
|
1014
|
+
h.layers.set(U.HIDDEN), t.visibility & P && h.layers.enable(U.getCaptureLayer(t.nativeLayer));
|
|
1015
|
+
else {
|
|
1016
|
+
const f = t.visibility & P ? U.BASE : U.HIDDEN;
|
|
1017
|
+
if (h.layers.set(f), t.visibility & te && h.layers.enable(U.SELECTED), t.visibility & P)
|
|
1018
|
+
if (!r && t.nativeLayer !== void 0 && t.nativeStyles !== void 0)
|
|
1019
|
+
for (let v = t.captureLayer; v <= _.MAX_LAYERS + 1; v++)
|
|
1020
|
+
v !== t.nativeLayer && h.layers.enable(U.getCaptureLayer(v));
|
|
1021
|
+
else
|
|
1022
|
+
for (let v = t.captureLayer; v <= _.MAX_LAYERS + 1; v++)
|
|
1023
|
+
h.layers.enable(U.getCaptureLayer(v));
|
|
1024
|
+
}
|
|
1023
1025
|
});
|
|
1024
1026
|
}
|
|
1025
1027
|
updateMeshProperties(e, t) {
|
|
1026
1028
|
var S, x, C;
|
|
1027
|
-
const { rect: r, styles: i } = t,
|
|
1029
|
+
const { rect: r, styles: i } = t, l = this.renderer.getPixelRatio(), n = this.renderer.domElement.width / l, o = this.renderer.domElement.height / l;
|
|
1028
1030
|
e.material = e.userData.baseMaterial, e.scale.set(r.width, r.height, 1), e.userData.domRect = {
|
|
1029
1031
|
x: r.x,
|
|
1030
1032
|
y: r.y,
|
|
@@ -1033,12 +1035,12 @@ class rt {
|
|
|
1033
1035
|
};
|
|
1034
1036
|
const a = 1e-3;
|
|
1035
1037
|
this.renderOrder++;
|
|
1036
|
-
const
|
|
1038
|
+
const c = this.targetRect.left + window.scrollX, d = this.targetRect.top + window.scrollY;
|
|
1037
1039
|
let h, f;
|
|
1038
1040
|
if (this.isViewport)
|
|
1039
1041
|
h = r.x - window.innerWidth / 2 + r.width / 2, f = -r.y + window.innerHeight / 2 - r.height / 2;
|
|
1040
1042
|
else {
|
|
1041
|
-
const w = r.x -
|
|
1043
|
+
const w = r.x - c, T = r.y - d;
|
|
1042
1044
|
h = w - n / 2 + r.width / 2, f = -T + o / 2 - r.height / 2;
|
|
1043
1045
|
}
|
|
1044
1046
|
e.position.set(
|
|
@@ -1046,9 +1048,9 @@ class rt {
|
|
|
1046
1048
|
f,
|
|
1047
1049
|
i.zIndex + this.renderOrder * a
|
|
1048
1050
|
);
|
|
1049
|
-
const
|
|
1050
|
-
e.userData.basePosition = { x: h, y: f }, e.userData.originalBasePosition = { x: h, y: f }, e.userData.baseSize = { width: r.width, height: r.height }, e.userData.baseDOM = { x:
|
|
1051
|
-
const
|
|
1051
|
+
const v = r.x, g = r.y;
|
|
1052
|
+
e.userData.basePosition = { x: h, y: f }, e.userData.originalBasePosition = { x: h, y: f }, e.userData.baseSize = { width: r.width, height: r.height }, e.userData.baseDOM = { x: v, y: g }, e.userData.isFixed = t.isFixed, e.userData.initialScroll = { x: window.scrollX, y: window.scrollY };
|
|
1053
|
+
const m = t.element.nodeType === Node.TEXT_NODE ? t.element.parentElement : t.element, b = window.getComputedStyle(m);
|
|
1052
1054
|
let L = 0, M = 0;
|
|
1053
1055
|
if (b.transform && b.transform !== "none") {
|
|
1054
1056
|
const w = new DOMMatrix(b.transform);
|
|
@@ -1082,7 +1084,7 @@ class rt {
|
|
|
1082
1084
|
if (this.isViewport)
|
|
1083
1085
|
T = t.nativeRect.x - window.innerWidth / 2 + t.nativeRect.width / 2, A = -t.nativeRect.y + window.innerHeight / 2 - t.nativeRect.height / 2;
|
|
1084
1086
|
else {
|
|
1085
|
-
const X = t.nativeRect.x -
|
|
1087
|
+
const X = t.nativeRect.x - c, N = t.nativeRect.y - d;
|
|
1086
1088
|
T = X - n / 2 + t.nativeRect.width / 2, A = -N + o / 2 - t.nativeRect.height / 2;
|
|
1087
1089
|
}
|
|
1088
1090
|
let I = t.nativeRect.width, q = t.nativeRect.height, ie = T, se = A;
|
|
@@ -1095,10 +1097,10 @@ class rt {
|
|
|
1095
1097
|
const Z = X.match(/translate\(([^,]+),\s*([^)]+)\)/);
|
|
1096
1098
|
if (Z) {
|
|
1097
1099
|
const B = Z[1].trim(), F = Z[2].trim();
|
|
1098
|
-
let
|
|
1099
|
-
B.includes("%") && (
|
|
1100
|
+
let p = parseFloat(B);
|
|
1101
|
+
B.includes("%") && (p = p / 100 * t.nativeRect.width);
|
|
1100
1102
|
let R = parseFloat(F);
|
|
1101
|
-
F.includes("%") && (R = R / 100 * t.nativeRect.height), ie +=
|
|
1103
|
+
F.includes("%") && (R = R / 100 * t.nativeRect.height), ie += p, se -= R;
|
|
1102
1104
|
}
|
|
1103
1105
|
const ne = X.match(/translateX\(([^)]+)\)/);
|
|
1104
1106
|
if (ne) {
|
|
@@ -1131,34 +1133,33 @@ class rt {
|
|
|
1131
1133
|
e.userData.nativeMesh && (this.scene.remove(e.userData.nativeMesh), e.userData.nativeMesh.material instanceof y.Material && e.userData.nativeMesh.material.dispose(), delete e.userData.nativeMesh);
|
|
1132
1134
|
}
|
|
1133
1135
|
updateMeshLayers(e, t) {
|
|
1134
|
-
const r = t.visibility &
|
|
1136
|
+
const r = t.visibility & P ? U.BASE : U.HIDDEN;
|
|
1135
1137
|
if (e.layers.set(r), t.visibility & te && e.layers.enable(U.SELECTED), e.userData.nativeMesh && t.nativeLayer !== void 0) {
|
|
1136
1138
|
const i = e.userData.nativeMesh;
|
|
1137
|
-
if (i.layers.set(U.HIDDEN), t.visibility &
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
i.layers.enable(U.getCaptureLayer(c));
|
|
1139
|
+
if (i.layers.set(U.HIDDEN), t.visibility & P) {
|
|
1140
|
+
i.layers.enable(U.getCaptureLayer(t.nativeLayer));
|
|
1141
|
+
for (let l = t.captureLayer; l <= _.MAX_LAYERS + 1; l++)
|
|
1142
|
+
l !== t.nativeLayer && e.layers.enable(U.getCaptureLayer(l));
|
|
1142
1143
|
}
|
|
1143
|
-
} else if (t.visibility &
|
|
1144
|
+
} else if (t.visibility & P)
|
|
1144
1145
|
for (let i = t.captureLayer; i <= _.MAX_LAYERS + 1; i++)
|
|
1145
1146
|
e.layers.enable(U.getCaptureLayer(i));
|
|
1146
1147
|
}
|
|
1147
1148
|
captureRenderTarget(e, t, r) {
|
|
1148
1149
|
if (e.size === 0 || !r)
|
|
1149
1150
|
return;
|
|
1150
|
-
const i = new y.Color(),
|
|
1151
|
+
const i = new y.Color(), l = this.renderer.getClearAlpha();
|
|
1151
1152
|
this.renderer.getClearColor(i), this.renderer.setClearColor(0, 0), this.renderer.setRenderTarget(r), this.renderer.clear(), this.renderer.autoClear = !1, this.renderer.setScissorTest(!0), this.camera.layers.set(t);
|
|
1152
|
-
const n = new y.Vector3(), o = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, a = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height,
|
|
1153
|
+
const n = new y.Vector3(), o = this.isViewport ? window.innerWidth + this.overscan * 2 : this.targetRect.width, a = this.isViewport ? window.innerHeight + this.overscan * 2 : this.targetRect.height, c = this.renderer.getPixelRatio();
|
|
1153
1154
|
for (const d of e) {
|
|
1154
1155
|
n.setFromMatrixPosition(d.matrixWorld), n.project(this.camera);
|
|
1155
1156
|
const h = (n.x + 1) / 2 * o, f = (n.y + 1) / 2 * a;
|
|
1156
|
-
let
|
|
1157
|
-
typeof this.clipArea == "number" ? g = this.clipArea : this.clipArea.endsWith("%") ? g = parseFloat(this.clipArea) / 100 : this.clipArea.endsWith("px") && (
|
|
1158
|
-
const
|
|
1157
|
+
let v = 0, g = 1;
|
|
1158
|
+
typeof this.clipArea == "number" ? g = this.clipArea : this.clipArea.endsWith("%") ? g = parseFloat(this.clipArea) / 100 : this.clipArea.endsWith("px") && (v = parseFloat(this.clipArea));
|
|
1159
|
+
const m = d.scale.x * g + 0.5, b = d.scale.y * g + 0.5, L = h - m / 2, M = f - b / 2, S = (L * this.qualityFactor - v) / c, x = (M * this.qualityFactor - v) / c, C = (m * this.qualityFactor + v * 2) / c, w = (b * this.qualityFactor + v * 2) / c;
|
|
1159
1160
|
this.renderer.setScissor(S, x, C, w), this.renderer.render(this.scene, this.camera);
|
|
1160
1161
|
}
|
|
1161
|
-
this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(i,
|
|
1162
|
+
this.renderer.setScissorTest(!1), this.renderer.autoClear = !0, this.renderer.setRenderTarget(null), this.camera.layers.set(this.getSceneLayer()), this.renderer.setClearColor(i, l);
|
|
1162
1163
|
}
|
|
1163
1164
|
render() {
|
|
1164
1165
|
for (let e = 0; e < _.MAX_LAYERS; e++) {
|
|
@@ -1172,7 +1173,7 @@ class rt {
|
|
|
1172
1173
|
this.renderer.render(this.scene, this.camera);
|
|
1173
1174
|
}
|
|
1174
1175
|
syncMeshesByDOM() {
|
|
1175
|
-
const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, r = this.renderer.getPixelRatio(), i = this.renderer.domElement.width / r,
|
|
1176
|
+
const e = this.targetRect.left + window.scrollX, t = this.targetRect.top + window.scrollY, r = this.renderer.getPixelRatio(), i = this.renderer.domElement.width / r, l = this.renderer.domElement.height / r;
|
|
1176
1177
|
this.scene.children.forEach((n) => {
|
|
1177
1178
|
const o = n;
|
|
1178
1179
|
if (!o.userData || !o.userData.domElement)
|
|
@@ -1180,61 +1181,61 @@ class rt {
|
|
|
1180
1181
|
const a = o.userData.domElement;
|
|
1181
1182
|
if (!a.isConnected)
|
|
1182
1183
|
return;
|
|
1183
|
-
let
|
|
1184
|
+
let c;
|
|
1184
1185
|
if (a.nodeType === Node.TEXT_NODE) {
|
|
1185
1186
|
const h = document.createRange();
|
|
1186
|
-
h.selectNode(a),
|
|
1187
|
+
h.selectNode(a), c = h.getBoundingClientRect();
|
|
1187
1188
|
} else
|
|
1188
|
-
|
|
1189
|
+
c = a.getBoundingClientRect();
|
|
1189
1190
|
const d = o.userData.domRect;
|
|
1190
|
-
if (!d || Math.abs(
|
|
1191
|
+
if (!d || Math.abs(c.x - d.x) > 0.5 || Math.abs(c.y - d.y) > 0.5 || Math.abs(c.width - d.width) > 0.5 || Math.abs(c.height - d.height) > 0.5) {
|
|
1191
1192
|
o.userData.domRect = {
|
|
1192
|
-
x:
|
|
1193
|
-
y:
|
|
1194
|
-
width:
|
|
1195
|
-
height:
|
|
1193
|
+
x: c.x,
|
|
1194
|
+
y: c.y,
|
|
1195
|
+
width: c.width,
|
|
1196
|
+
height: c.height
|
|
1196
1197
|
};
|
|
1197
1198
|
let h, f;
|
|
1198
1199
|
if (this.isViewport)
|
|
1199
|
-
h =
|
|
1200
|
+
h = c.x - window.innerWidth / 2 + c.width / 2, f = -c.y + window.innerHeight / 2 - c.height / 2;
|
|
1200
1201
|
else {
|
|
1201
|
-
const
|
|
1202
|
-
h =
|
|
1202
|
+
const v = c.x - e, g = c.y - t;
|
|
1203
|
+
h = v - i / 2 + c.width / 2, f = -g + l / 2 - c.height / 2;
|
|
1203
1204
|
}
|
|
1204
|
-
if (o.position.setX(h), o.position.setY(f), o.scale.set(
|
|
1205
|
-
width:
|
|
1206
|
-
height:
|
|
1205
|
+
if (o.position.setX(h), o.position.setY(f), o.scale.set(c.width, c.height, 1), o.updateMatrixWorld(), o.material instanceof y.ShaderMaterial && H.forceUpdateUniforms(o.material, {
|
|
1206
|
+
width: c.width,
|
|
1207
|
+
height: c.height
|
|
1207
1208
|
}), o.userData.nativeMesh) {
|
|
1208
|
-
const
|
|
1209
|
-
let g =
|
|
1209
|
+
const v = o.userData.nativeMesh;
|
|
1210
|
+
let g = c.width, m = c.height, b = h, L = f;
|
|
1210
1211
|
if (o.userData.nativeTransform) {
|
|
1211
1212
|
const M = o.userData.nativeTransform, S = M.match(/scale\(([\d.]+%?)\)/);
|
|
1212
1213
|
if (S) {
|
|
1213
1214
|
let T = parseFloat(S[1]);
|
|
1214
|
-
S[1].includes("%") && (T /= 100), g *= T,
|
|
1215
|
+
S[1].includes("%") && (T /= 100), g *= T, m *= T;
|
|
1215
1216
|
}
|
|
1216
1217
|
const x = M.match(/translate\(([^,]+),\s*([^)]+)\)/);
|
|
1217
1218
|
if (x) {
|
|
1218
1219
|
const T = x[1].trim(), A = x[2].trim();
|
|
1219
1220
|
let I = parseFloat(T);
|
|
1220
|
-
T.includes("%") && (I = I / 100 *
|
|
1221
|
+
T.includes("%") && (I = I / 100 * c.width);
|
|
1221
1222
|
let q = parseFloat(A);
|
|
1222
|
-
A.includes("%") && (q = q / 100 *
|
|
1223
|
+
A.includes("%") && (q = q / 100 * c.height), b += I, L -= q;
|
|
1223
1224
|
}
|
|
1224
1225
|
const C = M.match(/translateX\(([^)]+)\)/);
|
|
1225
1226
|
if (C) {
|
|
1226
1227
|
const T = C[1].trim();
|
|
1227
1228
|
let A = parseFloat(T);
|
|
1228
|
-
T.includes("%") && (A = A / 100 *
|
|
1229
|
+
T.includes("%") && (A = A / 100 * c.width), b += A;
|
|
1229
1230
|
}
|
|
1230
1231
|
const w = M.match(/translateY\(([^)]+)\)/);
|
|
1231
1232
|
if (w) {
|
|
1232
1233
|
const T = w[1].trim();
|
|
1233
1234
|
let A = parseFloat(T);
|
|
1234
|
-
T.includes("%") && (A = A / 100 *
|
|
1235
|
+
T.includes("%") && (A = A / 100 * c.height), L -= A;
|
|
1235
1236
|
}
|
|
1236
1237
|
}
|
|
1237
|
-
|
|
1238
|
+
v.position.setX(b), v.position.setY(L), v.scale.set(g, m, 1), v.updateMatrixWorld();
|
|
1238
1239
|
}
|
|
1239
1240
|
}
|
|
1240
1241
|
});
|
|
@@ -1242,17 +1243,17 @@ class rt {
|
|
|
1242
1243
|
}
|
|
1243
1244
|
function it(s) {
|
|
1244
1245
|
const e = s.textContent || "", t = [];
|
|
1245
|
-
let r = "", i = null,
|
|
1246
|
-
const n = (
|
|
1247
|
-
for (let h = 0; h <
|
|
1248
|
-
const f =
|
|
1249
|
-
|
|
1250
|
-
const g =
|
|
1246
|
+
let r = "", i = null, l = -1;
|
|
1247
|
+
const n = (c, d) => {
|
|
1248
|
+
for (let h = 0; h < c.length; h++) {
|
|
1249
|
+
const f = c[h], v = document.createRange();
|
|
1250
|
+
v.setStart(s, d + h), v.setEnd(s, d + h + 1);
|
|
1251
|
+
const g = v.getBoundingClientRect();
|
|
1251
1252
|
if (g.width === 0 && g.height === 0) {
|
|
1252
1253
|
r += f;
|
|
1253
1254
|
continue;
|
|
1254
1255
|
}
|
|
1255
|
-
|
|
1256
|
+
l === -1 || Math.abs(g.top - l) > g.height / 2 ? (r && i && t.push({
|
|
1256
1257
|
text: r,
|
|
1257
1258
|
rect: {
|
|
1258
1259
|
left: i.left,
|
|
@@ -1265,26 +1266,26 @@ function it(s) {
|
|
|
1265
1266
|
top: g.top,
|
|
1266
1267
|
right: g.right,
|
|
1267
1268
|
bottom: g.bottom
|
|
1268
|
-
},
|
|
1269
|
+
}, l = g.top) : (r += f, i && (i.left = Math.min(i.left, g.left), i.top = Math.min(i.top, g.top), i.right = Math.max(i.right, g.right), i.bottom = Math.max(
|
|
1269
1270
|
i.bottom,
|
|
1270
1271
|
g.bottom
|
|
1271
1272
|
)));
|
|
1272
1273
|
}
|
|
1273
1274
|
}, o = e.match(/[^\s\-]+\-?|\-|\s+/g) || [];
|
|
1274
1275
|
let a = 0;
|
|
1275
|
-
for (const
|
|
1276
|
+
for (const c of o) {
|
|
1276
1277
|
const d = document.createRange();
|
|
1277
|
-
d.setStart(s, a), d.setEnd(s, a +
|
|
1278
|
+
d.setStart(s, a), d.setEnd(s, a + c.length);
|
|
1278
1279
|
const h = d.getClientRects();
|
|
1279
1280
|
if (h.length > 1)
|
|
1280
|
-
n(
|
|
1281
|
+
n(c, a);
|
|
1281
1282
|
else {
|
|
1282
1283
|
const f = h.length === 1 ? h[0] : d.getBoundingClientRect();
|
|
1283
1284
|
if (f.width === 0 && f.height === 0) {
|
|
1284
|
-
r +=
|
|
1285
|
+
r += c, a += c.length;
|
|
1285
1286
|
continue;
|
|
1286
1287
|
}
|
|
1287
|
-
|
|
1288
|
+
l === -1 || Math.abs(f.top - l) > f.height / 2 ? (r && i && t.push({
|
|
1288
1289
|
text: r,
|
|
1289
1290
|
rect: {
|
|
1290
1291
|
left: i.left,
|
|
@@ -1292,17 +1293,17 @@ function it(s) {
|
|
|
1292
1293
|
width: i.right - i.left,
|
|
1293
1294
|
height: i.bottom - i.top
|
|
1294
1295
|
}
|
|
1295
|
-
}), r =
|
|
1296
|
+
}), r = c, i = {
|
|
1296
1297
|
left: f.left,
|
|
1297
1298
|
top: f.top,
|
|
1298
1299
|
right: f.right,
|
|
1299
1300
|
bottom: f.bottom
|
|
1300
|
-
},
|
|
1301
|
+
}, l = f.top) : (r += c, 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(
|
|
1301
1302
|
i.bottom,
|
|
1302
1303
|
f.bottom
|
|
1303
1304
|
)));
|
|
1304
1305
|
}
|
|
1305
|
-
a +=
|
|
1306
|
+
a += c.length;
|
|
1306
1307
|
}
|
|
1307
1308
|
return r && i && t.push({
|
|
1308
1309
|
text: r,
|
|
@@ -1313,7 +1314,7 @@ function it(s) {
|
|
|
1313
1314
|
height: i.bottom - i.top
|
|
1314
1315
|
}
|
|
1315
1316
|
}), t.filter(
|
|
1316
|
-
(
|
|
1317
|
+
(c) => c.text.trim().length > 0 && c.rect.width > 0 && c.rect.height > 0
|
|
1317
1318
|
);
|
|
1318
1319
|
}
|
|
1319
1320
|
function Me(s) {
|
|
@@ -1332,30 +1333,30 @@ function Me(s) {
|
|
|
1332
1333
|
letterSpacing: r
|
|
1333
1334
|
};
|
|
1334
1335
|
}
|
|
1335
|
-
function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0,
|
|
1336
|
+
function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, l = 2, n, o) {
|
|
1336
1337
|
var N, Z, ne, oe, B, F;
|
|
1337
1338
|
if (s.nodeType === Node.TEXT_NODE) {
|
|
1338
|
-
const
|
|
1339
|
-
if (!
|
|
1339
|
+
const p = s;
|
|
1340
|
+
if (!p.textContent || !p.textContent.trim())
|
|
1340
1341
|
return null;
|
|
1341
|
-
const R =
|
|
1342
|
+
const R = p.textContent.replace(/\s+/g, " ");
|
|
1342
1343
|
if (R.length === 0)
|
|
1343
1344
|
return null;
|
|
1344
|
-
const O = it(
|
|
1345
|
+
const O = it(p);
|
|
1345
1346
|
if (O.length === 0)
|
|
1346
1347
|
return null;
|
|
1347
|
-
const V =
|
|
1348
|
+
const V = p.parentElement, k = V ? window.getComputedStyle(V) : null;
|
|
1348
1349
|
if (!k)
|
|
1349
1350
|
return null;
|
|
1350
|
-
const
|
|
1351
|
+
const G = Math.min(...O.map((E) => E.rect.left)), z = Math.min(...O.map((E) => E.rect.top)), j = Math.max(...O.map((E) => E.rect.left + E.rect.width)), D = Math.max(...O.map((E) => E.rect.top + E.rect.height));
|
|
1351
1352
|
return {
|
|
1352
1353
|
id: Math.random().toString(36).substring(2, 9),
|
|
1353
1354
|
type: "TEXT",
|
|
1354
|
-
element:
|
|
1355
|
+
element: p,
|
|
1355
1356
|
rect: {
|
|
1356
|
-
x:
|
|
1357
|
+
x: G + window.scrollX,
|
|
1357
1358
|
y: z + window.scrollY,
|
|
1358
|
-
width: j -
|
|
1359
|
+
width: j - G,
|
|
1359
1360
|
height: D - z
|
|
1360
1361
|
},
|
|
1361
1362
|
styles: {
|
|
@@ -1396,9 +1397,9 @@ function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, c = 2, n, o) {
|
|
|
1396
1397
|
isTraveler: !1
|
|
1397
1398
|
}, Me(k)), o) : void 0,
|
|
1398
1399
|
nativeRect: o ? {
|
|
1399
|
-
x:
|
|
1400
|
+
x: G + window.scrollX,
|
|
1400
1401
|
y: z + window.scrollY,
|
|
1401
|
-
width: j -
|
|
1402
|
+
width: j - G,
|
|
1402
1403
|
height: D - z
|
|
1403
1404
|
} : void 0,
|
|
1404
1405
|
children: []
|
|
@@ -1406,58 +1407,58 @@ function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, c = 2, n, o) {
|
|
|
1406
1407
|
}
|
|
1407
1408
|
if (s.nodeType !== Node.ELEMENT_NODE)
|
|
1408
1409
|
return null;
|
|
1409
|
-
const a = s,
|
|
1410
|
+
const a = s, c = a.dataset[W.KEY];
|
|
1410
1411
|
let d = t, h = t;
|
|
1411
|
-
if (
|
|
1412
|
-
const
|
|
1413
|
-
for (const R of
|
|
1412
|
+
if (c) {
|
|
1413
|
+
const p = new Set(c.split(/\s+/));
|
|
1414
|
+
for (const R of p)
|
|
1414
1415
|
if (!Te.includes(R))
|
|
1415
1416
|
throw new Error(
|
|
1416
1417
|
`[MirageEngine] Invalid filter token: '${R}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
|
|
1417
1418
|
);
|
|
1418
|
-
if (
|
|
1419
|
+
if (p.has(W.VALUES.END))
|
|
1419
1420
|
return null;
|
|
1420
|
-
if (
|
|
1421
|
+
if (p.has(W.VALUES.INCLUDE_TREE) && p.has(W.VALUES.EXCLUDE_TREE))
|
|
1421
1422
|
throw new Error(
|
|
1422
1423
|
"[MirageEngine] Conflicting filters: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
|
|
1423
1424
|
);
|
|
1424
|
-
if (
|
|
1425
|
+
if (p.has(W.VALUES.INCLUDE_SELF) && p.has(W.VALUES.EXCLUDE_SELF))
|
|
1425
1426
|
throw new Error(
|
|
1426
1427
|
"[MirageEngine] Conflicting filters: 'include-self' and 'exclude-self' cannot be used together on the same element."
|
|
1427
1428
|
);
|
|
1428
|
-
|
|
1429
|
+
p.has(W.VALUES.INCLUDE_TREE) ? d = d | P : p.has(W.VALUES.EXCLUDE_TREE) && (d = d & ~P), h = d, p.has(W.VALUES.INCLUDE_SELF) ? h = h | P : p.has(W.VALUES.EXCLUDE_SELF) && (h = h & ~P);
|
|
1429
1430
|
}
|
|
1430
|
-
const f = a.dataset[
|
|
1431
|
+
const f = a.dataset[$.KEY];
|
|
1431
1432
|
if (f) {
|
|
1432
|
-
const
|
|
1433
|
-
for (const R of
|
|
1433
|
+
const p = new Set(f.split(/\s+/));
|
|
1434
|
+
for (const R of p)
|
|
1434
1435
|
if (!Te.includes(R))
|
|
1435
1436
|
throw new Error(
|
|
1436
1437
|
`[MirageEngine] Invalid select token: '${R}'. Expected one of: 'include-tree', 'exclude-tree', 'include-self', 'exclude-self', 'end'.`
|
|
1437
1438
|
);
|
|
1438
|
-
if (
|
|
1439
|
+
if (p.has($.VALUES.END))
|
|
1439
1440
|
return null;
|
|
1440
|
-
if (
|
|
1441
|
+
if (p.has($.VALUES.INCLUDE_TREE) && p.has($.VALUES.EXCLUDE_TREE))
|
|
1441
1442
|
throw new Error(
|
|
1442
1443
|
"[MirageEngine] Conflicting selects: 'include-tree' and 'exclude-tree' cannot be used together on the same element."
|
|
1443
1444
|
);
|
|
1444
|
-
if (
|
|
1445
|
+
if (p.has($.VALUES.INCLUDE_SELF) && p.has($.VALUES.EXCLUDE_SELF))
|
|
1445
1446
|
throw new Error(
|
|
1446
1447
|
"[MirageEngine] Conflicting selects: 'include-self' and 'exclude-self' cannot be used together on the same element."
|
|
1447
1448
|
);
|
|
1448
|
-
|
|
1449
|
-
}
|
|
1450
|
-
const
|
|
1451
|
-
let g = !1,
|
|
1452
|
-
if (
|
|
1453
|
-
let
|
|
1454
|
-
const R =
|
|
1455
|
-
let V =
|
|
1449
|
+
p.has($.VALUES.INCLUDE_TREE) ? d = d | te : p.has($.VALUES.EXCLUDE_TREE) && (d = d & ~te), h = d, p.has($.VALUES.INCLUDE_SELF) ? h = h | te : p.has($.VALUES.EXCLUDE_SELF) && (h = h & ~te);
|
|
1450
|
+
}
|
|
1451
|
+
const v = a.dataset[_.KEY];
|
|
1452
|
+
let g = !1, m = o ? J({}, o) : {}, b = n;
|
|
1453
|
+
if (v) {
|
|
1454
|
+
let p = 1;
|
|
1455
|
+
const R = v.indexOf("{"), O = v.lastIndexOf("}");
|
|
1456
|
+
let V = v;
|
|
1456
1457
|
if (R !== -1 && O !== -1 && O > R) {
|
|
1457
|
-
V =
|
|
1458
|
-
const D =
|
|
1458
|
+
V = v.substring(0, R).trim();
|
|
1459
|
+
const D = v.substring(R, O + 1);
|
|
1459
1460
|
try {
|
|
1460
|
-
|
|
1461
|
+
m = new Function("return " + D)();
|
|
1461
1462
|
} catch (E) {
|
|
1462
1463
|
console.warn(
|
|
1463
1464
|
`[MirageEngine] Failed to parse travel styles JSON: ${D}`
|
|
@@ -1465,16 +1466,16 @@ function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, c = 2, n, o) {
|
|
|
1465
1466
|
}
|
|
1466
1467
|
}
|
|
1467
1468
|
const k = V.split(/\s+/);
|
|
1468
|
-
let
|
|
1469
|
+
let G = !1;
|
|
1469
1470
|
const z = k.indexOf(_.VALUES.TRAVELER);
|
|
1470
1471
|
if (z !== -1) {
|
|
1471
|
-
g = !0,
|
|
1472
|
+
g = !0, G = !0;
|
|
1472
1473
|
const D = k[z + 1];
|
|
1473
1474
|
if (D && !isNaN(parseInt(D, 10)))
|
|
1474
|
-
|
|
1475
|
+
p = parseInt(D, 10);
|
|
1475
1476
|
else {
|
|
1476
1477
|
const E = k.find((ee) => !isNaN(parseInt(ee, 10)));
|
|
1477
|
-
E && (
|
|
1478
|
+
E && (p = parseInt(E, 10));
|
|
1478
1479
|
}
|
|
1479
1480
|
}
|
|
1480
1481
|
const j = k.indexOf(_.VALUES.NATIVE);
|
|
@@ -1487,11 +1488,11 @@ function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, c = 2, n, o) {
|
|
|
1487
1488
|
E && (b = parseInt(E, 10));
|
|
1488
1489
|
}
|
|
1489
1490
|
}
|
|
1490
|
-
if (
|
|
1491
|
-
const D =
|
|
1491
|
+
if (G) {
|
|
1492
|
+
const D = p + 1;
|
|
1492
1493
|
if (D < r)
|
|
1493
1494
|
throw new Error(
|
|
1494
|
-
`[MirageEngine] Traveler layer (${
|
|
1495
|
+
`[MirageEngine] Traveler layer (${p}) cannot be smaller than inherited capture layer (${r - 1}).`
|
|
1495
1496
|
);
|
|
1496
1497
|
r = Math.min(D, _.MAX_LAYERS + 1);
|
|
1497
1498
|
}
|
|
@@ -1509,7 +1510,7 @@ function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, c = 2, n, o) {
|
|
|
1509
1510
|
if (a.tagName === "IMG")
|
|
1510
1511
|
A = a.src;
|
|
1511
1512
|
else if (a.tagName.toLowerCase() === "svg") {
|
|
1512
|
-
const
|
|
1513
|
+
const p = a.cloneNode(!0), R = m == null ? void 0 : m.color, O = m == null ? void 0 : m.fill, V = m == null ? void 0 : m.stroke, k = m == null ? void 0 : m.opacity, G = (E, ee) => {
|
|
1513
1514
|
const Y = window.getComputedStyle(E), ae = ee, Be = Y.fill === Y.color, Oe = Y.stroke === Y.color, fe = O || (Be ? R : void 0) || Y.fill;
|
|
1514
1515
|
fe && fe !== "none" && (ae.style.fill = fe);
|
|
1515
1516
|
const ge = V || (Oe ? R : void 0) || Y.stroke;
|
|
@@ -1519,19 +1520,19 @@ function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, c = 2, n, o) {
|
|
|
1519
1520
|
const pe = k || Y.opacity;
|
|
1520
1521
|
pe && pe !== "1" && (ae.style.opacity = pe);
|
|
1521
1522
|
for (let he = 0; he < E.children.length; he++)
|
|
1522
|
-
|
|
1523
|
+
G(E.children[he], ee.children[he]);
|
|
1523
1524
|
};
|
|
1524
|
-
|
|
1525
|
-
const z = a.getBoundingClientRect(), j = window.devicePixelRatio *
|
|
1526
|
-
|
|
1527
|
-
let D = new XMLSerializer().serializeToString(
|
|
1525
|
+
G(a, p);
|
|
1526
|
+
const z = a.getBoundingClientRect(), j = window.devicePixelRatio * l;
|
|
1527
|
+
p.hasAttribute("viewBox") || p.setAttribute("viewBox", `0 0 ${z.width} ${z.height}`), p.setAttribute("width", (z.width * j).toString()), p.setAttribute("height", (z.height * j).toString());
|
|
1528
|
+
let D = new XMLSerializer().serializeToString(p);
|
|
1528
1529
|
D.includes("xmlns=") || (D = D.replace(
|
|
1529
1530
|
"<svg",
|
|
1530
1531
|
'<svg xmlns="http://www.w3.org/2000/svg"'
|
|
1531
1532
|
)), A = `data:image/svg+xml;utf8,${encodeURIComponent(D)}`;
|
|
1532
1533
|
} else if (x.backgroundImage && x.backgroundImage !== "none") {
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1534
|
+
const p = x.backgroundImage.match(/url\(['"]?(.*?)['"]?\)/);
|
|
1535
|
+
p && (A = p[1]);
|
|
1535
1536
|
}
|
|
1536
1537
|
const I = {
|
|
1537
1538
|
backgroundColor: x.backgroundColor,
|
|
@@ -1546,16 +1547,16 @@ function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, c = 2, n, o) {
|
|
|
1546
1547
|
}, q = I;
|
|
1547
1548
|
let ie, se;
|
|
1548
1549
|
const X = [];
|
|
1549
|
-
return a.tagName.toLowerCase() !== "svg" && Array.from(a.childNodes).forEach((
|
|
1550
|
-
const R =
|
|
1551
|
-
|
|
1550
|
+
return a.tagName.toLowerCase() !== "svg" && Array.from(a.childNodes).forEach((p) => {
|
|
1551
|
+
const R = p.nodeType === Node.TEXT_NODE ? h : d, O = Ue(
|
|
1552
|
+
p,
|
|
1552
1553
|
e,
|
|
1553
1554
|
R,
|
|
1554
1555
|
r,
|
|
1555
1556
|
T,
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1557
|
+
l,
|
|
1558
|
+
p.nodeType === Node.TEXT_NODE ? b : void 0,
|
|
1559
|
+
p.nodeType === Node.TEXT_NODE && Object.keys(m).length > 0 ? m : void 0
|
|
1559
1560
|
);
|
|
1560
1561
|
O && X.push(O);
|
|
1561
1562
|
}), {
|
|
@@ -1577,21 +1578,21 @@ function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, c = 2, n, o) {
|
|
|
1577
1578
|
captureLayer: r,
|
|
1578
1579
|
nativeLayer: b,
|
|
1579
1580
|
nativeStyles: b !== void 0 ? xe(J({}, I), {
|
|
1580
|
-
backgroundColor: (N =
|
|
1581
|
-
backgroundImage: (Z =
|
|
1582
|
-
opacity: (ne =
|
|
1583
|
-
zIndex:
|
|
1584
|
-
borderRadius: (oe =
|
|
1585
|
-
borderColor: (B =
|
|
1586
|
-
borderWidth: (F =
|
|
1581
|
+
backgroundColor: (N = m.backgroundColor) != null ? N : I.backgroundColor,
|
|
1582
|
+
backgroundImage: (Z = m.backgroundImage) != null ? Z : I.backgroundImage,
|
|
1583
|
+
opacity: (ne = m.opacity) != null ? ne : I.opacity,
|
|
1584
|
+
zIndex: m.zIndex !== void 0 ? m.zIndex + T : I.zIndex,
|
|
1585
|
+
borderRadius: (oe = m.borderRadius) != null ? oe : I.borderRadius,
|
|
1586
|
+
borderColor: (B = m.borderColor) != null ? B : I.borderColor,
|
|
1587
|
+
borderWidth: (F = m.borderWidth) != null ? F : I.borderWidth,
|
|
1587
1588
|
isTraveler: I.isTraveler,
|
|
1588
|
-
transform:
|
|
1589
|
+
transform: m.transform
|
|
1589
1590
|
}) : void 0,
|
|
1590
1591
|
nativeRect: b !== void 0 ? {
|
|
1591
|
-
x:
|
|
1592
|
-
y:
|
|
1593
|
-
width:
|
|
1594
|
-
height:
|
|
1592
|
+
x: m.x !== void 0 ? parseFloat(m.x) : S.left + window.scrollX,
|
|
1593
|
+
y: m.y !== void 0 ? parseFloat(m.y) : S.top + window.scrollY,
|
|
1594
|
+
width: m.width !== void 0 ? parseFloat(m.width) : S.width,
|
|
1595
|
+
height: m.height !== void 0 ? parseFloat(m.height) : S.height
|
|
1595
1596
|
} : void 0,
|
|
1596
1597
|
isFixed: x.position === "fixed",
|
|
1597
1598
|
children: X,
|
|
@@ -1600,13 +1601,13 @@ function Ue(s, e = Q | ce | Ye | ve | ue, t, r = 1, i = 0, c = 2, n, o) {
|
|
|
1600
1601
|
}
|
|
1601
1602
|
function st(s, e) {
|
|
1602
1603
|
e.size !== 0 && e.forEach((t, r) => {
|
|
1603
|
-
var
|
|
1604
|
+
var l, n, o, a;
|
|
1604
1605
|
const i = s.get(r);
|
|
1605
1606
|
!i || !i.userData.basePosition || (H.forceUpdateUniforms(i.material, {
|
|
1606
1607
|
backgroundColor: t.backgroundColor,
|
|
1607
1608
|
backgroundImage: t.backgroundImage,
|
|
1608
1609
|
opacity: t.opacity,
|
|
1609
|
-
borderRadius: (n = t.borderRadius) != null ? n : (
|
|
1610
|
+
borderRadius: (n = t.borderRadius) != null ? n : (l = i.userData.baseStyles) == null ? void 0 : l.borderRadius
|
|
1610
1611
|
// width and height are no longer updated here, they are updated in syncMeshesByDOM
|
|
1611
1612
|
}), i.userData.nativeMesh && H.forceUpdateUniforms(i.userData.nativeMesh.material, {
|
|
1612
1613
|
backgroundColor: t.backgroundColor,
|
|
@@ -1625,19 +1626,19 @@ class nt {
|
|
|
1625
1626
|
u(this, "tracker");
|
|
1626
1627
|
this.target = e, this.renderer = t, this.registry = r, this.tracker = new De(e, {
|
|
1627
1628
|
resizeDebounce: i.resizeDebounce
|
|
1628
|
-
}), this.tracker.onLayoutChange.add((
|
|
1629
|
+
}), this.tracker.onLayoutChange.add((l, n) => {
|
|
1629
1630
|
document.querySelector(`[${_.NAME}~='${_.VALUES.TRAVELER}']`) !== null && !this.isTravelEnabled && (this.isTravelEnabled = !0, this.renderer.createRenderTarget());
|
|
1630
1631
|
const a = Ue(
|
|
1631
1632
|
this.target,
|
|
1632
|
-
|
|
1633
|
-
|
|
1633
|
+
l,
|
|
1634
|
+
P,
|
|
1634
1635
|
1,
|
|
1635
1636
|
0,
|
|
1636
1637
|
this.renderer.qualityFactor
|
|
1637
1638
|
);
|
|
1638
1639
|
a && this.renderer.syncScene(a, n);
|
|
1639
|
-
}), this.tracker.onStyleChange.add((
|
|
1640
|
-
st(this.registry,
|
|
1640
|
+
}), this.tracker.onStyleChange.add((l) => {
|
|
1641
|
+
st(this.registry, l);
|
|
1641
1642
|
}), this.tracker.onRender.add(() => {
|
|
1642
1643
|
this.renderer.syncMeshesByDOM(), this.renderer.render();
|
|
1643
1644
|
});
|
|
@@ -1680,7 +1681,7 @@ class at {
|
|
|
1680
1681
|
u(this, "syncer");
|
|
1681
1682
|
u(this, "target");
|
|
1682
1683
|
u(this, "registry");
|
|
1683
|
-
var i,
|
|
1684
|
+
var i, l, n;
|
|
1684
1685
|
if (this.target = e, this.registry = new ot(), !document.getElementById("mirage-engine-styles")) {
|
|
1685
1686
|
const o = document.createElement("style");
|
|
1686
1687
|
o.id = "mirage-engine-styles", o.textContent = `
|
|
@@ -1690,7 +1691,7 @@ class at {
|
|
|
1690
1691
|
`, document.head.appendChild(o);
|
|
1691
1692
|
}
|
|
1692
1693
|
let r;
|
|
1693
|
-
if (t.mode === "duplicate" ? r = (
|
|
1694
|
+
if (t.mode === "duplicate" ? r = (l = (i = t.container) != null ? i : this.target.parentElement) != null ? l : void 0 : r = (n = this.target.parentElement) != null ? n : void 0, !r)
|
|
1694
1695
|
throw new Error("[Mirage] Cannot find a container (parent or option).");
|
|
1695
1696
|
this.renderer = new rt(
|
|
1696
1697
|
this.target,
|
|
@@ -1729,10 +1730,10 @@ class at {
|
|
|
1729
1730
|
ArrowUp: !1,
|
|
1730
1731
|
ArrowDown: !1
|
|
1731
1732
|
};
|
|
1732
|
-
window.addEventListener("keydown", (
|
|
1733
|
-
t[
|
|
1734
|
-
}), window.addEventListener("keyup", (
|
|
1735
|
-
t[
|
|
1733
|
+
window.addEventListener("keydown", (l) => {
|
|
1734
|
+
t[l.key] !== void 0 && (t[l.key] = !0);
|
|
1735
|
+
}), window.addEventListener("keyup", (l) => {
|
|
1736
|
+
t[l.key] !== void 0 && (t[l.key] = !1);
|
|
1736
1737
|
});
|
|
1737
1738
|
const r = 2, i = () => {
|
|
1738
1739
|
requestAnimationFrame(i), t.ArrowRight && e.position.setX(e.position.x + r), t.ArrowLeft && e.position.setX(e.position.x - r), t.ArrowUp && e.position.setY(e.position.y + r), t.ArrowDown && e.position.setY(e.position.y - r);
|
|
@@ -1779,8 +1780,8 @@ class ct {
|
|
|
1779
1780
|
const e = document.querySelectorAll(this.frontSelector);
|
|
1780
1781
|
this.frontLayer && e.forEach((t) => {
|
|
1781
1782
|
var n;
|
|
1782
|
-
const r = t.getBoundingClientRect(), i = window.getComputedStyle(t),
|
|
1783
|
-
|
|
1783
|
+
const r = t.getBoundingClientRect(), i = window.getComputedStyle(t), l = document.createElement("div");
|
|
1784
|
+
l.className = "sand-placeholder", Object.assign(l.style, {
|
|
1784
1785
|
display: i.display === "inline" ? "inline-block" : i.display,
|
|
1785
1786
|
width: `${r.width}px`,
|
|
1786
1787
|
height: `${r.height}px`,
|
|
@@ -1791,14 +1792,14 @@ class ct {
|
|
|
1791
1792
|
marginRight: i.marginRight,
|
|
1792
1793
|
visibility: "hidden",
|
|
1793
1794
|
pointerEvents: "none"
|
|
1794
|
-
}), (n = t.parentNode) == null || n.insertBefore(
|
|
1795
|
+
}), (n = t.parentNode) == null || n.insertBefore(l, t), this.frontLayer.appendChild(t), Object.assign(t.style, {
|
|
1795
1796
|
position: "fixed",
|
|
1796
1797
|
margin: "0",
|
|
1797
1798
|
boxSizing: "border-box",
|
|
1798
1799
|
width: `${r.width}px`,
|
|
1799
1800
|
height: `${r.height}px`,
|
|
1800
1801
|
pointerEvents: "auto"
|
|
1801
|
-
}), this.items.push({ placeholder:
|
|
1802
|
+
}), this.items.push({ placeholder: l, original: t });
|
|
1802
1803
|
});
|
|
1803
1804
|
}
|
|
1804
1805
|
setupHooks() {
|