Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blender export to Three.js

I just created a random mesh using Blender and I want to export it to be used in HTML5 via the Three.js. I haven't seen any decent tutorials that shows how to do this. Can anyone help me out with this? I just want the 3D Mesh to display in the web, no animations included. Thanks!

like image 835
AJ Naidas Avatar asked Mar 20 '12 08:03

AJ Naidas


People also ask

What file types does three Js support?

three. js provides loaders for many other popular formats like FBX, Collada or OBJ as well. Nevertheless, you should always try to establish a glTF based workflow in your projects first.


1 Answers

The easiest way I found after many searches and trial and error was Three.ColladaLoader. Place your .dae files in a folder titled models in your /root directory. I found the Blender JSON exporter less reliable. Call the PinaCollada function from within the init() function, somthing like this:

function init(){     scene = new THREE.scene;     ...     var object1 = new PinaCollada('model1', 1);     scene.add(object1);      var object2 = new PinaCollada('model2', 2);     scene.add(object2);      ... }  function PinaCollada(modelname, scale) {     var loader = new THREE.ColladaLoader();     var localObject;     loader.options.convertUpAxis = true;     loader.load( 'models/'+modelname+'.dae', function colladaReady( collada ) {         localObject = collada.scene;         localObject.scale.x = localObject.scale.y = localObject.scale.z = scale;         localObject.updateMatrix();     } );     return localObject; } 
like image 159
Orbiting Eden Avatar answered Sep 21 '22 05:09

Orbiting Eden