0

I try to import blender object to my javascript code. But the object doesn't render like in blender. I export as .obj from blender.

Here is my blender:

blender screenshot

exporting options on left and on the right is how it look in threeJS:

three.js output

Ocaso Protal
  • 19,362
  • 8
  • 76
  • 83
ahmetkilinc
  • 674
  • 7
  • 19

1 Answers1

1

Here's a simple tutorial for Three.js and Blender.

As the easiest way to do this is to use the Three.ColladaLoader. Place your .dae files in a folder titled models in your /root directory. Call the Collada function from within the init() function.

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 Collada(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;
}

Following this answer or this one. Maybe it brings you ideas and maybe not, hope it helps!

Community
  • 1
  • 1
King Reload
  • 2,780
  • 1
  • 17
  • 42