WebGL export
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: WebGL export
I just exported a hacked up object as WebGL. I'm almost out of excuses not to learn WebGL. Nice!
Re: WebGL export
Just have been playing with this for the first time. It's a great feature very useable. Found only moving (hold right mouse button) and turning (hold left mousebutton). Is there any zoom too?yorik wrote:It's pretty simple, really... Select some geometry, then file->export->webgl.
EDIT: Just found it the middle button
Re: WebGL export
Actually the webgl exporter uses a "template", a webgl viewer I found (Actually IIRC Dan Falck found), and simply inserts the FreeCAD geometry inside. Everything is in Arch/importWebGL.py. Other templates could easily be used instead if you want a different viewer.
Re: WebGL export
Ahh thanks for information. I need to play with this a bit. All my modells where exported not usable in Browser. Found they are all in mm (ifcimport). If they are im m or cm the webglexport works greatyorik wrote:Actually the webgl exporter uses a "template", a webgl viewer I found (Actually IIRC Dan Falck found), and simply inserts the FreeCAD geometry inside. Everything is in Arch/importWebGL.py. Other templates could easily be used instead if you want a different viewer.
Re: WebGL export
It work well in mm for me.
http://wood3dservices.fr/webgl/Pergola.html
But I have two important things to do to have this nice export.
I must place the model so as to have the total reference mark in the center of the structure.
And I must modify the postion of the camera in html file like that :
The camera position in three.js is very complicated to understand.
http://wood3dservices.fr/webgl/Pergola.html
But I have two important things to do to have this nice export.
I must place the model so as to have the total reference mark in the center of the structure.
And I must modify the postion of the camera in html file like that :
Code: Select all
camera.position.set( 0.0, -8000.0, 500.0 );
Formations - Assistance - Développement : https://freecad-france.com
Re: WebGL export
Ahh, that looks cool.rockn wrote:It work well in mm for me.
http://wood3dservices.fr/webgl/Pergola.html
What is the total reference mark ? A point defined in importWebGL.py, or the origin of global coordinate system (0,0,0), or some other point?rockn wrote:I must place the model so as to have the total reference mark in the center of the structure.
Re: WebGL export
Oups, wrong translation. "The reference mark" is the origin of global coordinate system (0,0,0) in the FreeCAD model.
Formations - Assistance - Développement : https://freecad-france.com
Re: WebGL export
Hello,
Do you think it's possible to have html template out of the source code ? Could be cool to edit it easily and why not have more than one template.
Second : In the template I can't force the camera position. How can I force the camera postion before I make the export ?
See how I export my structure in a macro :
Do you think it's possible to have html template out of the source code ? Could be cool to edit it easily and why not have more than one template.
Second : In the template I can't force the camera position. How can I force the camera postion before I make the export ?
See how I export my structure in a macro :
Code: Select all
if f3dformat == 'html':
copyPergo = Draft.move([poteaux,poutres, solives,cfichesa,cfichesb,cfichesc,cfichesd,piedsPoteaux, wall, muraillere],FreeCAD.Vector(-pergolaLongueur/2, -pergolaLargeur/2, -pergolaHauteur/2), copy = True) # To place all my structure in the center of the FreeCAD model
importWebGL.export(copyPergo,filePath)
print("/!\ AJOUTER CECI DANS FICHIER HTML")
print("camera.position.set( 0.0, -8000.0, 500.0 );")
print("/!\ ")
for obj in copyPergo :
App.ActiveDocument.removeObject(obj.Name)
Formations - Assistance - Développement : https://freecad-france.com
-
- Posts: 329
- Joined: Mon Sep 09, 2013 6:08 pm
Re: WebGL export
I second the motion. I want to include a 3D view of the parts in the BOLTS web page, and for this a template without the html boilerplate would be really handy.
Re: WebGL export
In git commit 8f469bf I just added some mechanisms to make that simpler. I didn't put the template outside of the file, because then we would need additional GUI stuff to choose the template, etc... But it is now easy to use and change the template from a python script, like this:
You can get the default template simply with:
You can also change the export style (do it before calling the export() function):
"faceloop" is the default, but you can also use "multimaterial" or None
Code: Select all
import importWebGL
mytemplatefile = open( "/home/yorik/mytemplate.html" )
mytemplate = mytemplatefile.read()
mytemplatefile.close()
importWebGL.template = mytemplate
importWebGL.export( FreeCADGui.Selection.getSelection(), "/home/yorik/test.html" )
Code: Select all
import importWebGL
print importWebGL.template
Code: Select all
importWebGL.wireframeStyle = "faceloop"