holostaff-widget 3.0.0-alpha.8 → 3.0.0
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/{BufferResource-DXhnw-dI.js → BufferResource-DeLlYxf8.js} +58 -56
- package/dist/{BufferResource-DXhnw-dI.js.map → BufferResource-DeLlYxf8.js.map} +1 -1
- package/dist/CanvasRenderer-BgLtSh22.js +5933 -0
- package/dist/CanvasRenderer-BgLtSh22.js.map +1 -0
- package/dist/Geometry-Bdq2tsB3.js +1017 -0
- package/dist/Geometry-Bdq2tsB3.js.map +1 -0
- package/dist/{RenderTargetSystem-CzB0gbGa.js → RenderTargetSystem-BCBByEgg.js} +1543 -501
- package/dist/RenderTargetSystem-BCBByEgg.js.map +1 -0
- package/dist/{WebGLRenderer-DtR6kMFT.js → WebGLRenderer-3x7mgYt9.js} +55 -54
- package/dist/{WebGLRenderer-DtR6kMFT.js.map → WebGLRenderer-3x7mgYt9.js.map} +1 -1
- package/dist/{WebGPURenderer-dabwtEl1.js → WebGPURenderer-CdbjQMqs.js} +242 -197
- package/dist/WebGPURenderer-CdbjQMqs.js.map +1 -0
- package/dist/{browserAll-BVcYDudp.js → browserAll-DejMU3y7.js} +3 -3
- package/dist/{browserAll-BVcYDudp.js.map → browserAll-DejMU3y7.js.map} +1 -1
- package/dist/getTextureBatchBindGroup-CHJWR-eE.js +23 -0
- package/dist/getTextureBatchBindGroup-CHJWR-eE.js.map +1 -0
- package/dist/hs-widget.es.js +2 -2
- package/dist/hs-widget.umd.js +210 -122
- package/dist/hs-widget.umd.js.map +1 -1
- package/dist/index-C1ZbqCjI.js +17937 -0
- package/dist/index-C1ZbqCjI.js.map +1 -0
- package/dist/{webworkerAll-7qf_N1bC.js → webworkerAll-D5g5Ds7S.js} +12 -12
- package/dist/{webworkerAll-7qf_N1bC.js.map → webworkerAll-D5g5Ds7S.js.map} +1 -1
- package/package.json +2 -1
- package/dist/CanvasRenderer-JN1g1jcS.js +0 -976
- package/dist/CanvasRenderer-JN1g1jcS.js.map +0 -1
- package/dist/Filter-CD8NI4d3.js +0 -57
- package/dist/Filter-CD8NI4d3.js.map +0 -1
- package/dist/RenderTargetSystem-CzB0gbGa.js.map +0 -1
- package/dist/WebGPURenderer-dabwtEl1.js.map +0 -1
- package/dist/index-X9A71QD8.js +0 -25701
- package/dist/index-X9A71QD8.js.map +0 -1
|
@@ -1,6 +1,1012 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { F as
|
|
3
|
-
|
|
1
|
+
import { a as ze, i as T, G as He, w as te, c as u, t as Ct, M, e as re, l as V, x as St, B as se, y as G, F as Ve, S as kt, T as S, d as Q, z as xe, H as Fe, J as Le, K as We, L as Oe, C as F, N as wt, k as Y, D as ne, g as I, R as L, O as Mt, P as Bt, b as ge, Q as _e, f as X, p as Rt, W as Pt, X as At } from "./index-C1ZbqCjI.js";
|
|
2
|
+
import { f as Ut, e as Gt, a as be, b as z, G as $e, h as je, U as ie, d as It, F as Dt, S as Et, R as ae, B as zt } from "./Geometry-Bdq2tsB3.js";
|
|
3
|
+
class ve {
|
|
4
|
+
constructor(e) {
|
|
5
|
+
typeof e == "number" ? this.rawBinaryData = new ArrayBuffer(e) : e instanceof Uint8Array ? this.rawBinaryData = e.buffer : this.rawBinaryData = e, this.uint32View = new Uint32Array(this.rawBinaryData), this.float32View = new Float32Array(this.rawBinaryData), this.size = this.rawBinaryData.byteLength;
|
|
6
|
+
}
|
|
7
|
+
/** View on the raw binary data as a `Int8Array`. */
|
|
8
|
+
get int8View() {
|
|
9
|
+
return this._int8View || (this._int8View = new Int8Array(this.rawBinaryData)), this._int8View;
|
|
10
|
+
}
|
|
11
|
+
/** View on the raw binary data as a `Uint8Array`. */
|
|
12
|
+
get uint8View() {
|
|
13
|
+
return this._uint8View || (this._uint8View = new Uint8Array(this.rawBinaryData)), this._uint8View;
|
|
14
|
+
}
|
|
15
|
+
/** View on the raw binary data as a `Int16Array`. */
|
|
16
|
+
get int16View() {
|
|
17
|
+
return this._int16View || (this._int16View = new Int16Array(this.rawBinaryData)), this._int16View;
|
|
18
|
+
}
|
|
19
|
+
/** View on the raw binary data as a `Int32Array`. */
|
|
20
|
+
get int32View() {
|
|
21
|
+
return this._int32View || (this._int32View = new Int32Array(this.rawBinaryData)), this._int32View;
|
|
22
|
+
}
|
|
23
|
+
/** View on the raw binary data as a `Float64Array`. */
|
|
24
|
+
get float64View() {
|
|
25
|
+
return this._float64Array || (this._float64Array = new Float64Array(this.rawBinaryData)), this._float64Array;
|
|
26
|
+
}
|
|
27
|
+
/** View on the raw binary data as a `BigUint64Array`. */
|
|
28
|
+
get bigUint64View() {
|
|
29
|
+
return this._bigUint64Array || (this._bigUint64Array = new BigUint64Array(this.rawBinaryData)), this._bigUint64Array;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Returns the view of the given type.
|
|
33
|
+
* @param type - One of `int8`, `uint8`, `int16`,
|
|
34
|
+
* `uint16`, `int32`, `uint32`, and `float32`.
|
|
35
|
+
* @returns - typed array of given type
|
|
36
|
+
*/
|
|
37
|
+
view(e) {
|
|
38
|
+
return this[`${e}View`];
|
|
39
|
+
}
|
|
40
|
+
/** Destroys all buffer references. Do not use after calling this. */
|
|
41
|
+
destroy() {
|
|
42
|
+
this.rawBinaryData = null, this.uint32View = null, this.float32View = null, this.uint16View = null, this._int8View = null, this._uint8View = null, this._int16View = null, this._int32View = null, this._float64Array = null, this._bigUint64Array = null;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns the size of the given type in bytes.
|
|
46
|
+
* @param type - One of `int8`, `uint8`, `int16`,
|
|
47
|
+
* `uint16`, `int32`, `uint32`, and `float32`.
|
|
48
|
+
* @returns - size of the type in bytes
|
|
49
|
+
*/
|
|
50
|
+
static sizeOf(e) {
|
|
51
|
+
switch (e) {
|
|
52
|
+
case "int8":
|
|
53
|
+
case "uint8":
|
|
54
|
+
return 1;
|
|
55
|
+
case "int16":
|
|
56
|
+
case "uint16":
|
|
57
|
+
return 2;
|
|
58
|
+
case "int32":
|
|
59
|
+
case "uint32":
|
|
60
|
+
case "float32":
|
|
61
|
+
return 4;
|
|
62
|
+
default:
|
|
63
|
+
throw new Error(`${e} isn't a valid view type`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function ye(n, e, t, r) {
|
|
68
|
+
if (t ?? (t = 0), r ?? (r = Math.min(n.byteLength - t, e.byteLength)), !(t & 7) && !(r & 7)) {
|
|
69
|
+
const s = r / 8;
|
|
70
|
+
new Float64Array(e, 0, s).set(new Float64Array(n, t, s));
|
|
71
|
+
} else if (!(t & 3) && !(r & 3)) {
|
|
72
|
+
const s = r / 4;
|
|
73
|
+
new Float32Array(e, 0, s).set(new Float32Array(n, t, s));
|
|
74
|
+
} else
|
|
75
|
+
new Uint8Array(e).set(new Uint8Array(n, t, r));
|
|
76
|
+
}
|
|
77
|
+
const Ht = {
|
|
78
|
+
normal: "normal-npm",
|
|
79
|
+
add: "add-npm",
|
|
80
|
+
screen: "screen-npm"
|
|
81
|
+
};
|
|
82
|
+
var k = /* @__PURE__ */ ((n) => (n[n.DISABLED = 0] = "DISABLED", n[n.RENDERING_MASK_ADD = 1] = "RENDERING_MASK_ADD", n[n.MASK_ACTIVE = 2] = "MASK_ACTIVE", n[n.INVERSE_MASK_ACTIVE = 3] = "INVERSE_MASK_ACTIVE", n[n.RENDERING_MASK_REMOVE = 4] = "RENDERING_MASK_REMOVE", n[n.NONE = 5] = "NONE", n))(k || {});
|
|
83
|
+
function Te(n, e) {
|
|
84
|
+
return e.alphaMode === "no-premultiply-alpha" && Ht[n] || n;
|
|
85
|
+
}
|
|
86
|
+
const Vt = [
|
|
87
|
+
"precision mediump float;",
|
|
88
|
+
"void main(void){",
|
|
89
|
+
"float test = 0.1;",
|
|
90
|
+
"%forloop%",
|
|
91
|
+
"gl_FragColor = vec4(0.0);",
|
|
92
|
+
"}"
|
|
93
|
+
].join(`
|
|
94
|
+
`);
|
|
95
|
+
function Ft(n) {
|
|
96
|
+
let e = "";
|
|
97
|
+
for (let t = 0; t < n; ++t)
|
|
98
|
+
t > 0 && (e += `
|
|
99
|
+
else `), t < n - 1 && (e += `if(test == ${t}.0){}`);
|
|
100
|
+
return e;
|
|
101
|
+
}
|
|
102
|
+
function Lt(n, e) {
|
|
103
|
+
if (n === 0)
|
|
104
|
+
throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");
|
|
105
|
+
const t = e.createShader(e.FRAGMENT_SHADER);
|
|
106
|
+
try {
|
|
107
|
+
for (; ; ) {
|
|
108
|
+
const r = Vt.replace(/%forloop%/gi, Ft(n));
|
|
109
|
+
if (e.shaderSource(t, r), e.compileShader(t), !e.getShaderParameter(t, e.COMPILE_STATUS))
|
|
110
|
+
n = n / 2 | 0;
|
|
111
|
+
else
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
} finally {
|
|
115
|
+
e.deleteShader(t);
|
|
116
|
+
}
|
|
117
|
+
return n;
|
|
118
|
+
}
|
|
119
|
+
let R = null;
|
|
120
|
+
function Wt() {
|
|
121
|
+
var e;
|
|
122
|
+
if (R) return R;
|
|
123
|
+
const n = Ut();
|
|
124
|
+
return R = n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS), R = Lt(
|
|
125
|
+
R,
|
|
126
|
+
n
|
|
127
|
+
), (e = n.getExtension("WEBGL_lose_context")) == null || e.loseContext(), R;
|
|
128
|
+
}
|
|
129
|
+
class Ot {
|
|
130
|
+
constructor() {
|
|
131
|
+
this.ids = /* @__PURE__ */ Object.create(null), this.textures = [], this.count = 0;
|
|
132
|
+
}
|
|
133
|
+
/** Clear the textures and their locations. */
|
|
134
|
+
clear() {
|
|
135
|
+
for (let e = 0; e < this.count; e++) {
|
|
136
|
+
const t = this.textures[e];
|
|
137
|
+
this.textures[e] = null, this.ids[t.uid] = null;
|
|
138
|
+
}
|
|
139
|
+
this.count = 0;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
class $t {
|
|
143
|
+
constructor() {
|
|
144
|
+
this.renderPipeId = "batch", this.action = "startBatch", this.start = 0, this.size = 0, this.textures = new Ot(), this.blendMode = "normal", this.topology = "triangle-strip", this.canBundle = !0;
|
|
145
|
+
}
|
|
146
|
+
destroy() {
|
|
147
|
+
this.textures = null, this.gpuBindGroup = null, this.bindGroup = null, this.batcher = null, this.elements = null;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const D = [];
|
|
151
|
+
let W = 0;
|
|
152
|
+
He.register({
|
|
153
|
+
clear: () => {
|
|
154
|
+
if (D.length > 0)
|
|
155
|
+
for (const n of D)
|
|
156
|
+
n && n.destroy();
|
|
157
|
+
D.length = 0, W = 0;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
function Ce() {
|
|
161
|
+
return W > 0 ? D[--W] : new $t();
|
|
162
|
+
}
|
|
163
|
+
function Se(n) {
|
|
164
|
+
n.elements = null, D[W++] = n;
|
|
165
|
+
}
|
|
166
|
+
let A = 0;
|
|
167
|
+
const Ne = class Ke {
|
|
168
|
+
constructor(e) {
|
|
169
|
+
this.uid = ze("batcher"), this.dirty = !0, this.batchIndex = 0, this.batches = [], this._elements = [], e = { ...Ke.defaultOptions, ...e }, e.maxTextures || (T("v8.8.0", "maxTextures is a required option for Batcher now, please pass it in the options"), e.maxTextures = Wt());
|
|
170
|
+
const { maxTextures: t, attributesInitialSize: r, indicesInitialSize: s } = e;
|
|
171
|
+
this.attributeBuffer = new ve(r * 4), this.indexBuffer = new Uint16Array(s), this.maxTextures = t;
|
|
172
|
+
}
|
|
173
|
+
begin() {
|
|
174
|
+
this.elementSize = 0, this.elementStart = 0, this.indexSize = 0, this.attributeSize = 0;
|
|
175
|
+
for (let e = 0; e < this.batchIndex; e++)
|
|
176
|
+
Se(this.batches[e]);
|
|
177
|
+
this.batchIndex = 0, this._batchIndexStart = 0, this._batchIndexSize = 0, this.dirty = !0;
|
|
178
|
+
}
|
|
179
|
+
add(e) {
|
|
180
|
+
this._elements[this.elementSize++] = e, e._indexStart = this.indexSize, e._attributeStart = this.attributeSize, e._batcher = this, this.indexSize += e.indexSize, this.attributeSize += e.attributeSize * this.vertexSize;
|
|
181
|
+
}
|
|
182
|
+
checkAndUpdateTexture(e, t) {
|
|
183
|
+
const r = e._batch.textures.ids[t._source.uid];
|
|
184
|
+
return !r && r !== 0 ? !1 : (e._textureId = r, e.texture = t, !0);
|
|
185
|
+
}
|
|
186
|
+
updateElement(e) {
|
|
187
|
+
this.dirty = !0;
|
|
188
|
+
const t = this.attributeBuffer;
|
|
189
|
+
e.packAsQuad ? this.packQuadAttributes(
|
|
190
|
+
e,
|
|
191
|
+
t.float32View,
|
|
192
|
+
t.uint32View,
|
|
193
|
+
e._attributeStart,
|
|
194
|
+
e._textureId
|
|
195
|
+
) : this.packAttributes(
|
|
196
|
+
e,
|
|
197
|
+
t.float32View,
|
|
198
|
+
t.uint32View,
|
|
199
|
+
e._attributeStart,
|
|
200
|
+
e._textureId
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* breaks the batcher. This happens when a batch gets too big,
|
|
205
|
+
* or we need to switch to a different type of rendering (a filter for example)
|
|
206
|
+
* @param instructionSet
|
|
207
|
+
*/
|
|
208
|
+
break(e) {
|
|
209
|
+
const t = this._elements;
|
|
210
|
+
if (!t[this.elementStart]) return;
|
|
211
|
+
let r = Ce(), s = r.textures;
|
|
212
|
+
s.clear();
|
|
213
|
+
const i = t[this.elementStart];
|
|
214
|
+
let a = Te(i.blendMode, i.texture._source), o = i.topology;
|
|
215
|
+
this.attributeSize * 4 > this.attributeBuffer.size && this._resizeAttributeBuffer(this.attributeSize * 4), this.indexSize > this.indexBuffer.length && this._resizeIndexBuffer(this.indexSize);
|
|
216
|
+
const l = this.attributeBuffer.float32View, d = this.attributeBuffer.uint32View, f = this.indexBuffer;
|
|
217
|
+
let c = this._batchIndexSize, x = this._batchIndexStart, g = "startBatch", m = [];
|
|
218
|
+
const v = this.maxTextures;
|
|
219
|
+
for (let _ = this.elementStart; _ < this.elementSize; ++_) {
|
|
220
|
+
const h = t[_];
|
|
221
|
+
t[_] = null;
|
|
222
|
+
const p = h.texture._source, y = Te(h.blendMode, p), b = a !== y || o !== h.topology;
|
|
223
|
+
if (p._batchTick === A && !b) {
|
|
224
|
+
h._textureId = p._textureBindLocation, c += h.indexSize, h.packAsQuad ? (this.packQuadAttributes(
|
|
225
|
+
h,
|
|
226
|
+
l,
|
|
227
|
+
d,
|
|
228
|
+
h._attributeStart,
|
|
229
|
+
h._textureId
|
|
230
|
+
), this.packQuadIndex(
|
|
231
|
+
f,
|
|
232
|
+
h._indexStart,
|
|
233
|
+
h._attributeStart / this.vertexSize
|
|
234
|
+
)) : (this.packAttributes(
|
|
235
|
+
h,
|
|
236
|
+
l,
|
|
237
|
+
d,
|
|
238
|
+
h._attributeStart,
|
|
239
|
+
h._textureId
|
|
240
|
+
), this.packIndex(
|
|
241
|
+
h,
|
|
242
|
+
f,
|
|
243
|
+
h._indexStart,
|
|
244
|
+
h._attributeStart / this.vertexSize
|
|
245
|
+
)), h._batch = r, m.push(h);
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
p._batchTick = A, (s.count >= v || b) && (this._finishBatch(
|
|
249
|
+
r,
|
|
250
|
+
x,
|
|
251
|
+
c - x,
|
|
252
|
+
s,
|
|
253
|
+
a,
|
|
254
|
+
o,
|
|
255
|
+
e,
|
|
256
|
+
g,
|
|
257
|
+
m
|
|
258
|
+
), g = "renderBatch", x = c, a = y, o = h.topology, r = Ce(), s = r.textures, s.clear(), m = [], ++A), h._textureId = p._textureBindLocation = s.count, s.ids[p.uid] = s.count, s.textures[s.count++] = p, h._batch = r, m.push(h), c += h.indexSize, h.packAsQuad ? (this.packQuadAttributes(
|
|
259
|
+
h,
|
|
260
|
+
l,
|
|
261
|
+
d,
|
|
262
|
+
h._attributeStart,
|
|
263
|
+
h._textureId
|
|
264
|
+
), this.packQuadIndex(
|
|
265
|
+
f,
|
|
266
|
+
h._indexStart,
|
|
267
|
+
h._attributeStart / this.vertexSize
|
|
268
|
+
)) : (this.packAttributes(
|
|
269
|
+
h,
|
|
270
|
+
l,
|
|
271
|
+
d,
|
|
272
|
+
h._attributeStart,
|
|
273
|
+
h._textureId
|
|
274
|
+
), this.packIndex(
|
|
275
|
+
h,
|
|
276
|
+
f,
|
|
277
|
+
h._indexStart,
|
|
278
|
+
h._attributeStart / this.vertexSize
|
|
279
|
+
));
|
|
280
|
+
}
|
|
281
|
+
s.count > 0 && (this._finishBatch(
|
|
282
|
+
r,
|
|
283
|
+
x,
|
|
284
|
+
c - x,
|
|
285
|
+
s,
|
|
286
|
+
a,
|
|
287
|
+
o,
|
|
288
|
+
e,
|
|
289
|
+
g,
|
|
290
|
+
m
|
|
291
|
+
), x = c, ++A), this.elementStart = this.elementSize, this._batchIndexStart = x, this._batchIndexSize = c;
|
|
292
|
+
}
|
|
293
|
+
_finishBatch(e, t, r, s, i, a, o, l, d) {
|
|
294
|
+
e.gpuBindGroup = null, e.bindGroup = null, e.action = l, e.batcher = this, e.textures = s, e.blendMode = i, e.topology = a, e.start = t, e.size = r, e.elements = d, ++A, this.batches[this.batchIndex++] = e, o.add(e);
|
|
295
|
+
}
|
|
296
|
+
finish(e) {
|
|
297
|
+
this.break(e);
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Resizes the attribute buffer to the given size (1 = 1 float32)
|
|
301
|
+
* @param size - the size in vertices to ensure (not bytes!)
|
|
302
|
+
*/
|
|
303
|
+
ensureAttributeBuffer(e) {
|
|
304
|
+
e * 4 <= this.attributeBuffer.size || this._resizeAttributeBuffer(e * 4);
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Resizes the index buffer to the given size (1 = 1 float32)
|
|
308
|
+
* @param size - the size in vertices to ensure (not bytes!)
|
|
309
|
+
*/
|
|
310
|
+
ensureIndexBuffer(e) {
|
|
311
|
+
e <= this.indexBuffer.length || this._resizeIndexBuffer(e);
|
|
312
|
+
}
|
|
313
|
+
_resizeAttributeBuffer(e) {
|
|
314
|
+
const t = Math.max(e, this.attributeBuffer.size * 2), r = new ve(t);
|
|
315
|
+
ye(this.attributeBuffer.rawBinaryData, r.rawBinaryData), this.attributeBuffer = r;
|
|
316
|
+
}
|
|
317
|
+
_resizeIndexBuffer(e) {
|
|
318
|
+
const t = this.indexBuffer;
|
|
319
|
+
let r = Math.max(e, t.length * 1.5);
|
|
320
|
+
r += r % 2;
|
|
321
|
+
const s = r > 65535 ? new Uint32Array(r) : new Uint16Array(r);
|
|
322
|
+
if (s.BYTES_PER_ELEMENT !== t.BYTES_PER_ELEMENT)
|
|
323
|
+
for (let i = 0; i < t.length; i++)
|
|
324
|
+
s[i] = t[i];
|
|
325
|
+
else
|
|
326
|
+
ye(t.buffer, s.buffer);
|
|
327
|
+
this.indexBuffer = s;
|
|
328
|
+
}
|
|
329
|
+
packQuadIndex(e, t, r) {
|
|
330
|
+
e[t] = r + 0, e[t + 1] = r + 1, e[t + 2] = r + 2, e[t + 3] = r + 0, e[t + 4] = r + 2, e[t + 5] = r + 3;
|
|
331
|
+
}
|
|
332
|
+
packIndex(e, t, r, s) {
|
|
333
|
+
const i = e.indices, a = e.indexSize, o = e.indexOffset, l = e.attributeOffset;
|
|
334
|
+
for (let d = 0; d < a; d++)
|
|
335
|
+
t[r++] = s + i[d + o] - l;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Destroys the batch and its resources.
|
|
339
|
+
* @param options - destruction options
|
|
340
|
+
* @param options.shader - whether to destroy the associated shader
|
|
341
|
+
*/
|
|
342
|
+
destroy(e = {}) {
|
|
343
|
+
var t;
|
|
344
|
+
if (this.batches !== null) {
|
|
345
|
+
for (let r = 0; r < this.batchIndex; r++)
|
|
346
|
+
Se(this.batches[r]);
|
|
347
|
+
this.batches = null, this.geometry.destroy(!0), this.geometry = null, e.shader && ((t = this.shader) == null || t.destroy(), this.shader = null);
|
|
348
|
+
for (let r = 0; r < this._elements.length; r++)
|
|
349
|
+
this._elements[r] && (this._elements[r]._batch = null);
|
|
350
|
+
this._elements = null, this.indexBuffer = null, this.attributeBuffer.destroy(), this.attributeBuffer = null;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
Ne.defaultOptions = {
|
|
355
|
+
maxTextures: null,
|
|
356
|
+
attributesInitialSize: 4,
|
|
357
|
+
indicesInitialSize: 6
|
|
358
|
+
};
|
|
359
|
+
let jt = Ne;
|
|
360
|
+
const Nt = new Float32Array(1), Kt = new Uint32Array(1);
|
|
361
|
+
class qt extends Gt {
|
|
362
|
+
constructor() {
|
|
363
|
+
const t = new be({
|
|
364
|
+
data: Nt,
|
|
365
|
+
label: "attribute-batch-buffer",
|
|
366
|
+
usage: z.VERTEX | z.COPY_DST,
|
|
367
|
+
shrinkToFit: !1
|
|
368
|
+
}), r = new be({
|
|
369
|
+
data: Kt,
|
|
370
|
+
label: "index-batch-buffer",
|
|
371
|
+
usage: z.INDEX | z.COPY_DST,
|
|
372
|
+
// | BufferUsage.STATIC,
|
|
373
|
+
shrinkToFit: !1
|
|
374
|
+
}), s = 24;
|
|
375
|
+
super({
|
|
376
|
+
attributes: {
|
|
377
|
+
aPosition: {
|
|
378
|
+
buffer: t,
|
|
379
|
+
format: "float32x2",
|
|
380
|
+
stride: s,
|
|
381
|
+
offset: 0
|
|
382
|
+
},
|
|
383
|
+
aUV: {
|
|
384
|
+
buffer: t,
|
|
385
|
+
format: "float32x2",
|
|
386
|
+
stride: s,
|
|
387
|
+
offset: 8
|
|
388
|
+
},
|
|
389
|
+
aColor: {
|
|
390
|
+
buffer: t,
|
|
391
|
+
format: "unorm8x4",
|
|
392
|
+
stride: s,
|
|
393
|
+
offset: 16
|
|
394
|
+
},
|
|
395
|
+
aTextureIdAndRound: {
|
|
396
|
+
buffer: t,
|
|
397
|
+
format: "uint16x2",
|
|
398
|
+
stride: s,
|
|
399
|
+
offset: 20
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
indexBuffer: r
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
function ke(n, e, t) {
|
|
407
|
+
if (n)
|
|
408
|
+
for (const r in n) {
|
|
409
|
+
const s = r.toLocaleLowerCase(), i = e[s];
|
|
410
|
+
if (i) {
|
|
411
|
+
let a = n[r];
|
|
412
|
+
r === "header" && (a = a.replace(/@in\s+[^;]+;\s*/g, "").replace(/@out\s+[^;]+;\s*/g, "")), t && i.push(`//----${t}----//`), i.push(a);
|
|
413
|
+
} else
|
|
414
|
+
te(`${r} placement hook does not exist in shader`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
const Qt = /\{\{(.*?)\}\}/g;
|
|
418
|
+
function we(n) {
|
|
419
|
+
var r;
|
|
420
|
+
const e = {};
|
|
421
|
+
return (((r = n.match(Qt)) == null ? void 0 : r.map((s) => s.replace(/[{()}]/g, ""))) ?? []).forEach((s) => {
|
|
422
|
+
e[s] = [];
|
|
423
|
+
}), e;
|
|
424
|
+
}
|
|
425
|
+
function Me(n, e) {
|
|
426
|
+
let t;
|
|
427
|
+
const r = /@in\s+([^;]+);/g;
|
|
428
|
+
for (; (t = r.exec(n)) !== null; )
|
|
429
|
+
e.push(t[1]);
|
|
430
|
+
}
|
|
431
|
+
function Be(n, e, t = !1) {
|
|
432
|
+
const r = [];
|
|
433
|
+
Me(e, r), n.forEach((o) => {
|
|
434
|
+
o.header && Me(o.header, r);
|
|
435
|
+
});
|
|
436
|
+
const s = r;
|
|
437
|
+
t && s.sort();
|
|
438
|
+
const i = s.map((o, l) => ` @location(${l}) ${o},`).join(`
|
|
439
|
+
`);
|
|
440
|
+
let a = e.replace(/@in\s+[^;]+;\s*/g, "");
|
|
441
|
+
return a = a.replace("{{in}}", `
|
|
442
|
+
${i}
|
|
443
|
+
`), a;
|
|
444
|
+
}
|
|
445
|
+
function Re(n, e) {
|
|
446
|
+
let t;
|
|
447
|
+
const r = /@out\s+([^;]+);/g;
|
|
448
|
+
for (; (t = r.exec(n)) !== null; )
|
|
449
|
+
e.push(t[1]);
|
|
450
|
+
}
|
|
451
|
+
function Yt(n) {
|
|
452
|
+
const t = /\b(\w+)\s*:/g.exec(n);
|
|
453
|
+
return t ? t[1] : "";
|
|
454
|
+
}
|
|
455
|
+
function Xt(n) {
|
|
456
|
+
const e = /@.*?\s+/g;
|
|
457
|
+
return n.replace(e, "");
|
|
458
|
+
}
|
|
459
|
+
function Jt(n, e) {
|
|
460
|
+
const t = [];
|
|
461
|
+
Re(e, t), n.forEach((l) => {
|
|
462
|
+
l.header && Re(l.header, t);
|
|
463
|
+
});
|
|
464
|
+
let r = 0;
|
|
465
|
+
const s = t.sort().map((l) => l.indexOf("builtin") > -1 ? l : `@location(${r++}) ${l}`).join(`,
|
|
466
|
+
`), i = t.sort().map((l) => ` var ${Xt(l)};`).join(`
|
|
467
|
+
`), a = `return VSOutput(
|
|
468
|
+
${t.sort().map((l) => ` ${Yt(l)}`).join(`,
|
|
469
|
+
`)});`;
|
|
470
|
+
let o = e.replace(/@out\s+[^;]+;\s*/g, "");
|
|
471
|
+
return o = o.replace("{{struct}}", `
|
|
472
|
+
${s}
|
|
473
|
+
`), o = o.replace("{{start}}", `
|
|
474
|
+
${i}
|
|
475
|
+
`), o = o.replace("{{return}}", `
|
|
476
|
+
${a}
|
|
477
|
+
`), o;
|
|
478
|
+
}
|
|
479
|
+
function Pe(n, e) {
|
|
480
|
+
let t = n;
|
|
481
|
+
for (const r in e) {
|
|
482
|
+
const s = e[r];
|
|
483
|
+
s.join(`
|
|
484
|
+
`).length ? t = t.replace(`{{${r}}}`, `//-----${r} START-----//
|
|
485
|
+
${s.join(`
|
|
486
|
+
`)}
|
|
487
|
+
//----${r} FINISH----//`) : t = t.replace(`{{${r}}}`, "");
|
|
488
|
+
}
|
|
489
|
+
return t;
|
|
490
|
+
}
|
|
491
|
+
const w = /* @__PURE__ */ Object.create(null), j = /* @__PURE__ */ new Map();
|
|
492
|
+
let Zt = 0;
|
|
493
|
+
function er({
|
|
494
|
+
template: n,
|
|
495
|
+
bits: e
|
|
496
|
+
}) {
|
|
497
|
+
const t = qe(n, e);
|
|
498
|
+
if (w[t]) return w[t];
|
|
499
|
+
const { vertex: r, fragment: s } = rr(n, e);
|
|
500
|
+
return w[t] = Qe(r, s, e), w[t];
|
|
501
|
+
}
|
|
502
|
+
function tr({
|
|
503
|
+
template: n,
|
|
504
|
+
bits: e
|
|
505
|
+
}) {
|
|
506
|
+
const t = qe(n, e);
|
|
507
|
+
return w[t] || (w[t] = Qe(n.vertex, n.fragment, e)), w[t];
|
|
508
|
+
}
|
|
509
|
+
function rr(n, e) {
|
|
510
|
+
const t = e.map((a) => a.vertex).filter((a) => !!a), r = e.map((a) => a.fragment).filter((a) => !!a);
|
|
511
|
+
let s = Be(t, n.vertex, !0);
|
|
512
|
+
s = Jt(t, s);
|
|
513
|
+
const i = Be(r, n.fragment, !0);
|
|
514
|
+
return {
|
|
515
|
+
vertex: s,
|
|
516
|
+
fragment: i
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
function qe(n, e) {
|
|
520
|
+
return e.map((t) => (j.has(t) || j.set(t, Zt++), j.get(t))).sort((t, r) => t - r).join("-") + n.vertex + n.fragment;
|
|
521
|
+
}
|
|
522
|
+
function Qe(n, e, t) {
|
|
523
|
+
const r = we(n), s = we(e);
|
|
524
|
+
return t.forEach((i) => {
|
|
525
|
+
ke(i.vertex, r, i.name), ke(i.fragment, s, i.name);
|
|
526
|
+
}), {
|
|
527
|
+
vertex: Pe(n, r),
|
|
528
|
+
fragment: Pe(e, s)
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
const sr = (
|
|
532
|
+
/* wgsl */
|
|
533
|
+
`
|
|
534
|
+
@in aPosition: vec2<f32>;
|
|
535
|
+
@in aUV: vec2<f32>;
|
|
536
|
+
|
|
537
|
+
@out @builtin(position) vPosition: vec4<f32>;
|
|
538
|
+
@out vUV : vec2<f32>;
|
|
539
|
+
@out vColor : vec4<f32>;
|
|
540
|
+
|
|
541
|
+
{{header}}
|
|
542
|
+
|
|
543
|
+
struct VSOutput {
|
|
544
|
+
{{struct}}
|
|
545
|
+
};
|
|
546
|
+
|
|
547
|
+
@vertex
|
|
548
|
+
fn main( {{in}} ) -> VSOutput {
|
|
549
|
+
|
|
550
|
+
var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
|
|
551
|
+
var modelMatrix = mat3x3<f32>(
|
|
552
|
+
1.0, 0.0, 0.0,
|
|
553
|
+
0.0, 1.0, 0.0,
|
|
554
|
+
0.0, 0.0, 1.0
|
|
555
|
+
);
|
|
556
|
+
var position = aPosition;
|
|
557
|
+
var uv = aUV;
|
|
558
|
+
|
|
559
|
+
{{start}}
|
|
560
|
+
|
|
561
|
+
vColor = vec4<f32>(1., 1., 1., 1.);
|
|
562
|
+
|
|
563
|
+
{{main}}
|
|
564
|
+
|
|
565
|
+
vUV = uv;
|
|
566
|
+
|
|
567
|
+
var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
|
568
|
+
|
|
569
|
+
vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
|
|
570
|
+
|
|
571
|
+
vColor *= globalUniforms.uWorldColorAlpha;
|
|
572
|
+
|
|
573
|
+
{{end}}
|
|
574
|
+
|
|
575
|
+
{{return}}
|
|
576
|
+
};
|
|
577
|
+
`
|
|
578
|
+
), nr = (
|
|
579
|
+
/* wgsl */
|
|
580
|
+
`
|
|
581
|
+
@in vUV : vec2<f32>;
|
|
582
|
+
@in vColor : vec4<f32>;
|
|
583
|
+
|
|
584
|
+
{{header}}
|
|
585
|
+
|
|
586
|
+
@fragment
|
|
587
|
+
fn main(
|
|
588
|
+
{{in}}
|
|
589
|
+
) -> @location(0) vec4<f32> {
|
|
590
|
+
|
|
591
|
+
{{start}}
|
|
592
|
+
|
|
593
|
+
var outColor:vec4<f32>;
|
|
594
|
+
|
|
595
|
+
{{main}}
|
|
596
|
+
|
|
597
|
+
var finalColor:vec4<f32> = outColor * vColor;
|
|
598
|
+
|
|
599
|
+
{{end}}
|
|
600
|
+
|
|
601
|
+
return finalColor;
|
|
602
|
+
};
|
|
603
|
+
`
|
|
604
|
+
), ir = (
|
|
605
|
+
/* glsl */
|
|
606
|
+
`
|
|
607
|
+
in vec2 aPosition;
|
|
608
|
+
in vec2 aUV;
|
|
609
|
+
|
|
610
|
+
out vec4 vColor;
|
|
611
|
+
out vec2 vUV;
|
|
612
|
+
|
|
613
|
+
{{header}}
|
|
614
|
+
|
|
615
|
+
void main(void){
|
|
616
|
+
|
|
617
|
+
mat3 worldTransformMatrix = uWorldTransformMatrix;
|
|
618
|
+
mat3 modelMatrix = mat3(
|
|
619
|
+
1.0, 0.0, 0.0,
|
|
620
|
+
0.0, 1.0, 0.0,
|
|
621
|
+
0.0, 0.0, 1.0
|
|
622
|
+
);
|
|
623
|
+
vec2 position = aPosition;
|
|
624
|
+
vec2 uv = aUV;
|
|
625
|
+
|
|
626
|
+
{{start}}
|
|
627
|
+
|
|
628
|
+
vColor = vec4(1.);
|
|
629
|
+
|
|
630
|
+
{{main}}
|
|
631
|
+
|
|
632
|
+
vUV = uv;
|
|
633
|
+
|
|
634
|
+
mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
|
|
635
|
+
|
|
636
|
+
gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
|
|
637
|
+
|
|
638
|
+
vColor *= uWorldColorAlpha;
|
|
639
|
+
|
|
640
|
+
{{end}}
|
|
641
|
+
}
|
|
642
|
+
`
|
|
643
|
+
), ar = (
|
|
644
|
+
/* glsl */
|
|
645
|
+
`
|
|
646
|
+
|
|
647
|
+
in vec4 vColor;
|
|
648
|
+
in vec2 vUV;
|
|
649
|
+
|
|
650
|
+
out vec4 finalColor;
|
|
651
|
+
|
|
652
|
+
{{header}}
|
|
653
|
+
|
|
654
|
+
void main(void) {
|
|
655
|
+
|
|
656
|
+
{{start}}
|
|
657
|
+
|
|
658
|
+
vec4 outColor;
|
|
659
|
+
|
|
660
|
+
{{main}}
|
|
661
|
+
|
|
662
|
+
finalColor = outColor * vColor;
|
|
663
|
+
|
|
664
|
+
{{end}}
|
|
665
|
+
}
|
|
666
|
+
`
|
|
667
|
+
), or = {
|
|
668
|
+
name: "global-uniforms-bit",
|
|
669
|
+
vertex: {
|
|
670
|
+
header: (
|
|
671
|
+
/* wgsl */
|
|
672
|
+
`
|
|
673
|
+
struct GlobalUniforms {
|
|
674
|
+
uProjectionMatrix:mat3x3<f32>,
|
|
675
|
+
uWorldTransformMatrix:mat3x3<f32>,
|
|
676
|
+
uWorldColorAlpha: vec4<f32>,
|
|
677
|
+
uResolution: vec2<f32>,
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
@group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
|
|
681
|
+
`
|
|
682
|
+
)
|
|
683
|
+
}
|
|
684
|
+
}, lr = {
|
|
685
|
+
name: "global-uniforms-bit",
|
|
686
|
+
vertex: {
|
|
687
|
+
header: (
|
|
688
|
+
/* glsl */
|
|
689
|
+
`
|
|
690
|
+
uniform mat3 uProjectionMatrix;
|
|
691
|
+
uniform mat3 uWorldTransformMatrix;
|
|
692
|
+
uniform vec4 uWorldColorAlpha;
|
|
693
|
+
uniform vec2 uResolution;
|
|
694
|
+
`
|
|
695
|
+
)
|
|
696
|
+
}
|
|
697
|
+
};
|
|
698
|
+
function ur({ bits: n, name: e }) {
|
|
699
|
+
const t = er({
|
|
700
|
+
template: {
|
|
701
|
+
fragment: nr,
|
|
702
|
+
vertex: sr
|
|
703
|
+
},
|
|
704
|
+
bits: [
|
|
705
|
+
or,
|
|
706
|
+
...n
|
|
707
|
+
]
|
|
708
|
+
});
|
|
709
|
+
return je.from({
|
|
710
|
+
name: e,
|
|
711
|
+
vertex: {
|
|
712
|
+
source: t.vertex,
|
|
713
|
+
entryPoint: "main"
|
|
714
|
+
},
|
|
715
|
+
fragment: {
|
|
716
|
+
source: t.fragment,
|
|
717
|
+
entryPoint: "main"
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
function cr({ bits: n, name: e }) {
|
|
722
|
+
return new $e({
|
|
723
|
+
name: e,
|
|
724
|
+
...tr({
|
|
725
|
+
template: {
|
|
726
|
+
vertex: ir,
|
|
727
|
+
fragment: ar
|
|
728
|
+
},
|
|
729
|
+
bits: [
|
|
730
|
+
lr,
|
|
731
|
+
...n
|
|
732
|
+
]
|
|
733
|
+
})
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
const dr = {
|
|
737
|
+
name: "color-bit",
|
|
738
|
+
vertex: {
|
|
739
|
+
header: (
|
|
740
|
+
/* wgsl */
|
|
741
|
+
`
|
|
742
|
+
@in aColor: vec4<f32>;
|
|
743
|
+
`
|
|
744
|
+
),
|
|
745
|
+
main: (
|
|
746
|
+
/* wgsl */
|
|
747
|
+
`
|
|
748
|
+
vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
|
|
749
|
+
`
|
|
750
|
+
)
|
|
751
|
+
}
|
|
752
|
+
}, hr = {
|
|
753
|
+
name: "color-bit",
|
|
754
|
+
vertex: {
|
|
755
|
+
header: (
|
|
756
|
+
/* glsl */
|
|
757
|
+
`
|
|
758
|
+
in vec4 aColor;
|
|
759
|
+
`
|
|
760
|
+
),
|
|
761
|
+
main: (
|
|
762
|
+
/* glsl */
|
|
763
|
+
`
|
|
764
|
+
vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
|
|
765
|
+
`
|
|
766
|
+
)
|
|
767
|
+
}
|
|
768
|
+
}, N = {};
|
|
769
|
+
function fr(n) {
|
|
770
|
+
const e = [];
|
|
771
|
+
if (n === 1)
|
|
772
|
+
e.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"), e.push("@group(1) @binding(1) var textureSampler1: sampler;");
|
|
773
|
+
else {
|
|
774
|
+
let t = 0;
|
|
775
|
+
for (let r = 0; r < n; r++)
|
|
776
|
+
e.push(`@group(1) @binding(${t++}) var textureSource${r + 1}: texture_2d<f32>;`), e.push(`@group(1) @binding(${t++}) var textureSampler${r + 1}: sampler;`);
|
|
777
|
+
}
|
|
778
|
+
return e.join(`
|
|
779
|
+
`);
|
|
780
|
+
}
|
|
781
|
+
function pr(n) {
|
|
782
|
+
const e = [];
|
|
783
|
+
if (n === 1)
|
|
784
|
+
e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");
|
|
785
|
+
else {
|
|
786
|
+
e.push("switch vTextureId {");
|
|
787
|
+
for (let t = 0; t < n; t++)
|
|
788
|
+
t === n - 1 ? e.push(" default:{") : e.push(` case ${t}:{`), e.push(` outColor = textureSampleGrad(textureSource${t + 1}, textureSampler${t + 1}, vUV, uvDx, uvDy);`), e.push(" break;}");
|
|
789
|
+
e.push("}");
|
|
790
|
+
}
|
|
791
|
+
return e.join(`
|
|
792
|
+
`);
|
|
793
|
+
}
|
|
794
|
+
function mr(n) {
|
|
795
|
+
return N[n] || (N[n] = {
|
|
796
|
+
name: "texture-batch-bit",
|
|
797
|
+
vertex: {
|
|
798
|
+
header: `
|
|
799
|
+
@in aTextureIdAndRound: vec2<u32>;
|
|
800
|
+
@out @interpolate(flat) vTextureId : u32;
|
|
801
|
+
`,
|
|
802
|
+
main: `
|
|
803
|
+
vTextureId = aTextureIdAndRound.y;
|
|
804
|
+
`,
|
|
805
|
+
end: `
|
|
806
|
+
if(aTextureIdAndRound.x == 1)
|
|
807
|
+
{
|
|
808
|
+
vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
|
|
809
|
+
}
|
|
810
|
+
`
|
|
811
|
+
},
|
|
812
|
+
fragment: {
|
|
813
|
+
header: `
|
|
814
|
+
@in @interpolate(flat) vTextureId: u32;
|
|
815
|
+
|
|
816
|
+
${fr(n)}
|
|
817
|
+
`,
|
|
818
|
+
main: `
|
|
819
|
+
var uvDx = dpdx(vUV);
|
|
820
|
+
var uvDy = dpdy(vUV);
|
|
821
|
+
|
|
822
|
+
${pr(n)}
|
|
823
|
+
`
|
|
824
|
+
}
|
|
825
|
+
}), N[n];
|
|
826
|
+
}
|
|
827
|
+
const K = {};
|
|
828
|
+
function xr(n) {
|
|
829
|
+
const e = [];
|
|
830
|
+
for (let t = 0; t < n; t++)
|
|
831
|
+
t > 0 && e.push("else"), t < n - 1 && e.push(`if(vTextureId < ${t}.5)`), e.push("{"), e.push(` outColor = texture(uTextures[${t}], vUV);`), e.push("}");
|
|
832
|
+
return e.join(`
|
|
833
|
+
`);
|
|
834
|
+
}
|
|
835
|
+
function gr(n) {
|
|
836
|
+
return K[n] || (K[n] = {
|
|
837
|
+
name: "texture-batch-bit",
|
|
838
|
+
vertex: {
|
|
839
|
+
header: `
|
|
840
|
+
in vec2 aTextureIdAndRound;
|
|
841
|
+
out float vTextureId;
|
|
842
|
+
|
|
843
|
+
`,
|
|
844
|
+
main: `
|
|
845
|
+
vTextureId = aTextureIdAndRound.y;
|
|
846
|
+
`,
|
|
847
|
+
end: `
|
|
848
|
+
if(aTextureIdAndRound.x == 1.)
|
|
849
|
+
{
|
|
850
|
+
gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
|
|
851
|
+
}
|
|
852
|
+
`
|
|
853
|
+
},
|
|
854
|
+
fragment: {
|
|
855
|
+
header: `
|
|
856
|
+
in float vTextureId;
|
|
857
|
+
|
|
858
|
+
uniform sampler2D uTextures[${n}];
|
|
859
|
+
|
|
860
|
+
`,
|
|
861
|
+
main: `
|
|
862
|
+
|
|
863
|
+
${xr(n)}
|
|
864
|
+
`
|
|
865
|
+
}
|
|
866
|
+
}), K[n];
|
|
867
|
+
}
|
|
868
|
+
const _r = {
|
|
869
|
+
name: "round-pixels-bit",
|
|
870
|
+
vertex: {
|
|
871
|
+
header: (
|
|
872
|
+
/* wgsl */
|
|
873
|
+
`
|
|
874
|
+
fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
|
|
875
|
+
{
|
|
876
|
+
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
877
|
+
}
|
|
878
|
+
`
|
|
879
|
+
)
|
|
880
|
+
}
|
|
881
|
+
}, br = {
|
|
882
|
+
name: "round-pixels-bit",
|
|
883
|
+
vertex: {
|
|
884
|
+
header: (
|
|
885
|
+
/* glsl */
|
|
886
|
+
`
|
|
887
|
+
vec2 roundPixels(vec2 position, vec2 targetSize)
|
|
888
|
+
{
|
|
889
|
+
return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
|
|
890
|
+
}
|
|
891
|
+
`
|
|
892
|
+
)
|
|
893
|
+
}
|
|
894
|
+
}, Ae = {};
|
|
895
|
+
function vr(n) {
|
|
896
|
+
let e = Ae[n];
|
|
897
|
+
if (e) return e;
|
|
898
|
+
const t = new Int32Array(n);
|
|
899
|
+
for (let r = 0; r < n; r++)
|
|
900
|
+
t[r] = r;
|
|
901
|
+
return e = Ae[n] = new ie({
|
|
902
|
+
uTextures: { value: t, type: "i32", size: n }
|
|
903
|
+
}, { isStatic: !0 }), e;
|
|
904
|
+
}
|
|
905
|
+
class Ue extends It {
|
|
906
|
+
constructor(e) {
|
|
907
|
+
const t = cr({
|
|
908
|
+
name: "batch",
|
|
909
|
+
bits: [
|
|
910
|
+
hr,
|
|
911
|
+
gr(e),
|
|
912
|
+
br
|
|
913
|
+
]
|
|
914
|
+
}), r = ur({
|
|
915
|
+
name: "batch",
|
|
916
|
+
bits: [
|
|
917
|
+
dr,
|
|
918
|
+
mr(e),
|
|
919
|
+
_r
|
|
920
|
+
]
|
|
921
|
+
});
|
|
922
|
+
super({
|
|
923
|
+
glProgram: t,
|
|
924
|
+
gpuProgram: r,
|
|
925
|
+
resources: {
|
|
926
|
+
batchSamplers: vr(e)
|
|
927
|
+
}
|
|
928
|
+
}), this.maxTextures = e;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
let U = null;
|
|
932
|
+
const Ye = class Xe extends jt {
|
|
933
|
+
constructor(e) {
|
|
934
|
+
super(e), this.geometry = new qt(), this.name = Xe.extension.name, this.vertexSize = 6, U ?? (U = new Ue(e.maxTextures)), this.shader = U;
|
|
935
|
+
}
|
|
936
|
+
/**
|
|
937
|
+
* Packs the attributes of a DefaultBatchableMeshElement into the provided views.
|
|
938
|
+
* @param element - The DefaultBatchableMeshElement to pack.
|
|
939
|
+
* @param float32View - The Float32Array view to pack into.
|
|
940
|
+
* @param uint32View - The Uint32Array view to pack into.
|
|
941
|
+
* @param index - The starting index in the views.
|
|
942
|
+
* @param textureId - The texture ID to use.
|
|
943
|
+
*/
|
|
944
|
+
packAttributes(e, t, r, s, i) {
|
|
945
|
+
const a = i << 16 | e.roundPixels & 65535, o = e.transform, l = o.a, d = o.b, f = o.c, c = o.d, x = o.tx, g = o.ty, { positions: m, uvs: v } = e, _ = e.color, h = e.attributeOffset, C = h + e.attributeSize;
|
|
946
|
+
for (let p = h; p < C; p++) {
|
|
947
|
+
const y = p * 2, b = m[y], B = m[y + 1];
|
|
948
|
+
t[s++] = l * b + f * B + x, t[s++] = c * B + d * b + g, t[s++] = v[y], t[s++] = v[y + 1], r[s++] = _, r[s++] = a;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
/**
|
|
952
|
+
* Packs the attributes of a DefaultBatchableQuadElement into the provided views.
|
|
953
|
+
* @param element - The DefaultBatchableQuadElement to pack.
|
|
954
|
+
* @param float32View - The Float32Array view to pack into.
|
|
955
|
+
* @param uint32View - The Uint32Array view to pack into.
|
|
956
|
+
* @param index - The starting index in the views.
|
|
957
|
+
* @param textureId - The texture ID to use.
|
|
958
|
+
*/
|
|
959
|
+
packQuadAttributes(e, t, r, s, i) {
|
|
960
|
+
const a = e.texture, o = e.transform, l = o.a, d = o.b, f = o.c, c = o.d, x = o.tx, g = o.ty, m = e.bounds, v = m.maxX, _ = m.minX, h = m.maxY, C = m.minY, p = a.uvs, y = e.color, b = i << 16 | e.roundPixels & 65535;
|
|
961
|
+
t[s + 0] = l * _ + f * C + x, t[s + 1] = c * C + d * _ + g, t[s + 2] = p.x0, t[s + 3] = p.y0, r[s + 4] = y, r[s + 5] = b, t[s + 6] = l * v + f * C + x, t[s + 7] = c * C + d * v + g, t[s + 8] = p.x1, t[s + 9] = p.y1, r[s + 10] = y, r[s + 11] = b, t[s + 12] = l * v + f * h + x, t[s + 13] = c * h + d * v + g, t[s + 14] = p.x2, t[s + 15] = p.y2, r[s + 16] = y, r[s + 17] = b, t[s + 18] = l * _ + f * h + x, t[s + 19] = c * h + d * _ + g, t[s + 20] = p.x3, t[s + 21] = p.y3, r[s + 22] = y, r[s + 23] = b;
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Updates the maximum number of textures that can be used in the shader.
|
|
965
|
+
* @param maxTextures - The maximum number of textures that can be used in the shader.
|
|
966
|
+
* @internal
|
|
967
|
+
*/
|
|
968
|
+
_updateMaxTextures(e) {
|
|
969
|
+
this.shader.maxTextures !== e && (U = new Ue(e), this.shader = U);
|
|
970
|
+
}
|
|
971
|
+
destroy() {
|
|
972
|
+
this.shader = null, super.destroy();
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
Ye.extension = {
|
|
976
|
+
type: [
|
|
977
|
+
u.Batcher
|
|
978
|
+
],
|
|
979
|
+
name: "default"
|
|
980
|
+
};
|
|
981
|
+
let Je = Ye;
|
|
982
|
+
class qr {
|
|
983
|
+
constructor(e) {
|
|
984
|
+
this.items = /* @__PURE__ */ Object.create(null);
|
|
985
|
+
const { renderer: t, type: r, onUnload: s, priority: i, name: a } = e;
|
|
986
|
+
this._renderer = t, t.gc.addResourceHash(this, "items", r, i ?? 0), this._onUnload = s, this.name = a;
|
|
987
|
+
}
|
|
988
|
+
/**
|
|
989
|
+
* Add an item to the hash. No-op if already added.
|
|
990
|
+
* @param item
|
|
991
|
+
* @returns true if the item was added, false if it was already in the hash
|
|
992
|
+
*/
|
|
993
|
+
add(e) {
|
|
994
|
+
return this.items[e.uid] ? !1 : (this.items[e.uid] = e, e.once("unload", this.remove, this), e._gcLastUsed = this._renderer.gc.now, !0);
|
|
995
|
+
}
|
|
996
|
+
remove(e, ...t) {
|
|
997
|
+
var s;
|
|
998
|
+
if (!this.items[e.uid]) return;
|
|
999
|
+
const r = e._gpuData[this._renderer.uid];
|
|
1000
|
+
r && ((s = this._onUnload) == null || s.call(this, e, ...t), r.destroy(), e._gpuData[this._renderer.uid] = null, this.items[e.uid] = null);
|
|
1001
|
+
}
|
|
1002
|
+
removeAll(...e) {
|
|
1003
|
+
Object.values(this.items).forEach((t) => t && this.remove(t, ...e));
|
|
1004
|
+
}
|
|
1005
|
+
destroy(...e) {
|
|
1006
|
+
this.removeAll(...e), this.items = /* @__PURE__ */ Object.create(null), this._renderer = null, this._onUnload = null;
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
var yr = `in vec2 vMaskCoord;
|
|
4
1010
|
in vec2 vTextureCoord;
|
|
5
1011
|
|
|
6
1012
|
uniform sampler2D uTexture;
|
|
@@ -34,7 +1040,7 @@ void main(void)
|
|
|
34
1040
|
|
|
35
1041
|
finalColor = original * a;
|
|
36
1042
|
}
|
|
37
|
-
`,
|
|
1043
|
+
`, Tr = `in vec2 aPosition;
|
|
38
1044
|
|
|
39
1045
|
out vec2 vTextureCoord;
|
|
40
1046
|
out vec2 vMaskCoord;
|
|
@@ -71,7 +1077,7 @@ void main(void)
|
|
|
71
1077
|
vTextureCoord = filterTextureCoord(aPosition);
|
|
72
1078
|
vMaskCoord = getFilterCoord(aPosition);
|
|
73
1079
|
}
|
|
74
|
-
`,
|
|
1080
|
+
`, Ge = `struct GlobalFilterUniforms {
|
|
75
1081
|
uInputSize:vec4<f32>,
|
|
76
1082
|
uInputPixel:vec4<f32>,
|
|
77
1083
|
uInputClamp:vec4<f32>,
|
|
@@ -170,34 +1176,34 @@ fn mainFragment(
|
|
|
170
1176
|
return source * a;
|
|
171
1177
|
}
|
|
172
1178
|
`;
|
|
173
|
-
class
|
|
1179
|
+
class Cr extends Dt {
|
|
174
1180
|
constructor(e) {
|
|
175
|
-
const { sprite: t, ...r } = e, s = new
|
|
176
|
-
uFilterMatrix: { value: new
|
|
1181
|
+
const { sprite: t, ...r } = e, s = new Ct(t.texture), i = new ie({
|
|
1182
|
+
uFilterMatrix: { value: new M(), type: "mat3x3<f32>" },
|
|
177
1183
|
uMaskClamp: { value: s.uClampFrame, type: "vec4<f32>" },
|
|
178
1184
|
uAlpha: { value: 1, type: "f32" },
|
|
179
1185
|
uInverse: { value: e.inverse ? 1 : 0, type: "f32" }
|
|
180
|
-
}),
|
|
1186
|
+
}), a = je.from({
|
|
181
1187
|
vertex: {
|
|
182
|
-
source:
|
|
1188
|
+
source: Ge,
|
|
183
1189
|
entryPoint: "mainVertex"
|
|
184
1190
|
},
|
|
185
1191
|
fragment: {
|
|
186
|
-
source:
|
|
1192
|
+
source: Ge,
|
|
187
1193
|
entryPoint: "mainFragment"
|
|
188
1194
|
}
|
|
189
|
-
}), o =
|
|
190
|
-
vertex:
|
|
191
|
-
fragment:
|
|
1195
|
+
}), o = $e.from({
|
|
1196
|
+
vertex: Tr,
|
|
1197
|
+
fragment: yr,
|
|
192
1198
|
name: "mask-filter"
|
|
193
1199
|
});
|
|
194
1200
|
super({
|
|
195
1201
|
...r,
|
|
196
|
-
gpuProgram:
|
|
1202
|
+
gpuProgram: a,
|
|
197
1203
|
glProgram: o,
|
|
198
1204
|
clipToViewport: !1,
|
|
199
1205
|
resources: {
|
|
200
|
-
filterUniforms:
|
|
1206
|
+
filterUniforms: i,
|
|
201
1207
|
uMaskTexture: t.texture.source
|
|
202
1208
|
}
|
|
203
1209
|
}), this.sprite = t, this._textureMatrix = s;
|
|
@@ -215,17 +1221,38 @@ class lt extends at {
|
|
|
215
1221
|
).prepend(this._textureMatrix.mapCoord), this.resources.uMaskTexture = this.sprite.texture.source, e.applyFilter(this, t, r, s);
|
|
216
1222
|
}
|
|
217
1223
|
}
|
|
218
|
-
|
|
1224
|
+
function Sr(n, e, t) {
|
|
1225
|
+
const r = (n >> 24 & 255) / 255;
|
|
1226
|
+
e[t++] = (n & 255) / 255 * r, e[t++] = (n >> 8 & 255) / 255 * r, e[t++] = (n >> 16 & 255) / 255 * r, e[t++] = r;
|
|
1227
|
+
}
|
|
1228
|
+
class Ze {
|
|
1229
|
+
constructor() {
|
|
1230
|
+
this.batcherName = "default", this.topology = "triangle-list", this.attributeSize = 4, this.indexSize = 6, this.packAsQuad = !0, this.roundPixels = 0, this._attributeStart = 0, this._batcher = null, this._batch = null;
|
|
1231
|
+
}
|
|
1232
|
+
get blendMode() {
|
|
1233
|
+
return this.renderable.groupBlendMode;
|
|
1234
|
+
}
|
|
1235
|
+
get color() {
|
|
1236
|
+
return this.renderable.groupColorAlpha;
|
|
1237
|
+
}
|
|
1238
|
+
reset() {
|
|
1239
|
+
this.renderable = null, this.texture = null, this._batcher = null, this._batch = null, this.bounds = null;
|
|
1240
|
+
}
|
|
1241
|
+
destroy() {
|
|
1242
|
+
this.reset();
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
const oe = class et {
|
|
219
1246
|
constructor(e, t) {
|
|
220
1247
|
var r, s;
|
|
221
|
-
this.state =
|
|
1248
|
+
this.state = Et.for2d(), this._batchersByInstructionSet = /* @__PURE__ */ Object.create(null), this._activeBatches = /* @__PURE__ */ Object.create(null), this.renderer = e, this._adaptor = t, (s = (r = this._adaptor).init) == null || s.call(r, this);
|
|
222
1249
|
}
|
|
223
1250
|
static getBatcher(e) {
|
|
224
1251
|
return new this._availableBatchers[e]();
|
|
225
1252
|
}
|
|
226
1253
|
buildStart(e) {
|
|
227
1254
|
let t = this._batchersByInstructionSet[e.uid];
|
|
228
|
-
t || (t = this._batchersByInstructionSet[e.uid] = /* @__PURE__ */ Object.create(null), t.default || (t.default = new
|
|
1255
|
+
t || (t = this._batchersByInstructionSet[e.uid] = /* @__PURE__ */ Object.create(null), t.default || (t.default = new Je({
|
|
229
1256
|
maxTextures: this.renderer.limits.maxBatchableTextures
|
|
230
1257
|
}))), this._activeBatches = t, this._activeBatch = this._activeBatches.default;
|
|
231
1258
|
for (const r in this._activeBatches)
|
|
@@ -235,7 +1262,7 @@ const j = class ge {
|
|
|
235
1262
|
if (this._activeBatch.name !== e.batcherName) {
|
|
236
1263
|
this._activeBatch.break(t);
|
|
237
1264
|
let r = this._activeBatches[e.batcherName];
|
|
238
|
-
r || (r = this._activeBatches[e.batcherName] =
|
|
1265
|
+
r || (r = this._activeBatches[e.batcherName] = et.getBatcher(e.batcherName), r.begin()), this._activeBatch = r;
|
|
239
1266
|
}
|
|
240
1267
|
this._activeBatch.add(e);
|
|
241
1268
|
}
|
|
@@ -246,15 +1273,15 @@ const j = class ge {
|
|
|
246
1273
|
this._activeBatch.break(e);
|
|
247
1274
|
const t = this._activeBatches;
|
|
248
1275
|
for (const r in t) {
|
|
249
|
-
const s = t[r],
|
|
250
|
-
|
|
1276
|
+
const s = t[r], i = s.geometry;
|
|
1277
|
+
i.indexBuffer.setDataWithSize(s.indexBuffer, s.indexSize, !0), i.buffers[0].setDataWithSize(s.attributeBuffer.float32View, s.attributeSize, !1);
|
|
251
1278
|
}
|
|
252
1279
|
}
|
|
253
1280
|
upload(e) {
|
|
254
1281
|
const t = this._batchersByInstructionSet[e.uid];
|
|
255
1282
|
for (const r in t) {
|
|
256
|
-
const s = t[r],
|
|
257
|
-
s.dirty && (s.dirty = !1,
|
|
1283
|
+
const s = t[r], i = s.geometry;
|
|
1284
|
+
s.dirty && (s.dirty = !1, i.buffers[0].update(s.attributeSize * 4));
|
|
258
1285
|
}
|
|
259
1286
|
}
|
|
260
1287
|
execute(e) {
|
|
@@ -271,23 +1298,23 @@ const j = class ge {
|
|
|
271
1298
|
this._activeBatches = null;
|
|
272
1299
|
}
|
|
273
1300
|
};
|
|
274
|
-
|
|
1301
|
+
oe.extension = {
|
|
275
1302
|
type: [
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
1303
|
+
u.WebGLPipes,
|
|
1304
|
+
u.WebGPUPipes,
|
|
1305
|
+
u.CanvasPipes
|
|
279
1306
|
],
|
|
280
1307
|
name: "batch"
|
|
281
1308
|
};
|
|
282
|
-
|
|
283
|
-
let
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const
|
|
287
|
-
class
|
|
1309
|
+
oe._availableBatchers = /* @__PURE__ */ Object.create(null);
|
|
1310
|
+
let tt = oe;
|
|
1311
|
+
re.handleByMap(u.Batcher, tt._availableBatchers);
|
|
1312
|
+
re.add(Je);
|
|
1313
|
+
const kr = new se();
|
|
1314
|
+
class wr extends Ve {
|
|
288
1315
|
constructor() {
|
|
289
|
-
super(), this.filters = [new
|
|
290
|
-
sprite: new
|
|
1316
|
+
super(), this.filters = [new Cr({
|
|
1317
|
+
sprite: new kt(S.EMPTY),
|
|
291
1318
|
inverse: !1,
|
|
292
1319
|
resolution: "inherit",
|
|
293
1320
|
antialias: "inherit"
|
|
@@ -306,7 +1333,7 @@ class ut extends de {
|
|
|
306
1333
|
this.filters[0].inverse = e;
|
|
307
1334
|
}
|
|
308
1335
|
}
|
|
309
|
-
class
|
|
1336
|
+
class rt {
|
|
310
1337
|
constructor(e) {
|
|
311
1338
|
this._activeMaskStage = [], this._renderer = e;
|
|
312
1339
|
}
|
|
@@ -320,12 +1347,12 @@ class xe {
|
|
|
320
1347
|
canBundle: !1,
|
|
321
1348
|
maskedContainer: t
|
|
322
1349
|
}), e.inverse = t._maskOptions.inverse, e.renderMaskToTexture) {
|
|
323
|
-
const
|
|
324
|
-
|
|
1350
|
+
const i = e.mask;
|
|
1351
|
+
i.includeInBuild = !0, i.collectRenderables(
|
|
325
1352
|
r,
|
|
326
1353
|
s,
|
|
327
1354
|
null
|
|
328
|
-
),
|
|
1355
|
+
), i.includeInBuild = !1;
|
|
329
1356
|
}
|
|
330
1357
|
s.renderPipes.batch.break(r), r.add({
|
|
331
1358
|
renderPipeId: "alphaMask",
|
|
@@ -348,23 +1375,23 @@ class xe {
|
|
|
348
1375
|
execute(e) {
|
|
349
1376
|
const t = this._renderer, r = e.mask.renderMaskToTexture;
|
|
350
1377
|
if (e.action === "pushMaskBegin") {
|
|
351
|
-
const s =
|
|
1378
|
+
const s = V.get(wr);
|
|
352
1379
|
if (s.inverse = e.inverse, r) {
|
|
353
1380
|
e.mask.mask.measurable = !0;
|
|
354
|
-
const
|
|
355
|
-
e.mask.mask.measurable = !1,
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
1381
|
+
const i = St(e.mask.mask, !0, kr);
|
|
1382
|
+
e.mask.mask.measurable = !1, i.ceil();
|
|
1383
|
+
const a = t.renderTarget.renderTarget.colorTexture.source, o = G.getOptimalTexture(
|
|
1384
|
+
i.width,
|
|
1385
|
+
i.height,
|
|
1386
|
+
a._resolution,
|
|
1387
|
+
a.antialias
|
|
361
1388
|
);
|
|
362
1389
|
t.renderTarget.push(o, !0), t.globalUniforms.push({
|
|
363
|
-
offset:
|
|
1390
|
+
offset: i,
|
|
364
1391
|
worldColor: 4294967295
|
|
365
1392
|
});
|
|
366
|
-
const
|
|
367
|
-
|
|
1393
|
+
const l = s.sprite;
|
|
1394
|
+
l.texture = o, l.worldTransform.tx = i.minX, l.worldTransform.ty = i.minY, this._activeMaskStage.push({
|
|
368
1395
|
filterEffect: s,
|
|
369
1396
|
maskedContainer: e.maskedContainer,
|
|
370
1397
|
filterTexture: o
|
|
@@ -376,7 +1403,7 @@ class xe {
|
|
|
376
1403
|
});
|
|
377
1404
|
} else if (e.action === "pushMaskEnd") {
|
|
378
1405
|
const s = this._activeMaskStage[this._activeMaskStage.length - 1];
|
|
379
|
-
r && (t.type ===
|
|
1406
|
+
r && (t.type === ae.WEBGL && t.renderTarget.finishRenderPass(), t.renderTarget.pop(), t.globalUniforms.pop()), t.filter.push({
|
|
380
1407
|
renderPipeId: "filter",
|
|
381
1408
|
action: "pushFilter",
|
|
382
1409
|
container: s.maskedContainer,
|
|
@@ -386,22 +1413,22 @@ class xe {
|
|
|
386
1413
|
} else if (e.action === "popMaskEnd") {
|
|
387
1414
|
t.filter.pop();
|
|
388
1415
|
const s = this._activeMaskStage.pop();
|
|
389
|
-
r &&
|
|
1416
|
+
r && G.returnTexture(s.filterTexture), V.return(s.filterEffect);
|
|
390
1417
|
}
|
|
391
1418
|
}
|
|
392
1419
|
destroy() {
|
|
393
1420
|
this._renderer = null, this._activeMaskStage = null;
|
|
394
1421
|
}
|
|
395
1422
|
}
|
|
396
|
-
|
|
1423
|
+
rt.extension = {
|
|
397
1424
|
type: [
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
1425
|
+
u.WebGLPipes,
|
|
1426
|
+
u.WebGPUPipes,
|
|
1427
|
+
u.CanvasPipes
|
|
401
1428
|
],
|
|
402
1429
|
name: "alphaMask"
|
|
403
1430
|
};
|
|
404
|
-
class
|
|
1431
|
+
class st {
|
|
405
1432
|
constructor(e) {
|
|
406
1433
|
this._colorStack = [], this._colorStackIndex = 0, this._currentColor = 0, this._renderer = e;
|
|
407
1434
|
}
|
|
@@ -410,23 +1437,23 @@ class be {
|
|
|
410
1437
|
}
|
|
411
1438
|
push(e, t, r) {
|
|
412
1439
|
this._renderer.renderPipes.batch.break(r);
|
|
413
|
-
const
|
|
414
|
-
|
|
415
|
-
const
|
|
416
|
-
|
|
1440
|
+
const i = this._colorStack;
|
|
1441
|
+
i[this._colorStackIndex] = i[this._colorStackIndex - 1] & e.mask;
|
|
1442
|
+
const a = this._colorStack[this._colorStackIndex];
|
|
1443
|
+
a !== this._currentColor && (this._currentColor = a, r.add({
|
|
417
1444
|
renderPipeId: "colorMask",
|
|
418
|
-
colorMask:
|
|
1445
|
+
colorMask: a,
|
|
419
1446
|
canBundle: !1
|
|
420
1447
|
})), this._colorStackIndex++;
|
|
421
1448
|
}
|
|
422
1449
|
pop(e, t, r) {
|
|
423
1450
|
this._renderer.renderPipes.batch.break(r);
|
|
424
|
-
const
|
|
1451
|
+
const i = this._colorStack;
|
|
425
1452
|
this._colorStackIndex--;
|
|
426
|
-
const
|
|
427
|
-
|
|
1453
|
+
const a = i[this._colorStackIndex - 1];
|
|
1454
|
+
a !== this._currentColor && (this._currentColor = a, r.add({
|
|
428
1455
|
renderPipeId: "colorMask",
|
|
429
|
-
colorMask:
|
|
1456
|
+
colorMask: a,
|
|
430
1457
|
canBundle: !1
|
|
431
1458
|
}));
|
|
432
1459
|
}
|
|
@@ -437,60 +1464,60 @@ class be {
|
|
|
437
1464
|
this._renderer = null, this._colorStack = null;
|
|
438
1465
|
}
|
|
439
1466
|
}
|
|
440
|
-
|
|
1467
|
+
st.extension = {
|
|
441
1468
|
type: [
|
|
442
|
-
|
|
443
|
-
|
|
1469
|
+
u.WebGLPipes,
|
|
1470
|
+
u.WebGPUPipes
|
|
444
1471
|
],
|
|
445
1472
|
name: "colorMask"
|
|
446
1473
|
};
|
|
447
|
-
class
|
|
1474
|
+
class nt {
|
|
448
1475
|
constructor(e) {
|
|
449
1476
|
this._maskStackHash = {}, this._maskHash = /* @__PURE__ */ new WeakMap(), this._renderer = e;
|
|
450
1477
|
}
|
|
451
1478
|
push(e, t, r) {
|
|
452
1479
|
var s;
|
|
453
|
-
const
|
|
454
|
-
|
|
1480
|
+
const i = e, a = this._renderer;
|
|
1481
|
+
a.renderPipes.batch.break(r), a.renderPipes.blendMode.setBlendMode(i.mask, "none", r), r.add({
|
|
455
1482
|
renderPipeId: "stencilMask",
|
|
456
1483
|
action: "pushMaskBegin",
|
|
457
1484
|
mask: e,
|
|
458
1485
|
inverse: t._maskOptions.inverse,
|
|
459
1486
|
canBundle: !1
|
|
460
1487
|
});
|
|
461
|
-
const o =
|
|
462
|
-
o.includeInBuild = !0, this._maskHash.has(
|
|
1488
|
+
const o = i.mask;
|
|
1489
|
+
o.includeInBuild = !0, this._maskHash.has(i) || this._maskHash.set(i, {
|
|
463
1490
|
instructionsStart: 0,
|
|
464
1491
|
instructionsLength: 0
|
|
465
1492
|
});
|
|
466
|
-
const
|
|
467
|
-
|
|
1493
|
+
const l = this._maskHash.get(i);
|
|
1494
|
+
l.instructionsStart = r.instructionSize, o.collectRenderables(
|
|
468
1495
|
r,
|
|
469
|
-
|
|
1496
|
+
a,
|
|
470
1497
|
null
|
|
471
|
-
), o.includeInBuild = !1,
|
|
1498
|
+
), o.includeInBuild = !1, a.renderPipes.batch.break(r), r.add({
|
|
472
1499
|
renderPipeId: "stencilMask",
|
|
473
1500
|
action: "pushMaskEnd",
|
|
474
1501
|
mask: e,
|
|
475
1502
|
inverse: t._maskOptions.inverse,
|
|
476
1503
|
canBundle: !1
|
|
477
1504
|
});
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
const
|
|
481
|
-
(s = this._maskStackHash)[
|
|
1505
|
+
const d = r.instructionSize - l.instructionsStart - 1;
|
|
1506
|
+
l.instructionsLength = d;
|
|
1507
|
+
const f = a.renderTarget.renderTarget.uid;
|
|
1508
|
+
(s = this._maskStackHash)[f] ?? (s[f] = 0);
|
|
482
1509
|
}
|
|
483
1510
|
pop(e, t, r) {
|
|
484
|
-
const s = e,
|
|
485
|
-
|
|
1511
|
+
const s = e, i = this._renderer;
|
|
1512
|
+
i.renderPipes.batch.break(r), i.renderPipes.blendMode.setBlendMode(s.mask, "none", r), r.add({
|
|
486
1513
|
renderPipeId: "stencilMask",
|
|
487
1514
|
action: "popMaskBegin",
|
|
488
1515
|
inverse: t._maskOptions.inverse,
|
|
489
1516
|
canBundle: !1
|
|
490
1517
|
});
|
|
491
|
-
const
|
|
492
|
-
for (let o = 0; o <
|
|
493
|
-
r.instructions[r.instructionSize++] = r.instructions[
|
|
1518
|
+
const a = this._maskHash.get(e);
|
|
1519
|
+
for (let o = 0; o < a.instructionsLength; o++)
|
|
1520
|
+
r.instructions[r.instructionSize++] = r.instructions[a.instructionsStart++];
|
|
494
1521
|
r.add({
|
|
495
1522
|
renderPipeId: "stencilMask",
|
|
496
1523
|
action: "popMaskEnd",
|
|
@@ -499,22 +1526,22 @@ class Te {
|
|
|
499
1526
|
}
|
|
500
1527
|
execute(e) {
|
|
501
1528
|
var t;
|
|
502
|
-
const r = this._renderer, s = r,
|
|
503
|
-
let
|
|
504
|
-
e.action === "pushMaskBegin" ? (s.renderTarget.ensureDepthStencil(), s.stencil.setStencilMode(
|
|
1529
|
+
const r = this._renderer, s = r, i = r.renderTarget.renderTarget.uid;
|
|
1530
|
+
let a = (t = this._maskStackHash)[i] ?? (t[i] = 0);
|
|
1531
|
+
e.action === "pushMaskBegin" ? (s.renderTarget.ensureDepthStencil(), s.stencil.setStencilMode(k.RENDERING_MASK_ADD, a), a++, s.colorMask.setMask(0)) : e.action === "pushMaskEnd" ? (e.inverse ? s.stencil.setStencilMode(k.INVERSE_MASK_ACTIVE, a) : s.stencil.setStencilMode(k.MASK_ACTIVE, a), s.colorMask.setMask(15)) : e.action === "popMaskBegin" ? (s.colorMask.setMask(0), a !== 0 ? s.stencil.setStencilMode(k.RENDERING_MASK_REMOVE, a) : (s.renderTarget.clear(null, Q.STENCIL), s.stencil.setStencilMode(k.DISABLED, a)), a--) : e.action === "popMaskEnd" && (e.inverse ? s.stencil.setStencilMode(k.INVERSE_MASK_ACTIVE, a) : s.stencil.setStencilMode(k.MASK_ACTIVE, a), s.colorMask.setMask(15)), this._maskStackHash[i] = a;
|
|
505
1532
|
}
|
|
506
1533
|
destroy() {
|
|
507
1534
|
this._renderer = null, this._maskStackHash = null, this._maskHash = null;
|
|
508
1535
|
}
|
|
509
1536
|
}
|
|
510
|
-
|
|
1537
|
+
nt.extension = {
|
|
511
1538
|
type: [
|
|
512
|
-
|
|
513
|
-
|
|
1539
|
+
u.WebGLPipes,
|
|
1540
|
+
u.WebGPUPipes
|
|
514
1541
|
],
|
|
515
1542
|
name: "stencilMask"
|
|
516
1543
|
};
|
|
517
|
-
class
|
|
1544
|
+
class it {
|
|
518
1545
|
constructor(e) {
|
|
519
1546
|
this._renderer = e;
|
|
520
1547
|
}
|
|
@@ -535,22 +1562,22 @@ class ye {
|
|
|
535
1562
|
this._renderer = null;
|
|
536
1563
|
}
|
|
537
1564
|
}
|
|
538
|
-
|
|
1565
|
+
it.extension = {
|
|
539
1566
|
type: [
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
1567
|
+
u.WebGLPipes,
|
|
1568
|
+
u.WebGPUPipes,
|
|
1569
|
+
u.CanvasPipes
|
|
543
1570
|
],
|
|
544
1571
|
name: "customRender"
|
|
545
1572
|
};
|
|
546
|
-
function
|
|
547
|
-
const t =
|
|
1573
|
+
function J(n, e) {
|
|
1574
|
+
const t = n.instructionSet, r = t.instructions;
|
|
548
1575
|
for (let s = 0; s < t.instructionSize; s++) {
|
|
549
|
-
const
|
|
550
|
-
e[
|
|
1576
|
+
const i = r[s];
|
|
1577
|
+
e[i.renderPipeId].execute(i);
|
|
551
1578
|
}
|
|
552
1579
|
}
|
|
553
|
-
class
|
|
1580
|
+
class at {
|
|
554
1581
|
constructor(e) {
|
|
555
1582
|
this._renderer = e;
|
|
556
1583
|
}
|
|
@@ -564,16 +1591,16 @@ class ve {
|
|
|
564
1591
|
this._renderer = null;
|
|
565
1592
|
}
|
|
566
1593
|
_addRenderableDirect(e, t) {
|
|
567
|
-
this._renderer.renderPipes.batch.break(t), e._batchableRenderGroup && (
|
|
1594
|
+
this._renderer.renderPipes.batch.break(t), e._batchableRenderGroup && (V.return(e._batchableRenderGroup), e._batchableRenderGroup = null), t.add(e);
|
|
568
1595
|
}
|
|
569
1596
|
_addRenderableCacheAsTexture(e, t) {
|
|
570
|
-
const r = e._batchableRenderGroup ?? (e._batchableRenderGroup =
|
|
1597
|
+
const r = e._batchableRenderGroup ?? (e._batchableRenderGroup = V.get(Ze));
|
|
571
1598
|
r.renderable = e.root, r.transform = e.root.relativeGroupTransform, r.texture = e.texture, r.bounds = e._textureBounds, t.add(e), this._renderer.renderPipes.blendMode.pushBlendMode(e, e.root.groupBlendMode, t), this._renderer.renderPipes.batch.addToBatch(r, t), this._renderer.renderPipes.blendMode.popBlendMode(t);
|
|
572
1599
|
}
|
|
573
1600
|
_executeCacheAsTexture(e) {
|
|
574
1601
|
if (e.textureNeedsUpdate) {
|
|
575
1602
|
e.textureNeedsUpdate = !1;
|
|
576
|
-
const t = new
|
|
1603
|
+
const t = new M().translate(
|
|
577
1604
|
-e._textureBounds.x,
|
|
578
1605
|
-e._textureBounds.y
|
|
579
1606
|
);
|
|
@@ -581,7 +1608,7 @@ class ve {
|
|
|
581
1608
|
worldTransformMatrix: t,
|
|
582
1609
|
worldColor: 4294967295,
|
|
583
1610
|
offset: { x: 0, y: 0 }
|
|
584
|
-
}),
|
|
1611
|
+
}), J(e, this._renderer.renderPipes), this._renderer.renderTarget.finishRenderPass(), this._renderer.renderTarget.pop(), this._renderer.globalUniforms.pop();
|
|
585
1612
|
}
|
|
586
1613
|
e._batchableRenderGroup._batcher.updateElement(e._batchableRenderGroup), e._batchableRenderGroup._batcher.geometry.buffers[0].update();
|
|
587
1614
|
}
|
|
@@ -589,18 +1616,18 @@ class ve {
|
|
|
589
1616
|
this._renderer.globalUniforms.push({
|
|
590
1617
|
worldTransformMatrix: e.inverseParentTextureTransform,
|
|
591
1618
|
worldColor: e.worldColorAlpha
|
|
592
|
-
}),
|
|
1619
|
+
}), J(e, this._renderer.renderPipes), this._renderer.globalUniforms.pop();
|
|
593
1620
|
}
|
|
594
1621
|
}
|
|
595
|
-
|
|
1622
|
+
at.extension = {
|
|
596
1623
|
type: [
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
1624
|
+
u.WebGLPipes,
|
|
1625
|
+
u.WebGPUPipes,
|
|
1626
|
+
u.CanvasPipes
|
|
600
1627
|
],
|
|
601
1628
|
name: "renderGroup"
|
|
602
1629
|
};
|
|
603
|
-
class
|
|
1630
|
+
class ot {
|
|
604
1631
|
constructor(e) {
|
|
605
1632
|
this._renderer = e;
|
|
606
1633
|
}
|
|
@@ -626,30 +1653,30 @@ class Ce {
|
|
|
626
1653
|
return e._gpuData[this._renderer.uid] || this._initGPUSprite(e);
|
|
627
1654
|
}
|
|
628
1655
|
_initGPUSprite(e) {
|
|
629
|
-
const t = new
|
|
1656
|
+
const t = new Ze();
|
|
630
1657
|
return t.renderable = e, t.transform = e.groupTransform, t.texture = e._texture, t.bounds = e.visualBounds, t.roundPixels = this._renderer._roundPixels | e._roundPixels, e._gpuData[this._renderer.uid] = t, t;
|
|
631
1658
|
}
|
|
632
1659
|
destroy() {
|
|
633
1660
|
this._renderer = null;
|
|
634
1661
|
}
|
|
635
1662
|
}
|
|
636
|
-
|
|
1663
|
+
ot.extension = {
|
|
637
1664
|
type: [
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
1665
|
+
u.WebGLPipes,
|
|
1666
|
+
u.WebGPUPipes,
|
|
1667
|
+
u.CanvasPipes
|
|
641
1668
|
],
|
|
642
1669
|
name: "sprite"
|
|
643
1670
|
};
|
|
644
|
-
const
|
|
645
|
-
|
|
646
|
-
if (!
|
|
1671
|
+
const E = {};
|
|
1672
|
+
re.handle(u.BlendMode, (n) => {
|
|
1673
|
+
if (!n.name)
|
|
647
1674
|
throw new Error("BlendMode extension must have a name property");
|
|
648
|
-
|
|
649
|
-
}, (
|
|
650
|
-
delete
|
|
1675
|
+
E[n.name] = n.ref;
|
|
1676
|
+
}, (n) => {
|
|
1677
|
+
delete E[n.name];
|
|
651
1678
|
});
|
|
652
|
-
class
|
|
1679
|
+
class lt {
|
|
653
1680
|
constructor(e) {
|
|
654
1681
|
this._blendModeStack = [], this._isAdvanced = !1, this._filterHash = /* @__PURE__ */ Object.create(null), this._renderer = e, this._renderer.runners.prerender.add(this);
|
|
655
1682
|
}
|
|
@@ -683,34 +1710,34 @@ class ke {
|
|
|
683
1710
|
* @param instructionSet - The instruction set being built.
|
|
684
1711
|
*/
|
|
685
1712
|
setBlendMode(e, t, r) {
|
|
686
|
-
var
|
|
687
|
-
const s = e instanceof
|
|
1713
|
+
var i;
|
|
1714
|
+
const s = e instanceof xe;
|
|
688
1715
|
if (this._activeBlendMode === t) {
|
|
689
|
-
this._isAdvanced && e && !s && ((
|
|
1716
|
+
this._isAdvanced && e && !s && ((i = this._renderableList) == null || i.push(e));
|
|
690
1717
|
return;
|
|
691
1718
|
}
|
|
692
|
-
this._isAdvanced && this._endAdvancedBlendMode(r), this._activeBlendMode = t, e && (this._isAdvanced = !!
|
|
1719
|
+
this._isAdvanced && this._endAdvancedBlendMode(r), this._activeBlendMode = t, e && (this._isAdvanced = !!E[t], this._isAdvanced && this._beginAdvancedBlendMode(e, r));
|
|
693
1720
|
}
|
|
694
1721
|
_beginAdvancedBlendMode(e, t) {
|
|
695
1722
|
this._renderer.renderPipes.batch.break(t);
|
|
696
1723
|
const r = this._activeBlendMode;
|
|
697
|
-
if (!
|
|
698
|
-
|
|
1724
|
+
if (!E[r]) {
|
|
1725
|
+
te(`Unable to assign BlendMode: '${r}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);
|
|
699
1726
|
return;
|
|
700
1727
|
}
|
|
701
|
-
const s = this._ensureFilterEffect(r),
|
|
1728
|
+
const s = this._ensureFilterEffect(r), i = e instanceof xe, a = {
|
|
702
1729
|
renderPipeId: "filter",
|
|
703
1730
|
action: "pushFilter",
|
|
704
1731
|
filterEffect: s,
|
|
705
|
-
renderables:
|
|
706
|
-
container:
|
|
1732
|
+
renderables: i ? null : [e],
|
|
1733
|
+
container: i ? e.root : null,
|
|
707
1734
|
canBundle: !1
|
|
708
1735
|
};
|
|
709
|
-
this._renderableList =
|
|
1736
|
+
this._renderableList = a.renderables, t.add(a);
|
|
710
1737
|
}
|
|
711
1738
|
_ensureFilterEffect(e) {
|
|
712
1739
|
let t = this._filterHash[e];
|
|
713
|
-
return t || (t = this._filterHash[e] = new
|
|
1740
|
+
return t || (t = this._filterHash[e] = new Ve(), t.filters = [new E[e]()]), t;
|
|
714
1741
|
}
|
|
715
1742
|
_endAdvancedBlendMode(e) {
|
|
716
1743
|
this._isAdvanced = !1, this._renderableList = null, this._renderer.renderPipes.batch.break(e), e.add({
|
|
@@ -743,104 +1770,104 @@ class ke {
|
|
|
743
1770
|
this._filterHash = null;
|
|
744
1771
|
}
|
|
745
1772
|
}
|
|
746
|
-
|
|
1773
|
+
lt.extension = {
|
|
747
1774
|
type: [
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
1775
|
+
u.WebGLPipes,
|
|
1776
|
+
u.WebGPUPipes,
|
|
1777
|
+
u.CanvasPipes
|
|
751
1778
|
],
|
|
752
1779
|
name: "blendMode"
|
|
753
1780
|
};
|
|
754
|
-
function
|
|
1781
|
+
function Z(n, e) {
|
|
755
1782
|
e || (e = 0);
|
|
756
|
-
for (let t = e; t <
|
|
757
|
-
|
|
1783
|
+
for (let t = e; t < n.length && n[t]; t++)
|
|
1784
|
+
n[t] = null;
|
|
758
1785
|
}
|
|
759
|
-
const
|
|
760
|
-
function
|
|
761
|
-
|
|
762
|
-
const t =
|
|
1786
|
+
const Mr = new F(), Ie = Le | We | Oe;
|
|
1787
|
+
function ut(n, e = !1) {
|
|
1788
|
+
Br(n);
|
|
1789
|
+
const t = n.childrenToUpdate, r = n.updateTick++;
|
|
763
1790
|
for (const s in t) {
|
|
764
|
-
const
|
|
765
|
-
for (let
|
|
766
|
-
const
|
|
767
|
-
|
|
1791
|
+
const i = Number(s), a = t[s], o = a.list, l = a.index;
|
|
1792
|
+
for (let d = 0; d < l; d++) {
|
|
1793
|
+
const f = o[d];
|
|
1794
|
+
f.parentRenderGroup === n && f.relativeRenderGroupDepth === i && ct(f, r, 0);
|
|
768
1795
|
}
|
|
769
|
-
|
|
1796
|
+
Z(o, l), a.index = 0;
|
|
770
1797
|
}
|
|
771
1798
|
if (e)
|
|
772
|
-
for (let s = 0; s <
|
|
773
|
-
|
|
1799
|
+
for (let s = 0; s < n.renderGroupChildren.length; s++)
|
|
1800
|
+
ut(n.renderGroupChildren[s], e);
|
|
774
1801
|
}
|
|
775
|
-
function
|
|
776
|
-
const e =
|
|
1802
|
+
function Br(n) {
|
|
1803
|
+
const e = n.root;
|
|
777
1804
|
let t;
|
|
778
|
-
if (
|
|
779
|
-
const r =
|
|
780
|
-
|
|
1805
|
+
if (n.renderGroupParent) {
|
|
1806
|
+
const r = n.renderGroupParent;
|
|
1807
|
+
n.worldTransform.appendFrom(
|
|
781
1808
|
e.relativeGroupTransform,
|
|
782
1809
|
r.worldTransform
|
|
783
|
-
),
|
|
1810
|
+
), n.worldColor = Fe(
|
|
784
1811
|
e.groupColor,
|
|
785
1812
|
r.worldColor
|
|
786
1813
|
), t = e.groupAlpha * r.worldAlpha;
|
|
787
1814
|
} else
|
|
788
|
-
|
|
789
|
-
t = t < 0 ? 0 : t > 1 ? 1 : t,
|
|
790
|
-
}
|
|
791
|
-
function
|
|
792
|
-
if (e ===
|
|
793
|
-
|
|
794
|
-
const r =
|
|
795
|
-
|
|
796
|
-
const s =
|
|
797
|
-
if (s && !s.renderGroup ? (t |=
|
|
1815
|
+
n.worldTransform.copyFrom(e.localTransform), n.worldColor = e.localColor, t = e.localAlpha;
|
|
1816
|
+
t = t < 0 ? 0 : t > 1 ? 1 : t, n.worldAlpha = t, n.worldColorAlpha = n.worldColor + ((t * 255 | 0) << 24);
|
|
1817
|
+
}
|
|
1818
|
+
function ct(n, e, t) {
|
|
1819
|
+
if (e === n.updateTick) return;
|
|
1820
|
+
n.updateTick = e, n.didChange = !1;
|
|
1821
|
+
const r = n.localTransform;
|
|
1822
|
+
n.updateLocalTransform();
|
|
1823
|
+
const s = n.parent;
|
|
1824
|
+
if (s && !s.renderGroup ? (t |= n._updateFlags, n.relativeGroupTransform.appendFrom(
|
|
798
1825
|
r,
|
|
799
1826
|
s.relativeGroupTransform
|
|
800
|
-
), t &
|
|
801
|
-
const
|
|
802
|
-
for (let
|
|
803
|
-
|
|
804
|
-
const o =
|
|
805
|
-
|
|
806
|
-
}
|
|
807
|
-
}
|
|
808
|
-
function
|
|
809
|
-
if (t &
|
|
810
|
-
|
|
811
|
-
|
|
1827
|
+
), t & Ie && De(n, s, t)) : (t = n._updateFlags, n.relativeGroupTransform.copyFrom(r), t & Ie && De(n, Mr, t)), !n.renderGroup) {
|
|
1828
|
+
const i = n.children, a = i.length;
|
|
1829
|
+
for (let d = 0; d < a; d++)
|
|
1830
|
+
ct(i[d], e, t);
|
|
1831
|
+
const o = n.parentRenderGroup, l = n;
|
|
1832
|
+
l.renderPipeId && !o.structureDidChange && o.updateRenderable(l);
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
function De(n, e, t) {
|
|
1836
|
+
if (t & We) {
|
|
1837
|
+
n.groupColor = Fe(
|
|
1838
|
+
n.localColor,
|
|
812
1839
|
e.groupColor
|
|
813
1840
|
);
|
|
814
|
-
let r =
|
|
815
|
-
r = r < 0 ? 0 : r > 1 ? 1 : r,
|
|
1841
|
+
let r = n.localAlpha * e.groupAlpha;
|
|
1842
|
+
r = r < 0 ? 0 : r > 1 ? 1 : r, n.groupAlpha = r, n.groupColorAlpha = n.groupColor + ((r * 255 | 0) << 24);
|
|
816
1843
|
}
|
|
817
|
-
t &
|
|
1844
|
+
t & Oe && (n.groupBlendMode = n.localBlendMode === "inherit" ? e.groupBlendMode : n.localBlendMode), t & Le && (n.globalDisplayStatus = n.localDisplayStatus & e.globalDisplayStatus), n._updateFlags = 0;
|
|
818
1845
|
}
|
|
819
|
-
function
|
|
820
|
-
const { list: t } =
|
|
1846
|
+
function Rr(n, e) {
|
|
1847
|
+
const { list: t } = n.childrenRenderablesToUpdate;
|
|
821
1848
|
let r = !1;
|
|
822
|
-
for (let s = 0; s <
|
|
823
|
-
const
|
|
824
|
-
if (r = e[
|
|
1849
|
+
for (let s = 0; s < n.childrenRenderablesToUpdate.index; s++) {
|
|
1850
|
+
const i = t[s];
|
|
1851
|
+
if (r = e[i.renderPipeId].validateRenderable(i), r)
|
|
825
1852
|
break;
|
|
826
1853
|
}
|
|
827
|
-
return
|
|
1854
|
+
return n.structureDidChange = r, r;
|
|
828
1855
|
}
|
|
829
|
-
const
|
|
830
|
-
class
|
|
1856
|
+
const Pr = new M();
|
|
1857
|
+
class dt {
|
|
831
1858
|
constructor(e) {
|
|
832
1859
|
this._renderer = e;
|
|
833
1860
|
}
|
|
834
1861
|
render({ container: e, transform: t }) {
|
|
835
1862
|
const r = e.parent, s = e.renderGroup.renderGroupParent;
|
|
836
1863
|
e.parent = null, e.renderGroup.renderGroupParent = null;
|
|
837
|
-
const
|
|
838
|
-
t && (
|
|
839
|
-
const o =
|
|
840
|
-
this._updateCachedRenderGroups(e.renderGroup, null), this._updateRenderGroups(e.renderGroup),
|
|
1864
|
+
const i = this._renderer, a = Pr;
|
|
1865
|
+
t && (a.copyFrom(e.renderGroup.localTransform), e.renderGroup.localTransform.copyFrom(t));
|
|
1866
|
+
const o = i.renderPipes;
|
|
1867
|
+
this._updateCachedRenderGroups(e.renderGroup, null), this._updateRenderGroups(e.renderGroup), i.globalUniforms.start({
|
|
841
1868
|
worldTransformMatrix: t ? e.renderGroup.localTransform : e.renderGroup.worldTransform,
|
|
842
1869
|
worldColor: e.renderGroup.worldColorAlpha
|
|
843
|
-
}),
|
|
1870
|
+
}), J(e.renderGroup, o), o.uniformBatch && o.uniformBatch.renderEnd(), t && e.renderGroup.localTransform.copyFrom(a), e.parent = r, e.renderGroup.renderGroupParent = s;
|
|
844
1871
|
}
|
|
845
1872
|
destroy() {
|
|
846
1873
|
this._renderer = null;
|
|
@@ -854,64 +1881,64 @@ class Se {
|
|
|
854
1881
|
this._updateCachedRenderGroups(e.renderGroupChildren[r], t);
|
|
855
1882
|
if (e.invalidateMatrices(), e.isCachedAsTexture) {
|
|
856
1883
|
if (e.textureNeedsUpdate) {
|
|
857
|
-
const r = e.root.getLocalBounds(), s = this._renderer,
|
|
858
|
-
r.ceil(), e.texture &&
|
|
859
|
-
const
|
|
1884
|
+
const r = e.root.getLocalBounds(), s = this._renderer, i = e.textureOptions.resolution || s.view.resolution, a = e.textureOptions.antialias ?? s.view.antialias, o = e.textureOptions.scaleMode ?? "linear", l = e.texture;
|
|
1885
|
+
r.ceil(), e.texture && G.returnTexture(e.texture, !0);
|
|
1886
|
+
const d = G.getOptimalTexture(
|
|
860
1887
|
r.width,
|
|
861
1888
|
r.height,
|
|
862
|
-
|
|
863
|
-
|
|
1889
|
+
i,
|
|
1890
|
+
a
|
|
864
1891
|
);
|
|
865
|
-
|
|
1892
|
+
d._source.style = new wt({ scaleMode: o }), e.texture = d, e._textureBounds || (e._textureBounds = new se()), e._textureBounds.copyFrom(r), l !== e.texture && e.renderGroupParent && (e.renderGroupParent.structureDidChange = !0);
|
|
866
1893
|
}
|
|
867
|
-
} else e.texture && (
|
|
1894
|
+
} else e.texture && (G.returnTexture(e.texture, !0), e.texture = null);
|
|
868
1895
|
}
|
|
869
1896
|
_updateRenderGroups(e) {
|
|
870
1897
|
const t = this._renderer, r = t.renderPipes;
|
|
871
|
-
if (e.runOnRender(t), e.instructionSet.renderPipes = r, e.structureDidChange ?
|
|
1898
|
+
if (e.runOnRender(t), e.instructionSet.renderPipes = r, e.structureDidChange ? Z(e.childrenRenderablesToUpdate.list, 0) : Rr(e, r), ut(e), e.structureDidChange ? (e.structureDidChange = !1, this._buildInstructions(e, t)) : this._updateRenderables(e), e.childrenRenderablesToUpdate.index = 0, t.renderPipes.batch.upload(e.instructionSet), !(e.isCachedAsTexture && !e.textureNeedsUpdate))
|
|
872
1899
|
for (let s = 0; s < e.renderGroupChildren.length; s++)
|
|
873
1900
|
this._updateRenderGroups(e.renderGroupChildren[s]);
|
|
874
1901
|
}
|
|
875
1902
|
_updateRenderables(e) {
|
|
876
1903
|
const { list: t, index: r } = e.childrenRenderablesToUpdate;
|
|
877
1904
|
for (let s = 0; s < r; s++) {
|
|
878
|
-
const
|
|
879
|
-
|
|
1905
|
+
const i = t[s];
|
|
1906
|
+
i.didViewUpdate && e.updateRenderable(i);
|
|
880
1907
|
}
|
|
881
|
-
|
|
1908
|
+
Z(t, r);
|
|
882
1909
|
}
|
|
883
1910
|
_buildInstructions(e, t) {
|
|
884
1911
|
const r = e.root, s = e.instructionSet;
|
|
885
1912
|
s.reset();
|
|
886
|
-
const
|
|
887
|
-
|
|
1913
|
+
const i = t.renderPipes ? t : t.batch.renderer, a = i.renderPipes;
|
|
1914
|
+
a.batch.buildStart(s), a.blendMode.buildStart(), a.colorMask.buildStart(), r.sortableChildren && r.sortChildren(), r.collectRenderablesWithEffects(s, i, null), a.batch.buildEnd(s), a.blendMode.buildEnd(s);
|
|
888
1915
|
}
|
|
889
1916
|
}
|
|
890
|
-
|
|
1917
|
+
dt.extension = {
|
|
891
1918
|
type: [
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
1919
|
+
u.WebGLSystem,
|
|
1920
|
+
u.WebGPUSystem,
|
|
1921
|
+
u.CanvasSystem
|
|
895
1922
|
],
|
|
896
1923
|
name: "renderGroup"
|
|
897
1924
|
};
|
|
898
|
-
const
|
|
1925
|
+
const le = class ht {
|
|
899
1926
|
constructor() {
|
|
900
|
-
this.clearBeforeRender = !0, this._backgroundColor = new
|
|
1927
|
+
this.clearBeforeRender = !0, this._backgroundColor = new Y(0), this.color = this._backgroundColor, this.alpha = 1;
|
|
901
1928
|
}
|
|
902
1929
|
/**
|
|
903
1930
|
* initiates the background system
|
|
904
1931
|
* @param options - the options for the background colors
|
|
905
1932
|
*/
|
|
906
1933
|
init(e) {
|
|
907
|
-
e = { ...
|
|
1934
|
+
e = { ...ht.defaultOptions, ...e }, this.clearBeforeRender = e.clearBeforeRender, this.color = e.background || e.backgroundColor || this._backgroundColor, this.alpha = e.backgroundAlpha, this._backgroundColor.setAlpha(e.backgroundAlpha);
|
|
908
1935
|
}
|
|
909
1936
|
/** The background color to fill if not transparent */
|
|
910
1937
|
get color() {
|
|
911
1938
|
return this._backgroundColor;
|
|
912
1939
|
}
|
|
913
1940
|
set color(e) {
|
|
914
|
-
|
|
1941
|
+
Y.shared.setValue(e).alpha < 1 && this._backgroundColor.alpha === 1 && te(
|
|
915
1942
|
"Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."
|
|
916
1943
|
), this._backgroundColor.setValue(e);
|
|
917
1944
|
}
|
|
@@ -933,16 +1960,16 @@ const $ = class we {
|
|
|
933
1960
|
destroy() {
|
|
934
1961
|
}
|
|
935
1962
|
};
|
|
936
|
-
|
|
1963
|
+
le.extension = {
|
|
937
1964
|
type: [
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
1965
|
+
u.WebGLSystem,
|
|
1966
|
+
u.WebGPUSystem,
|
|
1967
|
+
u.CanvasSystem
|
|
941
1968
|
],
|
|
942
1969
|
name: "background",
|
|
943
1970
|
priority: 0
|
|
944
1971
|
};
|
|
945
|
-
|
|
1972
|
+
le.defaultOptions = {
|
|
946
1973
|
/**
|
|
947
1974
|
* {@link WebGLOptions.backgroundAlpha}
|
|
948
1975
|
* @default 1
|
|
@@ -959,18 +1986,18 @@ $.defaultOptions = {
|
|
|
959
1986
|
*/
|
|
960
1987
|
clearBeforeRender: !0
|
|
961
1988
|
};
|
|
962
|
-
let
|
|
963
|
-
const
|
|
1989
|
+
let Ar = le;
|
|
1990
|
+
const q = {
|
|
964
1991
|
png: "image/png",
|
|
965
1992
|
jpg: "image/jpeg",
|
|
966
1993
|
webp: "image/webp"
|
|
967
|
-
},
|
|
1994
|
+
}, ue = class ft {
|
|
968
1995
|
/** @param renderer - The renderer this System works for. */
|
|
969
1996
|
constructor(e) {
|
|
970
1997
|
this._renderer = e;
|
|
971
1998
|
}
|
|
972
1999
|
_normalizeOptions(e, t = {}) {
|
|
973
|
-
return e instanceof
|
|
2000
|
+
return e instanceof F || e instanceof S ? {
|
|
974
2001
|
target: e,
|
|
975
2002
|
...t
|
|
976
2003
|
} : {
|
|
@@ -1011,7 +2038,7 @@ const I = {
|
|
|
1011
2038
|
* @category rendering
|
|
1012
2039
|
*/
|
|
1013
2040
|
async image(e) {
|
|
1014
|
-
const t =
|
|
2041
|
+
const t = ne.get().createImage();
|
|
1015
2042
|
return t.src = await this.base64(e), t;
|
|
1016
2043
|
}
|
|
1017
2044
|
/**
|
|
@@ -1049,27 +2076,27 @@ const I = {
|
|
|
1049
2076
|
async base64(e) {
|
|
1050
2077
|
e = this._normalizeOptions(
|
|
1051
2078
|
e,
|
|
1052
|
-
|
|
2079
|
+
ft.defaultImageOptions
|
|
1053
2080
|
);
|
|
1054
2081
|
const { format: t, quality: r } = e, s = this.canvas(e);
|
|
1055
2082
|
if (s.toBlob !== void 0)
|
|
1056
|
-
return new Promise((
|
|
2083
|
+
return new Promise((i, a) => {
|
|
1057
2084
|
s.toBlob((o) => {
|
|
1058
2085
|
if (!o) {
|
|
1059
|
-
|
|
2086
|
+
a(new Error("ICanvas.toBlob failed!"));
|
|
1060
2087
|
return;
|
|
1061
2088
|
}
|
|
1062
|
-
const
|
|
1063
|
-
|
|
1064
|
-
},
|
|
2089
|
+
const l = new FileReader();
|
|
2090
|
+
l.onload = () => i(l.result), l.onerror = a, l.readAsDataURL(o);
|
|
2091
|
+
}, q[t], r);
|
|
1065
2092
|
});
|
|
1066
2093
|
if (s.toDataURL !== void 0)
|
|
1067
|
-
return s.toDataURL(
|
|
2094
|
+
return s.toDataURL(q[t], r);
|
|
1068
2095
|
if (s.convertToBlob !== void 0) {
|
|
1069
|
-
const
|
|
1070
|
-
return new Promise((
|
|
1071
|
-
const
|
|
1072
|
-
|
|
2096
|
+
const i = await s.convertToBlob({ type: q[t], quality: r });
|
|
2097
|
+
return new Promise((a, o) => {
|
|
2098
|
+
const l = new FileReader();
|
|
2099
|
+
l.onload = () => a(l.result), l.onerror = o, l.readAsDataURL(i);
|
|
1073
2100
|
});
|
|
1074
2101
|
}
|
|
1075
2102
|
throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented");
|
|
@@ -1117,10 +2144,10 @@ const I = {
|
|
|
1117
2144
|
canvas(e) {
|
|
1118
2145
|
e = this._normalizeOptions(e);
|
|
1119
2146
|
const t = e.target, r = this._renderer;
|
|
1120
|
-
if (t instanceof
|
|
2147
|
+
if (t instanceof S)
|
|
1121
2148
|
return r.texture.generateCanvas(t);
|
|
1122
|
-
const s = r.textureGenerator.generateTexture(e),
|
|
1123
|
-
return s.destroy(!0),
|
|
2149
|
+
const s = r.textureGenerator.generateTexture(e), i = r.texture.generateCanvas(s);
|
|
2150
|
+
return s.destroy(!0), i;
|
|
1124
2151
|
}
|
|
1125
2152
|
/**
|
|
1126
2153
|
* Returns a one-dimensional array containing the pixel data of the entire texture in RGBA order,
|
|
@@ -1154,8 +2181,8 @@ const I = {
|
|
|
1154
2181
|
*/
|
|
1155
2182
|
pixels(e) {
|
|
1156
2183
|
e = this._normalizeOptions(e);
|
|
1157
|
-
const t = e.target, r = this._renderer, s = t instanceof
|
|
1158
|
-
return t instanceof
|
|
2184
|
+
const t = e.target, r = this._renderer, s = t instanceof S ? t : r.textureGenerator.generateTexture(e), i = r.texture.getPixels(s);
|
|
2185
|
+
return t instanceof F && s.destroy(!0), i;
|
|
1159
2186
|
}
|
|
1160
2187
|
/**
|
|
1161
2188
|
* Creates a texture from a display object or existing texture.
|
|
@@ -1201,7 +2228,7 @@ const I = {
|
|
|
1201
2228
|
* @category rendering
|
|
1202
2229
|
*/
|
|
1203
2230
|
texture(e) {
|
|
1204
|
-
return e = this._normalizeOptions(e), e.target instanceof
|
|
2231
|
+
return e = this._normalizeOptions(e), e.target instanceof S ? e.target : this._renderer.textureGenerator.generateTexture(e);
|
|
1205
2232
|
}
|
|
1206
2233
|
/**
|
|
1207
2234
|
* Extracts and downloads content from the renderer as an image file.
|
|
@@ -1273,32 +2300,32 @@ const I = {
|
|
|
1273
2300
|
e = this._normalizeOptions(e);
|
|
1274
2301
|
const r = this.canvas(e), s = r.toDataURL();
|
|
1275
2302
|
console.log(`[Pixi Texture] ${r.width}px ${r.height}px`);
|
|
1276
|
-
const
|
|
2303
|
+
const i = [
|
|
1277
2304
|
"font-size: 1px;",
|
|
1278
2305
|
`padding: ${t}px 300px;`,
|
|
1279
2306
|
`background: url(${s}) no-repeat;`,
|
|
1280
2307
|
"background-size: contain;"
|
|
1281
2308
|
].join(" ");
|
|
1282
|
-
console.log("%c ",
|
|
2309
|
+
console.log("%c ", i);
|
|
1283
2310
|
}
|
|
1284
2311
|
destroy() {
|
|
1285
2312
|
this._renderer = null;
|
|
1286
2313
|
}
|
|
1287
2314
|
};
|
|
1288
|
-
|
|
2315
|
+
ue.extension = {
|
|
1289
2316
|
type: [
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
2317
|
+
u.WebGLSystem,
|
|
2318
|
+
u.WebGPUSystem,
|
|
2319
|
+
u.CanvasSystem
|
|
1293
2320
|
],
|
|
1294
2321
|
name: "extract"
|
|
1295
2322
|
};
|
|
1296
|
-
|
|
2323
|
+
ue.defaultImageOptions = {
|
|
1297
2324
|
format: "png",
|
|
1298
2325
|
quality: 1
|
|
1299
2326
|
};
|
|
1300
|
-
let
|
|
1301
|
-
class
|
|
2327
|
+
let Ur = ue;
|
|
2328
|
+
class ce extends S {
|
|
1302
2329
|
/**
|
|
1303
2330
|
* Creates a RenderTexture. Pass `dynamic: true` in options to allow resizing after creation.
|
|
1304
2331
|
* @param options - Options for the RenderTexture, including width, height, and dynamic.
|
|
@@ -1309,8 +2336,8 @@ class K extends f {
|
|
|
1309
2336
|
*/
|
|
1310
2337
|
static create(e) {
|
|
1311
2338
|
const { dynamic: t, ...r } = e;
|
|
1312
|
-
return new
|
|
1313
|
-
source: new
|
|
2339
|
+
return new ce({
|
|
2340
|
+
source: new I(r),
|
|
1314
2341
|
dynamic: t ?? !1
|
|
1315
2342
|
});
|
|
1316
2343
|
}
|
|
@@ -1325,8 +2352,8 @@ class K extends f {
|
|
|
1325
2352
|
return this.source.resize(e, t, r), this;
|
|
1326
2353
|
}
|
|
1327
2354
|
}
|
|
1328
|
-
const
|
|
1329
|
-
class
|
|
2355
|
+
const Gr = new L(), Ir = new se(), Dr = [0, 0, 0, 0];
|
|
2356
|
+
class pt {
|
|
1330
2357
|
constructor(e) {
|
|
1331
2358
|
this._renderer = e;
|
|
1332
2359
|
}
|
|
@@ -1367,66 +2394,66 @@ class Be {
|
|
|
1367
2394
|
* @category rendering
|
|
1368
2395
|
*/
|
|
1369
2396
|
generateTexture(e) {
|
|
1370
|
-
var
|
|
1371
|
-
e instanceof
|
|
2397
|
+
var d;
|
|
2398
|
+
e instanceof F && (e = {
|
|
1372
2399
|
target: e,
|
|
1373
2400
|
frame: void 0,
|
|
1374
2401
|
textureSourceOptions: {},
|
|
1375
2402
|
resolution: void 0
|
|
1376
2403
|
});
|
|
1377
2404
|
const t = e.resolution || this._renderer.resolution, r = e.antialias || this._renderer.view.antialias, s = e.target;
|
|
1378
|
-
let
|
|
1379
|
-
|
|
1380
|
-
const
|
|
1381
|
-
|
|
1382
|
-
const o =
|
|
2405
|
+
let i = e.clearColor;
|
|
2406
|
+
i ? i = Array.isArray(i) && i.length === 4 ? i : Y.shared.setValue(i).toArray() : i = Dr;
|
|
2407
|
+
const a = ((d = e.frame) == null ? void 0 : d.copyTo(Gr)) || Mt(s, Ir).rectangle;
|
|
2408
|
+
a.width = Math.max(a.width, 1 / t) | 0, a.height = Math.max(a.height, 1 / t) | 0;
|
|
2409
|
+
const o = ce.create({
|
|
1383
2410
|
...e.textureSourceOptions,
|
|
1384
|
-
width:
|
|
1385
|
-
height:
|
|
2411
|
+
width: a.width,
|
|
2412
|
+
height: a.height,
|
|
1386
2413
|
resolution: t,
|
|
1387
2414
|
antialias: r
|
|
1388
|
-
}),
|
|
2415
|
+
}), l = M.shared.translate(-a.x, -a.y);
|
|
1389
2416
|
return this._renderer.render({
|
|
1390
2417
|
container: s,
|
|
1391
|
-
transform:
|
|
2418
|
+
transform: l,
|
|
1392
2419
|
target: o,
|
|
1393
|
-
clearColor:
|
|
2420
|
+
clearColor: i
|
|
1394
2421
|
}), o.source.updateMipmaps(), o;
|
|
1395
2422
|
}
|
|
1396
2423
|
destroy() {
|
|
1397
2424
|
this._renderer = null;
|
|
1398
2425
|
}
|
|
1399
2426
|
}
|
|
1400
|
-
|
|
2427
|
+
pt.extension = {
|
|
1401
2428
|
type: [
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
2429
|
+
u.WebGLSystem,
|
|
2430
|
+
u.WebGPUSystem,
|
|
2431
|
+
u.CanvasSystem
|
|
1405
2432
|
],
|
|
1406
2433
|
name: "textureGenerator"
|
|
1407
2434
|
};
|
|
1408
|
-
function
|
|
2435
|
+
function Er(n) {
|
|
1409
2436
|
let e = !1;
|
|
1410
|
-
for (const r in
|
|
1411
|
-
if (
|
|
2437
|
+
for (const r in n)
|
|
2438
|
+
if (n[r] == null) {
|
|
1412
2439
|
e = !0;
|
|
1413
2440
|
break;
|
|
1414
2441
|
}
|
|
1415
|
-
if (!e) return
|
|
2442
|
+
if (!e) return n;
|
|
1416
2443
|
const t = /* @__PURE__ */ Object.create(null);
|
|
1417
|
-
for (const r in
|
|
1418
|
-
const s =
|
|
2444
|
+
for (const r in n) {
|
|
2445
|
+
const s = n[r];
|
|
1419
2446
|
s && (t[r] = s);
|
|
1420
2447
|
}
|
|
1421
2448
|
return t;
|
|
1422
2449
|
}
|
|
1423
|
-
function
|
|
2450
|
+
function zr(n) {
|
|
1424
2451
|
let e = 0;
|
|
1425
|
-
for (let t = 0; t <
|
|
1426
|
-
|
|
1427
|
-
return
|
|
2452
|
+
for (let t = 0; t < n.length; t++)
|
|
2453
|
+
n[t] == null ? e++ : n[t - e] = n[t];
|
|
2454
|
+
return n.length -= e, n;
|
|
1428
2455
|
}
|
|
1429
|
-
const
|
|
2456
|
+
const de = class mt {
|
|
1430
2457
|
/**
|
|
1431
2458
|
* Creates a new GCSystem instance.
|
|
1432
2459
|
* @param renderer - The renderer this garbage collection system works for
|
|
@@ -1439,7 +2466,7 @@ const Y = class Ge {
|
|
|
1439
2466
|
* @param options - Configuration options
|
|
1440
2467
|
*/
|
|
1441
2468
|
init(e) {
|
|
1442
|
-
e = { ...
|
|
2469
|
+
e = { ...mt.defaultOptions, ...e }, this.maxUnusedTime = e.gcMaxUnusedTime, this._frequency = e.gcFrequency, this.enabled = e.gcActive, this.now = performance.now();
|
|
1443
2470
|
}
|
|
1444
2471
|
/**
|
|
1445
2472
|
* Gets whether the garbage collection system is currently enabled.
|
|
@@ -1463,8 +2490,8 @@ const Y = class Ge {
|
|
|
1463
2490
|
), this._collectionsHandler = this._renderer.scheduler.repeat(
|
|
1464
2491
|
() => {
|
|
1465
2492
|
for (const t of this._managedCollections) {
|
|
1466
|
-
const { context: r, collection: s, type:
|
|
1467
|
-
|
|
2493
|
+
const { context: r, collection: s, type: i } = t;
|
|
2494
|
+
i === "hash" ? r[s] = Er(r[s]) : r[s] = zr(r[s]);
|
|
1468
2495
|
}
|
|
1469
2496
|
},
|
|
1470
2497
|
this._frequency
|
|
@@ -1511,7 +2538,7 @@ const Y = class Ge {
|
|
|
1511
2538
|
* @param type - The type of resource to track
|
|
1512
2539
|
*/
|
|
1513
2540
|
addResource(e, t) {
|
|
1514
|
-
var s,
|
|
2541
|
+
var s, i;
|
|
1515
2542
|
if (e._gcLastUsed !== -1) {
|
|
1516
2543
|
e._gcLastUsed = this.now, (s = e._onTouch) == null || s.call(e, this.now);
|
|
1517
2544
|
return;
|
|
@@ -1520,7 +2547,7 @@ const Y = class Ge {
|
|
|
1520
2547
|
e._gcData = {
|
|
1521
2548
|
index: r,
|
|
1522
2549
|
type: t
|
|
1523
|
-
}, e._gcLastUsed = this.now, (
|
|
2550
|
+
}, e._gcLastUsed = this.now, (i = e._onTouch) == null || i.call(e, this.now), e.once("unload", this.removeResource, this), this._managedResources.push(e);
|
|
1524
2551
|
}
|
|
1525
2552
|
/**
|
|
1526
2553
|
* Removes a resource from garbage collection tracking.
|
|
@@ -1532,8 +2559,8 @@ const Y = class Ge {
|
|
|
1532
2559
|
if (!t) return;
|
|
1533
2560
|
const r = t.index, s = this._managedResources.length - 1;
|
|
1534
2561
|
if (r !== s) {
|
|
1535
|
-
const
|
|
1536
|
-
this._managedResources[r] =
|
|
2562
|
+
const i = this._managedResources[s];
|
|
2563
|
+
this._managedResources[r] = i, i._gcData.index = r;
|
|
1537
2564
|
}
|
|
1538
2565
|
this._managedResources.length--, e._gcData = null, e._gcLastUsed = -1;
|
|
1539
2566
|
}
|
|
@@ -1551,7 +2578,7 @@ const Y = class Ge {
|
|
|
1551
2578
|
hash: t,
|
|
1552
2579
|
type: r,
|
|
1553
2580
|
priority: s
|
|
1554
|
-
}), this._managedResourceHashes.sort((
|
|
2581
|
+
}), this._managedResourceHashes.sort((i, a) => i.priority - a.priority);
|
|
1555
2582
|
}
|
|
1556
2583
|
/**
|
|
1557
2584
|
* Performs garbage collection by cleaning up unused resources.
|
|
@@ -1563,15 +2590,15 @@ const Y = class Ge {
|
|
|
1563
2590
|
this.runOnHash(s, e);
|
|
1564
2591
|
let r = 0;
|
|
1565
2592
|
for (let s = 0; s < this._managedResources.length; s++) {
|
|
1566
|
-
const
|
|
1567
|
-
r = this.runOnResource(
|
|
2593
|
+
const i = this._managedResources[s];
|
|
2594
|
+
r = this.runOnResource(i, e, r);
|
|
1568
2595
|
}
|
|
1569
2596
|
this._managedResources.length = r;
|
|
1570
2597
|
}
|
|
1571
2598
|
updateRenderableGCTick(e, t) {
|
|
1572
|
-
var
|
|
1573
|
-
const r = e.renderGroup ?? e.parentRenderGroup, s = ((
|
|
1574
|
-
((r == null ? void 0 : r.gcTick) ?? 0) === s && (e._gcLastUsed = t, (
|
|
2599
|
+
var i, a;
|
|
2600
|
+
const r = e.renderGroup ?? e.parentRenderGroup, s = ((i = r == null ? void 0 : r.instructionSet) == null ? void 0 : i.gcTick) ?? -1;
|
|
2601
|
+
((r == null ? void 0 : r.gcTick) ?? 0) === s && (e._gcLastUsed = t, (a = e._onTouch) == null || a.call(e, t));
|
|
1575
2602
|
}
|
|
1576
2603
|
runOnResource(e, t, r) {
|
|
1577
2604
|
const s = e._gcData;
|
|
@@ -1592,26 +2619,26 @@ const Y = class Ge {
|
|
|
1592
2619
|
return r;
|
|
1593
2620
|
}
|
|
1594
2621
|
runOnHash(e, t) {
|
|
1595
|
-
var
|
|
1596
|
-
const { context: r, hash: s, type:
|
|
1597
|
-
let o = null,
|
|
1598
|
-
for (const
|
|
1599
|
-
const
|
|
1600
|
-
if (
|
|
1601
|
-
|
|
2622
|
+
var d;
|
|
2623
|
+
const { context: r, hash: s, type: i } = e, a = r[s];
|
|
2624
|
+
let o = null, l = 0;
|
|
2625
|
+
for (const f in a) {
|
|
2626
|
+
const c = a[f];
|
|
2627
|
+
if (c === null) {
|
|
2628
|
+
l++, l === 1e4 && !o && (o = this._createHashClone(a, f));
|
|
1602
2629
|
continue;
|
|
1603
2630
|
}
|
|
1604
|
-
if (
|
|
1605
|
-
|
|
2631
|
+
if (c._gcLastUsed === -1) {
|
|
2632
|
+
c._gcLastUsed = t, (d = c._onTouch) == null || d.call(c, t), o && (o[f] = c);
|
|
1606
2633
|
continue;
|
|
1607
2634
|
}
|
|
1608
|
-
if (
|
|
1609
|
-
if (o || (
|
|
1610
|
-
const
|
|
1611
|
-
|
|
2635
|
+
if (i === "renderable" && this.updateRenderableGCTick(c, t), !(t - c._gcLastUsed < this.maxUnusedTime) && c.autoGarbageCollect) {
|
|
2636
|
+
if (o || (l + 1 !== 1e4 ? (a[f] = null, l++) : o = this._createHashClone(a, f)), i === "renderable") {
|
|
2637
|
+
const g = c, m = g.renderGroup ?? g.parentRenderGroup;
|
|
2638
|
+
m && (m.structureDidChange = !0);
|
|
1612
2639
|
}
|
|
1613
|
-
|
|
1614
|
-
} else o && (o[
|
|
2640
|
+
c.unload(), c._gcData = null, c._gcLastUsed = -1;
|
|
2641
|
+
} else o && (o[f] = c);
|
|
1615
2642
|
}
|
|
1616
2643
|
o && (r[s] = o);
|
|
1617
2644
|
}
|
|
@@ -1622,16 +2649,16 @@ const Y = class Ge {
|
|
|
1622
2649
|
}), this._managedResources.length = 0, this._managedResourceHashes.length = 0, this._managedCollections.length = 0, this._renderer = null;
|
|
1623
2650
|
}
|
|
1624
2651
|
};
|
|
1625
|
-
|
|
2652
|
+
de.extension = {
|
|
1626
2653
|
type: [
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
2654
|
+
u.WebGLSystem,
|
|
2655
|
+
u.WebGPUSystem,
|
|
2656
|
+
u.CanvasSystem
|
|
1630
2657
|
],
|
|
1631
2658
|
name: "gc",
|
|
1632
2659
|
priority: 0
|
|
1633
2660
|
};
|
|
1634
|
-
|
|
2661
|
+
de.defaultOptions = {
|
|
1635
2662
|
/** Enable/disable the garbage collector */
|
|
1636
2663
|
gcActive: !0,
|
|
1637
2664
|
/** Time in ms before an unused resource is collected (default 1 minute) */
|
|
@@ -1639,8 +2666,8 @@ Y.defaultOptions = {
|
|
|
1639
2666
|
/** How often to run garbage collection in ms (default 30 seconds) */
|
|
1640
2667
|
gcFrequency: 3e4
|
|
1641
2668
|
};
|
|
1642
|
-
let
|
|
1643
|
-
class
|
|
2669
|
+
let Hr = de;
|
|
2670
|
+
class xt {
|
|
1644
2671
|
constructor(e) {
|
|
1645
2672
|
this._stackIndex = 0, this._globalUniformDataStack = [], this._uniformsPool = [], this._activeUniforms = [], this._bindGroupPool = [], this._activeBindGroups = [], this._renderer = e;
|
|
1646
2673
|
}
|
|
@@ -1660,35 +2687,35 @@ class Ue {
|
|
|
1660
2687
|
projectionMatrix: t,
|
|
1661
2688
|
worldTransformMatrix: r,
|
|
1662
2689
|
worldColor: s,
|
|
1663
|
-
offset:
|
|
2690
|
+
offset: i
|
|
1664
2691
|
}) {
|
|
1665
|
-
const
|
|
1666
|
-
worldTransformMatrix: new
|
|
2692
|
+
const a = this._renderer.renderTarget.renderTarget, o = this._stackIndex ? this._globalUniformDataStack[this._stackIndex - 1] : {
|
|
2693
|
+
worldTransformMatrix: new M(),
|
|
1667
2694
|
worldColor: 4294967295,
|
|
1668
|
-
offset: new
|
|
1669
|
-
},
|
|
2695
|
+
offset: new Bt()
|
|
2696
|
+
}, l = {
|
|
1670
2697
|
projectionMatrix: t || this._renderer.renderTarget.projectionMatrix,
|
|
1671
|
-
resolution: e ||
|
|
2698
|
+
resolution: e || a.size,
|
|
1672
2699
|
worldTransformMatrix: r || o.worldTransformMatrix,
|
|
1673
2700
|
worldColor: s || o.worldColor,
|
|
1674
|
-
offset:
|
|
2701
|
+
offset: i || o.offset,
|
|
1675
2702
|
bindGroup: null
|
|
1676
|
-
},
|
|
1677
|
-
this._activeUniforms.push(
|
|
1678
|
-
const
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
2703
|
+
}, d = this._uniformsPool.pop() || this._createUniforms();
|
|
2704
|
+
this._activeUniforms.push(d);
|
|
2705
|
+
const f = d.uniforms;
|
|
2706
|
+
f.uProjectionMatrix = l.projectionMatrix, f.uResolution = l.resolution, f.uWorldTransformMatrix.copyFrom(l.worldTransformMatrix), f.uWorldTransformMatrix.tx -= l.offset.x, f.uWorldTransformMatrix.ty -= l.offset.y, Sr(
|
|
2707
|
+
l.worldColor,
|
|
2708
|
+
f.uWorldColorAlpha,
|
|
1682
2709
|
0
|
|
1683
|
-
),
|
|
1684
|
-
let
|
|
1685
|
-
this._renderer.renderPipes.uniformBatch ?
|
|
2710
|
+
), d.update();
|
|
2711
|
+
let c;
|
|
2712
|
+
this._renderer.renderPipes.uniformBatch ? c = this._renderer.renderPipes.uniformBatch.getUniformBindGroup(d, !1) : (c = this._bindGroupPool.pop() || new zt(), this._activeBindGroups.push(c), c.setResource(d, 0)), l.bindGroup = c, this._currentGlobalUniformData = l;
|
|
1686
2713
|
}
|
|
1687
2714
|
push(e) {
|
|
1688
2715
|
this.bind(e), this._globalUniformDataStack[this._stackIndex++] = this._currentGlobalUniformData;
|
|
1689
2716
|
}
|
|
1690
2717
|
pop() {
|
|
1691
|
-
this._currentGlobalUniformData = this._globalUniformDataStack[--this._stackIndex - 1], this._renderer.type ===
|
|
2718
|
+
this._currentGlobalUniformData = this._globalUniformDataStack[--this._stackIndex - 1], this._renderer.type === ae.WEBGL && this._currentGlobalUniformData.bindGroup.resources[0].update();
|
|
1692
2719
|
}
|
|
1693
2720
|
get bindGroup() {
|
|
1694
2721
|
return this._currentGlobalUniformData.bindGroup;
|
|
@@ -1700,9 +2727,9 @@ class Ue {
|
|
|
1700
2727
|
return this._currentGlobalUniformData.bindGroup.resources[0];
|
|
1701
2728
|
}
|
|
1702
2729
|
_createUniforms() {
|
|
1703
|
-
return new
|
|
1704
|
-
uProjectionMatrix: { value: new
|
|
1705
|
-
uWorldTransformMatrix: { value: new
|
|
2730
|
+
return new ie({
|
|
2731
|
+
uProjectionMatrix: { value: new M(), type: "mat3x3<f32>" },
|
|
2732
|
+
uWorldTransformMatrix: { value: new M(), type: "mat3x3<f32>" },
|
|
1706
2733
|
// TODO - someone smart - set this to be a unorm8x4 rather than a vec4<f32>
|
|
1707
2734
|
uWorldColorAlpha: { value: new Float32Array(4), type: "vec4<f32>" },
|
|
1708
2735
|
uResolution: { value: [0, 0], type: "vec2<f32>" }
|
|
@@ -1714,22 +2741,22 @@ class Ue {
|
|
|
1714
2741
|
this._renderer = null, this._globalUniformDataStack.length = 0, this._uniformsPool.length = 0, this._activeUniforms.length = 0, this._bindGroupPool.length = 0, this._activeBindGroups.length = 0, this._currentGlobalUniformData = null;
|
|
1715
2742
|
}
|
|
1716
2743
|
}
|
|
1717
|
-
|
|
2744
|
+
xt.extension = {
|
|
1718
2745
|
type: [
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
2746
|
+
u.WebGLSystem,
|
|
2747
|
+
u.WebGPUSystem,
|
|
2748
|
+
u.CanvasSystem
|
|
1722
2749
|
],
|
|
1723
2750
|
name: "globalUniforms"
|
|
1724
2751
|
};
|
|
1725
|
-
let
|
|
1726
|
-
class
|
|
2752
|
+
let Vr = 1;
|
|
2753
|
+
class gt {
|
|
1727
2754
|
constructor() {
|
|
1728
2755
|
this._tasks = [], this._offset = 0;
|
|
1729
2756
|
}
|
|
1730
2757
|
/** Initializes the scheduler system and starts the ticker. */
|
|
1731
2758
|
init() {
|
|
1732
|
-
|
|
2759
|
+
ge.system.add(this._update, this);
|
|
1733
2760
|
}
|
|
1734
2761
|
/**
|
|
1735
2762
|
* Schedules a repeating task.
|
|
@@ -1739,13 +2766,13 @@ class Ae {
|
|
|
1739
2766
|
* @returns The unique identifier for the scheduled task.
|
|
1740
2767
|
*/
|
|
1741
2768
|
repeat(e, t, r = !0) {
|
|
1742
|
-
const s =
|
|
1743
|
-
let
|
|
1744
|
-
return r && (this._offset += 1e3,
|
|
2769
|
+
const s = Vr++;
|
|
2770
|
+
let i = 0;
|
|
2771
|
+
return r && (this._offset += 1e3, i = this._offset), this._tasks.push({
|
|
1745
2772
|
func: e,
|
|
1746
2773
|
duration: t,
|
|
1747
2774
|
start: performance.now(),
|
|
1748
|
-
offset:
|
|
2775
|
+
offset: i,
|
|
1749
2776
|
last: performance.now(),
|
|
1750
2777
|
repeat: !0,
|
|
1751
2778
|
id: s
|
|
@@ -1781,24 +2808,24 @@ class Ae {
|
|
|
1781
2808
|
* @internal
|
|
1782
2809
|
*/
|
|
1783
2810
|
destroy() {
|
|
1784
|
-
|
|
2811
|
+
ge.system.remove(this._update, this), this._tasks.length = 0;
|
|
1785
2812
|
}
|
|
1786
2813
|
}
|
|
1787
|
-
|
|
2814
|
+
gt.extension = {
|
|
1788
2815
|
type: [
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
2816
|
+
u.WebGLSystem,
|
|
2817
|
+
u.WebGPUSystem,
|
|
2818
|
+
u.CanvasSystem
|
|
1792
2819
|
],
|
|
1793
2820
|
name: "scheduler",
|
|
1794
2821
|
priority: 0
|
|
1795
2822
|
};
|
|
1796
|
-
let
|
|
1797
|
-
function
|
|
1798
|
-
if (!
|
|
1799
|
-
if (
|
|
2823
|
+
let Ee = !1;
|
|
2824
|
+
function Fr(n) {
|
|
2825
|
+
if (!Ee) {
|
|
2826
|
+
if (ne.get().getNavigator().userAgent.toLowerCase().indexOf("chrome") > -1) {
|
|
1800
2827
|
const e = [
|
|
1801
|
-
`%c %c %c %c %c PixiJS %c v${
|
|
2828
|
+
`%c %c %c %c %c PixiJS %c v${_e} (${n}) http://www.pixijs.com/
|
|
1802
2829
|
|
|
1803
2830
|
`,
|
|
1804
2831
|
"background: #E72264; padding:5px 0;",
|
|
@@ -1809,11 +2836,11 @@ function kt(a) {
|
|
|
1809
2836
|
"color: #E72264; background: #FFFFFF; padding:5px 0;"
|
|
1810
2837
|
];
|
|
1811
2838
|
globalThis.console.log(...e);
|
|
1812
|
-
} else globalThis.console && globalThis.console.log(`PixiJS ${
|
|
1813
|
-
|
|
2839
|
+
} else globalThis.console && globalThis.console.log(`PixiJS ${_e} - ${n} - http://www.pixijs.com/`);
|
|
2840
|
+
Ee = !0;
|
|
1814
2841
|
}
|
|
1815
2842
|
}
|
|
1816
|
-
class
|
|
2843
|
+
class he {
|
|
1817
2844
|
constructor(e) {
|
|
1818
2845
|
this._renderer = e;
|
|
1819
2846
|
}
|
|
@@ -1824,24 +2851,24 @@ class J {
|
|
|
1824
2851
|
init(e) {
|
|
1825
2852
|
if (e.hello) {
|
|
1826
2853
|
let t = this._renderer.name;
|
|
1827
|
-
this._renderer.type ===
|
|
2854
|
+
this._renderer.type === ae.WEBGL && (t += ` ${this._renderer.context.webGLVersion}`), Fr(t);
|
|
1828
2855
|
}
|
|
1829
2856
|
}
|
|
1830
2857
|
}
|
|
1831
|
-
|
|
2858
|
+
he.extension = {
|
|
1832
2859
|
type: [
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
2860
|
+
u.WebGLSystem,
|
|
2861
|
+
u.WebGPUSystem,
|
|
2862
|
+
u.CanvasSystem
|
|
1836
2863
|
],
|
|
1837
2864
|
name: "hello",
|
|
1838
2865
|
priority: -2
|
|
1839
2866
|
};
|
|
1840
|
-
|
|
2867
|
+
he.defaultOptions = {
|
|
1841
2868
|
/** {@link WebGLOptions.hello} */
|
|
1842
2869
|
hello: !1
|
|
1843
2870
|
};
|
|
1844
|
-
const
|
|
2871
|
+
const fe = class _t {
|
|
1845
2872
|
/**
|
|
1846
2873
|
* Creates a new RenderableGCSystem instance.
|
|
1847
2874
|
* @param renderer - The renderer this garbage collection system works for
|
|
@@ -1854,14 +2881,14 @@ const X = class Ie {
|
|
|
1854
2881
|
* @param options - Configuration options for the renderer
|
|
1855
2882
|
*/
|
|
1856
2883
|
init(e) {
|
|
1857
|
-
e = { ...
|
|
2884
|
+
e = { ..._t.defaultOptions, ...e }, this.maxUnusedTime = e.renderableGCMaxUnusedTime;
|
|
1858
2885
|
}
|
|
1859
2886
|
/**
|
|
1860
2887
|
* Gets whether the garbage collection system is currently enabled.
|
|
1861
2888
|
* @returns True if GC is enabled, false otherwise
|
|
1862
2889
|
*/
|
|
1863
2890
|
get enabled() {
|
|
1864
|
-
return
|
|
2891
|
+
return T("8.15.0", "RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."), this._renderer.gc.enabled;
|
|
1865
2892
|
}
|
|
1866
2893
|
/**
|
|
1867
2894
|
* Enables or disables the garbage collection system.
|
|
@@ -1869,7 +2896,7 @@ const X = class Ie {
|
|
|
1869
2896
|
* When disabled, cancels all scheduled cleanups.
|
|
1870
2897
|
*/
|
|
1871
2898
|
set enabled(e) {
|
|
1872
|
-
|
|
2899
|
+
T("8.15.0", "RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."), this._renderer.gc.enabled = e;
|
|
1873
2900
|
}
|
|
1874
2901
|
/**
|
|
1875
2902
|
* Adds a hash table to be managed by the garbage collector.
|
|
@@ -1877,7 +2904,7 @@ const X = class Ie {
|
|
|
1877
2904
|
* @param hash - The property name of the hash table
|
|
1878
2905
|
*/
|
|
1879
2906
|
addManagedHash(e, t) {
|
|
1880
|
-
|
|
2907
|
+
T("8.15.0", "RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."), this._renderer.gc.addCollection(e, t, "hash");
|
|
1881
2908
|
}
|
|
1882
2909
|
/**
|
|
1883
2910
|
* Adds an array to be managed by the garbage collector.
|
|
@@ -1885,7 +2912,7 @@ const X = class Ie {
|
|
|
1885
2912
|
* @param hash - The property name of the array
|
|
1886
2913
|
*/
|
|
1887
2914
|
addManagedArray(e, t) {
|
|
1888
|
-
|
|
2915
|
+
T("8.15.0", "RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."), this._renderer.gc.addCollection(e, t, "array");
|
|
1889
2916
|
}
|
|
1890
2917
|
/**
|
|
1891
2918
|
* Starts tracking a renderable for garbage collection.
|
|
@@ -1893,30 +2920,30 @@ const X = class Ie {
|
|
|
1893
2920
|
* @deprecated since 8.15.0
|
|
1894
2921
|
*/
|
|
1895
2922
|
addRenderable(e) {
|
|
1896
|
-
|
|
2923
|
+
T("8.15.0", "RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."), this._renderer.gc.addResource(e, "renderable");
|
|
1897
2924
|
}
|
|
1898
2925
|
/**
|
|
1899
2926
|
* Performs garbage collection by cleaning up unused renderables.
|
|
1900
2927
|
* Removes renderables that haven't been used for longer than maxUnusedTime.
|
|
1901
2928
|
*/
|
|
1902
2929
|
run() {
|
|
1903
|
-
|
|
2930
|
+
T("8.15.0", "RenderableGCSystem.run is deprecated, please use the GCSystem instead."), this._renderer.gc.run();
|
|
1904
2931
|
}
|
|
1905
2932
|
/** Cleans up the garbage collection system. Disables GC and removes all tracked resources. */
|
|
1906
2933
|
destroy() {
|
|
1907
2934
|
this._renderer = null;
|
|
1908
2935
|
}
|
|
1909
2936
|
};
|
|
1910
|
-
|
|
2937
|
+
fe.extension = {
|
|
1911
2938
|
type: [
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
2939
|
+
u.WebGLSystem,
|
|
2940
|
+
u.WebGPUSystem,
|
|
2941
|
+
u.CanvasSystem
|
|
1915
2942
|
],
|
|
1916
2943
|
name: "renderableGC",
|
|
1917
2944
|
priority: 0
|
|
1918
2945
|
};
|
|
1919
|
-
|
|
2946
|
+
fe.defaultOptions = {
|
|
1920
2947
|
/** Enable/disable the garbage collector */
|
|
1921
2948
|
renderableGCActive: !0,
|
|
1922
2949
|
/** Time in ms before an unused resource is collected (default 1 minute) */
|
|
@@ -1924,8 +2951,8 @@ X.defaultOptions = {
|
|
|
1924
2951
|
/** How often to run garbage collection in ms (default 30 seconds) */
|
|
1925
2952
|
renderableGCFrequency: 3e4
|
|
1926
2953
|
};
|
|
1927
|
-
let
|
|
1928
|
-
const
|
|
2954
|
+
let Lr = fe;
|
|
2955
|
+
const pe = class H {
|
|
1929
2956
|
/**
|
|
1930
2957
|
* Frame count since started.
|
|
1931
2958
|
* @readonly
|
|
@@ -1943,7 +2970,7 @@ const Z = class S {
|
|
|
1943
2970
|
return this._checkCount;
|
|
1944
2971
|
}
|
|
1945
2972
|
set checkCount(e) {
|
|
1946
|
-
|
|
2973
|
+
T("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead."), this._checkCount = e;
|
|
1947
2974
|
}
|
|
1948
2975
|
/**
|
|
1949
2976
|
* Maximum idle frames before a texture is destroyed by garbage collection.
|
|
@@ -1954,7 +2981,7 @@ const Z = class S {
|
|
|
1954
2981
|
return this._renderer.gc.maxUnusedTime / 1e3 * 60;
|
|
1955
2982
|
}
|
|
1956
2983
|
set maxIdle(e) {
|
|
1957
|
-
|
|
2984
|
+
T("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead."), this._renderer.gc.maxUnusedTime = e / 60 * 1e3;
|
|
1958
2985
|
}
|
|
1959
2986
|
/**
|
|
1960
2987
|
* Frames between two garbage collections.
|
|
@@ -1966,7 +2993,7 @@ const Z = class S {
|
|
|
1966
2993
|
return Math.floor(this._renderer.gc._frequency / 1e3);
|
|
1967
2994
|
}
|
|
1968
2995
|
set checkCountMax(e) {
|
|
1969
|
-
|
|
2996
|
+
T("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead.");
|
|
1970
2997
|
}
|
|
1971
2998
|
/**
|
|
1972
2999
|
* Current garbage collection mode.
|
|
@@ -1977,14 +3004,14 @@ const Z = class S {
|
|
|
1977
3004
|
return this._renderer.gc.enabled;
|
|
1978
3005
|
}
|
|
1979
3006
|
set active(e) {
|
|
1980
|
-
|
|
3007
|
+
T("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead."), this._renderer.gc.enabled = e;
|
|
1981
3008
|
}
|
|
1982
3009
|
/** @param renderer - The renderer this System works for. */
|
|
1983
3010
|
constructor(e) {
|
|
1984
3011
|
this._renderer = e, this._checkCount = 0;
|
|
1985
3012
|
}
|
|
1986
3013
|
init(e) {
|
|
1987
|
-
e.textureGCActive !==
|
|
3014
|
+
e.textureGCActive !== H.defaultOptions.textureGCActive && (this.active = e.textureGCActive), e.textureGCMaxIdle !== H.defaultOptions.textureGCMaxIdle && (this.maxIdle = e.textureGCMaxIdle), e.textureGCCheckCountMax !== H.defaultOptions.textureGCCheckCountMax && (this.checkCountMax = e.textureGCCheckCountMax);
|
|
1988
3015
|
}
|
|
1989
3016
|
/**
|
|
1990
3017
|
* Checks to see when the last time a texture was used.
|
|
@@ -1992,20 +3019,20 @@ const Z = class S {
|
|
|
1992
3019
|
* @deprecated since 8.15.0
|
|
1993
3020
|
*/
|
|
1994
3021
|
run() {
|
|
1995
|
-
|
|
3022
|
+
T("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead."), this._renderer.gc.run();
|
|
1996
3023
|
}
|
|
1997
3024
|
destroy() {
|
|
1998
3025
|
this._renderer = null;
|
|
1999
3026
|
}
|
|
2000
3027
|
};
|
|
2001
|
-
|
|
3028
|
+
pe.extension = {
|
|
2002
3029
|
type: [
|
|
2003
|
-
|
|
2004
|
-
|
|
3030
|
+
u.WebGLSystem,
|
|
3031
|
+
u.WebGPUSystem
|
|
2005
3032
|
],
|
|
2006
3033
|
name: "textureGC"
|
|
2007
3034
|
};
|
|
2008
|
-
|
|
3035
|
+
pe.defaultOptions = {
|
|
2009
3036
|
/**
|
|
2010
3037
|
* If set to true, this will enable the garbage collector on the GPU.
|
|
2011
3038
|
* @default true
|
|
@@ -2027,17 +3054,17 @@ Z.defaultOptions = {
|
|
|
2027
3054
|
*/
|
|
2028
3055
|
textureGCCheckCountMax: 600
|
|
2029
3056
|
};
|
|
2030
|
-
let
|
|
2031
|
-
const
|
|
3057
|
+
let Wr = pe;
|
|
3058
|
+
const bt = class vt {
|
|
2032
3059
|
/**
|
|
2033
3060
|
* @param [descriptor] - Options for creating a render target.
|
|
2034
3061
|
*/
|
|
2035
3062
|
constructor(e = {}) {
|
|
2036
|
-
if (this.uid =
|
|
3063
|
+
if (this.uid = ze("renderTarget"), this.colorTextures = [], this.dirtyId = 0, this.isRoot = !1, this._size = new Float32Array(2), this._managedColorTextures = !1, e = { ...vt.defaultOptions, ...e }, this.stencil = e.stencil, this.depth = e.depth, this.isRoot = e.isRoot, typeof e.colorTextures == "number") {
|
|
2037
3064
|
this._managedColorTextures = !0;
|
|
2038
3065
|
for (let t = 0; t < e.colorTextures; t++)
|
|
2039
3066
|
this.colorTextures.push(
|
|
2040
|
-
new
|
|
3067
|
+
new I({
|
|
2041
3068
|
width: e.width,
|
|
2042
3069
|
height: e.height,
|
|
2043
3070
|
resolution: e.resolution,
|
|
@@ -2049,7 +3076,7 @@ const De = class Ee {
|
|
|
2049
3076
|
const t = this.colorTexture.source;
|
|
2050
3077
|
this.resize(t.width, t.height, t._resolution);
|
|
2051
3078
|
}
|
|
2052
|
-
this.colorTexture.source.on("resize", this.onSourceResize, this), (e.depthStencilTexture || this.stencil) && (e.depthStencilTexture instanceof
|
|
3079
|
+
this.colorTexture.source.on("resize", this.onSourceResize, this), (e.depthStencilTexture || this.stencil) && (e.depthStencilTexture instanceof S || e.depthStencilTexture instanceof I ? this.depthStencilTexture = e.depthStencilTexture.source : this.ensureDepthStencilTexture());
|
|
2053
3080
|
}
|
|
2054
3081
|
get size() {
|
|
2055
3082
|
const e = this._size;
|
|
@@ -2082,7 +3109,7 @@ const De = class Ee {
|
|
|
2082
3109
|
* @internal
|
|
2083
3110
|
*/
|
|
2084
3111
|
ensureDepthStencilTexture() {
|
|
2085
|
-
this.depthStencilTexture || (this.depthStencilTexture = new
|
|
3112
|
+
this.depthStencilTexture || (this.depthStencilTexture = new I({
|
|
2086
3113
|
width: this.width,
|
|
2087
3114
|
height: this.height,
|
|
2088
3115
|
resolution: this.resolution,
|
|
@@ -2094,8 +3121,8 @@ const De = class Ee {
|
|
|
2094
3121
|
}));
|
|
2095
3122
|
}
|
|
2096
3123
|
resize(e, t, r = this.resolution, s = !1) {
|
|
2097
|
-
this.dirtyId++, this.colorTextures.forEach((
|
|
2098
|
-
s &&
|
|
3124
|
+
this.dirtyId++, this.colorTextures.forEach((i, a) => {
|
|
3125
|
+
s && a === 0 || i.source.resize(e, t, r);
|
|
2099
3126
|
}), this.depthStencilTexture && this.depthStencilTexture.source.resize(e, t, r);
|
|
2100
3127
|
}
|
|
2101
3128
|
destroy() {
|
|
@@ -2104,7 +3131,7 @@ const De = class Ee {
|
|
|
2104
3131
|
}), this.depthStencilTexture && (this.depthStencilTexture.destroy(), delete this.depthStencilTexture);
|
|
2105
3132
|
}
|
|
2106
3133
|
};
|
|
2107
|
-
|
|
3134
|
+
bt.defaultOptions = {
|
|
2108
3135
|
/** the width of the RenderTarget */
|
|
2109
3136
|
width: 0,
|
|
2110
3137
|
/** the height of the RenderTarget */
|
|
@@ -2123,24 +3150,24 @@ De.defaultOptions = {
|
|
|
2123
3150
|
/** is this a root element, true if this is gl context owners render target */
|
|
2124
3151
|
isRoot: !1
|
|
2125
3152
|
};
|
|
2126
|
-
let
|
|
2127
|
-
const
|
|
2128
|
-
|
|
2129
|
-
function
|
|
2130
|
-
if (!
|
|
2131
|
-
const t = new
|
|
2132
|
-
source: new
|
|
2133
|
-
resource:
|
|
3153
|
+
let ee = bt;
|
|
3154
|
+
const P = /* @__PURE__ */ new Map();
|
|
3155
|
+
He.register(P);
|
|
3156
|
+
function yt(n, e) {
|
|
3157
|
+
if (!P.has(n)) {
|
|
3158
|
+
const t = new S({
|
|
3159
|
+
source: new X({
|
|
3160
|
+
resource: n,
|
|
2134
3161
|
...e
|
|
2135
3162
|
})
|
|
2136
3163
|
}), r = () => {
|
|
2137
|
-
|
|
3164
|
+
P.get(n) === t && P.delete(n);
|
|
2138
3165
|
};
|
|
2139
|
-
t.once("destroy", r), t.source.once("destroy", r),
|
|
3166
|
+
t.once("destroy", r), t.source.once("destroy", r), P.set(n, t);
|
|
2140
3167
|
}
|
|
2141
|
-
return
|
|
3168
|
+
return P.get(n);
|
|
2142
3169
|
}
|
|
2143
|
-
const
|
|
3170
|
+
const me = class Tt {
|
|
2144
3171
|
/**
|
|
2145
3172
|
* Whether CSS dimensions of canvas view should be resized to screen dimensions automatically.
|
|
2146
3173
|
* This is only supported for HTMLCanvasElement and will be ignored if the canvas is an OffscreenCanvas.
|
|
@@ -2169,9 +3196,9 @@ const Q = class Le {
|
|
|
2169
3196
|
*/
|
|
2170
3197
|
init(e) {
|
|
2171
3198
|
e = {
|
|
2172
|
-
...
|
|
3199
|
+
...Tt.defaultOptions,
|
|
2173
3200
|
...e
|
|
2174
|
-
}, e.view && (
|
|
3201
|
+
}, e.view && (T(Rt, "ViewSystem.view has been renamed to ViewSystem.canvas"), e.canvas = e.view), this.screen = new L(0, 0, e.width, e.height), this.canvas = e.canvas || ne.get().createCanvas(), this.antialias = !!e.antialias, this.texture = yt(this.canvas, e), this.renderTarget = new ee({
|
|
2175
3202
|
colorTextures: [this.texture],
|
|
2176
3203
|
depth: !!e.depth,
|
|
2177
3204
|
isRoot: !0
|
|
@@ -2198,16 +3225,16 @@ const Q = class Le {
|
|
|
2198
3225
|
(typeof e == "boolean" ? e : !!(e != null && e.removeView)) && this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), this.texture.destroy();
|
|
2199
3226
|
}
|
|
2200
3227
|
};
|
|
2201
|
-
|
|
3228
|
+
me.extension = {
|
|
2202
3229
|
type: [
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
3230
|
+
u.WebGLSystem,
|
|
3231
|
+
u.WebGPUSystem,
|
|
3232
|
+
u.CanvasSystem
|
|
2206
3233
|
],
|
|
2207
3234
|
name: "view",
|
|
2208
3235
|
priority: 0
|
|
2209
3236
|
};
|
|
2210
|
-
|
|
3237
|
+
me.defaultOptions = {
|
|
2211
3238
|
/**
|
|
2212
3239
|
* {@link WebGLOptions.width}
|
|
2213
3240
|
* @default 800
|
|
@@ -2229,41 +3256,41 @@ Q.defaultOptions = {
|
|
|
2229
3256
|
*/
|
|
2230
3257
|
antialias: !1
|
|
2231
3258
|
};
|
|
2232
|
-
let
|
|
2233
|
-
const
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
3259
|
+
let Or = me;
|
|
3260
|
+
const Qr = [
|
|
3261
|
+
Ar,
|
|
3262
|
+
xt,
|
|
3263
|
+
he,
|
|
3264
|
+
Or,
|
|
3265
|
+
dt,
|
|
3266
|
+
Hr,
|
|
3267
|
+
Wr,
|
|
3268
|
+
pt,
|
|
3269
|
+
Ur,
|
|
3270
|
+
Pt,
|
|
3271
|
+
Lr,
|
|
3272
|
+
gt
|
|
3273
|
+
], Yr = [
|
|
3274
|
+
lt,
|
|
3275
|
+
tt,
|
|
3276
|
+
ot,
|
|
3277
|
+
at,
|
|
3278
|
+
rt,
|
|
3279
|
+
nt,
|
|
2243
3280
|
st,
|
|
2244
|
-
|
|
2245
|
-
Ae
|
|
2246
|
-
], At = [
|
|
2247
|
-
ke,
|
|
2248
|
-
_e,
|
|
2249
|
-
Ce,
|
|
2250
|
-
ve,
|
|
2251
|
-
xe,
|
|
2252
|
-
Te,
|
|
2253
|
-
be,
|
|
2254
|
-
ye
|
|
3281
|
+
it
|
|
2255
3282
|
];
|
|
2256
|
-
function
|
|
2257
|
-
const
|
|
2258
|
-
return
|
|
3283
|
+
function $r(n, e, t, r, s, i) {
|
|
3284
|
+
const a = i ? 1 : -1;
|
|
3285
|
+
return n.identity(), n.a = 1 / r * 2, n.d = a * (1 / s * 2), n.tx = -1 - e * n.a, n.ty = -a - t * n.d, n;
|
|
2259
3286
|
}
|
|
2260
|
-
function
|
|
2261
|
-
const e =
|
|
3287
|
+
function jr(n) {
|
|
3288
|
+
const e = n.colorTexture.source.resource;
|
|
2262
3289
|
return globalThis.HTMLCanvasElement && e instanceof HTMLCanvasElement && document.body.contains(e);
|
|
2263
3290
|
}
|
|
2264
|
-
class
|
|
3291
|
+
class Xr {
|
|
2265
3292
|
constructor(e) {
|
|
2266
|
-
this.rootViewPort = new
|
|
3293
|
+
this.rootViewPort = new L(), this.viewport = new L(), this.mipLevel = 0, this.layer = 0, this.onRenderTargetChange = new At("onRenderTargetChange"), this.projectionMatrix = new M(), this.defaultClearColor = [0, 0, 0, 0], this._renderSurfaceToRenderTargetHash = /* @__PURE__ */ new Map(), this._gpuRenderTargetHash = /* @__PURE__ */ Object.create(null), this._renderTargetStack = [], this._renderer = e, e.gc.addCollection(this, "_gpuRenderTargetHash", "hash");
|
|
2267
3294
|
}
|
|
2268
3295
|
/** called when dev wants to finish a render pass */
|
|
2269
3296
|
finishRenderPass() {
|
|
@@ -2285,18 +3312,18 @@ class It {
|
|
|
2285
3312
|
clear: t,
|
|
2286
3313
|
clearColor: r,
|
|
2287
3314
|
frame: s,
|
|
2288
|
-
mipLevel:
|
|
2289
|
-
layer:
|
|
3315
|
+
mipLevel: i,
|
|
3316
|
+
layer: a
|
|
2290
3317
|
}) {
|
|
2291
|
-
var o,
|
|
3318
|
+
var o, l;
|
|
2292
3319
|
this._renderTargetStack.length = 0, this.push(
|
|
2293
3320
|
e,
|
|
2294
3321
|
t,
|
|
2295
3322
|
r,
|
|
2296
3323
|
s,
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
), this.rootViewPort.copyFrom(this.viewport), this.rootRenderTarget = this.renderTarget, this.renderingToScreen =
|
|
3324
|
+
i ?? 0,
|
|
3325
|
+
a ?? 0
|
|
3326
|
+
), this.rootViewPort.copyFrom(this.viewport), this.rootRenderTarget = this.renderTarget, this.renderingToScreen = jr(this.rootRenderTarget), (l = (o = this.adaptor).prerender) == null || l.call(o, this.rootRenderTarget);
|
|
2300
3327
|
}
|
|
2301
3328
|
postrender() {
|
|
2302
3329
|
var e, t;
|
|
@@ -2327,39 +3354,39 @@ class It {
|
|
|
2327
3354
|
* Ignored for surfaces that do not support layers.
|
|
2328
3355
|
* @returns the render target that was bound
|
|
2329
3356
|
*/
|
|
2330
|
-
bind(e, t = !0, r, s,
|
|
2331
|
-
const o = this.getRenderTarget(e),
|
|
3357
|
+
bind(e, t = !0, r, s, i = 0, a = 0) {
|
|
3358
|
+
const o = this.getRenderTarget(e), l = this.renderTarget !== o;
|
|
2332
3359
|
this.renderTarget = o, this.renderSurface = e;
|
|
2333
|
-
const
|
|
2334
|
-
(o.pixelWidth !==
|
|
2335
|
-
const
|
|
2336
|
-
if ((
|
|
2337
|
-
throw new Error(`[RenderTargetSystem] layer ${
|
|
2338
|
-
this.mipLevel =
|
|
2339
|
-
const
|
|
2340
|
-
if (!s && e instanceof
|
|
2341
|
-
const
|
|
2342
|
-
let
|
|
2343
|
-
|
|
3360
|
+
const d = this.getGpuRenderTarget(o);
|
|
3361
|
+
(o.pixelWidth !== d.width || o.pixelHeight !== d.height) && (this.adaptor.resizeGpuRenderTarget(o), d.width = o.pixelWidth, d.height = o.pixelHeight);
|
|
3362
|
+
const f = o.colorTexture, c = this.viewport, x = f.arrayLayerCount || 1;
|
|
3363
|
+
if ((a | 0) !== a && (a |= 0), a < 0 || a >= x)
|
|
3364
|
+
throw new Error(`[RenderTargetSystem] layer ${a} is out of bounds (arrayLayerCount=${x}).`);
|
|
3365
|
+
this.mipLevel = i | 0, this.layer = a | 0;
|
|
3366
|
+
const g = Math.max(f.pixelWidth >> i, 1), m = Math.max(f.pixelHeight >> i, 1);
|
|
3367
|
+
if (!s && e instanceof S && (s = e.frame), s) {
|
|
3368
|
+
const v = f._resolution, _ = 1 << Math.max(i | 0, 0), h = s.x * v + 0.5 | 0, C = s.y * v + 0.5 | 0, p = s.width * v + 0.5 | 0, y = s.height * v + 0.5 | 0;
|
|
3369
|
+
let b = Math.floor(h / _), B = Math.floor(C / _), O = Math.ceil(p / _), $ = Math.ceil(y / _);
|
|
3370
|
+
b = Math.min(Math.max(b, 0), g - 1), B = Math.min(Math.max(B, 0), m - 1), O = Math.min(Math.max(O, 1), g - b), $ = Math.min(Math.max($, 1), m - B), c.x = b, c.y = B, c.width = O, c.height = $;
|
|
2344
3371
|
} else
|
|
2345
|
-
|
|
2346
|
-
return
|
|
3372
|
+
c.x = 0, c.y = 0, c.width = g, c.height = m;
|
|
3373
|
+
return $r(
|
|
2347
3374
|
this.projectionMatrix,
|
|
2348
3375
|
0,
|
|
2349
3376
|
0,
|
|
2350
|
-
|
|
2351
|
-
|
|
3377
|
+
c.width / f.resolution,
|
|
3378
|
+
c.height / f.resolution,
|
|
2352
3379
|
!o.isRoot
|
|
2353
|
-
), this.adaptor.startRenderPass(o, t, r,
|
|
3380
|
+
), this.adaptor.startRenderPass(o, t, r, c, i, a), l && this.onRenderTargetChange.emit(o), o;
|
|
2354
3381
|
}
|
|
2355
|
-
clear(e, t =
|
|
3382
|
+
clear(e, t = Q.ALL, r, s = this.mipLevel, i = this.layer) {
|
|
2356
3383
|
t && (e && (e = this.getRenderTarget(e)), this.adaptor.clear(
|
|
2357
3384
|
e || this.renderTarget,
|
|
2358
3385
|
t,
|
|
2359
3386
|
r,
|
|
2360
3387
|
this.viewport,
|
|
2361
3388
|
s,
|
|
2362
|
-
|
|
3389
|
+
i
|
|
2363
3390
|
));
|
|
2364
3391
|
}
|
|
2365
3392
|
contextChange() {
|
|
@@ -2375,13 +3402,13 @@ class It {
|
|
|
2375
3402
|
* @param layer - The layer of the render surface to render to. For array textures or cube maps, this specifies
|
|
2376
3403
|
* which layer or face to target. Defaults to 0 (the first layer).
|
|
2377
3404
|
*/
|
|
2378
|
-
push(e, t =
|
|
2379
|
-
const o = this.bind(e, t, r, s,
|
|
3405
|
+
push(e, t = Q.ALL, r, s, i = 0, a = 0) {
|
|
3406
|
+
const o = this.bind(e, t, r, s, i, a);
|
|
2380
3407
|
return this._renderTargetStack.push({
|
|
2381
3408
|
renderTarget: o,
|
|
2382
3409
|
frame: s,
|
|
2383
|
-
mipLevel:
|
|
2384
|
-
layer:
|
|
3410
|
+
mipLevel: i,
|
|
3411
|
+
layer: a
|
|
2385
3412
|
}), o;
|
|
2386
3413
|
}
|
|
2387
3414
|
/** Pops the current render target from the renderer and restores the previous render target. */
|
|
@@ -2446,15 +3473,15 @@ class It {
|
|
|
2446
3473
|
* @param {number} originDest.x - the x origin of the paste
|
|
2447
3474
|
* @param {number} originDest.y - the y origin of the paste
|
|
2448
3475
|
*/
|
|
2449
|
-
copyToTexture(e, t, r, s,
|
|
2450
|
-
r.x < 0 && (s.width += r.x,
|
|
2451
|
-
const { pixelWidth:
|
|
2452
|
-
return s.width = Math.min(s.width,
|
|
3476
|
+
copyToTexture(e, t, r, s, i) {
|
|
3477
|
+
r.x < 0 && (s.width += r.x, i.x -= r.x, r.x = 0), r.y < 0 && (s.height += r.y, i.y -= r.y, r.y = 0);
|
|
3478
|
+
const { pixelWidth: a, pixelHeight: o } = e;
|
|
3479
|
+
return s.width = Math.min(s.width, a - r.x), s.height = Math.min(s.height, o - r.y), this.adaptor.copyToTexture(
|
|
2453
3480
|
e,
|
|
2454
3481
|
t,
|
|
2455
3482
|
r,
|
|
2456
3483
|
s,
|
|
2457
|
-
|
|
3484
|
+
i
|
|
2458
3485
|
);
|
|
2459
3486
|
}
|
|
2460
3487
|
/**
|
|
@@ -2472,9 +3499,9 @@ class It {
|
|
|
2472
3499
|
}
|
|
2473
3500
|
_initRenderTarget(e) {
|
|
2474
3501
|
let t = null;
|
|
2475
|
-
return
|
|
3502
|
+
return X.test(e) && (e = yt(e).source), e instanceof ee ? t = e : e instanceof I && (t = new ee({
|
|
2476
3503
|
colorTextures: [e]
|
|
2477
|
-
}), e.source instanceof
|
|
3504
|
+
}), e.source instanceof X && (t.isRoot = !0), e.once("destroy", () => {
|
|
2478
3505
|
t.destroy(), this._renderSurfaceToRenderTargetHash.delete(e);
|
|
2479
3506
|
const r = this._gpuRenderTargetHash[t.uid];
|
|
2480
3507
|
r && (this._gpuRenderTargetHash[t.uid] = null, this.adaptor.destroyGpuRenderTarget(r));
|
|
@@ -2488,14 +3515,29 @@ class It {
|
|
|
2488
3515
|
}
|
|
2489
3516
|
}
|
|
2490
3517
|
export {
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
3518
|
+
rt as A,
|
|
3519
|
+
lt as B,
|
|
3520
|
+
it as C,
|
|
3521
|
+
Je as D,
|
|
3522
|
+
qr as G,
|
|
3523
|
+
Xr as R,
|
|
3524
|
+
k as S,
|
|
3525
|
+
dr as a,
|
|
3526
|
+
Qr as b,
|
|
3527
|
+
ur as c,
|
|
3528
|
+
Yr as d,
|
|
3529
|
+
Lt as e,
|
|
3530
|
+
ye as f,
|
|
3531
|
+
mr as g,
|
|
3532
|
+
cr as h,
|
|
3533
|
+
hr as i,
|
|
3534
|
+
br as j,
|
|
3535
|
+
gr as k,
|
|
3536
|
+
vr as l,
|
|
3537
|
+
Sr as m,
|
|
3538
|
+
tt as n,
|
|
3539
|
+
ot as o,
|
|
3540
|
+
at as p,
|
|
3541
|
+
_r as r
|
|
2500
3542
|
};
|
|
2501
|
-
//# sourceMappingURL=RenderTargetSystem-
|
|
3543
|
+
//# sourceMappingURL=RenderTargetSystem-BCBByEgg.js.map
|