我在 Blender 中制作了一个带有纹理的形状并将其导出。然后用 json loader 显示它。几乎一切都很好,几何形状很好,可以在形状上看到纹理,但没有颜色。只是黑色和枯萎。如何显示纹理颜色?我做错了什么?
json文件:
{
"metadata" :
{
"formatVersion" : 3.1,
"generatedBy" : "Blender 2.65 Exporter",
"vertices" : 64,
"faces" : 92,
"normals" : 64,
"colors" : 0,
"uvs" : [133],
"materials" : 1,
"morphTargets" : 0,
"bones" : 0
},
"scale" : 1.000000,
"materials" : [ {
"DbgColor" : 15658734,
"DbgIndex" : 0,
"DbgName" : "Material",
"blending" : "NormalBlending",
"colorAmbient" : [0.44769230556029527, 0.44769230556029527, 0.44769230556029527],
"colorDiffuse" : [0.44769230556029527, 0.44769230556029527, 0.44769230556029527],
"colorSpecular" : [0.0, 0.0, 0.0],
"depthTest" : true,
"depthWrite" : true,
"mapNormal" : "texture3.jpg",
"mapNormalFactor" : -0.058823585510253906,
"mapNormalWrap" : ["repeat", "repeat"],
"shading" : "Phong",
"specularCoef" : 50,
"transparency" : 1.0,
"transparent" : false,
"vertexColors" : false
}],
"vertices" : [-1.37836e-07,-2.55512,-2.55512,-1.37836e-07,2.55512,-2.55512,0.498479,-2.55512,-2.50602,0.498479,2.55512,-2.50602,0.977802,-2.55512,-2.36062,0.977802,2.55512,-2.36062,1.41955,-2.55512,-2.1245,1.41955,2.55512,-2.1245,1.80674,-2.55512,-1.80674,1.80674,2.55512,-1.80674,2.1245,-2.55512,-1.41955,2.1245,2.55512,-1.41955,2.36062,-2.55512,-0.977801,2.36062,2.55512,-0.977801,2.50602,-2.55512,-0.498479,2.50602,2.55512,-0.498479,2.55512,-2.55512,4.14106e-07,2.55512,2.55512,1.90731e-07,2.50602,-2.55512,0.498479,2.50602,2.55512,0.498479,2.36062,-2.55512,0.977802,2.36062,2.55512,0.977802,2.1245,-2.55512,1.41955,2.1245,2.55512,1.41955,1.80674,-2.55512,1.80674,1.80674,2.55512,1.80674,1.41955,-2.55512,2.1245,1.41955,2.55512,2.1245,0.977801,-2.55512,2.36062,0.977801,2.55512,2.36062,0.498478,-2.55512,2.50602,0.498478,2.55512,2.50602,-9.68575e-07,-2.55512,2.55512,-9.68575e-07,2.55512,2.55512,-0.49848,-2.55512,2.50602,-0.49848,2.55512,2.50602,-0.977803,-2.55512,2.36062,-0.977803,2.55512,2.36062,-1.41955,-2.55512,2.1245,-1.41955,2.55512,2.1245,-1.80674,-2.55512,1.80674,-1.80674,2.55512,1.80674,-2.12451,-2.55512,1.41955,-2.12451,2.55512,1.41955,-2.36062,-2.55512,0.977801,-2.36062,2.55512,0.9778,-2.50602,-2.55512,0.498477,-2.50602,2.55512,0.498477,-2.55512,-2.55512,-1.86021e-06,-2.55512,2.55512,-2.08358e-06,-2.50602,-2.55512,-0.498481,-2.50602,2.55512,-0.498481,-2.36062,-2.55512,-0.977804,-2.36062,2.55512,-0.977804,-2.1245,-2.55512,-1.41955,-2.1245,2.55512,-1.41955,-1.80674,-2.55512,-1.80674,-1.80674,2.55512,-1.80674,-1.41955,-2.55512,-2.12451,-1.41955,2.55512,-2.12451,-0.977799,-2.55512,-2.36062,-0.977799,2.55512,-2.36062,-0.498475,-2.55512,-2.50602,-0.498475,2.55512,-2.50602],
"morphTargets" : [],
"normals" : [0,-0.68569,-0.727866,0,0.68569,-0.727866,0.142003,0.68569,-0.713889,0.142003,-0.68569,-0.713889,0.278542,0.68569,-0.672475,0.278542,-0.68569,-0.672475,0.40437,0.68569,-0.605213,0.40437,-0.68569,-0.605213,0.514664,0.68569,-0.514664,0.514664,-0.68569,-0.514664,0.605213,0.68569,-0.40437,0.605213,-0.68569,-0.40437,0.672475,0.68569,-0.278542,0.672475,-0.68569,-0.278542,0.713889,0.68569,-0.142003,0.713889,-0.68569,-0.142003,0.727866,0.68569,0,0.727866,-0.68569,0,0.713889,0.68569,0.142003,0.713889,-0.68569,0.142003,0.672475,0.68569,0.278542,0.672475,-0.68569,0.278542,0.605213,0.68569,0.40437,0.605213,-0.68569,0.40437,0.514664,0.68569,0.514664,0.514664,-0.68569,0.514664,0.40437,0.68569,0.605213,0.40437,-0.68569,0.605213,0.278542,0.68569,0.672475,0.278542,-0.68569,0.672475,0.142003,0.68569,0.713889,0.142003,-0.68569,0.713889,0,0.68569,0.727866,0,-0.68569,0.727866,-0.142003,0.68569,0.713889,-0.142003,-0.68569,0.713889,-0.278542,0.68569,0.672475,-0.278542,-0.68569,0.672475,-0.40437,0.68569,0.605213,-0.40437,-0.68569,0.605213,-0.514664,0.68569,0.514664,-0.514664,-0.68569,0.514664,-0.605213,0.68569,0.40437,-0.605213,-0.68569,0.40437,-0.672475,0.68569,0.278542,-0.672475,-0.68569,0.278542,-0.713889,0.68569,0.142003,-0.713889,-0.68569,0.142003,-0.727866,0.68569,0,-0.727866,-0.68569,0,-0.713889,0.68569,-0.142003,-0.713889,-0.68569,-0.142003,-0.672475,0.68569,-0.278542,-0.672475,-0.68569,-0.278542,-0.605213,0.68569,-0.40437,-0.605213,-0.68569,-0.40437,-0.514664,0.68569,-0.514695,-0.514664,-0.68569,-0.514695,-0.40437,0.68569,-0.605213,-0.40437,-0.68569,-0.605213,-0.278542,0.68569,-0.672475,-0.278542,-0.68569,-0.672475,-0.142003,0.68569,-0.713889,-0.142003,-0.68569,-0.713889],
"colors" : [],
"uvs" : [[0.595239,0.415587,0.593966,0.00043,0.633876,0.000307,0.63515,0.415464,0.671471,0.000192,0.672745,0.415349,0.705306,8.8e-05,0.70658,0.415245,0.73408,0,0.735354,0.415157,0.735354,0.417126,0.73408,0.832282,0.705306,0.832194,0.70658,0.417037,0.671472,0.83209,0.672745,0.416934,0.633877,0.831975,0.63515,0.416818,0.593966,0.831853,0.59524,0.416696,0.553274,0.831728,0.554547,0.416571,0.513363,0.831605,0.514637,0.416449,0.475768,0.83149,0.477042,0.416333,0.441933,0.831386,0.443207,0.41623,0.41316,0.831298,0.414433,0.416141,0.736627,0.832106,0.735354,0.416949,0.769188,0.416845,0.770462,0.832002,0.806783,0.41673,0.808057,0.831887,0.846694,0.416608,0.847967,0.831764,0.887386,0.416483,0.88866,0.83164,0.927297,0.41636,0.92857,0.831517,0.964892,0.416245,0.966165,0.831402,0.998726,0.416141,1,0.831298,0.998726,0,1,0.415157,0.966165,0.415261,0.964892,0.000104,0.92857,0.415376,0.927297,0.000219,0.88866,0.415498,0.887386,0.000342,0.847967,0.415623,0.846694,0.000466,0.808057,0.415746,0.806783,0.000589,0.770462,0.415861,0.769188,0.000704,0.736627,0.415965,0.735354,0.000808,0.41316,0.000985,0.441933,0.000896,0.443207,0.416053,0.475768,0.000793,0.477042,0.415949,0.513363,0.000677,0.514637,0.415834,0.226926,0.41316,0.266837,0.421098,0.304432,0.436671,0.338267,0.459278,0.186233,0.41316,0.367041,0.488053,0.146323,0.421098,0.389648,0.521887,0.108727,0.436671,0.405221,0.559482,0.074893,0.459279,0.41316,0.599393,0.046119,0.488053,0.41316,0.640086,0.023511,0.521887,0.405221,0.679997,0.007939,0.559483,0.389648,0.717592,0,0.599393,0.367041,0.751426,0,0.640086,0.338267,0.7802,0.007939,0.679997,0.304432,0.802808,0.023511,0.717592,0.266837,0.81838,0.046119,0.751427,0.226926,0.826319,0.074893,0.780201,0.186233,0.826319,0.108728,0.802808,0.146323,0.81838,0.554547,0.415711,0.553274,0.000555,0.304432,0.023511,0.338267,0.046119,0.367041,0.074893,0.266837,0.007939,0.389648,0.108728,0.226926,0,0.405221,0.146323,0.186233,0,0.41316,0.186234,0.146323,0.007939,0.41316,0.226926,0.108728,0.023511,0.405221,0.266837,0.074893,0.046119,0.389648,0.304432,0.046119,0.074893,0.367041,0.338267,0.023511,0.108728,0.338267,0.367041,0.007939,0.146323,0.304432,0.389649,0,0.186233,0.266837,0.405221,0,0.226926,0.007939,0.266837,0.023511,0.304432,0.146322,0.405221,0.046119,0.338267,0.108727,0.389648,0.074893,0.367041]],
"faces" : [43,0,1,3,2,0,0,1,2,3,0,1,2,3,43,2,3,5,4,0,3,2,4,5,3,2,4,5,43,4,5,7,6,0,5,4,6,7,5,4,6,7,43,6,7,9,8,0,7,6,8,9,7,6,8,9,43,8,9,11,10,0,10,11,12,13,9,8,10,11,43,10,11,13,12,0,13,12,14,15,11,10,12,13,43,12,13,15,14,0,15,14,16,17,13,12,14,15,43,14,15,17,16,0,17,16,18,19,15,14,16,17,43,16,17,19,18,0,19,18,20,21,17,16,18,19,43,18,19,21,20,0,21,20,22,23,19,18,20,21,43,20,21,23,22,0,23,22,24,25,21,20,22,23,43,22,23,25,24,0,25,24,26,27,23,22,24,25,43,24,25,27,26,0,27,26,28,29,25,24,26,27,43,26,27,29,28,0,30,31,32,33,27,26,28,29,43,28,29,31,30,0,33,32,34,35,29,28,30,31,43,30,31,33,32,0,35,34,36,37,31,30,32,33,43,32,33,35,34,0,37,36,38,39,33,32,34,35,43,34,35,37,36,0,39,38,40,41,35,34,36,37,43,36,37,39,38,0,41,40,42,43,37,36,38,39,43,38,39,41,40,0,43,42,44,45,39,38,40,41,43,40,41,43,42,0,46,47,48,49,41,40,42,43,43,42,43,45,44,0,49,48,50,51,43,42,44,45,43,44,45,47,46,0,51,50,52,53,45,44,46,47,43,46,47,49,48,0,53,52,54,55,47,46,48,49,43,48,49,51,50,0,55,54,56,57,49,48,50,51,43,50,51,53,52,0,57,56,58,59,51,50,52,53,43,52,53,55,54,0,59,58,60,61,53,52,54,55,43,54,55,57,56,0,29,62,63,64,55,54,56,57,43,56,57,59,58,0,64,63,65,66,57,56,58,59,43,58,59,61,60,0,66,65,67,68,59,58,60,61,42,35,33,31,0,69,70,71,34,32,30,42,35,31,29,0,69,71,72,34,30,28,42,37,35,29,0,73,69,72,36,34,28,42,37,29,27,0,73,72,74,36,28,26,42,39,37,27,0,75,73,74,38,36,26,42,39,27,25,0,75,74,76,38,26,24,42,41,39,25,0,77,75,76,40,38,24,42,41,25,23,0,77,76,78,40,24,22,42,43,41,23,0,79,77,78,42,40,22,42,43,23,21,0,79,78,80,42,22,20,42,45,43,21,0,81,79,80,44,42,20,42,45,21,19,0,81,80,82,44,20,18,42,47,45,19,0,83,81,82,46,44,18,42,47,19,17,0,83,82,84,46,18,16,42,49,47,17,0,85,83,84,48,46,16,42,49,17,15,0,85,84,86,48,16,14,42,51,49,15,0,87,85,86,50,48,14,42,51,15,13,0,87,86,88,50,14,12,42,53,51,13,0,89,87,88,52,50,12,42,53,13,11,0,89,88,90,52,12,10,42,55,53,11,0,91,89,90,54,52,10,42,55,11,9,0,91,90,92,54,10,8,42,57,55,9,0,93,91,92,56,54,8,42,57,9,7,0,93,92,94,56,8,6,42,59,57,7,0,95,93,94,58,56,6,42,59,7,5,0,95,94,96,58,6,4,42,61,59,5,0,97,95,96,60,58,4,42,3,61,5,0,98,97,96,2,60,4,42,3,63,61,0,98,99,97,2,62,60,42,3,1,63,0,98,100,99,2,1,62,43,1,0,62,63,0,1,0,101,102,1,0,63,62,43,60,61,63,62,0,68,67,102,101,61,60,62,63,42,30,32,34,0,103,104,105,31,33,35,42,28,30,34,0,106,103,105,29,31,35,42,28,34,36,0,106,105,107,29,35,37,42,26,28,36,0,108,106,107,27,29,37,42,26,36,38,0,108,107,109,27,37,39,42,24,26,38,0,110,108,109,25,27,39,42,24,38,40,0,110,109,111,25,39,41,42,22,24,40,0,112,110,111,23,25,41,42,22,40,42,0,112,111,113,23,41,43,42,20,22,42,0,114,112,113,21,23,43,42,20,42,44,0,114,113,115,21,43,45,42,18,20,44,0,116,114,115,19,21,45,42,18,44,46,0,116,115,117,19,45,47,42,16,18,46,0,118,116,117,17,19,47,42,16,46,48,0,118,117,119,17,47,49,42,14,16,48,0,120,118,119,15,17,49,42,14,48,50,0,120,119,121,15,49,51,42,12,14,50,0,122,120,121,13,15,51,42,12,50,52,0,122,121,123,13,51,53,42,10,12,52,0,124,122,123,11,13,53,42,10,52,54,0,124,123,125,11,53,55,42,8,10,54,0,126,124,125,9,11,55,42,8,54,56,0,126,125,69,9,55,57,42,6,8,56,0,127,126,69,7,9,57,42,6,56,58,0,127,69,73,7,57,59,42,4,6,58,0,128,127,73,5,7,59,42,4,58,60,0,128,73,129,5,59,61,42,2,4,60,0,130,128,129,3,5,61,42,2,60,62,0,130,129,131,3,61,63,42,0,2,62,0,132,130,131,0,3,63],
"bones" : [],
"skinIndices" : [],
"skinWeights" : [],
"animation" : {}
}
加载网格的代码是:
var loader = new THREE.JSONLoader();
loader.load('cylinder.js', function(geo, mat){
var materials = new THREE.MeshFaceMaterial( mat );
var mesh = new THREE.Mesh(geo, materials);
mesh.position.y=0;
mesh.position.x=5;
loadJson(mesh );
});
function loadJson(mesh){
scene.add( mesh );
}
结果: