@industry-theme/repository-composition-panels 0.7.15 → 0.7.17

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 (39) hide show
  1. package/dist/browserAll-BWR83R0-.js +7 -0
  2. package/dist/browserAll-BWR83R0-.js.map +1 -0
  3. package/dist/{index-pPFTSf2O.js → index-BsDrFty7.js} +16159 -704
  4. package/dist/{index-pPFTSf2O.js.map → index-BsDrFty7.js.map} +1 -1
  5. package/dist/index.d.ts +2 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/init-BViSvzO2.js +4 -0
  8. package/dist/init-BViSvzO2.js.map +1 -0
  9. package/dist/panels/CollectionMapPanel.d.ts.map +1 -1
  10. package/dist/panels/overworld-map/OverworldMapPanel.d.ts.map +1 -1
  11. package/dist/panels/overworld-map/components/IsometricRenderer.d.ts.map +1 -1
  12. package/dist/panels/overworld-map/components/RepoSprite.d.ts +51 -0
  13. package/dist/panels/overworld-map/components/RepoSprite.d.ts.map +1 -0
  14. package/dist/panels/overworld-map/index.d.ts +3 -1
  15. package/dist/panels/overworld-map/index.d.ts.map +1 -1
  16. package/dist/panels.bundle.js +32 -31
  17. package/dist/webworkerAll-DkB5mV_6.js +3 -0
  18. package/dist/webworkerAll-DkB5mV_6.js.map +1 -0
  19. package/package.json +1 -1
  20. package/dist/BufferResource-DME1VWVJ.js +0 -593
  21. package/dist/BufferResource-DME1VWVJ.js.map +0 -1
  22. package/dist/CanvasRenderer-Md8Ayshs.js +0 -1525
  23. package/dist/CanvasRenderer-Md8Ayshs.js.map +0 -1
  24. package/dist/Filter-Bi2t_gmW.js +0 -81
  25. package/dist/Filter-Bi2t_gmW.js.map +0 -1
  26. package/dist/RenderTargetSystem-D98tiHim.js +0 -3046
  27. package/dist/RenderTargetSystem-D98tiHim.js.map +0 -1
  28. package/dist/WebGLRenderer-2YtxQhbh.js +0 -3884
  29. package/dist/WebGLRenderer-2YtxQhbh.js.map +0 -1
  30. package/dist/WebGPURenderer-kS6gO2Xc.js +0 -2142
  31. package/dist/WebGPURenderer-kS6gO2Xc.js.map +0 -1
  32. package/dist/browserAll-TZZf5l7B.js +0 -2687
  33. package/dist/browserAll-TZZf5l7B.js.map +0 -1
  34. package/dist/init-CfSmqCnm.js +0 -670
  35. package/dist/init-CfSmqCnm.js.map +0 -1
  36. package/dist/panels/overworld-map/spriteGenerator.d.ts +0 -53
  37. package/dist/panels/overworld-map/spriteGenerator.d.ts.map +0 -1
  38. package/dist/webworkerAll-TcJuZTza.js +0 -3
  39. package/dist/webworkerAll-TcJuZTza.js.map +0 -1
@@ -1,670 +0,0 @@
1
- import { G as GpuProgram, b as GlProgram, E as ExtensionType, M as Matrix, U as UniformGroup, B as BindGroup, T as TexturePool, c as Texture, d as Geometry, R as RendererType, w as warn, e as Bounds, f as extensions } from "./index-pPFTSf2O.js";
2
- import { F as Filter } from "./Filter-Bi2t_gmW.js";
3
- var vertex = "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";
4
- var fragment = "in vec2 vTextureCoord;\nout vec4 finalColor;\nuniform sampler2D uTexture;\nvoid main() {\n finalColor = texture(uTexture, vTextureCoord);\n}\n";
5
- var source = "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";
6
- class PassthroughFilter extends Filter {
7
- constructor() {
8
- const gpuProgram = GpuProgram.from({
9
- vertex: { source, entryPoint: "mainVertex" },
10
- fragment: { source, entryPoint: "mainFragment" },
11
- name: "passthrough-filter"
12
- });
13
- const glProgram = GlProgram.from({
14
- vertex,
15
- fragment,
16
- name: "passthrough-filter"
17
- });
18
- super({
19
- gpuProgram,
20
- glProgram
21
- });
22
- }
23
- }
24
- class FilterPipe {
25
- constructor(renderer) {
26
- this._renderer = renderer;
27
- }
28
- push(filterEffect, container, instructionSet) {
29
- const renderPipes = this._renderer.renderPipes;
30
- renderPipes.batch.break(instructionSet);
31
- instructionSet.add({
32
- renderPipeId: "filter",
33
- canBundle: false,
34
- action: "pushFilter",
35
- container,
36
- filterEffect
37
- });
38
- }
39
- pop(_filterEffect, _container, instructionSet) {
40
- this._renderer.renderPipes.batch.break(instructionSet);
41
- instructionSet.add({
42
- renderPipeId: "filter",
43
- action: "popFilter",
44
- canBundle: false
45
- });
46
- }
47
- execute(instruction) {
48
- if (instruction.action === "pushFilter") {
49
- this._renderer.filter.push(instruction);
50
- } else if (instruction.action === "popFilter") {
51
- this._renderer.filter.pop();
52
- }
53
- }
54
- destroy() {
55
- this._renderer = null;
56
- }
57
- }
58
- FilterPipe.extension = {
59
- type: [
60
- ExtensionType.WebGLPipes,
61
- ExtensionType.WebGPUPipes,
62
- ExtensionType.CanvasPipes
63
- ],
64
- name: "filter"
65
- };
66
- const tempProjectionMatrix = new Matrix();
67
- function getGlobalRenderableBounds(renderables, bounds) {
68
- bounds.clear();
69
- const actualMatrix = bounds.matrix;
70
- for (let i = 0; i < renderables.length; i++) {
71
- const renderable = renderables[i];
72
- if (renderable.globalDisplayStatus < 7) {
73
- continue;
74
- }
75
- const renderGroup = renderable.renderGroup ?? renderable.parentRenderGroup;
76
- if (renderGroup == null ? void 0 : renderGroup.isCachedAsTexture) {
77
- bounds.matrix = tempProjectionMatrix.copyFrom(renderGroup.textureOffsetInverseTransform).append(renderable.worldTransform);
78
- } else if (renderGroup == null ? void 0 : renderGroup._parentCacheAsTextureRenderGroup) {
79
- bounds.matrix = tempProjectionMatrix.copyFrom(renderGroup._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(renderable.groupTransform);
80
- } else {
81
- bounds.matrix = renderable.worldTransform;
82
- }
83
- bounds.addBounds(renderable.bounds);
84
- }
85
- bounds.matrix = actualMatrix;
86
- return bounds;
87
- }
88
- const quadGeometry = new Geometry({
89
- attributes: {
90
- aPosition: {
91
- buffer: new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]),
92
- format: "float32x2",
93
- stride: 2 * 4,
94
- offset: 0
95
- }
96
- },
97
- indexBuffer: new Uint32Array([0, 1, 2, 0, 2, 3])
98
- });
99
- class FilterData {
100
- constructor() {
101
- this.skip = false;
102
- this.inputTexture = null;
103
- this.backTexture = null;
104
- this.filters = null;
105
- this.bounds = new Bounds();
106
- this.container = null;
107
- this.blendRequired = false;
108
- this.outputRenderSurface = null;
109
- this.globalFrame = { x: 0, y: 0, width: 0, height: 0 };
110
- this.firstEnabledIndex = -1;
111
- this.lastEnabledIndex = -1;
112
- }
113
- }
114
- class FilterSystem {
115
- constructor(renderer) {
116
- this._filterStackIndex = 0;
117
- this._filterStack = [];
118
- this._filterGlobalUniforms = new UniformGroup({
119
- uInputSize: { value: new Float32Array(4), type: "vec4<f32>" },
120
- uInputPixel: { value: new Float32Array(4), type: "vec4<f32>" },
121
- uInputClamp: { value: new Float32Array(4), type: "vec4<f32>" },
122
- uOutputFrame: { value: new Float32Array(4), type: "vec4<f32>" },
123
- uGlobalFrame: { value: new Float32Array(4), type: "vec4<f32>" },
124
- uOutputTexture: { value: new Float32Array(4), type: "vec4<f32>" }
125
- });
126
- this._globalFilterBindGroup = new BindGroup({});
127
- this.renderer = renderer;
128
- }
129
- /**
130
- * The back texture of the currently active filter. Requires the filter to have `blendRequired` set to true.
131
- * @readonly
132
- */
133
- get activeBackTexture() {
134
- var _a;
135
- return (_a = this._activeFilterData) == null ? void 0 : _a.backTexture;
136
- }
137
- /**
138
- * Pushes a filter instruction onto the filter stack.
139
- * @param instruction - The instruction containing the filter effect and container.
140
- * @internal
141
- */
142
- push(instruction) {
143
- const renderer = this.renderer;
144
- const filters = instruction.filterEffect.filters;
145
- const filterData = this._pushFilterData();
146
- filterData.skip = false;
147
- filterData.filters = filters;
148
- filterData.container = instruction.container;
149
- filterData.outputRenderSurface = renderer.renderTarget.renderSurface;
150
- const colorTextureSource = renderer.renderTarget.renderTarget.colorTexture.source;
151
- const rootResolution = colorTextureSource.resolution;
152
- const rootAntialias = colorTextureSource.antialias;
153
- if (filters.every((filter) => !filter.enabled)) {
154
- filterData.skip = true;
155
- return;
156
- }
157
- const bounds = filterData.bounds;
158
- this._calculateFilterArea(instruction, bounds);
159
- this._calculateFilterBounds(filterData, renderer.renderTarget.rootViewPort, rootAntialias, rootResolution, 1);
160
- if (filterData.skip) {
161
- return;
162
- }
163
- const previousFilterData = this._getPreviousFilterData();
164
- const globalResolution = this._findFilterResolution(rootResolution);
165
- let offsetX = 0;
166
- let offsetY = 0;
167
- if (previousFilterData) {
168
- offsetX = previousFilterData.bounds.minX;
169
- offsetY = previousFilterData.bounds.minY;
170
- }
171
- this._calculateGlobalFrame(
172
- filterData,
173
- offsetX,
174
- offsetY,
175
- globalResolution,
176
- colorTextureSource.width,
177
- colorTextureSource.height
178
- );
179
- this._setupFilterTextures(filterData, bounds, renderer, previousFilterData);
180
- }
181
- /**
182
- * Applies filters to a texture.
183
- *
184
- * This method takes a texture and a list of filters, applies the filters to the texture,
185
- * and returns the resulting texture.
186
- * @param {object} params - The parameters for applying filters.
187
- * @param {Texture} params.texture - The texture to apply filters to.
188
- * @param {Filter[]} params.filters - The filters to apply.
189
- * @returns {Texture} The resulting texture after all filters have been applied.
190
- * @example
191
- *
192
- * ```ts
193
- * // Create a texture and a list of filters
194
- * const texture = new Texture(...);
195
- * const filters = [new BlurFilter(), new ColorMatrixFilter()];
196
- *
197
- * // Apply the filters to the texture
198
- * const resultTexture = filterSystem.applyToTexture({ texture, filters });
199
- *
200
- * // Use the resulting texture
201
- * sprite.texture = resultTexture;
202
- * ```
203
- *
204
- * Key Points:
205
- * 1. padding is not currently supported here - so clipping may occur with filters that use padding.
206
- * 2. If all filters are disabled or skipped, the original texture is returned.
207
- */
208
- generateFilteredTexture({ texture, filters }) {
209
- const filterData = this._pushFilterData();
210
- this._activeFilterData = filterData;
211
- filterData.skip = false;
212
- filterData.filters = filters;
213
- const colorTextureSource = texture.source;
214
- const rootResolution = colorTextureSource.resolution;
215
- const rootAntialias = colorTextureSource.antialias;
216
- if (filters.every((filter) => !filter.enabled)) {
217
- filterData.skip = true;
218
- return texture;
219
- }
220
- const bounds = filterData.bounds;
221
- bounds.addRect(texture.frame);
222
- this._calculateFilterBounds(filterData, bounds.rectangle, rootAntialias, rootResolution, 0);
223
- if (filterData.skip) {
224
- return texture;
225
- }
226
- const globalResolution = rootResolution;
227
- const offsetX = 0;
228
- const offsetY = 0;
229
- this._calculateGlobalFrame(
230
- filterData,
231
- offsetX,
232
- offsetY,
233
- globalResolution,
234
- colorTextureSource.width,
235
- colorTextureSource.height
236
- );
237
- filterData.outputRenderSurface = TexturePool.getOptimalTexture(
238
- bounds.width,
239
- bounds.height,
240
- filterData.resolution,
241
- filterData.antialias
242
- );
243
- filterData.backTexture = Texture.EMPTY;
244
- filterData.inputTexture = texture;
245
- const renderer = this.renderer;
246
- renderer.renderTarget.finishRenderPass();
247
- this._applyFiltersToTexture(filterData, true);
248
- const outputTexture = filterData.outputRenderSurface;
249
- outputTexture.source.alphaMode = "premultiplied-alpha";
250
- return outputTexture;
251
- }
252
- /** @internal */
253
- pop() {
254
- const renderer = this.renderer;
255
- const filterData = this._popFilterData();
256
- if (filterData.skip) {
257
- return;
258
- }
259
- renderer.globalUniforms.pop();
260
- renderer.renderTarget.finishRenderPass();
261
- this._activeFilterData = filterData;
262
- this._applyFiltersToTexture(filterData, false);
263
- if (filterData.blendRequired) {
264
- TexturePool.returnTexture(filterData.backTexture);
265
- }
266
- TexturePool.returnTexture(filterData.inputTexture);
267
- }
268
- /**
269
- * Copies the last render surface to a texture.
270
- * @param lastRenderSurface - The last render surface to copy from.
271
- * @param bounds - The bounds of the area to copy.
272
- * @param previousBounds - The previous bounds to use for offsetting the copy.
273
- */
274
- getBackTexture(lastRenderSurface, bounds, previousBounds) {
275
- const backgroundResolution = lastRenderSurface.colorTexture.source._resolution;
276
- const backTexture = TexturePool.getOptimalTexture(
277
- bounds.width,
278
- bounds.height,
279
- backgroundResolution,
280
- false
281
- );
282
- let x = bounds.minX;
283
- let y = bounds.minY;
284
- if (previousBounds) {
285
- x -= previousBounds.minX;
286
- y -= previousBounds.minY;
287
- }
288
- x = Math.floor(x * backgroundResolution);
289
- y = Math.floor(y * backgroundResolution);
290
- const width = Math.ceil(bounds.width * backgroundResolution);
291
- const height = Math.ceil(bounds.height * backgroundResolution);
292
- this.renderer.renderTarget.copyToTexture(
293
- lastRenderSurface,
294
- backTexture,
295
- { x, y },
296
- { width, height },
297
- { x: 0, y: 0 }
298
- );
299
- return backTexture;
300
- }
301
- /**
302
- * Applies a filter to a texture.
303
- * @param filter - The filter to apply.
304
- * @param input - The input texture.
305
- * @param output - The output render surface.
306
- * @param clear - Whether to clear the output surface before applying the filter.
307
- */
308
- applyFilter(filter, input, output, clear) {
309
- const renderer = this.renderer;
310
- const filterData = this._activeFilterData;
311
- const outputRenderSurface = filterData.outputRenderSurface;
312
- const isFinalTarget = outputRenderSurface === output;
313
- const rootResolution = renderer.renderTarget.rootRenderTarget.colorTexture.source._resolution;
314
- const resolution = this._findFilterResolution(rootResolution);
315
- let offsetX = 0;
316
- let offsetY = 0;
317
- if (isFinalTarget) {
318
- const offset = this._findPreviousFilterOffset();
319
- offsetX = offset.x;
320
- offsetY = offset.y;
321
- }
322
- this._updateFilterUniforms(input, output, filterData, offsetX, offsetY, resolution, isFinalTarget, clear);
323
- const filterToApply = filter.enabled ? filter : this._getPassthroughFilter();
324
- this._setupBindGroupsAndRender(filterToApply, input, renderer);
325
- }
326
- /**
327
- * Multiply _input normalized coordinates_ to this matrix to get _sprite texture normalized coordinates_.
328
- *
329
- * Use `outputMatrix * vTextureCoord` in the shader.
330
- * @param outputMatrix - The matrix to output to.
331
- * @param {Sprite} sprite - The sprite to map to.
332
- * @returns The mapped matrix.
333
- */
334
- calculateSpriteMatrix(outputMatrix, sprite) {
335
- const data = this._activeFilterData;
336
- const mappedMatrix = outputMatrix.set(
337
- data.inputTexture._source.width,
338
- 0,
339
- 0,
340
- data.inputTexture._source.height,
341
- data.bounds.minX,
342
- data.bounds.minY
343
- );
344
- const worldTransform = sprite.worldTransform.copyTo(Matrix.shared);
345
- const renderGroup = sprite.renderGroup || sprite.parentRenderGroup;
346
- if (renderGroup && renderGroup.cacheToLocalTransform) {
347
- worldTransform.prepend(renderGroup.cacheToLocalTransform);
348
- }
349
- worldTransform.invert();
350
- mappedMatrix.prepend(worldTransform);
351
- mappedMatrix.scale(
352
- 1 / sprite.texture.orig.width,
353
- 1 / sprite.texture.orig.height
354
- );
355
- mappedMatrix.translate(sprite.anchor.x, sprite.anchor.y);
356
- return mappedMatrix;
357
- }
358
- destroy() {
359
- var _a;
360
- (_a = this._passthroughFilter) == null ? void 0 : _a.destroy(true);
361
- this._passthroughFilter = null;
362
- }
363
- _getPassthroughFilter() {
364
- this._passthroughFilter ?? (this._passthroughFilter = new PassthroughFilter());
365
- return this._passthroughFilter;
366
- }
367
- /**
368
- * Sets up the bind groups and renders the filter.
369
- * @param filter - The filter to apply
370
- * @param input - The input texture
371
- * @param renderer - The renderer instance
372
- */
373
- _setupBindGroupsAndRender(filter, input, renderer) {
374
- if (renderer.renderPipes.uniformBatch) {
375
- const batchUniforms = renderer.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);
376
- this._globalFilterBindGroup.setResource(batchUniforms, 0);
377
- } else {
378
- this._globalFilterBindGroup.setResource(this._filterGlobalUniforms, 0);
379
- }
380
- this._globalFilterBindGroup.setResource(input.source, 1);
381
- this._globalFilterBindGroup.setResource(input.source.style, 2);
382
- filter.groups[0] = this._globalFilterBindGroup;
383
- renderer.encoder.draw({
384
- geometry: quadGeometry,
385
- shader: filter,
386
- state: filter._state,
387
- topology: "triangle-list"
388
- });
389
- if (renderer.type === RendererType.WEBGL) {
390
- renderer.renderTarget.finishRenderPass();
391
- }
392
- }
393
- /**
394
- * Sets up the filter textures including input texture and back texture if needed.
395
- * @param filterData - The filter data to update
396
- * @param bounds - The bounds for the texture
397
- * @param renderer - The renderer instance
398
- * @param previousFilterData - The previous filter data for back texture calculation
399
- */
400
- _setupFilterTextures(filterData, bounds, renderer, previousFilterData) {
401
- filterData.backTexture = Texture.EMPTY;
402
- filterData.inputTexture = TexturePool.getOptimalTexture(
403
- bounds.width,
404
- bounds.height,
405
- filterData.resolution,
406
- filterData.antialias
407
- );
408
- if (filterData.blendRequired) {
409
- renderer.renderTarget.finishRenderPass();
410
- const renderTarget = renderer.renderTarget.getRenderTarget(filterData.outputRenderSurface);
411
- filterData.backTexture = this.getBackTexture(renderTarget, bounds, previousFilterData == null ? void 0 : previousFilterData.bounds);
412
- }
413
- renderer.renderTarget.bind(filterData.inputTexture, true);
414
- renderer.globalUniforms.push({
415
- offset: bounds
416
- });
417
- }
418
- /**
419
- * Calculates and sets the global frame for the filter.
420
- * @param filterData - The filter data to update
421
- * @param offsetX - The X offset
422
- * @param offsetY - The Y offset
423
- * @param globalResolution - The global resolution
424
- * @param sourceWidth - The source texture width
425
- * @param sourceHeight - The source texture height
426
- */
427
- _calculateGlobalFrame(filterData, offsetX, offsetY, globalResolution, sourceWidth, sourceHeight) {
428
- const globalFrame = filterData.globalFrame;
429
- globalFrame.x = offsetX * globalResolution;
430
- globalFrame.y = offsetY * globalResolution;
431
- globalFrame.width = sourceWidth * globalResolution;
432
- globalFrame.height = sourceHeight * globalResolution;
433
- }
434
- /**
435
- * Updates the filter uniforms with the current filter state.
436
- * @param input - The input texture
437
- * @param output - The output render surface
438
- * @param filterData - The current filter data
439
- * @param offsetX - The X offset for positioning
440
- * @param offsetY - The Y offset for positioning
441
- * @param resolution - The current resolution
442
- * @param isFinalTarget - Whether this is the final render target
443
- * @param clear - Whether to clear the output surface
444
- */
445
- _updateFilterUniforms(input, output, filterData, offsetX, offsetY, resolution, isFinalTarget, clear) {
446
- const uniforms = this._filterGlobalUniforms.uniforms;
447
- const outputFrame = uniforms.uOutputFrame;
448
- const inputSize = uniforms.uInputSize;
449
- const inputPixel = uniforms.uInputPixel;
450
- const inputClamp = uniforms.uInputClamp;
451
- const globalFrame = uniforms.uGlobalFrame;
452
- const outputTexture = uniforms.uOutputTexture;
453
- if (isFinalTarget) {
454
- outputFrame[0] = filterData.bounds.minX - offsetX;
455
- outputFrame[1] = filterData.bounds.minY - offsetY;
456
- } else {
457
- outputFrame[0] = 0;
458
- outputFrame[1] = 0;
459
- }
460
- outputFrame[2] = input.frame.width;
461
- outputFrame[3] = input.frame.height;
462
- inputSize[0] = input.source.width;
463
- inputSize[1] = input.source.height;
464
- inputSize[2] = 1 / inputSize[0];
465
- inputSize[3] = 1 / inputSize[1];
466
- inputPixel[0] = input.source.pixelWidth;
467
- inputPixel[1] = input.source.pixelHeight;
468
- inputPixel[2] = 1 / inputPixel[0];
469
- inputPixel[3] = 1 / inputPixel[1];
470
- inputClamp[0] = 0.5 * inputPixel[2];
471
- inputClamp[1] = 0.5 * inputPixel[3];
472
- inputClamp[2] = input.frame.width * inputSize[2] - 0.5 * inputPixel[2];
473
- inputClamp[3] = input.frame.height * inputSize[3] - 0.5 * inputPixel[3];
474
- const rootTexture = this.renderer.renderTarget.rootRenderTarget.colorTexture;
475
- globalFrame[0] = offsetX * resolution;
476
- globalFrame[1] = offsetY * resolution;
477
- globalFrame[2] = rootTexture.source.width * resolution;
478
- globalFrame[3] = rootTexture.source.height * resolution;
479
- if (output instanceof Texture) output.source.resource = null;
480
- const renderTarget = this.renderer.renderTarget.getRenderTarget(output);
481
- this.renderer.renderTarget.bind(output, !!clear);
482
- if (output instanceof Texture) {
483
- outputTexture[0] = output.frame.width;
484
- outputTexture[1] = output.frame.height;
485
- } else {
486
- outputTexture[0] = renderTarget.width;
487
- outputTexture[1] = renderTarget.height;
488
- }
489
- outputTexture[2] = renderTarget.isRoot ? -1 : 1;
490
- this._filterGlobalUniforms.update();
491
- }
492
- /**
493
- * Finds the correct resolution by looking back through the filter stack.
494
- * @param rootResolution - The fallback root resolution to use
495
- * @returns The resolution from the previous filter or root resolution
496
- */
497
- _findFilterResolution(rootResolution) {
498
- let currentIndex = this._filterStackIndex - 1;
499
- while (currentIndex > 0 && this._filterStack[currentIndex].skip) {
500
- --currentIndex;
501
- }
502
- return currentIndex > 0 && this._filterStack[currentIndex].inputTexture ? this._filterStack[currentIndex].inputTexture.source._resolution : rootResolution;
503
- }
504
- /**
505
- * Finds the offset from the previous non-skipped filter in the stack.
506
- * @returns The offset coordinates from the previous filter
507
- */
508
- _findPreviousFilterOffset() {
509
- let offsetX = 0;
510
- let offsetY = 0;
511
- let lastIndex = this._filterStackIndex;
512
- while (lastIndex > 0) {
513
- lastIndex--;
514
- const prevFilterData = this._filterStack[lastIndex];
515
- if (!prevFilterData.skip) {
516
- offsetX = prevFilterData.bounds.minX;
517
- offsetY = prevFilterData.bounds.minY;
518
- break;
519
- }
520
- }
521
- return { x: offsetX, y: offsetY };
522
- }
523
- /**
524
- * Calculates the filter area bounds based on the instruction type.
525
- * @param instruction - The filter instruction
526
- * @param bounds - The bounds object to populate
527
- */
528
- _calculateFilterArea(instruction, bounds) {
529
- if (instruction.renderables) {
530
- getGlobalRenderableBounds(instruction.renderables, bounds);
531
- } else if (instruction.filterEffect.filterArea) {
532
- bounds.clear();
533
- bounds.addRect(instruction.filterEffect.filterArea);
534
- bounds.applyMatrix(instruction.container.worldTransform);
535
- } else {
536
- instruction.container.getFastGlobalBounds(true, bounds);
537
- }
538
- if (instruction.container) {
539
- const renderGroup = instruction.container.renderGroup || instruction.container.parentRenderGroup;
540
- const filterFrameTransform = renderGroup.cacheToLocalTransform;
541
- if (filterFrameTransform) {
542
- bounds.applyMatrix(filterFrameTransform);
543
- }
544
- }
545
- }
546
- _applyFiltersToTexture(filterData, clear) {
547
- const inputTexture = filterData.inputTexture;
548
- const bounds = filterData.bounds;
549
- const filters = filterData.filters;
550
- const firstEnabled = filterData.firstEnabledIndex;
551
- const lastEnabled = filterData.lastEnabledIndex;
552
- this._globalFilterBindGroup.setResource(inputTexture.source.style, 2);
553
- this._globalFilterBindGroup.setResource(filterData.backTexture.source, 3);
554
- if (firstEnabled === lastEnabled) {
555
- filters[firstEnabled].apply(this, inputTexture, filterData.outputRenderSurface, clear);
556
- } else {
557
- let flip = filterData.inputTexture;
558
- const tempTexture = TexturePool.getOptimalTexture(
559
- bounds.width,
560
- bounds.height,
561
- flip.source._resolution,
562
- false
563
- );
564
- let flop = tempTexture;
565
- for (let i = firstEnabled; i < lastEnabled; i++) {
566
- const filter = filters[i];
567
- if (!filter.enabled) continue;
568
- filter.apply(this, flip, flop, true);
569
- const t = flip;
570
- flip = flop;
571
- flop = t;
572
- }
573
- filters[lastEnabled].apply(this, flip, filterData.outputRenderSurface, clear);
574
- TexturePool.returnTexture(tempTexture);
575
- }
576
- }
577
- _calculateFilterBounds(filterData, viewPort, rootAntialias, rootResolution, paddingMultiplier) {
578
- var _a;
579
- const renderer = this.renderer;
580
- const bounds = filterData.bounds;
581
- const filters = filterData.filters;
582
- let resolution = Infinity;
583
- let padding = 0;
584
- let antialias = true;
585
- let blendRequired = false;
586
- let enabled = false;
587
- let clipToViewport = true;
588
- let firstEnabledIndex = -1;
589
- let lastEnabledIndex = -1;
590
- for (let i = 0; i < filters.length; i++) {
591
- const filter = filters[i];
592
- if (!filter.enabled) continue;
593
- if (firstEnabledIndex === -1) firstEnabledIndex = i;
594
- lastEnabledIndex = i;
595
- resolution = Math.min(resolution, filter.resolution === "inherit" ? rootResolution : filter.resolution);
596
- padding += filter.padding;
597
- if (filter.antialias === "off") {
598
- antialias = false;
599
- } else if (filter.antialias === "inherit") {
600
- antialias && (antialias = rootAntialias);
601
- }
602
- if (!filter.clipToViewport) {
603
- clipToViewport = false;
604
- }
605
- const isCompatible = !!(filter.compatibleRenderers & renderer.type);
606
- if (!isCompatible) {
607
- enabled = false;
608
- break;
609
- }
610
- if (filter.blendRequired && !(((_a = renderer.backBuffer) == null ? void 0 : _a.useBackBuffer) ?? true)) {
611
- warn("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options.");
612
- enabled = false;
613
- break;
614
- }
615
- enabled = true;
616
- blendRequired || (blendRequired = filter.blendRequired);
617
- }
618
- if (!enabled) {
619
- filterData.skip = true;
620
- return;
621
- }
622
- if (clipToViewport) {
623
- bounds.fitBounds(0, viewPort.width / rootResolution, 0, viewPort.height / rootResolution);
624
- }
625
- bounds.scale(resolution).ceil().scale(1 / resolution).pad((padding | 0) * paddingMultiplier);
626
- if (!bounds.isPositive) {
627
- filterData.skip = true;
628
- return;
629
- }
630
- filterData.antialias = antialias;
631
- filterData.resolution = resolution;
632
- filterData.blendRequired = blendRequired;
633
- filterData.firstEnabledIndex = firstEnabledIndex;
634
- filterData.lastEnabledIndex = lastEnabledIndex;
635
- }
636
- _popFilterData() {
637
- this._filterStackIndex--;
638
- return this._filterStack[this._filterStackIndex];
639
- }
640
- _getPreviousFilterData() {
641
- let previousFilterData;
642
- let index = this._filterStackIndex - 1;
643
- while (index > 0) {
644
- index--;
645
- previousFilterData = this._filterStack[index];
646
- if (!previousFilterData.skip) {
647
- break;
648
- }
649
- }
650
- return previousFilterData;
651
- }
652
- _pushFilterData() {
653
- let filterData = this._filterStack[this._filterStackIndex];
654
- if (!filterData) {
655
- filterData = this._filterStack[this._filterStackIndex] = new FilterData();
656
- }
657
- this._filterStackIndex++;
658
- return filterData;
659
- }
660
- }
661
- FilterSystem.extension = {
662
- type: [
663
- ExtensionType.WebGLSystem,
664
- ExtensionType.WebGPUSystem
665
- ],
666
- name: "filter"
667
- };
668
- extensions.add(FilterSystem);
669
- extensions.add(FilterPipe);
670
- //# sourceMappingURL=init-CfSmqCnm.js.map