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