holostaff-widget 2.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-Bh7Dg2tm.js +535 -0
- package/dist/BufferResource-Bh7Dg2tm.js.map +1 -0
- package/dist/CanvasRenderer-DVQieOII.js +976 -0
- package/dist/CanvasRenderer-DVQieOII.js.map +1 -0
- package/dist/RenderTargetSystem-B-GzTxxb.js +2500 -0
- package/dist/RenderTargetSystem-B-GzTxxb.js.map +1 -0
- package/dist/WebGLRenderer-D18tg5um.js +2938 -0
- package/dist/WebGLRenderer-D18tg5um.js.map +1 -0
- package/dist/WebGPURenderer-BuntxQ1w.js +1723 -0
- package/dist/WebGPURenderer-BuntxQ1w.js.map +1 -0
- package/dist/assets/idle-loop-green-8.mp4 +0 -0
- package/dist/assets/idle-loop-green.mp4 +0 -0
- package/dist/assets/idle-loop.mp4 +0 -0
- package/dist/assets/idle-loop.webm +0 -0
- package/dist/browserAll-DgNyjpqs.js +1872 -0
- package/dist/browserAll-DgNyjpqs.js.map +1 -0
- package/dist/hs-widget.es.js +5 -0
- package/dist/hs-widget.es.js.map +1 -0
- package/dist/hs-widget.umd.js +1003 -0
- package/dist/hs-widget.umd.js.map +1 -0
- package/dist/index-DjIeNhPr.js +23003 -0
- package/dist/index-DjIeNhPr.js.map +1 -0
- package/dist/webworkerAll-DndJ9Gy-.js +525 -0
- package/dist/webworkerAll-DndJ9Gy-.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,2500 @@
|
|
|
1
|
+
import { Q as Ve, V as Ne, H as oe, M as m, W as je, X as $e, p as qe, Y as le, e as l, k as W, Z as w, _ as Ke, $ as z, a0 as T, R as V, a1 as de, a2 as Ye, T as f, S as g, y as D, a3 as ue, w as ce, a4 as ee, a5 as he, a6 as pe, a7 as fe, a8 as me, n as P, a9 as Xe, C as E, D as N, z as v, aa as B, ab as Je, P as Qe, ac as Ze, v as et, l as te, ad as re, ae as p, b as tt, j as O, af as rt, ag as st, ah as nt, ai as at } from "./index-DjIeNhPr.js";
|
|
2
|
+
var it = `in vec2 vMaskCoord;
|
|
3
|
+
in vec2 vTextureCoord;
|
|
4
|
+
|
|
5
|
+
uniform sampler2D uTexture;
|
|
6
|
+
uniform sampler2D uMaskTexture;
|
|
7
|
+
|
|
8
|
+
uniform float uAlpha;
|
|
9
|
+
uniform vec4 uMaskClamp;
|
|
10
|
+
uniform float uInverse;
|
|
11
|
+
|
|
12
|
+
out vec4 finalColor;
|
|
13
|
+
|
|
14
|
+
void main(void)
|
|
15
|
+
{
|
|
16
|
+
float clip = step(3.5,
|
|
17
|
+
step(uMaskClamp.x, vMaskCoord.x) +
|
|
18
|
+
step(uMaskClamp.y, vMaskCoord.y) +
|
|
19
|
+
step(vMaskCoord.x, uMaskClamp.z) +
|
|
20
|
+
step(vMaskCoord.y, uMaskClamp.w));
|
|
21
|
+
|
|
22
|
+
// TODO look into why this is needed
|
|
23
|
+
float npmAlpha = uAlpha;
|
|
24
|
+
vec4 original = texture(uTexture, vTextureCoord);
|
|
25
|
+
vec4 masky = texture(uMaskTexture, vMaskCoord);
|
|
26
|
+
float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
|
|
27
|
+
|
|
28
|
+
float a = alphaMul * masky.r * npmAlpha * clip;
|
|
29
|
+
|
|
30
|
+
if (uInverse == 1.0) {
|
|
31
|
+
a = 1.0 - a;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
finalColor = original * a;
|
|
35
|
+
}
|
|
36
|
+
`, ot = `in vec2 aPosition;
|
|
37
|
+
|
|
38
|
+
out vec2 vTextureCoord;
|
|
39
|
+
out vec2 vMaskCoord;
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
uniform vec4 uInputSize;
|
|
43
|
+
uniform vec4 uOutputFrame;
|
|
44
|
+
uniform vec4 uOutputTexture;
|
|
45
|
+
uniform mat3 uFilterMatrix;
|
|
46
|
+
|
|
47
|
+
vec4 filterVertexPosition( vec2 aPosition )
|
|
48
|
+
{
|
|
49
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
50
|
+
|
|
51
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
52
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
53
|
+
|
|
54
|
+
return vec4(position, 0.0, 1.0);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
vec2 filterTextureCoord( vec2 aPosition )
|
|
58
|
+
{
|
|
59
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
vec2 getFilterCoord( vec2 aPosition )
|
|
63
|
+
{
|
|
64
|
+
return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
void main(void)
|
|
68
|
+
{
|
|
69
|
+
gl_Position = filterVertexPosition(aPosition);
|
|
70
|
+
vTextureCoord = filterTextureCoord(aPosition);
|
|
71
|
+
vMaskCoord = getFilterCoord(aPosition);
|
|
72
|
+
}
|
|
73
|
+
`, se = `struct GlobalFilterUniforms {
|
|
74
|
+
uInputSize:vec4<f32>,
|
|
75
|
+
uInputPixel:vec4<f32>,
|
|
76
|
+
uInputClamp:vec4<f32>,
|
|
77
|
+
uOutputFrame:vec4<f32>,
|
|
78
|
+
uGlobalFrame:vec4<f32>,
|
|
79
|
+
uOutputTexture:vec4<f32>,
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
struct MaskUniforms {
|
|
83
|
+
uFilterMatrix:mat3x3<f32>,
|
|
84
|
+
uMaskClamp:vec4<f32>,
|
|
85
|
+
uAlpha:f32,
|
|
86
|
+
uInverse:f32,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
90
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
91
|
+
@group(0) @binding(2) var uSampler : sampler;
|
|
92
|
+
|
|
93
|
+
@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
|
|
94
|
+
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
|
|
95
|
+
|
|
96
|
+
struct VSOutput {
|
|
97
|
+
@builtin(position) position: vec4<f32>,
|
|
98
|
+
@location(0) uv : vec2<f32>,
|
|
99
|
+
@location(1) filterUv : vec2<f32>,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
103
|
+
{
|
|
104
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
105
|
+
|
|
106
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
107
|
+
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
108
|
+
|
|
109
|
+
return vec4(position, 0.0, 1.0);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
113
|
+
{
|
|
114
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
118
|
+
{
|
|
119
|
+
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
|
|
123
|
+
{
|
|
124
|
+
return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
fn getSize() -> vec2<f32>
|
|
128
|
+
{
|
|
129
|
+
return gfu.uGlobalFrame.zw;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@vertex
|
|
133
|
+
fn mainVertex(
|
|
134
|
+
@location(0) aPosition : vec2<f32>,
|
|
135
|
+
) -> VSOutput {
|
|
136
|
+
return VSOutput(
|
|
137
|
+
filterVertexPosition(aPosition),
|
|
138
|
+
filterTextureCoord(aPosition),
|
|
139
|
+
getFilterCoord(aPosition)
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@fragment
|
|
144
|
+
fn mainFragment(
|
|
145
|
+
@location(0) uv: vec2<f32>,
|
|
146
|
+
@location(1) filterUv: vec2<f32>,
|
|
147
|
+
@builtin(position) position: vec4<f32>
|
|
148
|
+
) -> @location(0) vec4<f32> {
|
|
149
|
+
|
|
150
|
+
var maskClamp = filterUniforms.uMaskClamp;
|
|
151
|
+
var uAlpha = filterUniforms.uAlpha;
|
|
152
|
+
|
|
153
|
+
var clip = step(3.5,
|
|
154
|
+
step(maskClamp.x, filterUv.x) +
|
|
155
|
+
step(maskClamp.y, filterUv.y) +
|
|
156
|
+
step(filterUv.x, maskClamp.z) +
|
|
157
|
+
step(filterUv.y, maskClamp.w));
|
|
158
|
+
|
|
159
|
+
var mask = textureSample(uMaskTexture, uSampler, filterUv);
|
|
160
|
+
var source = textureSample(uTexture, uSampler, uv);
|
|
161
|
+
var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
|
|
162
|
+
|
|
163
|
+
var a: f32 = alphaMul * mask.r * uAlpha * clip;
|
|
164
|
+
|
|
165
|
+
if (filterUniforms.uInverse == 1.0) {
|
|
166
|
+
a = 1.0 - a;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return source * a;
|
|
170
|
+
}
|
|
171
|
+
`;
|
|
172
|
+
class lt extends Ve {
|
|
173
|
+
constructor(e) {
|
|
174
|
+
const { sprite: t, ...r } = e, s = new Ne(t.texture), n = new oe({
|
|
175
|
+
uFilterMatrix: { value: new m(), type: "mat3x3<f32>" },
|
|
176
|
+
uMaskClamp: { value: s.uClampFrame, type: "vec4<f32>" },
|
|
177
|
+
uAlpha: { value: 1, type: "f32" },
|
|
178
|
+
uInverse: { value: e.inverse ? 1 : 0, type: "f32" }
|
|
179
|
+
}), i = je.from({
|
|
180
|
+
vertex: {
|
|
181
|
+
source: se,
|
|
182
|
+
entryPoint: "mainVertex"
|
|
183
|
+
},
|
|
184
|
+
fragment: {
|
|
185
|
+
source: se,
|
|
186
|
+
entryPoint: "mainFragment"
|
|
187
|
+
}
|
|
188
|
+
}), o = $e.from({
|
|
189
|
+
vertex: ot,
|
|
190
|
+
fragment: it,
|
|
191
|
+
name: "mask-filter"
|
|
192
|
+
});
|
|
193
|
+
super({
|
|
194
|
+
...r,
|
|
195
|
+
gpuProgram: i,
|
|
196
|
+
glProgram: o,
|
|
197
|
+
clipToViewport: !1,
|
|
198
|
+
resources: {
|
|
199
|
+
filterUniforms: n,
|
|
200
|
+
uMaskTexture: t.texture.source
|
|
201
|
+
}
|
|
202
|
+
}), this.sprite = t, this._textureMatrix = s;
|
|
203
|
+
}
|
|
204
|
+
set inverse(e) {
|
|
205
|
+
this.resources.filterUniforms.uniforms.uInverse = e ? 1 : 0;
|
|
206
|
+
}
|
|
207
|
+
get inverse() {
|
|
208
|
+
return this.resources.filterUniforms.uniforms.uInverse === 1;
|
|
209
|
+
}
|
|
210
|
+
apply(e, t, r, s) {
|
|
211
|
+
this._textureMatrix.texture = this.sprite.texture, e.calculateSpriteMatrix(
|
|
212
|
+
this.resources.filterUniforms.uniforms.uFilterMatrix,
|
|
213
|
+
this.sprite
|
|
214
|
+
).prepend(this._textureMatrix.mapCoord), this.resources.uMaskTexture = this.sprite.texture.source, e.applyFilter(this, t, r, s);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const j = class ge {
|
|
218
|
+
constructor(e, t) {
|
|
219
|
+
var r, s;
|
|
220
|
+
this.state = qe.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);
|
|
221
|
+
}
|
|
222
|
+
static getBatcher(e) {
|
|
223
|
+
return new this._availableBatchers[e]();
|
|
224
|
+
}
|
|
225
|
+
buildStart(e) {
|
|
226
|
+
let t = this._batchersByInstructionSet[e.uid];
|
|
227
|
+
t || (t = this._batchersByInstructionSet[e.uid] = /* @__PURE__ */ Object.create(null), t.default || (t.default = new le({
|
|
228
|
+
maxTextures: this.renderer.limits.maxBatchableTextures
|
|
229
|
+
}))), this._activeBatches = t, this._activeBatch = this._activeBatches.default;
|
|
230
|
+
for (const r in this._activeBatches)
|
|
231
|
+
this._activeBatches[r].begin();
|
|
232
|
+
}
|
|
233
|
+
addToBatch(e, t) {
|
|
234
|
+
if (this._activeBatch.name !== e.batcherName) {
|
|
235
|
+
this._activeBatch.break(t);
|
|
236
|
+
let r = this._activeBatches[e.batcherName];
|
|
237
|
+
r || (r = this._activeBatches[e.batcherName] = ge.getBatcher(e.batcherName), r.begin()), this._activeBatch = r;
|
|
238
|
+
}
|
|
239
|
+
this._activeBatch.add(e);
|
|
240
|
+
}
|
|
241
|
+
break(e) {
|
|
242
|
+
this._activeBatch.break(e);
|
|
243
|
+
}
|
|
244
|
+
buildEnd(e) {
|
|
245
|
+
this._activeBatch.break(e);
|
|
246
|
+
const t = this._activeBatches;
|
|
247
|
+
for (const r in t) {
|
|
248
|
+
const s = t[r], n = s.geometry;
|
|
249
|
+
n.indexBuffer.setDataWithSize(s.indexBuffer, s.indexSize, !0), n.buffers[0].setDataWithSize(s.attributeBuffer.float32View, s.attributeSize, !1);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
upload(e) {
|
|
253
|
+
const t = this._batchersByInstructionSet[e.uid];
|
|
254
|
+
for (const r in t) {
|
|
255
|
+
const s = t[r], n = s.geometry;
|
|
256
|
+
s.dirty && (s.dirty = !1, n.buffers[0].update(s.attributeSize * 4));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
execute(e) {
|
|
260
|
+
if (e.action === "startBatch") {
|
|
261
|
+
const t = e.batcher, r = t.geometry, s = t.shader;
|
|
262
|
+
this._adaptor.start(this, r, s);
|
|
263
|
+
}
|
|
264
|
+
this._adaptor.execute(this, e);
|
|
265
|
+
}
|
|
266
|
+
destroy() {
|
|
267
|
+
this.state = null, this.renderer = null, this._adaptor = null;
|
|
268
|
+
for (const e in this._activeBatches)
|
|
269
|
+
this._activeBatches[e].destroy();
|
|
270
|
+
this._activeBatches = null;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
j.extension = {
|
|
274
|
+
type: [
|
|
275
|
+
l.WebGLPipes,
|
|
276
|
+
l.WebGPUPipes,
|
|
277
|
+
l.CanvasPipes
|
|
278
|
+
],
|
|
279
|
+
name: "batch"
|
|
280
|
+
};
|
|
281
|
+
j._availableBatchers = /* @__PURE__ */ Object.create(null);
|
|
282
|
+
let _e = j;
|
|
283
|
+
W.handleByMap(l.Batcher, _e._availableBatchers);
|
|
284
|
+
W.add(le);
|
|
285
|
+
const dt = new z();
|
|
286
|
+
class ut extends de {
|
|
287
|
+
constructor() {
|
|
288
|
+
super(), this.filters = [new lt({
|
|
289
|
+
sprite: new Ye(f.EMPTY),
|
|
290
|
+
inverse: !1,
|
|
291
|
+
resolution: "inherit",
|
|
292
|
+
antialias: "inherit"
|
|
293
|
+
})];
|
|
294
|
+
}
|
|
295
|
+
get sprite() {
|
|
296
|
+
return this.filters[0].sprite;
|
|
297
|
+
}
|
|
298
|
+
set sprite(e) {
|
|
299
|
+
this.filters[0].sprite = e;
|
|
300
|
+
}
|
|
301
|
+
get inverse() {
|
|
302
|
+
return this.filters[0].inverse;
|
|
303
|
+
}
|
|
304
|
+
set inverse(e) {
|
|
305
|
+
this.filters[0].inverse = e;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
class xe {
|
|
309
|
+
constructor(e) {
|
|
310
|
+
this._activeMaskStage = [], this._renderer = e;
|
|
311
|
+
}
|
|
312
|
+
push(e, t, r) {
|
|
313
|
+
const s = this._renderer;
|
|
314
|
+
if (s.renderPipes.batch.break(r), r.add({
|
|
315
|
+
renderPipeId: "alphaMask",
|
|
316
|
+
action: "pushMaskBegin",
|
|
317
|
+
mask: e,
|
|
318
|
+
inverse: t._maskOptions.inverse,
|
|
319
|
+
canBundle: !1,
|
|
320
|
+
maskedContainer: t
|
|
321
|
+
}), e.inverse = t._maskOptions.inverse, e.renderMaskToTexture) {
|
|
322
|
+
const n = e.mask;
|
|
323
|
+
n.includeInBuild = !0, n.collectRenderables(
|
|
324
|
+
r,
|
|
325
|
+
s,
|
|
326
|
+
null
|
|
327
|
+
), n.includeInBuild = !1;
|
|
328
|
+
}
|
|
329
|
+
s.renderPipes.batch.break(r), r.add({
|
|
330
|
+
renderPipeId: "alphaMask",
|
|
331
|
+
action: "pushMaskEnd",
|
|
332
|
+
mask: e,
|
|
333
|
+
maskedContainer: t,
|
|
334
|
+
inverse: t._maskOptions.inverse,
|
|
335
|
+
canBundle: !1
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
pop(e, t, r) {
|
|
339
|
+
this._renderer.renderPipes.batch.break(r), r.add({
|
|
340
|
+
renderPipeId: "alphaMask",
|
|
341
|
+
action: "popMaskEnd",
|
|
342
|
+
mask: e,
|
|
343
|
+
inverse: t._maskOptions.inverse,
|
|
344
|
+
canBundle: !1
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
execute(e) {
|
|
348
|
+
const t = this._renderer, r = e.mask.renderMaskToTexture;
|
|
349
|
+
if (e.action === "pushMaskBegin") {
|
|
350
|
+
const s = w.get(ut);
|
|
351
|
+
if (s.inverse = e.inverse, r) {
|
|
352
|
+
e.mask.mask.measurable = !0;
|
|
353
|
+
const n = Ke(e.mask.mask, !0, dt);
|
|
354
|
+
e.mask.mask.measurable = !1, n.ceil();
|
|
355
|
+
const i = t.renderTarget.renderTarget.colorTexture.source, o = T.getOptimalTexture(
|
|
356
|
+
n.width,
|
|
357
|
+
n.height,
|
|
358
|
+
i._resolution,
|
|
359
|
+
i.antialias
|
|
360
|
+
);
|
|
361
|
+
t.renderTarget.push(o, !0), t.globalUniforms.push({
|
|
362
|
+
offset: n,
|
|
363
|
+
worldColor: 4294967295
|
|
364
|
+
});
|
|
365
|
+
const d = s.sprite;
|
|
366
|
+
d.texture = o, d.worldTransform.tx = n.minX, d.worldTransform.ty = n.minY, this._activeMaskStage.push({
|
|
367
|
+
filterEffect: s,
|
|
368
|
+
maskedContainer: e.maskedContainer,
|
|
369
|
+
filterTexture: o
|
|
370
|
+
});
|
|
371
|
+
} else
|
|
372
|
+
s.sprite = e.mask.mask, this._activeMaskStage.push({
|
|
373
|
+
filterEffect: s,
|
|
374
|
+
maskedContainer: e.maskedContainer
|
|
375
|
+
});
|
|
376
|
+
} else if (e.action === "pushMaskEnd") {
|
|
377
|
+
const s = this._activeMaskStage[this._activeMaskStage.length - 1];
|
|
378
|
+
r && (t.type === V.WEBGL && t.renderTarget.finishRenderPass(), t.renderTarget.pop(), t.globalUniforms.pop()), t.filter.push({
|
|
379
|
+
renderPipeId: "filter",
|
|
380
|
+
action: "pushFilter",
|
|
381
|
+
container: s.maskedContainer,
|
|
382
|
+
filterEffect: s.filterEffect,
|
|
383
|
+
canBundle: !1
|
|
384
|
+
});
|
|
385
|
+
} else if (e.action === "popMaskEnd") {
|
|
386
|
+
t.filter.pop();
|
|
387
|
+
const s = this._activeMaskStage.pop();
|
|
388
|
+
r && T.returnTexture(s.filterTexture), w.return(s.filterEffect);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
destroy() {
|
|
392
|
+
this._renderer = null, this._activeMaskStage = null;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
xe.extension = {
|
|
396
|
+
type: [
|
|
397
|
+
l.WebGLPipes,
|
|
398
|
+
l.WebGPUPipes,
|
|
399
|
+
l.CanvasPipes
|
|
400
|
+
],
|
|
401
|
+
name: "alphaMask"
|
|
402
|
+
};
|
|
403
|
+
class be {
|
|
404
|
+
constructor(e) {
|
|
405
|
+
this._colorStack = [], this._colorStackIndex = 0, this._currentColor = 0, this._renderer = e;
|
|
406
|
+
}
|
|
407
|
+
buildStart() {
|
|
408
|
+
this._colorStack[0] = 15, this._colorStackIndex = 1, this._currentColor = 15;
|
|
409
|
+
}
|
|
410
|
+
push(e, t, r) {
|
|
411
|
+
this._renderer.renderPipes.batch.break(r);
|
|
412
|
+
const n = this._colorStack;
|
|
413
|
+
n[this._colorStackIndex] = n[this._colorStackIndex - 1] & e.mask;
|
|
414
|
+
const i = this._colorStack[this._colorStackIndex];
|
|
415
|
+
i !== this._currentColor && (this._currentColor = i, r.add({
|
|
416
|
+
renderPipeId: "colorMask",
|
|
417
|
+
colorMask: i,
|
|
418
|
+
canBundle: !1
|
|
419
|
+
})), this._colorStackIndex++;
|
|
420
|
+
}
|
|
421
|
+
pop(e, t, r) {
|
|
422
|
+
this._renderer.renderPipes.batch.break(r);
|
|
423
|
+
const n = this._colorStack;
|
|
424
|
+
this._colorStackIndex--;
|
|
425
|
+
const i = n[this._colorStackIndex - 1];
|
|
426
|
+
i !== this._currentColor && (this._currentColor = i, r.add({
|
|
427
|
+
renderPipeId: "colorMask",
|
|
428
|
+
colorMask: i,
|
|
429
|
+
canBundle: !1
|
|
430
|
+
}));
|
|
431
|
+
}
|
|
432
|
+
execute(e) {
|
|
433
|
+
this._renderer.colorMask.setMask(e.colorMask);
|
|
434
|
+
}
|
|
435
|
+
destroy() {
|
|
436
|
+
this._renderer = null, this._colorStack = null;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
be.extension = {
|
|
440
|
+
type: [
|
|
441
|
+
l.WebGLPipes,
|
|
442
|
+
l.WebGPUPipes
|
|
443
|
+
],
|
|
444
|
+
name: "colorMask"
|
|
445
|
+
};
|
|
446
|
+
class Te {
|
|
447
|
+
constructor(e) {
|
|
448
|
+
this._maskStackHash = {}, this._maskHash = /* @__PURE__ */ new WeakMap(), this._renderer = e;
|
|
449
|
+
}
|
|
450
|
+
push(e, t, r) {
|
|
451
|
+
var s;
|
|
452
|
+
const n = e, i = this._renderer;
|
|
453
|
+
i.renderPipes.batch.break(r), i.renderPipes.blendMode.setBlendMode(n.mask, "none", r), r.add({
|
|
454
|
+
renderPipeId: "stencilMask",
|
|
455
|
+
action: "pushMaskBegin",
|
|
456
|
+
mask: e,
|
|
457
|
+
inverse: t._maskOptions.inverse,
|
|
458
|
+
canBundle: !1
|
|
459
|
+
});
|
|
460
|
+
const o = n.mask;
|
|
461
|
+
o.includeInBuild = !0, this._maskHash.has(n) || this._maskHash.set(n, {
|
|
462
|
+
instructionsStart: 0,
|
|
463
|
+
instructionsLength: 0
|
|
464
|
+
});
|
|
465
|
+
const d = this._maskHash.get(n);
|
|
466
|
+
d.instructionsStart = r.instructionSize, o.collectRenderables(
|
|
467
|
+
r,
|
|
468
|
+
i,
|
|
469
|
+
null
|
|
470
|
+
), o.includeInBuild = !1, i.renderPipes.batch.break(r), r.add({
|
|
471
|
+
renderPipeId: "stencilMask",
|
|
472
|
+
action: "pushMaskEnd",
|
|
473
|
+
mask: e,
|
|
474
|
+
inverse: t._maskOptions.inverse,
|
|
475
|
+
canBundle: !1
|
|
476
|
+
});
|
|
477
|
+
const c = r.instructionSize - d.instructionsStart - 1;
|
|
478
|
+
d.instructionsLength = c;
|
|
479
|
+
const h = i.renderTarget.renderTarget.uid;
|
|
480
|
+
(s = this._maskStackHash)[h] ?? (s[h] = 0);
|
|
481
|
+
}
|
|
482
|
+
pop(e, t, r) {
|
|
483
|
+
const s = e, n = this._renderer;
|
|
484
|
+
n.renderPipes.batch.break(r), n.renderPipes.blendMode.setBlendMode(s.mask, "none", r), r.add({
|
|
485
|
+
renderPipeId: "stencilMask",
|
|
486
|
+
action: "popMaskBegin",
|
|
487
|
+
inverse: t._maskOptions.inverse,
|
|
488
|
+
canBundle: !1
|
|
489
|
+
});
|
|
490
|
+
const i = this._maskHash.get(e);
|
|
491
|
+
for (let o = 0; o < i.instructionsLength; o++)
|
|
492
|
+
r.instructions[r.instructionSize++] = r.instructions[i.instructionsStart++];
|
|
493
|
+
r.add({
|
|
494
|
+
renderPipeId: "stencilMask",
|
|
495
|
+
action: "popMaskEnd",
|
|
496
|
+
canBundle: !1
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
execute(e) {
|
|
500
|
+
var t;
|
|
501
|
+
const r = this._renderer, s = r, n = r.renderTarget.renderTarget.uid;
|
|
502
|
+
let i = (t = this._maskStackHash)[n] ?? (t[n] = 0);
|
|
503
|
+
e.action === "pushMaskBegin" ? (s.renderTarget.ensureDepthStencil(), s.stencil.setStencilMode(g.RENDERING_MASK_ADD, i), i++, s.colorMask.setMask(0)) : e.action === "pushMaskEnd" ? (e.inverse ? s.stencil.setStencilMode(g.INVERSE_MASK_ACTIVE, i) : s.stencil.setStencilMode(g.MASK_ACTIVE, i), s.colorMask.setMask(15)) : e.action === "popMaskBegin" ? (s.colorMask.setMask(0), i !== 0 ? s.stencil.setStencilMode(g.RENDERING_MASK_REMOVE, i) : (s.renderTarget.clear(null, D.STENCIL), s.stencil.setStencilMode(g.DISABLED, i)), i--) : e.action === "popMaskEnd" && (e.inverse ? s.stencil.setStencilMode(g.INVERSE_MASK_ACTIVE, i) : s.stencil.setStencilMode(g.MASK_ACTIVE, i), s.colorMask.setMask(15)), this._maskStackHash[n] = i;
|
|
504
|
+
}
|
|
505
|
+
destroy() {
|
|
506
|
+
this._renderer = null, this._maskStackHash = null, this._maskHash = null;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
Te.extension = {
|
|
510
|
+
type: [
|
|
511
|
+
l.WebGLPipes,
|
|
512
|
+
l.WebGPUPipes
|
|
513
|
+
],
|
|
514
|
+
name: "stencilMask"
|
|
515
|
+
};
|
|
516
|
+
class ve {
|
|
517
|
+
constructor(e) {
|
|
518
|
+
this._renderer = e;
|
|
519
|
+
}
|
|
520
|
+
updateRenderable() {
|
|
521
|
+
}
|
|
522
|
+
destroyRenderable() {
|
|
523
|
+
}
|
|
524
|
+
validateRenderable() {
|
|
525
|
+
return !1;
|
|
526
|
+
}
|
|
527
|
+
addRenderable(e, t) {
|
|
528
|
+
this._renderer.renderPipes.batch.break(t), t.add(e);
|
|
529
|
+
}
|
|
530
|
+
execute(e) {
|
|
531
|
+
e.isRenderable && e.render(this._renderer);
|
|
532
|
+
}
|
|
533
|
+
destroy() {
|
|
534
|
+
this._renderer = null;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
ve.extension = {
|
|
538
|
+
type: [
|
|
539
|
+
l.WebGLPipes,
|
|
540
|
+
l.WebGPUPipes,
|
|
541
|
+
l.CanvasPipes
|
|
542
|
+
],
|
|
543
|
+
name: "customRender"
|
|
544
|
+
};
|
|
545
|
+
function L(a, e) {
|
|
546
|
+
const t = a.instructionSet, r = t.instructions;
|
|
547
|
+
for (let s = 0; s < t.instructionSize; s++) {
|
|
548
|
+
const n = r[s];
|
|
549
|
+
e[n.renderPipeId].execute(n);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
class ye {
|
|
553
|
+
constructor(e) {
|
|
554
|
+
this._renderer = e;
|
|
555
|
+
}
|
|
556
|
+
addRenderGroup(e, t) {
|
|
557
|
+
e.isCachedAsTexture ? this._addRenderableCacheAsTexture(e, t) : this._addRenderableDirect(e, t);
|
|
558
|
+
}
|
|
559
|
+
execute(e) {
|
|
560
|
+
e.isRenderable && (e.isCachedAsTexture ? this._executeCacheAsTexture(e) : this._executeDirect(e));
|
|
561
|
+
}
|
|
562
|
+
destroy() {
|
|
563
|
+
this._renderer = null;
|
|
564
|
+
}
|
|
565
|
+
_addRenderableDirect(e, t) {
|
|
566
|
+
this._renderer.renderPipes.batch.break(t), e._batchableRenderGroup && (w.return(e._batchableRenderGroup), e._batchableRenderGroup = null), t.add(e);
|
|
567
|
+
}
|
|
568
|
+
_addRenderableCacheAsTexture(e, t) {
|
|
569
|
+
const r = e._batchableRenderGroup ?? (e._batchableRenderGroup = w.get(ue));
|
|
570
|
+
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);
|
|
571
|
+
}
|
|
572
|
+
_executeCacheAsTexture(e) {
|
|
573
|
+
if (e.textureNeedsUpdate) {
|
|
574
|
+
e.textureNeedsUpdate = !1;
|
|
575
|
+
const t = new m().translate(
|
|
576
|
+
-e._textureBounds.x,
|
|
577
|
+
-e._textureBounds.y
|
|
578
|
+
);
|
|
579
|
+
this._renderer.renderTarget.push(e.texture, !0, null, e.texture.frame), this._renderer.globalUniforms.push({
|
|
580
|
+
worldTransformMatrix: t,
|
|
581
|
+
worldColor: 4294967295,
|
|
582
|
+
offset: { x: 0, y: 0 }
|
|
583
|
+
}), L(e, this._renderer.renderPipes), this._renderer.renderTarget.finishRenderPass(), this._renderer.renderTarget.pop(), this._renderer.globalUniforms.pop();
|
|
584
|
+
}
|
|
585
|
+
e._batchableRenderGroup._batcher.updateElement(e._batchableRenderGroup), e._batchableRenderGroup._batcher.geometry.buffers[0].update();
|
|
586
|
+
}
|
|
587
|
+
_executeDirect(e) {
|
|
588
|
+
this._renderer.globalUniforms.push({
|
|
589
|
+
worldTransformMatrix: e.inverseParentTextureTransform,
|
|
590
|
+
worldColor: e.worldColorAlpha
|
|
591
|
+
}), L(e, this._renderer.renderPipes), this._renderer.globalUniforms.pop();
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
ye.extension = {
|
|
595
|
+
type: [
|
|
596
|
+
l.WebGLPipes,
|
|
597
|
+
l.WebGPUPipes,
|
|
598
|
+
l.CanvasPipes
|
|
599
|
+
],
|
|
600
|
+
name: "renderGroup"
|
|
601
|
+
};
|
|
602
|
+
class Ce {
|
|
603
|
+
constructor(e) {
|
|
604
|
+
this._renderer = e;
|
|
605
|
+
}
|
|
606
|
+
addRenderable(e, t) {
|
|
607
|
+
const r = this._getGpuSprite(e);
|
|
608
|
+
e.didViewUpdate && this._updateBatchableSprite(e, r), this._renderer.renderPipes.batch.addToBatch(r, t);
|
|
609
|
+
}
|
|
610
|
+
updateRenderable(e) {
|
|
611
|
+
const t = this._getGpuSprite(e);
|
|
612
|
+
e.didViewUpdate && this._updateBatchableSprite(e, t), t._batcher.updateElement(t);
|
|
613
|
+
}
|
|
614
|
+
validateRenderable(e) {
|
|
615
|
+
const t = this._getGpuSprite(e);
|
|
616
|
+
return !t._batcher.checkAndUpdateTexture(
|
|
617
|
+
t,
|
|
618
|
+
e._texture
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
_updateBatchableSprite(e, t) {
|
|
622
|
+
t.bounds = e.visualBounds, t.texture = e._texture;
|
|
623
|
+
}
|
|
624
|
+
_getGpuSprite(e) {
|
|
625
|
+
return e._gpuData[this._renderer.uid] || this._initGPUSprite(e);
|
|
626
|
+
}
|
|
627
|
+
_initGPUSprite(e) {
|
|
628
|
+
const t = new ue();
|
|
629
|
+
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;
|
|
630
|
+
}
|
|
631
|
+
destroy() {
|
|
632
|
+
this._renderer = null;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
Ce.extension = {
|
|
636
|
+
type: [
|
|
637
|
+
l.WebGLPipes,
|
|
638
|
+
l.WebGPUPipes,
|
|
639
|
+
l.CanvasPipes
|
|
640
|
+
],
|
|
641
|
+
name: "sprite"
|
|
642
|
+
};
|
|
643
|
+
const y = {};
|
|
644
|
+
W.handle(l.BlendMode, (a) => {
|
|
645
|
+
if (!a.name)
|
|
646
|
+
throw new Error("BlendMode extension must have a name property");
|
|
647
|
+
y[a.name] = a.ref;
|
|
648
|
+
}, (a) => {
|
|
649
|
+
delete y[a.name];
|
|
650
|
+
});
|
|
651
|
+
class ke {
|
|
652
|
+
constructor(e) {
|
|
653
|
+
this._blendModeStack = [], this._isAdvanced = !1, this._filterHash = /* @__PURE__ */ Object.create(null), this._renderer = e, this._renderer.runners.prerender.add(this);
|
|
654
|
+
}
|
|
655
|
+
prerender() {
|
|
656
|
+
this._activeBlendMode = "normal", this._isAdvanced = !1;
|
|
657
|
+
}
|
|
658
|
+
/**
|
|
659
|
+
* Push a blend mode onto the internal stack and apply it to the instruction set if needed.
|
|
660
|
+
* @param renderable - The renderable or {@link RenderGroup} associated with the change.
|
|
661
|
+
* @param blendMode - The blend mode to activate.
|
|
662
|
+
* @param instructionSet - The instruction set being built.
|
|
663
|
+
*/
|
|
664
|
+
pushBlendMode(e, t, r) {
|
|
665
|
+
this._blendModeStack.push(t), this.setBlendMode(e, t, r);
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Pop the last blend mode from the stack and apply the new top-of-stack mode.
|
|
669
|
+
* @param instructionSet - The instruction set being built.
|
|
670
|
+
*/
|
|
671
|
+
popBlendMode(e) {
|
|
672
|
+
this._blendModeStack.pop();
|
|
673
|
+
const t = this._blendModeStack[this._activeBlendMode.length - 1] ?? "normal";
|
|
674
|
+
this.setBlendMode(null, t, e);
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Ensure a blend mode switch is added to the instruction set when the mode changes.
|
|
678
|
+
* If an advanced blend mode is active, subsequent renderables will be collected so they can be
|
|
679
|
+
* rendered within a single filter pass.
|
|
680
|
+
* @param renderable - The renderable or {@link RenderGroup} to associate with the change, or null when unwinding.
|
|
681
|
+
* @param blendMode - The target blend mode.
|
|
682
|
+
* @param instructionSet - The instruction set being built.
|
|
683
|
+
*/
|
|
684
|
+
setBlendMode(e, t, r) {
|
|
685
|
+
var n;
|
|
686
|
+
const s = e instanceof ee;
|
|
687
|
+
if (this._activeBlendMode === t) {
|
|
688
|
+
this._isAdvanced && e && !s && ((n = this._renderableList) == null || n.push(e));
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
this._isAdvanced && this._endAdvancedBlendMode(r), this._activeBlendMode = t, e && (this._isAdvanced = !!y[t], this._isAdvanced && this._beginAdvancedBlendMode(e, r));
|
|
692
|
+
}
|
|
693
|
+
_beginAdvancedBlendMode(e, t) {
|
|
694
|
+
this._renderer.renderPipes.batch.break(t);
|
|
695
|
+
const r = this._activeBlendMode;
|
|
696
|
+
if (!y[r]) {
|
|
697
|
+
ce(`Unable to assign BlendMode: '${r}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
const s = this._ensureFilterEffect(r), n = e instanceof ee, i = {
|
|
701
|
+
renderPipeId: "filter",
|
|
702
|
+
action: "pushFilter",
|
|
703
|
+
filterEffect: s,
|
|
704
|
+
renderables: n ? null : [e],
|
|
705
|
+
container: n ? e.root : null,
|
|
706
|
+
canBundle: !1
|
|
707
|
+
};
|
|
708
|
+
this._renderableList = i.renderables, t.add(i);
|
|
709
|
+
}
|
|
710
|
+
_ensureFilterEffect(e) {
|
|
711
|
+
let t = this._filterHash[e];
|
|
712
|
+
return t || (t = this._filterHash[e] = new de(), t.filters = [new y[e]()]), t;
|
|
713
|
+
}
|
|
714
|
+
_endAdvancedBlendMode(e) {
|
|
715
|
+
this._isAdvanced = !1, this._renderableList = null, this._renderer.renderPipes.batch.break(e), e.add({
|
|
716
|
+
renderPipeId: "filter",
|
|
717
|
+
action: "popFilter",
|
|
718
|
+
canBundle: !1
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* called when the instruction build process is starting this will reset internally to the default blend mode
|
|
723
|
+
* @internal
|
|
724
|
+
*/
|
|
725
|
+
buildStart() {
|
|
726
|
+
this._isAdvanced = !1;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* called when the instruction build process is finished, ensuring that if there is an advanced blend mode
|
|
730
|
+
* active, we add the final render instructions added to the instruction set
|
|
731
|
+
* @param instructionSet - The instruction set we are adding to
|
|
732
|
+
* @internal
|
|
733
|
+
*/
|
|
734
|
+
buildEnd(e) {
|
|
735
|
+
this._isAdvanced && this._endAdvancedBlendMode(e);
|
|
736
|
+
}
|
|
737
|
+
/** @internal */
|
|
738
|
+
destroy() {
|
|
739
|
+
this._renderer = null, this._renderableList = null;
|
|
740
|
+
for (const e in this._filterHash)
|
|
741
|
+
this._filterHash[e].destroy();
|
|
742
|
+
this._filterHash = null;
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
ke.extension = {
|
|
746
|
+
type: [
|
|
747
|
+
l.WebGLPipes,
|
|
748
|
+
l.WebGPUPipes,
|
|
749
|
+
l.CanvasPipes
|
|
750
|
+
],
|
|
751
|
+
name: "blendMode"
|
|
752
|
+
};
|
|
753
|
+
function H(a, e) {
|
|
754
|
+
e || (e = 0);
|
|
755
|
+
for (let t = e; t < a.length && a[t]; t++)
|
|
756
|
+
a[t] = null;
|
|
757
|
+
}
|
|
758
|
+
const ct = new P(), ne = pe | fe | me;
|
|
759
|
+
function Me(a, e = !1) {
|
|
760
|
+
ht(a);
|
|
761
|
+
const t = a.childrenToUpdate, r = a.updateTick++;
|
|
762
|
+
for (const s in t) {
|
|
763
|
+
const n = Number(s), i = t[s], o = i.list, d = i.index;
|
|
764
|
+
for (let c = 0; c < d; c++) {
|
|
765
|
+
const h = o[c];
|
|
766
|
+
h.parentRenderGroup === a && h.relativeRenderGroupDepth === n && Re(h, r, 0);
|
|
767
|
+
}
|
|
768
|
+
H(o, d), i.index = 0;
|
|
769
|
+
}
|
|
770
|
+
if (e)
|
|
771
|
+
for (let s = 0; s < a.renderGroupChildren.length; s++)
|
|
772
|
+
Me(a.renderGroupChildren[s], e);
|
|
773
|
+
}
|
|
774
|
+
function ht(a) {
|
|
775
|
+
const e = a.root;
|
|
776
|
+
let t;
|
|
777
|
+
if (a.renderGroupParent) {
|
|
778
|
+
const r = a.renderGroupParent;
|
|
779
|
+
a.worldTransform.appendFrom(
|
|
780
|
+
e.relativeGroupTransform,
|
|
781
|
+
r.worldTransform
|
|
782
|
+
), a.worldColor = he(
|
|
783
|
+
e.groupColor,
|
|
784
|
+
r.worldColor
|
|
785
|
+
), t = e.groupAlpha * r.worldAlpha;
|
|
786
|
+
} else
|
|
787
|
+
a.worldTransform.copyFrom(e.localTransform), a.worldColor = e.localColor, t = e.localAlpha;
|
|
788
|
+
t = t < 0 ? 0 : t > 1 ? 1 : t, a.worldAlpha = t, a.worldColorAlpha = a.worldColor + ((t * 255 | 0) << 24);
|
|
789
|
+
}
|
|
790
|
+
function Re(a, e, t) {
|
|
791
|
+
if (e === a.updateTick) return;
|
|
792
|
+
a.updateTick = e, a.didChange = !1;
|
|
793
|
+
const r = a.localTransform;
|
|
794
|
+
a.updateLocalTransform();
|
|
795
|
+
const s = a.parent;
|
|
796
|
+
if (s && !s.renderGroup ? (t |= a._updateFlags, a.relativeGroupTransform.appendFrom(
|
|
797
|
+
r,
|
|
798
|
+
s.relativeGroupTransform
|
|
799
|
+
), t & ne && ae(a, s, t)) : (t = a._updateFlags, a.relativeGroupTransform.copyFrom(r), t & ne && ae(a, ct, t)), !a.renderGroup) {
|
|
800
|
+
const n = a.children, i = n.length;
|
|
801
|
+
for (let c = 0; c < i; c++)
|
|
802
|
+
Re(n[c], e, t);
|
|
803
|
+
const o = a.parentRenderGroup, d = a;
|
|
804
|
+
d.renderPipeId && !o.structureDidChange && o.updateRenderable(d);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
function ae(a, e, t) {
|
|
808
|
+
if (t & fe) {
|
|
809
|
+
a.groupColor = he(
|
|
810
|
+
a.localColor,
|
|
811
|
+
e.groupColor
|
|
812
|
+
);
|
|
813
|
+
let r = a.localAlpha * e.groupAlpha;
|
|
814
|
+
r = r < 0 ? 0 : r > 1 ? 1 : r, a.groupAlpha = r, a.groupColorAlpha = a.groupColor + ((r * 255 | 0) << 24);
|
|
815
|
+
}
|
|
816
|
+
t & me && (a.groupBlendMode = a.localBlendMode === "inherit" ? e.groupBlendMode : a.localBlendMode), t & pe && (a.globalDisplayStatus = a.localDisplayStatus & e.globalDisplayStatus), a._updateFlags = 0;
|
|
817
|
+
}
|
|
818
|
+
function pt(a, e) {
|
|
819
|
+
const { list: t } = a.childrenRenderablesToUpdate;
|
|
820
|
+
let r = !1;
|
|
821
|
+
for (let s = 0; s < a.childrenRenderablesToUpdate.index; s++) {
|
|
822
|
+
const n = t[s];
|
|
823
|
+
if (r = e[n.renderPipeId].validateRenderable(n), r)
|
|
824
|
+
break;
|
|
825
|
+
}
|
|
826
|
+
return a.structureDidChange = r, r;
|
|
827
|
+
}
|
|
828
|
+
const ft = new m();
|
|
829
|
+
class Se {
|
|
830
|
+
constructor(e) {
|
|
831
|
+
this._renderer = e;
|
|
832
|
+
}
|
|
833
|
+
render({ container: e, transform: t }) {
|
|
834
|
+
const r = e.parent, s = e.renderGroup.renderGroupParent;
|
|
835
|
+
e.parent = null, e.renderGroup.renderGroupParent = null;
|
|
836
|
+
const n = this._renderer, i = ft;
|
|
837
|
+
t && (i.copyFrom(e.renderGroup.localTransform), e.renderGroup.localTransform.copyFrom(t));
|
|
838
|
+
const o = n.renderPipes;
|
|
839
|
+
this._updateCachedRenderGroups(e.renderGroup, null), this._updateRenderGroups(e.renderGroup), n.globalUniforms.start({
|
|
840
|
+
worldTransformMatrix: t ? e.renderGroup.localTransform : e.renderGroup.worldTransform,
|
|
841
|
+
worldColor: e.renderGroup.worldColorAlpha
|
|
842
|
+
}), L(e.renderGroup, o), o.uniformBatch && o.uniformBatch.renderEnd(), t && e.renderGroup.localTransform.copyFrom(i), e.parent = r, e.renderGroup.renderGroupParent = s;
|
|
843
|
+
}
|
|
844
|
+
destroy() {
|
|
845
|
+
this._renderer = null;
|
|
846
|
+
}
|
|
847
|
+
_updateCachedRenderGroups(e, t) {
|
|
848
|
+
if (e._parentCacheAsTextureRenderGroup = t, e.isCachedAsTexture) {
|
|
849
|
+
if (!e.textureNeedsUpdate) return;
|
|
850
|
+
t = e;
|
|
851
|
+
}
|
|
852
|
+
for (let r = e.renderGroupChildren.length - 1; r >= 0; r--)
|
|
853
|
+
this._updateCachedRenderGroups(e.renderGroupChildren[r], t);
|
|
854
|
+
if (e.invalidateMatrices(), e.isCachedAsTexture) {
|
|
855
|
+
if (e.textureNeedsUpdate) {
|
|
856
|
+
const r = e.root.getLocalBounds(), s = this._renderer, n = e.textureOptions.resolution || s.view.resolution, i = e.textureOptions.antialias ?? s.view.antialias, o = e.textureOptions.scaleMode ?? "linear", d = e.texture;
|
|
857
|
+
r.ceil(), e.texture && T.returnTexture(e.texture, !0);
|
|
858
|
+
const c = T.getOptimalTexture(
|
|
859
|
+
r.width,
|
|
860
|
+
r.height,
|
|
861
|
+
n,
|
|
862
|
+
i
|
|
863
|
+
);
|
|
864
|
+
c._source.style = new Xe({ scaleMode: o }), e.texture = c, e._textureBounds || (e._textureBounds = new z()), e._textureBounds.copyFrom(r), d !== e.texture && e.renderGroupParent && (e.renderGroupParent.structureDidChange = !0);
|
|
865
|
+
}
|
|
866
|
+
} else e.texture && (T.returnTexture(e.texture, !0), e.texture = null);
|
|
867
|
+
}
|
|
868
|
+
_updateRenderGroups(e) {
|
|
869
|
+
const t = this._renderer, r = t.renderPipes;
|
|
870
|
+
if (e.runOnRender(t), e.instructionSet.renderPipes = r, e.structureDidChange ? H(e.childrenRenderablesToUpdate.list, 0) : pt(e, r), Me(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))
|
|
871
|
+
for (let s = 0; s < e.renderGroupChildren.length; s++)
|
|
872
|
+
this._updateRenderGroups(e.renderGroupChildren[s]);
|
|
873
|
+
}
|
|
874
|
+
_updateRenderables(e) {
|
|
875
|
+
const { list: t, index: r } = e.childrenRenderablesToUpdate;
|
|
876
|
+
for (let s = 0; s < r; s++) {
|
|
877
|
+
const n = t[s];
|
|
878
|
+
n.didViewUpdate && e.updateRenderable(n);
|
|
879
|
+
}
|
|
880
|
+
H(t, r);
|
|
881
|
+
}
|
|
882
|
+
_buildInstructions(e, t) {
|
|
883
|
+
const r = e.root, s = e.instructionSet;
|
|
884
|
+
s.reset();
|
|
885
|
+
const n = t.renderPipes ? t : t.batch.renderer, i = n.renderPipes;
|
|
886
|
+
i.batch.buildStart(s), i.blendMode.buildStart(), i.colorMask.buildStart(), r.sortableChildren && r.sortChildren(), r.collectRenderablesWithEffects(s, n, null), i.batch.buildEnd(s), i.blendMode.buildEnd(s);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
Se.extension = {
|
|
890
|
+
type: [
|
|
891
|
+
l.WebGLSystem,
|
|
892
|
+
l.WebGPUSystem,
|
|
893
|
+
l.CanvasSystem
|
|
894
|
+
],
|
|
895
|
+
name: "renderGroup"
|
|
896
|
+
};
|
|
897
|
+
const $ = class we {
|
|
898
|
+
constructor() {
|
|
899
|
+
this.clearBeforeRender = !0, this._backgroundColor = new E(0), this.color = this._backgroundColor, this.alpha = 1;
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* initiates the background system
|
|
903
|
+
* @param options - the options for the background colors
|
|
904
|
+
*/
|
|
905
|
+
init(e) {
|
|
906
|
+
e = { ...we.defaultOptions, ...e }, this.clearBeforeRender = e.clearBeforeRender, this.color = e.background || e.backgroundColor || this._backgroundColor, this.alpha = e.backgroundAlpha, this._backgroundColor.setAlpha(e.backgroundAlpha);
|
|
907
|
+
}
|
|
908
|
+
/** The background color to fill if not transparent */
|
|
909
|
+
get color() {
|
|
910
|
+
return this._backgroundColor;
|
|
911
|
+
}
|
|
912
|
+
set color(e) {
|
|
913
|
+
E.shared.setValue(e).alpha < 1 && this._backgroundColor.alpha === 1 && ce(
|
|
914
|
+
"Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."
|
|
915
|
+
), this._backgroundColor.setValue(e);
|
|
916
|
+
}
|
|
917
|
+
/** The background color alpha. Setting this to 0 will make the canvas transparent. */
|
|
918
|
+
get alpha() {
|
|
919
|
+
return this._backgroundColor.alpha;
|
|
920
|
+
}
|
|
921
|
+
set alpha(e) {
|
|
922
|
+
this._backgroundColor.setAlpha(e);
|
|
923
|
+
}
|
|
924
|
+
/** The background color as an [R, G, B, A] array. */
|
|
925
|
+
get colorRgba() {
|
|
926
|
+
return this._backgroundColor.toArray();
|
|
927
|
+
}
|
|
928
|
+
/**
|
|
929
|
+
* destroys the background system
|
|
930
|
+
* @internal
|
|
931
|
+
*/
|
|
932
|
+
destroy() {
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
$.extension = {
|
|
936
|
+
type: [
|
|
937
|
+
l.WebGLSystem,
|
|
938
|
+
l.WebGPUSystem,
|
|
939
|
+
l.CanvasSystem
|
|
940
|
+
],
|
|
941
|
+
name: "background",
|
|
942
|
+
priority: 0
|
|
943
|
+
};
|
|
944
|
+
$.defaultOptions = {
|
|
945
|
+
/**
|
|
946
|
+
* {@link WebGLOptions.backgroundAlpha}
|
|
947
|
+
* @default 1
|
|
948
|
+
*/
|
|
949
|
+
backgroundAlpha: 1,
|
|
950
|
+
/**
|
|
951
|
+
* {@link WebGLOptions.backgroundColor}
|
|
952
|
+
* @default 0x000000
|
|
953
|
+
*/
|
|
954
|
+
backgroundColor: 0,
|
|
955
|
+
/**
|
|
956
|
+
* {@link WebGLOptions.clearBeforeRender}
|
|
957
|
+
* @default true
|
|
958
|
+
*/
|
|
959
|
+
clearBeforeRender: !0
|
|
960
|
+
};
|
|
961
|
+
let mt = $;
|
|
962
|
+
const I = {
|
|
963
|
+
png: "image/png",
|
|
964
|
+
jpg: "image/jpeg",
|
|
965
|
+
webp: "image/webp"
|
|
966
|
+
}, q = class Pe {
|
|
967
|
+
/** @param renderer - The renderer this System works for. */
|
|
968
|
+
constructor(e) {
|
|
969
|
+
this._renderer = e;
|
|
970
|
+
}
|
|
971
|
+
_normalizeOptions(e, t = {}) {
|
|
972
|
+
return e instanceof P || e instanceof f ? {
|
|
973
|
+
target: e,
|
|
974
|
+
...t
|
|
975
|
+
} : {
|
|
976
|
+
...t,
|
|
977
|
+
...e
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
/**
|
|
981
|
+
* Creates an IImage from a display object or texture.
|
|
982
|
+
* @param options - Options for creating the image, or the target to extract
|
|
983
|
+
* @returns Promise that resolves with the generated IImage
|
|
984
|
+
* @example
|
|
985
|
+
* ```ts
|
|
986
|
+
* // Basic usage with a sprite
|
|
987
|
+
* const sprite = new Sprite(texture);
|
|
988
|
+
* const image = await renderer.extract.image(sprite);
|
|
989
|
+
* document.body.appendChild(image);
|
|
990
|
+
*
|
|
991
|
+
* // Advanced usage with options
|
|
992
|
+
* const image = await renderer.extract.image({
|
|
993
|
+
* target: container,
|
|
994
|
+
* format: 'webp',
|
|
995
|
+
* quality: 0.8,
|
|
996
|
+
* frame: new Rectangle(0, 0, 100, 100),
|
|
997
|
+
* resolution: 2,
|
|
998
|
+
* clearColor: '#ff0000',
|
|
999
|
+
* antialias: true
|
|
1000
|
+
* });
|
|
1001
|
+
*
|
|
1002
|
+
* // Extract directly from a texture
|
|
1003
|
+
* const texture = Texture.from('myTexture.png');
|
|
1004
|
+
* const image = await renderer.extract.image(texture);
|
|
1005
|
+
* ```
|
|
1006
|
+
* @see {@link ExtractImageOptions} For detailed options
|
|
1007
|
+
* @see {@link ExtractSystem.base64} For base64 string output
|
|
1008
|
+
* @see {@link ExtractSystem.canvas} For canvas output
|
|
1009
|
+
* @see {@link ImageLike} For the image interface
|
|
1010
|
+
* @category rendering
|
|
1011
|
+
*/
|
|
1012
|
+
async image(e) {
|
|
1013
|
+
const t = N.get().createImage();
|
|
1014
|
+
return t.src = await this.base64(e), t;
|
|
1015
|
+
}
|
|
1016
|
+
/**
|
|
1017
|
+
* Converts the target into a base64 encoded string.
|
|
1018
|
+
*
|
|
1019
|
+
* This method works by first creating
|
|
1020
|
+
* a canvas using `Extract.canvas` and then converting it to a base64 string.
|
|
1021
|
+
* @param options - The options for creating the base64 string, or the target to extract
|
|
1022
|
+
* @returns Promise that resolves with the base64 encoded string
|
|
1023
|
+
* @example
|
|
1024
|
+
* ```ts
|
|
1025
|
+
* // Basic usage with a sprite
|
|
1026
|
+
* const sprite = new Sprite(texture);
|
|
1027
|
+
* const base64 = await renderer.extract.base64(sprite);
|
|
1028
|
+
* console.log(base64); // data:image/png;base64,...
|
|
1029
|
+
*
|
|
1030
|
+
* // Advanced usage with options
|
|
1031
|
+
* const base64 = await renderer.extract.base64({
|
|
1032
|
+
* target: container,
|
|
1033
|
+
* format: 'webp',
|
|
1034
|
+
* quality: 0.8,
|
|
1035
|
+
* frame: new Rectangle(0, 0, 100, 100),
|
|
1036
|
+
* resolution: 2
|
|
1037
|
+
* });
|
|
1038
|
+
* ```
|
|
1039
|
+
* @throws Will throw an error if the platform doesn't support any of:
|
|
1040
|
+
* - ICanvas.toDataURL
|
|
1041
|
+
* - ICanvas.toBlob
|
|
1042
|
+
* - ICanvas.convertToBlob
|
|
1043
|
+
* @see {@link ExtractImageOptions} For detailed options
|
|
1044
|
+
* @see {@link ExtractSystem.canvas} For canvas output
|
|
1045
|
+
* @see {@link ExtractSystem.image} For HTMLImage output
|
|
1046
|
+
* @category rendering
|
|
1047
|
+
*/
|
|
1048
|
+
async base64(e) {
|
|
1049
|
+
e = this._normalizeOptions(
|
|
1050
|
+
e,
|
|
1051
|
+
Pe.defaultImageOptions
|
|
1052
|
+
);
|
|
1053
|
+
const { format: t, quality: r } = e, s = this.canvas(e);
|
|
1054
|
+
if (s.toBlob !== void 0)
|
|
1055
|
+
return new Promise((n, i) => {
|
|
1056
|
+
s.toBlob((o) => {
|
|
1057
|
+
if (!o) {
|
|
1058
|
+
i(new Error("ICanvas.toBlob failed!"));
|
|
1059
|
+
return;
|
|
1060
|
+
}
|
|
1061
|
+
const d = new FileReader();
|
|
1062
|
+
d.onload = () => n(d.result), d.onerror = i, d.readAsDataURL(o);
|
|
1063
|
+
}, I[t], r);
|
|
1064
|
+
});
|
|
1065
|
+
if (s.toDataURL !== void 0)
|
|
1066
|
+
return s.toDataURL(I[t], r);
|
|
1067
|
+
if (s.convertToBlob !== void 0) {
|
|
1068
|
+
const n = await s.convertToBlob({ type: I[t], quality: r });
|
|
1069
|
+
return new Promise((i, o) => {
|
|
1070
|
+
const d = new FileReader();
|
|
1071
|
+
d.onload = () => i(d.result), d.onerror = o, d.readAsDataURL(n);
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented");
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Creates a Canvas element, renders the target to it and returns it.
|
|
1078
|
+
* This method is useful for creating static images or when you need direct canvas access.
|
|
1079
|
+
* @param options - The options for creating the canvas, or the target to extract
|
|
1080
|
+
* @returns A Canvas element with the texture rendered on
|
|
1081
|
+
* @example
|
|
1082
|
+
* ```ts
|
|
1083
|
+
* // Basic canvas extraction from a sprite
|
|
1084
|
+
* const sprite = new Sprite(texture);
|
|
1085
|
+
* const canvas = renderer.extract.canvas(sprite);
|
|
1086
|
+
* document.body.appendChild(canvas);
|
|
1087
|
+
*
|
|
1088
|
+
* // Extract with custom region
|
|
1089
|
+
* const canvas = renderer.extract.canvas({
|
|
1090
|
+
* target: container,
|
|
1091
|
+
* frame: new Rectangle(0, 0, 100, 100)
|
|
1092
|
+
* });
|
|
1093
|
+
*
|
|
1094
|
+
* // Extract with high resolution
|
|
1095
|
+
* const canvas = renderer.extract.canvas({
|
|
1096
|
+
* target: sprite,
|
|
1097
|
+
* resolution: 2,
|
|
1098
|
+
* clearColor: '#ff0000'
|
|
1099
|
+
* });
|
|
1100
|
+
*
|
|
1101
|
+
* // Extract directly from a texture
|
|
1102
|
+
* const texture = Texture.from('myTexture.png');
|
|
1103
|
+
* const canvas = renderer.extract.canvas(texture);
|
|
1104
|
+
*
|
|
1105
|
+
* // Extract with anti-aliasing
|
|
1106
|
+
* const canvas = renderer.extract.canvas({
|
|
1107
|
+
* target: graphics,
|
|
1108
|
+
* antialias: true
|
|
1109
|
+
* });
|
|
1110
|
+
* ```
|
|
1111
|
+
* @see {@link ExtractOptions} For detailed options
|
|
1112
|
+
* @see {@link ExtractSystem.image} For HTMLImage output
|
|
1113
|
+
* @see {@link ExtractSystem.pixels} For raw pixel data
|
|
1114
|
+
* @category rendering
|
|
1115
|
+
*/
|
|
1116
|
+
canvas(e) {
|
|
1117
|
+
e = this._normalizeOptions(e);
|
|
1118
|
+
const t = e.target, r = this._renderer;
|
|
1119
|
+
if (t instanceof f)
|
|
1120
|
+
return r.texture.generateCanvas(t);
|
|
1121
|
+
const s = r.textureGenerator.generateTexture(e), n = r.texture.generateCanvas(s);
|
|
1122
|
+
return s.destroy(!0), n;
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Returns a one-dimensional array containing the pixel data of the entire texture in RGBA order,
|
|
1126
|
+
* with integer values between 0 and 255 (inclusive).
|
|
1127
|
+
* > [!NOE] The returned array is a flat Uint8Array where every 4 values represent RGBA
|
|
1128
|
+
* @param options - The options for extracting the image, or the target to extract
|
|
1129
|
+
* @returns One-dimensional Uint8Array containing the pixel data in RGBA format
|
|
1130
|
+
* @example
|
|
1131
|
+
* ```ts
|
|
1132
|
+
* // Basic pixel extraction
|
|
1133
|
+
* const sprite = new Sprite(texture);
|
|
1134
|
+
* const pixels = renderer.extract.pixels(sprite);
|
|
1135
|
+
* console.log(pixels[0], pixels[1], pixels[2], pixels[3]); // R,G,B,A values
|
|
1136
|
+
*
|
|
1137
|
+
* // Extract with custom region
|
|
1138
|
+
* const pixels = renderer.extract.pixels({
|
|
1139
|
+
* target: sprite,
|
|
1140
|
+
* frame: new Rectangle(0, 0, 100, 100)
|
|
1141
|
+
* });
|
|
1142
|
+
*
|
|
1143
|
+
* // Extract with high resolution
|
|
1144
|
+
* const pixels = renderer.extract.pixels({
|
|
1145
|
+
* target: sprite,
|
|
1146
|
+
* resolution: 2
|
|
1147
|
+
* });
|
|
1148
|
+
* ```
|
|
1149
|
+
* @see {@link ExtractOptions} For detailed options
|
|
1150
|
+
* @see {@link ExtractSystem.canvas} For canvas output
|
|
1151
|
+
* @see {@link ExtractSystem.image} For image output
|
|
1152
|
+
* @category rendering
|
|
1153
|
+
*/
|
|
1154
|
+
pixels(e) {
|
|
1155
|
+
e = this._normalizeOptions(e);
|
|
1156
|
+
const t = e.target, r = this._renderer, s = t instanceof f ? t : r.textureGenerator.generateTexture(e), n = r.texture.getPixels(s);
|
|
1157
|
+
return t instanceof P && s.destroy(!0), n;
|
|
1158
|
+
}
|
|
1159
|
+
/**
|
|
1160
|
+
* Creates a texture from a display object or existing texture.
|
|
1161
|
+
*
|
|
1162
|
+
* This is useful for creating
|
|
1163
|
+
* reusable textures from rendered content or making copies of existing textures.
|
|
1164
|
+
* > [!NOTE] The returned texture should be destroyed when no longer needed
|
|
1165
|
+
* @param options - The options for creating the texture, or the target to extract
|
|
1166
|
+
* @returns A new texture containing the extracted content
|
|
1167
|
+
* @example
|
|
1168
|
+
* ```ts
|
|
1169
|
+
* // Basic texture extraction from a sprite
|
|
1170
|
+
* const sprite = new Sprite(texture);
|
|
1171
|
+
* const extractedTexture = renderer.extract.texture(sprite);
|
|
1172
|
+
*
|
|
1173
|
+
* // Extract with custom region
|
|
1174
|
+
* const regionTexture = renderer.extract.texture({
|
|
1175
|
+
* target: container,
|
|
1176
|
+
* frame: new Rectangle(0, 0, 100, 100)
|
|
1177
|
+
* });
|
|
1178
|
+
*
|
|
1179
|
+
* // Extract with high resolution
|
|
1180
|
+
* const hiResTexture = renderer.extract.texture({
|
|
1181
|
+
* target: sprite,
|
|
1182
|
+
* resolution: 2,
|
|
1183
|
+
* clearColor: '#ff0000'
|
|
1184
|
+
* });
|
|
1185
|
+
*
|
|
1186
|
+
* // Create a new sprite from extracted texture
|
|
1187
|
+
* const newSprite = new Sprite(
|
|
1188
|
+
* renderer.extract.texture({
|
|
1189
|
+
* target: graphics,
|
|
1190
|
+
* antialias: true
|
|
1191
|
+
* })
|
|
1192
|
+
* );
|
|
1193
|
+
*
|
|
1194
|
+
* // Clean up when done
|
|
1195
|
+
* extractedTexture.destroy(true);
|
|
1196
|
+
* ```
|
|
1197
|
+
* @see {@link ExtractOptions} For detailed options
|
|
1198
|
+
* @see {@link Texture} For texture management
|
|
1199
|
+
* @see {@link GenerateTextureSystem} For texture generation
|
|
1200
|
+
* @category rendering
|
|
1201
|
+
*/
|
|
1202
|
+
texture(e) {
|
|
1203
|
+
return e = this._normalizeOptions(e), e.target instanceof f ? e.target : this._renderer.textureGenerator.generateTexture(e);
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Extracts and downloads content from the renderer as an image file.
|
|
1207
|
+
* This is a convenient way to save screenshots or export rendered content.
|
|
1208
|
+
* > [!NOTE] The download will use PNG format regardless of the filename extension
|
|
1209
|
+
* @param options - The options for downloading and extracting the image, or the target to extract
|
|
1210
|
+
* @example
|
|
1211
|
+
* ```ts
|
|
1212
|
+
* // Basic download with default filename
|
|
1213
|
+
* const sprite = new Sprite(texture);
|
|
1214
|
+
* renderer.extract.download(sprite); // Downloads as 'image.png'
|
|
1215
|
+
*
|
|
1216
|
+
* // Download with custom filename
|
|
1217
|
+
* renderer.extract.download({
|
|
1218
|
+
* target: sprite,
|
|
1219
|
+
* filename: 'screenshot.png'
|
|
1220
|
+
* });
|
|
1221
|
+
*
|
|
1222
|
+
* // Download with custom region
|
|
1223
|
+
* renderer.extract.download({
|
|
1224
|
+
* target: container,
|
|
1225
|
+
* filename: 'region.png',
|
|
1226
|
+
* frame: new Rectangle(0, 0, 100, 100)
|
|
1227
|
+
* });
|
|
1228
|
+
*
|
|
1229
|
+
* // Download with high resolution and background
|
|
1230
|
+
* renderer.extract.download({
|
|
1231
|
+
* target: stage,
|
|
1232
|
+
* filename: 'hd-screenshot.png',
|
|
1233
|
+
* resolution: 2,
|
|
1234
|
+
* clearColor: '#ff0000'
|
|
1235
|
+
* });
|
|
1236
|
+
*
|
|
1237
|
+
* // Download with anti-aliasing
|
|
1238
|
+
* renderer.extract.download({
|
|
1239
|
+
* target: graphics,
|
|
1240
|
+
* filename: 'smooth.png',
|
|
1241
|
+
* antialias: true
|
|
1242
|
+
* });
|
|
1243
|
+
* ```
|
|
1244
|
+
* @see {@link ExtractDownloadOptions} For detailed options
|
|
1245
|
+
* @see {@link ExtractSystem.image} For creating images without download
|
|
1246
|
+
* @see {@link ExtractSystem.canvas} For canvas output
|
|
1247
|
+
* @category rendering
|
|
1248
|
+
*/
|
|
1249
|
+
download(e) {
|
|
1250
|
+
e = this._normalizeOptions(e);
|
|
1251
|
+
const t = this.canvas(e), r = document.createElement("a");
|
|
1252
|
+
r.download = e.filename ?? "image.png", r.href = t.toDataURL("image/png"), document.body.appendChild(r), r.click(), document.body.removeChild(r);
|
|
1253
|
+
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Logs the target to the console as an image. This is a useful way to debug what's happening in the renderer.
|
|
1256
|
+
* The image will be displayed in the browser's console using CSS background images.
|
|
1257
|
+
* @param options - The options for logging the image, or the target to log
|
|
1258
|
+
* @param options.width - The width of the logged image preview in the console (in pixels)
|
|
1259
|
+
* @example
|
|
1260
|
+
* ```ts
|
|
1261
|
+
* // Basic usage
|
|
1262
|
+
* const sprite = new Sprite(texture);
|
|
1263
|
+
* renderer.extract.log(sprite);
|
|
1264
|
+
* ```
|
|
1265
|
+
* @see {@link ExtractSystem.canvas} For getting raw canvas output
|
|
1266
|
+
* @see {@link ExtractSystem.pixels} For raw pixel data
|
|
1267
|
+
* @category rendering
|
|
1268
|
+
* @advanced
|
|
1269
|
+
*/
|
|
1270
|
+
log(e) {
|
|
1271
|
+
const t = e.width ?? 200;
|
|
1272
|
+
e = this._normalizeOptions(e);
|
|
1273
|
+
const r = this.canvas(e), s = r.toDataURL();
|
|
1274
|
+
console.log(`[Pixi Texture] ${r.width}px ${r.height}px`);
|
|
1275
|
+
const n = [
|
|
1276
|
+
"font-size: 1px;",
|
|
1277
|
+
`padding: ${t}px 300px;`,
|
|
1278
|
+
`background: url(${s}) no-repeat;`,
|
|
1279
|
+
"background-size: contain;"
|
|
1280
|
+
].join(" ");
|
|
1281
|
+
console.log("%c ", n);
|
|
1282
|
+
}
|
|
1283
|
+
destroy() {
|
|
1284
|
+
this._renderer = null;
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
q.extension = {
|
|
1288
|
+
type: [
|
|
1289
|
+
l.WebGLSystem,
|
|
1290
|
+
l.WebGPUSystem,
|
|
1291
|
+
l.CanvasSystem
|
|
1292
|
+
],
|
|
1293
|
+
name: "extract"
|
|
1294
|
+
};
|
|
1295
|
+
q.defaultImageOptions = {
|
|
1296
|
+
format: "png",
|
|
1297
|
+
quality: 1
|
|
1298
|
+
};
|
|
1299
|
+
let gt = q;
|
|
1300
|
+
class K extends f {
|
|
1301
|
+
/**
|
|
1302
|
+
* Creates a RenderTexture. Pass `dynamic: true` in options to allow resizing after creation.
|
|
1303
|
+
* @param options - Options for the RenderTexture, including width, height, and dynamic.
|
|
1304
|
+
* @returns A new RenderTexture instance.
|
|
1305
|
+
* @example
|
|
1306
|
+
* const rt = RenderTexture.create({ width: 100, height: 100, dynamic: true });
|
|
1307
|
+
* rt.resize(500, 500);
|
|
1308
|
+
*/
|
|
1309
|
+
static create(e) {
|
|
1310
|
+
const { dynamic: t, ...r } = e;
|
|
1311
|
+
return new K({
|
|
1312
|
+
source: new v(r),
|
|
1313
|
+
dynamic: t ?? !1
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Resizes the render texture.
|
|
1318
|
+
* @param width - The new width of the render texture.
|
|
1319
|
+
* @param height - The new height of the render texture.
|
|
1320
|
+
* @param resolution - The new resolution of the render texture.
|
|
1321
|
+
* @returns This texture.
|
|
1322
|
+
*/
|
|
1323
|
+
resize(e, t, r) {
|
|
1324
|
+
return this.source.resize(e, t, r), this;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
const _t = new B(), xt = new z(), bt = [0, 0, 0, 0];
|
|
1328
|
+
class Be {
|
|
1329
|
+
constructor(e) {
|
|
1330
|
+
this._renderer = e;
|
|
1331
|
+
}
|
|
1332
|
+
/**
|
|
1333
|
+
* Creates a texture from a display object that can be used for creating sprites and other textures.
|
|
1334
|
+
* This is particularly useful for optimizing performance when a complex container needs to be reused.
|
|
1335
|
+
* @param options - Generate texture options or a container to convert to texture
|
|
1336
|
+
* @returns A new RenderTexture containing the rendered display object
|
|
1337
|
+
* @example
|
|
1338
|
+
* ```ts
|
|
1339
|
+
* // Basic usage with a container
|
|
1340
|
+
* const container = new Container();
|
|
1341
|
+
* container.addChild(
|
|
1342
|
+
* new Graphics()
|
|
1343
|
+
* .circle(0, 0, 50)
|
|
1344
|
+
* .fill('red')
|
|
1345
|
+
* );
|
|
1346
|
+
*
|
|
1347
|
+
* const texture = renderer.textureGenerator.generateTexture(container);
|
|
1348
|
+
*
|
|
1349
|
+
* // Advanced usage with options
|
|
1350
|
+
* const texture = renderer.textureGenerator.generateTexture({
|
|
1351
|
+
* target: container,
|
|
1352
|
+
* frame: new Rectangle(0, 0, 100, 100), // Specific region
|
|
1353
|
+
* resolution: 2, // High DPI
|
|
1354
|
+
* clearColor: '#ff0000', // Red background
|
|
1355
|
+
* antialias: true // Smooth edges
|
|
1356
|
+
* });
|
|
1357
|
+
*
|
|
1358
|
+
* // Create a sprite from the generated texture
|
|
1359
|
+
* const sprite = new Sprite(texture);
|
|
1360
|
+
*
|
|
1361
|
+
* // Clean up when done
|
|
1362
|
+
* texture.destroy(true);
|
|
1363
|
+
* ```
|
|
1364
|
+
* @see {@link GenerateTextureOptions} For detailed texture generation options
|
|
1365
|
+
* @see {@link RenderTexture} For the type of texture created
|
|
1366
|
+
* @category rendering
|
|
1367
|
+
*/
|
|
1368
|
+
generateTexture(e) {
|
|
1369
|
+
var c;
|
|
1370
|
+
e instanceof P && (e = {
|
|
1371
|
+
target: e,
|
|
1372
|
+
frame: void 0,
|
|
1373
|
+
textureSourceOptions: {},
|
|
1374
|
+
resolution: void 0
|
|
1375
|
+
});
|
|
1376
|
+
const t = e.resolution || this._renderer.resolution, r = e.antialias || this._renderer.view.antialias, s = e.target;
|
|
1377
|
+
let n = e.clearColor;
|
|
1378
|
+
n ? n = Array.isArray(n) && n.length === 4 ? n : E.shared.setValue(n).toArray() : n = bt;
|
|
1379
|
+
const i = ((c = e.frame) == null ? void 0 : c.copyTo(_t)) || Je(s, xt).rectangle;
|
|
1380
|
+
i.width = Math.max(i.width, 1 / t) | 0, i.height = Math.max(i.height, 1 / t) | 0;
|
|
1381
|
+
const o = K.create({
|
|
1382
|
+
...e.textureSourceOptions,
|
|
1383
|
+
width: i.width,
|
|
1384
|
+
height: i.height,
|
|
1385
|
+
resolution: t,
|
|
1386
|
+
antialias: r
|
|
1387
|
+
}), d = m.shared.translate(-i.x, -i.y);
|
|
1388
|
+
return this._renderer.render({
|
|
1389
|
+
container: s,
|
|
1390
|
+
transform: d,
|
|
1391
|
+
target: o,
|
|
1392
|
+
clearColor: n
|
|
1393
|
+
}), o.source.updateMipmaps(), o;
|
|
1394
|
+
}
|
|
1395
|
+
destroy() {
|
|
1396
|
+
this._renderer = null;
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
Be.extension = {
|
|
1400
|
+
type: [
|
|
1401
|
+
l.WebGLSystem,
|
|
1402
|
+
l.WebGPUSystem,
|
|
1403
|
+
l.CanvasSystem
|
|
1404
|
+
],
|
|
1405
|
+
name: "textureGenerator"
|
|
1406
|
+
};
|
|
1407
|
+
function Tt(a) {
|
|
1408
|
+
let e = !1;
|
|
1409
|
+
for (const r in a)
|
|
1410
|
+
if (a[r] == null) {
|
|
1411
|
+
e = !0;
|
|
1412
|
+
break;
|
|
1413
|
+
}
|
|
1414
|
+
if (!e) return a;
|
|
1415
|
+
const t = /* @__PURE__ */ Object.create(null);
|
|
1416
|
+
for (const r in a) {
|
|
1417
|
+
const s = a[r];
|
|
1418
|
+
s && (t[r] = s);
|
|
1419
|
+
}
|
|
1420
|
+
return t;
|
|
1421
|
+
}
|
|
1422
|
+
function vt(a) {
|
|
1423
|
+
let e = 0;
|
|
1424
|
+
for (let t = 0; t < a.length; t++)
|
|
1425
|
+
a[t] == null ? e++ : a[t - e] = a[t];
|
|
1426
|
+
return a.length -= e, a;
|
|
1427
|
+
}
|
|
1428
|
+
const Y = class Ge {
|
|
1429
|
+
/**
|
|
1430
|
+
* Creates a new GCSystem instance.
|
|
1431
|
+
* @param renderer - The renderer this garbage collection system works for
|
|
1432
|
+
*/
|
|
1433
|
+
constructor(e) {
|
|
1434
|
+
this._managedResources = [], this._managedResourceHashes = [], this._managedCollections = [], this._ready = !1, this._renderer = e;
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* Initializes the garbage collection system with the provided options.
|
|
1438
|
+
* @param options - Configuration options
|
|
1439
|
+
*/
|
|
1440
|
+
init(e) {
|
|
1441
|
+
e = { ...Ge.defaultOptions, ...e }, this.maxUnusedTime = e.gcMaxUnusedTime, this._frequency = e.gcFrequency, this.enabled = e.gcActive, this.now = performance.now();
|
|
1442
|
+
}
|
|
1443
|
+
/**
|
|
1444
|
+
* Gets whether the garbage collection system is currently enabled.
|
|
1445
|
+
* @returns True if GC is enabled, false otherwise
|
|
1446
|
+
*/
|
|
1447
|
+
get enabled() {
|
|
1448
|
+
return !!this._handler;
|
|
1449
|
+
}
|
|
1450
|
+
/**
|
|
1451
|
+
* Enables or disables the garbage collection system.
|
|
1452
|
+
* When enabled, schedules periodic cleanup of resources.
|
|
1453
|
+
* When disabled, cancels all scheduled cleanups.
|
|
1454
|
+
*/
|
|
1455
|
+
set enabled(e) {
|
|
1456
|
+
this.enabled !== e && (e ? (this._handler = this._renderer.scheduler.repeat(
|
|
1457
|
+
() => {
|
|
1458
|
+
this._ready = !0;
|
|
1459
|
+
},
|
|
1460
|
+
this._frequency,
|
|
1461
|
+
!1
|
|
1462
|
+
), this._collectionsHandler = this._renderer.scheduler.repeat(
|
|
1463
|
+
() => {
|
|
1464
|
+
for (const t of this._managedCollections) {
|
|
1465
|
+
const { context: r, collection: s, type: n } = t;
|
|
1466
|
+
n === "hash" ? r[s] = Tt(r[s]) : r[s] = vt(r[s]);
|
|
1467
|
+
}
|
|
1468
|
+
},
|
|
1469
|
+
this._frequency
|
|
1470
|
+
)) : (this._renderer.scheduler.cancel(this._handler), this._renderer.scheduler.cancel(this._collectionsHandler), this._handler = 0, this._collectionsHandler = 0));
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* Called before rendering. Updates the current timestamp.
|
|
1474
|
+
* @param options - The render options
|
|
1475
|
+
* @param options.container - The container to render
|
|
1476
|
+
*/
|
|
1477
|
+
prerender({ container: e }) {
|
|
1478
|
+
this.now = performance.now(), e.renderGroup.gcTick = this._renderer.tick++, this._updateInstructionGCTick(e.renderGroup, e.renderGroup.gcTick);
|
|
1479
|
+
}
|
|
1480
|
+
/** Performs garbage collection after rendering. */
|
|
1481
|
+
postrender() {
|
|
1482
|
+
!this._ready || !this.enabled || (this.run(), this._ready = !1);
|
|
1483
|
+
}
|
|
1484
|
+
/**
|
|
1485
|
+
* Updates the GC tick counter for a render group and its children.
|
|
1486
|
+
* @param renderGroup - The render group to update
|
|
1487
|
+
* @param gcTick - The new tick value
|
|
1488
|
+
*/
|
|
1489
|
+
_updateInstructionGCTick(e, t) {
|
|
1490
|
+
e.instructionSet.gcTick = t, e.gcTick = t;
|
|
1491
|
+
for (const r of e.renderGroupChildren)
|
|
1492
|
+
this._updateInstructionGCTick(r, t);
|
|
1493
|
+
}
|
|
1494
|
+
/**
|
|
1495
|
+
* Registers a collection for garbage collection tracking.
|
|
1496
|
+
* @param context - The object containing the collection
|
|
1497
|
+
* @param collection - The property name on context that holds the collection
|
|
1498
|
+
* @param type - The type of collection to track ('hash' or 'array')
|
|
1499
|
+
*/
|
|
1500
|
+
addCollection(e, t, r) {
|
|
1501
|
+
this._managedCollections.push({
|
|
1502
|
+
context: e,
|
|
1503
|
+
collection: t,
|
|
1504
|
+
type: r
|
|
1505
|
+
});
|
|
1506
|
+
}
|
|
1507
|
+
/**
|
|
1508
|
+
* Registers a resource for garbage collection tracking.
|
|
1509
|
+
* @param resource - The resource to track
|
|
1510
|
+
* @param type - The type of resource to track
|
|
1511
|
+
*/
|
|
1512
|
+
addResource(e, t) {
|
|
1513
|
+
var s, n;
|
|
1514
|
+
if (e._gcLastUsed !== -1) {
|
|
1515
|
+
e._gcLastUsed = this.now, (s = e._onTouch) == null || s.call(e, this.now);
|
|
1516
|
+
return;
|
|
1517
|
+
}
|
|
1518
|
+
const r = this._managedResources.length;
|
|
1519
|
+
e._gcData = {
|
|
1520
|
+
index: r,
|
|
1521
|
+
type: t
|
|
1522
|
+
}, e._gcLastUsed = this.now, (n = e._onTouch) == null || n.call(e, this.now), e.once("unload", this.removeResource, this), this._managedResources.push(e);
|
|
1523
|
+
}
|
|
1524
|
+
/**
|
|
1525
|
+
* Removes a resource from garbage collection tracking.
|
|
1526
|
+
* Call this when manually destroying a resource.
|
|
1527
|
+
* @param resource - The resource to stop tracking
|
|
1528
|
+
*/
|
|
1529
|
+
removeResource(e) {
|
|
1530
|
+
const t = e._gcData;
|
|
1531
|
+
if (!t) return;
|
|
1532
|
+
const r = t.index, s = this._managedResources.length - 1;
|
|
1533
|
+
if (r !== s) {
|
|
1534
|
+
const n = this._managedResources[s];
|
|
1535
|
+
this._managedResources[r] = n, n._gcData.index = r;
|
|
1536
|
+
}
|
|
1537
|
+
this._managedResources.length--, e._gcData = null, e._gcLastUsed = -1;
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* Registers a hash-based resource collection for garbage collection tracking.
|
|
1541
|
+
* Resources in the hash will be automatically tracked and cleaned up when unused.
|
|
1542
|
+
* @param context - The object containing the hash property
|
|
1543
|
+
* @param hash - The property name on context that holds the resource hash
|
|
1544
|
+
* @param type - The type of resources in the hash ('resource' or 'renderable')
|
|
1545
|
+
* @param priority - Processing priority (lower values are processed first)
|
|
1546
|
+
*/
|
|
1547
|
+
addResourceHash(e, t, r, s = 0) {
|
|
1548
|
+
this._managedResourceHashes.push({
|
|
1549
|
+
context: e,
|
|
1550
|
+
hash: t,
|
|
1551
|
+
type: r,
|
|
1552
|
+
priority: s
|
|
1553
|
+
}), this._managedResourceHashes.sort((n, i) => n.priority - i.priority);
|
|
1554
|
+
}
|
|
1555
|
+
/**
|
|
1556
|
+
* Performs garbage collection by cleaning up unused resources.
|
|
1557
|
+
* Removes resources that haven't been used for longer than maxUnusedTime.
|
|
1558
|
+
*/
|
|
1559
|
+
run() {
|
|
1560
|
+
const e = performance.now(), t = this._managedResourceHashes;
|
|
1561
|
+
for (const s of t)
|
|
1562
|
+
this.runOnHash(s, e);
|
|
1563
|
+
let r = 0;
|
|
1564
|
+
for (let s = 0; s < this._managedResources.length; s++) {
|
|
1565
|
+
const n = this._managedResources[s];
|
|
1566
|
+
r = this.runOnResource(n, e, r);
|
|
1567
|
+
}
|
|
1568
|
+
this._managedResources.length = r;
|
|
1569
|
+
}
|
|
1570
|
+
updateRenderableGCTick(e, t) {
|
|
1571
|
+
var n, i;
|
|
1572
|
+
const r = e.renderGroup ?? e.parentRenderGroup, s = ((n = r == null ? void 0 : r.instructionSet) == null ? void 0 : n.gcTick) ?? -1;
|
|
1573
|
+
((r == null ? void 0 : r.gcTick) ?? 0) === s && (e._gcLastUsed = t, (i = e._onTouch) == null || i.call(e, t));
|
|
1574
|
+
}
|
|
1575
|
+
runOnResource(e, t, r) {
|
|
1576
|
+
const s = e._gcData;
|
|
1577
|
+
return s.type === "renderable" && this.updateRenderableGCTick(e, t), t - e._gcLastUsed < this.maxUnusedTime || !e.autoGarbageCollect ? (this._managedResources[r] = e, s.index = r, r++) : (e.unload(), e._gcData = null, e._gcLastUsed = -1, e.off("unload", this.removeResource, this)), r;
|
|
1578
|
+
}
|
|
1579
|
+
/**
|
|
1580
|
+
* Creates a clone of the hash, copying all non-null entries up to (but not including) the stop key.
|
|
1581
|
+
* @param hashValue - The original hash to clone from
|
|
1582
|
+
* @param stopKey - The key to stop at (exclusive)
|
|
1583
|
+
* @returns A new hash object with copied entries
|
|
1584
|
+
*/
|
|
1585
|
+
_createHashClone(e, t) {
|
|
1586
|
+
const r = /* @__PURE__ */ Object.create(null);
|
|
1587
|
+
for (const s in e) {
|
|
1588
|
+
if (s === t) break;
|
|
1589
|
+
e[s] !== null && (r[s] = e[s]);
|
|
1590
|
+
}
|
|
1591
|
+
return r;
|
|
1592
|
+
}
|
|
1593
|
+
runOnHash(e, t) {
|
|
1594
|
+
var c;
|
|
1595
|
+
const { context: r, hash: s, type: n } = e, i = r[s];
|
|
1596
|
+
let o = null, d = 0;
|
|
1597
|
+
for (const h in i) {
|
|
1598
|
+
const u = i[h];
|
|
1599
|
+
if (u === null) {
|
|
1600
|
+
d++, d === 1e4 && !o && (o = this._createHashClone(i, h));
|
|
1601
|
+
continue;
|
|
1602
|
+
}
|
|
1603
|
+
if (u._gcLastUsed === -1) {
|
|
1604
|
+
u._gcLastUsed = t, (c = u._onTouch) == null || c.call(u, t), o && (o[h] = u);
|
|
1605
|
+
continue;
|
|
1606
|
+
}
|
|
1607
|
+
if (n === "renderable" && this.updateRenderableGCTick(u, t), !(t - u._gcLastUsed < this.maxUnusedTime) && u.autoGarbageCollect) {
|
|
1608
|
+
if (o || (d + 1 !== 1e4 ? (i[h] = null, d++) : o = this._createHashClone(i, h)), n === "renderable") {
|
|
1609
|
+
const _ = u, x = _.renderGroup ?? _.parentRenderGroup;
|
|
1610
|
+
x && (x.structureDidChange = !0);
|
|
1611
|
+
}
|
|
1612
|
+
u.unload(), u._gcData = null, u._gcLastUsed = -1;
|
|
1613
|
+
} else o && (o[h] = u);
|
|
1614
|
+
}
|
|
1615
|
+
o && (r[s] = o);
|
|
1616
|
+
}
|
|
1617
|
+
/** Cleans up the garbage collection system. Disables GC and removes all tracked resources. */
|
|
1618
|
+
destroy() {
|
|
1619
|
+
this.enabled = !1, this._managedResources.forEach((e) => {
|
|
1620
|
+
e.off("unload", this.removeResource, this);
|
|
1621
|
+
}), this._managedResources.length = 0, this._managedResourceHashes.length = 0, this._managedCollections.length = 0, this._renderer = null;
|
|
1622
|
+
}
|
|
1623
|
+
};
|
|
1624
|
+
Y.extension = {
|
|
1625
|
+
type: [
|
|
1626
|
+
l.WebGLSystem,
|
|
1627
|
+
l.WebGPUSystem,
|
|
1628
|
+
l.CanvasSystem
|
|
1629
|
+
],
|
|
1630
|
+
name: "gc",
|
|
1631
|
+
priority: 0
|
|
1632
|
+
};
|
|
1633
|
+
Y.defaultOptions = {
|
|
1634
|
+
/** Enable/disable the garbage collector */
|
|
1635
|
+
gcActive: !0,
|
|
1636
|
+
/** Time in ms before an unused resource is collected (default 1 minute) */
|
|
1637
|
+
gcMaxUnusedTime: 6e4,
|
|
1638
|
+
/** How often to run garbage collection in ms (default 30 seconds) */
|
|
1639
|
+
gcFrequency: 3e4
|
|
1640
|
+
};
|
|
1641
|
+
let yt = Y;
|
|
1642
|
+
class Ue {
|
|
1643
|
+
constructor(e) {
|
|
1644
|
+
this._stackIndex = 0, this._globalUniformDataStack = [], this._uniformsPool = [], this._activeUniforms = [], this._bindGroupPool = [], this._activeBindGroups = [], this._renderer = e;
|
|
1645
|
+
}
|
|
1646
|
+
reset() {
|
|
1647
|
+
this._stackIndex = 0;
|
|
1648
|
+
for (let e = 0; e < this._activeUniforms.length; e++)
|
|
1649
|
+
this._uniformsPool.push(this._activeUniforms[e]);
|
|
1650
|
+
for (let e = 0; e < this._activeBindGroups.length; e++)
|
|
1651
|
+
this._bindGroupPool.push(this._activeBindGroups[e]);
|
|
1652
|
+
this._activeUniforms.length = 0, this._activeBindGroups.length = 0;
|
|
1653
|
+
}
|
|
1654
|
+
start(e) {
|
|
1655
|
+
this.reset(), this.push(e);
|
|
1656
|
+
}
|
|
1657
|
+
bind({
|
|
1658
|
+
size: e,
|
|
1659
|
+
projectionMatrix: t,
|
|
1660
|
+
worldTransformMatrix: r,
|
|
1661
|
+
worldColor: s,
|
|
1662
|
+
offset: n
|
|
1663
|
+
}) {
|
|
1664
|
+
const i = this._renderer.renderTarget.renderTarget, o = this._stackIndex ? this._globalUniformDataStack[this._stackIndex - 1] : {
|
|
1665
|
+
worldTransformMatrix: new m(),
|
|
1666
|
+
worldColor: 4294967295,
|
|
1667
|
+
offset: new Qe()
|
|
1668
|
+
}, d = {
|
|
1669
|
+
projectionMatrix: t || this._renderer.renderTarget.projectionMatrix,
|
|
1670
|
+
resolution: e || i.size,
|
|
1671
|
+
worldTransformMatrix: r || o.worldTransformMatrix,
|
|
1672
|
+
worldColor: s || o.worldColor,
|
|
1673
|
+
offset: n || o.offset,
|
|
1674
|
+
bindGroup: null
|
|
1675
|
+
}, c = this._uniformsPool.pop() || this._createUniforms();
|
|
1676
|
+
this._activeUniforms.push(c);
|
|
1677
|
+
const h = c.uniforms;
|
|
1678
|
+
h.uProjectionMatrix = d.projectionMatrix, h.uResolution = d.resolution, h.uWorldTransformMatrix.copyFrom(d.worldTransformMatrix), h.uWorldTransformMatrix.tx -= d.offset.x, h.uWorldTransformMatrix.ty -= d.offset.y, Ze(
|
|
1679
|
+
d.worldColor,
|
|
1680
|
+
h.uWorldColorAlpha,
|
|
1681
|
+
0
|
|
1682
|
+
), c.update();
|
|
1683
|
+
let u;
|
|
1684
|
+
this._renderer.renderPipes.uniformBatch ? u = this._renderer.renderPipes.uniformBatch.getUniformBindGroup(c, !1) : (u = this._bindGroupPool.pop() || new et(), this._activeBindGroups.push(u), u.setResource(c, 0)), d.bindGroup = u, this._currentGlobalUniformData = d;
|
|
1685
|
+
}
|
|
1686
|
+
push(e) {
|
|
1687
|
+
this.bind(e), this._globalUniformDataStack[this._stackIndex++] = this._currentGlobalUniformData;
|
|
1688
|
+
}
|
|
1689
|
+
pop() {
|
|
1690
|
+
this._currentGlobalUniformData = this._globalUniformDataStack[--this._stackIndex - 1], this._renderer.type === V.WEBGL && this._currentGlobalUniformData.bindGroup.resources[0].update();
|
|
1691
|
+
}
|
|
1692
|
+
get bindGroup() {
|
|
1693
|
+
return this._currentGlobalUniformData.bindGroup;
|
|
1694
|
+
}
|
|
1695
|
+
get globalUniformData() {
|
|
1696
|
+
return this._currentGlobalUniformData;
|
|
1697
|
+
}
|
|
1698
|
+
get uniformGroup() {
|
|
1699
|
+
return this._currentGlobalUniformData.bindGroup.resources[0];
|
|
1700
|
+
}
|
|
1701
|
+
_createUniforms() {
|
|
1702
|
+
return new oe({
|
|
1703
|
+
uProjectionMatrix: { value: new m(), type: "mat3x3<f32>" },
|
|
1704
|
+
uWorldTransformMatrix: { value: new m(), type: "mat3x3<f32>" },
|
|
1705
|
+
// TODO - someone smart - set this to be a unorm8x4 rather than a vec4<f32>
|
|
1706
|
+
uWorldColorAlpha: { value: new Float32Array(4), type: "vec4<f32>" },
|
|
1707
|
+
uResolution: { value: [0, 0], type: "vec2<f32>" }
|
|
1708
|
+
}, {
|
|
1709
|
+
isStatic: !0
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
destroy() {
|
|
1713
|
+
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;
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
Ue.extension = {
|
|
1717
|
+
type: [
|
|
1718
|
+
l.WebGLSystem,
|
|
1719
|
+
l.WebGPUSystem,
|
|
1720
|
+
l.CanvasSystem
|
|
1721
|
+
],
|
|
1722
|
+
name: "globalUniforms"
|
|
1723
|
+
};
|
|
1724
|
+
let Ct = 1;
|
|
1725
|
+
class Ae {
|
|
1726
|
+
constructor() {
|
|
1727
|
+
this._tasks = [], this._offset = 0;
|
|
1728
|
+
}
|
|
1729
|
+
/** Initializes the scheduler system and starts the ticker. */
|
|
1730
|
+
init() {
|
|
1731
|
+
te.system.add(this._update, this);
|
|
1732
|
+
}
|
|
1733
|
+
/**
|
|
1734
|
+
* Schedules a repeating task.
|
|
1735
|
+
* @param func - The function to execute.
|
|
1736
|
+
* @param duration - The interval duration in milliseconds.
|
|
1737
|
+
* @param useOffset - this will spread out tasks so that they do not all run at the same time
|
|
1738
|
+
* @returns The unique identifier for the scheduled task.
|
|
1739
|
+
*/
|
|
1740
|
+
repeat(e, t, r = !0) {
|
|
1741
|
+
const s = Ct++;
|
|
1742
|
+
let n = 0;
|
|
1743
|
+
return r && (this._offset += 1e3, n = this._offset), this._tasks.push({
|
|
1744
|
+
func: e,
|
|
1745
|
+
duration: t,
|
|
1746
|
+
start: performance.now(),
|
|
1747
|
+
offset: n,
|
|
1748
|
+
last: performance.now(),
|
|
1749
|
+
repeat: !0,
|
|
1750
|
+
id: s
|
|
1751
|
+
}), s;
|
|
1752
|
+
}
|
|
1753
|
+
/**
|
|
1754
|
+
* Cancels a scheduled task.
|
|
1755
|
+
* @param id - The unique identifier of the task to cancel.
|
|
1756
|
+
*/
|
|
1757
|
+
cancel(e) {
|
|
1758
|
+
for (let t = 0; t < this._tasks.length; t++)
|
|
1759
|
+
if (this._tasks[t].id === e) {
|
|
1760
|
+
this._tasks.splice(t, 1);
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
/**
|
|
1765
|
+
* Updates and executes the scheduled tasks.
|
|
1766
|
+
* @private
|
|
1767
|
+
*/
|
|
1768
|
+
_update() {
|
|
1769
|
+
const e = performance.now();
|
|
1770
|
+
for (let t = 0; t < this._tasks.length; t++) {
|
|
1771
|
+
const r = this._tasks[t];
|
|
1772
|
+
if (e - r.offset - r.last >= r.duration) {
|
|
1773
|
+
const s = e - r.start;
|
|
1774
|
+
r.func(s), r.last = e;
|
|
1775
|
+
}
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Destroys the scheduler system and removes all tasks.
|
|
1780
|
+
* @internal
|
|
1781
|
+
*/
|
|
1782
|
+
destroy() {
|
|
1783
|
+
te.system.remove(this._update, this), this._tasks.length = 0;
|
|
1784
|
+
}
|
|
1785
|
+
}
|
|
1786
|
+
Ae.extension = {
|
|
1787
|
+
type: [
|
|
1788
|
+
l.WebGLSystem,
|
|
1789
|
+
l.WebGPUSystem,
|
|
1790
|
+
l.CanvasSystem
|
|
1791
|
+
],
|
|
1792
|
+
name: "scheduler",
|
|
1793
|
+
priority: 0
|
|
1794
|
+
};
|
|
1795
|
+
let ie = !1;
|
|
1796
|
+
function kt(a) {
|
|
1797
|
+
if (!ie) {
|
|
1798
|
+
if (N.get().getNavigator().userAgent.toLowerCase().indexOf("chrome") > -1) {
|
|
1799
|
+
const e = [
|
|
1800
|
+
`%c %c %c %c %c PixiJS %c v${re} (${a}) http://www.pixijs.com/
|
|
1801
|
+
|
|
1802
|
+
`,
|
|
1803
|
+
"background: #E72264; padding:5px 0;",
|
|
1804
|
+
"background: #6CA2EA; padding:5px 0;",
|
|
1805
|
+
"background: #B5D33D; padding:5px 0;",
|
|
1806
|
+
"background: #FED23F; padding:5px 0;",
|
|
1807
|
+
"color: #FFFFFF; background: #E72264; padding:5px 0;",
|
|
1808
|
+
"color: #E72264; background: #FFFFFF; padding:5px 0;"
|
|
1809
|
+
];
|
|
1810
|
+
globalThis.console.log(...e);
|
|
1811
|
+
} else globalThis.console && globalThis.console.log(`PixiJS ${re} - ${a} - http://www.pixijs.com/`);
|
|
1812
|
+
ie = !0;
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
class X {
|
|
1816
|
+
constructor(e) {
|
|
1817
|
+
this._renderer = e;
|
|
1818
|
+
}
|
|
1819
|
+
/**
|
|
1820
|
+
* It all starts here! This initiates every system, passing in the options for any system by name.
|
|
1821
|
+
* @param options - the config for the renderer and all its systems
|
|
1822
|
+
*/
|
|
1823
|
+
init(e) {
|
|
1824
|
+
if (e.hello) {
|
|
1825
|
+
let t = this._renderer.name;
|
|
1826
|
+
this._renderer.type === V.WEBGL && (t += ` ${this._renderer.context.webGLVersion}`), kt(t);
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
X.extension = {
|
|
1831
|
+
type: [
|
|
1832
|
+
l.WebGLSystem,
|
|
1833
|
+
l.WebGPUSystem,
|
|
1834
|
+
l.CanvasSystem
|
|
1835
|
+
],
|
|
1836
|
+
name: "hello",
|
|
1837
|
+
priority: -2
|
|
1838
|
+
};
|
|
1839
|
+
X.defaultOptions = {
|
|
1840
|
+
/** {@link WebGLOptions.hello} */
|
|
1841
|
+
hello: !1
|
|
1842
|
+
};
|
|
1843
|
+
const J = class Ie {
|
|
1844
|
+
/**
|
|
1845
|
+
* Creates a new RenderableGCSystem instance.
|
|
1846
|
+
* @param renderer - The renderer this garbage collection system works for
|
|
1847
|
+
*/
|
|
1848
|
+
constructor(e) {
|
|
1849
|
+
this._renderer = e;
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Initializes the garbage collection system with the provided options.
|
|
1853
|
+
* @param options - Configuration options for the renderer
|
|
1854
|
+
*/
|
|
1855
|
+
init(e) {
|
|
1856
|
+
e = { ...Ie.defaultOptions, ...e }, this.maxUnusedTime = e.renderableGCMaxUnusedTime;
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* Gets whether the garbage collection system is currently enabled.
|
|
1860
|
+
* @returns True if GC is enabled, false otherwise
|
|
1861
|
+
*/
|
|
1862
|
+
get enabled() {
|
|
1863
|
+
return p("8.15.0", "RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."), this._renderer.gc.enabled;
|
|
1864
|
+
}
|
|
1865
|
+
/**
|
|
1866
|
+
* Enables or disables the garbage collection system.
|
|
1867
|
+
* When enabled, schedules periodic cleanup of resources.
|
|
1868
|
+
* When disabled, cancels all scheduled cleanups.
|
|
1869
|
+
*/
|
|
1870
|
+
set enabled(e) {
|
|
1871
|
+
p("8.15.0", "RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."), this._renderer.gc.enabled = e;
|
|
1872
|
+
}
|
|
1873
|
+
/**
|
|
1874
|
+
* Adds a hash table to be managed by the garbage collector.
|
|
1875
|
+
* @param context - The object containing the hash table
|
|
1876
|
+
* @param hash - The property name of the hash table
|
|
1877
|
+
*/
|
|
1878
|
+
addManagedHash(e, t) {
|
|
1879
|
+
p("8.15.0", "RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."), this._renderer.gc.addCollection(e, t, "hash");
|
|
1880
|
+
}
|
|
1881
|
+
/**
|
|
1882
|
+
* Adds an array to be managed by the garbage collector.
|
|
1883
|
+
* @param context - The object containing the array
|
|
1884
|
+
* @param hash - The property name of the array
|
|
1885
|
+
*/
|
|
1886
|
+
addManagedArray(e, t) {
|
|
1887
|
+
p("8.15.0", "RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."), this._renderer.gc.addCollection(e, t, "array");
|
|
1888
|
+
}
|
|
1889
|
+
/**
|
|
1890
|
+
* Starts tracking a renderable for garbage collection.
|
|
1891
|
+
* @param _renderable - The renderable to track
|
|
1892
|
+
* @deprecated since 8.15.0
|
|
1893
|
+
*/
|
|
1894
|
+
addRenderable(e) {
|
|
1895
|
+
p("8.15.0", "RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."), this._renderer.gc.addResource(e, "renderable");
|
|
1896
|
+
}
|
|
1897
|
+
/**
|
|
1898
|
+
* Performs garbage collection by cleaning up unused renderables.
|
|
1899
|
+
* Removes renderables that haven't been used for longer than maxUnusedTime.
|
|
1900
|
+
*/
|
|
1901
|
+
run() {
|
|
1902
|
+
p("8.15.0", "RenderableGCSystem.run is deprecated, please use the GCSystem instead."), this._renderer.gc.run();
|
|
1903
|
+
}
|
|
1904
|
+
/** Cleans up the garbage collection system. Disables GC and removes all tracked resources. */
|
|
1905
|
+
destroy() {
|
|
1906
|
+
this._renderer = null;
|
|
1907
|
+
}
|
|
1908
|
+
};
|
|
1909
|
+
J.extension = {
|
|
1910
|
+
type: [
|
|
1911
|
+
l.WebGLSystem,
|
|
1912
|
+
l.WebGPUSystem,
|
|
1913
|
+
l.CanvasSystem
|
|
1914
|
+
],
|
|
1915
|
+
name: "renderableGC",
|
|
1916
|
+
priority: 0
|
|
1917
|
+
};
|
|
1918
|
+
J.defaultOptions = {
|
|
1919
|
+
/** Enable/disable the garbage collector */
|
|
1920
|
+
renderableGCActive: !0,
|
|
1921
|
+
/** Time in ms before an unused resource is collected (default 1 minute) */
|
|
1922
|
+
renderableGCMaxUnusedTime: 6e4,
|
|
1923
|
+
/** How often to run garbage collection in ms (default 30 seconds) */
|
|
1924
|
+
renderableGCFrequency: 3e4
|
|
1925
|
+
};
|
|
1926
|
+
let Mt = J;
|
|
1927
|
+
const Q = class S {
|
|
1928
|
+
/**
|
|
1929
|
+
* Frame count since started.
|
|
1930
|
+
* @readonly
|
|
1931
|
+
* @deprecated since 8.15.0
|
|
1932
|
+
*/
|
|
1933
|
+
get count() {
|
|
1934
|
+
return this._renderer.tick;
|
|
1935
|
+
}
|
|
1936
|
+
/**
|
|
1937
|
+
* Frame count since last garbage collection.
|
|
1938
|
+
* @readonly
|
|
1939
|
+
* @deprecated since 8.15.0
|
|
1940
|
+
*/
|
|
1941
|
+
get checkCount() {
|
|
1942
|
+
return this._checkCount;
|
|
1943
|
+
}
|
|
1944
|
+
set checkCount(e) {
|
|
1945
|
+
p("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead."), this._checkCount = e;
|
|
1946
|
+
}
|
|
1947
|
+
/**
|
|
1948
|
+
* Maximum idle frames before a texture is destroyed by garbage collection.
|
|
1949
|
+
* @see TextureGCSystem.defaultMaxIdle
|
|
1950
|
+
* @deprecated since 8.15.0
|
|
1951
|
+
*/
|
|
1952
|
+
get maxIdle() {
|
|
1953
|
+
return this._renderer.gc.maxUnusedTime / 1e3 * 60;
|
|
1954
|
+
}
|
|
1955
|
+
set maxIdle(e) {
|
|
1956
|
+
p("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead."), this._renderer.gc.maxUnusedTime = e / 60 * 1e3;
|
|
1957
|
+
}
|
|
1958
|
+
/**
|
|
1959
|
+
* Frames between two garbage collections.
|
|
1960
|
+
* @see TextureGCSystem.defaultCheckCountMax
|
|
1961
|
+
* @deprecated since 8.15.0
|
|
1962
|
+
*/
|
|
1963
|
+
// eslint-disable-next-line dot-notation
|
|
1964
|
+
get checkCountMax() {
|
|
1965
|
+
return Math.floor(this._renderer.gc._frequency / 1e3);
|
|
1966
|
+
}
|
|
1967
|
+
set checkCountMax(e) {
|
|
1968
|
+
p("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead.");
|
|
1969
|
+
}
|
|
1970
|
+
/**
|
|
1971
|
+
* Current garbage collection mode.
|
|
1972
|
+
* @see TextureGCSystem.defaultMode
|
|
1973
|
+
* @deprecated since 8.15.0
|
|
1974
|
+
*/
|
|
1975
|
+
get active() {
|
|
1976
|
+
return this._renderer.gc.enabled;
|
|
1977
|
+
}
|
|
1978
|
+
set active(e) {
|
|
1979
|
+
p("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead."), this._renderer.gc.enabled = e;
|
|
1980
|
+
}
|
|
1981
|
+
/** @param renderer - The renderer this System works for. */
|
|
1982
|
+
constructor(e) {
|
|
1983
|
+
this._renderer = e, this._checkCount = 0;
|
|
1984
|
+
}
|
|
1985
|
+
init(e) {
|
|
1986
|
+
e.textureGCActive !== S.defaultOptions.textureGCActive && (this.active = e.textureGCActive), e.textureGCMaxIdle !== S.defaultOptions.textureGCMaxIdle && (this.maxIdle = e.textureGCMaxIdle), e.textureGCCheckCountMax !== S.defaultOptions.textureGCCheckCountMax && (this.checkCountMax = e.textureGCCheckCountMax);
|
|
1987
|
+
}
|
|
1988
|
+
/**
|
|
1989
|
+
* Checks to see when the last time a texture was used.
|
|
1990
|
+
* If the texture has not been used for a specified amount of time, it will be removed from the GPU.
|
|
1991
|
+
* @deprecated since 8.15.0
|
|
1992
|
+
*/
|
|
1993
|
+
run() {
|
|
1994
|
+
p("8.15.0", "TextureGCSystem.run is deprecated, please use the GCSystem instead."), this._renderer.gc.run();
|
|
1995
|
+
}
|
|
1996
|
+
destroy() {
|
|
1997
|
+
this._renderer = null;
|
|
1998
|
+
}
|
|
1999
|
+
};
|
|
2000
|
+
Q.extension = {
|
|
2001
|
+
type: [
|
|
2002
|
+
l.WebGLSystem,
|
|
2003
|
+
l.WebGPUSystem
|
|
2004
|
+
],
|
|
2005
|
+
name: "textureGC"
|
|
2006
|
+
};
|
|
2007
|
+
Q.defaultOptions = {
|
|
2008
|
+
/**
|
|
2009
|
+
* If set to true, this will enable the garbage collector on the GPU.
|
|
2010
|
+
* @default true
|
|
2011
|
+
*/
|
|
2012
|
+
textureGCActive: !0,
|
|
2013
|
+
/**
|
|
2014
|
+
* @deprecated since 8.3.0
|
|
2015
|
+
* @see {@link TextureGCSystemOptions.textureGCMaxIdle}
|
|
2016
|
+
*/
|
|
2017
|
+
textureGCAMaxIdle: null,
|
|
2018
|
+
/**
|
|
2019
|
+
* The maximum idle frames before a texture is destroyed by garbage collection.
|
|
2020
|
+
* @default 60 * 60
|
|
2021
|
+
*/
|
|
2022
|
+
textureGCMaxIdle: 3600,
|
|
2023
|
+
/**
|
|
2024
|
+
* Frames between two garbage collections.
|
|
2025
|
+
* @default 600
|
|
2026
|
+
*/
|
|
2027
|
+
textureGCCheckCountMax: 600
|
|
2028
|
+
};
|
|
2029
|
+
let Rt = Q;
|
|
2030
|
+
const De = class Ee {
|
|
2031
|
+
/**
|
|
2032
|
+
* @param [descriptor] - Options for creating a render target.
|
|
2033
|
+
*/
|
|
2034
|
+
constructor(e = {}) {
|
|
2035
|
+
if (this.uid = tt("renderTarget"), this.colorTextures = [], this.dirtyId = 0, this.isRoot = !1, this._size = new Float32Array(2), this._managedColorTextures = !1, e = { ...Ee.defaultOptions, ...e }, this.stencil = e.stencil, this.depth = e.depth, this.isRoot = e.isRoot, typeof e.colorTextures == "number") {
|
|
2036
|
+
this._managedColorTextures = !0;
|
|
2037
|
+
for (let t = 0; t < e.colorTextures; t++)
|
|
2038
|
+
this.colorTextures.push(
|
|
2039
|
+
new v({
|
|
2040
|
+
width: e.width,
|
|
2041
|
+
height: e.height,
|
|
2042
|
+
resolution: e.resolution,
|
|
2043
|
+
antialias: e.antialias
|
|
2044
|
+
})
|
|
2045
|
+
);
|
|
2046
|
+
} else {
|
|
2047
|
+
this.colorTextures = [...e.colorTextures.map((r) => r.source)];
|
|
2048
|
+
const t = this.colorTexture.source;
|
|
2049
|
+
this.resize(t.width, t.height, t._resolution);
|
|
2050
|
+
}
|
|
2051
|
+
this.colorTexture.source.on("resize", this.onSourceResize, this), (e.depthStencilTexture || this.stencil) && (e.depthStencilTexture instanceof f || e.depthStencilTexture instanceof v ? this.depthStencilTexture = e.depthStencilTexture.source : this.ensureDepthStencilTexture());
|
|
2052
|
+
}
|
|
2053
|
+
get size() {
|
|
2054
|
+
const e = this._size;
|
|
2055
|
+
return e[0] = this.pixelWidth, e[1] = this.pixelHeight, e;
|
|
2056
|
+
}
|
|
2057
|
+
get width() {
|
|
2058
|
+
return this.colorTexture.source.width;
|
|
2059
|
+
}
|
|
2060
|
+
get height() {
|
|
2061
|
+
return this.colorTexture.source.height;
|
|
2062
|
+
}
|
|
2063
|
+
get pixelWidth() {
|
|
2064
|
+
return this.colorTexture.source.pixelWidth;
|
|
2065
|
+
}
|
|
2066
|
+
get pixelHeight() {
|
|
2067
|
+
return this.colorTexture.source.pixelHeight;
|
|
2068
|
+
}
|
|
2069
|
+
get resolution() {
|
|
2070
|
+
return this.colorTexture.source._resolution;
|
|
2071
|
+
}
|
|
2072
|
+
get colorTexture() {
|
|
2073
|
+
return this.colorTextures[0];
|
|
2074
|
+
}
|
|
2075
|
+
onSourceResize(e) {
|
|
2076
|
+
this.resize(e.width, e.height, e._resolution, !0);
|
|
2077
|
+
}
|
|
2078
|
+
/**
|
|
2079
|
+
* This will ensure a depthStencil texture is created for this render target.
|
|
2080
|
+
* Most likely called by the mask system to make sure we have stencil buffer added.
|
|
2081
|
+
* @internal
|
|
2082
|
+
*/
|
|
2083
|
+
ensureDepthStencilTexture() {
|
|
2084
|
+
this.depthStencilTexture || (this.depthStencilTexture = new v({
|
|
2085
|
+
width: this.width,
|
|
2086
|
+
height: this.height,
|
|
2087
|
+
resolution: this.resolution,
|
|
2088
|
+
format: "depth24plus-stencil8",
|
|
2089
|
+
autoGenerateMipmaps: !1,
|
|
2090
|
+
antialias: !1,
|
|
2091
|
+
mipLevelCount: 1
|
|
2092
|
+
// sampleCount: handled by the render target system..
|
|
2093
|
+
}));
|
|
2094
|
+
}
|
|
2095
|
+
resize(e, t, r = this.resolution, s = !1) {
|
|
2096
|
+
this.dirtyId++, this.colorTextures.forEach((n, i) => {
|
|
2097
|
+
s && i === 0 || n.source.resize(e, t, r);
|
|
2098
|
+
}), this.depthStencilTexture && this.depthStencilTexture.source.resize(e, t, r);
|
|
2099
|
+
}
|
|
2100
|
+
destroy() {
|
|
2101
|
+
this.colorTexture.source.off("resize", this.onSourceResize, this), this._managedColorTextures && this.colorTextures.forEach((e) => {
|
|
2102
|
+
e.destroy();
|
|
2103
|
+
}), this.depthStencilTexture && (this.depthStencilTexture.destroy(), delete this.depthStencilTexture);
|
|
2104
|
+
}
|
|
2105
|
+
};
|
|
2106
|
+
De.defaultOptions = {
|
|
2107
|
+
/** the width of the RenderTarget */
|
|
2108
|
+
width: 0,
|
|
2109
|
+
/** the height of the RenderTarget */
|
|
2110
|
+
height: 0,
|
|
2111
|
+
/** the resolution of the RenderTarget */
|
|
2112
|
+
resolution: 1,
|
|
2113
|
+
/** an array of textures, or a number indicating how many color textures there should be */
|
|
2114
|
+
colorTextures: 1,
|
|
2115
|
+
/** should this render target have a stencil buffer? */
|
|
2116
|
+
stencil: !1,
|
|
2117
|
+
/** should this render target have a depth buffer? */
|
|
2118
|
+
depth: !1,
|
|
2119
|
+
/** should this render target be antialiased? */
|
|
2120
|
+
antialias: !1,
|
|
2121
|
+
// save on perf by default!
|
|
2122
|
+
/** is this a root element, true if this is gl context owners render target */
|
|
2123
|
+
isRoot: !1
|
|
2124
|
+
};
|
|
2125
|
+
let F = De;
|
|
2126
|
+
const b = /* @__PURE__ */ new Map();
|
|
2127
|
+
rt.register(b);
|
|
2128
|
+
function Oe(a, e) {
|
|
2129
|
+
if (!b.has(a)) {
|
|
2130
|
+
const t = new f({
|
|
2131
|
+
source: new O({
|
|
2132
|
+
resource: a,
|
|
2133
|
+
...e
|
|
2134
|
+
})
|
|
2135
|
+
}), r = () => {
|
|
2136
|
+
b.get(a) === t && b.delete(a);
|
|
2137
|
+
};
|
|
2138
|
+
t.once("destroy", r), t.source.once("destroy", r), b.set(a, t);
|
|
2139
|
+
}
|
|
2140
|
+
return b.get(a);
|
|
2141
|
+
}
|
|
2142
|
+
const Z = class Le {
|
|
2143
|
+
/**
|
|
2144
|
+
* Whether CSS dimensions of canvas view should be resized to screen dimensions automatically.
|
|
2145
|
+
* This is only supported for HTMLCanvasElement and will be ignored if the canvas is an OffscreenCanvas.
|
|
2146
|
+
* @type {boolean}
|
|
2147
|
+
*/
|
|
2148
|
+
get autoDensity() {
|
|
2149
|
+
return this.texture.source.autoDensity;
|
|
2150
|
+
}
|
|
2151
|
+
set autoDensity(e) {
|
|
2152
|
+
this.texture.source.autoDensity = e;
|
|
2153
|
+
}
|
|
2154
|
+
/** The resolution / device pixel ratio of the renderer. */
|
|
2155
|
+
get resolution() {
|
|
2156
|
+
return this.texture.source._resolution;
|
|
2157
|
+
}
|
|
2158
|
+
set resolution(e) {
|
|
2159
|
+
this.texture.source.resize(
|
|
2160
|
+
this.texture.source.width,
|
|
2161
|
+
this.texture.source.height,
|
|
2162
|
+
e
|
|
2163
|
+
);
|
|
2164
|
+
}
|
|
2165
|
+
/**
|
|
2166
|
+
* initiates the view system
|
|
2167
|
+
* @param options - the options for the view
|
|
2168
|
+
*/
|
|
2169
|
+
init(e) {
|
|
2170
|
+
e = {
|
|
2171
|
+
...Le.defaultOptions,
|
|
2172
|
+
...e
|
|
2173
|
+
}, e.view && (p(st, "ViewSystem.view has been renamed to ViewSystem.canvas"), e.canvas = e.view), this.screen = new B(0, 0, e.width, e.height), this.canvas = e.canvas || N.get().createCanvas(), this.antialias = !!e.antialias, this.texture = Oe(this.canvas, e), this.renderTarget = new F({
|
|
2174
|
+
colorTextures: [this.texture],
|
|
2175
|
+
depth: !!e.depth,
|
|
2176
|
+
isRoot: !0
|
|
2177
|
+
}), this.texture.source.transparent = e.backgroundAlpha < 1, this.resolution = e.resolution;
|
|
2178
|
+
}
|
|
2179
|
+
/**
|
|
2180
|
+
* Resizes the screen and canvas to the specified dimensions.
|
|
2181
|
+
* @param desiredScreenWidth - The new width of the screen.
|
|
2182
|
+
* @param desiredScreenHeight - The new height of the screen.
|
|
2183
|
+
* @param resolution
|
|
2184
|
+
*/
|
|
2185
|
+
resize(e, t, r) {
|
|
2186
|
+
this.texture.source.resize(e, t, r), this.screen.width = this.texture.frame.width, this.screen.height = this.texture.frame.height;
|
|
2187
|
+
}
|
|
2188
|
+
/**
|
|
2189
|
+
* Destroys this System and optionally removes the canvas from the dom.
|
|
2190
|
+
* @param {options | false} options - The options for destroying the view, or "false".
|
|
2191
|
+
* @example
|
|
2192
|
+
* viewSystem.destroy();
|
|
2193
|
+
* viewSystem.destroy(true);
|
|
2194
|
+
* viewSystem.destroy({ removeView: true });
|
|
2195
|
+
*/
|
|
2196
|
+
destroy(e = !1) {
|
|
2197
|
+
(typeof e == "boolean" ? e : !!(e != null && e.removeView)) && this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas), this.texture.destroy();
|
|
2198
|
+
}
|
|
2199
|
+
};
|
|
2200
|
+
Z.extension = {
|
|
2201
|
+
type: [
|
|
2202
|
+
l.WebGLSystem,
|
|
2203
|
+
l.WebGPUSystem,
|
|
2204
|
+
l.CanvasSystem
|
|
2205
|
+
],
|
|
2206
|
+
name: "view",
|
|
2207
|
+
priority: 0
|
|
2208
|
+
};
|
|
2209
|
+
Z.defaultOptions = {
|
|
2210
|
+
/**
|
|
2211
|
+
* {@link WebGLOptions.width}
|
|
2212
|
+
* @default 800
|
|
2213
|
+
*/
|
|
2214
|
+
width: 800,
|
|
2215
|
+
/**
|
|
2216
|
+
* {@link WebGLOptions.height}
|
|
2217
|
+
* @default 600
|
|
2218
|
+
*/
|
|
2219
|
+
height: 600,
|
|
2220
|
+
/**
|
|
2221
|
+
* {@link WebGLOptions.autoDensity}
|
|
2222
|
+
* @default false
|
|
2223
|
+
*/
|
|
2224
|
+
autoDensity: !1,
|
|
2225
|
+
/**
|
|
2226
|
+
* {@link WebGLOptions.antialias}
|
|
2227
|
+
* @default false
|
|
2228
|
+
*/
|
|
2229
|
+
antialias: !1
|
|
2230
|
+
};
|
|
2231
|
+
let St = Z;
|
|
2232
|
+
const Gt = [
|
|
2233
|
+
mt,
|
|
2234
|
+
Ue,
|
|
2235
|
+
X,
|
|
2236
|
+
St,
|
|
2237
|
+
Se,
|
|
2238
|
+
yt,
|
|
2239
|
+
Rt,
|
|
2240
|
+
Be,
|
|
2241
|
+
gt,
|
|
2242
|
+
nt,
|
|
2243
|
+
Mt,
|
|
2244
|
+
Ae
|
|
2245
|
+
], Ut = [
|
|
2246
|
+
ke,
|
|
2247
|
+
_e,
|
|
2248
|
+
Ce,
|
|
2249
|
+
ye,
|
|
2250
|
+
xe,
|
|
2251
|
+
Te,
|
|
2252
|
+
be,
|
|
2253
|
+
ve
|
|
2254
|
+
];
|
|
2255
|
+
function wt(a, e, t, r, s, n) {
|
|
2256
|
+
const i = n ? 1 : -1;
|
|
2257
|
+
return a.identity(), a.a = 1 / r * 2, a.d = i * (1 / s * 2), a.tx = -1 - e * a.a, a.ty = -i - t * a.d, a;
|
|
2258
|
+
}
|
|
2259
|
+
function Pt(a) {
|
|
2260
|
+
const e = a.colorTexture.source.resource;
|
|
2261
|
+
return globalThis.HTMLCanvasElement && e instanceof HTMLCanvasElement && document.body.contains(e);
|
|
2262
|
+
}
|
|
2263
|
+
class At {
|
|
2264
|
+
constructor(e) {
|
|
2265
|
+
this.rootViewPort = new B(), this.viewport = new B(), 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");
|
|
2266
|
+
}
|
|
2267
|
+
/** called when dev wants to finish a render pass */
|
|
2268
|
+
finishRenderPass() {
|
|
2269
|
+
this.adaptor.finishRenderPass(this.renderTarget);
|
|
2270
|
+
}
|
|
2271
|
+
/**
|
|
2272
|
+
* called when the renderer starts to render a scene.
|
|
2273
|
+
* @param options
|
|
2274
|
+
* @param options.target - the render target to render to
|
|
2275
|
+
* @param options.clear - the clear mode to use. Can be true or a CLEAR number 'COLOR | DEPTH | STENCIL' 0b111
|
|
2276
|
+
* @param options.clearColor - the color to clear to
|
|
2277
|
+
* @param options.frame - the frame to render to
|
|
2278
|
+
* @param options.mipLevel - the mip level to render to
|
|
2279
|
+
* @param options.layer - The layer of the render target to render to. Used for array or 3D textures, or when rendering
|
|
2280
|
+
* to a specific layer of a layered render target. Optional.
|
|
2281
|
+
*/
|
|
2282
|
+
renderStart({
|
|
2283
|
+
target: e,
|
|
2284
|
+
clear: t,
|
|
2285
|
+
clearColor: r,
|
|
2286
|
+
frame: s,
|
|
2287
|
+
mipLevel: n,
|
|
2288
|
+
layer: i
|
|
2289
|
+
}) {
|
|
2290
|
+
var o, d;
|
|
2291
|
+
this._renderTargetStack.length = 0, this.push(
|
|
2292
|
+
e,
|
|
2293
|
+
t,
|
|
2294
|
+
r,
|
|
2295
|
+
s,
|
|
2296
|
+
n ?? 0,
|
|
2297
|
+
i ?? 0
|
|
2298
|
+
), this.rootViewPort.copyFrom(this.viewport), this.rootRenderTarget = this.renderTarget, this.renderingToScreen = Pt(this.rootRenderTarget), (d = (o = this.adaptor).prerender) == null || d.call(o, this.rootRenderTarget);
|
|
2299
|
+
}
|
|
2300
|
+
postrender() {
|
|
2301
|
+
var e, t;
|
|
2302
|
+
(t = (e = this.adaptor).postrender) == null || t.call(e, this.rootRenderTarget);
|
|
2303
|
+
}
|
|
2304
|
+
/**
|
|
2305
|
+
* Binding a render surface! This is the main function of the render target system.
|
|
2306
|
+
* It will take the RenderSurface (which can be a texture, canvas, or render target) and bind it to the renderer.
|
|
2307
|
+
* Once bound all draw calls will be rendered to the render surface.
|
|
2308
|
+
*
|
|
2309
|
+
* If a frame is not provided and the render surface is a {@link Texture}, the frame of the texture will be used.
|
|
2310
|
+
*
|
|
2311
|
+
* IMPORTANT:
|
|
2312
|
+
* - `frame` is treated as **base mip (mip 0) pixel space**.
|
|
2313
|
+
* - When `mipLevel > 0`, the viewport derived from `frame` is scaled by \(2^{mipLevel}\) and clamped to the
|
|
2314
|
+
* mip dimensions. This keeps "render the same region" semantics consistent across mip levels.
|
|
2315
|
+
* - When `renderSurface` is a {@link Texture}, `renderer.render({ container, target: texture, mipLevel })` will
|
|
2316
|
+
* render into
|
|
2317
|
+
* the underlying {@link TextureSource} (Pixi will create/use a {@link RenderTarget} for the source) using the
|
|
2318
|
+
* texture's frame to define the region (in mip 0 space).
|
|
2319
|
+
* @param renderSurface - the render surface to bind
|
|
2320
|
+
* @param clear - the clear mode to use. Can be true or a CLEAR number 'COLOR | DEPTH | STENCIL' 0b111
|
|
2321
|
+
* @param clearColor - the color to clear to
|
|
2322
|
+
* @param frame - the frame to render to
|
|
2323
|
+
* @param mipLevel - the mip level to render to
|
|
2324
|
+
* @param layer - the layer (or slice) of the render surface to render to. For array textures,
|
|
2325
|
+
* 3D textures, or cubemaps, this specifies the target layer or face. Defaults to 0 (the first layer/face).
|
|
2326
|
+
* Ignored for surfaces that do not support layers.
|
|
2327
|
+
* @returns the render target that was bound
|
|
2328
|
+
*/
|
|
2329
|
+
bind(e, t = !0, r, s, n = 0, i = 0) {
|
|
2330
|
+
const o = this.getRenderTarget(e), d = this.renderTarget !== o;
|
|
2331
|
+
this.renderTarget = o, this.renderSurface = e;
|
|
2332
|
+
const c = this.getGpuRenderTarget(o);
|
|
2333
|
+
(o.pixelWidth !== c.width || o.pixelHeight !== c.height) && (this.adaptor.resizeGpuRenderTarget(o), c.width = o.pixelWidth, c.height = o.pixelHeight);
|
|
2334
|
+
const h = o.colorTexture, u = this.viewport, G = h.arrayLayerCount || 1;
|
|
2335
|
+
if ((i | 0) !== i && (i |= 0), i < 0 || i >= G)
|
|
2336
|
+
throw new Error(`[RenderTargetSystem] layer ${i} is out of bounds (arrayLayerCount=${G}).`);
|
|
2337
|
+
this.mipLevel = n | 0, this.layer = i | 0;
|
|
2338
|
+
const _ = Math.max(h.pixelWidth >> n, 1), x = Math.max(h.pixelHeight >> n, 1);
|
|
2339
|
+
if (!s && e instanceof f && (s = e.frame), s) {
|
|
2340
|
+
const C = h._resolution, k = 1 << Math.max(n | 0, 0), He = s.x * C + 0.5 | 0, Fe = s.y * C + 0.5 | 0, We = s.width * C + 0.5 | 0, ze = s.height * C + 0.5 | 0;
|
|
2341
|
+
let M = Math.floor(He / k), R = Math.floor(Fe / k), U = Math.ceil(We / k), A = Math.ceil(ze / k);
|
|
2342
|
+
M = Math.min(Math.max(M, 0), _ - 1), R = Math.min(Math.max(R, 0), x - 1), U = Math.min(Math.max(U, 1), _ - M), A = Math.min(Math.max(A, 1), x - R), u.x = M, u.y = R, u.width = U, u.height = A;
|
|
2343
|
+
} else
|
|
2344
|
+
u.x = 0, u.y = 0, u.width = _, u.height = x;
|
|
2345
|
+
return wt(
|
|
2346
|
+
this.projectionMatrix,
|
|
2347
|
+
0,
|
|
2348
|
+
0,
|
|
2349
|
+
u.width / h.resolution,
|
|
2350
|
+
u.height / h.resolution,
|
|
2351
|
+
!o.isRoot
|
|
2352
|
+
), this.adaptor.startRenderPass(o, t, r, u, n, i), d && this.onRenderTargetChange.emit(o), o;
|
|
2353
|
+
}
|
|
2354
|
+
clear(e, t = D.ALL, r, s = this.mipLevel, n = this.layer) {
|
|
2355
|
+
t && (e && (e = this.getRenderTarget(e)), this.adaptor.clear(
|
|
2356
|
+
e || this.renderTarget,
|
|
2357
|
+
t,
|
|
2358
|
+
r,
|
|
2359
|
+
this.viewport,
|
|
2360
|
+
s,
|
|
2361
|
+
n
|
|
2362
|
+
));
|
|
2363
|
+
}
|
|
2364
|
+
contextChange() {
|
|
2365
|
+
this._gpuRenderTargetHash = /* @__PURE__ */ Object.create(null);
|
|
2366
|
+
}
|
|
2367
|
+
/**
|
|
2368
|
+
* Push a render surface to the renderer. This will bind the render surface to the renderer,
|
|
2369
|
+
* @param renderSurface - the render surface to push
|
|
2370
|
+
* @param clear - the clear mode to use. Can be true or a CLEAR number 'COLOR | DEPTH | STENCIL' 0b111
|
|
2371
|
+
* @param clearColor - the color to clear to
|
|
2372
|
+
* @param frame - the frame to use when rendering to the render surface
|
|
2373
|
+
* @param mipLevel - the mip level to render to
|
|
2374
|
+
* @param layer - The layer of the render surface to render to. For array textures or cube maps, this specifies
|
|
2375
|
+
* which layer or face to target. Defaults to 0 (the first layer).
|
|
2376
|
+
*/
|
|
2377
|
+
push(e, t = D.ALL, r, s, n = 0, i = 0) {
|
|
2378
|
+
const o = this.bind(e, t, r, s, n, i);
|
|
2379
|
+
return this._renderTargetStack.push({
|
|
2380
|
+
renderTarget: o,
|
|
2381
|
+
frame: s,
|
|
2382
|
+
mipLevel: n,
|
|
2383
|
+
layer: i
|
|
2384
|
+
}), o;
|
|
2385
|
+
}
|
|
2386
|
+
/** Pops the current render target from the renderer and restores the previous render target. */
|
|
2387
|
+
pop() {
|
|
2388
|
+
this._renderTargetStack.pop();
|
|
2389
|
+
const e = this._renderTargetStack[this._renderTargetStack.length - 1];
|
|
2390
|
+
this.bind(
|
|
2391
|
+
e.renderTarget,
|
|
2392
|
+
!1,
|
|
2393
|
+
null,
|
|
2394
|
+
e.frame,
|
|
2395
|
+
e.mipLevel,
|
|
2396
|
+
e.layer
|
|
2397
|
+
);
|
|
2398
|
+
}
|
|
2399
|
+
/**
|
|
2400
|
+
* Gets the render target from the provide render surface. Eg if its a texture,
|
|
2401
|
+
* it will return the render target for the texture.
|
|
2402
|
+
* If its a render target, it will return the same render target.
|
|
2403
|
+
* @param renderSurface - the render surface to get the render target for
|
|
2404
|
+
* @returns the render target for the render surface
|
|
2405
|
+
*/
|
|
2406
|
+
getRenderTarget(e) {
|
|
2407
|
+
return e.isTexture && (e = e.source), this._renderSurfaceToRenderTargetHash.get(e) ?? this._initRenderTarget(e);
|
|
2408
|
+
}
|
|
2409
|
+
/**
|
|
2410
|
+
* Copies a render surface to another texture.
|
|
2411
|
+
*
|
|
2412
|
+
* NOTE:
|
|
2413
|
+
* for sourceRenderSurfaceTexture, The render target must be something that is written too by the renderer
|
|
2414
|
+
*
|
|
2415
|
+
* The following is not valid:
|
|
2416
|
+
* @example
|
|
2417
|
+
* const canvas = document.createElement('canvas')
|
|
2418
|
+
* canvas.width = 200;
|
|
2419
|
+
* canvas.height = 200;
|
|
2420
|
+
*
|
|
2421
|
+
* const ctx = canvas2.getContext('2d')!
|
|
2422
|
+
* ctx.fillStyle = 'red'
|
|
2423
|
+
* ctx.fillRect(0, 0, 200, 200);
|
|
2424
|
+
*
|
|
2425
|
+
* const texture = RenderTexture.create({
|
|
2426
|
+
* width: 200,
|
|
2427
|
+
* height: 200,
|
|
2428
|
+
* })
|
|
2429
|
+
* const renderTarget = renderer.renderTarget.getRenderTarget(canvas2);
|
|
2430
|
+
*
|
|
2431
|
+
* renderer.renderTarget.copyToTexture(renderTarget,texture, {x:0,y:0},{width:200,height:200},{x:0,y:0});
|
|
2432
|
+
*
|
|
2433
|
+
* The best way to copy a canvas is to create a texture from it. Then render with that.
|
|
2434
|
+
*
|
|
2435
|
+
* Parsing in a RenderTarget canvas context (with a 2d context)
|
|
2436
|
+
* @param sourceRenderSurfaceTexture - the render surface to copy from
|
|
2437
|
+
* @param {Texture} destinationTexture - the texture to copy to
|
|
2438
|
+
* @param {object} originSrc - the origin of the copy
|
|
2439
|
+
* @param {number} originSrc.x - the x origin of the copy
|
|
2440
|
+
* @param {number} originSrc.y - the y origin of the copy
|
|
2441
|
+
* @param {object} size - the size of the copy
|
|
2442
|
+
* @param {number} size.width - the width of the copy
|
|
2443
|
+
* @param {number} size.height - the height of the copy
|
|
2444
|
+
* @param {object} originDest - the destination origin (top left to paste from!)
|
|
2445
|
+
* @param {number} originDest.x - the x origin of the paste
|
|
2446
|
+
* @param {number} originDest.y - the y origin of the paste
|
|
2447
|
+
*/
|
|
2448
|
+
copyToTexture(e, t, r, s, n) {
|
|
2449
|
+
r.x < 0 && (s.width += r.x, n.x -= r.x, r.x = 0), r.y < 0 && (s.height += r.y, n.y -= r.y, r.y = 0);
|
|
2450
|
+
const { pixelWidth: i, pixelHeight: o } = e;
|
|
2451
|
+
return s.width = Math.min(s.width, i - r.x), s.height = Math.min(s.height, o - r.y), this.adaptor.copyToTexture(
|
|
2452
|
+
e,
|
|
2453
|
+
t,
|
|
2454
|
+
r,
|
|
2455
|
+
s,
|
|
2456
|
+
n
|
|
2457
|
+
);
|
|
2458
|
+
}
|
|
2459
|
+
/**
|
|
2460
|
+
* ensures that we have a depth stencil buffer available to render to
|
|
2461
|
+
* This is used by the mask system to make sure we have a stencil buffer.
|
|
2462
|
+
*/
|
|
2463
|
+
ensureDepthStencil() {
|
|
2464
|
+
this.renderTarget.stencil || (this.renderTarget.stencil = !0, this.adaptor.startRenderPass(this.renderTarget, !1, null, this.viewport, 0, this.layer));
|
|
2465
|
+
}
|
|
2466
|
+
/** nukes the render target system */
|
|
2467
|
+
destroy() {
|
|
2468
|
+
this._renderer = null, this._renderSurfaceToRenderTargetHash.forEach((e, t) => {
|
|
2469
|
+
e !== t && e.destroy();
|
|
2470
|
+
}), this._renderSurfaceToRenderTargetHash.clear(), this._gpuRenderTargetHash = /* @__PURE__ */ Object.create(null);
|
|
2471
|
+
}
|
|
2472
|
+
_initRenderTarget(e) {
|
|
2473
|
+
let t = null;
|
|
2474
|
+
return O.test(e) && (e = Oe(e).source), e instanceof F ? t = e : e instanceof v && (t = new F({
|
|
2475
|
+
colorTextures: [e]
|
|
2476
|
+
}), e.source instanceof O && (t.isRoot = !0), e.once("destroy", () => {
|
|
2477
|
+
t.destroy(), this._renderSurfaceToRenderTargetHash.delete(e);
|
|
2478
|
+
const r = this._gpuRenderTargetHash[t.uid];
|
|
2479
|
+
r && (this._gpuRenderTargetHash[t.uid] = null, this.adaptor.destroyGpuRenderTarget(r));
|
|
2480
|
+
})), this._renderSurfaceToRenderTargetHash.set(e, t), t;
|
|
2481
|
+
}
|
|
2482
|
+
getGpuRenderTarget(e) {
|
|
2483
|
+
return this._gpuRenderTargetHash[e.uid] || (this._gpuRenderTargetHash[e.uid] = this.adaptor.initGpuRenderTarget(e));
|
|
2484
|
+
}
|
|
2485
|
+
resetState() {
|
|
2486
|
+
this.renderTarget = null, this.renderSurface = null;
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
export {
|
|
2490
|
+
xe as A,
|
|
2491
|
+
ke as B,
|
|
2492
|
+
ve as C,
|
|
2493
|
+
At as R,
|
|
2494
|
+
Gt as S,
|
|
2495
|
+
_e as a,
|
|
2496
|
+
Ce as b,
|
|
2497
|
+
ye as c,
|
|
2498
|
+
Ut as d
|
|
2499
|
+
};
|
|
2500
|
+
//# sourceMappingURL=RenderTargetSystem-B-GzTxxb.js.map
|