Template makes it possible to use Blender groups in order to organise model for user interaction. Users can toggle visibility of objects/groups (like layers) and it is also possible to explore indvidual objects from menu.
X3DOM template also allows users to add nodes to the X3D file, like LOD, Switch or Inline nodes that are not possible with basic export.
The actual export is done with slightly modified X3D-export of Blender. The export is controlled with "meta nodes" defined in a XML file.
The produced HTML is based on template. Some example templates can be found here:
- Download the addon and install it.
- Download x3dom-template-2-column-fixed template and extract it.
- Open the city.blend file from the template directory.
- Choose export -> X3DOM template (.x3d) and choose "metanodes_city.xml" and press Export.
- Open index.html with your browser.
- (note: If you are using index.html locally and you are using Google Chrome, then you must start it with -allow-file-access-from-files flag. In linux: google-chrome --allow-file-access-from-files
- Examine metanodes_city.xml for clarification!
How does it work?
Template is HTML file that has certain structure. The exporter injects the control structure to the template and saves the result. The file name is defined in the metanodes file.
The are two kind of metanodes. First, there are nodes that affect the X3D file written by the exporter. This allows you to add for example Switch or LOD nodes.
Second type of nodes define what kind of HTML is written to the www-template. This makes it possible to define "links" to objects (so that viewpoint is focused to object) or define objects that can be turned on and off (layers).
Here is an example file:
The script uses groups as layers. This makes it possible to group buildings or parts together and allow users to switch them on/off (note: this is different from Switch). Layers (groups) are written in a JSON file.
These nodes affect the actual output of the X3D exporter.
This replaces an object called "Cube" with an Inline node:
<blender_object name="Cube" >
<Inline url="palikat.x3d" />
With add_nodes one can add extra nodes to the exported X3D file.
<Switch DEF="temple_or_cabin" title="rich and poor" whichChoice='0'>
<Group title="poor Suzanne">
<blender_group name="Suzanne's house" />
<Group title="Rich Suzanne">
<blender_group name="temple" />
These nodes does not affect the X3D-file. However, they define what is written to the html file.
- title: string that is displayed as a header for the examineable objects
- HTMLrender: "list" or "select"
<examineable title="houses" HTMLrender="list">
<blender_group name="Suzanne's house" axis="posY" title="Suzanne talo"/>
<blender_group name="House2" axis="posZ"/>
The code above will render something like this:
More info coming soon!