Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to render three.js server-side?

How can I render three.js server side? At the moment our website renders player avatars using three.js locally, however that issues security things as well as potential bugs with people with less-end computers (people can inject the code into console and have it render god knows what..)

I looked into using node.js but all documentation on that is vague and appears to be quite outdated..

Any help would be useful

Current local: http://pastebin.com/yv5Qamfz

like image 431
Amicon Interactive Avatar asked Mar 17 '16 03:03

Amicon Interactive


People also ask

How does server-side rendering?

Server-side rendering (SSR) is an application's ability to convert HTML files on the server into a fully rendered HTML page for the client. The web browser submits a request for information from the server, which instantly responds by sending a fully rendered page to the client.

Is Three Js client-side?

three. js is a client side library. Even if you dynamically generate markup server-side, the code will still be executed client-side.

Can you use JavaScript for server-side?

Server-Side JavaScript is the use of the JavaScript language on servers. You know, those computers that are always on (and maybe online) running stuff, doing all kinds of work. Nowadays many of them have software, web servers, command-line applications, and other services that are written in JavaScript.

Does Next JS render server-side?

Next.js has two forms of pre-rendering: Static Generation and Server-side Rendering. The difference is in when it generates the HTML for a page. Static Generation (Recommended): The HTML is generated at build time and will be reused on each request. Server-side Rendering: The HTML is generated on each request.


1 Answers

There are several discussions about using three.js on node.js on the three.js GitHub page. Check for example:

  • Use Three.js functions in node.js
  • node.js server rendering with node-webgl and/or headless-gl

There is also this question on stackoverflow which could be considered a duplicate of your question.

This one is dealing with a project called node-three.js on GitHub. It will support rendering in three.js on node.js. Not sure if it does exactly what you want (I have no first hand experience with this library) but worth checking it out I guess.

like image 170
Wilt Avatar answered Sep 22 '22 11:09

Wilt