Swiftwork Posted November 12, 2016 Share Posted November 12, 2016 Hi I have spoken to @Nockawa already and he suggested I turn to the forums which I agreed with. When using a bundler such as Webpack, the developer imports the the BabylonJS library rather than including it in a script tag. The problem that arises is that Earcut has been defined in it's own namespace and is available only in the babylon.js file or globally when using script tags. However in Webpack each imported module is treated as an isolated scope and doesn't have access to other modules or global variables unless they have specifically been required/provided. Because Earcut is never exported and in it's own namespace it is literally unreachable for module bundlers: > babylon.js defines Earcut module > babylon.js defines and exports BABYLON module > Webpack provides the BABYLON module from babylon.js to all other libraries > babylon.canvas2d.js extends and exports BABYLON module x babylon.canvas2d.js uses BABYLON and Earcut (but Earcut is not provided nor in the same namespace) This leave 2 solutions as I see it: Add Earcut to the BABYLON namespace so that they get exported together and can both be provided by bundlers. Keep Earcut in it's own namespace and export it so that it can be imported by both babylon.js and babylon.canvas2d.js or provided using a bundler. Ping @Deltakosh, moving forward it might be worth looking into npm more. They offer the for example the option to add @next version tag for alphas/betas of packages. I am sure Babylon.JS would benefit from having more users testing/working with the preview build and finding issues. Kind Regards Swiftwork Quote Link to comment Share on other sites More sharing options...
Nockawa Posted November 12, 2016 Share Posted November 12, 2016 also ping @RaananW which is insight will be useful Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 14, 2016 Share Posted November 14, 2016 What could be the update we need to do for this? Please feel free to start a pull request Quote Link to comment Share on other sites More sharing options...
Swiftwork Posted November 17, 2016 Author Share Posted November 17, 2016 I missed your reply @Deltakosh and I would suggest for now just add Earcut to the babylon namespace because the file is fairly small and doesnt have any specific reason to not being included in its current state. I can make a pull request for this today if I get some free time. Quote Link to comment Share on other sites More sharing options...
RaananW Posted November 17, 2016 Share Posted November 17, 2016 My 2 cents - Earcut should not be a part of the babylon namespace, as it is not a part of babylon. There is also the OS license that we should consider, and, in general, the fact that the developer of the module might need to approve such a move. That would be like adding jQuery to the angular namespace, because angular can use jquery. Sounds rather wrong I like the 2nd option, which is exporting Earcut as an external dependency. If you want to provide a very simple project that I can download and experiment with offline, it would be wonderful! 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.