Jump to content

Load scene, get "TypeError: a is undefined"


Recommended Posts

Hi, I'm new in babylon.js (and the others 3d frameworks). A moment ago I exported scene from *.obj to *.babylon. Now I'm trying to load it, but im getting error:


TypeError: a is undefined [babylon.min.js:2]


My simple code:

    if (BABYLON.Engine.isSupported()) {        var canvas = document.getElementById("renderCanvas");        var engine = new BABYLON.Engine(canvas, true);        BABYLON.SceneLoader.Load("", "/~patrol/objects/maps/city/scene.babylon", engine, function (newScene) {            // Wait for textures and shaders to be ready            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        });    }
Link to comment
Share on other sites

Your error is on this line


Bad = > BABYLON.SceneLoader.Load("", "/~patrol/objects/maps/city/scene.babylon", engine, function (newScene) {


The path should be in the first argument :


Good => BABYLON.SceneLoader.Load("/~patrol/objects/maps/city/", "scene.babylon", engine, function (newScene) {

Link to comment
Share on other sites

Couple of thoughts:


If you are going to post about an error in Babylon.js, do yourself a favor & use the debug version.  Line 2 of babylon.min.js has probably hundreds of statements.


SceneLoader, is not a statement executed inside a tight loop, so if having a '/' is not valid inside the filename arg, then performing argument validation should be done.  You can look at such things for a long time and not notice the issue.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...