我用这篇文章http://blogs.msdn.com/b/eternalcoding/archive/2013/06/28/babylon-js-how-to-load-a-babylon-file-produced-with-blender.aspx来加载巴比伦文件。
if (BABYLON.Engine.isSupported()) {
var canvas = document.getElementById("renderCanvas");
var engine = new BABYLON.Engine(canvas, true);
BABYLON.SceneLoader.Load("", "scene.babylon", engine, function (newScene) {
newScene.executeWhenReady(function () {
// Attach camera to canvas inputs
newScene.activeCamera.attachControl(canvas);
// Once the scene is loaded, just register a render loop to render it
engine.runRenderLoop(function () {
newScene.render();
});
});
}, function (progress) {
// To do: give progress feedback to user
});
}
最初它不起作用,但后来我在 web 配置文件中定义了 mimeMap,它开始工作
<mimeMap fileExtension=".babylon" mimeType="application/babylon" />
<mimeMap fileExtension=".babylonmeshdata" mimeType="application/babylonmeshdata" />
问题是当我将 scene.babylon 更改为我的 head.babylon 时,它不起作用。Firefox 没有加载任何内容,我在 IE 上收到此错误:
0x800a138f - JavaScript 运行时错误:无法获取未定义或空引用的属性“0”
我确实在http://www.babylonjs.com/sandbox/上尝试了 head.babylon ,它加载得很好。关于我接下来可以做什么的任何建议?