Pryme8 Posted February 22, 2016 Share Posted February 22, 2016 So, I guess this would be considered a bug. If you ever pass a value from a standard HTML input to like let say CreateSphere or CreateGround functions it handles them like they are strings. So this lead me to test and sure enough the mesh creation functions do not automatically parse passed values. Is there a reason for this? I really see no reason for these functions to not inherently parse variables passed to them as Integers. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted February 22, 2016 Share Posted February 22, 2016 Not sure to understand but I'm pretty sure this is not related to babylon.js Quote Link to comment Share on other sites More sharing options...
jerome Posted February 22, 2016 Share Posted February 22, 2016 Actually, no BJS CreateXXX() function parses the input parameters. If they aren't the expected type, the function crashes or behaves strangely due to JS dynamic typing. This is not a bug neither a lack. This is a design choice : the function (and the framework) intends to be as fast, light and performant as possible. Thus, no internal parsing, nor check, nor cast, nor error message. The doc (API + user doc) is here to explain how, when and what to use. Sometimes, it may be incomplete. Please let us know where to complete it (or feel fre to contribute ) It is then the user responsability to pass the right types at the right places. In your case, I guess that, by default, anything coming from the DOM inputs is considered by javascript as strings. So you might first cast it to the right type before passing it to any CreateXXX() function. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted February 22, 2016 Author Share Posted February 22, 2016 Yup, I understand now I did not know if it was intentional or not but your explanation validates that it was. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted February 22, 2016 Share Posted February 22, 2016 glad to help (at least to understand ) Quote Link to comment Share on other sites More sharing options...
RaananW Posted February 23, 2016 Share Posted February 23, 2016 Hi, you just need a middleware between your form and Babylon. Some form of validation and conversion. Passing strings can sometimes work (due to JavaScript auto-conversion when the need arises), but due to type-matching (like the "===" operator) and other architecture choices (as jerome said) it won't be possible to fully use strings. Here is the basic scene with strings - http://www.babylonjs-playground.com/#SERR9 . You would notice that the last parameter of the ground creation function is a number. try changing it to a string and it will fail. Pryme8 1 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.