@kolkrabbi/design-editor 0.2.0 → 0.3.1

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.
Files changed (34) hide show
  1. package/README.md +41 -26
  2. package/dist/{BufferResource-CKQMSOM4.js → BufferResource-BfLgK37S.js} +42 -34
  3. package/dist/{CanvasPool-ilDNHrRx.js → CanvasPool-YNSF8hsR.js} +9 -9
  4. package/dist/CanvasRenderer-Bl0rlqNq.js +2 -0
  5. package/dist/{browserAll-CJ593myQ.js → FederatedEventTarget-BJgROaRQ.js} +119 -127
  6. package/dist/FilterSystem-BUrPNXx-.js +1323 -0
  7. package/dist/{Geometry-D3fkwmax.js → Geometry-C5s5KpWq.js} +492 -411
  8. package/dist/{OrbitControls-CE3qSrHQ.js → OrbitControls-Cql8Rn2i.js} +1944 -1914
  9. package/dist/{RenderTargetSystem-umK0aqrs.js → RenderTargetSystem-oFwWv5IW.js} +1107 -612
  10. package/dist/WebGLRenderer-CXxpVIx3.js +2 -0
  11. package/dist/WebGPURenderer-BwLEUYBa.js +2 -0
  12. package/dist/browserAll-CAzdTUbR.js +6 -0
  13. package/dist/canvasUtils-BoNfkAod.js +168 -0
  14. package/dist/{rolldown-runtime-B0aSnxlc.js → chunk-3b4jIN3o.js} +4 -11
  15. package/dist/design-editor.css +2 -2
  16. package/dist/design-editor.js +7675 -8478
  17. package/dist/{getTextureBatchBindGroup-ChWkOJ3t.js → getTextureBatchBindGroup-CNWhZRbV.js} +5 -5
  18. package/dist/{host-6EhdLf5-.js → host-CVR9RL_W.js} +8 -6
  19. package/dist/{host-DPFYZP9I.js → host-be1CWhN1.js} +4 -2
  20. package/dist/init-jApIMi04.js +4 -0
  21. package/dist/{phase-D3rwI6OO.js → phase-t_DhU5Nm.js} +2 -2
  22. package/dist/pipeline-CMpuPUaX.js +11995 -0
  23. package/dist/{src-zDOFeQWX.js → src-QwKcYKfv.js} +747 -746
  24. package/dist/webworkerAll-DEZhpG90.js +2 -0
  25. package/package.json +33 -27
  26. package/LICENSE +0 -21
  27. package/dist/CanvasRenderer-CDbc3nH9.js +0 -3396
  28. package/dist/WebGLRenderer-DVKPZbKc.js +0 -2145
  29. package/dist/WebGPURenderer-DHSBocAL.js +0 -1656
  30. package/dist/canvasUtils-CXoNqK7T.js +0 -168
  31. package/dist/defaultFilter.vert-C9efGgir.js +0 -888
  32. package/dist/init-4Y6mtayI.js +0 -441
  33. package/dist/pipeline-DfTD40M-.js +0 -4825
  34. package/dist/webworkerAll-wTH3MKcZ.js +0 -2
@@ -1,441 +0,0 @@
1
- import { B as e, C as t, K as n, Q as r, c as i, f as a, i as o, it as s, l as c, rt as l, s as u, t as d, u as f, w as p } from "./Geometry-D3fkwmax.js";
2
- import { t as m } from "./defaultFilter.vert-C9efGgir.js";
3
- import { t as h } from "./canvasUtils-CXoNqK7T.js";
4
- import { t as g } from "./CanvasPool-ilDNHrRx.js";
5
- //#region node_modules/.pnpm/pixi.js@8.19.0/node_modules/pixi.js/lib/scene/container/bounds/getRenderableBounds.mjs
6
- var _ = new r();
7
- function v(e, t) {
8
- t.clear();
9
- let n = t.matrix;
10
- for (let n = 0; n < e.length; n++) {
11
- let r = e[n];
12
- if (r.globalDisplayStatus < 7) continue;
13
- let i = r.renderGroup ?? r.parentRenderGroup;
14
- t.matrix = i?.isCachedAsTexture ? _.copyFrom(i.textureOffsetInverseTransform).append(r.worldTransform) : i?._parentCacheAsTextureRenderGroup ? _.copyFrom(i._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(r.groupTransform) : r.worldTransform, t.addBounds(r.bounds);
15
- }
16
- return t.matrix = n, t;
17
- }
18
- //#endregion
19
- //#region node_modules/.pnpm/pixi.js@8.19.0/node_modules/pixi.js/lib/scene/text/utils/getPo2TextureFromSource.mjs
20
- var y = new e();
21
- function b(e, n, r, i, a = !1) {
22
- let o = y;
23
- o.minX = 0, o.minY = 0, o.maxX = e.width / i | 0, o.maxY = e.height / i | 0;
24
- let s = t.getOptimalTexture(o.width, o.height, i, !1, a);
25
- return s.source.uploadMethodId = "image", s.source.resource = e, s.source.alphaMode = "premultiply-alpha-on-upload", s.frame.width = n / i, s.frame.height = r / i, s.source.emit("update", s.source), s.updateUvs(), s;
26
- }
27
- //#endregion
28
- //#region node_modules/.pnpm/pixi.js@8.19.0/node_modules/pixi.js/lib/filters/CanvasFilterSystem.mjs
29
- function x(e) {
30
- return typeof e.getCanvasFilterString == "function";
31
- }
32
- var S = class {
33
- constructor() {
34
- this.skip = !1, this.useClip = !1, this.filters = null, this.container = null, this.bounds = new e(), this.cssFilterString = "";
35
- }
36
- }, C = class {
37
- constructor(e) {
38
- this._filterStack = [], this._filterStackIndex = 0, this._savedStates = [], this._alphaMultiplier = 1, this._warnedFilterTypes = /* @__PURE__ */ new Set(), this.renderer = e;
39
- }
40
- push(e) {
41
- let t = this._pushFilterFrame(), n = e.filterEffect.filters;
42
- if (t.skip = !1, t.useClip = !1, t.filters = n, t.container = e.container, t.cssFilterString = "", n.every((e) => !e.enabled)) {
43
- t.skip = !0;
44
- return;
45
- }
46
- let r = [];
47
- for (let e of n) {
48
- if (!e.enabled) continue;
49
- if (!x(e)) {
50
- this._warnUnsupportedFilter(e);
51
- continue;
52
- }
53
- let t = e.getCanvasFilterString();
54
- if (t === null) {
55
- this._warnUnsupportedFilter(e);
56
- continue;
57
- }
58
- t && r.push(t);
59
- }
60
- if (r.length === 0) {
61
- t.skip = !0;
62
- return;
63
- }
64
- t.cssFilterString = r.join(" "), this._calculateFilterArea(e, t.bounds), t.useClip = !!e.filterEffect.filterArea;
65
- let i = this.renderer.canvasContext.activeContext, a = i.filter || "none";
66
- if (this._savedStates.push({
67
- filter: a,
68
- alphaMultiplier: this._alphaMultiplier
69
- }), t.useClip && Number.isFinite(t.bounds.width) && Number.isFinite(t.bounds.height) && t.bounds.width > 0 && t.bounds.height > 0) {
70
- let e = this.renderer.canvasContext.activeResolution || 1;
71
- i.save(), i.setTransform(1, 0, 0, 1, 0, 0), i.beginPath(), i.rect(t.bounds.x * e, t.bounds.y * e, t.bounds.width * e, t.bounds.height * e), i.clip();
72
- } else t.useClip = !1;
73
- t.cssFilterString && (i.filter = a === "none" ? t.cssFilterString : `${a} ${t.cssFilterString}`);
74
- }
75
- pop() {
76
- let e = this._popFilterFrame();
77
- if (e.skip) return;
78
- let t = this._savedStates.pop();
79
- if (!t) return;
80
- let n = this.renderer.canvasContext.activeContext;
81
- e.useClip ? n.restore() : n.filter = t.filter, this._alphaMultiplier = t.alphaMultiplier;
82
- }
83
- generateFilteredTexture({ texture: e, filters: t }) {
84
- if (!t?.length || t.every((e) => !e.enabled)) return e;
85
- let n = [];
86
- for (let e of t) {
87
- if (!e.enabled) continue;
88
- if (!x(e)) {
89
- this._warnUnsupportedFilter(e);
90
- continue;
91
- }
92
- let t = e.getCanvasFilterString();
93
- if (t === null) {
94
- this._warnUnsupportedFilter(e);
95
- continue;
96
- }
97
- t && n.push(t);
98
- }
99
- if (n.length === 0) return e;
100
- let r = h.getCanvasSource(e);
101
- if (!r) return e;
102
- let i = e.frame, a = e.source._resolution ?? e.source.resolution ?? 1, o = i.width, s = i.height, { canvas: c, context: l } = g.getOptimalCanvasAndContext(o, s, a);
103
- l.setTransform(1, 0, 0, 1, 0, 0), l.clearRect(0, 0, c.width, c.height), n.length && (l.filter = n.join(" "));
104
- let u = i.x * a, d = i.y * a, f = o * a, p = s * a;
105
- return l.drawImage(r, u, d, f, p, 0, 0, f, p), l.filter = "none", l.globalAlpha = 1, b(c, o, s, a);
106
- }
107
- _calculateFilterArea(e, t) {
108
- if (e.renderables ? v(e.renderables, t) : e.filterEffect.filterArea ? (t.clear(), t.addRect(e.filterEffect.filterArea), t.applyMatrix(e.container.worldTransform)) : e.container.getFastGlobalBounds(!0, t), e.container) {
109
- let n = (e.container.renderGroup || e.container.parentRenderGroup)?.cacheToLocalTransform;
110
- n && t.applyMatrix(n);
111
- }
112
- }
113
- _warnUnsupportedFilter(e) {
114
- let t = e?.constructor?.name || "Filter";
115
- this._warnedFilterTypes.has(t) || (this._warnedFilterTypes.add(t), console.warn(`CanvasRenderer: filter "${t}" is not supported in Canvas2D and will be skipped.`));
116
- }
117
- get alphaMultiplier() {
118
- return this._alphaMultiplier;
119
- }
120
- _pushFilterFrame() {
121
- let e = this._filterStack[this._filterStackIndex];
122
- return e ||= this._filterStack[this._filterStackIndex] = new S(), this._filterStackIndex++, e;
123
- }
124
- _popFilterFrame() {
125
- return this._filterStackIndex <= 0 ? this._filterStack[0] : (this._filterStackIndex--, this._filterStack[this._filterStackIndex]);
126
- }
127
- destroy() {
128
- this._filterStack = null, this._savedStates = null, this._warnedFilterTypes = null, this._alphaMultiplier = 1;
129
- }
130
- };
131
- C.extension = {
132
- type: [l.CanvasSystem],
133
- name: "filter"
134
- };
135
- //#endregion
136
- //#region node_modules/.pnpm/pixi.js@8.19.0/node_modules/pixi.js/lib/filters/FilterPipe.mjs
137
- var w = class {
138
- constructor(e) {
139
- this._renderer = e;
140
- }
141
- push(e, t, n) {
142
- this._renderer.renderPipes.batch.break(n), n.add({
143
- renderPipeId: "filter",
144
- canBundle: !1,
145
- action: "pushFilter",
146
- container: t,
147
- filterEffect: e
148
- });
149
- }
150
- pop(e, t, n) {
151
- this._renderer.renderPipes.batch.break(n), n.add({
152
- renderPipeId: "filter",
153
- action: "popFilter",
154
- canBundle: !1
155
- });
156
- }
157
- execute(e) {
158
- e.action === "pushFilter" ? this._renderer.filter.push(e) : e.action === "popFilter" && this._renderer.filter.pop();
159
- }
160
- destroy() {
161
- this._renderer = null;
162
- }
163
- };
164
- w.extension = {
165
- type: [
166
- l.WebGLPipes,
167
- l.WebGPUPipes,
168
- l.CanvasPipes
169
- ],
170
- name: "filter"
171
- };
172
- //#endregion
173
- //#region node_modules/.pnpm/pixi.js@8.19.0/node_modules/pixi.js/lib/filters/defaults/passthrough/passthrough.frag.mjs
174
- var T = "in vec2 vTextureCoord;\nout vec4 finalColor;\nuniform sampler2D uTexture;\nvoid main() {\n finalColor = texture(uTexture, vTextureCoord);\n}\n", E = "struct GlobalFilterUniforms {\n uInputSize: vec4<f32>,\n uInputPixel: vec4<f32>,\n uInputClamp: vec4<f32>,\n uOutputFrame: vec4<f32>,\n uGlobalFrame: vec4<f32>,\n uOutputTexture: vec4<f32>,\n};\n\n@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;\n@group(0) @binding(1) var uTexture: texture_2d<f32>;\n@group(0) @binding(2) var uSampler: sampler;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv: vec2<f32>\n};\n\nfn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>\n{\n var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>\n{\n return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\n@vertex\nfn mainVertex(\n @location(0) aPosition: vec2<f32>,\n) -> VSOutput {\n return VSOutput(\n filterVertexPosition(aPosition),\n filterTextureCoord(aPosition)\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n) -> @location(0) vec4<f32> {\n return textureSample(uTexture, uSampler, uv);\n}\n", D = class extends o {
175
- constructor() {
176
- let e = f.from({
177
- vertex: {
178
- source: E,
179
- entryPoint: "mainVertex"
180
- },
181
- fragment: {
182
- source: E,
183
- entryPoint: "mainFragment"
184
- },
185
- name: "passthrough-filter"
186
- }), t = a.from({
187
- vertex: m,
188
- fragment: T,
189
- name: "passthrough-filter"
190
- });
191
- super({
192
- gpuProgram: e,
193
- glProgram: t
194
- });
195
- }
196
- }, O = new d({
197
- attributes: { aPosition: {
198
- buffer: new Float32Array([
199
- 0,
200
- 0,
201
- 1,
202
- 0,
203
- 1,
204
- 1,
205
- 0,
206
- 1
207
- ]),
208
- format: "float32x2",
209
- stride: 8,
210
- offset: 0
211
- } },
212
- indexBuffer: new Uint32Array([
213
- 0,
214
- 1,
215
- 2,
216
- 0,
217
- 2,
218
- 3
219
- ])
220
- }), k = class {
221
- constructor() {
222
- this.skip = !1, this.inputTexture = null, this.backTexture = null, this.filters = null, this.bounds = new e(), this.container = null, this.blendRequired = !1, this.outputRenderSurface = null, this.globalFrame = {
223
- x: 0,
224
- y: 0,
225
- width: 0,
226
- height: 0
227
- }, this.firstEnabledIndex = -1, this.lastEnabledIndex = -1;
228
- }
229
- }, A = class {
230
- constructor(e) {
231
- this._filterStackIndex = 0, this._filterStack = [], this._filterGlobalUniforms = new u({
232
- uInputSize: {
233
- value: /* @__PURE__ */ new Float32Array(4),
234
- type: "vec4<f32>"
235
- },
236
- uInputPixel: {
237
- value: /* @__PURE__ */ new Float32Array(4),
238
- type: "vec4<f32>"
239
- },
240
- uInputClamp: {
241
- value: /* @__PURE__ */ new Float32Array(4),
242
- type: "vec4<f32>"
243
- },
244
- uOutputFrame: {
245
- value: /* @__PURE__ */ new Float32Array(4),
246
- type: "vec4<f32>"
247
- },
248
- uGlobalFrame: {
249
- value: /* @__PURE__ */ new Float32Array(4),
250
- type: "vec4<f32>"
251
- },
252
- uOutputTexture: {
253
- value: /* @__PURE__ */ new Float32Array(4),
254
- type: "vec4<f32>"
255
- }
256
- }), this._globalFilterBindGroup = new c({}), this.renderer = e;
257
- }
258
- get activeBackTexture() {
259
- return this._activeFilterData?.backTexture;
260
- }
261
- push(e) {
262
- let t = this.renderer, n = e.filterEffect.filters, r = this._pushFilterData();
263
- r.skip = !1, r.filters = n, r.container = e.container, r.outputRenderSurface = t.renderTarget.renderSurface;
264
- let i = t.renderTarget.renderTarget.colorTexture.source, a = i.resolution, o = i.antialias;
265
- if (n.every((e) => !e.enabled)) {
266
- r.skip = !0;
267
- return;
268
- }
269
- let s = r.bounds;
270
- if (this._calculateFilterArea(e, s), this._calculateFilterBounds(r, t.renderTarget.rootViewPort, o, a, 1), r.skip) return;
271
- let c = this._getPreviousFilterData(), l = this._findFilterResolution(a), u = 0, d = 0;
272
- c && (u = c.bounds.minX, d = c.bounds.minY), this._calculateGlobalFrame(r, u, d, l, i.width, i.height), this._setupFilterTextures(r, s, t, c);
273
- }
274
- generateFilteredTexture({ texture: e, filters: n }) {
275
- let r = this._pushFilterData();
276
- this._activeFilterData = r, r.skip = !1, r.filters = n;
277
- let i = e.source, a = i.resolution, o = i.antialias;
278
- if (n.every((e) => !e.enabled)) return r.skip = !0, e;
279
- let s = r.bounds;
280
- if (s.addRect(e.frame), this._calculateFilterBounds(r, s.rectangle, o, a, 0), r.skip) return e;
281
- let c = a;
282
- this._calculateGlobalFrame(r, 0, 0, c, i.width, i.height), r.outputRenderSurface = t.getOptimalTexture(s.width, s.height, r.resolution, r.antialias), r.backTexture = p.EMPTY, r.inputTexture = e, this.renderer.renderTarget.finishRenderPass(), this._applyFiltersToTexture(r, !0);
283
- let l = r.outputRenderSurface;
284
- return l.source.alphaMode = "premultiplied-alpha", l;
285
- }
286
- pop() {
287
- let e = this.renderer, n = this._popFilterData();
288
- n.skip || (e.globalUniforms.pop(), e.renderTarget.finishRenderPass(), this._activeFilterData = n, this._applyFiltersToTexture(n, !1), n.blendRequired && t.returnTexture(n.backTexture), t.returnTexture(n.inputTexture));
289
- }
290
- getBackTexture(e, n, r) {
291
- let i = e.colorTexture.source._resolution, a = t.getOptimalTexture(n.width, n.height, i, !1), o = n.minX, s = n.minY;
292
- r && (o -= r.minX, s -= r.minY), o = Math.floor(o * i), s = Math.floor(s * i);
293
- let c = Math.ceil(n.width * i), l = Math.ceil(n.height * i);
294
- return this.renderer.renderTarget.copyToTexture(e, a, {
295
- x: o,
296
- y: s
297
- }, {
298
- width: c,
299
- height: l
300
- }, {
301
- x: 0,
302
- y: 0
303
- }), a;
304
- }
305
- applyFilter(e, t, n, r) {
306
- let i = this.renderer, a = this._activeFilterData, o = a.outputRenderSurface === n, s = i.renderTarget.rootRenderTarget.colorTexture.source._resolution, c = this._findFilterResolution(s), l = 0, u = 0;
307
- if (o) {
308
- let e = this._findPreviousFilterOffset();
309
- l = e.x, u = e.y;
310
- }
311
- this._updateFilterUniforms(t, n, a, l, u, c, o, r);
312
- let d = e.enabled ? e : this._getPassthroughFilter();
313
- this._setupBindGroupsAndRender(d, t, i);
314
- }
315
- calculateSpriteMatrix(e, t) {
316
- let n = this._activeFilterData, i = e.set(n.inputTexture._source.width, 0, 0, n.inputTexture._source.height, n.bounds.minX, n.bounds.minY), a = t.worldTransform.copyTo(r.shared), o = t.renderGroup || t.parentRenderGroup;
317
- return o && o.cacheToLocalTransform && a.prepend(o.cacheToLocalTransform), a.invert(), i.prepend(a), i.scale(1 / t.texture.orig.width, 1 / t.texture.orig.height), i.translate(t.anchor.x, t.anchor.y), i;
318
- }
319
- destroy() {
320
- this._passthroughFilter?.destroy(!0), this._passthroughFilter = null;
321
- }
322
- _getPassthroughFilter() {
323
- return this._passthroughFilter ??= new D(), this._passthroughFilter;
324
- }
325
- _setupBindGroupsAndRender(e, t, n) {
326
- if (n.renderPipes.uniformBatch) {
327
- let e = n.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);
328
- this._globalFilterBindGroup.setResource(e, 0);
329
- } else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms, 0);
330
- this._globalFilterBindGroup.setResource(t.source, 1), this._globalFilterBindGroup.setResource(t.source.style, 2), e.groups[0] = this._globalFilterBindGroup, n.encoder.draw({
331
- geometry: O,
332
- shader: e,
333
- state: e._state,
334
- topology: "triangle-list"
335
- }), n.type === i.WEBGL && n.renderTarget.finishRenderPass();
336
- }
337
- _setupFilterTextures(e, n, r, i) {
338
- if (e.backTexture = p.EMPTY, e.inputTexture = t.getOptimalTexture(n.width, n.height, e.resolution, e.antialias), e.blendRequired) {
339
- r.renderTarget.finishRenderPass();
340
- let t = r.renderTarget.getRenderTarget(e.outputRenderSurface);
341
- e.backTexture = this.getBackTexture(t, n, i?.bounds);
342
- }
343
- r.renderTarget.bind(e.inputTexture, !0), r.globalUniforms.push({ offset: n });
344
- }
345
- _calculateGlobalFrame(e, t, n, r, i, a) {
346
- let o = e.globalFrame;
347
- o.x = t * r, o.y = n * r, o.width = i * r, o.height = a * r;
348
- }
349
- _updateFilterUniforms(e, t, n, r, i, a, o, s) {
350
- let c = this._filterGlobalUniforms.uniforms, l = c.uOutputFrame, u = c.uInputSize, d = c.uInputPixel, f = c.uInputClamp, m = c.uGlobalFrame, h = c.uOutputTexture;
351
- o ? (l[0] = n.bounds.minX - r, l[1] = n.bounds.minY - i) : (l[0] = 0, l[1] = 0), l[2] = e.frame.width, l[3] = e.frame.height, u[0] = e.source.width, u[1] = e.source.height, u[2] = 1 / u[0], u[3] = 1 / u[1], d[0] = e.source.pixelWidth, d[1] = e.source.pixelHeight, d[2] = 1 / d[0], d[3] = 1 / d[1], f[0] = .5 * d[2], f[1] = .5 * d[3], f[2] = e.frame.width * u[2] - .5 * d[2], f[3] = e.frame.height * u[3] - .5 * d[3];
352
- let g = this.renderer.renderTarget.rootRenderTarget.colorTexture;
353
- m[0] = r * a, m[1] = i * a, m[2] = g.source.width * a, m[3] = g.source.height * a, t instanceof p && (t.source.resource = null);
354
- let _ = this.renderer.renderTarget.getRenderTarget(t);
355
- this.renderer.renderTarget.bind(t, !!s), t instanceof p ? (h[0] = t.frame.width, h[1] = t.frame.height) : (h[0] = _.width, h[1] = _.height), h[2] = _.isRoot ? -1 : 1, this._filterGlobalUniforms.update();
356
- }
357
- _findFilterResolution(e) {
358
- let t = this._filterStackIndex - 1;
359
- for (; t > 0 && this._filterStack[t].skip;) --t;
360
- return t > 0 && this._filterStack[t].inputTexture ? this._filterStack[t].inputTexture.source._resolution : e;
361
- }
362
- _findPreviousFilterOffset() {
363
- let e = 0, t = 0, n = this._filterStackIndex;
364
- for (; n > 0;) {
365
- n--;
366
- let r = this._filterStack[n];
367
- if (!r.skip) {
368
- e = r.bounds.minX, t = r.bounds.minY;
369
- break;
370
- }
371
- }
372
- return {
373
- x: e,
374
- y: t
375
- };
376
- }
377
- _calculateFilterArea(e, t) {
378
- if (e.renderables ? v(e.renderables, t) : e.filterEffect.filterArea ? (t.clear(), t.addRect(e.filterEffect.filterArea), t.applyMatrix(e.container.worldTransform)) : e.container.getFastGlobalBounds(!0, t), e.container) {
379
- let n = (e.container.renderGroup || e.container.parentRenderGroup).cacheToLocalTransform;
380
- n && t.applyMatrix(n);
381
- }
382
- }
383
- _applyFiltersToTexture(e, n) {
384
- let r = e.inputTexture, i = e.bounds, a = e.filters, o = e.firstEnabledIndex, s = e.lastEnabledIndex;
385
- if (this._globalFilterBindGroup.setResource(r.source.style, 2), this._globalFilterBindGroup.setResource(e.backTexture.source, 3), o === s) a[o].apply(this, r, e.outputRenderSurface, n);
386
- else {
387
- let r = e.inputTexture, c = t.getOptimalTexture(i.width, i.height, r.source._resolution, !1), l = c;
388
- for (let e = o; e < s; e++) {
389
- let t = a[e];
390
- if (!t.enabled) continue;
391
- t.apply(this, r, l, !0);
392
- let n = r;
393
- r = l, l = n;
394
- }
395
- a[s].apply(this, r, e.outputRenderSurface, n), t.returnTexture(c);
396
- }
397
- }
398
- _calculateFilterBounds(e, t, r, i, a) {
399
- let o = this.renderer, s = e.bounds, c = e.filters, l = Infinity, u = 0, d = !0, f = !1, p = !1, m = !0, h = -1, g = -1;
400
- for (let e = 0; e < c.length; e++) {
401
- let t = c[e];
402
- if (t.enabled) {
403
- if (h === -1 && (h = e), g = e, l = Math.min(l, t.resolution === "inherit" ? i : t.resolution), u += t.padding, t.antialias === "off" ? d = !1 : t.antialias === "inherit" && (d &&= r), t.clipToViewport || (m = !1), !(t.compatibleRenderers & o.type)) {
404
- p = !1;
405
- break;
406
- }
407
- if (t.blendRequired && !(o.backBuffer?.useBackBuffer ?? !0)) {
408
- n("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."), p = !1;
409
- break;
410
- }
411
- p = !0, f ||= t.blendRequired;
412
- }
413
- }
414
- if (!p) {
415
- e.skip = !0;
416
- return;
417
- }
418
- if (m && s.fitBounds(0, t.width / i, 0, t.height / i), s.scale(l).ceil().scale(1 / l).pad((u | 0) * a), !s.isPositive) {
419
- e.skip = !0;
420
- return;
421
- }
422
- e.antialias = d, e.resolution = l, e.blendRequired = f, e.firstEnabledIndex = h, e.lastEnabledIndex = g;
423
- }
424
- _popFilterData() {
425
- return this._filterStackIndex--, this._filterStack[this._filterStackIndex];
426
- }
427
- _getPreviousFilterData() {
428
- let e, t = this._filterStackIndex - 1;
429
- for (; t > 0 && (t--, e = this._filterStack[t], e.skip););
430
- return e;
431
- }
432
- _pushFilterData() {
433
- let e = this._filterStack[this._filterStackIndex];
434
- return e ||= this._filterStack[this._filterStackIndex] = new k(), this._filterStackIndex++, e;
435
- }
436
- };
437
- A.extension = {
438
- type: [l.WebGLSystem, l.WebGPUSystem],
439
- name: "filter"
440
- }, s.add(A, C), s.add(w);
441
- //#endregion