THREE.JS + Blender(obj、mtl加载代码)

时间:2022-05-14 19:34:50

2016-11-04  09:23:17

THREE.REVISION  "81dev"  Blender     “2.78”

1、加载OBJ、MTL文件

 //        THREE.Loader.Handlers.add(/\.dds$/i, new THREE.DDSLoader() );
var mtlLoader = new THREE.MTLLoader();
mtlLoader.setBaseUrl('libs/obj/');
mtlLoader.setPath('libs/obj/'); mtlLoader.load('Tree2.mtl', function(materials){
materials.preload();
//model
var objLoader = new THREE.OBJLoader();
objLoader.setMaterials(materials);
objLoader.setPath('libs/obj/');
objLoader.load('Tree2.obj',function(object){
// object.traverse(function(child){
// child.material.side = THREE.DoubleSide;
// });
object.position.y = 0;
object.scale.set(4,4,4);
scene.add(object); },onProgress, onError);
});

效果:

THREE.JS + Blender(obj、mtl加载代码)

2、Blender Add-ons

THREE.JS + Blender(obj、mtl加载代码)

Sapling Tree Gen可以直接搜索到

SCA Tree Generator 下载地址:https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Add_Mesh/Add_Space_Tree

在Blender中Shift+A快捷键可以查看是否安装成功

THREE.JS + Blender(obj、mtl加载代码)THREE.JS + Blender(obj、mtl加载代码)