This module defines some classes and function to help with the creation of WebGL models. A WebGL model can be viewed directly from a compatible browser (see http://en.wikipedia.org/wiki/WebGL).
A WebGL model typically consists out of an HTML file and a Javascript file, possibly also some geometry data files. The HTML file is loaded in the browser and starts the Javascript program, responsible for rendering the WebGL scene.
Classes defined in module webgl
A 3D geometry model for export to WebGL.
The WebGL class provides a limited model to be easily exported as a complete WebGL model, including the required HTML, Javascript and data files.
Currently the following features are included:
An example of its usage can be found in the WebGL example.
The created model uses the XTK toolkit from http://www.goXTK.com or the modified version of FEops.
Return a dict with the objects in this model.
Returns a dict with the name:object pairs in the model. Objects that have no name are disregarded.
Add the current OpenGL scene to the WebGL model.
This method add all the geometry in the current viewport to the WebGL model.
Add a geometry object to the model.
Currently, two types of objects can be added: pyFormex Geometry objects and file names. Geometry objects should be convertible to TriSurface (using their toSurface method). Geometry files should be in STL format.
The following keyword parameters are available and all optional:
Add an actor to the model.
The actor’s drawable objects are added to the WebGL model as a list. The actor’s controller attributes are added to the controller gui.
Set the camera position and direction.
This takes two (optional) keyword parameters:
Export an object in XTK Javascript format
Format a single controller
Create the controller GUI script
Export the current scene to a pgf file
Export the WebGL scene.
Parameters:
You can also set the meta tags ‘description’, ‘keywords’ and ‘author’ to be included in the .html file. The first two have defaults if not specified.
Returns the name of the exported htmlfile.
Functions defined in module webgl
Sanitize sloppy settings for JavaScript output
Return properties of an object
properties are public attributes (not starting with an ‘_’) that are not callable.
Create a WebGL model of a surface