trsh Posted September 13, 2016 Share Posted September 13, 2016 Any chance to battle those small precision errors? https://jsfiddle.net/u0zgL0va/ (check console -> x:200.39999389648438) Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 13, 2016 Share Posted September 13, 2016 You're very lucky that JS uses double precision. Because if you try to put big coordinates in Graphics, it will use single precision, and shader uses single precision and THAT will be real problem with precision. Put as much as you can in javascript side: use ".position" in graphics and meshes, dont try to put big coords inside them. As for the case you mentioned, there's no precision problem. Quote Link to comment Share on other sites More sharing options...
trsh Posted September 13, 2016 Author Share Posted September 13, 2016 1 hour ago, ivan.popelyshev said: You're very lucky that JS uses double precision. Because if you try to put big coordinates in Graphics, it will use single precision, and shader uses single precision and THAT will be real problem with precision. Put as much as you can in javascript side: use ".position" in graphics and meshes, dont try to put big coords inside them. As for the case you mentioned, there's no precision problem. But I put .4 and I got (.4 - 0.0000000001) something. So i lost 0.000001 something? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 13, 2016 Share Posted September 13, 2016 I guess you're right, getBounds() uses single precision and is losing some part of it. But I dont think why do you need better precision there Quote Link to comment Share on other sites More sharing options...
xerver Posted September 13, 2016 Share Posted September 13, 2016 https://en.wikipedia.org/wiki/Floating_point#Representable_numbers.2C_conversion_and_rounding Just an artifact of the IEEE 754 format. There is a reason you don't use hardware-level floating precision numbers in applications that deal with money Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 13, 2016 Share Posted September 13, 2016 @xerver Its because getBounds() of Sprite uses Float32Array which is single precision 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.