Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: v8 bug with pushing filters #447

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions examples/src/DemoApplication.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
// Setup the container
this.pond = new PIXI.Container();
this.pond.filterArea = this.filterArea;
this.pond.filters = this.pondFilters;
this.stage.addChild(this.pond);

// Setup the background image
Expand Down Expand Up @@ -208,8 +207,6 @@

this.events.emit('animate', delta, animateTimer);

this.pond.filters = this.pondFilters;

if (!this.animating)
{
return;
Expand All @@ -224,7 +221,6 @@
const fish = this.fishes[i];

fish.direction += fish.turnSpeed * 0.01;
fish.filters = this.fishFilters;
fish.x += Math.sin(fish.direction) * fish.speed;
fish.y += Math.cos(fish.direction) * fish.speed;

Expand Down Expand Up @@ -302,28 +298,44 @@
// https://github.com/orgs/pixijs/projects/2/views/4?pane=issue&itemId=48582986
const toggleFilter = (enabled) =>
{
if (enabled)
if (options.fishOnly)
{
if (options.fishOnly)
const fishFilters = [...this.fishFilters];

if (enabled)
{
this.fishFilters.push(filter);
fishFilters.push(filter);
}
else
{
this.pondFilters.push(filter);
}
}
else if (options.fishOnly)
{
const index = this.fishFilters.indexOf(filter);
const index = fishFilters.indexOf(filter);

if (index !== -1) this.fishFilters.splice(index, 1);
if (index !== -1) fishFilters.splice(index, 1);
}
this.fishFilters = fishFilters;
this.fishes.forEach((fish) => {

Check warning on line 316 in examples/src/DemoApplication.mjs

View workflow job for this annotation

GitHub Actions / Build

Opening curly brace appears on the same line as controlling statement

Check warning on line 316 in examples/src/DemoApplication.mjs

View workflow job for this annotation

GitHub Actions / Build

Trailing spaces not allowed

Check warning on line 316 in examples/src/DemoApplication.mjs

View workflow job for this annotation

GitHub Actions / Build

Opening curly brace appears on the same line as controlling statement

Check warning on line 316 in examples/src/DemoApplication.mjs

View workflow job for this annotation

GitHub Actions / Build

Trailing spaces not allowed
fish.filters = fishFilters;
});
}
else
{
const index = this.pondFilters.indexOf(filter);
const pondFilters = [...this.pondFilters];

if (enabled)
{
pondFilters.push(filter);
}
else
{
const index = pondFilters.indexOf(filter);

if (index !== -1) pondFilters.splice(index, 1);
}

if (index !== -1) this.pondFilters.splice(index, 1);
this.pondFilters = pondFilters;
// TODO: seems like a bug, requiring invalidation
this.pond.filters = [];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GoodBoyDigital any idea why we'd need to invalidate the filters before applying them? This doesn't work without this line.

this.pond.filters = pondFilters;
}
};

Expand Down
Loading