var loader = new BABYLON.AssetsManager(scene);
var bane = loader.addMeshTask("bike", "", "/OBJFiles/", "bike.obj");
loader.load();
加载obj文件时写好了路径,然而JS会解析成一个url请求,这个时候需要修改路由。
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("*{objfiles}/*.obj", new { objfiles = "OBJFiles" });
routes.IgnoreRoute("*{img}/*.{imgext}", new { img = @"ad-images|images", imgext = @"(?i)jpg|gif|png" });
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
但是修改路由以后仍不能解决问题,obj文件还是不能正常加载。
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
<staticContent>
<remove fileExtension=".obj" />
<mimeMap fileExtension=".obj" mimeType="application/obj"/>
</staticContent>
</system.webServer>
试了一下在webconfig中加上obj的mime类型,凑巧的解决了加载问题。