NodeJS support
See original GitHub issueIs 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.js
src/loaders/FileLoader.js
=>src/loaders/FileLoader.node.js
examples/js/loaders/GltfLoader.js
=>examples/js/loaders/GltfLoader.node.js
examples/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
dst
folder additionally to the jsm one - Add a field called
nodePath
infiles
items pointing to the node version of the file if relevant - Modify the
convert
function 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
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:44 (11 by maintainers)
Top Results From Across the Web
Node.js
Node.js ® is a JavaScript runtime built on Chrome's V8 JavaScript engine. ... For information about supported releases, see the release schedule.
Read more >Node.js - endoflife.date
Release Released Active Support Se...
19 2 months and 1 week ago. (18 Oct 2022) Ends in 3 months. (01 Apr 2023) En...
18 (...
Read more >Node.js Release Working Group - GitHub
There are three phases that a Node.js release can be in: 'Current', 'Active Long Term Support (LTS)', and 'Maintenance'. Odd-numbered release lines are...
Read more >Node.js ES2015/ES6, ES2016 and ES2017 support
Yes. Yes Yes. Yes Error. Error Error. Error Error. Error Error. Error
function() function() function() function() function() function()
function() function() function() function() function() function()
function() function()...
Read more >Node.js Support - NodeSource
Node.js Support from NodeSource is comprehensive support for businesses looking to establish production-grade best practices.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes @crabmusket here’s how we typically create a renderer in node using our package and
headless-gl
. We simply shim a canvas with the gl context at the right place. Most hardcoded features bellow can be customised.Here’s a full render using mainline THREE and headless-gl, based on your example above: https://gist.github.com/crabmusket/b164c9b9d3c43db9bddbfb83afde0319