我尝试加载3D模型并首次使用three.js。我一直在加载纹理时遇到错误。
loader.load('models/asteroid_OBJ/asteroid OBJ.js', function (geometry, materials) {
var material = new THREE.MeshLambertMaterial({
//map: THREE.ImageUtils.loadTexture('models/asteroid_OBJ/Map__4_Mix.tga'),
//map: THREE.ImageUtils.loadTexture('models/asteroid_OBJ/Map__12_Cellular.tga'),
//map: THREE.ImageUtils.loadTexture('models/asteroid_OBJ/Map__15_Noise.tga'),
colorAmbient: [0.480000026226044, 0.480000026226044, 0.480000026226044],
colorDiffuse: [0.480000026226044, 0.480000026226044, 0.480000026226044],
colorSpecular: [0.8999999761581421, 0.8999999761581421, 0.8999999761581421]
});
如果我注释掉loadTextures,那么图像会正确加载并运行。如果我不这样做,图像就不会显示出来。无论哪种方式,我都会收到此错误:
GET http://localhost:8080/models/asteroid_OBJ/-bm%200.800000%20Map__4_Mix.tga 404 (Not Found)
据我所知,纹理位于asteroid OBJ.js
答案 0 :(得分:1)
当我收到此错误时,这是因为我忘记在我的Web.config文件中注册.tga作为文件扩展名。您的Web.config文件应如下所示:
<system.webServer>
<staticContent>
<mimeMap fileExtension=".obj" mimeType="application/octet-stream" />
<mimeMap fileExtension=".tga" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>