Blender导出到Three.js [英] Blender export to Three.js

查看:558
本文介绍了Blender导出到Three.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用Blender创建了一个随机网格物体,我想通过Three.js导出它以便在HTML5中使用。我还没有看到任何体面的教程,说明如何做到这一点。任何人都可以帮我解决这个问题吗?我只是希望3D网格在网络上显示,不包括动画。谢谢!

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!

推荐答案

我经过多次搜索和试错后找到的最简单方法是 Three.ColladaLoader 。将 .dae 文件放在 / root models 的文件夹中$ c>目录。我发现Blender JSON导出器不太可靠。从 init()函数中调用PinaCollada函数,如下所示:

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

这篇关于Blender导出到Three.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆