Jump to content

Error when importing a scene


Recommended Posts

I'm getting this error when trying to import a babylon file


Uncaught ReferenceError: camera is not defined
    at Observer.callback (localhost/:33)
    at Observable.notifyObservers (babylon.max.js:3399)
    at Scene._checkIsReady (babylon.max.js:15546)
    at babylon.max.js:15540


You can see the code on attachment.

Help please :)


Link to comment
Share on other sites

Hi @fitocs452, welcome to the forum.  I'm no expert at loading... but I want to show you some things.

#1.  Your loader code is slightly old.  Please look at THIS playground demo.  Model loaded ok?  Notice line 6 ...  Append instead of Load.  Not sure why Append is preferred ... but I heard it is.  Perhaps 'Get ZIP' of this playground, home-edit the index.html (to point to your generic-houses-1.babylon), and try that.  Does it work?

#2.  Here is another playground demo.  It uses 'ImportMesh instead of Append or Load.  Scene look good?  Model render?  Perhaps do the same with THIS playground. Use the 'Get .zip' button on the playground, take it home, adjust the index.html for generic-houses-1.babylon, and see if things load-in/display.

Note:  Look carefully at the previous playground demo.  In line 3 we define a 'camera', and in line 12 we define another 'camera'.  This is not unusual when working inside the playground.  Notice that the playground app complains of not having a camera... when I disable the first camera.  That happens mostly in playgrounds.  We can talk more about that later.  I just wanted to tell you about the reason for seeing two cameras being defined.  The top camera, if not set as the scene.activeCamera... is there ONLY to "fool" the playground... avoiding its "You must have at least one camera" error.

#3.  If you want to keep trying YOUR index.html, I see one little mistake... 


Probably should be...


If I understand error report, the camera is missing... within .executeWhenReady function.  You COULD try this...

BABYLON.SceneLoader.Load("", "generic-houses-1.babylon", engine, function(newScene){
   newScene.executeWhenReady(function() {
        var camera = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(0, 5,-10), newScene);
        newScene.activeCamera = camera;  // this line might be removable - done automatically.

Might work.  :)

Okay, that's all I have for you, so far.  Do you have a free GitHub account?  That is where I stored my bjs_text.babylon file (as you can see), and it would be a good place for YOU to "publish" your generic-houses-1.babylon (so we could suck it into the playground for testing). 

Others (smarter people than I) may comment soon... it's still early.  :)  Hope this helps.  Be well, talk again soon.

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...