jakubdev Posted April 22, 2021 Share Posted April 22, 2021 Hello, html5 freaks I trying to make idle game using pixijs, but when I put animated sprite that is 1024x512 in size it freeze game short time. From profiler I saw that texImage2d took 180ms and from that 104ms was imageDecode. I read somewhere to preload the animations before hand and just make them visible when needed, but it didn't work and same texImage2d happend. How I can prevent that other than downscaling the sprite? Also is there possibility to do that in webworker? I read somewhere that pixi is starting to be capable of rendering on webworker. Cheers, Jakub Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 22, 2021 Share Posted April 22, 2021 > I read somewhere to preload the animations before hand and just make them visible when needed basically, PIXI.prepare plugin that actually uses"renderer.texture.bind(myTexture)" . However there is "createImageBitmap" function and you can use it with pixi resources, but we turned it off by default because we dont actually have good async mechanisms to notify user that everything is loaded, and basic "createImageBitmap" usage affected many parts of pixi. You can enable it if you read the source code first, because i dont remember where is this setting > Also is there possibility to do that in webworker? decode? yeah, theoretically, i didnt see apps that use it. Its possible workaround, if you do it and it works - please share your experience. Quote Link to comment Share on other sites More sharing options...
jakubdev Posted April 22, 2021 Author Share Posted April 22, 2021 Thanks just added prepare and everything works smoothly now on animated sprite appers. CreateImageBitmap caused some strange behaviours on sprites that have something transparent. From your experiance do u think utilizing webworker to do pixi work is worth? I already moved http request to webworker, planning to move characters polygons and calculation to webworker, but I read here(https://github.com/pixijs/pixi.js/issues/7123) that some user utilized pixi on webworker and thought why not do something similar also for rendering and leave calculation on main thread. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted April 23, 2021 Share Posted April 23, 2021 > CreateImageBitmap caused some strange behaviours on sprites that have something transparent. welcome to premultiplied alpha. pass a param named like this in this funtio > From your experiance do u think utilizing webworker to do pixi work is worth? No, its not worth it. When its actually worth, it doesnt have to do anything with pixi Quote Link to comment Share on other sites More sharing options...
jakubdev Posted April 23, 2021 Author Share Posted April 23, 2021 Thanks 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.