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!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
yorik
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: WebGL export

Post by yorik »

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

Post by jreinhardt »

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
Veteran
Posts: 1791
Joined: Wed Sep 28, 2011 10:39 am
Location: Toulouse, France
Contact:

Re: WebGL export

Post by rockn »

Just perfect ! Thank you.
Formations - Assistance - Développement : https://freecad-france.com
User avatar
shoogen
Veteran
Posts: 2823
Joined: Thu Dec 01, 2011 5:24 pm

Re: WebGL export

Post by shoogen »

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
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: WebGL export

Post by bernd »

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

Post by jreinhardt »

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
Founder
Posts: 13640
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels
Contact:

Re: WebGL export

Post by yorik »

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

Re: WebGL export

Post by rockn »

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 - Assistance - Développement : https://freecad-france.com
jreinhardt
Posts: 329
Joined: Mon Sep 09, 2013 6:08 pm

Re: WebGL export

Post by jreinhardt »

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

Post by jreinhardt »

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
Post Reply