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