-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adapting Vessel.js to ES6 class #165
Conversation
* Add a web-page for testing modules. * Adjust JSONSpec style. * Fix export/import syntax and add default modules.
Our first goal might be to convert Then we can try to rebuild this app with modules. |
As far as I understood Classes syntax, there were some mistakes on the BaseObject.js. I am using the following link for reference: mrdoob/three.js#19980 (comment) |
Good references Ícaro. This gives handy tricks to exchange properly from function to class. |
I created a test folder which contains possible test files we can start using for now on. I created a playground.js script which contains the ship version instantiated by the two forms. The idea is to compare the two methods to ensure both of them present the same results. |
I created a project Kanban to track which of the elements are already modified to avoid double work. In addtion, I already finnshed recreating the most crucial modules as agreed in the comment above:
With that accomplishement the app stated can be recreated. I assume it fits best inside the folder tester. In addition, be aware I am testing each one of the modules in the |
With the completion of the commit 2e9dea6 we reached the milestone defined in #165 (comment). Check the tests/playground.html to see the results. |
The new version using class were not behaving as intend and was retriving undefined in the new class style instead of the value expected for the volume in this line: vesseljs/source/classes/Hull.js Line 509 in 72ec010
As solution, I modified the method which were returning a function to return the final object instead. The results seems ok for the tests done so far: vesseljs/source/jsm/ship/Hull.js Line 398 in 14541f9
For a comparison here is the function as it was before: vesseljs/source/classes/Hull.js Line 322 in 72ec010
I do not know why this function was designed that way in the first place and I am not sure about the implications in terms of efficiency or applicability of this modification, therefore, I am making this comment in case someone has better idea how to handle this specific part of the code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merge the PR to dev so it is possible to start with more thorough tests of examples.
Merge pull request shiplab#165 from ferrari212/master
No description provided.