Jump to content

offscreen canvas


Granaat
 Share

Recommended Posts

If you know how to work with OffscreenCanvas, you can use it with pixi. I know that people used pixi in webworker to render something on main screen even without it :) As for code in pixi that is related to OffscreenCanvas, its only for TextMetrics and for creating texture out of it https://github.com/pixijs/pixi.js/blob/dev/packages/core/src/textures/resources/CanvasResource.js . You can call "Texture.from(myCanvas)"  and then "update()" it when you made changes to canvas, that's all. Is there anything else you need ?

I just want to point that we are not the framework that covers everything and forbids users to hack its components and use html5 api's directly. PixiJS is a library that is supposed to be used with WebGL and canvas2d API's in heavy cases. You can manually call texImage2D when its needed, you can even use another renderer (skia, threejs, anything) with it, in same or in another context.

Link to comment
Share on other sites

I've used offscreenCanvas before without pixi  with no problems.

problem is, my project is in angular. All drawings that are made with pixi in the main thread render without any issues, but the worker gives me the 'Uncaught ReferenceError: window is not defined' error whenever I create a pixi oject

Any examples of pixi usage in an offscreencanvas you know of?

 

Link to comment
Share on other sites

Oh, right, you need to patch pixi that way it doesnt reference "window". Yes, there are projects that use pixi as worker, I guess they manually pathched all occurences of "window".

I can just tell you its all possible and I used OffscreenCanvas for certain things too, it has 2d context in chromium, always accelerated: for simple canvas its 50/50, depends on your getImageData usage.

As for why isn't pixi support it from the start, well, even basic usage for textmetrics made a problem for us => that feature can't be put in vanilla before someone spends a lot of time on it and covers all the possible problems.

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...