Comments (4)
Thank you for bringing this out. This bug troubled me a lot.
To provide more information, the code I'm using looks like follows:
import * as PIXI from "pixi.js";
(async () => {
const app = new PIXI.Application();
await app.init({ background: "#1099bb", resizeTo: window });
document.body.appendChild(app.canvas);
// create a new Sprite from an image path
const texture = await PIXI.Assets.load("https://pixijs.com/assets/bunny.png");
const bunny = PIXI.Sprite.from(texture);
// center the sprite's anchor point
bunny.anchor.set(0.5);
// move the sprite to the center of the screen
bunny.x = app.screen.width / 2;
bunny.y = app.screen.height / 2;
const stage = new PIXI.Container();
stage.filters = []; // L1
app.stage.addChild(stage);
const container = new PIXI.Container();
container.addChild(bunny);
const filter = new PIXI.ColorMatrixFilter();
container.filters = [filter]; // L2
const wrapper = new PIXI.Container();
wrapper.filters = [];
const useWrapper = false; // L3
if(useWrapper) {
wrapper.addChild(container);
stage.addChild(wrapper);
} else {
stage.addChild(container);
}
const graphic = new PIXI.Graphics();
stage.addChild(graphic); // L4
graphic.rect(-4000, -4000, 8000, 8000).fill({color: 0xffffff, alpha: 0}); // L5
})();
Observations:
- In the original code, the sprite is not shown at all.
- If we comment out L1, the sprite shows and the position is correct. Everything is normal.
- This is the normal case when no empty array is used.
- If we change L2 to
container.filters = [];
, the sprite shows and the position is correct. Everything is normal.- This means if all filters are empty arrays, rendering is good.
- If we change L3 to
const useWrapper = true;
, the sprite shows but the position becomes (0,0);- This means a wrapper with an empty array can fix the visibility issue, but the position is still wrong.
- If we comment out L4, the sprite shows but the position becomes (0,0).
- If we change L5 to
graphic.rect(-200, -200, 8000, 8000).fill({color: 0xffffff, alpha: 0});
, the sprite shows but in the right, bottom corner, rather than the middle of screen.
from pixijs.
thanks for sharing! looking into this now 💯
from pixijs.
I have played more and found that the issue is related to skip
:
pixijs/src/filters/FilterSystem.ts
Lines 141 to 146 in 071a616
A filter array with filters all disabled will gave the same result as an empty array.
The reason I think could be that there is an offset applied to the global transform. When skip
is true, FilterSystem does not directly modify globalUniforms
. However, based on my observation, the coordinate origin is aligned with the last element drawn before popFilter
. I suspect the reason is the following code:
pixijs/src/filters/FilterSystem.ts
Lines 458 to 466 in 071a616
When a second filter is applied, it does not know the previous filter is skipped and still tries to apply the offset.
A quick fix could be to copy the input to the output when filters is empty instead of skipping the rendering.
from pixijs.
This should be fixed in the latest rc.2
from pixijs.
Related Issues (20)
- Assets.init failing HOT 4
- Bug: Uncaught TypeError: Cannot read properties of null (reading '_x') HOT 6
- Graphics not rendering HOT 4
- Feature Request: Video autoPlay for bundle asset loading HOT 2
- Pixi Text not showing the dynamic font loaded through Assets
- Bug: Unexpected Height during Initialization Pixi App HOT 1
- Bug: incorrect text stroke drawing with some fonts HOT 3
- Feature Request: Change the default priorities of the compressed textures formats HOT 1
- Bug: Asset format is not resolved correctly
- Feature Request: Make deprecation() warnings optional HOT 1
- Impossible to set sprite filters as an empty array to then add multiple filters HOT 4
- Feature Request: Is there a way to scale a Graphics without getting the linewidth scaled as well?
- Bug: [v8] Compressed textures are not being rendered HOT 6
- Bug: PIXI.Graphics method lineTo at later call different
- Bug: Argument of type 'Sprite' is not assignable to parameter of type 'DisplayObject'. HOT 5
- Bug: http://gametest.mobi/pixi/morph is down HOT 3
- Bug: Stutter in basic animation on various browsers and OS HOT 1
- Save and load the current state of the application
- Bug: Graphics scaling and adding filters, display abnormal
- Bug:
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pixijs.