Three.js Loading .OBJ error in Azure but not Local

2019-01-26 20:06发布

I am using three.js for webGL to load .obj but I have a problem when loading .obj in Windows Azure runnning Windows Server 2008 I using Google chrome browser and it gives the error below:

GET http://websiteaddress.net/webGL/obj/test.mtl 404 (Not Found)

even, I used their original source code to load .obj file it has the same error

and when i try to navigate other images file in the server i can preview it eg: (website.net/images/test.gif) - i can see the test.gif image in the browser

but when i navigate to .obj, i receive error in the browser: (eg : website.net/obg/test.obj)

404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

i can view my .obj locally but not when I put it in Azure! can anyone helps me? Thanks!

4条回答
女痞
2楼-- · 2019-01-26 20:33

I thought I should add what I ended up doing after finding this post. I'm using .mtl files for material (in addition to the .obj) for a THREE JS project. Since I'm using MTLLoader to get the materials as well (my models aren't just flat-color), I had to add the following line:

web.config

 <!-- Instruct IISNODE to treate .obj+.mtl models as application/octet data -->
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension=".obj" mimeType="application/octet-stream" />
            <mimeMap fileExtension=".mtl" mimeType="application/octet-stream" />
        </staticContent>
    </system.webServer>
</configuration>
查看更多
Bombasti
3楼-- · 2019-01-26 20:36

I found an answer to my problem, is because the file extension .obj is not yet map to the MIME type in my Azure server:

Check the link below on how to add it:

http://technet.microsoft.com/en-us/library/cc725608(v=ws.10).aspx

and you could check here for the MIME type:

http://filext.com/file-extension/OBJ

Once you have map .obj to MIME, you will have no problem to load it anymore! :)

查看更多
Summer. ? 凉城
4楼-- · 2019-01-26 20:40

You will need to add a mime type definition in your application to tell IIS how this file should be served. The mime map referred to in the error message should be defined in the web.config file. Here's an example.

<system.webServer>
     <staticContent>
            <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
            <mimeMap fileExtension=".m4v" mimeType="video/m4v" />
     </staticContent>
 </system.webServer>

Click on the link below for a full list of mime types:

Full list of mime types.

查看更多
三岁会撩人
5楼-- · 2019-01-26 20:47

[SOLVED] LOADING .OBJ (Wavefront) FILE IN WINDOWS HOSTING RETURN 404 ERROR [SOLVED]

As I was Working with Three.js and loading a .obj file works great for me in localhost but when running the files from the Windows Hosting it return 404 for the .obj file.

So, we need to add this lines to the web.config file of the project root folder (if you don't have the file in your project root folder then go ahead and create one. )

web.config

        <?xml version="1.0" encoding="UTF-8"?>
        <configuration>
            <system.webServer>
                 <staticContent>
                        <mimeMap fileExtension=".obj" mimeType="application/octet-stream" />
                 </staticContent>
            </system.webServer>
        </configuration>

Place the web.config to correct location and Enjoy :)

查看更多
登录 后发表回答