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...
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.