rapid-render 1.0.27 → 1.0.29
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/README.md +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/matrix-engine.d.ts +4 -0
- package/dist/rapid-render.js +203 -199
- package/dist/rapid-render.umd.cjs +8 -8
- package/dist/texture.d.ts +7 -1
- package/package.json +1 -1
package/dist/rapid-render.js
CHANGED
|
@@ -176,19 +176,19 @@ class Ct {
|
|
|
176
176
|
async load(t, e) {
|
|
177
177
|
let r = this.cache.get(t);
|
|
178
178
|
if (r)
|
|
179
|
-
return this.addTexture(new
|
|
179
|
+
return this.addTexture(new W(r));
|
|
180
180
|
try {
|
|
181
181
|
const i = await this._fetchImage(t);
|
|
182
|
-
return r =
|
|
182
|
+
return r = Y.fromSource(this.render, i, e), r.uid = t, this.cache.set(t, r), this.addTexture(new W(r));
|
|
183
183
|
} catch (i) {
|
|
184
184
|
throw console.error(`[TextureManager] Failed to load: ${t}`, i), i;
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
187
|
create(t, e) {
|
|
188
188
|
if (e?.key && this.cache.has(e.key))
|
|
189
|
-
return this.addTexture(new
|
|
190
|
-
const r =
|
|
191
|
-
return e?.key && (r.uid = e.key, this.cache.set(e.key, r)), this.addTexture(new
|
|
189
|
+
return this.addTexture(new W(this.cache.get(e.key)));
|
|
190
|
+
const r = Y.fromSource(this.render, t, e);
|
|
191
|
+
return e?.key && (r.uid = e.key, this.cache.set(e.key, r)), this.addTexture(new W(r));
|
|
192
192
|
}
|
|
193
193
|
createRenderTexture(t) {
|
|
194
194
|
return this.addTexture(new _t(this.render, t));
|
|
@@ -198,7 +198,7 @@ class Ct {
|
|
|
198
198
|
}
|
|
199
199
|
destroy(t, e = !1) {
|
|
200
200
|
let r, i;
|
|
201
|
-
typeof t == "string" ? (i = t, r = this.cache.get(i)) : t instanceof
|
|
201
|
+
typeof t == "string" ? (i = t, r = this.cache.get(i)) : t instanceof W ? (r = t.base, i = r?.uid, this.removeTexture(t), t.destroy()) : (r = t, i = r.uid), r && (r.refCount <= 0 || e) && (r.destroy(this.render.gl), i && this.cache.delete(i));
|
|
202
202
|
}
|
|
203
203
|
destroyAll() {
|
|
204
204
|
for (const t of this.cache.values())
|
|
@@ -212,7 +212,7 @@ class Ct {
|
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
class
|
|
215
|
+
class Y {
|
|
216
216
|
glTexture = null;
|
|
217
217
|
width;
|
|
218
218
|
height;
|
|
@@ -223,7 +223,7 @@ class z {
|
|
|
223
223
|
}
|
|
224
224
|
static fromSource(t, e, r = {}) {
|
|
225
225
|
const i = nt(t, e, r);
|
|
226
|
-
return new
|
|
226
|
+
return new Y(i, e.width, e.height);
|
|
227
227
|
}
|
|
228
228
|
updateSource(t, e, r = {}) {
|
|
229
229
|
this.glTexture && (t.bindTexture(t.TEXTURE_2D, this.glTexture), r.textureFilter !== void 0 && ht(t, r.textureFilter), r.wrap !== void 0 && ot(t, r.wrap), t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL, 1), t.pixelStorei(t.UNPACK_ALIGNMENT, 1), r.premultipliedAlpha !== void 0 && t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL, r.premultipliedAlpha), this.width === e.width && this.height === e.height ? t.texSubImage2D(t.TEXTURE_2D, 0, 0, 0, t.RGBA, t.UNSIGNED_BYTE, e) : (t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, e), this.width = e.width, this.height = e.height), r.premultipliedAlpha !== void 0 && t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1));
|
|
@@ -238,7 +238,7 @@ class z {
|
|
|
238
238
|
this.glTexture && (t.deleteTexture(this.glTexture), this.glTexture = null);
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
|
-
class
|
|
241
|
+
class W {
|
|
242
242
|
base;
|
|
243
243
|
uvX = 0;
|
|
244
244
|
uvY = 0;
|
|
@@ -267,6 +267,8 @@ class k {
|
|
|
267
267
|
}
|
|
268
268
|
updateResolution() {
|
|
269
269
|
}
|
|
270
|
+
ensureUpdated() {
|
|
271
|
+
}
|
|
270
272
|
setBase(t) {
|
|
271
273
|
return this.base === t ? this : (this.base && this.base.refCount--, this.base = t, this.base.refCount++, this.setRegion(0, 0, t.width, t.height), this.glTexture = t.glTexture, this);
|
|
272
274
|
}
|
|
@@ -274,12 +276,12 @@ class k {
|
|
|
274
276
|
return this.base ? (this._px = t, this._py = e, this.isAtlas = t !== 0 || e !== 0 || r !== this.base.width || i !== this.base.height, this.uvX = t / this.base.width, this.uvY = e / this.base.height, this.uvW = this.uvX + r / this.base.width, this.uvH = this.uvY + i / this.base.height, this.rawWidth = r * this.scale, this.rawHeight = i * this.scale, this) : this;
|
|
275
277
|
}
|
|
276
278
|
getSubTexture(t, e, r, i) {
|
|
277
|
-
if (!this.base) return new
|
|
279
|
+
if (!this.base) return new W();
|
|
278
280
|
const s = this.clone(), a = this._px, o = this._py;
|
|
279
281
|
return s.setRegion(a + t, o + e, r, i), s;
|
|
280
282
|
}
|
|
281
283
|
clone(t) {
|
|
282
|
-
const e = t ?? new
|
|
284
|
+
const e = t ?? new W(this.base);
|
|
283
285
|
return t && this.base && t.setBase(this.base), e.scale = this.scale, e.uvX = this.uvX, e.uvY = this.uvY, e.uvW = this.uvW, e.uvH = this.uvH, e.rawWidth = this.rawWidth, e.rawHeight = this.rawHeight, e.offsetX = this.offsetX, e.offsetY = this.offsetY, e.flipY = this.flipY, e.isRotated = this.isRotated, e.isAtlas = this.isAtlas, e._px = this._px, e._py = this._py, e;
|
|
284
286
|
}
|
|
285
287
|
splitGrid(t, e, r, i, s = 0) {
|
|
@@ -292,13 +294,13 @@ class k {
|
|
|
292
294
|
}
|
|
293
295
|
static fromImageSource(t, e, r = {}) {
|
|
294
296
|
const i = nt(t, e, r);
|
|
295
|
-
return new
|
|
297
|
+
return new W(new Y(i, e.width, e.height));
|
|
296
298
|
}
|
|
297
299
|
destroy() {
|
|
298
300
|
this.base && (this.base.refCount--, this.base = void 0), this.glTexture = null;
|
|
299
301
|
}
|
|
300
302
|
}
|
|
301
|
-
class _t extends
|
|
303
|
+
class _t extends W {
|
|
302
304
|
framebuffer;
|
|
303
305
|
renderbuffer;
|
|
304
306
|
gl;
|
|
@@ -309,7 +311,7 @@ class _t extends k {
|
|
|
309
311
|
constructor(t, e) {
|
|
310
312
|
super(), this.gl = t.gl, this.premultipliedAlpha = t.premultipliedAlpha, this.clearColor = e.clearColor ?? g.Black;
|
|
311
313
|
const r = Math.max(Math.round(e.width), 1), i = Math.max(Math.round(e.height), 1), a = nt(t, { width: r, height: i }, { ...e, onlySize: !0 });
|
|
312
|
-
if (this.setBase(new
|
|
314
|
+
if (this.setBase(new Y(a, r, i)), this.framebuffer = this.gl.createFramebuffer(), this.renderbuffer = this.gl.createRenderbuffer(), !this.framebuffer || !this.renderbuffer)
|
|
313
315
|
throw new Error("Failed to create Framebuffer or Renderbuffer");
|
|
314
316
|
this.resize(r, i, !0);
|
|
315
317
|
}
|
|
@@ -362,7 +364,7 @@ const Pt = {
|
|
|
362
364
|
align: "left",
|
|
363
365
|
lineHeight: 1
|
|
364
366
|
};
|
|
365
|
-
class Lt extends
|
|
367
|
+
class Lt extends W {
|
|
366
368
|
canvas;
|
|
367
369
|
ctx;
|
|
368
370
|
render;
|
|
@@ -370,6 +372,8 @@ class Lt extends k {
|
|
|
370
372
|
_style;
|
|
371
373
|
options;
|
|
372
374
|
resolution = 1;
|
|
375
|
+
_scaleResolution = 1;
|
|
376
|
+
dirty = !0;
|
|
373
377
|
constructor(t, e) {
|
|
374
378
|
super(), this.render = t, this._style = { ...Pt, ...e }, this._text = e?.text ?? "", this.options = {
|
|
375
379
|
premultipliedAlpha: t.premultipliedAlpha,
|
|
@@ -381,19 +385,25 @@ class Lt extends k {
|
|
|
381
385
|
if (!r) throw new Error("Failed to get 2d context for TextTexture");
|
|
382
386
|
this.ctx = r, this.canvas.width = 1, this.canvas.height = 1;
|
|
383
387
|
const i = nt(t, this.canvas, this.options);
|
|
384
|
-
this.setBase(new
|
|
388
|
+
this.setBase(new Y(i, 1, 1)), this.updateResolution(), this.update();
|
|
385
389
|
}
|
|
386
390
|
get text() {
|
|
387
391
|
return this._text;
|
|
388
392
|
}
|
|
389
393
|
set text(t) {
|
|
390
|
-
this._text !== t && (this._text = t, this.
|
|
394
|
+
this._text !== t && (this._text = t, this.dirty = !0);
|
|
391
395
|
}
|
|
392
396
|
get style() {
|
|
393
397
|
return this._style;
|
|
394
398
|
}
|
|
399
|
+
set scaleResolution(t) {
|
|
400
|
+
t != this._scaleResolution && (this._scaleResolution = Math.max(0, t), this.dirty = !0);
|
|
401
|
+
}
|
|
402
|
+
get scaleResolution() {
|
|
403
|
+
return this._scaleResolution;
|
|
404
|
+
}
|
|
395
405
|
set style(t) {
|
|
396
|
-
this._style = { ...this._style, ...t }, this.
|
|
406
|
+
this._style = { ...this._style, ...t }, this.dirty = !0;
|
|
397
407
|
}
|
|
398
408
|
updateOffset(t, e) {
|
|
399
409
|
switch (this._style.align) {
|
|
@@ -407,34 +417,38 @@ class Lt extends k {
|
|
|
407
417
|
}
|
|
408
418
|
updateResolution() {
|
|
409
419
|
let t = 1;
|
|
410
|
-
t *= this.render.viewport.resolution, t != this.resolution && (this.resolution = t, this.
|
|
420
|
+
t *= this.render.viewport.resolution, t != this.resolution && (this.resolution = t, this.dirty = !0);
|
|
421
|
+
}
|
|
422
|
+
ensureUpdated() {
|
|
423
|
+
this.dirty && this.update();
|
|
411
424
|
}
|
|
412
425
|
update() {
|
|
413
|
-
|
|
414
|
-
|
|
426
|
+
this.dirty = !1;
|
|
427
|
+
const t = this.ctx, e = this.style, r = e.fontSize, i = e.fontWeight, s = e.fontFamily, a = e.lineHeight, h = Math.max(r, 32), c = r / h, u = `${i} ${r}px ${s}`, l = `${i} ${h}px ${s}`, d = this.resolution * this._scaleResolution, f = e.baseline ?? "top", m = e.align ?? "left", x = e.strokeThickness ?? 0, y = x > 0, v = this._text.split(`
|
|
428
|
+
`), w = "国g", R = v[0] || w;
|
|
415
429
|
t.font = l, t.textBaseline = "alphabetic", t.textAlign = "left";
|
|
416
|
-
let U = 0,
|
|
430
|
+
let U = 0, C = 0, I = 0;
|
|
417
431
|
for (const B of v) {
|
|
418
|
-
const X = t.measureText(B ||
|
|
419
|
-
U = Math.max(U, B ? X.width * c : 0), B == v.at(0) && (
|
|
432
|
+
const X = t.measureText(B || w);
|
|
433
|
+
U = Math.max(U, B ? X.width * c : 0), B == v.at(0) && (C = X.actualBoundingBoxAscent * c), B == v.at(-1) && (I = X.actualBoundingBoxDescent * c);
|
|
420
434
|
}
|
|
421
435
|
t.textBaseline = "alphabetic";
|
|
422
|
-
const
|
|
436
|
+
const b = t.measureText(R).fontBoundingBoxDescent * c;
|
|
423
437
|
t.textBaseline = f;
|
|
424
|
-
const
|
|
425
|
-
(this.canvas.width !== N || this.canvas.height !==
|
|
438
|
+
const T = t.measureText(R).fontBoundingBoxDescent * c, E = r * a, M = C + I + (v.length - 1) * E, F = x / 2 + 2 / d, k = U + F * 2, G = M + F * 2, N = Math.max(1, Math.ceil(k * d)), O = Math.max(1, Math.ceil(G * d)), V = N / d;
|
|
439
|
+
(this.canvas.width !== N || this.canvas.height !== O) && (this.canvas.width = N, this.canvas.height = O), t.setTransform(d, 0, 0, -d, 0, O), t.clearRect(
|
|
426
440
|
0,
|
|
427
441
|
0,
|
|
428
442
|
N / d,
|
|
429
|
-
|
|
443
|
+
O / d
|
|
430
444
|
), t.font = u, t.textBaseline = "alphabetic", t.textAlign = m;
|
|
431
|
-
const H = this.updateOffset(V,
|
|
445
|
+
const H = this.updateOffset(V, F);
|
|
432
446
|
y && (t.lineWidth = x, t.strokeStyle = e.stroke ?? "#000000", t.lineJoin = "round"), e.fill && (t.fillStyle = e.fill);
|
|
433
|
-
let
|
|
447
|
+
let _ = F + C;
|
|
434
448
|
for (const B of v)
|
|
435
|
-
y && t.strokeText(B, H,
|
|
436
|
-
const $ =
|
|
437
|
-
this.scale = 1 /
|
|
449
|
+
y && t.strokeText(B, H, _), e.fill && t.fillText(B, H, _), _ += E;
|
|
450
|
+
const $ = T - b;
|
|
451
|
+
this.scale = 1 / d, this.offsetX = -H, this.offsetY = -F - C + $, this.base?.updateSource(this.render.gl, this.canvas, this.options), this.setRegion(0, 0, N, O);
|
|
438
452
|
}
|
|
439
453
|
}
|
|
440
454
|
const Nt = (n, t = !1, e = !0) => {
|
|
@@ -617,10 +631,10 @@ function Dt(n, t, e, r, i = !1) {
|
|
|
617
631
|
return n.uniformMatrix3x2fv(t, !1, r);
|
|
618
632
|
// fallback: guess by value shape
|
|
619
633
|
default:
|
|
620
|
-
return
|
|
634
|
+
return Wt(n, t, r);
|
|
621
635
|
}
|
|
622
636
|
}
|
|
623
|
-
function
|
|
637
|
+
function Wt(n, t, e) {
|
|
624
638
|
if (typeof e == "number")
|
|
625
639
|
return n.uniform1f(t, e);
|
|
626
640
|
const r = e;
|
|
@@ -803,8 +817,8 @@ class Rt {
|
|
|
803
817
|
return !1;
|
|
804
818
|
}
|
|
805
819
|
}
|
|
806
|
-
var
|
|
807
|
-
class
|
|
820
|
+
var P = /* @__PURE__ */ ((n) => (n[n.Float32 = 0] = "Float32", n[n.Uint32 = 1] = "Uint32", n[n.Uint16 = 2] = "Uint16", n))(P || {});
|
|
821
|
+
class L {
|
|
808
822
|
usedElemNum;
|
|
809
823
|
typedArray;
|
|
810
824
|
arrayType;
|
|
@@ -903,7 +917,7 @@ class _ {
|
|
|
903
917
|
return this.usedElemNum;
|
|
904
918
|
}
|
|
905
919
|
}
|
|
906
|
-
class lt extends
|
|
920
|
+
class lt extends L {
|
|
907
921
|
buffer;
|
|
908
922
|
gl;
|
|
909
923
|
dirty = !0;
|
|
@@ -1014,7 +1028,7 @@ void main(void) {\r
|
|
|
1014
1028
|
\r
|
|
1015
1029
|
// CUSTOM_CODE_CALL\r
|
|
1016
1030
|
}\r
|
|
1017
|
-
`, j = 48,
|
|
1031
|
+
`, j = 48, kt = new Float32Array([0, 0, 1, 0, 0, 1, 1, 1]);
|
|
1018
1032
|
class dt extends Rt {
|
|
1019
1033
|
instanceBuffer;
|
|
1020
1034
|
quadBuffer;
|
|
@@ -1027,9 +1041,9 @@ class dt extends Rt {
|
|
|
1027
1041
|
}
|
|
1028
1042
|
createBuffer() {
|
|
1029
1043
|
const t = this.gl;
|
|
1030
|
-
this.quadBuffer = new lt(t,
|
|
1031
|
-
for (const e of
|
|
1032
|
-
this.quadBuffer.makeDirty(), this.quadBuffer.bufferData(), this.instanceBuffer = new lt(t,
|
|
1044
|
+
this.quadBuffer = new lt(t, P.Float32, t.ARRAY_BUFFER, t.STATIC_DRAW), this.quadBuffer.bindBuffer();
|
|
1045
|
+
for (const e of kt) this.quadBuffer.pushFloat32(e);
|
|
1046
|
+
this.quadBuffer.makeDirty(), this.quadBuffer.bufferData(), this.instanceBuffer = new lt(t, P.Uint32, t.ARRAY_BUFFER, t.DYNAMIC_DRAW);
|
|
1033
1047
|
}
|
|
1034
1048
|
createDefaultShader() {
|
|
1035
1049
|
return this.vs = st, this.fs = mt, this.defaultShader = this.createShader(st, mt), this.defaultShader;
|
|
@@ -1069,16 +1083,17 @@ class dt extends Rt {
|
|
|
1069
1083
|
);
|
|
1070
1084
|
}
|
|
1071
1085
|
drawSpriteAffine(t, e, r, i, s, a, o, h = 0, c = 0, u = 1, l = 1, d = 4294967295, f = 0, m = 0, x = !1, y = !1, v = !1) {
|
|
1072
|
-
|
|
1086
|
+
t.ensureUpdated();
|
|
1087
|
+
const w = t.base, R = t.rawWidth, U = t.rawHeight, C = t.offsetX, I = t.offsetY, b = this.useTexture(
|
|
1073
1088
|
t.glTexture,
|
|
1074
|
-
f /
|
|
1075
|
-
m /
|
|
1076
|
-
),
|
|
1077
|
-
|
|
1078
|
-
const
|
|
1079
|
-
v ? (
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1089
|
+
f / w.width,
|
|
1090
|
+
m / w.height
|
|
1091
|
+
), T = this.instanceBuffer, E = T.usedElemNum;
|
|
1092
|
+
T.resize(12);
|
|
1093
|
+
const M = T.float32, F = T.uint32, k = v ? U : R, G = v ? R : U, N = k + 2 * f, O = G + 2 * m, V = C - f, H = I - m, S = this.localSpriteMatrix;
|
|
1094
|
+
v ? (S[0] = 0, S[1] = y ? O : -O, S[2] = x ? -N : N, S[3] = 0, S[4] = V + (x ? N : 0), S[5] = H + (y ? 0 : O)) : (S[0] = x ? -N : N, S[1] = 0, S[2] = 0, S[3] = y ? -O : O, S[4] = V + (x ? N : 0), S[5] = H + (y ? O : 0));
|
|
1095
|
+
const _ = this.worldSpriteMatrix;
|
|
1096
|
+
_[0] = e * S[0] + i * S[1], _[1] = r * S[0] + s * S[1], _[2] = e * S[2] + i * S[3], _[3] = r * S[2] + s * S[3], _[4] = a + e * S[4] + i * S[5], _[5] = o + r * S[4] + s * S[5], M[E + 6] = h, M[E + 7] = c, M[E + 8] = u, M[E + 9] = l, F[E + 10] = d, F[E + 11] = b, this.rapid.roundPixels && (_[4] = Math.round(_[4]), _[5] = Math.round(_[5])), M[E] = _[0], M[E + 1] = _[2], M[E + 2] = _[4], M[E + 3] = _[1], M[E + 4] = _[3], M[E + 5] = _[5], T.usedElemNum += 12, T.makeDirty(), this.instanceCount++;
|
|
1082
1097
|
}
|
|
1083
1098
|
render() {
|
|
1084
1099
|
if (this.instanceCount === 0) return;
|
|
@@ -1093,8 +1108,9 @@ class dt extends Rt {
|
|
|
1093
1108
|
return this.instanceCount > 0;
|
|
1094
1109
|
}
|
|
1095
1110
|
}
|
|
1096
|
-
const
|
|
1111
|
+
const A = 6;
|
|
1097
1112
|
class Gt {
|
|
1113
|
+
transformValues = [1, 0, 0, 1, 0, 0];
|
|
1098
1114
|
matrixCount = 0;
|
|
1099
1115
|
buffer;
|
|
1100
1116
|
data;
|
|
@@ -1103,7 +1119,7 @@ class Gt {
|
|
|
1103
1119
|
temporary = -1;
|
|
1104
1120
|
identityMatrix = -1;
|
|
1105
1121
|
constructor(t = 10) {
|
|
1106
|
-
this.buffer = new
|
|
1122
|
+
this.buffer = new L(P.Float32), this.buffer.resize(t * A), this.data = this.buffer.getArray(), this.freeFlag = new L(P.Uint32), this.freeMatrixStack = new L(P.Uint32), this.reset();
|
|
1107
1123
|
}
|
|
1108
1124
|
alloc() {
|
|
1109
1125
|
const t = this.allocDirty();
|
|
@@ -1114,7 +1130,7 @@ class Gt {
|
|
|
1114
1130
|
const e = this.freeMatrixStack.pop();
|
|
1115
1131
|
return this.freeFlag.typedArray[e] = 1, e;
|
|
1116
1132
|
}
|
|
1117
|
-
this.buffer.resize(
|
|
1133
|
+
this.buffer.resize(A) && (this.data = this.buffer.getArray()), this.buffer.usedElemNum += A, this.freeFlag.resize(1);
|
|
1118
1134
|
const t = this.matrixCount++;
|
|
1119
1135
|
return this.freeFlag.typedArray[this.freeFlag.usedElemNum++] = 1, t;
|
|
1120
1136
|
}
|
|
@@ -1129,37 +1145,37 @@ class Gt {
|
|
|
1129
1145
|
this.matrixCount = 0, this.buffer.usedElemNum = 0, this.freeFlag.clear(), this.freeMatrixStack.clear(), this.temporary = this.alloc(), this.identityMatrix = this.alloc();
|
|
1130
1146
|
}
|
|
1131
1147
|
identity(t) {
|
|
1132
|
-
const e = t *
|
|
1148
|
+
const e = t * A, r = this.data;
|
|
1133
1149
|
r[e] = 1, r[e + 1] = 0, r[e + 2] = 0, r[e + 3] = 1, r[e + 4] = 0, r[e + 5] = 0;
|
|
1134
1150
|
}
|
|
1135
1151
|
translate(t, e, r) {
|
|
1136
|
-
const i = t *
|
|
1152
|
+
const i = t * A, s = this.data;
|
|
1137
1153
|
s[i + 4] = s[i] * e + s[i + 2] * r + s[i + 4], s[i + 5] = s[i + 1] * e + s[i + 3] * r + s[i + 5];
|
|
1138
1154
|
}
|
|
1139
1155
|
scale(t, e, r) {
|
|
1140
|
-
const i = t *
|
|
1156
|
+
const i = t * A, s = this.data;
|
|
1141
1157
|
s[i] *= e, s[i + 1] *= e, s[i + 2] *= r, s[i + 3] *= r;
|
|
1142
1158
|
}
|
|
1143
1159
|
rotate(t, e) {
|
|
1144
|
-
const r = t *
|
|
1160
|
+
const r = t * A, i = this.data, s = Math.cos(e), a = Math.sin(e), o = i[r], h = i[r + 1], c = i[r + 2], u = i[r + 3];
|
|
1145
1161
|
i[r] = o * s + c * a, i[r + 1] = h * s + u * a, i[r + 2] = o * -a + c * s, i[r + 3] = h * -a + u * s;
|
|
1146
1162
|
}
|
|
1147
1163
|
rotateWithOffset(t, e, r, i) {
|
|
1148
1164
|
this.translate(t, r, i), this.rotate(t, e), this.translate(t, -r, -i);
|
|
1149
1165
|
}
|
|
1150
1166
|
copy(t, e) {
|
|
1151
|
-
const r = t *
|
|
1167
|
+
const r = t * A, i = e * A, s = this.data;
|
|
1152
1168
|
s[r] = s[i], s[r + 1] = s[i + 1], s[r + 2] = s[i + 2], s[r + 3] = s[i + 3], s[r + 4] = s[i + 4], s[r + 5] = s[i + 5];
|
|
1153
1169
|
}
|
|
1154
1170
|
multiply(t, e) {
|
|
1155
1171
|
this.multiplyOut(t, t, e);
|
|
1156
1172
|
}
|
|
1157
1173
|
multiplyOut(t, e, r) {
|
|
1158
|
-
const i = t *
|
|
1159
|
-
o[i] = h * m + u * x, o[i + 1] = c * m + l * x, o[i + 2] = h * y + u * v, o[i + 3] = c * y + l * v, o[i + 4] = h *
|
|
1174
|
+
const i = t * A, s = e * A, a = r * A, o = this.data, h = o[s], c = o[s + 1], u = o[s + 2], l = o[s + 3], d = o[s + 4], f = o[s + 5], m = o[a], x = o[a + 1], y = o[a + 2], v = o[a + 3], w = o[a + 4], R = o[a + 5];
|
|
1175
|
+
o[i] = h * m + u * x, o[i + 1] = c * m + l * x, o[i + 2] = h * y + u * v, o[i + 3] = c * y + l * v, o[i + 4] = h * w + u * R + d, o[i + 5] = c * w + l * R + f;
|
|
1160
1176
|
}
|
|
1161
1177
|
invert(t) {
|
|
1162
|
-
const e = t *
|
|
1178
|
+
const e = t * A, r = this.data, i = r[e], s = r[e + 1], a = r[e + 2], o = r[e + 3], h = r[e + 4], c = r[e + 5];
|
|
1163
1179
|
let u = i * o - s * a;
|
|
1164
1180
|
if (!u) {
|
|
1165
1181
|
this.identity(t);
|
|
@@ -1168,7 +1184,7 @@ class Gt {
|
|
|
1168
1184
|
u = 1 / u, r[e] = o * u, r[e + 1] = -s * u, r[e + 2] = -a * u, r[e + 3] = i * u, r[e + 4] = (a * c - o * h) * u, r[e + 5] = (s * h - i * c) * u;
|
|
1169
1185
|
}
|
|
1170
1186
|
transformPoint(t, e, r) {
|
|
1171
|
-
const i = t *
|
|
1187
|
+
const i = t * A, s = this.data;
|
|
1172
1188
|
return {
|
|
1173
1189
|
x: e * s[i] + r * s[i + 2] + s[i + 4],
|
|
1174
1190
|
y: e * s[i + 1] + r * s[i + 3] + s[i + 5]
|
|
@@ -1184,31 +1200,31 @@ class Gt {
|
|
|
1184
1200
|
return this.transformPoint(t, e, r);
|
|
1185
1201
|
}
|
|
1186
1202
|
getPosition(t) {
|
|
1187
|
-
const e = t *
|
|
1203
|
+
const e = t * A, r = this.data;
|
|
1188
1204
|
return { x: r[e + 4], y: r[e + 5] };
|
|
1189
1205
|
}
|
|
1190
1206
|
getScale(t) {
|
|
1191
|
-
const e = t *
|
|
1207
|
+
const e = t * A, r = this.data, i = Math.sqrt(r[e] * r[e] + r[e + 1] * r[e + 1]), s = Math.sqrt(r[e + 2] * r[e + 2] + r[e + 3] * r[e + 3]);
|
|
1192
1208
|
return { x: i, y: s };
|
|
1193
1209
|
}
|
|
1194
1210
|
getRotation(t) {
|
|
1195
|
-
const e = t *
|
|
1211
|
+
const e = t * A, r = this.data;
|
|
1196
1212
|
return Math.atan2(r[e + 1], r[e]);
|
|
1197
1213
|
}
|
|
1198
1214
|
toCSSMatrix(t, e = 1, r = 1) {
|
|
1199
|
-
const i = t *
|
|
1215
|
+
const i = t * A, s = this.data;
|
|
1200
1216
|
return `matrix(${s[i] * e}, ${s[i + 1] * r}, ${s[i + 2] * e}, ${s[i + 3] * r}, ${s[i + 4] * e}, ${s[i + 5] * r})`;
|
|
1201
1217
|
}
|
|
1202
1218
|
getMatrix(t) {
|
|
1203
|
-
const e = t *
|
|
1204
|
-
return this.data.slice(e, e +
|
|
1219
|
+
const e = t * A;
|
|
1220
|
+
return this.data.slice(e, e + A);
|
|
1205
1221
|
}
|
|
1206
1222
|
getMatrixRef(t) {
|
|
1207
|
-
const e = t *
|
|
1208
|
-
return this.data.subarray(e, e +
|
|
1223
|
+
const e = t * A;
|
|
1224
|
+
return this.data.subarray(e, e + A);
|
|
1209
1225
|
}
|
|
1210
1226
|
setMatrix(t, e) {
|
|
1211
|
-
const r = t *
|
|
1227
|
+
const r = t * A, i = this.data;
|
|
1212
1228
|
i[r] = e[0], i[r + 1] = e[1], i[r + 2] = e[2], i[r + 3] = e[3], i[r + 4] = e[4], i[r + 5] = e[5];
|
|
1213
1229
|
}
|
|
1214
1230
|
multiplyAffineInPlace(t, e, r, i, s, a, o) {
|
|
@@ -1222,36 +1238,31 @@ class Gt {
|
|
|
1222
1238
|
clampBounds(t, e, r, i, s, a, o) {
|
|
1223
1239
|
if (i === void 0 && s === void 0 && a === void 0 && o === void 0)
|
|
1224
1240
|
return;
|
|
1225
|
-
const h = t *
|
|
1241
|
+
const h = t * A, c = this.data, u = Math.sqrt(c[h] * c[h] + c[h + 1] * c[h + 1]) || 1, l = Math.sqrt(c[h + 2] * c[h + 2] + c[h + 3] * c[h + 3]) || 1, d = e * 0.5 * u, f = r * 0.5 * l;
|
|
1226
1242
|
let m = c[h + 4], x = c[h + 5];
|
|
1227
1243
|
i !== void 0 && s !== void 0 ? m = s - i < d * 2 ? (i + s) * 0.5 : Math.max(i + d, Math.min(m, s - d)) : i !== void 0 ? m = Math.max(m, i + d) : s !== void 0 && (m = Math.min(m, s - d)), a !== void 0 && o !== void 0 ? x = o - a < f * 2 ? (a + o) * 0.5 : Math.max(a + f, Math.min(x, o - f)) : a !== void 0 ? x = Math.max(x, a + f) : o !== void 0 && (x = Math.min(x, o - f)), c[h + 4] = m, c[h + 5] = x;
|
|
1228
1244
|
}
|
|
1229
|
-
applyTransform(t, e = 0, r = 0) {
|
|
1230
|
-
let
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
v,
|
|
1245
|
-
T,
|
|
1246
|
-
w,
|
|
1247
|
-
U
|
|
1248
|
-
];
|
|
1245
|
+
applyTransform(t, e = 0, r, i = 1, s = 0, a = 0, o = 0, h = 0, c = 0, u = 0, l = 0) {
|
|
1246
|
+
let d, f, m = r ?? 1;
|
|
1247
|
+
if (typeof t == "object") {
|
|
1248
|
+
h = e ?? 0, c = r ?? 0;
|
|
1249
|
+
const T = t;
|
|
1250
|
+
d = (T.x ?? 0) + (T.position?.x ?? 0), f = (T.y ?? 0) + (T.position?.y ?? 0);
|
|
1251
|
+
const E = T.scale;
|
|
1252
|
+
m = typeof E == "number" ? E : E?.x ?? 1, i = typeof E == "number" ? E : E?.y ?? 1, s = T.rotation ?? 0;
|
|
1253
|
+
const M = T.origin;
|
|
1254
|
+
a = typeof M == "number" ? M : M?.x ?? 0, o = typeof M == "number" ? M : M?.y ?? 0, u = (T.offsetX ?? 0) + (T.offset?.x ?? 0), l = (T.offsetY ?? 0) + (T.offset?.y ?? 0);
|
|
1255
|
+
} else
|
|
1256
|
+
d = t, f = e;
|
|
1257
|
+
u -= a * h, l -= o * c;
|
|
1258
|
+
const x = s ? Math.cos(s) : 1, y = s ? Math.sin(s) : 0, v = x * m, w = y * m, R = -y * i, U = x * i, C = d + v * u + R * l, I = f + w * u + U * l, b = this.transformValues;
|
|
1259
|
+
return b[0] = v, b[1] = w, b[2] = R, b[3] = U, b[4] = C, b[5] = I, typeof t == "number" ? b : b.slice();
|
|
1249
1260
|
}
|
|
1250
1261
|
}
|
|
1251
1262
|
class Ht {
|
|
1252
1263
|
matrix = new Gt();
|
|
1253
|
-
stack = new
|
|
1254
|
-
currStack = new
|
|
1264
|
+
stack = new L(P.Uint32);
|
|
1265
|
+
currStack = new L(P.Uint32);
|
|
1255
1266
|
curLocalM = -1;
|
|
1256
1267
|
curWorldM = -1;
|
|
1257
1268
|
rapid;
|
|
@@ -1276,7 +1287,7 @@ class Ht {
|
|
|
1276
1287
|
), r = [];
|
|
1277
1288
|
for (let i = 0; i < this.currStack.length; i++)
|
|
1278
1289
|
e.has(this.currStack.get(i)) && r.push(i);
|
|
1279
|
-
return
|
|
1290
|
+
return L.removeAtIndices(r, [this.currStack]), t;
|
|
1280
1291
|
}
|
|
1281
1292
|
translate(t, e) {
|
|
1282
1293
|
this.matrix.translate(this.curLocalM, t, e), this.matrix.translate(this.curWorldM, t, e);
|
|
@@ -1317,51 +1328,40 @@ class Ht {
|
|
|
1317
1328
|
return this.matrix.toCSSMatrix(this.curWorldM);
|
|
1318
1329
|
}
|
|
1319
1330
|
getTransform() {
|
|
1320
|
-
const t = this.curWorldM *
|
|
1321
|
-
return this.matrix.data.slice(t, t +
|
|
1331
|
+
const t = this.curWorldM * A;
|
|
1332
|
+
return this.matrix.data.slice(t, t + A);
|
|
1322
1333
|
}
|
|
1323
1334
|
setTransform(t) {
|
|
1324
|
-
const e = this.curWorldM *
|
|
1335
|
+
const e = this.curWorldM * A, r = this.matrix.data;
|
|
1325
1336
|
r[e] = t[0], r[e + 1] = t[1], r[e + 2] = t[2], r[e + 3] = t[3], r[e + 4] = t[4], r[e + 5] = t[5];
|
|
1326
1337
|
}
|
|
1327
1338
|
transformPoint(t, e) {
|
|
1328
1339
|
return this.matrix.transformPoint(this.curLocalM, t, e);
|
|
1329
1340
|
}
|
|
1330
|
-
applyTransform(t, e = 0, r = 0,
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
l,
|
|
1337
|
-
d
|
|
1338
|
-
] = this.matrix.applyTransform(t, e, r);
|
|
1339
|
-
i != null ? this.matrix.multiplyAffine(
|
|
1340
|
-
s,
|
|
1341
|
+
applyTransform(t, e = 0, r, i, s, a, o = 0, h = 0, c = 0, u = 0, l = 0, d, f = this.curWorldM, m = this.curLocalM) {
|
|
1342
|
+
let x;
|
|
1343
|
+
typeof t == "object" ? (x = this.matrix.applyTransform(t, e, r), d = i, f = s ?? this.curWorldM, m = a ?? this.curLocalM) : x = this.matrix.applyTransform(
|
|
1344
|
+
t,
|
|
1345
|
+
e,
|
|
1346
|
+
r,
|
|
1341
1347
|
i,
|
|
1342
|
-
o,
|
|
1343
|
-
h,
|
|
1344
|
-
c,
|
|
1345
|
-
u,
|
|
1346
|
-
l,
|
|
1347
|
-
d
|
|
1348
|
-
) : (this.matrix.multiplyAffineInPlace(
|
|
1349
|
-
a,
|
|
1350
|
-
o,
|
|
1351
|
-
h,
|
|
1352
|
-
c,
|
|
1353
|
-
u,
|
|
1354
|
-
l,
|
|
1355
|
-
d
|
|
1356
|
-
), this.matrix.multiplyAffineInPlace(
|
|
1357
1348
|
s,
|
|
1349
|
+
a,
|
|
1358
1350
|
o,
|
|
1359
1351
|
h,
|
|
1360
1352
|
c,
|
|
1361
1353
|
u,
|
|
1362
|
-
l
|
|
1363
|
-
|
|
1364
|
-
|
|
1354
|
+
l
|
|
1355
|
+
);
|
|
1356
|
+
const [
|
|
1357
|
+
y,
|
|
1358
|
+
v,
|
|
1359
|
+
w,
|
|
1360
|
+
R,
|
|
1361
|
+
U,
|
|
1362
|
+
C
|
|
1363
|
+
] = x;
|
|
1364
|
+
d !== void 0 ? this.matrix.multiplyAffine(f, d, y, v, w, R, U, C) : (this.matrix.multiplyAffineInPlace(m, y, v, w, R, U, C), this.matrix.multiplyAffineInPlace(f, y, v, w, R, U, C));
|
|
1365
1365
|
}
|
|
1366
1366
|
}
|
|
1367
1367
|
const Vt = `#version 300 es\r
|
|
@@ -1442,7 +1442,7 @@ void main(void) {\r
|
|
|
1442
1442
|
fragColor = sampleTexture(vRegion) * vColor;\r
|
|
1443
1443
|
// CUSTOM_CODE_CALL\r
|
|
1444
1444
|
}\r
|
|
1445
|
-
`,
|
|
1445
|
+
`, zt = `#version 300 es\r
|
|
1446
1446
|
precision highp float;\r
|
|
1447
1447
|
\r
|
|
1448
1448
|
in vec2 aPosition;\r
|
|
@@ -1465,7 +1465,7 @@ void main(void) {\r
|
|
|
1465
1465
|
);\r
|
|
1466
1466
|
gl_Position = u_projection * position;\r
|
|
1467
1467
|
}\r
|
|
1468
|
-
`,
|
|
1468
|
+
`, Yt = `#version 300 es\r
|
|
1469
1469
|
precision mediump float;\r
|
|
1470
1470
|
\r
|
|
1471
1471
|
in vec2 vRegion;\r
|
|
@@ -1500,7 +1500,7 @@ class $t extends Rt {
|
|
|
1500
1500
|
}
|
|
1501
1501
|
createBuffer() {
|
|
1502
1502
|
const t = this.gl;
|
|
1503
|
-
this.vertexBuffer = new lt(t,
|
|
1503
|
+
this.vertexBuffer = new lt(t, P.Float32, t.ARRAY_BUFFER, t.DYNAMIC_DRAW), this.maskShader = this.createMaskShader(zt, Yt);
|
|
1504
1504
|
}
|
|
1505
1505
|
createDefaultShader() {
|
|
1506
1506
|
return this.vs = Vt, this.fs = Xt, this.defaultShader = this.createShader(this.vs, this.fs), this.defaultShader;
|
|
@@ -1521,7 +1521,7 @@ class $t extends Rt {
|
|
|
1521
1521
|
]), i.unbindVAO(), this.currentShader && this.currentShader.use(), i;
|
|
1522
1522
|
}
|
|
1523
1523
|
startGraphic(t, e = this.gl.TRIANGLES, r) {
|
|
1524
|
-
this.vertexBuffer.clear(), this.vertexCount = 0, this.matrixIndex = t, this.drawMode = e, this.texture = r, this.texture?.glTexture && this.useTexture(this.texture.glTexture, 0, 0);
|
|
1524
|
+
this.vertexBuffer.clear(), this.vertexCount = 0, this.matrixIndex = t, this.drawMode = e, this.texture = r, this.texture?.glTexture && (this.texture.ensureUpdated(), this.useTexture(this.texture.glTexture, 0, 0));
|
|
1525
1525
|
}
|
|
1526
1526
|
addVertex(t, e, r = 0, i = 0, s = 4294967295) {
|
|
1527
1527
|
const a = this.vertexBuffer;
|
|
@@ -1746,16 +1746,16 @@ const at = 10, xt = (n, t, e, r, i, s) => {
|
|
|
1746
1746
|
let c = 0;
|
|
1747
1747
|
const u = n.texture?.rawWidth || 1, l = n.closed ? t.length : t.length - 1;
|
|
1748
1748
|
for (let d = 0; d < l; d++) {
|
|
1749
|
-
const f = t[d], m = e[d].normal, x = e[d].miters, y = (d + 1) % t.length, v = t[y],
|
|
1750
|
-
let E = 0,
|
|
1751
|
-
h === 0 ? (E = c / r,
|
|
1752
|
-
const
|
|
1753
|
-
s.push(U), a.push(
|
|
1749
|
+
const f = t[d], m = e[d].normal, x = e[d].miters, y = (d + 1) % t.length, v = t[y], w = e[y].normal, R = e[y].miters, U = f.add(m.multiply(x * i)), C = f.subtract(m.multiply(x * i)), I = v.add(w.multiply(R * i)), b = v.subtract(w.multiply(R * i)), T = f.distanceTo(v);
|
|
1750
|
+
let E = 0, M = 0;
|
|
1751
|
+
h === 0 ? (E = c / r, M = (c + T) / r) : (E = c / u, M = E + T / u);
|
|
1752
|
+
const F = new p(E, 0), k = new p(E, 1), G = new p(M, 0), N = new p(M, 1);
|
|
1753
|
+
s.push(U), a.push(F), s.push(C), a.push(k), s.push(I), a.push(G), s.push(I), a.push(G), s.push(b), a.push(N), s.push(C), a.push(k), c += T;
|
|
1754
1754
|
}
|
|
1755
1755
|
if (o && !n.closed) {
|
|
1756
1756
|
const d = t[0], f = e[0].normal, m = h === 0 ? r > 0 ? 1 / r : 0 : 1 / u, x = xt(d, f, i, !0, 0, m);
|
|
1757
1757
|
s.push(...x.vertices), a.push(...x.uv);
|
|
1758
|
-
const y = t[t.length - 1], v = e[t.length - 1].normal,
|
|
1758
|
+
const y = t[t.length - 1], v = e[t.length - 1].normal, w = h === 0 ? 1 : c / u, R = h === 0 ? r > 0 ? 1 / r : 0 : 1 / u, U = xt(y, v, i, !1, w, R);
|
|
1759
1759
|
s.push(...U.vertices), a.push(...U.uv);
|
|
1760
1760
|
}
|
|
1761
1761
|
return { vertices: s, uv: a };
|
|
@@ -1785,19 +1785,21 @@ const at = 10, xt = (n, t, e, r, i, s) => {
|
|
|
1785
1785
|
n.matrixStack.curWorldM
|
|
1786
1786
|
), i;
|
|
1787
1787
|
}, Jt = (n, t) => t ? n ? t.premultipliedUint32 : t.uint32 : 4294967295, te = 2, ee = (n, t) => {
|
|
1788
|
-
const e =
|
|
1789
|
-
|
|
1788
|
+
const e = t.texture;
|
|
1789
|
+
e.ensureUpdated();
|
|
1790
|
+
const r = tt(n, t, t.texture.rawWidth, t.texture.rawHeight);
|
|
1791
|
+
if (!e?.base || n.inCreateMask)
|
|
1790
1792
|
return;
|
|
1791
|
-
const i =
|
|
1793
|
+
const i = e.isAtlas ? n.atlasSpriteRegion : n.spriteRegion;
|
|
1792
1794
|
n.enterRegion(i, t.shader);
|
|
1793
|
-
let s =
|
|
1794
|
-
const c = !!t.flipX, u = !!t.flipY != !!
|
|
1795
|
+
let s = e.uvX, a = e.uvY, o = e.uvW, h = e.uvH;
|
|
1796
|
+
const c = !!t.flipX, u = !!t.flipY != !!e.flipY;
|
|
1795
1797
|
let l = t.padding ?? i.currentShader.padding;
|
|
1796
|
-
|
|
1798
|
+
e.isAtlas && (l += te);
|
|
1797
1799
|
const d = s <= o ? l : -l, f = a <= h ? l : -l;
|
|
1798
1800
|
i.drawSprite(
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
+
e,
|
|
1802
|
+
r ?? t.customMatrix ?? n.matrixStack.curWorldM,
|
|
1801
1803
|
s,
|
|
1802
1804
|
a,
|
|
1803
1805
|
o,
|
|
@@ -1807,7 +1809,7 @@ const at = 10, xt = (n, t, e, r, i, s) => {
|
|
|
1807
1809
|
f,
|
|
1808
1810
|
c,
|
|
1809
1811
|
u,
|
|
1810
|
-
|
|
1812
|
+
e.isRotated
|
|
1811
1813
|
);
|
|
1812
1814
|
}, re = (n, t) => {
|
|
1813
1815
|
const e = n.particleRegion;
|
|
@@ -2003,7 +2005,7 @@ void main(void) {\r
|
|
|
2003
2005
|
\r
|
|
2004
2006
|
// CUSTOM_CODE_CALL\r
|
|
2005
2007
|
}\r
|
|
2006
|
-
`,
|
|
2008
|
+
`, z = 48, ue = z / 4;
|
|
2007
2009
|
class le extends dt {
|
|
2008
2010
|
KEY = "ParticleSprite";
|
|
2009
2011
|
texture;
|
|
@@ -2023,42 +2025,42 @@ class le extends dt {
|
|
|
2023
2025
|
createShader(t, e) {
|
|
2024
2026
|
const r = super.createShader(t, e);
|
|
2025
2027
|
return r.use(), r.bindVAO(), this.instanceBuffer.bindBuffer(), r.setAttributes([
|
|
2026
|
-
{ name: "aPosition", size: 2, stride:
|
|
2027
|
-
{ name: "aScale", size: 2, stride:
|
|
2028
|
-
{ name: "aRotation", size: 1, stride:
|
|
2029
|
-
{ name: "aUVRect", size: 4, stride:
|
|
2030
|
-
{ name: "aColor", size: 4, type: ct, normalized: !0, stride:
|
|
2031
|
-
{ name: "aOrigin", size: 2, stride:
|
|
2028
|
+
{ name: "aPosition", size: 2, stride: z, offset: 0, divisor: 1 },
|
|
2029
|
+
{ name: "aScale", size: 2, stride: z, offset: 8, divisor: 1 },
|
|
2030
|
+
{ name: "aRotation", size: 1, stride: z, offset: 16, divisor: 1 },
|
|
2031
|
+
{ name: "aUVRect", size: 4, stride: z, offset: 20, divisor: 1 },
|
|
2032
|
+
{ name: "aColor", size: 4, type: ct, normalized: !0, stride: z, offset: 36, divisor: 1 },
|
|
2033
|
+
{ name: "aOrigin", size: 2, stride: z, offset: 40, divisor: 1 }
|
|
2032
2034
|
]), this.quadBuffer.bindBuffer(), r.setAttributes([
|
|
2033
2035
|
{ name: "aVertex", size: 2, stride: 8, offset: 0, divisor: 0 }
|
|
2034
2036
|
]), r.unbindVAO(), this.currentShader && this.currentShader.use(), r;
|
|
2035
2037
|
}
|
|
2036
|
-
drawParticles(t, e, r, i = 0, s = 4294967295, a, o = 1, h = 1, c = 0, u = 0, l = 1, d = 1, f = !1, m = !1, x = !1, y = 0.5, v = 0.5,
|
|
2037
|
-
if (!t.glTexture || a <= 0) return;
|
|
2038
|
+
drawParticles(t, e, r, i = 0, s = 4294967295, a, o = 1, h = 1, c = 0, u = 0, l = 1, d = 1, f = !1, m = !1, x = !1, y = 0.5, v = 0.5, w, R = !1, U) {
|
|
2039
|
+
if (t.ensureUpdated(), !t.glTexture || a <= 0) return;
|
|
2038
2040
|
this.texture && t !== this.texture && this.flush();
|
|
2039
|
-
const
|
|
2040
|
-
let
|
|
2041
|
-
|
|
2041
|
+
const C = typeof o == "number", I = typeof h == "number", b = typeof i == "number", T = typeof s == "number", E = typeof c == "number", M = !T && typeof s[0] == "number", F = t.uvW - t.uvX, k = t.uvH - t.uvY, G = F === 0 ? 0 : 1 / F, N = k === 0 ? 0 : 1 / k;
|
|
2042
|
+
let O = t.rawWidth * (f ? -1 : 1);
|
|
2043
|
+
C && (O *= o);
|
|
2042
2044
|
let V = t.rawHeight * (m ? -1 : 1);
|
|
2043
|
-
|
|
2045
|
+
I && (V *= h), E && (O *= (l - c) * G, V *= (d - u) * N);
|
|
2044
2046
|
let H = x ? Math.PI / 2 : 0;
|
|
2045
|
-
|
|
2046
|
-
const
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
L,
|
|
2050
|
-
E,
|
|
2051
|
-
S,
|
|
2047
|
+
b && (H += i);
|
|
2048
|
+
const S = s ?? 4294967295, _ = this.getParticleLoop(
|
|
2049
|
+
C,
|
|
2050
|
+
I,
|
|
2052
2051
|
b,
|
|
2053
|
-
|
|
2054
|
-
T
|
|
2052
|
+
E,
|
|
2053
|
+
T,
|
|
2054
|
+
M,
|
|
2055
|
+
R,
|
|
2056
|
+
w
|
|
2055
2057
|
);
|
|
2056
2058
|
this.texture || (this.texture = t, this.useTexture(t.glTexture, 0, 0));
|
|
2057
2059
|
const $ = a, B = this.instanceBuffer;
|
|
2058
2060
|
let X = B.usedElemNum;
|
|
2059
2061
|
B.resize($ * ue);
|
|
2060
2062
|
const bt = B.float32, Ut = B.uint32;
|
|
2061
|
-
X =
|
|
2063
|
+
X = _(
|
|
2062
2064
|
e,
|
|
2063
2065
|
r,
|
|
2064
2066
|
o,
|
|
@@ -2071,12 +2073,12 @@ class le extends dt {
|
|
|
2071
2073
|
s,
|
|
2072
2074
|
bt,
|
|
2073
2075
|
Ut,
|
|
2074
|
-
|
|
2076
|
+
O,
|
|
2075
2077
|
V,
|
|
2076
2078
|
G,
|
|
2077
2079
|
N,
|
|
2078
2080
|
H,
|
|
2079
|
-
|
|
2081
|
+
S,
|
|
2080
2082
|
1 - y,
|
|
2081
2083
|
1 - v,
|
|
2082
2084
|
a,
|
|
@@ -2190,17 +2192,17 @@ class me {
|
|
|
2190
2192
|
case 0:
|
|
2191
2193
|
case 1:
|
|
2192
2194
|
case 2: {
|
|
2193
|
-
const
|
|
2195
|
+
const w = y, R = v, U = Math.min(
|
|
2194
2196
|
s.physicsWidth / t,
|
|
2195
2197
|
s.physicsHeight / e
|
|
2196
|
-
),
|
|
2197
|
-
if (u = -
|
|
2198
|
-
const E =
|
|
2198
|
+
), C = s.physicsWidth / U, I = s.physicsHeight / U, b = C - t, T = I - e;
|
|
2199
|
+
if (u = -b * w.x, l = t + b * (1 - w.x), f = -T * w.y, d = e + T * (1 - w.y), !R.x && b > 0 || !R.y && T > 0) {
|
|
2200
|
+
const E = R.x && b > 0 ? u : 0, M = R.x && b > 0 ? l : t, F = R.y && T > 0 ? f : 0, k = R.y && T > 0 ? d : e;
|
|
2199
2201
|
this.scissorViewport = {
|
|
2200
2202
|
x: E,
|
|
2201
|
-
y:
|
|
2202
|
-
width:
|
|
2203
|
-
height:
|
|
2203
|
+
y: F,
|
|
2204
|
+
width: M - E,
|
|
2205
|
+
height: k - F
|
|
2204
2206
|
};
|
|
2205
2207
|
}
|
|
2206
2208
|
break;
|
|
@@ -2262,16 +2264,16 @@ class me {
|
|
|
2262
2264
|
s.flush();
|
|
2263
2265
|
const a = s.gl, o = this.scissorViewport;
|
|
2264
2266
|
if (o && a.getParameter(a.FRAMEBUFFER_BINDING) === null) {
|
|
2265
|
-
const
|
|
2267
|
+
const C = Math.max(Math.min(t, t + r), o.x), I = Math.min(Math.max(t, t + r), o.x + o.width), b = Math.max(Math.min(e, e + i), o.y), T = Math.min(
|
|
2266
2268
|
Math.max(e, e + i),
|
|
2267
2269
|
o.y + o.height
|
|
2268
2270
|
);
|
|
2269
|
-
t =
|
|
2271
|
+
t = C, e = b, r = Math.max(0, I - C), i = Math.max(0, T - b);
|
|
2270
2272
|
}
|
|
2271
2273
|
const [h, c, u, l] = a.getParameter(
|
|
2272
2274
|
a.VIEWPORT
|
|
2273
|
-
), d = s.projection, f = h + (d[0] * t + d[12] + 1) * u / 2, m = h + (d[0] * (t + r) + d[12] + 1) * u / 2, x = c + (d[5] * e + d[13] + 1) * l / 2, y = c + (d[5] * (e + i) + d[13] + 1) * l / 2, v = Math.round(Math.min(f, m)),
|
|
2274
|
-
a.enable(a.SCISSOR_TEST), a.scissor(v,
|
|
2275
|
+
), d = s.projection, f = h + (d[0] * t + d[12] + 1) * u / 2, m = h + (d[0] * (t + r) + d[12] + 1) * u / 2, x = c + (d[5] * e + d[13] + 1) * l / 2, y = c + (d[5] * (e + i) + d[13] + 1) * l / 2, v = Math.round(Math.min(f, m)), w = Math.round(Math.max(f, m)), R = Math.round(Math.min(x, y)), U = Math.round(Math.max(x, y));
|
|
2276
|
+
a.enable(a.SCISSOR_TEST), a.scissor(v, R, w - v, U - R);
|
|
2275
2277
|
}
|
|
2276
2278
|
restoreViewportScissor() {
|
|
2277
2279
|
this.rapid.flush();
|
|
@@ -2312,7 +2314,7 @@ class we {
|
|
|
2312
2314
|
textureFilter;
|
|
2313
2315
|
viewport;
|
|
2314
2316
|
_filterRT = [null, null];
|
|
2315
|
-
_filterInput = new
|
|
2317
|
+
_filterInput = new W();
|
|
2316
2318
|
get height() {
|
|
2317
2319
|
return this.logicHeight;
|
|
2318
2320
|
}
|
|
@@ -2617,9 +2619,9 @@ class q {
|
|
|
2617
2619
|
if (!Number.isInteger(t) || t <= 0)
|
|
2618
2620
|
throw new RangeError("ParticleAttributeStore size must be a positive integer");
|
|
2619
2621
|
this.components = Array.from({ length: t }, () => ({
|
|
2620
|
-
value: new
|
|
2621
|
-
delta: new
|
|
2622
|
-
damping: new
|
|
2622
|
+
value: new L(P.Float32),
|
|
2623
|
+
delta: new L(P.Float32),
|
|
2624
|
+
damping: new L(P.Float32)
|
|
2623
2625
|
}));
|
|
2624
2626
|
}
|
|
2625
2627
|
getArrayBuffer() {
|
|
@@ -2676,13 +2678,13 @@ class At {
|
|
|
2676
2678
|
emitTimeCounter = 0;
|
|
2677
2679
|
localSpace = Tt;
|
|
2678
2680
|
rapid;
|
|
2679
|
-
x = new
|
|
2680
|
-
y = new
|
|
2681
|
-
scaleX = new
|
|
2682
|
-
scaleY = new
|
|
2683
|
-
rotation = new
|
|
2684
|
-
color = new
|
|
2685
|
-
remainingLife = new
|
|
2681
|
+
x = new L(P.Float32);
|
|
2682
|
+
y = new L(P.Float32);
|
|
2683
|
+
scaleX = new L(P.Float32);
|
|
2684
|
+
scaleY = new L(P.Float32);
|
|
2685
|
+
rotation = new L(P.Float32);
|
|
2686
|
+
color = new L(P.Uint32);
|
|
2687
|
+
remainingLife = new L(P.Float32);
|
|
2686
2688
|
animations = {
|
|
2687
2689
|
speed: new q(),
|
|
2688
2690
|
rotation: new q(),
|
|
@@ -2778,7 +2780,7 @@ class At {
|
|
|
2778
2780
|
r > 0 && (this.emit(r), this.emitTimer -= r / this.emitRate);
|
|
2779
2781
|
}
|
|
2780
2782
|
const e = this.updateParticle(t);
|
|
2781
|
-
this.count -= e.length,
|
|
2783
|
+
this.count -= e.length, L.removeAtIndices(e, this.getAllArrayBuffer());
|
|
2782
2784
|
}
|
|
2783
2785
|
updateParticle(t) {
|
|
2784
2786
|
const e = [], r = this.animations;
|
|
@@ -2931,8 +2933,8 @@ class Ee {
|
|
|
2931
2933
|
i.withMask(() => {
|
|
2932
2934
|
i.startMaskGraphic(i.gl.TRIANGLES);
|
|
2933
2935
|
for (let c = 0; c < o.length; c++) {
|
|
2934
|
-
const u = o[c], l = o[(c + 1) % o.length], d = u.subtract(a).normalized(), f = l.subtract(a).normalized(), m = Math.max(-0.999, Math.min(1, d.dot(f))), x = Math.sqrt((1 + m) * 0.5), y = h / x, v = a.add(d.multiply(y)),
|
|
2935
|
-
i.addGraphicVertex(u.x, u.y), i.addGraphicVertex(l.x, l.y), i.addGraphicVertex(
|
|
2936
|
+
const u = o[c], l = o[(c + 1) % o.length], d = u.subtract(a).normalized(), f = l.subtract(a).normalized(), m = Math.max(-0.999, Math.min(1, d.dot(f))), x = Math.sqrt((1 + m) * 0.5), y = h / x, v = a.add(d.multiply(y)), w = a.add(f.multiply(y));
|
|
2937
|
+
i.addGraphicVertex(u.x, u.y), i.addGraphicVertex(l.x, l.y), i.addGraphicVertex(w.x, w.y), i.addGraphicVertex(u.x, u.y), i.addGraphicVertex(w.x, w.y), i.addGraphicVertex(v.x, v.y);
|
|
2936
2938
|
}
|
|
2937
2939
|
i.endGraphic();
|
|
2938
2940
|
}, () => {
|
|
@@ -2965,7 +2967,7 @@ class Ee {
|
|
|
2965
2967
|
}
|
|
2966
2968
|
}
|
|
2967
2969
|
export {
|
|
2968
|
-
|
|
2970
|
+
Y as BaseTexture,
|
|
2969
2971
|
xe as BlendMode,
|
|
2970
2972
|
Q as CanvasScaleMode,
|
|
2971
2973
|
g as Color,
|
|
@@ -2977,12 +2979,14 @@ export {
|
|
|
2977
2979
|
qt as LineTextureMode,
|
|
2978
2980
|
rt as MAX_LIGHTS,
|
|
2979
2981
|
St as MaskType,
|
|
2982
|
+
Ht as MatrixStack,
|
|
2983
|
+
Gt as MatrixStore,
|
|
2980
2984
|
At as ParticleEmitter,
|
|
2981
2985
|
ge as ParticleShape,
|
|
2982
2986
|
we as Rapid,
|
|
2983
2987
|
_t as RenderTexture,
|
|
2984
2988
|
Lt as TextTexture,
|
|
2985
|
-
|
|
2989
|
+
W as Texture,
|
|
2986
2990
|
it as TextureFilterMode,
|
|
2987
2991
|
Ct as TextureManager,
|
|
2988
2992
|
J as TextureWrapMode,
|