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

查看:56
本文介绍了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 的文件夹中.我发现 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天全站免登陆