Jump to content

Waiting for everything to load


Recommended Posts

Hey there,


I have a problem with my imported babylon-mesh. Its not that small, and sometimes if I refresh the site, it is loaded to the half (the balloon loads, the basket not). Thats probably because the basket uses some textures, the balloon not.

Is there a way to wait for everything (also textures) to load? Like the spinning circle from a lot of bablyonjs-projects featured on the main site.


Here is the project:





I don't want to seem unthankful, and because of that this small information: I'm not at home from now on till probably tomorrow  :rolleyes: Thanks for any answers, I'll have a close look tomorrow!

Link to comment
Share on other sites

yes you can: just call the runRenderLoop inside a scene.executeWhenReady:

var canvas = document.getElementById("renderCanvas");var engine = new BABYLON.Engine(canvas, true);BABYLON.SceneLoader.Load("TestScene/", "test.babylon", engine, function (newScene) {    newScene.executeWhenReady(function () {        newScene.activeCamera.attachControl(canvas);        engine.runRenderLoop(function () {            newScene.render();        });    });}, function (progress) {    // To do: give progress feedback to user});
Link to comment
Share on other sites

I guess I had a complete wrong approach to loading 3D-models into the scene. However, I'm not quite sure what I did wrong now.


I created a complete fresh file for testing the assetsmanager and added a clean code from the beginners tutorial to be sure to have a working scene.



The balloon is loaded correctly, but it seems like I cannot modify its position. This is what I've added to the sourcecode:

var assetsManager = new BABYLON.AssetsManager(scene);var balloon = assetsManager.addMeshTask("balloon", "", "", "balloon-ef.babylon");balloon.onSuccess = function (task) {   task.loadedMeshes[0].position = new BABYLON.Vector3(0, 10, 0);}				assetsManager.load();
Link to comment
Share on other sites



Your code is correct. However, your 3D model (exported from Blender as I suppose) is not.

The attribute mesh.position returns the pivot point of the mesh: Your model is actually positionned at x: -1.565878181216135, y: 829.4620088867188, z: 0.7638135395141035}.


Try to set the model in Blender in (0,0,0), export it again and test your code. (and don't forget to empy your cache :) )

Link to comment
Share on other sites

Meh, 3D modelling is a buggy mess. I created the balloon with SketchUp, and if I import it into blender there is always something not working correctly. When I export it to blender using .3ds, the .babylon-file has seriously size issues (the basket is too small, etc). If I export a .dae, there is a small balloon inside the basket of the balloon. It is a pain in the ass. However, my op question has been resolved, thanks for that! :)

Link to comment
Share on other sites

If you import into Blender for the purpose of exporting .babylon files to BJS, I always advise resetting all transforms on your objects in Blender - especially if you will be using bones to weigh vertex deformations on any mesh.  But as different software packages and export file formats use dramatically different units of measurement internally, resetting all matrix transforms in Blender will allow Blender (or any other program you use as a final export program to BJS) to reset and somewhat unify the units of measurement, which then are used in transforming your object's centers which are set at render time - to the familiar babylon.js units of measurement.


I advise finding a sequence of file formats and software in which you create your operators such as texture UVs, bones, hierarchies, etc. which will provide you with consistant results, and to use these routinely and repeatledly to maintain consistant and repeatable values in your pipeline in case you need to troubleshoot problems which invariably will arise in almost every project.





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