-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Closed
Labels
Description
Is your feature request related to a problem? Please describe.
Running Three on Node is a massive pain
Making packages that are based on Three and meant to run on Web, NodeJS, and React Native is a massive pain.
With a colleague we have plan to make it easier by providing a node specific build, just like there is a jsm specific build.
Describe the solution you'd like
The plan is to do this:
- Create node compatible versions of at least:
src/loaders/ImageLoader.js=>src/loaders/ImageLoader.node.jssrc/loaders/FileLoader.js=>src/loaders/FileLoader.node.jsexamples/js/loaders/GltfLoader.js=>examples/js/loaders/GltfLoader.node.jsexamples/js/loaders/GltfExporter.js=>examples/js/loaders/GltfExporter.node.js
- Edit the rollup config of
utils/build/rollup.config.js:- Add an alias plugin to manage the two first changed packages above
- Add a fourth bundle of three with
output: "three.node.js"including the alias plugin
- Edit the
utils/build/modularize.js:- Add another
dstfolder additionally to the jsm one - Add a field called
nodePathinfilesitems pointing to the node version of the file if relevant - Modify the
convertfunction to output something similar to the jsm version with:if ( keys ) imports.push( 'import {${keys}\n} from "${pathPrefix}../../build/three.node.js";' );
- Add another
Would you accept such a PR back into the main three.js repo / package ?
Describe alternatives you've considered
We use a custom sh***y fork of an old version three in our repo and it is messy, we'd like to go for a cleaner version that is now possible thanks to the cleanup of the three codebase using ES modules.
Additional context
etiennedupont