LDraw.org Discussion Forums

Full Version: WebGL renderer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
yeah, working with the whole package is not ok. my latest idea is this: upload all parts as single file in some server where you can query single parts. Then in javascript i scan an ldr/mpd and for any reference to a subpart, i query the server to obtain it, and use all the parts to build the full geometry.
This would allow displaying of arbitrary models (ie embeddable in html, from user textarea, etc) without any server side work, with hopefully minimal bandwidth usage. I've tested that my Viper model uses about 80 parts for about 300kB total, which can be compressed to about 30kB with gzip, quite good. With this performances is more easily to overload the video card than to use too much bandwidth Smile
The only problem is that it would generate 80 asynchronous request to the server, which can be quite a lot. But parts file are cacheable so that should help.
I'll try asap
nice idea. just some more thoughts to share:
you could in fact put all the parts to the server,
then have the client send a "list of needed parts" to it.
the server could put all the needed files into a *.mpd on the fly (which is trivial),
and then that result could get send gzip compressed to the client.
Or store the parts pre-processed somewhere and read that. If you've got them on your own server you're not limited to LDraw File Format.

Tim
Here the new version!
Now it's all javascript. It asynchronously fetch all part data from a server, build the model and display it. No server logic. The parts on the server are unprocessed, they're just redistribuited in different subfolder as my server was complaining about 7000+ files on a single dir Smile

The main javascript object mantain a cache of already downloaded parts, so if you show multiple models the fetches are limited.

Here's a simple display:

http://www.lugato.net/ldraw/simple.html

And here's a page that lets you paste LDraw model in a textarea to load them:

http://www.lugato.net/ldraw/copypaste.html

And a page with multiple models in a gallery like fashion (caution: use lots of ram Tongue):

http://www.lugato.net/ldraw/multiple.html

Note that my server doesn't GZip.
So there's much room for improvements, for example optimizing part requests, 3d rendering (some better filtering and lighting), zooming, compression of parts, etc.

Let me know if something go wrong while you try it. note that there may be some missing parts on the server.
Nicola Wrote:http://www.lugato.net/ldraw/simple.html

"Something went wrong loading: 48\....dat"

and there a lots of these messages after loading the page. Afterwards it freezes saying "Initializing..."

w.
I bow to you.
Seeing the loading progress text messages rush through,
and then seeing the model so beautifully is just amazing.
Great compliments! I am truly amazed! The beauty of this solution is
that it is NOT tied to either iOS or Android, but still can be seen on mobile devices, as long as the browser sports WebGL.
This embodies the MAIN principle of the Internet, offering contents INDEPENDENTLY of OS or browser brand.
Would we have to implement an Android App, an iOS App, an XYZ App separately, this would multiply the needed
effort. THIS way, all is bundled in ONE. YES, it's JavaScript, and JavaScript is not (to my eyes) the most beautiful
of all programming languages, but browsers nowadays are HIGHLY optimized for it, and you can always put something
ELSE to work together with it. However, for a browser, it's the most natural choice, being - in my eyes - MUCH better than
Flash or Silverlight, which again would be vendor-specific.
Good decision, and an impressive prototype. Kudos!
the improvements which I spontaneously like to collect here, jumping to my eye or mind, are

(a) rotation center:
The center of rotation currently seems to be hardcoded 0/0/0.
I would better like to have it at the model's center, like in LDView.
Using the mouse currently in your web app feels so different than LDView,
that it confuses me. I would love to see a big similarity in mouse handling between the 2 tools.

(b) incremental parts display:
perhaps it is very easy to do, and you could show the model already while it is loading.
the user can watch the downloaded parts appear in the model.
I think it could be quite cheap to do, because you already know all the matrices etc, just the "real" part data is missing.
Thus, you could already build up the necessary data structures, and skip them on rendering, while the model is not fully loaded.
I think this would be an evern more "incremental" load than displaying the progress status message Big Grin

© mousewheel:
I am missing the use of the mousewheel for zooming...

(d) default color 16:
Nicola, you seem to currently use 0/0/0 always for default color 16.
I would prefer if you would use the color specified explicitly in LDConfig.ldr (some "medium" default grey).
To you already use that file? You can always get the most recent version also from the ldraw.org site.

(e) edges:
you currently are not rendering edges at all.
I would like to have a checkbox or button for toggling that on and off.
It should be nearly trivial to add the drawing of them to your existing implementation.
Nicola, I am again falling of my chair, impressed.
I just tested the attached file, which uses an LSYNTH synthesized cable,
plus unofficial parts, it loaded quickly and smooth, and looked beautiful!
Code:
var flip = geometry._inverting ^ (det<0.0) ^ (!ccw); // kungfu

hahahaha, liked that
NICE JOB!
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16