Rodrigo Posted November 20, 2017 Share Posted November 20, 2017 Hi, I'd like to know if there could be any unwanted consequences or behavior if I comment out the error thrown when a frame doesn't fit in the base texture:https://github.com/pixijs/pixi.js/blob/dev/src/core/textures/Texture.js#L567 The thing is that I'm getting the error between the 8th or 10th decimal, something like this: 20.3333333333 + 20.6666666668 > 41 A brief description of what I'm doing is working with responsive images that are sliced by a specific amount of horizontal slices (depending on the screen height), each slice is an integer. Since the images are scaled before slicing the real size has to be corrected by that scale which leads to this numbers with all those decimal positions. Would be even noticeable if the error is commented out?. Could be possible for PIXI to throw an error after creating the slices in another situation?. The slices are moved by the user with touch events and the problem always appears in the final slice and for some specific image sizes and screen resolutions. Unfortunately I don't have any control over the image size. I don't know how many decimals PIXI actually needs in order to work properly, but this is math versus rendering. The math indicates that the number is bigger, no questions there, but with rendering in mind, will the 8th or 10th decimal of a pixel does even get rendered?. does it make a difference?, is it noticeable even in retina screens?. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted November 20, 2017 Share Posted November 20, 2017 You can set "this._frame" and "this.orig" manually and call "this._updateUvs()" after that. Or you can override "frame" property in "PIXI.Texture.prototype". That code really doesn't accound for rounding errors it. PIXI is supposed to be hacked, either from outside plugin either by making fork if there are enough big changes. Its not a black box, its open-source library made for people who want their own engine, you save the time by using our expertise that certainly doesnt cover all the cases people need. If your fix is good enough to be added in the library, make a pull request. As for partial pixels, yes, linear filtering takes care of that. You have to learn webgl and look up which command pixi use for sprite rendering to understand that. Quote Link to comment Share on other sites More sharing options...
Rodrigo Posted November 20, 2017 Author Share Posted November 20, 2017 Thanks for the answer Ivan. I'll try with a console warning with the measurements to know when and by how much the frame doesn't fit and check if it produces any subsequent errors. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted November 20, 2017 Share Posted November 20, 2017 Just add "eps=1e-7" there and it'll be fine. 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.