Squirrl
Squirrl

Reputation: 4966

Getting a 404 error with THREE.ImageUtils.loadTexture and three.js

I'm trying to load a 3D model and use three.js for the first time. I keep running into an error loading the textures.

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

If I comment out the loadTextures the image loads properly, and functions. If I don't, the image does not show up. Either way, I get this error:

GET http://localhost:8080/models/asteroid_OBJ/-bm%200.800000%20Map__4_Mix.tga 404 (Not Found)

As far as I can tell the textures are in the correct directory aside asteroid OBJ.js

Upvotes: 1

Views: 1676

Answers (1)

Steffan Pallesen
Steffan Pallesen

Reputation: 570

When i get this error, it is because i have forgotten to register .tga as a file extension in my Web.config file. Your Web.config file should look something like this:

<system.webServer>
             <staticContent>
                    <mimeMap fileExtension=".obj" mimeType="application/octet-stream" />
                    <mimeMap fileExtension=".tga" mimeType="application/octet-stream" />

             </staticContent>
</system.webServer>

Upvotes: 1

Related Questions