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

前端 未结 4 1989
北海茫月
北海茫月 2020-12-19 19:41

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 th

相关标签:
4条回答
  • 2020-12-19 19:59

    [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 :)

    0 讨论(0)
  • 2020-12-19 20:02

    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! :)

    0 讨论(0)
  • 2020-12-19 20:12

    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>
    
    0 讨论(0)
  • 2020-12-19 20:17

    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.

    0 讨论(0)
提交回复
热议问题