-
Notifications
You must be signed in to change notification settings - Fork 8
Description
I've started using https://github.com/stackgl/headless-gl so it would be great if I could use this with Node.js too. There are two hurdles as far as I can tell:
- No
XMLHttpRequestsupport. textandbinaryloaders will work fine, but currently loadingimage/video/audiodata requires DOM support.
Can fairly easily tackle 1. by using a XMLHttpRequest polyfill for Node.js. Alternatively could move to using something like Superagent which works across environments (although understand that this might be undesirable as it would add ~5kb to gzipped code weight). Did look at using fetch API with ponyfill / polyfill for Node.js (e.g. https://github.com/qubyte/fetch-ponyfill / https://github.com/matthew-andrews/isomorphic-fetch) but currently this doesn't support progress events so seemed undesirable.
Support for image loader could be achieved by (conditionally for Node.js) using native Node.js image decoders for png, jpeg and gif etc. Not sure about video and audio but I guess in theory the same applies.
I made a fork to look into this (and also add some unit tests) but wanted to float the idea before I went ahead and tried this out. If done properly adding Node.js support wouldn't change the behaviour of, or add any weight to, the browser code. What are your thoughts on this @mikolalysenko?