我有一个带有增强现实的 Three.js 项目,现在我尝试加载一个带有纹理的模型。出于某种原因,我的模型是黑色的,我没有纹理。我选中了搅拌机中的框以导出图像,我还在 t-rex(我正在使用的模型)的 .js 文件中看到它列出了纹理,但我的应用程序不会加载它。
编辑(添加代码) 我用来加载模型的代码:
new THREE.JSONLoader().load("models/trex.json", function(geometry) {
var material = new THREE.MeshFaceMaterial();
var dino = new THREE.Mesh(geometry, material);
dino.position.z = -50;
dino.scale.x = dino.scale.y = dino.scale.z = 2;
dino.updateMatrix();
dino.overdraw = true;
marker.object3d.add(dino);
});
我将它添加到标记对象,因为我正在使用标记,如果我显示标记,我希望在标记上(或正上方)绘制一个 trex。
trex 模型和这个一样,但是我在 blender 中打开它并使用最新版本的 blender 到 three.js 导出器:http ://alteredqualia.com/three/examples/webgl_trex.html
我的 trex.json 文件也如下所示:
{
"metadata" :
{
"formatVersion" : 3.1,
"generatedBy" : "Blender 2.63 Exporter",
"vertices" : 23273,
"faces" : 23268,
"normals" : 20842,
"colors" : 0,
"uvs" : [11497],
"materials" : 1,
"morphTargets" : 0,
"bones" : 0
},
"scale" : 0.0500,
"materials": [ {
"DbgColor" : 15658734,
"DbgIndex" : 0,
"DbgName" : "Material.001",
"blending" : "NormalBlending",
"colorAmbient" : [0.2933282256126404, 0.2933282256126404, 0.2933282256126404],
"colorDiffuse" : [0.2933282256126404, 0.2933282256126404, 0.2933282256126404],
"colorSpecular" : [0.13438941538333893, 0.13438941538333893, 0.13438941538333893],
"depthTest" : true,
"depthWrite" : true,
"mapDiffuse" : "trex_image_copy.png",
"mapNormal" : "trex_image_bump.png",
"mapNormalFactor" : 12.0,
"mapSpecular" : "trex_image_spec.png",
"shading" : "Phong",
"specularCoef" : 511,
"transparency" : 1.0,
"transparent" : false,
"vertexColors" : false
},
{
"DbgColor" : 15597568,
"DbgIndex" : 1,
"DbgName" : "Material",
"blending" : "NormalBlending",
"colorAmbient" : [0.7257574200630188, 0.7257574200630188, 0.7257574200630188],
"colorDiffuse" : [0.7257574200630188, 0.7257574200630188, 0.7257574200630188],
"colorSpecular" : [0.0, 0.0, 0.0],
"depthTest" : true,
"depthWrite" : true,
"mapDiffuse" : "trex_image_copy.png",
"mapLight" : "trex_image_eye.png",
"mapLightWrap" : ["repeat", "repeat"],
"shading" : "Lambert",
"specularCoef" : 1,
"transparency" : 1.0,
"transparent" : false,
"vertexColors" : false
},
{
"DbgColor" : 60928,
"DbgIndex" : 2,
"DbgName" : "Material",
"blending" : "NormalBlending",
"colorAmbient" : [0.7257574200630188, 0.7257574200630188, 0.7257574200630188],
"colorDiffuse" : [0.7257574200630188, 0.7257574200630188, 0.7257574200630188],
"colorSpecular" : [0.0, 0.0, 0.0],
"depthTest" : true,
"depthWrite" : true,
"mapDiffuse" : "trex_image_copy.png",
"mapLight" : "trex_image_eye.png",
"mapLightWrap" : ["repeat", "repeat"],
"shading" : "Lambert",
"specularCoef" : 1,
"transparency" : 1.0,
"transparent" : false,
"vertexColors" : false
}],
"vertices":
我尝试绘制一个框,然后添加纹理,这可行,但从 json 格式加载文件,然后显示纹理不起作用。
非常感谢!