Saturday, December 1, 2012

Easy Way to Embed Three.js into Blogger: Use an Iframe

An easy way to add Three.js to Blogger is to embed a Three.js page as the source in an IFRAME.

And you can even edit the code in the post causing the animation to update.

For example, change camera.position.z to 800 or color: to 0cff0000.

Here's the code for the iframe that causes the Three.js online editor to appear here.

<iframe height="40%" src="http://mrdoob.com/projects/htmleditor/" style="border: medium solid rgb(0, 0, 0);" width="100%"></iframe>

It's best to keep the iframe  height well under 100%, otherwise the frame can obscure your code while you are editing the post.