Babylon - NextJS lag on loading model

hi, if you are using react-babylonjs and trying to achieve a high level of tree-shaking then you will be disappointed. all of the types from that library are excluded from that bundle, but the code is generated for each supported class for diffing. that will be fixed in v4 either with dynamic registration via side-effects or having no generated code and losing lots of functionality. There are open issues on the repo and the implementation details are still up in the air. The underlying issue is no way to inspect the scene graph from JSX to tree shake (the renderer uses host elements - not Components).

If tree-shaking is important then use babylonjs-hook npm (not declarative):
babylonjs-hook - npm (npmjs.com)

1 Like