three.js ObjectLoader是否可以加载纹理? [英] Is three.js ObjectLoader capable of loading textures?

查看:451
本文介绍了three.js ObjectLoader是否可以加载纹理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

three.js版本0.0.70,搅拌器版本2.73a

three.js version 0.0.70, blender version 2.73a

我有一个场景是使用新的io_three(而非io_three_mesh)导出器从 blender 导出为 three.js json格式的.

I have a scene exported from blender to three.js json format using new io_three (not io_three_mesh) exporter.

我可以使用ObjectLoader将场景导入three.js:

I'm able to import the scene into three.js using ObjectLoader:

var objectLoader = new THREE.ObjectLoader();
objectLoader.load('assets/models/exportedScene.json', function(imported) {
    scene.add(imported);
});

不幸的是,没有纹理应用于对象,只有材质. 从exportedScene.json文件中可以看到,文件中有关于纹理的信息:

Unfortunatelly, no texture is applied to an object, only the material. As I see from exportedScene.json file, there is an info about texture in file:

"images": [{
    "url": "blue.jpg",
    "uuid": "DFE5BBBF-601B-48EA-9C05-B9CB9C07D92E",
    "type": "Geometry",
    "name": "blue.jpg"
}],
"materials": [{
    "color": 200962,
    "specular": 5066061,
    "shininess": 8,
    "ambient": 200962,
    "depthTest": true,
    "depthWrite": true,
    "name": "partitionMat",
    "emissive": 0,
    "uuid": "A705A33F-68C1-489C-A702-89A0140247AB",
    "blending": "NormalBlending",
    "vertexColors": false,
    "map": "73277351-6CCF-4E84-A9F0-D275A101D842",
    "type": "MeshPhongMaterial"
}],
"textures": [{
    "minFilter": "LinearMipMapLinearFilter",
    "wrap": ["RepeatWrapping","RepeatWrapping"],
    "magFilter": "LinearFilter",
    "mapping": "UVMapping",
    "image": "DFE5BBBF-601B-48EA-9C05-B9CB9C07D92E",
    "repeat": [1,1],
    "name": "carpetTexture",
    "anisotropy": 1.0,
    "uuid": "73277351-6CCF-4E84-A9F0-D275A101D842",
    "type": "Geometry"
}],

但是正如我之前所说,没有应用纹理. 我尝试使用js脚本将纹理文件放置在html附近,但没有用.

But as I said before, no texture is applied. I tried placing texture file near the html with js script, but it didn't work.

也许我的最初方法不正确,我应该导入类似于 http://threejs.org/examples的纹理/webgl_loader_obj.html ?但是,这是关于使用ObjLoader(而不是ObjectLoader)的,我不确定是否正确.

Maybe my initial approach is incorrect and I should import textures similar to http://threejs.org/examples/webgl_loader_obj.html? However, this one is about using ObjLoader (not ObjectLoader), and I'm not sure if it's correct.

推荐答案

签出dev分支.最近已经为即将发布的r71版本提供了纹理支持.

Check out the dev branch. There have been recent commits for texture support for the upcoming r71 release.

这篇关于three.js ObjectLoader是否可以加载纹理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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