@applemusic-like-lyrics/core 0.2.0-alpha.1 → 0.2.0-alpha.2
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/amll-core.js +811 -691
- package/dist/amll-core.js.map +1 -1
- package/package.json +3 -1
package/dist/amll-core.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Container as
|
|
5
|
-
import { Application as
|
|
1
|
+
var me = Object.defineProperty;
|
|
2
|
+
var fe = (d, t, e) => t in d ? me(d, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : d[t] = e;
|
|
3
|
+
var f = (d, t, e) => fe(d, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { Container as pe } from "@pixi/display";
|
|
5
|
+
import { Application as ge } from "@pixi/app";
|
|
6
6
|
import { BlurFilter as X } from "@pixi/filter-blur";
|
|
7
|
-
import { ColorMatrixFilter as
|
|
8
|
-
import { Texture as
|
|
9
|
-
import { Sprite as
|
|
10
|
-
import { BulgePinchFilter as
|
|
11
|
-
class
|
|
7
|
+
import { ColorMatrixFilter as Pt } from "@pixi/filter-color-matrix";
|
|
8
|
+
import { Texture as ue } from "@pixi/core";
|
|
9
|
+
import { Sprite as ft } from "@pixi/sprite";
|
|
10
|
+
import { BulgePinchFilter as pt } from "@pixi/filter-bulge-pinch";
|
|
11
|
+
class ye {
|
|
12
12
|
}
|
|
13
|
-
class
|
|
13
|
+
class Jt extends ye {
|
|
14
14
|
constructor(e) {
|
|
15
15
|
super();
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
f(this, "observer");
|
|
17
|
+
f(this, "flowSpeed", 4);
|
|
18
|
+
f(this, "currerntRenderScale", 0.75);
|
|
19
19
|
this.canvas = e, this.observer = new ResizeObserver(() => {
|
|
20
20
|
const s = Math.max(
|
|
21
21
|
1,
|
|
@@ -57,13 +57,13 @@ class qt extends ee {
|
|
|
57
57
|
return this.canvas;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function Me(d) {
|
|
61
61
|
return new Promise((t, e) => {
|
|
62
62
|
const s = document.createElement("img");
|
|
63
63
|
s.onload = () => t(s), s.onerror = e, s.src = d, s.crossOrigin = "anonymous", s.loading = "eager";
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function Te(d) {
|
|
67
67
|
return new Promise((t, e) => {
|
|
68
68
|
const s = document.createElement("video");
|
|
69
69
|
let i = !1, n = !1, r = !1;
|
|
@@ -92,28 +92,28 @@ function ie(d) {
|
|
|
92
92
|
s.src = d, s.playsInline = !0, s.crossOrigin = "anonymous", s.autoplay = !0, s.loop = !0, s.muted = !0, s.play();
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
-
function
|
|
96
|
-
return t ?
|
|
95
|
+
function Qt(d, t = !1) {
|
|
96
|
+
return t ? Te(d) : Me(d);
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function Kt(d) {
|
|
99
99
|
return new Promise((t, e) => {
|
|
100
100
|
(d instanceof HTMLImageElement ? d.complete : d.readyState >= 3) ? t(d) : (d.onload = () => t(d), d.onerror = e);
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
class
|
|
103
|
+
class xe extends pe {
|
|
104
104
|
constructor() {
|
|
105
105
|
super(...arguments);
|
|
106
|
-
|
|
106
|
+
f(this, "time", 0);
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
|
-
class
|
|
109
|
+
class Os extends Jt {
|
|
110
110
|
constructor(e) {
|
|
111
111
|
super(e);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
112
|
+
f(this, "app");
|
|
113
|
+
f(this, "curContainer");
|
|
114
|
+
f(this, "staticMode", !1);
|
|
115
|
+
f(this, "lastContainer", /* @__PURE__ */ new Set());
|
|
116
|
+
f(this, "onTick", (e) => {
|
|
117
117
|
for (const s of this.lastContainer)
|
|
118
118
|
s.alpha = Math.max(0, s.alpha - e / 60), s.alpha <= 0 && (this.app.stage.removeChild(s), this.lastContainer.delete(s), s.destroy(!0));
|
|
119
119
|
if (this.curContainer) {
|
|
@@ -128,7 +128,7 @@ class ys extends qt {
|
|
|
128
128
|
), n.position.set(this.app.screen.width / 2, this.app.screen.height / 2), r.position.set(this.app.screen.width / 2, this.app.screen.height / 2), s.width = a * Math.sqrt(2), s.height = s.width, i.width = a * 0.8, i.height = i.width, n.width = a * 0.5, n.height = n.width, r.width = a * 0.25, r.height = r.width, this.curContainer.time += e * this.flowSpeed, s.rotation += e / 1e3 * this.flowSpeed, i.rotation -= e / 500 * this.flowSpeed, n.rotation += e / 1e3 * this.flowSpeed, r.rotation -= e / 750 * this.flowSpeed, n.x = this.app.screen.width / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), n.y = this.app.screen.height / 2 + this.app.screen.width / 4 * Math.cos(this.curContainer.time / 1e3 * 0.75), r.x = this.app.screen.width / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), r.y = this.app.screen.height / 2 + this.app.screen.width / 4 * 0.1 + Math.cos(this.curContainer.time * 6e-3 * 0.75), this.curContainer.alpha >= 1 && this.lastContainer.size === 0 && this.staticMode && this.app.ticker.stop();
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
|
-
this.canvas = e, this.app = new
|
|
131
|
+
this.canvas = e, this.app = new ge({
|
|
132
132
|
view: e,
|
|
133
133
|
resizeTo: this.canvas,
|
|
134
134
|
powerPreference: "low-power",
|
|
@@ -143,33 +143,33 @@ class ys extends qt {
|
|
|
143
143
|
}
|
|
144
144
|
rebuildFilters() {
|
|
145
145
|
var a;
|
|
146
|
-
const e = Math.min(this.canvas.width, this.canvas.height), s = Math.max(this.canvas.width, this.canvas.height), i = new
|
|
146
|
+
const e = Math.min(this.canvas.width, this.canvas.height), s = Math.max(this.canvas.width, this.canvas.height), i = new Pt();
|
|
147
147
|
i.saturate(1.2, !1);
|
|
148
|
-
const n = new
|
|
148
|
+
const n = new Pt();
|
|
149
149
|
n.brightness(0.6, !1);
|
|
150
|
-
const r = new
|
|
150
|
+
const r = new Pt();
|
|
151
151
|
r.contrast(0.3, !0), (a = this.app.stage.filters) == null || a.forEach((c) => {
|
|
152
152
|
c.destroy();
|
|
153
153
|
}), this.app.stage.filters = [], this.app.stage.filters.push(new X(5, 1)), this.app.stage.filters.push(new X(10, 1)), this.app.stage.filters.push(new X(20, 2)), this.app.stage.filters.push(new X(40, 2)), this.app.stage.filters.push(new X(80, 2)), e > 768 && this.app.stage.filters.push(new X(160, 4)), e > 768 * 2 && this.app.stage.filters.push(new X(320, 4)), this.app.stage.filters.push(i, n, r), this.app.stage.filters.push(new X(5, 1)), Math.random() > 0.5 ? (this.app.stage.filters.push(
|
|
154
|
-
new
|
|
154
|
+
new pt({
|
|
155
155
|
radius: (s + e) / 2,
|
|
156
156
|
strength: 1,
|
|
157
157
|
center: [0.25, 1]
|
|
158
158
|
})
|
|
159
159
|
), this.app.stage.filters.push(
|
|
160
|
-
new
|
|
160
|
+
new pt({
|
|
161
161
|
radius: (s + e) / 2,
|
|
162
162
|
strength: 1,
|
|
163
163
|
center: [0.75, 0]
|
|
164
164
|
})
|
|
165
165
|
)) : (this.app.stage.filters.push(
|
|
166
|
-
new
|
|
166
|
+
new pt({
|
|
167
167
|
radius: (s + e) / 2,
|
|
168
168
|
strength: 1,
|
|
169
169
|
center: [0.75, 1]
|
|
170
170
|
})
|
|
171
171
|
), this.app.stage.filters.push(
|
|
172
|
-
new
|
|
172
|
+
new pt({
|
|
173
173
|
radius: (s + e) / 2,
|
|
174
174
|
strength: 1,
|
|
175
175
|
center: [0.25, 0]
|
|
@@ -193,13 +193,13 @@ class ys extends qt {
|
|
|
193
193
|
setHasLyric(e) {
|
|
194
194
|
}
|
|
195
195
|
async setAlbum(e, s) {
|
|
196
|
-
var
|
|
196
|
+
var m, g;
|
|
197
197
|
if (typeof e == "string" && e.trim().length === 0)
|
|
198
198
|
return;
|
|
199
199
|
let i = null, n = 5, r = null;
|
|
200
|
-
for (; !((g = (
|
|
200
|
+
for (; !((g = (m = r == null ? void 0 : r.baseTexture) == null ? void 0 : m.resource) != null && g.valid) && n > 0; )
|
|
201
201
|
try {
|
|
202
|
-
typeof e == "string" ? i = await
|
|
202
|
+
typeof e == "string" ? i = await Qt(e, s) : i = await Kt(e), r = ue.from(i, {
|
|
203
203
|
resourceOptions: {
|
|
204
204
|
autoLoad: !1
|
|
205
205
|
}
|
|
@@ -212,8 +212,8 @@ class ys extends qt {
|
|
|
212
212
|
), r = null, n--;
|
|
213
213
|
}
|
|
214
214
|
if (!r) return;
|
|
215
|
-
const a = new
|
|
216
|
-
c.anchor.set(0.5, 0.5),
|
|
215
|
+
const a = new xe(), c = new ft(r), h = new ft(r), o = new ft(r), l = new ft(r);
|
|
216
|
+
c.anchor.set(0.5, 0.5), h.anchor.set(0.5, 0.5), o.anchor.set(0.5, 0.5), l.anchor.set(0.5, 0.5), c.rotation = Math.random() * Math.PI * 2, h.rotation = Math.random() * Math.PI * 2, o.rotation = Math.random() * Math.PI * 2, l.rotation = Math.random() * Math.PI * 2, a.addChild(c, h, o, l), this.curContainer && this.lastContainer.add(this.curContainer), this.curContainer = a, this.app.stage.addChild(a), this.curContainer.alpha = 0, this.app.ticker.start();
|
|
217
217
|
}
|
|
218
218
|
dispose() {
|
|
219
219
|
super.dispose(), this.app.ticker.remove(this.onTick), this.app.destroy(!0);
|
|
@@ -222,7 +222,7 @@ class ys extends qt {
|
|
|
222
222
|
return this.canvas;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
const
|
|
225
|
+
const O = 1e-6, Ot = new Float32Array([
|
|
226
226
|
1,
|
|
227
227
|
0,
|
|
228
228
|
0,
|
|
@@ -239,7 +239,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
239
239
|
0,
|
|
240
240
|
0,
|
|
241
241
|
1
|
|
242
|
-
]),
|
|
242
|
+
]), q = class q extends Float32Array {
|
|
243
243
|
/**
|
|
244
244
|
* Create a {@link Mat4}.
|
|
245
245
|
*/
|
|
@@ -273,7 +273,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
273
273
|
]) : super(e, 0, 16);
|
|
274
274
|
break;
|
|
275
275
|
default:
|
|
276
|
-
super(
|
|
276
|
+
super(Ot);
|
|
277
277
|
break;
|
|
278
278
|
}
|
|
279
279
|
}
|
|
@@ -285,7 +285,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
285
285
|
* Equivalent to `Mat4.str(this);`
|
|
286
286
|
*/
|
|
287
287
|
get str() {
|
|
288
|
-
return
|
|
288
|
+
return q.str(this);
|
|
289
289
|
}
|
|
290
290
|
//===================
|
|
291
291
|
// Instance methods
|
|
@@ -306,7 +306,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
306
306
|
* @returns `this`
|
|
307
307
|
*/
|
|
308
308
|
identity() {
|
|
309
|
-
return this.set(
|
|
309
|
+
return this.set(Ot), this;
|
|
310
310
|
}
|
|
311
311
|
/**
|
|
312
312
|
* Multiplies this {@link Mat4} against another one
|
|
@@ -318,7 +318,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
318
318
|
* @returns `this`
|
|
319
319
|
*/
|
|
320
320
|
multiply(t) {
|
|
321
|
-
return
|
|
321
|
+
return q.multiply(this, this, t);
|
|
322
322
|
}
|
|
323
323
|
/**
|
|
324
324
|
* Alias for {@link Mat4.multiply}
|
|
@@ -333,7 +333,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
333
333
|
* @returns `this`
|
|
334
334
|
*/
|
|
335
335
|
transpose() {
|
|
336
|
-
return
|
|
336
|
+
return q.transpose(this, this);
|
|
337
337
|
}
|
|
338
338
|
/**
|
|
339
339
|
* Inverts this {@link Mat4}
|
|
@@ -342,7 +342,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
342
342
|
* @returns `this`
|
|
343
343
|
*/
|
|
344
344
|
invert() {
|
|
345
|
-
return
|
|
345
|
+
return q.invert(this, this);
|
|
346
346
|
}
|
|
347
347
|
/**
|
|
348
348
|
* Translate this {@link Mat4} by the given vector
|
|
@@ -352,7 +352,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
352
352
|
* @returns `this`
|
|
353
353
|
*/
|
|
354
354
|
translate(t) {
|
|
355
|
-
return
|
|
355
|
+
return q.translate(this, this, t);
|
|
356
356
|
}
|
|
357
357
|
/**
|
|
358
358
|
* Rotates this {@link Mat4} by the given angle around the given axis
|
|
@@ -363,7 +363,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
363
363
|
* @returns `out`
|
|
364
364
|
*/
|
|
365
365
|
rotate(t, e) {
|
|
366
|
-
return
|
|
366
|
+
return q.rotate(this, this, t, e);
|
|
367
367
|
}
|
|
368
368
|
/**
|
|
369
369
|
* Scales this {@link Mat4} by the dimensions in the given vec3 not using vectorization
|
|
@@ -373,7 +373,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
373
373
|
* @returns `this`
|
|
374
374
|
*/
|
|
375
375
|
scale(t) {
|
|
376
|
-
return
|
|
376
|
+
return q.scale(this, this, t);
|
|
377
377
|
}
|
|
378
378
|
/**
|
|
379
379
|
* Rotates this {@link Mat4} by the given angle around the X axis
|
|
@@ -383,7 +383,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
383
383
|
* @returns `this`
|
|
384
384
|
*/
|
|
385
385
|
rotateX(t) {
|
|
386
|
-
return
|
|
386
|
+
return q.rotateX(this, this, t);
|
|
387
387
|
}
|
|
388
388
|
/**
|
|
389
389
|
* Rotates this {@link Mat4} by the given angle around the Y axis
|
|
@@ -393,7 +393,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
393
393
|
* @returns `this`
|
|
394
394
|
*/
|
|
395
395
|
rotateY(t) {
|
|
396
|
-
return
|
|
396
|
+
return q.rotateY(this, this, t);
|
|
397
397
|
}
|
|
398
398
|
/**
|
|
399
399
|
* Rotates this {@link Mat4} by the given angle around the Z axis
|
|
@@ -403,7 +403,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
403
403
|
* @returns `this`
|
|
404
404
|
*/
|
|
405
405
|
rotateZ(t) {
|
|
406
|
-
return
|
|
406
|
+
return q.rotateZ(this, this, t);
|
|
407
407
|
}
|
|
408
408
|
/**
|
|
409
409
|
* Generates a perspective projection matrix with the given bounds.
|
|
@@ -419,7 +419,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
419
419
|
* @returns `this`
|
|
420
420
|
*/
|
|
421
421
|
perspectiveNO(t, e, s, i) {
|
|
422
|
-
return
|
|
422
|
+
return q.perspectiveNO(this, t, e, s, i);
|
|
423
423
|
}
|
|
424
424
|
/**
|
|
425
425
|
* Generates a perspective projection matrix suitable for WebGPU with the given bounds.
|
|
@@ -435,7 +435,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
435
435
|
* @returns `this`
|
|
436
436
|
*/
|
|
437
437
|
perspectiveZO(t, e, s, i) {
|
|
438
|
-
return
|
|
438
|
+
return q.perspectiveZO(this, t, e, s, i);
|
|
439
439
|
}
|
|
440
440
|
/**
|
|
441
441
|
* Generates a orthogonal projection matrix with the given bounds.
|
|
@@ -452,7 +452,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
452
452
|
* @returns `this`
|
|
453
453
|
*/
|
|
454
454
|
orthoNO(t, e, s, i, n, r) {
|
|
455
|
-
return
|
|
455
|
+
return q.orthoNO(this, t, e, s, i, n, r);
|
|
456
456
|
}
|
|
457
457
|
/**
|
|
458
458
|
* Generates a orthogonal projection matrix with the given bounds.
|
|
@@ -469,7 +469,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
469
469
|
* @returns `this`
|
|
470
470
|
*/
|
|
471
471
|
orthoZO(t, e, s, i, n, r) {
|
|
472
|
-
return
|
|
472
|
+
return q.orthoZO(this, t, e, s, i, n, r);
|
|
473
473
|
}
|
|
474
474
|
//================
|
|
475
475
|
// Static methods
|
|
@@ -481,7 +481,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
481
481
|
* @returns A new {@link Mat4}
|
|
482
482
|
*/
|
|
483
483
|
static create() {
|
|
484
|
-
return new
|
|
484
|
+
return new q();
|
|
485
485
|
}
|
|
486
486
|
/**
|
|
487
487
|
* Creates a new {@link Mat4} initialized with values from an existing matrix
|
|
@@ -491,7 +491,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
491
491
|
* @returns A new {@link Mat4}
|
|
492
492
|
*/
|
|
493
493
|
static clone(t) {
|
|
494
|
-
return new
|
|
494
|
+
return new q(t);
|
|
495
495
|
}
|
|
496
496
|
/**
|
|
497
497
|
* Copy the values from one {@link Mat4} to another
|
|
@@ -512,7 +512,7 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
512
512
|
* @returns A new {@link Mat4}
|
|
513
513
|
*/
|
|
514
514
|
static fromValues(...t) {
|
|
515
|
-
return new
|
|
515
|
+
return new q(...t);
|
|
516
516
|
}
|
|
517
517
|
/**
|
|
518
518
|
* Set the components of a mat4 to the given values
|
|
@@ -560,9 +560,9 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
560
560
|
* @returns `out` or `null` if the matrix is not invertable
|
|
561
561
|
*/
|
|
562
562
|
static invert(t, e) {
|
|
563
|
-
const s = e[0], i = e[1], n = e[2], r = e[3], a = e[4], c = e[5],
|
|
564
|
-
let _ = L * C - b *
|
|
565
|
-
return _ ? (_ = 1 / _, t[0] = (c * C -
|
|
563
|
+
const s = e[0], i = e[1], n = e[2], r = e[3], a = e[4], c = e[5], h = e[6], o = e[7], l = e[8], m = e[9], g = e[10], u = e[11], M = e[12], p = e[13], T = e[14], x = e[15], L = s * c - i * a, b = s * h - n * a, E = s * o - r * a, w = i * h - n * c, S = i * o - r * c, z = n * o - r * h, v = l * p - m * M, F = l * T - g * M, P = l * x - u * M, k = m * T - g * p, I = m * x - u * p, C = g * x - u * T;
|
|
564
|
+
let _ = L * C - b * I + E * k + w * P - S * F + z * v;
|
|
565
|
+
return _ ? (_ = 1 / _, t[0] = (c * C - h * I + o * k) * _, t[1] = (n * I - i * C - r * k) * _, t[2] = (p * z - T * S + x * w) * _, t[3] = (g * S - m * z - u * w) * _, t[4] = (h * P - a * C - o * F) * _, t[5] = (s * C - n * P + r * F) * _, t[6] = (T * E - M * z - x * b) * _, t[7] = (l * z - g * E + u * b) * _, t[8] = (a * I - c * P + o * v) * _, t[9] = (i * P - s * I - r * v) * _, t[10] = (M * S - p * E + x * L) * _, t[11] = (m * E - l * S - u * L) * _, t[12] = (c * F - a * k - h * v) * _, t[13] = (s * k - i * F + n * v) * _, t[14] = (p * b - M * w - T * L) * _, t[15] = (l * w - m * b + g * L) * _, t) : null;
|
|
566
566
|
}
|
|
567
567
|
/**
|
|
568
568
|
* Calculates the adjugate of a {@link Mat4}
|
|
@@ -573,8 +573,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
573
573
|
* @returns `out`
|
|
574
574
|
*/
|
|
575
575
|
static adjoint(t, e) {
|
|
576
|
-
const s = e[0], i = e[1], n = e[2], r = e[3], a = e[4], c = e[5],
|
|
577
|
-
return t[0] = c * C -
|
|
576
|
+
const s = e[0], i = e[1], n = e[2], r = e[3], a = e[4], c = e[5], h = e[6], o = e[7], l = e[8], m = e[9], g = e[10], u = e[11], M = e[12], p = e[13], T = e[14], x = e[15], L = s * c - i * a, b = s * h - n * a, E = s * o - r * a, w = i * h - n * c, S = i * o - r * c, z = n * o - r * h, v = l * p - m * M, F = l * T - g * M, P = l * x - u * M, k = m * T - g * p, I = m * x - u * p, C = g * x - u * T;
|
|
577
|
+
return t[0] = c * C - h * I + o * k, t[1] = n * I - i * C - r * k, t[2] = p * z - T * S + x * w, t[3] = g * S - m * z - u * w, t[4] = h * P - a * C - o * F, t[5] = s * C - n * P + r * F, t[6] = T * E - M * z - x * b, t[7] = l * z - g * E + u * b, t[8] = a * I - c * P + o * v, t[9] = i * P - s * I - r * v, t[10] = M * S - p * E + x * L, t[11] = m * E - l * S - u * L, t[12] = c * F - a * k - h * v, t[13] = s * k - i * F + n * v, t[14] = p * b - M * w - T * L, t[15] = l * w - m * b + g * L, t;
|
|
578
578
|
}
|
|
579
579
|
/**
|
|
580
580
|
* Calculates the determinant of a {@link Mat4}
|
|
@@ -584,8 +584,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
584
584
|
* @returns determinant of a
|
|
585
585
|
*/
|
|
586
586
|
static determinant(t) {
|
|
587
|
-
const e = t[0], s = t[1], i = t[2], n = t[3], r = t[4], a = t[5], c = t[6],
|
|
588
|
-
return
|
|
587
|
+
const e = t[0], s = t[1], i = t[2], n = t[3], r = t[4], a = t[5], c = t[6], h = t[7], o = t[8], l = t[9], m = t[10], g = t[11], u = t[12], M = t[13], p = t[14], T = t[15], x = e * a - s * r, L = e * c - i * r, b = s * c - i * a, E = o * M - l * u, w = o * p - m * u, S = l * p - m * M, z = e * S - s * w + i * E, v = r * S - a * w + c * E, F = o * b - l * L + m * x, P = u * b - M * L + p * x;
|
|
588
|
+
return h * z - n * v + T * F - g * P;
|
|
589
589
|
}
|
|
590
590
|
/**
|
|
591
591
|
* Multiplies two {@link Mat4}s
|
|
@@ -597,9 +597,9 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
597
597
|
* @returns `out`
|
|
598
598
|
*/
|
|
599
599
|
static multiply(t, e, s) {
|
|
600
|
-
const i = e[0], n = e[1], r = e[2], a = e[3], c = e[4],
|
|
600
|
+
const i = e[0], n = e[1], r = e[2], a = e[3], c = e[4], h = e[5], o = e[6], l = e[7], m = e[8], g = e[9], u = e[10], M = e[11], p = e[12], T = e[13], x = e[14], L = e[15];
|
|
601
601
|
let b = s[0], E = s[1], w = s[2], S = s[3];
|
|
602
|
-
return t[0] = b * i + E * c + w *
|
|
602
|
+
return t[0] = b * i + E * c + w * m + S * p, t[1] = b * n + E * h + w * g + S * T, t[2] = b * r + E * o + w * u + S * x, t[3] = b * a + E * l + w * M + S * L, b = s[4], E = s[5], w = s[6], S = s[7], t[4] = b * i + E * c + w * m + S * p, t[5] = b * n + E * h + w * g + S * T, t[6] = b * r + E * o + w * u + S * x, t[7] = b * a + E * l + w * M + S * L, b = s[8], E = s[9], w = s[10], S = s[11], t[8] = b * i + E * c + w * m + S * p, t[9] = b * n + E * h + w * g + S * T, t[10] = b * r + E * o + w * u + S * x, t[11] = b * a + E * l + w * M + S * L, b = s[12], E = s[13], w = s[14], S = s[15], t[12] = b * i + E * c + w * m + S * p, t[13] = b * n + E * h + w * g + S * T, t[14] = b * r + E * o + w * u + S * x, t[15] = b * a + E * l + w * M + S * L, t;
|
|
603
603
|
}
|
|
604
604
|
/**
|
|
605
605
|
* Alias for {@link Mat4.multiply}
|
|
@@ -622,8 +622,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
622
622
|
if (e === t)
|
|
623
623
|
t[12] = e[0] * i + e[4] * n + e[8] * r + e[12], t[13] = e[1] * i + e[5] * n + e[9] * r + e[13], t[14] = e[2] * i + e[6] * n + e[10] * r + e[14], t[15] = e[3] * i + e[7] * n + e[11] * r + e[15];
|
|
624
624
|
else {
|
|
625
|
-
const a = e[0], c = e[1],
|
|
626
|
-
t[0] = a, t[1] = c, t[2] =
|
|
625
|
+
const a = e[0], c = e[1], h = e[2], o = e[3], l = e[4], m = e[5], g = e[6], u = e[7], M = e[8], p = e[9], T = e[10], x = e[11];
|
|
626
|
+
t[0] = a, t[1] = c, t[2] = h, t[3] = o, t[4] = l, t[5] = m, t[6] = g, t[7] = u, t[8] = M, t[9] = p, t[10] = T, t[11] = x, t[12] = a * i + l * n + M * r + e[12], t[13] = c * i + m * n + p * r + e[13], t[14] = h * i + g * n + T * r + e[14], t[15] = o * i + u * n + x * r + e[15];
|
|
627
627
|
}
|
|
628
628
|
return t;
|
|
629
629
|
}
|
|
@@ -652,11 +652,11 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
652
652
|
*/
|
|
653
653
|
static rotate(t, e, s, i) {
|
|
654
654
|
let n = i[0], r = i[1], a = i[2], c = Math.sqrt(n * n + r * r + a * a);
|
|
655
|
-
if (c <
|
|
655
|
+
if (c < O)
|
|
656
656
|
return null;
|
|
657
657
|
c = 1 / c, n *= c, r *= c, a *= c;
|
|
658
|
-
const
|
|
659
|
-
return t[0] =
|
|
658
|
+
const h = Math.sin(s), o = Math.cos(s), l = 1 - o, m = e[0], g = e[1], u = e[2], M = e[3], p = e[4], T = e[5], x = e[6], L = e[7], b = e[8], E = e[9], w = e[10], S = e[11], z = n * n * l + o, v = r * n * l + a * h, F = a * n * l - r * h, P = n * r * l - a * h, k = r * r * l + o, I = a * r * l + n * h, C = n * a * l + r * h, _ = r * a * l - n * h, W = a * a * l + o;
|
|
659
|
+
return t[0] = m * z + p * v + b * F, t[1] = g * z + T * v + E * F, t[2] = u * z + x * v + w * F, t[3] = M * z + L * v + S * F, t[4] = m * P + p * k + b * I, t[5] = g * P + T * k + E * I, t[6] = u * P + x * k + w * I, t[7] = M * P + L * k + S * I, t[8] = m * C + p * _ + b * W, t[9] = g * C + T * _ + E * W, t[10] = u * C + x * _ + w * W, t[11] = M * C + L * _ + S * W, e !== t && (t[12] = e[12], t[13] = e[13], t[14] = e[14], t[15] = e[15]), t;
|
|
660
660
|
}
|
|
661
661
|
/**
|
|
662
662
|
* Rotates a matrix by the given angle around the X axis
|
|
@@ -668,8 +668,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
668
668
|
* @returns `out`
|
|
669
669
|
*/
|
|
670
670
|
static rotateX(t, e, s) {
|
|
671
|
-
let i = Math.sin(s), n = Math.cos(s), r = e[4], a = e[5], c = e[6],
|
|
672
|
-
return e !== t && (t[0] = e[0], t[1] = e[1], t[2] = e[2], t[3] = e[3], t[12] = e[12], t[13] = e[13], t[14] = e[14], t[15] = e[15]), t[4] = r * n +
|
|
671
|
+
let i = Math.sin(s), n = Math.cos(s), r = e[4], a = e[5], c = e[6], h = e[7], o = e[8], l = e[9], m = e[10], g = e[11];
|
|
672
|
+
return e !== t && (t[0] = e[0], t[1] = e[1], t[2] = e[2], t[3] = e[3], t[12] = e[12], t[13] = e[13], t[14] = e[14], t[15] = e[15]), t[4] = r * n + o * i, t[5] = a * n + l * i, t[6] = c * n + m * i, t[7] = h * n + g * i, t[8] = o * n - r * i, t[9] = l * n - a * i, t[10] = m * n - c * i, t[11] = g * n - h * i, t;
|
|
673
673
|
}
|
|
674
674
|
/**
|
|
675
675
|
* Rotates a matrix by the given angle around the Y axis
|
|
@@ -681,8 +681,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
681
681
|
* @returns `out`
|
|
682
682
|
*/
|
|
683
683
|
static rotateY(t, e, s) {
|
|
684
|
-
let i = Math.sin(s), n = Math.cos(s), r = e[0], a = e[1], c = e[2],
|
|
685
|
-
return e !== t && (t[4] = e[4], t[5] = e[5], t[6] = e[6], t[7] = e[7], t[12] = e[12], t[13] = e[13], t[14] = e[14], t[15] = e[15]), t[0] = r * n -
|
|
684
|
+
let i = Math.sin(s), n = Math.cos(s), r = e[0], a = e[1], c = e[2], h = e[3], o = e[8], l = e[9], m = e[10], g = e[11];
|
|
685
|
+
return e !== t && (t[4] = e[4], t[5] = e[5], t[6] = e[6], t[7] = e[7], t[12] = e[12], t[13] = e[13], t[14] = e[14], t[15] = e[15]), t[0] = r * n - o * i, t[1] = a * n - l * i, t[2] = c * n - m * i, t[3] = h * n - g * i, t[8] = r * i + o * n, t[9] = a * i + l * n, t[10] = c * i + m * n, t[11] = h * i + g * n, t;
|
|
686
686
|
}
|
|
687
687
|
/**
|
|
688
688
|
* Rotates a matrix by the given angle around the Z axis
|
|
@@ -694,8 +694,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
694
694
|
* @returns `out`
|
|
695
695
|
*/
|
|
696
696
|
static rotateZ(t, e, s) {
|
|
697
|
-
let i = Math.sin(s), n = Math.cos(s), r = e[0], a = e[1], c = e[2],
|
|
698
|
-
return e !== t && (t[8] = e[8], t[9] = e[9], t[10] = e[10], t[11] = e[11], t[12] = e[12], t[13] = e[13], t[14] = e[14], t[15] = e[15]), t[0] = r * n +
|
|
697
|
+
let i = Math.sin(s), n = Math.cos(s), r = e[0], a = e[1], c = e[2], h = e[3], o = e[4], l = e[5], m = e[6], g = e[7];
|
|
698
|
+
return e !== t && (t[8] = e[8], t[9] = e[9], t[10] = e[10], t[11] = e[11], t[12] = e[12], t[13] = e[13], t[14] = e[14], t[15] = e[15]), t[0] = r * n + o * i, t[1] = a * n + l * i, t[2] = c * n + m * i, t[3] = h * n + g * i, t[4] = o * n - r * i, t[5] = l * n - a * i, t[6] = m * n - c * i, t[7] = g * n - h * i, t;
|
|
699
699
|
}
|
|
700
700
|
/**
|
|
701
701
|
* Creates a {@link Mat4} from a vector translation
|
|
@@ -742,11 +742,11 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
742
742
|
*/
|
|
743
743
|
static fromRotation(t, e, s) {
|
|
744
744
|
let i = s[0], n = s[1], r = s[2], a = Math.sqrt(i * i + n * n + r * r);
|
|
745
|
-
if (a <
|
|
745
|
+
if (a < O)
|
|
746
746
|
return null;
|
|
747
747
|
a = 1 / a, i *= a, n *= a, r *= a;
|
|
748
|
-
const c = Math.sin(e),
|
|
749
|
-
return t[0] = i * i *
|
|
748
|
+
const c = Math.sin(e), h = Math.cos(e), o = 1 - h;
|
|
749
|
+
return t[0] = i * i * o + h, t[1] = n * i * o + r * c, t[2] = r * i * o - n * c, t[3] = 0, t[4] = i * n * o - r * c, t[5] = n * n * o + h, t[6] = r * n * o + i * c, t[7] = 0, t[8] = i * r * o + n * c, t[9] = n * r * o - i * c, t[10] = r * r * o + h, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, t;
|
|
750
750
|
}
|
|
751
751
|
/**
|
|
752
752
|
* Creates a matrix from the given angle around the X axis
|
|
@@ -813,8 +813,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
813
813
|
* @returns `out`
|
|
814
814
|
*/
|
|
815
815
|
static fromRotationTranslation(t, e, s) {
|
|
816
|
-
const i = e[0], n = e[1], r = e[2], a = e[3], c = i + i,
|
|
817
|
-
return t[0] = 1 - (u + p), t[1] =
|
|
816
|
+
const i = e[0], n = e[1], r = e[2], a = e[3], c = i + i, h = n + n, o = r + r, l = i * c, m = i * h, g = i * o, u = n * h, M = n * o, p = r * o, T = a * c, x = a * h, L = a * o;
|
|
817
|
+
return t[0] = 1 - (u + p), t[1] = m + L, t[2] = g - x, t[3] = 0, t[4] = m - L, t[5] = 1 - (l + p), t[6] = M + T, t[7] = 0, t[8] = g + x, t[9] = M - T, t[10] = 1 - (l + u), t[11] = 0, t[12] = s[0], t[13] = s[1], t[14] = s[2], t[15] = 1, t;
|
|
818
818
|
}
|
|
819
819
|
/**
|
|
820
820
|
* Sets a {@link Mat4} from a {@link Quat2}.
|
|
@@ -825,9 +825,9 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
825
825
|
* @returns `out`
|
|
826
826
|
*/
|
|
827
827
|
static fromQuat2(t, e) {
|
|
828
|
-
const s = -e[0], i = -e[1], n = -e[2], r = e[3], a = e[4], c = e[5],
|
|
828
|
+
const s = -e[0], i = -e[1], n = -e[2], r = e[3], a = e[4], c = e[5], h = e[6], o = e[7];
|
|
829
829
|
let l = s * s + i * i + n * n + r * r;
|
|
830
|
-
return l > 0 ? (V[0] = (a * r +
|
|
830
|
+
return l > 0 ? (V[0] = (a * r + o * s + c * n - h * i) * 2 / l, V[1] = (c * r + o * i + h * s - a * n) * 2 / l, V[2] = (h * r + o * n + a * i - c * s) * 2 / l) : (V[0] = (a * r + o * s + c * n - h * i) * 2, V[1] = (c * r + o * i + h * s - a * n) * 2, V[2] = (h * r + o * n + a * i - c * s) * 2), q.fromRotationTranslation(t, e, V), t;
|
|
831
831
|
}
|
|
832
832
|
/**
|
|
833
833
|
* Calculates a {@link Mat4} normal matrix (transpose inverse) from a {@link Mat4}
|
|
@@ -838,9 +838,9 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
838
838
|
* @returns `out` or `null` if the matrix is not invertable
|
|
839
839
|
*/
|
|
840
840
|
static normalFromMat4(t, e) {
|
|
841
|
-
const s = e[0], i = e[1], n = e[2], r = e[3], a = e[4], c = e[5],
|
|
842
|
-
let _ = L * C - b *
|
|
843
|
-
return _ ? (_ = 1 / _, t[0] = (c * C -
|
|
841
|
+
const s = e[0], i = e[1], n = e[2], r = e[3], a = e[4], c = e[5], h = e[6], o = e[7], l = e[8], m = e[9], g = e[10], u = e[11], M = e[12], p = e[13], T = e[14], x = e[15], L = s * c - i * a, b = s * h - n * a, E = s * o - r * a, w = i * h - n * c, S = i * o - r * c, z = n * o - r * h, v = l * p - m * M, F = l * T - g * M, P = l * x - u * M, k = m * T - g * p, I = m * x - u * p, C = g * x - u * T;
|
|
842
|
+
let _ = L * C - b * I + E * k + w * P - S * F + z * v;
|
|
843
|
+
return _ ? (_ = 1 / _, t[0] = (c * C - h * I + o * k) * _, t[1] = (h * P - a * C - o * F) * _, t[2] = (a * I - c * P + o * v) * _, t[3] = 0, t[4] = (n * I - i * C - r * k) * _, t[5] = (s * C - n * P + r * F) * _, t[6] = (i * P - s * I - r * v) * _, t[7] = 0, t[8] = (p * z - T * S + x * w) * _, t[9] = (T * E - M * z - x * b) * _, t[10] = (M * S - p * E + x * L) * _, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, t) : null;
|
|
844
844
|
}
|
|
845
845
|
/**
|
|
846
846
|
* Calculates a {@link Mat4} normal matrix (transpose inverse) from a {@link Mat4}
|
|
@@ -854,8 +854,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
854
854
|
* @returns `out`
|
|
855
855
|
*/
|
|
856
856
|
static normalFromMat4Fast(t, e) {
|
|
857
|
-
const s = e[0], i = e[1], n = e[2], r = e[4], a = e[5], c = e[6],
|
|
858
|
-
return t[0] = a * l - l *
|
|
857
|
+
const s = e[0], i = e[1], n = e[2], r = e[4], a = e[5], c = e[6], h = e[8], o = e[9], l = e[10];
|
|
858
|
+
return t[0] = a * l - l * o, t[1] = c * h - h * l, t[2] = r * o - o * h, t[3] = 0, t[4] = o * n - l * i, t[5] = l * s - h * n, t[6] = h * i - o * s, t[7] = 0, t[8] = i * c - n * a, t[9] = n * r - s * c, t[10] = s * a - i * r, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, t;
|
|
859
859
|
}
|
|
860
860
|
/**
|
|
861
861
|
* Returns the translation vector component of a transformation
|
|
@@ -884,8 +884,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
884
884
|
* @return {vec3} out
|
|
885
885
|
*/
|
|
886
886
|
static getScaling(t, e) {
|
|
887
|
-
const s = e[0], i = e[1], n = e[2], r = e[4], a = e[5], c = e[6],
|
|
888
|
-
return t[0] = Math.sqrt(s * s + i * i + n * n), t[1] = Math.sqrt(r * r + a * a + c * c), t[2] = Math.sqrt(
|
|
887
|
+
const s = e[0], i = e[1], n = e[2], r = e[4], a = e[5], c = e[6], h = e[8], o = e[9], l = e[10];
|
|
888
|
+
return t[0] = Math.sqrt(s * s + i * i + n * n), t[1] = Math.sqrt(r * r + a * a + c * c), t[2] = Math.sqrt(h * h + o * o + l * l), t;
|
|
889
889
|
}
|
|
890
890
|
/**
|
|
891
891
|
* Returns a quaternion representing the rotational component
|
|
@@ -899,10 +899,10 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
899
899
|
* @return `out`
|
|
900
900
|
*/
|
|
901
901
|
static getRotation(t, e) {
|
|
902
|
-
|
|
903
|
-
const s = 1 / V[0], i = 1 / V[1], n = 1 / V[2], r = e[0] * s, a = e[1] * i, c = e[2] * n,
|
|
902
|
+
q.getScaling(V, e);
|
|
903
|
+
const s = 1 / V[0], i = 1 / V[1], n = 1 / V[2], r = e[0] * s, a = e[1] * i, c = e[2] * n, h = e[4] * s, o = e[5] * i, l = e[6] * n, m = e[8] * s, g = e[9] * i, u = e[10] * n, M = r + o + u;
|
|
904
904
|
let p = 0;
|
|
905
|
-
return M > 0 ? (p = Math.sqrt(M + 1) * 2, t[3] = 0.25 * p, t[0] = (l - g) / p, t[1] = (
|
|
905
|
+
return M > 0 ? (p = Math.sqrt(M + 1) * 2, t[3] = 0.25 * p, t[0] = (l - g) / p, t[1] = (m - c) / p, t[2] = (a - h) / p) : r > o && r > u ? (p = Math.sqrt(1 + r - o - u) * 2, t[3] = (l - g) / p, t[0] = 0.25 * p, t[1] = (a + h) / p, t[2] = (m + c) / p) : o > u ? (p = Math.sqrt(1 + o - r - u) * 2, t[3] = (m - c) / p, t[0] = (a + h) / p, t[1] = 0.25 * p, t[2] = (l + g) / p) : (p = Math.sqrt(1 + u - r - o) * 2, t[3] = (a - h) / p, t[0] = (m + c) / p, t[1] = (l + g) / p, t[2] = 0.25 * p), t;
|
|
906
906
|
}
|
|
907
907
|
/**
|
|
908
908
|
* Decomposes a transformation matrix into its rotation, translation
|
|
@@ -917,11 +917,11 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
917
917
|
*/
|
|
918
918
|
static decompose(t, e, s, i) {
|
|
919
919
|
e[0] = i[12], e[1] = i[13], e[2] = i[14];
|
|
920
|
-
const n = i[0], r = i[1], a = i[2], c = i[4],
|
|
921
|
-
s[0] = Math.sqrt(n * n + r * r + a * a), s[1] = Math.sqrt(c * c +
|
|
922
|
-
const u = 1 / s[0], M = 1 / s[1], p = 1 / s[2], T = n * u, x = r * M, L = a * p, b = c * u, E =
|
|
923
|
-
let
|
|
924
|
-
return F > 0 ? (
|
|
920
|
+
const n = i[0], r = i[1], a = i[2], c = i[4], h = i[5], o = i[6], l = i[8], m = i[9], g = i[10];
|
|
921
|
+
s[0] = Math.sqrt(n * n + r * r + a * a), s[1] = Math.sqrt(c * c + h * h + o * o), s[2] = Math.sqrt(l * l + m * m + g * g);
|
|
922
|
+
const u = 1 / s[0], M = 1 / s[1], p = 1 / s[2], T = n * u, x = r * M, L = a * p, b = c * u, E = h * M, w = o * p, S = l * u, z = m * M, v = g * p, F = T + E + v;
|
|
923
|
+
let P = 0;
|
|
924
|
+
return F > 0 ? (P = Math.sqrt(F + 1) * 2, t[3] = 0.25 * P, t[0] = (w - z) / P, t[1] = (S - L) / P, t[2] = (x - b) / P) : T > E && T > v ? (P = Math.sqrt(1 + T - E - v) * 2, t[3] = (w - z) / P, t[0] = 0.25 * P, t[1] = (x + b) / P, t[2] = (S + L) / P) : E > v ? (P = Math.sqrt(1 + E - T - v) * 2, t[3] = (S - L) / P, t[0] = (x + b) / P, t[1] = 0.25 * P, t[2] = (w + z) / P) : (P = Math.sqrt(1 + v - T - E) * 2, t[3] = (x - b) / P, t[0] = (S + L) / P, t[1] = (w + z) / P, t[2] = 0.25 * P), t;
|
|
925
925
|
}
|
|
926
926
|
/**
|
|
927
927
|
* Creates a matrix from a quaternion rotation, vector translation and vector scale
|
|
@@ -942,8 +942,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
942
942
|
* @returns `out`
|
|
943
943
|
*/
|
|
944
944
|
static fromRotationTranslationScale(t, e, s, i) {
|
|
945
|
-
const n = e[0], r = e[1], a = e[2], c = e[3],
|
|
946
|
-
return t[0] = (1 - (M + T)) * E, t[1] = (g + b) * E, t[2] = (u - L) * E, t[3] = 0, t[4] = (g - b) * w, t[5] = (1 - (
|
|
945
|
+
const n = e[0], r = e[1], a = e[2], c = e[3], h = n + n, o = r + r, l = a + a, m = n * h, g = n * o, u = n * l, M = r * o, p = r * l, T = a * l, x = c * h, L = c * o, b = c * l, E = i[0], w = i[1], S = i[2];
|
|
946
|
+
return t[0] = (1 - (M + T)) * E, t[1] = (g + b) * E, t[2] = (u - L) * E, t[3] = 0, t[4] = (g - b) * w, t[5] = (1 - (m + T)) * w, t[6] = (p + x) * w, t[7] = 0, t[8] = (u + L) * S, t[9] = (p - x) * S, t[10] = (1 - (m + M)) * S, t[11] = 0, t[12] = s[0], t[13] = s[1], t[14] = s[2], t[15] = 1, t;
|
|
947
947
|
}
|
|
948
948
|
/**
|
|
949
949
|
* Creates a matrix from a quaternion rotation, vector translation and vector scale, rotating and scaling around the given origin
|
|
@@ -967,8 +967,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
967
967
|
* @returns `out`
|
|
968
968
|
*/
|
|
969
969
|
static fromRotationTranslationScaleOrigin(t, e, s, i, n) {
|
|
970
|
-
const r = e[0], a = e[1], c = e[2],
|
|
971
|
-
return t[0] =
|
|
970
|
+
const r = e[0], a = e[1], c = e[2], h = e[3], o = r + r, l = a + a, m = c + c, g = r * o, u = r * l, M = r * m, p = a * l, T = a * m, x = c * m, L = h * o, b = h * l, E = h * m, w = i[0], S = i[1], z = i[2], v = n[0], F = n[1], P = n[2], k = (1 - (p + x)) * w, I = (u + E) * w, C = (M - b) * w, _ = (u - E) * S, W = (1 - (g + x)) * S, at = (T + L) * S, ct = (M + b) * z, Ct = (T - L) * z, Bt = (1 - (g + p)) * z;
|
|
971
|
+
return t[0] = k, t[1] = I, t[2] = C, t[3] = 0, t[4] = _, t[5] = W, t[6] = at, t[7] = 0, t[8] = ct, t[9] = Ct, t[10] = Bt, t[11] = 0, t[12] = s[0] + v - (k * v + _ * F + ct * P), t[13] = s[1] + F - (I * v + W * F + Ct * P), t[14] = s[2] + P - (C * v + at * F + Bt * P), t[15] = 1, t;
|
|
972
972
|
}
|
|
973
973
|
/**
|
|
974
974
|
* Calculates a 4x4 matrix from the given quaternion
|
|
@@ -979,8 +979,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
979
979
|
* @returns `out`
|
|
980
980
|
*/
|
|
981
981
|
static fromQuat(t, e) {
|
|
982
|
-
const s = e[0], i = e[1], n = e[2], r = e[3], a = s + s, c = i + i,
|
|
983
|
-
return t[0] = 1 -
|
|
982
|
+
const s = e[0], i = e[1], n = e[2], r = e[3], a = s + s, c = i + i, h = n + n, o = s * a, l = i * a, m = i * c, g = n * a, u = n * c, M = n * h, p = r * a, T = r * c, x = r * h;
|
|
983
|
+
return t[0] = 1 - m - M, t[1] = l + x, t[2] = g - T, t[3] = 0, t[4] = l - x, t[5] = 1 - o - M, t[6] = u + p, t[7] = 0, t[8] = g + T, t[9] = u - p, t[10] = 1 - o - m, t[11] = 0, t[12] = 0, t[13] = 0, t[14] = 0, t[15] = 1, t;
|
|
984
984
|
}
|
|
985
985
|
/**
|
|
986
986
|
* Generates a frustum matrix with the given bounds
|
|
@@ -999,10 +999,10 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
999
999
|
* @returns `out`
|
|
1000
1000
|
*/
|
|
1001
1001
|
static frustumNO(t, e, s, i, n, r, a = 1 / 0) {
|
|
1002
|
-
const c = 1 / (s - e),
|
|
1003
|
-
if (t[0] = r * 2 * c, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = r * 2 *
|
|
1004
|
-
const
|
|
1005
|
-
t[10] = (a + r) *
|
|
1002
|
+
const c = 1 / (s - e), h = 1 / (n - i);
|
|
1003
|
+
if (t[0] = r * 2 * c, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = r * 2 * h, t[6] = 0, t[7] = 0, t[8] = (s + e) * c, t[9] = (n + i) * h, t[11] = -1, t[12] = 0, t[13] = 0, t[15] = 0, a != null && a !== 1 / 0) {
|
|
1004
|
+
const o = 1 / (r - a);
|
|
1005
|
+
t[10] = (a + r) * o, t[14] = 2 * a * r * o;
|
|
1006
1006
|
} else
|
|
1007
1007
|
t[10] = -1, t[14] = -2 * r;
|
|
1008
1008
|
return t;
|
|
@@ -1032,10 +1032,10 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
1032
1032
|
* @returns `out`
|
|
1033
1033
|
*/
|
|
1034
1034
|
static frustumZO(t, e, s, i, n, r, a = 1 / 0) {
|
|
1035
|
-
const c = 1 / (s - e),
|
|
1036
|
-
if (t[0] = r * 2 * c, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = r * 2 *
|
|
1037
|
-
const
|
|
1038
|
-
t[10] = a *
|
|
1035
|
+
const c = 1 / (s - e), h = 1 / (n - i);
|
|
1036
|
+
if (t[0] = r * 2 * c, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = r * 2 * h, t[6] = 0, t[7] = 0, t[8] = (s + e) * c, t[9] = (n + i) * h, t[11] = -1, t[12] = 0, t[13] = 0, t[15] = 0, a != null && a !== 1 / 0) {
|
|
1037
|
+
const o = 1 / (r - a);
|
|
1038
|
+
t[10] = a * o, t[14] = a * r * o;
|
|
1039
1039
|
} else
|
|
1040
1040
|
t[10] = -1, t[14] = -r;
|
|
1041
1041
|
return t;
|
|
@@ -1108,8 +1108,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
1108
1108
|
* @deprecated
|
|
1109
1109
|
*/
|
|
1110
1110
|
static perspectiveFromFieldOfView(t, e, s, i) {
|
|
1111
|
-
const n = Math.tan(e.upDegrees * Math.PI / 180), r = Math.tan(e.downDegrees * Math.PI / 180), a = Math.tan(e.leftDegrees * Math.PI / 180), c = Math.tan(e.rightDegrees * Math.PI / 180),
|
|
1112
|
-
return t[0] =
|
|
1111
|
+
const n = Math.tan(e.upDegrees * Math.PI / 180), r = Math.tan(e.downDegrees * Math.PI / 180), a = Math.tan(e.leftDegrees * Math.PI / 180), c = Math.tan(e.rightDegrees * Math.PI / 180), h = 2 / (a + c), o = 2 / (n + r);
|
|
1112
|
+
return t[0] = h, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = o, t[6] = 0, t[7] = 0, t[8] = -((a - c) * h * 0.5), t[9] = (n - r) * o * 0.5, t[10] = i / (s - i), t[11] = -1, t[12] = 0, t[13] = 0, t[14] = i * s / (s - i), t[15] = 0, t;
|
|
1113
1113
|
}
|
|
1114
1114
|
/**
|
|
1115
1115
|
* Generates a orthogonal projection matrix with the given bounds.
|
|
@@ -1127,8 +1127,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
1127
1127
|
* @returns `out`
|
|
1128
1128
|
*/
|
|
1129
1129
|
static orthoNO(t, e, s, i, n, r, a) {
|
|
1130
|
-
const c = 1 / (e - s),
|
|
1131
|
-
return t[0] = -2 * c, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = -2 *
|
|
1130
|
+
const c = 1 / (e - s), h = 1 / (i - n), o = 1 / (r - a);
|
|
1131
|
+
return t[0] = -2 * c, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = -2 * h, t[6] = 0, t[7] = 0, t[8] = 0, t[9] = 0, t[10] = 2 * o, t[11] = 0, t[12] = (e + s) * c, t[13] = (n + i) * h, t[14] = (a + r) * o, t[15] = 1, t;
|
|
1132
1132
|
}
|
|
1133
1133
|
/**
|
|
1134
1134
|
* Alias for {@link Mat4.orthoNO}
|
|
@@ -1154,8 +1154,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
1154
1154
|
* @returns `out`
|
|
1155
1155
|
*/
|
|
1156
1156
|
static orthoZO(t, e, s, i, n, r, a) {
|
|
1157
|
-
const c = 1 / (e - s),
|
|
1158
|
-
return t[0] = -2 * c, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = -2 *
|
|
1157
|
+
const c = 1 / (e - s), h = 1 / (i - n), o = 1 / (r - a);
|
|
1158
|
+
return t[0] = -2 * c, t[1] = 0, t[2] = 0, t[3] = 0, t[4] = 0, t[5] = -2 * h, t[6] = 0, t[7] = 0, t[8] = 0, t[9] = 0, t[10] = o, t[11] = 0, t[12] = (e + s) * c, t[13] = (n + i) * h, t[14] = r * o, t[15] = 1, t;
|
|
1159
1159
|
}
|
|
1160
1160
|
/**
|
|
1161
1161
|
* Generates a look-at matrix with the given eye position, focal point, and up axis.
|
|
@@ -1169,12 +1169,12 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
1169
1169
|
* @returns `out`
|
|
1170
1170
|
*/
|
|
1171
1171
|
static lookAt(t, e, s, i) {
|
|
1172
|
-
const n = e[0], r = e[1], a = e[2], c = i[0],
|
|
1173
|
-
if (Math.abs(n - l) <
|
|
1174
|
-
return
|
|
1175
|
-
let u = n - l, M = r -
|
|
1172
|
+
const n = e[0], r = e[1], a = e[2], c = i[0], h = i[1], o = i[2], l = s[0], m = s[1], g = s[2];
|
|
1173
|
+
if (Math.abs(n - l) < O && Math.abs(r - m) < O && Math.abs(a - g) < O)
|
|
1174
|
+
return q.identity(t);
|
|
1175
|
+
let u = n - l, M = r - m, p = a - g, T = 1 / Math.sqrt(u * u + M * M + p * p);
|
|
1176
1176
|
u *= T, M *= T, p *= T;
|
|
1177
|
-
let x =
|
|
1177
|
+
let x = h * p - o * M, L = o * u - c * p, b = c * M - h * u;
|
|
1178
1178
|
T = Math.sqrt(x * x + L * L + b * b), T ? (T = 1 / T, x *= T, L *= T, b *= T) : (x = 0, L = 0, b = 0);
|
|
1179
1179
|
let E = M * b - p * L, w = p * x - u * b, S = u * L - M * x;
|
|
1180
1180
|
return T = Math.sqrt(E * E + w * w + S * S), T ? (T = 1 / T, E *= T, w *= T, S *= T) : (E = 0, w = 0, S = 0), t[0] = x, t[1] = E, t[2] = u, t[3] = 0, t[4] = L, t[5] = w, t[6] = M, t[7] = 0, t[8] = b, t[9] = S, t[10] = p, t[11] = 0, t[12] = -(x * n + L * r + b * a), t[13] = -(E * n + w * r + S * a), t[14] = -(u * n + M * r + p * a), t[15] = 1, t;
|
|
@@ -1190,11 +1190,11 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
1190
1190
|
* @returns `out`
|
|
1191
1191
|
*/
|
|
1192
1192
|
static targetTo(t, e, s, i) {
|
|
1193
|
-
const n = e[0], r = e[1], a = e[2], c = i[0],
|
|
1194
|
-
let l = n - s[0],
|
|
1195
|
-
u > 0 && (u = 1 / Math.sqrt(u), l *= u,
|
|
1196
|
-
let M =
|
|
1197
|
-
return u = M * M + p * p + T * T, u > 0 && (u = 1 / Math.sqrt(u), M *= u, p *= u, T *= u), t[0] = M, t[1] = p, t[2] = T, t[3] = 0, t[4] =
|
|
1193
|
+
const n = e[0], r = e[1], a = e[2], c = i[0], h = i[1], o = i[2];
|
|
1194
|
+
let l = n - s[0], m = r - s[1], g = a - s[2], u = l * l + m * m + g * g;
|
|
1195
|
+
u > 0 && (u = 1 / Math.sqrt(u), l *= u, m *= u, g *= u);
|
|
1196
|
+
let M = h * g - o * m, p = o * l - c * g, T = c * m - h * l;
|
|
1197
|
+
return u = M * M + p * p + T * T, u > 0 && (u = 1 / Math.sqrt(u), M *= u, p *= u, T *= u), t[0] = M, t[1] = p, t[2] = T, t[3] = 0, t[4] = m * T - g * p, t[5] = g * M - l * T, t[6] = l * p - m * M, t[7] = 0, t[8] = l, t[9] = m, t[10] = g, t[11] = 0, t[12] = n, t[13] = r, t[14] = a, t[15] = 1, t;
|
|
1198
1198
|
}
|
|
1199
1199
|
/**
|
|
1200
1200
|
* Returns Frobenius norm of a {@link Mat4}
|
|
@@ -1282,8 +1282,8 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
1282
1282
|
* @returns True if the matrices are equal, false otherwise.
|
|
1283
1283
|
*/
|
|
1284
1284
|
static equals(t, e) {
|
|
1285
|
-
const s = t[0], i = t[1], n = t[2], r = t[3], a = t[4], c = t[5],
|
|
1286
|
-
return Math.abs(s - L) <=
|
|
1285
|
+
const s = t[0], i = t[1], n = t[2], r = t[3], a = t[4], c = t[5], h = t[6], o = t[7], l = t[8], m = t[9], g = t[10], u = t[11], M = t[12], p = t[13], T = t[14], x = t[15], L = e[0], b = e[1], E = e[2], w = e[3], S = e[4], z = e[5], v = e[6], F = e[7], P = e[8], k = e[9], I = e[10], C = e[11], _ = e[12], W = e[13], at = e[14], ct = e[15];
|
|
1286
|
+
return Math.abs(s - L) <= O * Math.max(1, Math.abs(s), Math.abs(L)) && Math.abs(i - b) <= O * Math.max(1, Math.abs(i), Math.abs(b)) && Math.abs(n - E) <= O * Math.max(1, Math.abs(n), Math.abs(E)) && Math.abs(r - w) <= O * Math.max(1, Math.abs(r), Math.abs(w)) && Math.abs(a - S) <= O * Math.max(1, Math.abs(a), Math.abs(S)) && Math.abs(c - z) <= O * Math.max(1, Math.abs(c), Math.abs(z)) && Math.abs(h - v) <= O * Math.max(1, Math.abs(h), Math.abs(v)) && Math.abs(o - F) <= O * Math.max(1, Math.abs(o), Math.abs(F)) && Math.abs(l - P) <= O * Math.max(1, Math.abs(l), Math.abs(P)) && Math.abs(m - k) <= O * Math.max(1, Math.abs(m), Math.abs(k)) && Math.abs(g - I) <= O * Math.max(1, Math.abs(g), Math.abs(I)) && Math.abs(u - C) <= O * Math.max(1, Math.abs(u), Math.abs(C)) && Math.abs(M - _) <= O * Math.max(1, Math.abs(M), Math.abs(_)) && Math.abs(p - W) <= O * Math.max(1, Math.abs(p), Math.abs(W)) && Math.abs(T - at) <= O * Math.max(1, Math.abs(T), Math.abs(at)) && Math.abs(x - ct) <= O * Math.max(1, Math.abs(x), Math.abs(ct));
|
|
1287
1287
|
}
|
|
1288
1288
|
/**
|
|
1289
1289
|
* Returns a string representation of a {@link Mat4}
|
|
@@ -1299,15 +1299,15 @@ const q = 1e-6, zt = new Float32Array([
|
|
|
1299
1299
|
/**
|
|
1300
1300
|
* The number of bytes in a {@link Mat4}.
|
|
1301
1301
|
*/
|
|
1302
|
-
|
|
1303
|
-
let
|
|
1302
|
+
f(q, "BYTE_LENGTH", 16 * Float32Array.BYTES_PER_ELEMENT);
|
|
1303
|
+
let A = q;
|
|
1304
1304
|
const V = new Float32Array(3);
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1305
|
+
A.prototype.mul = A.prototype.multiply;
|
|
1306
|
+
A.sub = A.subtract;
|
|
1307
|
+
A.mul = A.multiply;
|
|
1308
|
+
A.frustum = A.frustumNO;
|
|
1309
|
+
A.perspective = A.perspectiveNO;
|
|
1310
|
+
A.ortho = A.orthoNO;
|
|
1311
1311
|
const U = class U extends Float32Array {
|
|
1312
1312
|
/**
|
|
1313
1313
|
* Create a {@link Vec3}.
|
|
@@ -1974,8 +1974,8 @@ const U = class U extends Float32Array {
|
|
|
1974
1974
|
* @returns `out`
|
|
1975
1975
|
*/
|
|
1976
1976
|
static cross(t, e, s) {
|
|
1977
|
-
const i = e[0], n = e[1], r = e[2], a = s[0], c = s[1],
|
|
1978
|
-
return t[0] = n *
|
|
1977
|
+
const i = e[0], n = e[1], r = e[2], a = s[0], c = s[1], h = s[2];
|
|
1978
|
+
return t[0] = n * h - r * c, t[1] = r * a - i * h, t[2] = i * c - n * a, t;
|
|
1979
1979
|
}
|
|
1980
1980
|
/**
|
|
1981
1981
|
* Performs a linear interpolation between two vec3's
|
|
@@ -2018,8 +2018,8 @@ const U = class U extends Float32Array {
|
|
|
2018
2018
|
* @returns `out`
|
|
2019
2019
|
*/
|
|
2020
2020
|
static hermite(t, e, s, i, n, r) {
|
|
2021
|
-
const a = r * r, c = a * (2 * r - 3) + 1,
|
|
2022
|
-
return t[0] = e[0] * c + s[0] *
|
|
2021
|
+
const a = r * r, c = a * (2 * r - 3) + 1, h = a * (r - 2) + r, o = a * (r - 1), l = a * (3 - 2 * r);
|
|
2022
|
+
return t[0] = e[0] * c + s[0] * h + i[0] * o + n[0] * l, t[1] = e[1] * c + s[1] * h + i[1] * o + n[1] * l, t[2] = e[2] * c + s[2] * h + i[2] * o + n[2] * l, t;
|
|
2023
2023
|
}
|
|
2024
2024
|
/**
|
|
2025
2025
|
* Performs a bezier interpolation with two control points
|
|
@@ -2034,8 +2034,8 @@ const U = class U extends Float32Array {
|
|
|
2034
2034
|
* @returns `out`
|
|
2035
2035
|
*/
|
|
2036
2036
|
static bezier(t, e, s, i, n, r) {
|
|
2037
|
-
const a = 1 - r, c = a * a,
|
|
2038
|
-
return t[0] = e[0] *
|
|
2037
|
+
const a = 1 - r, c = a * a, h = r * r, o = c * a, l = 3 * r * c, m = 3 * h * a, g = h * r;
|
|
2038
|
+
return t[0] = e[0] * o + s[0] * l + i[0] * m + n[0] * g, t[1] = e[1] * o + s[1] * l + i[1] * m + n[1] * g, t[2] = e[2] * o + s[2] * l + i[2] * m + n[2] * g, t;
|
|
2039
2039
|
}
|
|
2040
2040
|
/**
|
|
2041
2041
|
* Generates a random vector with the given scale
|
|
@@ -2095,8 +2095,8 @@ const U = class U extends Float32Array {
|
|
|
2095
2095
|
* @returns `out`
|
|
2096
2096
|
*/
|
|
2097
2097
|
static transformQuat(t, e, s) {
|
|
2098
|
-
const i = s[0], n = s[1], r = s[2], a = s[3] * 2, c = e[0],
|
|
2099
|
-
return t[0] = c + l * a + u, t[1] =
|
|
2098
|
+
const i = s[0], n = s[1], r = s[2], a = s[3] * 2, c = e[0], h = e[1], o = e[2], l = n * o - r * h, m = r * c - i * o, g = i * h - n * c, u = (n * g - r * m) * 2, M = (r * l - i * g) * 2, p = (i * m - n * l) * 2;
|
|
2099
|
+
return t[0] = c + l * a + u, t[1] = h + m * a + M, t[2] = o + g * a + p, t;
|
|
2100
2100
|
}
|
|
2101
2101
|
/**
|
|
2102
2102
|
* Rotate a 3D vector around the x-axis
|
|
@@ -2141,8 +2141,8 @@ const U = class U extends Float32Array {
|
|
|
2141
2141
|
* @returns The angle in radians
|
|
2142
2142
|
*/
|
|
2143
2143
|
static angle(t, e) {
|
|
2144
|
-
const s = t[0], i = t[1], n = t[2], r = e[0], a = e[1], c = e[2],
|
|
2145
|
-
return Math.acos(Math.min(Math.max(
|
|
2144
|
+
const s = t[0], i = t[1], n = t[2], r = e[0], a = e[1], c = e[2], h = Math.sqrt((s * s + i * i + n * n) * (r * r + a * a + c * c)), o = h && U.dot(t, e) / h;
|
|
2145
|
+
return Math.acos(Math.min(Math.max(o, -1), 1));
|
|
2146
2146
|
}
|
|
2147
2147
|
/**
|
|
2148
2148
|
* Set the components of a vec3 to zero
|
|
@@ -2185,13 +2185,13 @@ const U = class U extends Float32Array {
|
|
|
2185
2185
|
*/
|
|
2186
2186
|
static equals(t, e) {
|
|
2187
2187
|
const s = t[0], i = t[1], n = t[2], r = e[0], a = e[1], c = e[2];
|
|
2188
|
-
return Math.abs(s - r) <=
|
|
2188
|
+
return Math.abs(s - r) <= O * Math.max(1, Math.abs(s), Math.abs(r)) && Math.abs(i - a) <= O * Math.max(1, Math.abs(i), Math.abs(a)) && Math.abs(n - c) <= O * Math.max(1, Math.abs(n), Math.abs(c));
|
|
2189
2189
|
}
|
|
2190
2190
|
};
|
|
2191
2191
|
/**
|
|
2192
2192
|
* The number of bytes in a {@link Vec3}.
|
|
2193
2193
|
*/
|
|
2194
|
-
|
|
2194
|
+
f(U, "BYTE_LENGTH", 3 * Float32Array.BYTES_PER_ELEMENT);
|
|
2195
2195
|
let B = U;
|
|
2196
2196
|
B.prototype.sub = B.prototype.subtract;
|
|
2197
2197
|
B.prototype.mul = B.prototype.multiply;
|
|
@@ -2207,7 +2207,7 @@ B.sqrLen = B.squaredLength;
|
|
|
2207
2207
|
B.mag = B.magnitude;
|
|
2208
2208
|
B.length = B.magnitude;
|
|
2209
2209
|
B.len = B.magnitude;
|
|
2210
|
-
const
|
|
2210
|
+
const H = class H extends Float32Array {
|
|
2211
2211
|
/**
|
|
2212
2212
|
* Create a {@link Vec4}.
|
|
2213
2213
|
*/
|
|
@@ -2338,7 +2338,7 @@ const $ = class $ extends Float32Array {
|
|
|
2338
2338
|
* Equivalent to `Vec4.str(this);`
|
|
2339
2339
|
*/
|
|
2340
2340
|
get str() {
|
|
2341
|
-
return
|
|
2341
|
+
return H.str(this);
|
|
2342
2342
|
}
|
|
2343
2343
|
//===================
|
|
2344
2344
|
// Instances methods
|
|
@@ -2439,7 +2439,7 @@ const $ = class $ extends Float32Array {
|
|
|
2439
2439
|
* @returns Distance between `this` and `b`
|
|
2440
2440
|
*/
|
|
2441
2441
|
distance(t) {
|
|
2442
|
-
return
|
|
2442
|
+
return H.distance(this, t);
|
|
2443
2443
|
}
|
|
2444
2444
|
/**
|
|
2445
2445
|
* Alias for {@link Vec4.distance}
|
|
@@ -2455,7 +2455,7 @@ const $ = class $ extends Float32Array {
|
|
|
2455
2455
|
* @returns Squared distance between `this` and `b`
|
|
2456
2456
|
*/
|
|
2457
2457
|
squaredDistance(t) {
|
|
2458
|
-
return
|
|
2458
|
+
return H.squaredDistance(this, t);
|
|
2459
2459
|
}
|
|
2460
2460
|
/**
|
|
2461
2461
|
* Alias for {@link Vec4.squaredDistance}
|
|
@@ -2507,7 +2507,7 @@ const $ = class $ extends Float32Array {
|
|
|
2507
2507
|
* @returns `this`
|
|
2508
2508
|
*/
|
|
2509
2509
|
normalize() {
|
|
2510
|
-
return
|
|
2510
|
+
return H.normalize(this, this);
|
|
2511
2511
|
}
|
|
2512
2512
|
//===================
|
|
2513
2513
|
// Static methods
|
|
@@ -2519,7 +2519,7 @@ const $ = class $ extends Float32Array {
|
|
|
2519
2519
|
* @returns a new 4D vector
|
|
2520
2520
|
*/
|
|
2521
2521
|
static create() {
|
|
2522
|
-
return new
|
|
2522
|
+
return new H();
|
|
2523
2523
|
}
|
|
2524
2524
|
/**
|
|
2525
2525
|
* Creates a new {@link Vec4} initialized with values from an existing vector
|
|
@@ -2529,7 +2529,7 @@ const $ = class $ extends Float32Array {
|
|
|
2529
2529
|
* @returns a new 4D vector
|
|
2530
2530
|
*/
|
|
2531
2531
|
static clone(t) {
|
|
2532
|
-
return new
|
|
2532
|
+
return new H(t);
|
|
2533
2533
|
}
|
|
2534
2534
|
/**
|
|
2535
2535
|
* Creates a new {@link Vec4} initialized with the given values
|
|
@@ -2542,7 +2542,7 @@ const $ = class $ extends Float32Array {
|
|
|
2542
2542
|
* @returns a new 4D vector
|
|
2543
2543
|
*/
|
|
2544
2544
|
static fromValues(t, e, s, i) {
|
|
2545
|
-
return new
|
|
2545
|
+
return new H(t, e, s, i);
|
|
2546
2546
|
}
|
|
2547
2547
|
/**
|
|
2548
2548
|
* Copy the values from one {@link Vec4} to another
|
|
@@ -2879,8 +2879,8 @@ const $ = class $ extends Float32Array {
|
|
|
2879
2879
|
* @returns result
|
|
2880
2880
|
*/
|
|
2881
2881
|
static cross(t, e, s, i) {
|
|
2882
|
-
const n = s[0] * i[1] - s[1] * i[0], r = s[0] * i[2] - s[2] * i[0], a = s[0] * i[3] - s[3] * i[0], c = s[1] * i[2] - s[2] * i[1],
|
|
2883
|
-
return t[0] =
|
|
2882
|
+
const n = s[0] * i[1] - s[1] * i[0], r = s[0] * i[2] - s[2] * i[0], a = s[0] * i[3] - s[3] * i[0], c = s[1] * i[2] - s[2] * i[1], h = s[1] * i[3] - s[3] * i[1], o = s[2] * i[3] - s[3] * i[2], l = e[0], m = e[1], g = e[2], u = e[3];
|
|
2883
|
+
return t[0] = m * o - g * h + u * c, t[1] = -(l * o) + g * a - u * r, t[2] = l * h - m * a + u * n, t[3] = -(l * c) + m * r - g * n, t;
|
|
2884
2884
|
}
|
|
2885
2885
|
/**
|
|
2886
2886
|
* Performs a linear interpolation between two {@link Vec4}'s
|
|
@@ -2953,8 +2953,8 @@ const $ = class $ extends Float32Array {
|
|
|
2953
2953
|
* @returns `out`
|
|
2954
2954
|
*/
|
|
2955
2955
|
static transformQuat(t, e, s) {
|
|
2956
|
-
const i = e[0], n = e[1], r = e[2], a = s[0], c = s[1],
|
|
2957
|
-
return t[0] = l *
|
|
2956
|
+
const i = e[0], n = e[1], r = e[2], a = s[0], c = s[1], h = s[2], o = s[3], l = o * i + c * r - h * n, m = o * n + h * i - a * r, g = o * r + a * n - c * i, u = -a * i - c * n - h * r;
|
|
2957
|
+
return t[0] = l * o + u * -a + m * -h - g * -c, t[1] = m * o + u * -c + g * -a - l * -h, t[2] = g * o + u * -h + l * -c - m * -a, t[3] = e[3], t;
|
|
2958
2958
|
}
|
|
2959
2959
|
/**
|
|
2960
2960
|
* Set the components of a {@link Vec4} to zero
|
|
@@ -2996,15 +2996,15 @@ const $ = class $ extends Float32Array {
|
|
|
2996
2996
|
* @returns True if the vectors are equal, false otherwise.
|
|
2997
2997
|
*/
|
|
2998
2998
|
static equals(t, e) {
|
|
2999
|
-
const s = t[0], i = t[1], n = t[2], r = t[3], a = e[0], c = e[1],
|
|
3000
|
-
return Math.abs(s - a) <=
|
|
2999
|
+
const s = t[0], i = t[1], n = t[2], r = t[3], a = e[0], c = e[1], h = e[2], o = e[3];
|
|
3000
|
+
return Math.abs(s - a) <= O * Math.max(1, Math.abs(s), Math.abs(a)) && Math.abs(i - c) <= O * Math.max(1, Math.abs(i), Math.abs(c)) && Math.abs(n - h) <= O * Math.max(1, Math.abs(n), Math.abs(h)) && Math.abs(r - o) <= O * Math.max(1, Math.abs(r), Math.abs(o));
|
|
3001
3001
|
}
|
|
3002
3002
|
};
|
|
3003
3003
|
/**
|
|
3004
3004
|
* The number of bytes in a {@link Vec4}.
|
|
3005
3005
|
*/
|
|
3006
|
-
|
|
3007
|
-
let D =
|
|
3006
|
+
f(H, "BYTE_LENGTH", 4 * Float32Array.BYTES_PER_ELEMENT);
|
|
3007
|
+
let D = H;
|
|
3008
3008
|
D.prototype.sub = D.prototype.subtract;
|
|
3009
3009
|
D.prototype.mul = D.prototype.multiply;
|
|
3010
3010
|
D.prototype.div = D.prototype.divide;
|
|
@@ -3019,7 +3019,7 @@ D.sqrLen = D.squaredLength;
|
|
|
3019
3019
|
D.mag = D.magnitude;
|
|
3020
3020
|
D.length = D.magnitude;
|
|
3021
3021
|
D.len = D.magnitude;
|
|
3022
|
-
const
|
|
3022
|
+
const $ = class $ extends Float32Array {
|
|
3023
3023
|
/**
|
|
3024
3024
|
* Create a {@link Vec2}.
|
|
3025
3025
|
*/
|
|
@@ -3122,7 +3122,7 @@ const H = class H extends Float32Array {
|
|
|
3122
3122
|
* Equivalent to `Vec2.str(this);`
|
|
3123
3123
|
*/
|
|
3124
3124
|
get str() {
|
|
3125
|
-
return
|
|
3125
|
+
return $.str(this);
|
|
3126
3126
|
}
|
|
3127
3127
|
//===================
|
|
3128
3128
|
// Instances methods
|
|
@@ -3224,7 +3224,7 @@ const H = class H extends Float32Array {
|
|
|
3224
3224
|
* @returns Distance between `this` and `b`
|
|
3225
3225
|
*/
|
|
3226
3226
|
distance(t) {
|
|
3227
|
-
return
|
|
3227
|
+
return $.distance(this, t);
|
|
3228
3228
|
}
|
|
3229
3229
|
/**
|
|
3230
3230
|
* Alias for {@link Vec2.distance}
|
|
@@ -3240,7 +3240,7 @@ const H = class H extends Float32Array {
|
|
|
3240
3240
|
* @returns Squared distance between `this` and `b`
|
|
3241
3241
|
*/
|
|
3242
3242
|
squaredDistance(t) {
|
|
3243
|
-
return
|
|
3243
|
+
return $.squaredDistance(this, t);
|
|
3244
3244
|
}
|
|
3245
3245
|
/**
|
|
3246
3246
|
* Alias for {@link Vec2.squaredDistance}
|
|
@@ -3292,7 +3292,7 @@ const H = class H extends Float32Array {
|
|
|
3292
3292
|
* @returns `this`
|
|
3293
3293
|
*/
|
|
3294
3294
|
normalize() {
|
|
3295
|
-
return
|
|
3295
|
+
return $.normalize(this, this);
|
|
3296
3296
|
}
|
|
3297
3297
|
//================
|
|
3298
3298
|
// Static methods
|
|
@@ -3304,7 +3304,7 @@ const H = class H extends Float32Array {
|
|
|
3304
3304
|
* @returns A new 2D vector
|
|
3305
3305
|
*/
|
|
3306
3306
|
static create() {
|
|
3307
|
-
return new
|
|
3307
|
+
return new $();
|
|
3308
3308
|
}
|
|
3309
3309
|
/**
|
|
3310
3310
|
* Creates a new {@link Vec2} initialized with values from an existing vector
|
|
@@ -3314,7 +3314,7 @@ const H = class H extends Float32Array {
|
|
|
3314
3314
|
* @returns A new 2D vector
|
|
3315
3315
|
*/
|
|
3316
3316
|
static clone(t) {
|
|
3317
|
-
return new
|
|
3317
|
+
return new $(t);
|
|
3318
3318
|
}
|
|
3319
3319
|
/**
|
|
3320
3320
|
* Creates a new {@link Vec2} initialized with the given values
|
|
@@ -3325,7 +3325,7 @@ const H = class H extends Float32Array {
|
|
|
3325
3325
|
* @returns A new 2D vector
|
|
3326
3326
|
*/
|
|
3327
3327
|
static fromValues(t, e) {
|
|
3328
|
-
return new
|
|
3328
|
+
return new $(t, e);
|
|
3329
3329
|
}
|
|
3330
3330
|
/**
|
|
3331
3331
|
* Copy the values from one {@link Vec2} to another
|
|
@@ -3787,7 +3787,7 @@ const H = class H extends Float32Array {
|
|
|
3787
3787
|
*/
|
|
3788
3788
|
static equals(t, e) {
|
|
3789
3789
|
const s = t[0], i = t[1], n = e[0], r = e[1];
|
|
3790
|
-
return Math.abs(s - n) <=
|
|
3790
|
+
return Math.abs(s - n) <= O * Math.max(1, Math.abs(s), Math.abs(n)) && Math.abs(i - r) <= O * Math.max(1, Math.abs(i), Math.abs(r));
|
|
3791
3791
|
}
|
|
3792
3792
|
/**
|
|
3793
3793
|
* Returns a string representation of a vector
|
|
@@ -3803,8 +3803,8 @@ const H = class H extends Float32Array {
|
|
|
3803
3803
|
/**
|
|
3804
3804
|
* The number of bytes in a {@link Vec2}.
|
|
3805
3805
|
*/
|
|
3806
|
-
|
|
3807
|
-
let R =
|
|
3806
|
+
f($, "BYTE_LENGTH", 2 * Float32Array.BYTES_PER_ELEMENT);
|
|
3807
|
+
let R = $;
|
|
3808
3808
|
R.prototype.sub = R.prototype.subtract;
|
|
3809
3809
|
R.prototype.mul = R.prototype.multiply;
|
|
3810
3810
|
R.prototype.div = R.prototype.divide;
|
|
@@ -3819,48 +3819,48 @@ R.sqrLen = R.squaredLength;
|
|
|
3819
3819
|
R.mag = R.magnitude;
|
|
3820
3820
|
R.length = R.magnitude;
|
|
3821
3821
|
R.len = R.magnitude;
|
|
3822
|
-
function
|
|
3822
|
+
function be(d, t, e) {
|
|
3823
3823
|
const s = d.data, i = d.width, n = d.height;
|
|
3824
|
-
let r, a, c,
|
|
3825
|
-
const L = i - 1, b = n - 1, E = t + 1, w = t + E, S = t + 1, z = t + S,
|
|
3824
|
+
let r, a, c, h, o, l, m, g, u, M, p, T, x;
|
|
3825
|
+
const L = i - 1, b = n - 1, E = t + 1, w = t + E, S = t + 1, z = t + S, v = 1 / (w * z), F = [], P = [], k = [], I = [], C = [], _ = [];
|
|
3826
3826
|
for (; e-- > 0; ) {
|
|
3827
3827
|
for (x = T = 0, l = 0; l < n; l++) {
|
|
3828
|
-
for (r = s[x] * E, a = s[x + 1] * E, c = s[x + 2] * E,
|
|
3829
|
-
g = x + ((
|
|
3830
|
-
for (
|
|
3831
|
-
F[T] = r,
|
|
3828
|
+
for (r = s[x] * E, a = s[x + 1] * E, c = s[x + 2] * E, h = s[x + 3] * E, m = 1; m <= t; m++)
|
|
3829
|
+
g = x + ((m > L ? L : m) << 2), r += s[g++], a += s[g++], c += s[g++], h += s[g];
|
|
3830
|
+
for (o = 0; o < i; o++)
|
|
3831
|
+
F[T] = r, P[T] = a, k[T] = c, I[T] = h, l === 0 && (C[o] = Math.min(o + E, L) << 2, _[o] = Math.max(o - t, 0) << 2), u = x + C[o], M = x + _[o], r += s[u++] - s[M++], a += s[u++] - s[M++], c += s[u++] - s[M++], h += s[u] - s[M], T++;
|
|
3832
3832
|
x += i << 2;
|
|
3833
3833
|
}
|
|
3834
|
-
for (
|
|
3835
|
-
for (p =
|
|
3836
|
-
p +=
|
|
3837
|
-
for (T =
|
|
3838
|
-
s[T] = r *
|
|
3834
|
+
for (o = 0; o < i; o++) {
|
|
3835
|
+
for (p = o, r = F[p] * S, a = P[p] * S, c = k[p] * S, h = I[p] * S, m = 1; m <= t; m++)
|
|
3836
|
+
p += m > b ? 0 : i, r += F[p], a += P[p], c += k[p], h += I[p];
|
|
3837
|
+
for (T = o << 2, l = 0; l < n; l++)
|
|
3838
|
+
s[T] = r * v + 0.5 | 0, s[T + 1] = a * v + 0.5 | 0, s[T + 2] = c * v + 0.5 | 0, s[T + 3] = h * v + 0.5 | 0, o === 0 && (C[l] = Math.min(l + S, b) * i, _[l] = Math.max(l - t, 0) * i), u = o + C[l], M = o + _[l], r += F[u] - F[M], a += P[u] - P[M], c += k[u] - k[M], h += I[u] - I[M], T += i << 2;
|
|
3839
3839
|
}
|
|
3840
3840
|
}
|
|
3841
3841
|
}
|
|
3842
|
-
function
|
|
3842
|
+
function Ee(d, t) {
|
|
3843
3843
|
const e = d.data;
|
|
3844
3844
|
for (let s = 0; s < e.length; s += 4) {
|
|
3845
3845
|
const i = e[s], n = e[s + 1], r = e[s + 2], a = e[s + 3], c = i * 0.3 + n * 0.59 + r * 0.11;
|
|
3846
3846
|
e[s] = c * (1 - t) + i * t, e[s + 1] = c * (1 - t) + n * t, e[s + 2] = c * (1 - t) + r * t, e[s + 3] = a;
|
|
3847
3847
|
}
|
|
3848
3848
|
}
|
|
3849
|
-
function
|
|
3849
|
+
function Se(d, t) {
|
|
3850
3850
|
const e = d.data;
|
|
3851
3851
|
for (let s = 0; s < e.length; s += 4) {
|
|
3852
3852
|
const i = e[s], n = e[s + 1], r = e[s + 2], a = e[s + 3];
|
|
3853
3853
|
e[s] = i * t, e[s + 1] = n * t, e[s + 2] = r * t, e[s + 3] = a;
|
|
3854
3854
|
}
|
|
3855
3855
|
}
|
|
3856
|
-
function
|
|
3856
|
+
function Nt(d, t) {
|
|
3857
3857
|
const e = d.data;
|
|
3858
3858
|
for (let s = 0; s < e.length; s += 4) {
|
|
3859
3859
|
const i = e[s], n = e[s + 1], r = e[s + 2], a = e[s + 3];
|
|
3860
3860
|
e[s] = (i - 128) * t + 128, e[s + 1] = (n - 128) * t + 128, e[s + 2] = (r - 128) * t + 128, e[s + 3] = a;
|
|
3861
3861
|
}
|
|
3862
3862
|
}
|
|
3863
|
-
const
|
|
3863
|
+
const we = `precision highp float;
|
|
3864
3864
|
|
|
3865
3865
|
varying vec2 v_uv;
|
|
3866
3866
|
uniform sampler2D u_texture;
|
|
@@ -3885,7 +3885,7 @@ void main() {
|
|
|
3885
3885
|
vec4 result = texture2D(u_texture, v_uv);
|
|
3886
3886
|
gl_FragColor = result * vec4(1.0, 1.0, 1.0, u_alpha) + vec4(dither);
|
|
3887
3887
|
}
|
|
3888
|
-
`,
|
|
3888
|
+
`, Le = `precision highp float;
|
|
3889
3889
|
|
|
3890
3890
|
attribute vec2 a_pos;
|
|
3891
3891
|
attribute vec2 a_uv;
|
|
@@ -3895,9 +3895,9 @@ void main() {
|
|
|
3895
3895
|
v_uv = a_uv;
|
|
3896
3896
|
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
3897
3897
|
}
|
|
3898
|
-
`, y = (d, t, e, s, i = 0, n = 0, r = 1, a = 1) => Object.freeze({ cx: d, cy: t, x: e, y: s, ur: i, vr: n, up: r, vp: a }),
|
|
3898
|
+
`, y = (d, t, e, s, i = 0, n = 0, r = 1, a = 1) => Object.freeze({ cx: d, cy: t, x: e, y: s, ur: i, vr: n, up: r, vp: a }), J = (d, t, e) => Object.freeze({ width: d, height: t, conf: e }), qt = [
|
|
3899
3899
|
// TODO: 竖屏推荐
|
|
3900
|
-
|
|
3900
|
+
J(5, 5, [
|
|
3901
3901
|
y(0, 0, -1, -1, 0, 0, 1, 1),
|
|
3902
3902
|
y(1, 0, -0.5, -1, 0, 0, 1, 1),
|
|
3903
3903
|
y(2, 0, 0, -1, 0, 0, 1, 1),
|
|
@@ -3924,7 +3924,7 @@ void main() {
|
|
|
3924
3924
|
y(3, 4, 0.5, 1, 0, 0, 1, 1),
|
|
3925
3925
|
y(4, 4, 1, 1, 0, 0, 1, 1)
|
|
3926
3926
|
]),
|
|
3927
|
-
|
|
3927
|
+
J(6, 6, [
|
|
3928
3928
|
y(0, 0, -1, -1, 0, 0, 1, 1),
|
|
3929
3929
|
y(1, 0, -0.6, -1, 0, 0, 1, 1),
|
|
3930
3930
|
y(2, 0, -0.19999999999999996, -1, 0, 0, 1, 1),
|
|
@@ -3963,7 +3963,7 @@ void main() {
|
|
|
3963
3963
|
y(5, 5, 1, 1, 0, 0, 1, 1)
|
|
3964
3964
|
]),
|
|
3965
3965
|
// TODO: 横屏推荐
|
|
3966
|
-
|
|
3966
|
+
J(4, 4, [
|
|
3967
3967
|
y(0, 0, -1, -1, 0, 0, 1, 1),
|
|
3968
3968
|
y(1, 0, -0.33333333333333337, -1, 0, 0, 1, 1),
|
|
3969
3969
|
y(2, 0, 0.33333333333333326, -1, 0, 0, 1, 1),
|
|
@@ -3981,7 +3981,7 @@ void main() {
|
|
|
3981
3981
|
y(2, 3, 0.33333333333333326, 1, 0, 0, 1, 1),
|
|
3982
3982
|
y(3, 3, 1, 1, 0, 0, 1, 1)
|
|
3983
3983
|
]),
|
|
3984
|
-
|
|
3984
|
+
J(4, 4, [
|
|
3985
3985
|
y(0, 0, -1, -1, 0, 0, 1, 2.075),
|
|
3986
3986
|
y(1, 0, -0.33333333333333337, -1, 0, 0, 1, 1),
|
|
3987
3987
|
y(2, 0, 0.33333333333333326, -1, 0, 0, 1, 1),
|
|
@@ -3999,7 +3999,7 @@ void main() {
|
|
|
3999
3999
|
y(2, 3, 0.5125850864305672, 1, -20, -18, 0, 1.604),
|
|
4000
4000
|
y(3, 3, 1, 1, 0, 0, 1, 1)
|
|
4001
4001
|
]),
|
|
4002
|
-
|
|
4002
|
+
J(4, 4, [
|
|
4003
4003
|
y(0, 0, -1, -1, 0, 0, 1, 1),
|
|
4004
4004
|
y(1, 0, -0.04704442742088466, -1, 0, 14, 2.013, 3.522),
|
|
4005
4005
|
y(2, 0, 0.5910378220172194, -1, 0, 0, 1, 1),
|
|
@@ -4017,7 +4017,7 @@ void main() {
|
|
|
4017
4017
|
y(2, 3, 0.33333333333333326, 1, 0, 0, 1, 1),
|
|
4018
4018
|
y(3, 3, 1, 1, 0, 0, 1, 1)
|
|
4019
4019
|
]),
|
|
4020
|
-
|
|
4020
|
+
J(5, 5, [
|
|
4021
4021
|
y(0, 0, -1, -1, 0, 0, 1, 1),
|
|
4022
4022
|
y(1, 0, -0.632824853134554, -1, 0, -31, 1.101, 1.038),
|
|
4023
4023
|
y(2, 0, -0.1019613423315412, -1, 0, 0, 1, 1),
|
|
@@ -4044,7 +4044,7 @@ void main() {
|
|
|
4044
4044
|
y(3, 4, 0.6093434603207717, 1, 0, 0, 0.629, 1),
|
|
4045
4045
|
y(4, 4, 1, 1, 0, 0, 1, 1)
|
|
4046
4046
|
])
|
|
4047
|
-
],
|
|
4047
|
+
], Pe = `precision highp float;
|
|
4048
4048
|
|
|
4049
4049
|
varying vec3 v_color;
|
|
4050
4050
|
varying vec2 v_uv;
|
|
@@ -4065,7 +4065,7 @@ void main() {
|
|
|
4065
4065
|
result *= vec4(1.0 - u_volume * 0.1);
|
|
4066
4066
|
gl_FragColor = result;
|
|
4067
4067
|
}
|
|
4068
|
-
`,
|
|
4068
|
+
`, ve = `precision highp float;
|
|
4069
4069
|
|
|
4070
4070
|
attribute vec2 a_pos;
|
|
4071
4071
|
attribute vec3 a_color;
|
|
@@ -4087,14 +4087,14 @@ void main() {
|
|
|
4087
4087
|
gl_Position = vec4(pos, 0.0, 1.0);
|
|
4088
4088
|
}
|
|
4089
4089
|
`;
|
|
4090
|
-
class
|
|
4090
|
+
class Ut {
|
|
4091
4091
|
constructor(t, e, s, i = "unknown") {
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
|
|
4092
|
+
f(this, "gl");
|
|
4093
|
+
f(this, "program");
|
|
4094
|
+
f(this, "vertexShader");
|
|
4095
|
+
f(this, "fragmentShader");
|
|
4096
|
+
f(this, "attrs");
|
|
4097
|
+
f(this, "notFoundUniforms", /* @__PURE__ */ new Set());
|
|
4098
4098
|
this.label = i, this.gl = t, this.vertexShader = this.createShader(t.VERTEX_SHADER, e), this.fragmentShader = this.createShader(
|
|
4099
4099
|
t.FRAGMENT_SHADER,
|
|
4100
4100
|
s
|
|
@@ -4103,8 +4103,8 @@ class Dt {
|
|
|
4103
4103
|
for (let a = 0; a < n; a++) {
|
|
4104
4104
|
const c = t.getActiveAttrib(this.program, a);
|
|
4105
4105
|
if (!c) continue;
|
|
4106
|
-
const
|
|
4107
|
-
|
|
4106
|
+
const h = t.getAttribLocation(this.program, c.name);
|
|
4107
|
+
h !== -1 && (r[c.name] = h);
|
|
4108
4108
|
}
|
|
4109
4109
|
this.attrs = r;
|
|
4110
4110
|
}
|
|
@@ -4151,17 +4151,17 @@ class Dt {
|
|
|
4151
4151
|
t.deleteShader(this.vertexShader), t.deleteShader(this.fragmentShader), t.deleteProgram(this.program);
|
|
4152
4152
|
}
|
|
4153
4153
|
}
|
|
4154
|
-
class
|
|
4154
|
+
class te {
|
|
4155
4155
|
constructor(t, e, s, i) {
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4156
|
+
f(this, "vertexWidth", 0);
|
|
4157
|
+
f(this, "vertexHeight", 0);
|
|
4158
|
+
f(this, "vertexBuffer");
|
|
4159
|
+
f(this, "indexBuffer");
|
|
4160
|
+
f(this, "vertexData");
|
|
4161
|
+
f(this, "indexData");
|
|
4162
|
+
f(this, "vertexIndexLength", 0);
|
|
4163
4163
|
// 调试用途,开启线框模式
|
|
4164
|
-
|
|
4164
|
+
f(this, "wireFrame", !1);
|
|
4165
4165
|
this.gl = t, this.attrPos = e, this.attrColor = s, this.attrUV = i;
|
|
4166
4166
|
const n = t.createBuffer();
|
|
4167
4167
|
if (!n) throw new Error("Failed to create vertex buffer");
|
|
@@ -4217,8 +4217,8 @@ class Ut {
|
|
|
4217
4217
|
this.vertexData = s, this.indexData = i;
|
|
4218
4218
|
for (let r = 0; r < e; r++)
|
|
4219
4219
|
for (let a = 0; a < t; a++) {
|
|
4220
|
-
const c = a / (t - 1) * 2 - 1,
|
|
4221
|
-
this.setVertexPos(a, r, c || 0,
|
|
4220
|
+
const c = a / (t - 1) * 2 - 1, h = r / (e - 1) * 2 - 1;
|
|
4221
|
+
this.setVertexPos(a, r, c || 0, h || 0), this.setVertexColor(a, r, 1, 1, 1), this.setVertexUV(a, r, a / (t - 1), r / (e - 1));
|
|
4222
4222
|
}
|
|
4223
4223
|
for (let r = 0; r < e - 1; r++)
|
|
4224
4224
|
for (let a = 0; a < t - 1; a++)
|
|
@@ -4244,16 +4244,16 @@ class Ut {
|
|
|
4244
4244
|
this.gl.deleteBuffer(this.vertexBuffer), this.gl.deleteBuffer(this.indexBuffer);
|
|
4245
4245
|
}
|
|
4246
4246
|
}
|
|
4247
|
-
class
|
|
4247
|
+
class ze {
|
|
4248
4248
|
constructor() {
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4249
|
+
f(this, "color", B.fromValues(1, 1, 1));
|
|
4250
|
+
f(this, "location", R.fromValues(0, 0));
|
|
4251
|
+
f(this, "uTangent", R.fromValues(0, 0));
|
|
4252
|
+
f(this, "vTangent", R.fromValues(0, 0));
|
|
4253
|
+
f(this, "_uRot", 0);
|
|
4254
|
+
f(this, "_vRot", 0);
|
|
4255
|
+
f(this, "_uScale", 1);
|
|
4256
|
+
f(this, "_vScale", 1);
|
|
4257
4257
|
Object.seal(this);
|
|
4258
4258
|
}
|
|
4259
4259
|
get uRot() {
|
|
@@ -4287,31 +4287,31 @@ class me {
|
|
|
4287
4287
|
this.vTangent[0] = -Math.sin(this._vRot) * this._vScale, this.vTangent[1] = Math.cos(this._vRot) * this._vScale;
|
|
4288
4288
|
}
|
|
4289
4289
|
}
|
|
4290
|
-
const
|
|
4291
|
-
function
|
|
4292
|
-
G[0] = d ** 3, G[1] = d ** 2, G[2] = d, G[3] = 1,
|
|
4293
|
-
const n =
|
|
4294
|
-
tt.copy(s).transpose(),
|
|
4295
|
-
const r =
|
|
4290
|
+
const rt = A.fromValues(2, -2, 1, 1, -3, 3, -2, -1, 0, 0, 1, 0, 1, 0, 0, 0), dt = A.clone(rt).transpose(), G = D.create(), gt = D.create(), Q = D.create(), K = A.create(), tt = A.create();
|
|
4291
|
+
function _e(d, t, e, s, i = R.create()) {
|
|
4292
|
+
G[0] = d ** 3, G[1] = d ** 2, G[2] = d, G[3] = 1, gt.copy(G), Q[0] = t ** 3, Q[1] = t ** 2, Q[2] = t, Q[3] = 1, K.copy(e).transpose(), A.mul(K, K, rt), A.mul(K, dt, K), D.transformMat4(G, G, K);
|
|
4293
|
+
const n = Q.dot(G);
|
|
4294
|
+
tt.copy(s).transpose(), A.mul(tt, tt, rt), A.mul(tt, dt, tt), D.transformMat4(gt, gt, tt);
|
|
4295
|
+
const r = Q.dot(gt);
|
|
4296
4296
|
return i.x = n, i.y = r, i;
|
|
4297
4297
|
}
|
|
4298
|
-
function
|
|
4299
|
-
const r = (
|
|
4298
|
+
function Vt(d, t, e, s, i, n = A.create()) {
|
|
4299
|
+
const r = (h) => h.location[i], a = (h) => h.uTangent[i], c = (h) => h.vTangent[i];
|
|
4300
4300
|
return n[0] = r(d), n[1] = r(t), n[2] = c(d), n[3] = c(t), n[4] = r(e), n[5] = r(s), n[6] = c(e), n[7] = c(s), n[8] = a(d), n[9] = a(t), n[10] = 0, n[11] = 0, n[12] = a(e), n[13] = a(s), n[14] = 0, n[15] = 0, n;
|
|
4301
4301
|
}
|
|
4302
|
-
function
|
|
4302
|
+
function vt(d, t, e, s, i, n = A.create()) {
|
|
4303
4303
|
const r = (a) => a.color[i];
|
|
4304
4304
|
return n.fill(0), n[0] = r(d), n[1] = r(t), n[4] = r(e), n[5] = r(s), n;
|
|
4305
4305
|
}
|
|
4306
|
-
const Y = D.create(),
|
|
4307
|
-
function
|
|
4308
|
-
return Y[0] = d ** 3, Y[1] = d ** 2, Y[2] = d, Y[3] = 1,
|
|
4306
|
+
const Y = D.create(), ut = D.create(), yt = D.create(), j = D.create(), et = A.create(), st = A.create(), it = A.create(), Mt = B.create();
|
|
4307
|
+
function Fe(d, t, e, s, i) {
|
|
4308
|
+
return Y[0] = d ** 3, Y[1] = d ** 2, Y[2] = d, Y[3] = 1, ut.copy(Y), yt.copy(Y), j[0] = t ** 3, j[1] = t ** 2, j[2] = t, j[3] = 1, et.copy(e).transpose(), A.mul(et, et, rt), A.mul(et, dt, et), D.transformMat4(Y, Y, et), Mt.r = j.dot(Y), st.copy(s).transpose(), A.mul(st, st, rt), A.mul(st, dt, st), D.transformMat4(ut, ut, st), Mt.g = j.dot(ut), it.copy(i).transpose(), A.mul(it, it, rt), A.mul(it, dt, it), D.transformMat4(yt, yt, it), Mt.b = j.dot(yt), Mt;
|
|
4309
4309
|
}
|
|
4310
|
-
class
|
|
4310
|
+
class De {
|
|
4311
4311
|
constructor(t, e) {
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4312
|
+
f(this, "_width", 0);
|
|
4313
|
+
f(this, "_height", 0);
|
|
4314
|
+
f(this, "_data", []);
|
|
4315
4315
|
this.resize(t, e), Object.seal(this);
|
|
4316
4316
|
}
|
|
4317
4317
|
resize(t, e) {
|
|
@@ -4330,20 +4330,20 @@ class ge {
|
|
|
4330
4330
|
return this._height;
|
|
4331
4331
|
}
|
|
4332
4332
|
}
|
|
4333
|
-
class
|
|
4333
|
+
class Ie extends te {
|
|
4334
4334
|
constructor(e, s, i, n) {
|
|
4335
4335
|
super(e, s, i, n);
|
|
4336
4336
|
/**
|
|
4337
4337
|
* 细分级别,越大曲线越平滑,但是性能消耗也越大
|
|
4338
4338
|
*/
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4339
|
+
f(this, "_subDivisions", 10);
|
|
4340
|
+
f(this, "_controlPoints", new De(3, 3));
|
|
4341
|
+
f(this, "uMX", A.create());
|
|
4342
|
+
f(this, "uMY", A.create());
|
|
4343
|
+
f(this, "uMR", A.create());
|
|
4344
|
+
f(this, "uMG", A.create());
|
|
4345
|
+
f(this, "uMB", A.create());
|
|
4346
|
+
f(this, "tmpV2", R.create());
|
|
4347
4347
|
this.resizeControlPoints(3, 3), Object.seal(this);
|
|
4348
4348
|
}
|
|
4349
4349
|
setWireFrame(e) {
|
|
@@ -4371,7 +4371,7 @@ class ue extends Ut {
|
|
|
4371
4371
|
this._controlPoints.resize(e, s);
|
|
4372
4372
|
for (let i = 0; i < s; i++)
|
|
4373
4373
|
for (let n = 0; n < e; n++) {
|
|
4374
|
-
const r = new
|
|
4374
|
+
const r = new ze();
|
|
4375
4375
|
r.location.x = n / (e - 1) * 2 - 1, r.location.y = i / (s - 1) * 2 - 1, r.uTangent.x = 2 / (e - 1), r.vTangent.y = 2 / (s - 1), this._controlPoints.set(n, i, r);
|
|
4376
4376
|
}
|
|
4377
4377
|
this.resetSubdivition(this._subDivisions);
|
|
@@ -4395,33 +4395,33 @@ class ue extends Ut {
|
|
|
4395
4395
|
const e = this._subDivisions - 1, s = e * (this._controlPoints.height - 1), i = e * (this._controlPoints.width - 1);
|
|
4396
4396
|
for (let n = 0; n < this._controlPoints.width - 1; n++)
|
|
4397
4397
|
for (let r = 0; r < this._controlPoints.height - 1; r++) {
|
|
4398
|
-
const a = this._controlPoints.get(n, r), c = this._controlPoints.get(n, r + 1),
|
|
4398
|
+
const a = this._controlPoints.get(n, r), c = this._controlPoints.get(n, r + 1), h = this._controlPoints.get(n + 1, r), o = this._controlPoints.get(n + 1, r + 1), l = Vt(a, c, h, o, "x", this.uMX), m = Vt(a, c, h, o, "y", this.uMY), g = vt(a, c, h, o, "r", this.uMR), u = vt(a, c, h, o, "g", this.uMG), M = vt(a, c, h, o, "b", this.uMB), p = n / (this._controlPoints.width - 1), T = r / (this._controlPoints.height - 1);
|
|
4399
4399
|
for (let x = 0; x < this._subDivisions; x++)
|
|
4400
4400
|
for (let L = 0; L < this._subDivisions; L++) {
|
|
4401
|
-
const b = r * this._subDivisions + x, E = n * this._subDivisions + L, [w, S] =
|
|
4401
|
+
const b = r * this._subDivisions + x, E = n * this._subDivisions + L, [w, S] = _e(
|
|
4402
4402
|
x / e,
|
|
4403
4403
|
L / e,
|
|
4404
4404
|
l,
|
|
4405
|
-
|
|
4405
|
+
m,
|
|
4406
4406
|
this.tmpV2
|
|
4407
4407
|
);
|
|
4408
4408
|
this.setVertexPos(b, E, w, S), this.setVertexUV(b, E, p + L / i, 1 - T - x / s);
|
|
4409
|
-
const [z,
|
|
4409
|
+
const [z, v, F] = Fe(
|
|
4410
4410
|
x / e,
|
|
4411
4411
|
L / e,
|
|
4412
4412
|
g,
|
|
4413
4413
|
u,
|
|
4414
4414
|
M
|
|
4415
4415
|
);
|
|
4416
|
-
this.setVertexColor(b, E, z,
|
|
4416
|
+
this.setVertexColor(b, E, z, v, F);
|
|
4417
4417
|
}
|
|
4418
4418
|
}
|
|
4419
4419
|
this.update();
|
|
4420
4420
|
}
|
|
4421
4421
|
}
|
|
4422
|
-
class
|
|
4422
|
+
class Wt {
|
|
4423
4423
|
constructor(t, e) {
|
|
4424
|
-
|
|
4424
|
+
f(this, "tex");
|
|
4425
4425
|
this.gl = t;
|
|
4426
4426
|
const s = t.createTexture();
|
|
4427
4427
|
if (!s) throw new Error("Failed to create texture");
|
|
@@ -4441,52 +4441,52 @@ class At {
|
|
|
4441
4441
|
this.gl.deleteTexture(this.tex);
|
|
4442
4442
|
}
|
|
4443
4443
|
}
|
|
4444
|
-
function
|
|
4444
|
+
function Ae(d, t) {
|
|
4445
4445
|
if ("OffscreenCanvas" in window) return new OffscreenCanvas(d, t);
|
|
4446
4446
|
const e = document.createElement("canvas");
|
|
4447
4447
|
return e.width = d, e.height = t, e;
|
|
4448
4448
|
}
|
|
4449
|
-
class
|
|
4449
|
+
class Ns extends Jt {
|
|
4450
4450
|
constructor(e) {
|
|
4451
4451
|
super(e);
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4452
|
+
f(this, "gl");
|
|
4453
|
+
f(this, "lastFrameTime", 0);
|
|
4454
|
+
f(this, "frameTime", 0);
|
|
4455
|
+
f(this, "lastTickTime", 0);
|
|
4456
|
+
f(this, "volume", 0);
|
|
4457
|
+
f(this, "tickHandle", 0);
|
|
4458
|
+
f(this, "maxFPS", 60);
|
|
4459
|
+
f(this, "paused", !1);
|
|
4460
|
+
f(this, "staticMode", !1);
|
|
4461
|
+
f(this, "mainProgram");
|
|
4462
|
+
f(this, "blendProgram");
|
|
4463
|
+
f(this, "manualControl", !1);
|
|
4464
|
+
f(this, "reduceImageSizeCanvas", Ae(
|
|
4465
4465
|
32,
|
|
4466
4466
|
32
|
|
4467
4467
|
));
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4468
|
+
f(this, "targetSize", R.fromValues(0, 0));
|
|
4469
|
+
f(this, "currentSize", R.fromValues(0, 0));
|
|
4470
|
+
f(this, "fullScreenMesh");
|
|
4471
|
+
f(this, "drawFrameBuffer");
|
|
4472
|
+
f(this, "drawFrameBufferTexture");
|
|
4473
|
+
f(this, "meshStates", []);
|
|
4474
|
+
f(this, "_disposed", !1);
|
|
4475
|
+
f(this, "onTickBinded", this.onTick.bind(this));
|
|
4476
|
+
f(this, "supportTextureFloat", !0);
|
|
4477
4477
|
const s = e.getContext("webgl");
|
|
4478
4478
|
if (!s) throw new Error("WebGL not supported");
|
|
4479
|
-
s.getExtension("EXT_color_buffer_float") || console.warn("EXT_color_buffer_float not supported"), s.getExtension("EXT_float_blend") || (console.warn("EXT_float_blend not supported"), this.supportTextureFloat = !1), s.getExtension("OES_texture_float_linear") || console.warn("OES_texture_float_linear not supported"), s.getExtension("OES_texture_float") || (this.supportTextureFloat = !1, console.warn("OES_texture_float not supported")), this.gl = s, s.enable(s.BLEND), s.enable(s.DEPTH_TEST), s.depthFunc(s.ALWAYS), this.mainProgram = new
|
|
4479
|
+
s.getExtension("EXT_color_buffer_float") || console.warn("EXT_color_buffer_float not supported"), s.getExtension("EXT_float_blend") || (console.warn("EXT_float_blend not supported"), this.supportTextureFloat = !1), s.getExtension("OES_texture_float_linear") || console.warn("OES_texture_float_linear not supported"), s.getExtension("OES_texture_float") || (this.supportTextureFloat = !1, console.warn("OES_texture_float not supported")), this.gl = s, s.enable(s.BLEND), s.enable(s.DEPTH_TEST), s.depthFunc(s.ALWAYS), this.mainProgram = new Ut(
|
|
4480
4480
|
s,
|
|
4481
|
-
|
|
4482
|
-
|
|
4481
|
+
ve,
|
|
4482
|
+
Pe,
|
|
4483
4483
|
"main-program-mg"
|
|
4484
|
-
), this.blendProgram = new
|
|
4484
|
+
), this.blendProgram = new Ut(
|
|
4485
4485
|
s,
|
|
4486
|
-
|
|
4487
|
-
|
|
4486
|
+
Le,
|
|
4487
|
+
we,
|
|
4488
4488
|
"blend-program-mg"
|
|
4489
|
-
), this.fullScreenMesh = new
|
|
4489
|
+
), this.fullScreenMesh = new te(
|
|
4490
4490
|
s,
|
|
4491
4491
|
this.blendProgram.attrs.a_pos,
|
|
4492
4492
|
this.blendProgram.attrs.a_color,
|
|
@@ -4612,7 +4612,7 @@ class Ms extends qt {
|
|
|
4612
4612
|
let i = null, n = 5;
|
|
4613
4613
|
for (; !i && n > 0; )
|
|
4614
4614
|
try {
|
|
4615
|
-
typeof e == "string" ? i = await
|
|
4615
|
+
typeof e == "string" ? i = await Qt(e, s) : i = await Kt(e);
|
|
4616
4616
|
} catch (l) {
|
|
4617
4617
|
console.warn(
|
|
4618
4618
|
`failed on loading album resource, retrying (${n})`,
|
|
@@ -4628,29 +4628,29 @@ class Ms extends qt {
|
|
|
4628
4628
|
});
|
|
4629
4629
|
if (!a) throw new Error("Failed to create canvas context");
|
|
4630
4630
|
a.clearRect(0, 0, r.width, r.height);
|
|
4631
|
-
const c = i instanceof HTMLVideoElement ? i.videoWidth : i.naturalWidth,
|
|
4632
|
-
if (c *
|
|
4633
|
-
a.drawImage(i, 0, 0, c,
|
|
4634
|
-
const
|
|
4635
|
-
if (
|
|
4636
|
-
this.meshStates[0].texture.dispose(), this.meshStates[0].texture = new
|
|
4631
|
+
const c = i instanceof HTMLVideoElement ? i.videoWidth : i.naturalWidth, h = i instanceof HTMLVideoElement ? i.videoHeight : i.naturalHeight;
|
|
4632
|
+
if (c * h === 0) throw new Error("Invalid image size");
|
|
4633
|
+
a.drawImage(i, 0, 0, c, h, 0, 0, r.width, r.height);
|
|
4634
|
+
const o = a.getImageData(0, 0, r.width, r.height);
|
|
4635
|
+
if (Nt(o, 0.4), Ee(o, 3), Nt(o, 1.7), Se(o, 0.75), be(o, 2, 4), this.manualControl && this.meshStates.length > 0)
|
|
4636
|
+
this.meshStates[0].texture.dispose(), this.meshStates[0].texture = new Wt(this.gl, o);
|
|
4637
4637
|
else {
|
|
4638
|
-
const l = new
|
|
4638
|
+
const l = new Ie(
|
|
4639
4639
|
this.gl,
|
|
4640
4640
|
this.mainProgram.attrs.a_pos,
|
|
4641
4641
|
this.mainProgram.attrs.a_color,
|
|
4642
4642
|
this.mainProgram.attrs.a_uv
|
|
4643
4643
|
);
|
|
4644
4644
|
l.resetSubdivition(15);
|
|
4645
|
-
const
|
|
4646
|
-
l.resizeControlPoints(
|
|
4647
|
-
const g = 2 / (
|
|
4648
|
-
for (const T of
|
|
4645
|
+
const m = qt[Math.floor(Math.random() * qt.length)];
|
|
4646
|
+
l.resizeControlPoints(m.width, m.height);
|
|
4647
|
+
const g = 2 / (m.width - 1), u = 2 / (m.height - 1);
|
|
4648
|
+
for (const T of m.conf) {
|
|
4649
4649
|
const x = l.getControlPoint(T.cx, T.cy);
|
|
4650
4650
|
x.location.x = T.x, x.location.y = T.y, x.uRot = T.ur * Math.PI / 180, x.vRot = T.vr * Math.PI / 180, x.uScale = g * T.up, x.vScale = u * T.vp;
|
|
4651
4651
|
}
|
|
4652
4652
|
l.updateMesh();
|
|
4653
|
-
const M = new
|
|
4653
|
+
const M = new Wt(this.gl, o), p = {
|
|
4654
4654
|
mesh: l,
|
|
4655
4655
|
texture: M,
|
|
4656
4656
|
alpha: 0
|
|
@@ -4670,15 +4670,15 @@ class Ms extends qt {
|
|
|
4670
4670
|
e.mesh.dispose(), e.texture.dispose();
|
|
4671
4671
|
}
|
|
4672
4672
|
}
|
|
4673
|
-
class
|
|
4673
|
+
class ee {
|
|
4674
4674
|
constructor(t, e) {
|
|
4675
|
-
|
|
4676
|
-
|
|
4675
|
+
f(this, "element");
|
|
4676
|
+
f(this, "renderer");
|
|
4677
4677
|
this.renderer = t, this.element = e, e.style.pointerEvents = "none", e.style.zIndex = "-1", e.style.contain = "strict";
|
|
4678
4678
|
}
|
|
4679
4679
|
static new(t) {
|
|
4680
4680
|
const e = document.createElement("canvas");
|
|
4681
|
-
return new
|
|
4681
|
+
return new ee(new t(e), e);
|
|
4682
4682
|
}
|
|
4683
4683
|
setRenderScale(t) {
|
|
4684
4684
|
this.renderer.setRenderScale(t);
|
|
@@ -4714,21 +4714,172 @@ class Vt {
|
|
|
4714
4714
|
this.renderer.dispose(), this.element.remove();
|
|
4715
4715
|
}
|
|
4716
4716
|
}
|
|
4717
|
-
const
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
4723
|
-
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4717
|
+
const se = -1, Lt = 0, Et = 1, St = 2, Dt = 3, It = 4, At = 5, kt = 6, ie = 7, ne = 8, Ht = typeof self == "object" ? self : globalThis, ke = (d, t) => {
|
|
4718
|
+
const e = (i, n) => (d.set(n, i), i), s = (i) => {
|
|
4719
|
+
if (d.has(i))
|
|
4720
|
+
return d.get(i);
|
|
4721
|
+
const [n, r] = t[i];
|
|
4722
|
+
switch (n) {
|
|
4723
|
+
case Lt:
|
|
4724
|
+
case se:
|
|
4725
|
+
return e(r, i);
|
|
4726
|
+
case Et: {
|
|
4727
|
+
const a = e([], i);
|
|
4728
|
+
for (const c of r)
|
|
4729
|
+
a.push(s(c));
|
|
4730
|
+
return a;
|
|
4731
|
+
}
|
|
4732
|
+
case St: {
|
|
4733
|
+
const a = e({}, i);
|
|
4734
|
+
for (const [c, h] of r)
|
|
4735
|
+
a[s(c)] = s(h);
|
|
4736
|
+
return a;
|
|
4737
|
+
}
|
|
4738
|
+
case Dt:
|
|
4739
|
+
return e(new Date(r), i);
|
|
4740
|
+
case It: {
|
|
4741
|
+
const { source: a, flags: c } = r;
|
|
4742
|
+
return e(new RegExp(a, c), i);
|
|
4743
|
+
}
|
|
4744
|
+
case At: {
|
|
4745
|
+
const a = e(/* @__PURE__ */ new Map(), i);
|
|
4746
|
+
for (const [c, h] of r)
|
|
4747
|
+
a.set(s(c), s(h));
|
|
4748
|
+
return a;
|
|
4749
|
+
}
|
|
4750
|
+
case kt: {
|
|
4751
|
+
const a = e(/* @__PURE__ */ new Set(), i);
|
|
4752
|
+
for (const c of r)
|
|
4753
|
+
a.add(s(c));
|
|
4754
|
+
return a;
|
|
4755
|
+
}
|
|
4756
|
+
case ie: {
|
|
4757
|
+
const { name: a, message: c } = r;
|
|
4758
|
+
return e(new Ht[a](c), i);
|
|
4759
|
+
}
|
|
4760
|
+
case ne:
|
|
4761
|
+
return e(BigInt(r), i);
|
|
4762
|
+
case "BigInt":
|
|
4763
|
+
return e(Object(BigInt(r)), i);
|
|
4764
|
+
}
|
|
4765
|
+
return e(new Ht[n](r), i);
|
|
4766
|
+
};
|
|
4767
|
+
return s;
|
|
4768
|
+
}, $t = (d) => ke(/* @__PURE__ */ new Map(), d)(0), nt = "", { toString: Re } = {}, { keys: Ce } = Object, ot = (d) => {
|
|
4769
|
+
const t = typeof d;
|
|
4770
|
+
if (t !== "object" || !d)
|
|
4771
|
+
return [Lt, t];
|
|
4772
|
+
const e = Re.call(d).slice(8, -1);
|
|
4773
|
+
switch (e) {
|
|
4774
|
+
case "Array":
|
|
4775
|
+
return [Et, nt];
|
|
4776
|
+
case "Object":
|
|
4777
|
+
return [St, nt];
|
|
4778
|
+
case "Date":
|
|
4779
|
+
return [Dt, nt];
|
|
4780
|
+
case "RegExp":
|
|
4781
|
+
return [It, nt];
|
|
4782
|
+
case "Map":
|
|
4783
|
+
return [At, nt];
|
|
4784
|
+
case "Set":
|
|
4785
|
+
return [kt, nt];
|
|
4786
|
+
}
|
|
4787
|
+
return e.includes("Array") ? [Et, e] : e.includes("Error") ? [ie, e] : [St, e];
|
|
4788
|
+
}, Tt = ([d, t]) => d === Lt && (t === "function" || t === "symbol"), Be = (d, t, e, s) => {
|
|
4789
|
+
const i = (r, a) => {
|
|
4790
|
+
const c = s.push(r) - 1;
|
|
4791
|
+
return e.set(a, c), c;
|
|
4792
|
+
}, n = (r) => {
|
|
4793
|
+
if (e.has(r))
|
|
4794
|
+
return e.get(r);
|
|
4795
|
+
let [a, c] = ot(r);
|
|
4796
|
+
switch (a) {
|
|
4797
|
+
case Lt: {
|
|
4798
|
+
let o = r;
|
|
4799
|
+
switch (c) {
|
|
4800
|
+
case "bigint":
|
|
4801
|
+
a = ne, o = r.toString();
|
|
4802
|
+
break;
|
|
4803
|
+
case "function":
|
|
4804
|
+
case "symbol":
|
|
4805
|
+
if (d)
|
|
4806
|
+
throw new TypeError("unable to serialize " + c);
|
|
4807
|
+
o = null;
|
|
4808
|
+
break;
|
|
4809
|
+
case "undefined":
|
|
4810
|
+
return i([se], r);
|
|
4811
|
+
}
|
|
4812
|
+
return i([a, o], r);
|
|
4813
|
+
}
|
|
4814
|
+
case Et: {
|
|
4815
|
+
if (c)
|
|
4816
|
+
return i([c, [...r]], r);
|
|
4817
|
+
const o = [], l = i([a, o], r);
|
|
4818
|
+
for (const m of r)
|
|
4819
|
+
o.push(n(m));
|
|
4820
|
+
return l;
|
|
4821
|
+
}
|
|
4822
|
+
case St: {
|
|
4823
|
+
if (c)
|
|
4824
|
+
switch (c) {
|
|
4825
|
+
case "BigInt":
|
|
4826
|
+
return i([c, r.toString()], r);
|
|
4827
|
+
case "Boolean":
|
|
4828
|
+
case "Number":
|
|
4829
|
+
case "String":
|
|
4830
|
+
return i([c, r.valueOf()], r);
|
|
4831
|
+
}
|
|
4832
|
+
if (t && "toJSON" in r)
|
|
4833
|
+
return n(r.toJSON());
|
|
4834
|
+
const o = [], l = i([a, o], r);
|
|
4835
|
+
for (const m of Ce(r))
|
|
4836
|
+
(d || !Tt(ot(r[m]))) && o.push([n(m), n(r[m])]);
|
|
4837
|
+
return l;
|
|
4838
|
+
}
|
|
4839
|
+
case Dt:
|
|
4840
|
+
return i([a, r.toISOString()], r);
|
|
4841
|
+
case It: {
|
|
4842
|
+
const { source: o, flags: l } = r;
|
|
4843
|
+
return i([a, { source: o, flags: l }], r);
|
|
4844
|
+
}
|
|
4845
|
+
case At: {
|
|
4846
|
+
const o = [], l = i([a, o], r);
|
|
4847
|
+
for (const [m, g] of r)
|
|
4848
|
+
(d || !(Tt(ot(m)) || Tt(ot(g)))) && o.push([n(m), n(g)]);
|
|
4849
|
+
return l;
|
|
4850
|
+
}
|
|
4851
|
+
case kt: {
|
|
4852
|
+
const o = [], l = i([a, o], r);
|
|
4853
|
+
for (const m of r)
|
|
4854
|
+
(d || !Tt(ot(m))) && o.push(n(m));
|
|
4855
|
+
return l;
|
|
4856
|
+
}
|
|
4857
|
+
}
|
|
4858
|
+
const { message: h } = r;
|
|
4859
|
+
return i([a, { name: c, message: h }], r);
|
|
4860
|
+
};
|
|
4861
|
+
return n;
|
|
4862
|
+
}, Yt = (d, { json: t, lossy: e } = {}) => {
|
|
4863
|
+
const s = [];
|
|
4864
|
+
return Be(!(t || e), !!t, /* @__PURE__ */ new Map(), s)(d), s;
|
|
4865
|
+
}, Oe = typeof structuredClone == "function" ? (
|
|
4866
|
+
/* c8 ignore start */
|
|
4867
|
+
(d, t) => t && ("json" in t || "lossy" in t) ? $t(Yt(d, t)) : structuredClone(d)
|
|
4868
|
+
) : (d, t) => $t(Yt(d, t)), Ne = "_lyricLine_kocao_6", qe = "_lyricBgLine_kocao_31", Ue = "_active_kocao_40", Ve = "_lyricDuetLine_kocao_47", We = "_lyricMainLine_kocao_52", He = "_emphasizeWrapper_kocao_62", $e = "_emphasize_kocao_62", Ye = "_lyricSubLine_kocao_84", Xe = "_disableSpring_kocao_91", Ge = "_interludeDots_kocao_96", je = "_duet_kocao_115", Ze = "_tmpDisableTransition_kocao_127", N = {
|
|
4869
|
+
lyricLine: Ne,
|
|
4870
|
+
lyricBgLine: qe,
|
|
4871
|
+
active: Ue,
|
|
4872
|
+
lyricDuetLine: Ve,
|
|
4873
|
+
lyricMainLine: We,
|
|
4874
|
+
emphasizeWrapper: He,
|
|
4875
|
+
emphasize: $e,
|
|
4876
|
+
lyricSubLine: Ye,
|
|
4877
|
+
disableSpring: Xe,
|
|
4878
|
+
interludeDots: Ge,
|
|
4879
|
+
duet: je,
|
|
4880
|
+
tmpDisableTransition: Ze
|
|
4730
4881
|
};
|
|
4731
|
-
function
|
|
4882
|
+
function Xt(d, t = 1) {
|
|
4732
4883
|
let e = 0, s = t;
|
|
4733
4884
|
return (...n) => {
|
|
4734
4885
|
s = t, cancelAnimationFrame(e);
|
|
@@ -4738,35 +4889,35 @@ function kt(d, t = 1) {
|
|
|
4738
4889
|
e = requestAnimationFrame(r);
|
|
4739
4890
|
};
|
|
4740
4891
|
}
|
|
4741
|
-
const
|
|
4742
|
-
function
|
|
4892
|
+
const Je = (d, t) => d.size === t.size && [...d].every((e) => t.has(e));
|
|
4893
|
+
function Qe(d) {
|
|
4743
4894
|
return (e) => (d(e + 1e-3) - d(e - 1e-3)) / (2 * 1e-3);
|
|
4744
4895
|
}
|
|
4745
|
-
function
|
|
4746
|
-
return
|
|
4896
|
+
function Gt(d) {
|
|
4897
|
+
return Qe(d);
|
|
4747
4898
|
}
|
|
4748
|
-
class
|
|
4899
|
+
class mt {
|
|
4749
4900
|
constructor(t = 0) {
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4901
|
+
f(this, "currentPosition", 0);
|
|
4902
|
+
f(this, "targetPosition", 0);
|
|
4903
|
+
f(this, "currentTime", 0);
|
|
4904
|
+
f(this, "params", {});
|
|
4905
|
+
f(this, "currentSolver");
|
|
4906
|
+
f(this, "getV");
|
|
4907
|
+
f(this, "getV2");
|
|
4908
|
+
f(this, "queueParams");
|
|
4909
|
+
f(this, "queuePosition");
|
|
4759
4910
|
this.targetPosition = t, this.currentPosition = this.targetPosition, this.currentSolver = () => this.targetPosition, this.getV = () => 0, this.getV2 = () => 0;
|
|
4760
4911
|
}
|
|
4761
4912
|
resetSolver() {
|
|
4762
4913
|
const t = this.getV(this.currentTime);
|
|
4763
|
-
this.currentTime = 0, this.currentSolver =
|
|
4914
|
+
this.currentTime = 0, this.currentSolver = Ke(
|
|
4764
4915
|
this.currentPosition,
|
|
4765
4916
|
t,
|
|
4766
4917
|
this.targetPosition,
|
|
4767
4918
|
0,
|
|
4768
4919
|
this.params
|
|
4769
|
-
), this.getV =
|
|
4920
|
+
), this.getV = Gt(this.currentSolver), this.getV2 = Gt(this.getV);
|
|
4770
4921
|
}
|
|
4771
4922
|
arrived() {
|
|
4772
4923
|
return Math.abs(this.targetPosition - this.currentPosition) < 0.01 && this.getV(this.currentTime) < 0.01 && this.getV2(this.currentTime) < 0.01 && this.queueParams === void 0 && this.queuePosition === void 0;
|
|
@@ -4800,28 +4951,28 @@ class lt {
|
|
|
4800
4951
|
return this.currentPosition;
|
|
4801
4952
|
}
|
|
4802
4953
|
}
|
|
4803
|
-
function
|
|
4804
|
-
const n = (i == null ? void 0 : i.soft) ?? !1, r = (i == null ? void 0 : i.stiffness) ?? 100, a = (i == null ? void 0 : i.damping) ?? 10, c = (i == null ? void 0 : i.mass) ?? 1,
|
|
4954
|
+
function Ke(d, t, e, s = 0, i) {
|
|
4955
|
+
const n = (i == null ? void 0 : i.soft) ?? !1, r = (i == null ? void 0 : i.stiffness) ?? 100, a = (i == null ? void 0 : i.damping) ?? 10, c = (i == null ? void 0 : i.mass) ?? 1, h = e - d;
|
|
4805
4956
|
if (n || 1 <= a / (2 * Math.sqrt(r * c))) {
|
|
4806
|
-
const u = -Math.sqrt(r / c), M = -u *
|
|
4807
|
-
return (p) => (p -= s, p < 0 ? d : e - (
|
|
4957
|
+
const u = -Math.sqrt(r / c), M = -u * h - t;
|
|
4958
|
+
return (p) => (p -= s, p < 0 ? d : e - (h + p * M) * Math.E ** (p * u));
|
|
4808
4959
|
}
|
|
4809
|
-
const
|
|
4810
|
-
return (u) => (u -= s, u < 0 ? d : e - (Math.cos(u *
|
|
4960
|
+
const o = Math.sqrt(4 * c * r - a ** 2), l = (a * h - 2 * c * t) / o, m = 0.5 * o / c, g = -(0.5 * a) / c;
|
|
4961
|
+
return (u) => (u -= s, u < 0 ? d : e - (Math.cos(u * m) * h + Math.sin(u * m) * l) * Math.E ** (u * g));
|
|
4811
4962
|
}
|
|
4812
|
-
class
|
|
4963
|
+
class ts {
|
|
4813
4964
|
constructor(t) {
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4965
|
+
f(this, "element", document.createElement("div"));
|
|
4966
|
+
f(this, "left", 0);
|
|
4967
|
+
f(this, "top", 0);
|
|
4968
|
+
f(this, "delay", 0);
|
|
4818
4969
|
// 由 LyricPlayer 来设置
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
posX: new
|
|
4822
|
-
posY: new
|
|
4970
|
+
f(this, "lineSize", [0, 0]);
|
|
4971
|
+
f(this, "lineTransforms", {
|
|
4972
|
+
posX: new mt(0),
|
|
4973
|
+
posY: new mt(0)
|
|
4823
4974
|
});
|
|
4824
|
-
|
|
4975
|
+
f(this, "lastStyle", "");
|
|
4825
4976
|
this.lyricPlayer = t, this.element.setAttribute("class", N.lyricLine), this.rebuildStyle();
|
|
4826
4977
|
}
|
|
4827
4978
|
measureSize() {
|
|
@@ -4859,29 +5010,29 @@ class Ae {
|
|
|
4859
5010
|
this.element.remove();
|
|
4860
5011
|
}
|
|
4861
5012
|
}
|
|
4862
|
-
function
|
|
5013
|
+
function es(d) {
|
|
4863
5014
|
const e = 2.5949095;
|
|
4864
5015
|
return d < 0.5 ? Math.pow(2 * d, 2) * ((e + 1) * 2 * d - e) / 2 : (Math.pow(2 * d - 2, 2) * ((e + 1) * (d * 2 - 2) + e) + 2) / 2;
|
|
4865
5016
|
}
|
|
4866
|
-
function
|
|
5017
|
+
function ss(d) {
|
|
4867
5018
|
return d === 1 ? 1 : 1 - 2 ** (-10 * d);
|
|
4868
5019
|
}
|
|
4869
5020
|
const Z = (d, t, e) => Math.max(d, Math.min(t, e));
|
|
4870
|
-
class
|
|
5021
|
+
class is {
|
|
4871
5022
|
constructor(t) {
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
5023
|
+
f(this, "element", document.createElement("div"));
|
|
5024
|
+
f(this, "dot0", document.createElement("span"));
|
|
5025
|
+
f(this, "dot1", document.createElement("span"));
|
|
5026
|
+
f(this, "dot2", document.createElement("span"));
|
|
5027
|
+
f(this, "left", 0);
|
|
5028
|
+
f(this, "top", 0);
|
|
5029
|
+
f(this, "scale", 1);
|
|
5030
|
+
f(this, "playing", !0);
|
|
5031
|
+
f(this, "lastStyle", "");
|
|
5032
|
+
f(this, "currentInterlude");
|
|
5033
|
+
f(this, "currentTime", 0);
|
|
5034
|
+
f(this, "interludeTime", 0);
|
|
5035
|
+
f(this, "targetBreatheDuration", 1500);
|
|
4885
5036
|
this.lyricPlayer = t, this.element.className = N.interludeDots, this.element.appendChild(this.dot0), this.element.appendChild(this.dot1), this.element.appendChild(this.dot2);
|
|
4886
5037
|
}
|
|
4887
5038
|
getElement() {
|
|
@@ -4910,7 +5061,7 @@ class Ce {
|
|
|
4910
5061
|
if (i <= s) {
|
|
4911
5062
|
const n = s / Math.ceil(s / this.targetBreatheDuration);
|
|
4912
5063
|
let r = 1, a = 1;
|
|
4913
|
-
r *= Math.sin(1.5 * Math.PI - i / n * 2) / 20 + 1, i < 2e3 && (r *=
|
|
5064
|
+
r *= Math.sin(1.5 * Math.PI - i / n * 2) / 20 + 1, i < 2e3 && (r *= ss(i / 2e3)), i < 500 ? a = 0 : i < 1e3 && (a *= (i - 500) / 500), s - i < 750 && (r *= 1 - es(
|
|
4914
5065
|
(750 - (s - i)) / 750 / 2
|
|
4915
5066
|
)), s - i < 375 && (a *= Z(
|
|
4916
5067
|
0,
|
|
@@ -4919,11 +5070,11 @@ class Ce {
|
|
|
4919
5070
|
));
|
|
4920
5071
|
const c = Math.max(0, s - 750);
|
|
4921
5072
|
r = Math.max(0, r) * 0.7, e += ` scale(${r})`;
|
|
4922
|
-
const
|
|
5073
|
+
const h = Z(
|
|
4923
5074
|
0.25,
|
|
4924
5075
|
i * 3 / c * 0.75,
|
|
4925
5076
|
1
|
|
4926
|
-
),
|
|
5077
|
+
), o = Z(
|
|
4927
5078
|
0.25,
|
|
4928
5079
|
(i - c / 3) * 3 / c * 0.75,
|
|
4929
5080
|
1
|
|
@@ -4934,11 +5085,11 @@ class Ce {
|
|
|
4934
5085
|
);
|
|
4935
5086
|
this.dot0.style.opacity = `${Z(
|
|
4936
5087
|
0,
|
|
4937
|
-
Math.max(0, a *
|
|
5088
|
+
Math.max(0, a * h),
|
|
4938
5089
|
1
|
|
4939
5090
|
)}`, this.dot1.style.opacity = `${Z(
|
|
4940
5091
|
0,
|
|
4941
|
-
Math.max(0, a *
|
|
5092
|
+
Math.max(0, a * o),
|
|
4942
5093
|
1
|
|
4943
5094
|
)}`, this.dot2.style.opacity = `${Z(
|
|
4944
5095
|
0,
|
|
@@ -4955,65 +5106,65 @@ class Ce {
|
|
|
4955
5106
|
this.element.remove();
|
|
4956
5107
|
}
|
|
4957
5108
|
}
|
|
4958
|
-
function
|
|
5109
|
+
function ns(d) {
|
|
4959
5110
|
return d && d.__esModule && Object.prototype.hasOwnProperty.call(d, "default") ? d.default : d;
|
|
4960
5111
|
}
|
|
4961
|
-
var
|
|
4962
|
-
function
|
|
5112
|
+
var rs = 4, as = 1e-3, cs = 1e-7, os = 10, lt = 11, xt = 1 / (lt - 1), hs = typeof Float32Array == "function";
|
|
5113
|
+
function re(d, t) {
|
|
4963
5114
|
return 1 - 3 * t + 3 * d;
|
|
4964
5115
|
}
|
|
4965
|
-
function
|
|
5116
|
+
function ae(d, t) {
|
|
4966
5117
|
return 3 * t - 6 * d;
|
|
4967
5118
|
}
|
|
4968
|
-
function
|
|
5119
|
+
function ce(d) {
|
|
4969
5120
|
return 3 * d;
|
|
4970
5121
|
}
|
|
4971
|
-
function
|
|
4972
|
-
return ((
|
|
5122
|
+
function wt(d, t, e) {
|
|
5123
|
+
return ((re(t, e) * d + ae(t, e)) * d + ce(t)) * d;
|
|
4973
5124
|
}
|
|
4974
|
-
function
|
|
4975
|
-
return 3 *
|
|
5125
|
+
function oe(d, t, e) {
|
|
5126
|
+
return 3 * re(t, e) * d * d + 2 * ae(t, e) * d + ce(t);
|
|
4976
5127
|
}
|
|
4977
|
-
function
|
|
5128
|
+
function ls(d, t, e, s, i) {
|
|
4978
5129
|
var n, r, a = 0;
|
|
4979
5130
|
do
|
|
4980
|
-
r = t + (e - t) / 2, n =
|
|
4981
|
-
while (Math.abs(n) >
|
|
5131
|
+
r = t + (e - t) / 2, n = wt(r, s, i) - d, n > 0 ? e = r : t = r;
|
|
5132
|
+
while (Math.abs(n) > cs && ++a < os);
|
|
4982
5133
|
return r;
|
|
4983
5134
|
}
|
|
4984
|
-
function
|
|
4985
|
-
for (var i = 0; i <
|
|
4986
|
-
var n =
|
|
5135
|
+
function ds(d, t, e, s) {
|
|
5136
|
+
for (var i = 0; i < rs; ++i) {
|
|
5137
|
+
var n = oe(t, e, s);
|
|
4987
5138
|
if (n === 0)
|
|
4988
5139
|
return t;
|
|
4989
|
-
var r =
|
|
5140
|
+
var r = wt(t, e, s) - d;
|
|
4990
5141
|
t -= r / n;
|
|
4991
5142
|
}
|
|
4992
5143
|
return t;
|
|
4993
5144
|
}
|
|
4994
|
-
function
|
|
5145
|
+
function ms(d) {
|
|
4995
5146
|
return d;
|
|
4996
5147
|
}
|
|
4997
|
-
var
|
|
5148
|
+
var fs = function(t, e, s, i) {
|
|
4998
5149
|
if (!(0 <= t && t <= 1 && 0 <= s && s <= 1))
|
|
4999
5150
|
throw new Error("bezier x values must be in [0, 1] range");
|
|
5000
5151
|
if (t === e && s === i)
|
|
5001
|
-
return
|
|
5002
|
-
for (var n =
|
|
5003
|
-
n[r] =
|
|
5152
|
+
return ms;
|
|
5153
|
+
for (var n = hs ? new Float32Array(lt) : new Array(lt), r = 0; r < lt; ++r)
|
|
5154
|
+
n[r] = wt(r * xt, t, s);
|
|
5004
5155
|
function a(c) {
|
|
5005
|
-
for (var
|
|
5006
|
-
|
|
5007
|
-
--
|
|
5008
|
-
var
|
|
5009
|
-
return u >=
|
|
5010
|
-
}
|
|
5011
|
-
return function(
|
|
5012
|
-
return
|
|
5156
|
+
for (var h = 0, o = 1, l = lt - 1; o !== l && n[o] <= c; ++o)
|
|
5157
|
+
h += xt;
|
|
5158
|
+
--o;
|
|
5159
|
+
var m = (c - n[o]) / (n[o + 1] - n[o]), g = h + m * xt, u = oe(g, t, s);
|
|
5160
|
+
return u >= as ? ds(c, g, t, s) : u === 0 ? g : ls(c, h, h + xt, t, s);
|
|
5161
|
+
}
|
|
5162
|
+
return function(h) {
|
|
5163
|
+
return h === 0 ? 0 : h === 1 ? 1 : wt(a(h), e, i);
|
|
5013
5164
|
};
|
|
5014
5165
|
};
|
|
5015
|
-
const
|
|
5016
|
-
function
|
|
5166
|
+
const he = /* @__PURE__ */ ns(fs);
|
|
5167
|
+
function ps() {
|
|
5017
5168
|
return [
|
|
5018
5169
|
1,
|
|
5019
5170
|
0,
|
|
@@ -5033,7 +5184,7 @@ function Xe() {
|
|
|
5033
5184
|
1
|
|
5034
5185
|
];
|
|
5035
5186
|
}
|
|
5036
|
-
function
|
|
5187
|
+
function gs(d, t = 1, e = { x: 0, y: 0 }) {
|
|
5037
5188
|
const [s, i] = [e.x, e.y];
|
|
5038
5189
|
return [
|
|
5039
5190
|
d[0] * t,
|
|
@@ -5054,36 +5205,36 @@ function Ge(d, t = 1, e = { x: 0, y: 0 }) {
|
|
|
5054
5205
|
d[15]
|
|
5055
5206
|
];
|
|
5056
5207
|
}
|
|
5057
|
-
function
|
|
5208
|
+
function us(d, t = 4) {
|
|
5058
5209
|
const e = (s, i) => s.toFixed(t);
|
|
5059
5210
|
return `matrix3d(${d.map(e).join(", ")})`;
|
|
5060
5211
|
}
|
|
5061
|
-
const
|
|
5062
|
-
let
|
|
5063
|
-
function
|
|
5064
|
-
let d =
|
|
5212
|
+
const zt = [], _t = [];
|
|
5213
|
+
let Ft = !1;
|
|
5214
|
+
function ys() {
|
|
5215
|
+
let d = _t.shift();
|
|
5065
5216
|
for (; d; ) {
|
|
5066
5217
|
try {
|
|
5067
5218
|
d.resolve(d.task());
|
|
5068
5219
|
} catch (t) {
|
|
5069
5220
|
d.reject(t);
|
|
5070
5221
|
}
|
|
5071
|
-
d =
|
|
5222
|
+
d = _t.shift();
|
|
5072
5223
|
}
|
|
5073
|
-
for (d =
|
|
5224
|
+
for (d = zt.shift(); d; ) {
|
|
5074
5225
|
try {
|
|
5075
5226
|
d.resolve(d.task());
|
|
5076
5227
|
} catch (t) {
|
|
5077
5228
|
d.reject(t);
|
|
5078
5229
|
}
|
|
5079
|
-
d =
|
|
5230
|
+
d = zt.shift();
|
|
5080
5231
|
}
|
|
5081
|
-
|
|
5232
|
+
Ft = !1;
|
|
5082
5233
|
}
|
|
5083
|
-
function
|
|
5084
|
-
|
|
5234
|
+
function le() {
|
|
5235
|
+
Ft || (Ft = !0, requestAnimationFrame(ys));
|
|
5085
5236
|
}
|
|
5086
|
-
function
|
|
5237
|
+
function Ms(d) {
|
|
5087
5238
|
const t = {
|
|
5088
5239
|
task: d,
|
|
5089
5240
|
resolve: () => {
|
|
@@ -5093,9 +5244,9 @@ function Qe(d) {
|
|
|
5093
5244
|
}, e = new Promise((s, i) => {
|
|
5094
5245
|
t.resolve = s, t.reject = i;
|
|
5095
5246
|
});
|
|
5096
|
-
return
|
|
5247
|
+
return zt.push(t), le(), e;
|
|
5097
5248
|
}
|
|
5098
|
-
function
|
|
5249
|
+
function jt(d) {
|
|
5099
5250
|
const t = {
|
|
5100
5251
|
task: d,
|
|
5101
5252
|
resolve: () => {
|
|
@@ -5105,17 +5256,17 @@ function Ct(d) {
|
|
|
5105
5256
|
}, e = new Promise((s, i) => {
|
|
5106
5257
|
t.resolve = s, t.reject = i;
|
|
5107
5258
|
});
|
|
5108
|
-
return
|
|
5259
|
+
return _t.push(t), le(), e;
|
|
5109
5260
|
}
|
|
5110
|
-
const
|
|
5111
|
-
function
|
|
5261
|
+
const Ts = /^[\p{Unified_Ideograph}\u0800-\u9FFC]+$/u, bt = 32, de = (d, t) => (e) => Math.min(1, Math.max(0, (e - d) / (t - d))), Rt = 0.5, xs = de(0, Rt), bs = de(Rt, 1), Es = he(0.2, 0.4, 0.58, 1), Ss = he(0.3, 0, 0.58, 1), ws = (d) => (t) => t < d ? Es(xs(t)) : 1 - Ss(bs(t));
|
|
5262
|
+
function Zt(d, t = 0, e = "rgba(0,0,0,var(--bright-mask-alpha, 1.0))", s = "rgba(0,0,0,var(--dark-mask-alpha, 1.0))") {
|
|
5112
5263
|
const i = 2 + d + t, n = d / i, r = (1 - n) / 2;
|
|
5113
5264
|
return [
|
|
5114
5265
|
`linear-gradient(to right,${e} ${r * 100}%,${s} ${(r + n) * 100}%)`,
|
|
5115
5266
|
i
|
|
5116
5267
|
];
|
|
5117
5268
|
}
|
|
5118
|
-
function
|
|
5269
|
+
function Ls(d) {
|
|
5119
5270
|
const t = [];
|
|
5120
5271
|
for (const n of d) {
|
|
5121
5272
|
const r = n.word.replace(/\s/g, "").length, a = n.word.split(" ").filter((c) => c.trim().length > 0);
|
|
@@ -5126,17 +5277,17 @@ function ns(d) {
|
|
|
5126
5277
|
endTime: 0
|
|
5127
5278
|
});
|
|
5128
5279
|
let c = 0;
|
|
5129
|
-
for (const
|
|
5130
|
-
const
|
|
5131
|
-
word:
|
|
5280
|
+
for (const h of a) {
|
|
5281
|
+
const o = {
|
|
5282
|
+
word: h,
|
|
5132
5283
|
startTime: n.startTime + c / r * (n.endTime - n.startTime),
|
|
5133
|
-
endTime: n.startTime + (c +
|
|
5284
|
+
endTime: n.startTime + (c + h.length) / r * (n.endTime - n.startTime)
|
|
5134
5285
|
};
|
|
5135
|
-
t.push(
|
|
5286
|
+
t.push(o), t.push({
|
|
5136
5287
|
word: " ",
|
|
5137
5288
|
startTime: 0,
|
|
5138
5289
|
endTime: 0
|
|
5139
|
-
}), c +=
|
|
5290
|
+
}), c += h.length;
|
|
5140
5291
|
}
|
|
5141
5292
|
n.word.endsWith(" ") || t.pop();
|
|
5142
5293
|
} else
|
|
@@ -5148,19 +5299,19 @@ function ns(d) {
|
|
|
5148
5299
|
const i = [];
|
|
5149
5300
|
for (const n of t) {
|
|
5150
5301
|
const r = n.word;
|
|
5151
|
-
e.push(r), s.push(n), r.length > 0 && r.trim().length === 0 ? (e.pop(), s.pop(), s.length === 1 ? i.push(s[0]) : s.length > 1 && i.push(s), i.push(n), e = [], s = []) : (!/^\s*[^\s]*\s*$/.test(e.join("")) ||
|
|
5302
|
+
e.push(r), s.push(n), r.length > 0 && r.trim().length === 0 ? (e.pop(), s.pop(), s.length === 1 ? i.push(s[0]) : s.length > 1 && i.push(s), i.push(n), e = [], s = []) : (!/^\s*[^\s]*\s*$/.test(e.join("")) || Ts.test(r)) && (e.pop(), s.pop(), s.length === 1 ? i.push(s[0]) : s.length > 1 && i.push(s), e = [r], s = [n]);
|
|
5152
5303
|
}
|
|
5153
5304
|
return s.length === 1 ? i.push(s[0]) : i.push(s), i;
|
|
5154
5305
|
}
|
|
5155
|
-
function
|
|
5306
|
+
function ht(d) {
|
|
5156
5307
|
return d.endTime - d.startTime >= 1e3 && d.word.trim().length <= 7 && d.word.trim().length > 1;
|
|
5157
5308
|
}
|
|
5158
|
-
class
|
|
5309
|
+
class Ps extends MouseEvent {
|
|
5159
5310
|
constructor(t, e) {
|
|
5160
5311
|
super(e.type, e), this.line = t;
|
|
5161
5312
|
}
|
|
5162
5313
|
}
|
|
5163
|
-
function
|
|
5314
|
+
function vs(d) {
|
|
5164
5315
|
const t = d.match(/matrix\(([^)]+)\)/);
|
|
5165
5316
|
if (t) {
|
|
5166
5317
|
const e = t[1].split(", "), s = Number.parseFloat(e[0]), i = Number.parseFloat(e[3]);
|
|
@@ -5168,7 +5319,7 @@ function as(d) {
|
|
|
5168
5319
|
}
|
|
5169
5320
|
return 1;
|
|
5170
5321
|
}
|
|
5171
|
-
class
|
|
5322
|
+
class zs extends EventTarget {
|
|
5172
5323
|
constructor(e, s = {
|
|
5173
5324
|
words: [],
|
|
5174
5325
|
translatedLyric: "",
|
|
@@ -5179,36 +5330,36 @@ class cs extends EventTarget {
|
|
|
5179
5330
|
isDuet: !1
|
|
5180
5331
|
}) {
|
|
5181
5332
|
super();
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5333
|
+
f(this, "element", document.createElement("div"));
|
|
5334
|
+
f(this, "left", 0);
|
|
5335
|
+
f(this, "top", 0);
|
|
5336
|
+
f(this, "scale", 1);
|
|
5337
|
+
f(this, "blur", 0);
|
|
5338
|
+
f(this, "delay", 0);
|
|
5339
|
+
f(this, "splittedWords", []);
|
|
5189
5340
|
// 由 LyricPlayer 来设置
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
posX: new
|
|
5193
|
-
posY: new
|
|
5194
|
-
scale: new
|
|
5341
|
+
f(this, "lineSize", [0, 0]);
|
|
5342
|
+
f(this, "lineTransforms", {
|
|
5343
|
+
posX: new mt(0),
|
|
5344
|
+
posY: new mt(0),
|
|
5345
|
+
scale: new mt(100)
|
|
5195
5346
|
});
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
const s = new
|
|
5347
|
+
f(this, "listenersMap", /* @__PURE__ */ new Map());
|
|
5348
|
+
f(this, "onMouseEvent", (e) => {
|
|
5349
|
+
const s = new Ps(this, e);
|
|
5199
5350
|
for (const i of this.listenersMap.get(e.type) ?? [])
|
|
5200
5351
|
i.call(this, s);
|
|
5201
5352
|
if (!this.dispatchEvent(s) || s.defaultPrevented)
|
|
5202
5353
|
return e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation(), !1;
|
|
5203
5354
|
});
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5355
|
+
f(this, "isEnabled", !1);
|
|
5356
|
+
f(this, "hasFaded", !1);
|
|
5357
|
+
f(this, "lastWord");
|
|
5358
|
+
f(this, "_hide", !0);
|
|
5359
|
+
f(this, "_prevParentEl", null);
|
|
5360
|
+
f(this, "lastStyle", "");
|
|
5361
|
+
f(this, "maskImageDirty", !1);
|
|
5362
|
+
f(this, "markImageDirtyPromises", []);
|
|
5212
5363
|
this.lyricPlayer = e, this.lyricLine = s, this._prevParentEl = e.getElement(), this.element.setAttribute("class", N.lyricLine), this.lyricLine.isBG && this.element.classList.add(N.lyricBgLine), this.lyricLine.isDuet && this.element.classList.add(N.lyricDuetLine), this.element.appendChild(document.createElement("div")), this.element.appendChild(document.createElement("div")), this.element.appendChild(document.createElement("div"));
|
|
5213
5364
|
const i = this.element.children[0], n = this.element.children[1], r = this.element.children[2];
|
|
5214
5365
|
i.setAttribute("class", N.lyricMainLine), n.setAttribute("class", N.lyricSubLine), r.setAttribute("class", N.lyricSubLine), this.rebuildElement(), this.rebuildStyle();
|
|
@@ -5318,35 +5469,35 @@ class cs extends EventTarget {
|
|
|
5318
5469
|
e.innerText = this.lyricLine.words.map((r) => r.word).join(""), s.innerText = this.lyricLine.translatedLyric, i.innerText = this.lyricLine.romanLyric;
|
|
5319
5470
|
return;
|
|
5320
5471
|
}
|
|
5321
|
-
const n =
|
|
5472
|
+
const n = Ls(this.lyricLine.words);
|
|
5322
5473
|
e.innerHTML = "";
|
|
5323
5474
|
for (const r of n)
|
|
5324
5475
|
if (Array.isArray(r)) {
|
|
5325
5476
|
if (r.length === 0) continue;
|
|
5326
5477
|
const a = r.reduce(
|
|
5327
|
-
(l,
|
|
5478
|
+
(l, m) => (l.endTime = Math.max(l.endTime, m.endTime), l.startTime = Math.min(l.startTime, m.startTime), l.word += m.word, l),
|
|
5328
5479
|
{
|
|
5329
5480
|
word: "",
|
|
5330
5481
|
startTime: Number.POSITIVE_INFINITY,
|
|
5331
5482
|
endTime: Number.NEGATIVE_INFINITY
|
|
5332
5483
|
}
|
|
5333
|
-
), c = r.map((l) =>
|
|
5334
|
-
|
|
5335
|
-
const
|
|
5484
|
+
), c = r.map((l) => ht(l)).reduce((l, m) => l || m, ht(a)), h = document.createElement("span");
|
|
5485
|
+
h.classList.add(N.emphasizeWrapper);
|
|
5486
|
+
const o = [];
|
|
5336
5487
|
for (const l of r) {
|
|
5337
|
-
const
|
|
5488
|
+
const m = document.createElement("span");
|
|
5338
5489
|
if (c) {
|
|
5339
|
-
|
|
5490
|
+
m.classList.add(N.emphasize);
|
|
5340
5491
|
const g = [];
|
|
5341
5492
|
for (const M of l.word.trim().split("")) {
|
|
5342
5493
|
const p = document.createElement("span");
|
|
5343
|
-
p.innerText = M, g.push(p),
|
|
5494
|
+
p.innerText = M, g.push(p), o.push(p), m.appendChild(p);
|
|
5344
5495
|
}
|
|
5345
5496
|
const u = {
|
|
5346
5497
|
...l,
|
|
5347
|
-
mainElement:
|
|
5498
|
+
mainElement: m,
|
|
5348
5499
|
subElements: g,
|
|
5349
|
-
elementAnimations: [this.initFloatAnimation(l,
|
|
5500
|
+
elementAnimations: [this.initFloatAnimation(l, m)],
|
|
5350
5501
|
maskAnimations: [],
|
|
5351
5502
|
width: 0,
|
|
5352
5503
|
height: 0,
|
|
@@ -5355,31 +5506,31 @@ class cs extends EventTarget {
|
|
|
5355
5506
|
};
|
|
5356
5507
|
this.splittedWords.push(u);
|
|
5357
5508
|
} else
|
|
5358
|
-
|
|
5509
|
+
m.innerText = l.word, this.splittedWords.push({
|
|
5359
5510
|
...l,
|
|
5360
|
-
mainElement:
|
|
5511
|
+
mainElement: m,
|
|
5361
5512
|
subElements: [],
|
|
5362
|
-
elementAnimations: [this.initFloatAnimation(l,
|
|
5513
|
+
elementAnimations: [this.initFloatAnimation(l, m)],
|
|
5363
5514
|
maskAnimations: [],
|
|
5364
5515
|
width: 0,
|
|
5365
5516
|
height: 0,
|
|
5366
5517
|
padding: 0,
|
|
5367
5518
|
shouldEmphasize: c
|
|
5368
5519
|
});
|
|
5369
|
-
|
|
5520
|
+
h.appendChild(m);
|
|
5370
5521
|
}
|
|
5371
5522
|
c && this.splittedWords[this.splittedWords.length - 1].elementAnimations.push(
|
|
5372
5523
|
...this.initEmphasizeAnimation(
|
|
5373
5524
|
a,
|
|
5374
|
-
|
|
5525
|
+
o,
|
|
5375
5526
|
a.endTime - a.startTime,
|
|
5376
5527
|
a.startTime - this.lyricLine.startTime
|
|
5377
5528
|
)
|
|
5378
|
-
), a.word.trimStart() !== a.word && e.appendChild(document.createTextNode(" ")), e.appendChild(
|
|
5529
|
+
), a.word.trimStart() !== a.word && e.appendChild(document.createTextNode(" ")), e.appendChild(h), a.word.trimEnd() !== a.word && ht(a) && e.appendChild(document.createTextNode(" "));
|
|
5379
5530
|
} else if (r.word.trim().length === 0)
|
|
5380
5531
|
e.appendChild(document.createTextNode(" "));
|
|
5381
5532
|
else {
|
|
5382
|
-
const a =
|
|
5533
|
+
const a = ht(r), c = document.createElement("span"), h = {
|
|
5383
5534
|
...r,
|
|
5384
5535
|
mainElement: c,
|
|
5385
5536
|
subElements: [],
|
|
@@ -5390,26 +5541,26 @@ class cs extends EventTarget {
|
|
|
5390
5541
|
padding: 0,
|
|
5391
5542
|
shouldEmphasize: a
|
|
5392
5543
|
};
|
|
5393
|
-
if (
|
|
5544
|
+
if (ht(r)) {
|
|
5394
5545
|
c.classList.add(N.emphasize);
|
|
5395
|
-
const
|
|
5396
|
-
for (const
|
|
5546
|
+
const o = [];
|
|
5547
|
+
for (const m of r.word.trim().split("")) {
|
|
5397
5548
|
const g = document.createElement("span");
|
|
5398
|
-
g.innerText =
|
|
5549
|
+
g.innerText = m, o.push(g), c.appendChild(g);
|
|
5399
5550
|
}
|
|
5400
|
-
|
|
5401
|
-
const l = Math.abs(
|
|
5402
|
-
|
|
5551
|
+
h.subElements = o;
|
|
5552
|
+
const l = Math.abs(h.endTime - h.startTime);
|
|
5553
|
+
h.elementAnimations.push(
|
|
5403
5554
|
...this.initEmphasizeAnimation(
|
|
5404
5555
|
r,
|
|
5405
|
-
|
|
5556
|
+
o,
|
|
5406
5557
|
l,
|
|
5407
|
-
|
|
5558
|
+
h.startTime - this.lyricLine.startTime
|
|
5408
5559
|
)
|
|
5409
5560
|
);
|
|
5410
5561
|
} else
|
|
5411
5562
|
c.innerText = r.word.trim();
|
|
5412
|
-
r.word.trimStart() !== r.word && e.appendChild(document.createTextNode(" ")), e.appendChild(c), r.word.trimEnd() !== r.word && e.appendChild(document.createTextNode(" ")), this.splittedWords.push(
|
|
5563
|
+
r.word.trimStart() !== r.word && e.appendChild(document.createTextNode(" ")), e.appendChild(c), r.word.trimEnd() !== r.word && e.appendChild(document.createTextNode(" ")), this.splittedWords.push(h);
|
|
5413
5564
|
}
|
|
5414
5565
|
s.innerText = this.lyricLine.translatedLyric, i.innerText = this.lyricLine.romanLyric;
|
|
5415
5566
|
}
|
|
@@ -5441,25 +5592,25 @@ class cs extends EventTarget {
|
|
|
5441
5592
|
// 为了避免产生锯齿抖动感,使用 matrix3d 来实现缩放和位移
|
|
5442
5593
|
initEmphasizeAnimation(e, s, i, n) {
|
|
5443
5594
|
const r = Math.max(0, n);
|
|
5444
|
-
let a = Math.max(1e3, i), c = [],
|
|
5445
|
-
|
|
5446
|
-
let
|
|
5447
|
-
|
|
5595
|
+
let a = Math.max(1e3, i), c = [], h = a / 2e3;
|
|
5596
|
+
h = h > 1 ? Math.sqrt(h) : h ** 3;
|
|
5597
|
+
let o = a / 3e3;
|
|
5598
|
+
o = o > 1 ? Math.sqrt(o) : o ** 3, h *= 0.6, o *= 0.5, this.lyricLine.words.length > 0 && e.word.includes(
|
|
5448
5599
|
this.lyricLine.words[this.lyricLine.words.length - 1].word
|
|
5449
|
-
) && (
|
|
5450
|
-
const l = Number.isFinite(a) ? a : 0,
|
|
5600
|
+
) && (h *= 1.6, o *= 1.5, a *= 1.2), h = Math.min(1.2, h), o = Math.min(0.8, o);
|
|
5601
|
+
const l = Number.isFinite(a) ? a : 0, m = ws(Rt);
|
|
5451
5602
|
return c = s.flatMap((g, u, M) => {
|
|
5452
|
-
const p = r + a / 2.5 / M.length * u, T = [], x = new Array(
|
|
5453
|
-
const z = (S + 1) /
|
|
5603
|
+
const p = r + a / 2.5 / M.length * u, T = [], x = new Array(bt).fill(0).map((w, S) => {
|
|
5604
|
+
const z = (S + 1) / bt, v = m(z), F = m(z) * o, P = gs(ps(), 1 + v * 0.1 * h), k = -v * 0.03 * h * (M.length / 2 - u), I = -v * 0.025 * h;
|
|
5454
5605
|
return {
|
|
5455
5606
|
offset: z,
|
|
5456
|
-
transform: `${
|
|
5457
|
-
|
|
5607
|
+
transform: `${us(
|
|
5608
|
+
P,
|
|
5458
5609
|
4
|
|
5459
|
-
)} translate(${
|
|
5610
|
+
)} translate(${k}em, ${I}em)`,
|
|
5460
5611
|
textShadow: `0 0 ${Math.min(
|
|
5461
5612
|
0.3,
|
|
5462
|
-
|
|
5613
|
+
o * 0.3
|
|
5463
5614
|
)}em rgba(255, 255, 255, ${F})`
|
|
5464
5615
|
};
|
|
5465
5616
|
}), L = g.animate(x, {
|
|
@@ -5474,12 +5625,12 @@ class cs extends EventTarget {
|
|
|
5474
5625
|
L.onfinish = () => {
|
|
5475
5626
|
L.pause();
|
|
5476
5627
|
}, L.pause(), T.push(L);
|
|
5477
|
-
const b = new Array(
|
|
5478
|
-
const z = (S + 1) /
|
|
5479
|
-
let
|
|
5480
|
-
return this.lyricLine.isBG && (
|
|
5628
|
+
const b = new Array(bt).fill(0).map((w, S) => {
|
|
5629
|
+
const z = (S + 1) / bt;
|
|
5630
|
+
let v = Math.sin(z * Math.PI);
|
|
5631
|
+
return this.lyricLine.isBG && (v *= 2), {
|
|
5481
5632
|
offset: z,
|
|
5482
|
-
transform: `translateY(${-
|
|
5633
|
+
transform: `translateY(${-v * 0.05}em)`
|
|
5483
5634
|
};
|
|
5484
5635
|
}), E = g.animate(b, {
|
|
5485
5636
|
duration: l * 1.4,
|
|
@@ -5510,16 +5661,16 @@ class cs extends EventTarget {
|
|
|
5510
5661
|
}
|
|
5511
5662
|
async updateMaskImage() {
|
|
5512
5663
|
const e = this.markImageDirtyPromises;
|
|
5513
|
-
this.markImageDirtyPromises = [], this.maskImageDirty = !1, this._hide && await
|
|
5664
|
+
this.markImageDirtyPromises = [], this.maskImageDirty = !1, this._hide && await jt(() => {
|
|
5514
5665
|
this._prevParentEl && this._prevParentEl.appendChild(this.element), this.element.style.display = "", this.element.style.visibility = "hidden";
|
|
5515
5666
|
});
|
|
5516
5667
|
for (const s of this.splittedWords) {
|
|
5517
5668
|
const i = s.mainElement;
|
|
5518
|
-
i ? await
|
|
5669
|
+
i ? await Ms(() => {
|
|
5519
5670
|
s.padding = Number.parseFloat(getComputedStyle(i).paddingLeft), s.width = i.clientWidth - s.padding * 2, s.height = i.clientHeight - s.padding * 2;
|
|
5520
5671
|
}) : (s.width = 0, s.height = 0, s.padding = 0);
|
|
5521
5672
|
}
|
|
5522
|
-
this.lyricPlayer.supportMaskImage ? this.generateWebAnimationBasedMaskImage() : this.generateCalcBasedMaskImage(), this._hide && await
|
|
5673
|
+
this.lyricPlayer.supportMaskImage ? this.generateWebAnimationBasedMaskImage() : this.generateCalcBasedMaskImage(), this._hide && await jt(() => {
|
|
5523
5674
|
this._prevParentEl && this.element.remove(), this.element.style.display = "none", this.element.style.visibility = "";
|
|
5524
5675
|
});
|
|
5525
5676
|
for (const s of e)
|
|
@@ -5530,12 +5681,12 @@ class cs extends EventTarget {
|
|
|
5530
5681
|
const s = e.mainElement;
|
|
5531
5682
|
if (s) {
|
|
5532
5683
|
e.width = s.clientWidth, e.height = s.clientHeight;
|
|
5533
|
-
const i = e.height * this.lyricPlayer.wordFadeWidth, [n, r] =
|
|
5684
|
+
const i = e.height * this.lyricPlayer.wordFadeWidth, [n, r] = Zt(
|
|
5534
5685
|
i / e.width
|
|
5535
5686
|
), a = `${r * 100}% 100%`;
|
|
5536
5687
|
this.lyricPlayer.supportMaskImage ? (s.style.maskImage = n, s.style.maskRepeat = "no-repeat", s.style.maskOrigin = "left", s.style.maskSize = a) : (s.style.webkitMaskImage = n, s.style.webkitMaskRepeat = "no-repeat", s.style.webkitMaskOrigin = "left", s.style.webkitMaskSize = a);
|
|
5537
|
-
const c = e.width + i,
|
|
5538
|
-
s.style.maskPosition =
|
|
5688
|
+
const c = e.width + i, h = `clamp(${-c}px,calc(${-c}px + (var(--amll-player-time) - ${e.startTime})*${c / Math.abs(e.endTime - e.startTime)}px),0px) 0px, left top`;
|
|
5689
|
+
s.style.maskPosition = h, s.style.webkitMaskPosition = h;
|
|
5539
5690
|
}
|
|
5540
5691
|
}
|
|
5541
5692
|
}
|
|
@@ -5547,35 +5698,35 @@ class cs extends EventTarget {
|
|
|
5547
5698
|
this.splittedWords.forEach((s, i) => {
|
|
5548
5699
|
const n = s.mainElement;
|
|
5549
5700
|
if (n) {
|
|
5550
|
-
const r = s.height * this.lyricPlayer.wordFadeWidth, [a, c] =
|
|
5701
|
+
const r = s.height * this.lyricPlayer.wordFadeWidth, [a, c] = Zt(
|
|
5551
5702
|
r / (s.width + s.padding * 2)
|
|
5552
|
-
),
|
|
5553
|
-
this.lyricPlayer.supportMaskImage ? (n.style.maskImage = a, n.style.maskRepeat = "no-repeat", n.style.maskOrigin = "left", n.style.maskSize =
|
|
5554
|
-
const
|
|
5555
|
-
let g = -
|
|
5703
|
+
), h = `${c * 100}% 100%`;
|
|
5704
|
+
this.lyricPlayer.supportMaskImage ? (n.style.maskImage = a, n.style.maskRepeat = "no-repeat", n.style.maskOrigin = "left", n.style.maskSize = h) : (n.style.webkitMaskImage = a, n.style.webkitMaskRepeat = "no-repeat", n.style.webkitMaskOrigin = "left", n.style.webkitMaskSize = h);
|
|
5705
|
+
const o = this.splittedWords.slice(0, i).reduce((b, E) => b + E.width, 0) + (this.splittedWords[0] ? r : 0), l = -(s.width + s.padding * 2 + r), m = (b) => Math.max(l, Math.min(0, b));
|
|
5706
|
+
let g = -o - s.width - s.padding - r, u = 0;
|
|
5556
5707
|
const M = [];
|
|
5557
5708
|
let p = g, T = 0;
|
|
5558
5709
|
const x = () => {
|
|
5559
5710
|
const b = "cubic-bezier(.33,.12,.83,.9)", E = g - p, w = Math.max(0, Math.min(1, u)), S = w - T, z = Math.abs(S / E);
|
|
5560
5711
|
if (g > l && p < l) {
|
|
5561
|
-
const
|
|
5562
|
-
offset: T +
|
|
5563
|
-
maskPosition:
|
|
5712
|
+
const P = Math.abs(p - l) * z, k = `${m(p)}px 0`, I = {
|
|
5713
|
+
offset: T + P,
|
|
5714
|
+
maskPosition: k,
|
|
5564
5715
|
easing: b
|
|
5565
5716
|
};
|
|
5566
|
-
M.push(
|
|
5717
|
+
M.push(I);
|
|
5567
5718
|
}
|
|
5568
5719
|
if (g > 0 && p < 0) {
|
|
5569
|
-
const
|
|
5570
|
-
offset: T +
|
|
5571
|
-
maskPosition:
|
|
5720
|
+
const P = Math.abs(p) * z, k = `${m(g)}px 0`, I = {
|
|
5721
|
+
offset: T + P,
|
|
5722
|
+
maskPosition: k,
|
|
5572
5723
|
easing: b
|
|
5573
5724
|
};
|
|
5574
|
-
M.push(
|
|
5725
|
+
M.push(I);
|
|
5575
5726
|
}
|
|
5576
|
-
const
|
|
5727
|
+
const v = `${m(g)}px 0`, F = {
|
|
5577
5728
|
offset: w,
|
|
5578
|
-
maskPosition:
|
|
5729
|
+
maskPosition: v,
|
|
5579
5730
|
easing: b
|
|
5580
5731
|
};
|
|
5581
5732
|
M.push(F), p = g, T = w;
|
|
@@ -5611,21 +5762,21 @@ class cs extends EventTarget {
|
|
|
5611
5762
|
getElement() {
|
|
5612
5763
|
return this.element;
|
|
5613
5764
|
}
|
|
5614
|
-
setTransform(e = this.left, s = this.top, i = this.scale, n = 1, r = 0.4, a = 0, c = !1,
|
|
5615
|
-
const
|
|
5616
|
-
this.left = e, this.top = s, this.scale = i, this.delay =
|
|
5617
|
-
const
|
|
5618
|
-
if (
|
|
5765
|
+
setTransform(e = this.left, s = this.top, i = this.scale, n = 1, r = 0.4, a = 0, c = !1, h = 0) {
|
|
5766
|
+
const o = this.isInSight, l = this.lyricPlayer.getEnableSpring();
|
|
5767
|
+
this.left = e, this.top = s, this.scale = i, this.delay = h * 1e3 | 0;
|
|
5768
|
+
const m = this.element.children[0], g = this.element.children[1], u = this.element.children[2];
|
|
5769
|
+
if (m.style.opacity = `${n}`, g.style.opacity = `${r}`, u.style.opacity = `${r}`, c || !l) {
|
|
5619
5770
|
if (this.blur = Math.min(32, a), c && this.element.classList.add(N.tmpDisableTransition), this.lineTransforms.posX.setPosition(e), this.lineTransforms.posY.setPosition(s), this.lineTransforms.scale.setPosition(i), l)
|
|
5620
5771
|
this.rebuildStyle();
|
|
5621
5772
|
else {
|
|
5622
5773
|
const M = this.isInSight;
|
|
5623
|
-
|
|
5774
|
+
o || M ? this.show() : this.hide();
|
|
5624
5775
|
}
|
|
5625
5776
|
c && requestAnimationFrame(() => {
|
|
5626
5777
|
this.element.classList.remove(N.tmpDisableTransition);
|
|
5627
5778
|
});
|
|
5628
|
-
} else if (this.lineTransforms.posX.setTargetPosition(e,
|
|
5779
|
+
} else if (this.lineTransforms.posX.setTargetPosition(e, h), this.lineTransforms.posY.setTargetPosition(s, h), this.lineTransforms.scale.setTargetPosition(i), this.blur !== Math.min(32, a)) {
|
|
5629
5780
|
this.blur = Math.min(32, a);
|
|
5630
5781
|
const M = a.toFixed(3);
|
|
5631
5782
|
this.element.style.filter = `blur(${M}px)`;
|
|
@@ -5654,7 +5805,7 @@ class cs extends EventTarget {
|
|
|
5654
5805
|
) * 0.2 + 0.2}`
|
|
5655
5806
|
);
|
|
5656
5807
|
else {
|
|
5657
|
-
const i = window.getComputedStyle(this.element).transform, n =
|
|
5808
|
+
const i = window.getComputedStyle(this.element).transform, n = vs(i);
|
|
5658
5809
|
this.element.style.setProperty(
|
|
5659
5810
|
"--bright-mask-alpha",
|
|
5660
5811
|
`${Math.max(0, Math.min(1, (n - 0.97) / 0.03)) * 0.8 + 0.2}`
|
|
@@ -5668,8 +5819,8 @@ class cs extends EventTarget {
|
|
|
5668
5819
|
return `[位移: ${this.left}, ${this.top}; 缩放: ${this.scale}; 延时: ${this.delay}]`;
|
|
5669
5820
|
}
|
|
5670
5821
|
get isInSight() {
|
|
5671
|
-
const e = this.lineTransforms.posX.getCurrentPosition(), s = this.lineTransforms.posY.getCurrentPosition(), i = this.lineSize[0], n = this.lineSize[1], r = e + i, a = s + n, c = this.lyricPlayer.size[0],
|
|
5672
|
-
return !(e > c + i || r < -i || s >
|
|
5822
|
+
const e = this.lineTransforms.posX.getCurrentPosition(), s = this.lineTransforms.posY.getCurrentPosition(), i = this.lineSize[0], n = this.lineSize[1], r = e + i, a = s + n, c = this.lyricPlayer.size[0], h = this.lyricPlayer.size[1];
|
|
5823
|
+
return !(e > c + i || r < -i || s > h + n || a < -n);
|
|
5673
5824
|
}
|
|
5674
5825
|
disposeElements() {
|
|
5675
5826
|
var e, s;
|
|
@@ -5688,43 +5839,43 @@ class cs extends EventTarget {
|
|
|
5688
5839
|
this.disposeElements(), this.element.remove();
|
|
5689
5840
|
}
|
|
5690
5841
|
}
|
|
5691
|
-
class
|
|
5842
|
+
class _s extends MouseEvent {
|
|
5692
5843
|
constructor(t, e, s) {
|
|
5693
5844
|
super(`line-${s.type}`, s), this.lineIndex = t, this.line = e;
|
|
5694
5845
|
}
|
|
5695
5846
|
}
|
|
5696
|
-
class
|
|
5847
|
+
class qs extends EventTarget {
|
|
5697
5848
|
constructor() {
|
|
5698
5849
|
super();
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5850
|
+
f(this, "element", document.createElement("div"));
|
|
5851
|
+
f(this, "currentTime", 0);
|
|
5852
|
+
f(this, "lastCurrentTime", 0);
|
|
5853
|
+
f(this, "lyricLines", []);
|
|
5854
|
+
f(this, "processedLines", []);
|
|
5855
|
+
f(this, "lyricLinesEl", []);
|
|
5856
|
+
f(this, "lyricLinesSize", /* @__PURE__ */ new WeakMap());
|
|
5857
|
+
f(this, "lyricLinesIndexes", /* @__PURE__ */ new WeakMap());
|
|
5858
|
+
f(this, "hotLines", /* @__PURE__ */ new Set());
|
|
5859
|
+
f(this, "bufferedLines", /* @__PURE__ */ new Set());
|
|
5860
|
+
f(this, "scrollToIndex", 0);
|
|
5861
|
+
f(this, "_wordFadeWidth", 0.5);
|
|
5862
|
+
f(this, "allowScroll", !0);
|
|
5863
|
+
f(this, "scrolledHandler", 0);
|
|
5864
|
+
f(this, "isScrolled", !1);
|
|
5865
|
+
f(this, "isSeeking", !1);
|
|
5866
|
+
f(this, "initializeSeeking", !1);
|
|
5867
|
+
f(this, "invokedByScrollEvent", !1);
|
|
5868
|
+
f(this, "scrollOffset", 0);
|
|
5869
|
+
f(this, "hidePassedLines", !1);
|
|
5870
|
+
f(this, "debounceCalcLayout", Xt(async () => {
|
|
5720
5871
|
this.calcLayout(!0, !0), this.lyricLinesEl.forEach((e, s) => {
|
|
5721
5872
|
e.markMaskImageDirty().then(() => {
|
|
5722
5873
|
this.hotLines.has(s) && e.enable(this.currentTime);
|
|
5723
5874
|
});
|
|
5724
5875
|
});
|
|
5725
5876
|
}, 5));
|
|
5726
|
-
|
|
5727
|
-
|
|
5877
|
+
f(this, "resizeObserver", new ResizeObserver(
|
|
5878
|
+
Xt(
|
|
5728
5879
|
(e) => {
|
|
5729
5880
|
const s = e[0].contentRect;
|
|
5730
5881
|
this.size[0] = s.width, this.size[1] = s.height;
|
|
@@ -5741,17 +5892,17 @@ class Ts extends EventTarget {
|
|
|
5741
5892
|
5
|
|
5742
5893
|
)
|
|
5743
5894
|
));
|
|
5744
|
-
|
|
5895
|
+
f(this, "posXSpringParams", {
|
|
5745
5896
|
mass: 1,
|
|
5746
5897
|
damping: 10,
|
|
5747
5898
|
stiffness: 100
|
|
5748
5899
|
});
|
|
5749
|
-
|
|
5900
|
+
f(this, "posYSpringParams", {
|
|
5750
5901
|
mass: 0.9,
|
|
5751
5902
|
damping: 15,
|
|
5752
5903
|
stiffness: 90
|
|
5753
5904
|
});
|
|
5754
|
-
|
|
5905
|
+
f(this, "scaleSpringParams", {
|
|
5755
5906
|
mass: 2,
|
|
5756
5907
|
damping: 25,
|
|
5757
5908
|
stiffness: 100
|
|
@@ -5761,61 +5912,61 @@ class Ts extends EventTarget {
|
|
|
5761
5912
|
// damping: 25,
|
|
5762
5913
|
// stiffness: 40,
|
|
5763
5914
|
// };
|
|
5764
|
-
|
|
5915
|
+
f(this, "scaleForBGSpringParams", {
|
|
5765
5916
|
mass: 1,
|
|
5766
5917
|
damping: 20,
|
|
5767
5918
|
stiffness: 50
|
|
5768
5919
|
});
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
const s = new
|
|
5920
|
+
f(this, "enableBlur", !0);
|
|
5921
|
+
f(this, "enableScale", !0);
|
|
5922
|
+
f(this, "interludeDots");
|
|
5923
|
+
f(this, "interludeDotsSize", [0, 0]);
|
|
5924
|
+
f(this, "bottomLine");
|
|
5925
|
+
f(this, "supportPlusLighter", CSS.supports("mix-blend-mode", "plus-lighter"));
|
|
5926
|
+
f(this, "supportMaskImage", CSS.supports("mask-image", "none"));
|
|
5927
|
+
f(this, "disableSpring", !1);
|
|
5928
|
+
f(this, "alignAnchor", "center");
|
|
5929
|
+
f(this, "alignPosition", 0.35);
|
|
5930
|
+
f(this, "isNonDynamic", !1);
|
|
5931
|
+
f(this, "isNonDuet", !1);
|
|
5932
|
+
f(this, "scrollBoundary", [0, 0]);
|
|
5933
|
+
f(this, "size", [0, 0]);
|
|
5934
|
+
f(this, "innerSize", [0, 0]);
|
|
5935
|
+
f(this, "onLineClickedHandler", (e) => {
|
|
5936
|
+
const s = new _s(
|
|
5786
5937
|
this.lyricLinesIndexes.get(e.line) ?? -1,
|
|
5787
5938
|
e.line,
|
|
5788
5939
|
e
|
|
5789
5940
|
);
|
|
5790
5941
|
this.dispatchEvent(s) || (e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation());
|
|
5791
5942
|
});
|
|
5792
|
-
|
|
5943
|
+
f(this, "_baseFontSize", Number.parseFloat(
|
|
5793
5944
|
getComputedStyle(this.element).fontSize
|
|
5794
5945
|
));
|
|
5795
|
-
|
|
5796
|
-
|
|
5946
|
+
f(this, "isPageVisible", !0);
|
|
5947
|
+
f(this, "onPageShow", () => {
|
|
5797
5948
|
this.isPageVisible = !0, this.setCurrentTime(this.currentTime, !0);
|
|
5798
5949
|
});
|
|
5799
|
-
|
|
5950
|
+
f(this, "onPageHide", () => {
|
|
5800
5951
|
this.isPageVisible = !1;
|
|
5801
5952
|
});
|
|
5802
|
-
this.interludeDots = new
|
|
5803
|
-
let e = 0, s = "none", i = 0, n = 0, r = 0, a = Symbol("amll-scroll"), c = 0,
|
|
5804
|
-
this.element.addEventListener("touchstart", (
|
|
5805
|
-
this.beginScrollHandler() && (
|
|
5806
|
-
}), this.element.addEventListener("touchmove", (
|
|
5953
|
+
this.interludeDots = new is(this), this.bottomLine = new ts(this), this.element.setAttribute("class", "amll-lyric-player"), this.disableSpring && this.element.classList.add(N.disableSpring), this.rebuildStyle(), this.resizeObserver.observe(this.element), this.element.appendChild(this.interludeDots.getElement()), this.element.appendChild(this.bottomLine.getElement()), this.interludeDots.setTransform(0, 200), window.addEventListener("pageshow", this.onPageShow), window.addEventListener("pagehide", this.onPageHide);
|
|
5954
|
+
let e = 0, s = "none", i = 0, n = 0, r = 0, a = Symbol("amll-scroll"), c = 0, h = 0;
|
|
5955
|
+
this.element.addEventListener("touchstart", (o) => {
|
|
5956
|
+
this.beginScrollHandler() && (o.preventDefault(), e = this.scrollOffset, i = o.touches[0].screenY, c = i, n = Date.now(), r = 0);
|
|
5957
|
+
}), this.element.addEventListener("touchmove", (o) => {
|
|
5807
5958
|
if (this.beginScrollHandler()) {
|
|
5808
|
-
|
|
5809
|
-
const l =
|
|
5810
|
-
s !== u ? (s = u, e = this.scrollOffset, i = l, n = Date.now()) : this.scrollOffset = e -
|
|
5959
|
+
o.preventDefault();
|
|
5960
|
+
const l = o.touches[0].screenY, m = l - i, g = l - c, u = g > 0 ? "down" : g < 0 ? "up" : "none";
|
|
5961
|
+
s !== u ? (s = u, e = this.scrollOffset, i = l, n = Date.now()) : this.scrollOffset = e - m, c = l, h = Date.now(), this.limitScrollOffset(), this.calcLayout(!0);
|
|
5811
5962
|
}
|
|
5812
|
-
}), this.element.addEventListener("touchend", (
|
|
5963
|
+
}), this.element.addEventListener("touchend", (o) => {
|
|
5813
5964
|
if (this.beginScrollHandler()) {
|
|
5814
|
-
|
|
5965
|
+
o.preventDefault(), i = 0;
|
|
5815
5966
|
const l = Date.now();
|
|
5816
|
-
if (l -
|
|
5817
|
-
const
|
|
5818
|
-
r = (this.scrollOffset - e) /
|
|
5967
|
+
if (l - h > 100) return this.endScrollHandler();
|
|
5968
|
+
const m = l - n;
|
|
5969
|
+
r = (this.scrollOffset - e) / m * 1e3;
|
|
5819
5970
|
let g = 0;
|
|
5820
5971
|
const u = Symbol("amll-scroll");
|
|
5821
5972
|
a = u;
|
|
@@ -5824,8 +5975,8 @@ class Ts extends EventTarget {
|
|
|
5824
5975
|
};
|
|
5825
5976
|
requestAnimationFrame(M), this.endScrollHandler();
|
|
5826
5977
|
}
|
|
5827
|
-
}), this.element.addEventListener("wheel", (
|
|
5828
|
-
this.beginScrollHandler() && (
|
|
5978
|
+
}), this.element.addEventListener("wheel", (o) => {
|
|
5979
|
+
this.beginScrollHandler() && (o.deltaMode === o.DOM_DELTA_PIXEL ? (this.scrollOffset += o.deltaY, this.limitScrollOffset(), this.calcLayout(!0)) : (this.scrollOffset += o.deltaY * 50, this.limitScrollOffset(), this.calcLayout(!1)), this.endScrollHandler());
|
|
5829
5980
|
});
|
|
5830
5981
|
}
|
|
5831
5982
|
/**
|
|
@@ -5992,64 +6143,35 @@ class Ts extends EventTarget {
|
|
|
5992
6143
|
* @param initialTime 初始时间,默认为 0
|
|
5993
6144
|
*/
|
|
5994
6145
|
setLyricLines(e, s = 0) {
|
|
5995
|
-
for (const
|
|
5996
|
-
for (const
|
|
5997
|
-
|
|
5998
|
-
this.lastCurrentTime = s, this.currentTime = s, this.lyricLines = e;
|
|
5999
|
-
const i
|
|
6000
|
-
|
|
6001
|
-
(n) => n.words.reduce((r, a) => r + a.word.trim().length, 0) > 0
|
|
6002
|
-
).map((n, r, a) => {
|
|
6003
|
-
if (n.isBG)
|
|
6004
|
-
return {
|
|
6005
|
-
...n
|
|
6006
|
-
};
|
|
6007
|
-
if (r === 0)
|
|
6008
|
-
return {
|
|
6009
|
-
...n,
|
|
6010
|
-
startTime: Math.max(n.startTime - i, 0)
|
|
6011
|
-
};
|
|
6012
|
-
const c = a[r - 1], o = a[r - 2];
|
|
6013
|
-
if (c != null && c.isBG && o) {
|
|
6014
|
-
if (o.endTime < n.startTime)
|
|
6015
|
-
return {
|
|
6016
|
-
...n,
|
|
6017
|
-
startTime: Math.max(o.endTime, n.startTime - i) || n.startTime
|
|
6018
|
-
};
|
|
6019
|
-
} else if (c != null && c.endTime && c.endTime < n.startTime)
|
|
6020
|
-
return {
|
|
6021
|
-
...n,
|
|
6022
|
-
startTime: Math.max(c == null ? void 0 : c.endTime, n.startTime - i) || n.startTime
|
|
6023
|
-
};
|
|
6024
|
-
return {
|
|
6025
|
-
...n
|
|
6026
|
-
};
|
|
6027
|
-
}), this.isNonDynamic = !0, this.isNonDuet = !0;
|
|
6028
|
-
for (const n of this.processedLines)
|
|
6029
|
-
if (n.words.length > 1) {
|
|
6146
|
+
for (const i of e)
|
|
6147
|
+
for (const n of i.words)
|
|
6148
|
+
n.word = n.word.replace(/\s+/g, " ");
|
|
6149
|
+
this.lastCurrentTime = s, this.currentTime = s, this.lyricLines = e, this.processedLines = Oe(e), this.isNonDynamic = !0, this.isNonDuet = !0;
|
|
6150
|
+
for (const i of this.processedLines)
|
|
6151
|
+
if (i.words.length > 1) {
|
|
6030
6152
|
this.isNonDynamic = !1;
|
|
6031
6153
|
break;
|
|
6032
6154
|
}
|
|
6033
|
-
for (const
|
|
6034
|
-
if (
|
|
6155
|
+
for (const i of this.processedLines)
|
|
6156
|
+
if (i.isDuet) {
|
|
6035
6157
|
this.isNonDuet = !1;
|
|
6036
6158
|
break;
|
|
6037
6159
|
}
|
|
6038
|
-
this.rebuildStyle(), this.processedLines.forEach((n, r
|
|
6039
|
-
const
|
|
6040
|
-
|
|
6041
|
-
}), this.processedLines.forEach((n, r
|
|
6042
|
-
if (
|
|
6043
|
-
const
|
|
6044
|
-
|
|
6160
|
+
this.rebuildStyle(), this.processedLines.forEach((i, n, r) => {
|
|
6161
|
+
const a = r[n + 1];
|
|
6162
|
+
i.words[i.words.length - 1] && (a ? a.startTime > i.endTime && (i.endTime = Math.min(i.endTime + 1500, a.startTime)) : i.endTime = i.endTime + 1500);
|
|
6163
|
+
}), this.processedLines.forEach((i, n, r) => {
|
|
6164
|
+
if (i.isBG) return;
|
|
6165
|
+
const a = r[n + 1];
|
|
6166
|
+
a != null && a.isBG && (a.startTime = Math.min(a.startTime, i.startTime));
|
|
6045
6167
|
});
|
|
6046
|
-
for (const
|
|
6047
|
-
|
|
6048
|
-
this.lyricLinesEl = this.processedLines.map((
|
|
6049
|
-
const
|
|
6050
|
-
return
|
|
6051
|
-
}), this.lyricLinesEl.forEach((
|
|
6052
|
-
this.element.appendChild(
|
|
6168
|
+
for (const i of this.lyricLinesEl)
|
|
6169
|
+
i.removeMouseEventListener("click", this.onLineClickedHandler), i.removeMouseEventListener("contextmenu", this.onLineClickedHandler), i.dispose();
|
|
6170
|
+
this.lyricLinesEl = this.processedLines.map((i) => {
|
|
6171
|
+
const n = new zs(this, i);
|
|
6172
|
+
return n.addMouseEventListener("click", this.onLineClickedHandler), n.addMouseEventListener("contextmenu", this.onLineClickedHandler), n;
|
|
6173
|
+
}), this.lyricLinesEl.forEach((i, n) => {
|
|
6174
|
+
this.element.appendChild(i.getElement()), this.lyricLinesIndexes.set(i, n), i.markMaskImageDirty();
|
|
6053
6175
|
}), this.interludeDots.setInterlude(void 0), this.hotLines.clear(), this.bufferedLines.clear(), this.setLinePosXSpringParams({}), this.setLinePosYSpringParams({}), this.setLineScaleSpringParams({}), this.resetScroll(), this.setCurrentTime(0, !0), this.calcLayout(!0, !0);
|
|
6054
6176
|
}
|
|
6055
6177
|
/**
|
|
@@ -6080,7 +6202,6 @@ class Ts extends EventTarget {
|
|
|
6080
6202
|
calcLayout(e = !1, s = !1) {
|
|
6081
6203
|
var u;
|
|
6082
6204
|
if (s) {
|
|
6083
|
-
this.emUnit = Number.parseFloat(getComputedStyle(this.element).fontSize);
|
|
6084
6205
|
for (const M of this.lyricLinesEl) {
|
|
6085
6206
|
const p = M.measureSize();
|
|
6086
6207
|
this.lyricLinesSize.set(M, p), M.lineSize = p;
|
|
@@ -6098,9 +6219,9 @@ class Ts extends EventTarget {
|
|
|
6098
6219
|
0
|
|
6099
6220
|
);
|
|
6100
6221
|
this.scrollBoundary[0] = -c, n -= c, n += this.size[1] * this.alignPosition;
|
|
6101
|
-
const
|
|
6102
|
-
if (
|
|
6103
|
-
const M = ((u = this.lyricLinesSize.get(
|
|
6222
|
+
const h = this.lyricLinesEl[r];
|
|
6223
|
+
if (h) {
|
|
6224
|
+
const M = ((u = this.lyricLinesSize.get(h)) == null ? void 0 : u[1]) ?? 0;
|
|
6104
6225
|
switch (this.alignAnchor) {
|
|
6105
6226
|
case "bottom":
|
|
6106
6227
|
n -= M;
|
|
@@ -6110,31 +6231,30 @@ class Ts extends EventTarget {
|
|
|
6110
6231
|
break;
|
|
6111
6232
|
}
|
|
6112
6233
|
}
|
|
6113
|
-
const
|
|
6114
|
-
let l = 0,
|
|
6234
|
+
const o = Math.max(...this.bufferedLines);
|
|
6235
|
+
let l = 0, m = 0.05, g = !1;
|
|
6115
6236
|
this.lyricLinesEl.forEach((M, p) => {
|
|
6116
|
-
var
|
|
6117
|
-
const T = this.bufferedLines.has(p), x = T || p >= this.scrollToIndex && p <
|
|
6237
|
+
var v, F, P;
|
|
6238
|
+
const T = this.bufferedLines.has(p), x = T || p >= this.scrollToIndex && p < o, L = M.getLine();
|
|
6118
6239
|
let b = 24;
|
|
6119
|
-
L.isDuet && (b = this.size[0] - (((
|
|
6240
|
+
L.isDuet && (b = this.size[0] - (((v = this.lyricLinesSize.get(M)) == null ? void 0 : v[0]) ?? 0)), !g && a >= 4e3 && (p === this.scrollToIndex && (i == null ? void 0 : i[2]) === -2 || p === this.scrollToIndex + 1) && (g = !0, this.interludeDots.setTransform(24, n + 10), i && this.interludeDots.setInterlude([i[0], i[1]]), n += this.interludeDotsSize[1] + 40);
|
|
6120
6241
|
let E, w;
|
|
6121
6242
|
this.hidePassedLines ? p < (i ? i[2] + 1 : this.scrollToIndex) ? (E = 0, w = 0) : T ? (E = 0.85, w = 0.4) : (E = this.isNonDynamic ? 0.2 : 1, w = 0.2) : T ? (E = 0.85, w = 0.4) : (E = this.isNonDynamic ? 0.2 : 1, w = 0.2);
|
|
6122
6243
|
let S = 0;
|
|
6123
6244
|
this.enableBlur && (x ? S = 0 : (S = 1, p < this.scrollToIndex ? S += Math.abs(this.scrollToIndex - p) + 1 : S += Math.abs(
|
|
6124
|
-
p - Math.max(this.scrollToIndex,
|
|
6245
|
+
p - Math.max(this.scrollToIndex, o)
|
|
6125
6246
|
))), this.invokedByScrollEvent && (S = 0);
|
|
6126
|
-
const z =
|
|
6247
|
+
const z = this.enableScale ? 97 : 100;
|
|
6127
6248
|
M.setTransform(
|
|
6128
6249
|
b,
|
|
6129
6250
|
n,
|
|
6130
|
-
x ? 100 : L.isBG ? 75 :
|
|
6251
|
+
x ? 100 : L.isBG ? 75 : z,
|
|
6131
6252
|
E,
|
|
6132
6253
|
w,
|
|
6133
6254
|
window.innerWidth <= 1024 ? S * 0.8 : S,
|
|
6134
6255
|
e,
|
|
6135
|
-
l
|
|
6136
|
-
|
|
6137
|
-
), L.isBG && x ? n += ((v = this.lyricLinesSize.get(M)) == null ? void 0 : v[1]) ?? 0 : L.isBG || (n += ((I = this.lyricLinesSize.get(M)) == null ? void 0 : I[1]) ?? 0), n >= 0 && !this.isSeeking && (L.isBG || (l += f), p >= this.scrollToIndex && (f /= 1.05));
|
|
6256
|
+
l
|
|
6257
|
+
), L.isBG && x ? n += ((F = this.lyricLinesSize.get(M)) == null ? void 0 : F[1]) ?? 0 : L.isBG || (n += ((P = this.lyricLinesSize.get(M)) == null ? void 0 : P[1]) ?? 0), n >= 0 && !this.isSeeking && (L.isBG || (l += m), p >= this.scrollToIndex && (m /= 1.05));
|
|
6138
6258
|
}), this.scrollBoundary[1] = n + this.scrollOffset - this.size[1] / 2, this.bottomLine.setTransform(24, n, e, l);
|
|
6139
6259
|
}
|
|
6140
6260
|
/**
|
|
@@ -6205,20 +6325,20 @@ class Ts extends EventTarget {
|
|
|
6205
6325
|
const c = this.processedLines[a];
|
|
6206
6326
|
if (c) {
|
|
6207
6327
|
if (c.isBG) return;
|
|
6208
|
-
const
|
|
6209
|
-
if (
|
|
6210
|
-
const
|
|
6211
|
-
Math.max(c.endTime, (
|
|
6212
|
-
Math.max(c.endTime,
|
|
6328
|
+
const h = this.processedLines[a + 1];
|
|
6329
|
+
if (h != null && h.isBG) {
|
|
6330
|
+
const o = this.processedLines[a + 2], l = Math.min(c.startTime, h == null ? void 0 : h.startTime), m = Math.min(
|
|
6331
|
+
Math.max(c.endTime, (o == null ? void 0 : o.startTime) ?? Number.MAX_VALUE),
|
|
6332
|
+
Math.max(c.endTime, h == null ? void 0 : h.endTime)
|
|
6213
6333
|
);
|
|
6214
|
-
(l > e ||
|
|
6334
|
+
(l > e || m <= e) && (this.hotLines.delete(a), i.add(a), this.hotLines.delete(a + 1), i.add(a + 1), s && (this.lyricLinesEl[a].disable(e), this.lyricLinesEl[a + 1].disable(e)));
|
|
6215
6335
|
} else (c.startTime > e || c.endTime <= e) && (this.hotLines.delete(a), i.add(a), s && this.lyricLinesEl[a].disable(e));
|
|
6216
6336
|
} else
|
|
6217
6337
|
this.hotLines.delete(a), i.add(a), s && this.lyricLinesEl[a].disable(e);
|
|
6218
6338
|
}
|
|
6219
|
-
this.processedLines.forEach((a, c,
|
|
6220
|
-
var
|
|
6221
|
-
!a.isBG && a.startTime <= e && a.endTime > e && (this.hotLines.has(c) || (this.hotLines.add(c), r.add(c), s && this.lyricLinesEl[c].enable(e), (
|
|
6339
|
+
this.processedLines.forEach((a, c, h) => {
|
|
6340
|
+
var o;
|
|
6341
|
+
!a.isBG && a.startTime <= e && a.endTime > e && (this.hotLines.has(c) || (this.hotLines.add(c), r.add(c), s && this.lyricLinesEl[c].enable(e), (o = h[c + 1]) != null && o.isBG && (this.hotLines.add(c + 1), r.add(c + 1), s && this.lyricLinesEl[c + 1].enable(e))));
|
|
6222
6342
|
});
|
|
6223
6343
|
for (const a of this.bufferedLines)
|
|
6224
6344
|
this.hotLines.has(a) || (n.add(a), s && this.lyricLinesEl[a].disable(e));
|
|
@@ -6235,7 +6355,7 @@ class Ts extends EventTarget {
|
|
|
6235
6355
|
this.bufferedLines.add(a), this.lyricLinesEl[a].enable(e);
|
|
6236
6356
|
this.scrollToIndex = Math.min(...this.bufferedLines), this.calcLayout();
|
|
6237
6357
|
} else if (r.size === 0 && n.size > 0) {
|
|
6238
|
-
if (
|
|
6358
|
+
if (Je(n, this.bufferedLines)) {
|
|
6239
6359
|
for (const a of this.bufferedLines)
|
|
6240
6360
|
this.hotLines.has(a) || (this.bufferedLines.delete(a), this.lyricLinesEl[a].disable(e));
|
|
6241
6361
|
this.calcLayout();
|
|
@@ -6328,11 +6448,11 @@ class Ts extends EventTarget {
|
|
|
6328
6448
|
}
|
|
6329
6449
|
}
|
|
6330
6450
|
export {
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6451
|
+
ye as AbstractBaseRenderer,
|
|
6452
|
+
ee as BackgroundRender,
|
|
6453
|
+
Jt as BaseRenderer,
|
|
6454
|
+
qs as LyricPlayer,
|
|
6455
|
+
Ns as MeshGradientRenderer,
|
|
6456
|
+
Os as PixiRenderer
|
|
6337
6457
|
};
|
|
6338
6458
|
//# sourceMappingURL=amll-core.js.map
|