Jump to content

Setting Container or Sprite mask to a Graphics object freezes browser


Gonzales
 Share

Recommended Posts

Hello!

I am having a hard time trying to mask/clip a square sprite into a round one. Whenever I create a Graphics object then assign it to the `mask` property on a Container or a Sprite, the whole browser freezes up and I can't even debug where the issue is, sometimes my OS even logs me out when my devtools window is still loading up (perhaps due to CPU or RAM overload?)... 😢

Any help would be super appreciated! I've been trying to figure this out for hours!

My code is something like below: 

import * as PIXI from 'pixi.js';

const app = new PIXI.Application({
  width: 600,
  height: 600,
  antialias: true,
});

document.getElementById('root').appendChild(app.view);

const mask = new PIXI.Graphics();
mask.beginFill(0x000000);
mask.drawCircle(200, 200, 150);
mask.endFill();
const container = new PIXI.Container();
container.mask = mask; // If I don't set the mask, everything works OK.

app.stage.addChild(container);

// Sprites have problem too
//
// const sprite = new PIXI.Sprite(/*some texture*/);
// sprite.mask = mask;
// app.stage.addChild(sprite);
// 
// Now open up browser and wait to be logged out :(

 

Link to comment
Share on other sites

3 minutes ago, ivan.popelyshev said:

you should also add mask to the stage, however that's not ethe issue. Try set antialias to "off" , or maybe your device (linux drivers?) dont support webgl STENCIL mode

Wow it really was because of the antialias setting, I never suspected that! Thank you so much! But what can I do if I do need the antialiasing? 

 

 

Link to comment
Share on other sites

2 minutes ago, ivan.popelyshev said:

antialias can make Graphics edges smooth, but its slowing everything

Also I'm still getting used to understanding how Pixi works. May I ask why should I also add mask to the stage? (because I though since the mask is "attached" to the container, when the container is added to the stage, the mask gets added with container)

Thank you!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...