dom2three
dom2three copied to clipboard
Render HTML into your three.js scene.
DOM2three
Render web page element into three.js meshes for 3d radness!
Basic usage
1. Saving your HTML layout
-
Create a HTML layout and include the
dom2three.jsonto the page with content you want to convert.<script src="dom2thee.js"></script> -
Tag any elements which you would like created into a three.js mesh with a
data-meshattribute.<div id="example" data-mesh> Example element </div> -
Run the gulp script on your project folder.
gulp render yourproject/index.html -
The gulp script will place all the necessary data files into a
dom2threesub-folder.
2. Adding DOM2three elements to your three.js scene.
-
Include
dom2three.jsonto the page with your three.js scene. (step 1 above) -
Call
loadwith the dom2three data folder (step 4 above)var d23 = DOM2three.load('dom2three_dir')Loadreturns a promise once we are ready to go. -
Retrieve a dom2three node and add the mesh to your three.js scene.
d23.then( function() { var node = d23.getNodeById('example', true); scene.add( node.mesh ); });
More usage notes
- Create dynamic text areas from HTML layouts by specifying
data-textareaattributes. You'll also need to include what mesh hosts this textarea by specifyingdata-hostmesh='mesh-name'.
Gotcha's!
-
Examples are not really real examples yet. It's what we need to for our project www.github.com/mozvr/HIRO. I will come up with basic examples that are more general purpose at a later date.
-
We are using JADE + SASS to make it quick for us to generate templates, but standard HTML/CSS pages will work too.
-
There's a few dependencies that need to be installed. We will need to create a isntall script to make this easier to work with.