I'd like to take a lot of screenshots and export.glb from thousands of generated a-frame models. Since I can't save files from the browser without prompt, generating the models on the server-side with node.js would be awesome.
(As a workaround I could probably generate the models in the browser and POST them to a local server that saves the files to disk but I'd prefer the server-side rendering if possible)
So, how can I render A-Frame models in node.js?
Tried approaches like this with mock-browser for mocking the DOM (which is necessary in three
, let alone DOM-based a-frame
) and headless-gl for creating a WebGL context in node.
What I did, that resembles what you're looking for, is an electron application.
tldr: check this out . Download, npm install; npm run start;
npm install; npm run start;
and render screenshots / export the scene as glb. If you like it, let me know how to improve it to make it more useful.
You can load up an a-frame
website using electron, but use the main process to save the screenshot on your drive - so there are no prompts, and it can be automated.
To make a render, You can simply use the nativescreenshot component to create a canvas containing the screenshot image
document.querySelector('a-scene').components.screenshot.getCanvas('equirectangular');
but instead of downloading the blob, pass it into the main process via an renderer to main IPC channel - where you can save it on your drive.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.