I’ve recently been exploring a Babylon, React, Next.js stack as a new workflow, in addition to using the Babylon unity toolkit for its amazing unity usage for environments, light baking and scene placements. So far things have been good with all of the documentation and info here on the forum for guidance, I have been able to set up what looks like will be a nice stack and workflow. My only issue I really cant seem to overcome on my own is trying to implement exported content from the Babylon toolkit into the react/next.js app. My issue stems from 1) The scene being rendered properly with textures and lightmaps is tied to the scenemanager and many other scripts, which would not be an issue on a standard web app because you can just source it on the index. 2) I cant import the script into the react component unless its a node module because all babylon scripts need to be transpiled by node-transpiled-module npm pkg in order to work on next.js, and it can only look in the node modules directory. 3) I tried to create a local npm package out of the babylon.scenemanager script and the exported screen script, but its not clear what the dependencies are needed so the are a lot of NOT DEFINED errors. There’s 10,202 lines of code in just the scenemanager alone and its getting really hard to go error by error and cross reference what @babylon/core definitions are needed. 4) I cant just import babylon core as BABYLON on the scenemanger because it declares a var BABYLON on multiple lines so I keep getting this error:
It seems to me (in my very limited understanding) that Babylon toolkit exports are not compatible with component base apps unless the creator creates some sort of module package that can be installed like the rest of Babylon es6 packages, so my question(s) are; Is this the case? Has someone else come across this problem and created a workaround? Has anyone created a workflow for toolkit using react and would like to share?
I really thought the local npm pkg was going to be it but that proved difficult as well. The scenemanager and other dependencies make it really hard to manually implement and I’m not sure how to get a 1 to 1 render of the export, in next.js without it.