Is three.js ObjectLoader capable of loading textures?

匿名 (未验证) 提交于 2019-12-03 02:38:01

问题:

three.js version 0.0.70, blender version 2.73a

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

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

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" }], 

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.

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.

回答1:

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



回答2:

Latest format support it like following:

"images":[     {         "uuid": "A430CF4-AD77-11E3-914E-00248C62C323",                   "url": "../models/1024_tornis.png"               },     {         "uuid": "eka_tv_2_i",         "url": "../models/eka_tv_2.jpg"              },     {                    "uuid": "sala_model_0709_map_i",         "url": "../models/sala_model_0709_map.png"               } ],  "textures":[     {         "uuid": "1024_tornis",                   "image": "A430CF4-AD77-11E3-914E-00248C62C323"               },     {         "uuid": "eka_tv_2",         "image": "eka_tv_2_i"                },     {                    "uuid": "sala_model_0709_map",         "image": "sala_model_0709_map_i"                 } ], "materials": [     {         "uuid": "3C5CA6AA-055B-417B-97E0-706BA446140B",         "type": "MeshLambertMaterial",         "name": "Material.001",         "color": 16777215,         "emissive": 0,         "map": "1024_tornis"     }] 


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!