Granaat Posted September 10, 2019 Share Posted September 10, 2019 Is transerControlToOffscreen & offscreencanvas still not supported in pixi.js? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 11, 2019 Share Posted September 11, 2019 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. Quote Link to comment Share on other sites More sharing options...
Granaat Posted September 11, 2019 Author Share Posted September 11, 2019 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? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 11, 2019 Share Posted September 11, 2019 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.