fitocs452 Posted March 27, 2017 Share Posted March 27, 2017 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 index.html Quote Link to comment Share on other sites More sharing options...
Wingnut Posted March 27, 2017 Share Posted March 27, 2017 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... camera.activeCamera.attachControl(canvas); Probably should be... newScene.activeCamera.attachControl(canvas); 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. camera.attachControl(canvas); }); }); 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.