Kesshi Posted May 20, 2016 Share Posted May 20, 2016 I just stumbled upon some typing issues. 1. The ratio parameter in the PostProcess contructor is defined as "number | any" but in all derived classes (FxaaPostProcess ...) it is define as "number" only. see:https://github.com/BabylonJS/Babylon.js/blob/master/src/PostProcess/babylon.postProcess.ts#L100https://github.com/BabylonJS/Babylon.js/blob/master/src/PostProcess/babylon.fxaaPostProcess.ts#L6 2. There are some issues with the size parameter of the RenderTargetTexture: - in the constructor its defined as "any" but it should be "number | any" - the private member "_size" is defined as "number" but should be "number | any" - the getRenderSize() function returns "number" but should return "number | any" - the scale() function expects "_size" to be "number" and will fail if it is an object:https://github.com/BabylonJS/Babylon.js/blob/master/src/Materials/Textures/babylon.renderTargetTexture.ts#L168 Quote Link to comment Share on other sites More sharing options...
Kesshi Posted May 20, 2016 Author Share Posted May 20, 2016 It wouble be better not to use "any" as the type for function parameters. Because if it is not documented, you need to look at the sources to see which Parameters you can use for any. For example for the PostProcess it would be better to define "ratio" as "number | {width: number, height: number}". One more thing i don't like are things like samplingMode, coordinatesMode, fovMode .... They are always declared as number and its not obvious what the possible values are. Sometimes you can see it in the naming (e.g. Texture.NEAREST_SAMPLINGMODE) but in some cases its not so easy to see. For example the Camera.mode. Here you can use Camera.ORTHOGRAPHIC_CAMERA and Camera.PERSPECTIVE_CAMERA but its not clear. I always define things like this as enums. This makes it absolutly clear what values you can use and you get an compiler error if you assign something wrong. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 20, 2016 Share Posted May 20, 2016 Only problem of enum: they generate a string and this is not possible to have to test against a string while rendering a frame. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 20, 2016 Share Posted May 20, 2016 Regarding typings issues: Please provide a PR. I would be happy to merge it as it makes the devlopment easier Quote Link to comment Share on other sites More sharing options...
Kesshi Posted May 20, 2016 Author Share Posted May 20, 2016 3 hours ago, Deltakosh said: Only problem of enum: they generate a string and this is not possible to have to test against a string while rendering a frame. That is not true. This example will print "x=2 type=number": enum Test { Value1, Value2, Value3 } let x = Test.Value3; alert("x=" + x + " type=" + typeof (x)); You can even specify the numeric value like this: enum Test { Value1 = 12, Value2 = 13, Value3 = 14 } Regarding the PR. I will put it on my TODO list. If i have some time at work i can work on it. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 20, 2016 Share Posted May 20, 2016 Unfortunately I'm right: http://www.typescriptlang.org/play/index.html#src=enum%20Test%20%7B%0D%0A%20%20%20%20Value1%20%3D%2012%2C%0D%0A%20%20%20%20Value2%20%3D%2013%2C%0D%0A%20%20%20%20Value3%20%3D%2014%0D%0A%7D Quote Link to comment Share on other sites More sharing options...
Kesshi Posted May 21, 2016 Author Share Posted May 21, 2016 Ok but you can declare the enum as "const" and set the "preserveConstEnums" compiler option to true. Now this: const enum Test { Value1 = 12, Value2 = 13, Value3 = 14 } var x = Test.Value1; if (x === Test.Value2) { } compiles to this: var Test; (function (Test) { Test[Test["Value1"] = 12] = "Value1"; Test[Test["Value2"] = 13] = "Value2"; Test[Test["Value3"] = 14] = "Value3"; })(Test || (Test = {})); var x = 12 /* Value1 */; if (x === 13 /* Value2 */) { } If you do not set the " preserveConstEnums" you will only get: var x = 12 /* Value1 */; if (x === 13 /* Value2 */) { } Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 22, 2016 Share Posted May 22, 2016 Yes but the goal is to allow developers to use Texture.NEAREST_SAMPLINGMODE and not 2 and to be able to do if value === Texture.NEAREST_SAMPLINGMODE (int testing and not string testing) 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.