WebGL export

Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
User avatar
yorik
Site Admin
Posts: 11840
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: WebGL export

Postby yorik » Mon Apr 28, 2014 3:05 pm

I have too say, that web "counterpart" of bolts is really impressive.. Not many projects have such a solid online side...
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

Re: WebGL export

Postby jreinhardt » Mon Apr 28, 2014 3:19 pm

It is not so difficult once you have everything in machine-readable form. And for example for OpenSCAD it is really necessary to have documentation, as there is no GUI that offers you choices.

The website is another field where I need to invest some more time at some point. At the moment it is a bit hacky, with a two stage template process: First BOLTS fills in some data into templates to create templates that get then layouted by Jekyll. It works, but is quite cumbersome.
BOLTS, standard parts library for FreeCAD Thread, Help with Translation
User avatar
rockn
Posts: 1636
Joined: Wed Sep 28, 2011 10:39 am
Location: Toulouse, France
Contact:

Re: WebGL export

Postby rockn » Tue Apr 29, 2014 12:24 pm

Just perfect ! Thank you.
Formations et tutoriels FreeCAD en Français, soutenez moi : https://www.tipeee.com/formations-freecad
User avatar
shoogen
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: WebGL export

Postby shoogen » Tue Apr 29, 2014 1:01 pm

jreinhardt wrote:And for example for OpenSCAD it is really necessary to have documentation, as there is no GUI that offers you choices.
The OpenSCAD guys are planning to support the 'customizer' parametrization.
https://github.com/openscad/openscad/wi ... er-support
User avatar
bernd
Posts: 9806
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: WebGL export

Postby bernd » Tue Apr 29, 2014 3:59 pm

yorik wrote:I have too say, that web "counterpart" of bolts is really impressive.. Not many projects have such a solid online side...
+1 And it gets better and better and there are still ideas around so even more better :D . But on the other side a OpenSource CAD Framwork needs a smart OpenSource part library.
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

Re: WebGL export

Postby jreinhardt » Tue Apr 29, 2014 4:25 pm

https://github.com/jreinhardt/FreeCAD_s ... tree/webgl

contains a small feature and a fix. The feature is to allow selection of the line width using

Code: Select all

importWebGL.linewidth = 5
and the fix is for correctly treating non-straight edges in faceloop mode.
BOLTS, standard parts library for FreeCAD Thread, Help with Translation
User avatar
yorik
Site Admin
Posts: 11840
Joined: Tue Feb 17, 2009 9:16 pm
Location: São Paulo, Brazil
Contact:

Re: WebGL export

Postby yorik » Tue Apr 29, 2014 7:05 pm

I merged your change, very useful, thanks!!
User avatar
rockn
Posts: 1636
Joined: Wed Sep 28, 2011 10:39 am
Location: Toulouse, France
Contact:

Re: WebGL export

Postby rockn » Fri May 02, 2014 12:50 am

Hello,
I get something wrong with the webgl exporter, it make too big file :/ I saw this when it make me a 350Mo html file :)
A simplest beam (100x200x1000 mmm) make a 9.7Mo file with this version :
OS: Ubuntu 12.04.4 LTS
Platform: 64-bit
Version: 0.14.3488 (Git)
Branch: master
Hash: 147976515460de19bdf541d7d8de17c39b3a4bc7
Python version: 2.7.3
Qt version: 4.8.1
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.5.1
There is more than 100000 line and the most are like this :

Code: Select all

var wire = new THREE.Geometry();
                wire.vertices.push(new THREE.Vector3(-0.493266880512, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(-0.393266880512, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(-0.293266880512, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(-0.193266880512, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(-0.093266880512, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(0.006733119488, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(0.106733119488, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(0.206733119488, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(0.306733119488, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(0.406733119488, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(0.506733119488, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(0.606733119488, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(0.706733119488, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(0.806733119488, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(0.906733119488, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(1.00673311949, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(1.10673311949, -49.7647999972, -100.0));
                wire.vertices.push(new THREE.Vector3(1.20673311949, -49.7647999972, -100.0));
It make just a 10 ko file. With a old version :
OS: Ubuntu 12.04.4 LTS
Platform: 64-bit
Version: 0.14.3374 (Git)
Branch: master
Hash: fabe39b976a1456b70cf9da0c91bdb530e7e94d7
Python version: 2.7.3
Qt version: 4.8.1
Coin version: 3.1.3
SoQt version: 1.5.0
OCC version: 6.5.1

Have you got the same problem ?
Formations et tutoriels FreeCAD en Français, soutenez moi : https://www.tipeee.com/formations-freecad
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

Re: WebGL export

Postby jreinhardt » Fri May 02, 2014 8:17 am

Yes, I noticed that too yesterday. I guess I broke it with my "fix" for nonstraight edges. I will investigate.
BOLTS, standard parts library for FreeCAD Thread, Help with Translation
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

Re: WebGL export

Postby jreinhardt » Fri May 02, 2014 5:16 pm

I found the problem. The documentation string of Wire.discretize was wrong. This function can either be called with an integer or with a float. If called with an integer, this is interpreted as the number of vertices for the approximation. The docstring claims that a float is interpreted as the deflection of the discretization. The implementation however produces points that are uniformly spaced, which lead to a huge number of points for parts with long, straight lines.

In my webgl branch (https://github.com/jreinhardt/FreeCAD_s ... tree/webgl) I changed the implementation of Wire.discretize to be consistent with the docstring. This considerably reduces the filesize of the produces files. I tested with cylinders of size r x h and this is the result:

217469 -> 47080 10x10
222983 -> 43981 10x20
902408 -> 23600 1x1000
41702 -> 22805 1x10
54558 -> 43379 1x1

One little annoyance remains, namely that every edge is traced twice, once for each adjacent face. However, I believe that this is not easily fixed.
BOLTS, standard parts library for FreeCAD Thread, Help with Translation