Jump to content

Callback in Babylon.SceneLoader.ImportMesh


BSS
 Share

Recommended Posts

Hi guys,

I have  problem with babylon.sceneloader.importmesh. I tried importing mesh from .babylon file. Its importing correctly. but  the problem is the callback in importmesh function is called twice.because of this i got meshes. I need to call the callback only once. 

Help me out,

 

Note:

This is happening only in windows store app. Not in any other application.

Link to comment
Share on other sites

Hi guys,

I have  problem with babylon.sceneloader.importmesh. I tried importing mesh from .babylon file. Its importing correctly. but  the problem is the callback in importmesh function is called twice.because of this i got meshes. I need to call the callback only once. 

Help me out,

 

Note:

This is happening only in windows store app. Not in any other application.

 

Me too have the same issue, Anybody has any solution ?

Code :  

BABYLON.SceneLoader.ImportMesh("", "scene/", "link1.babylon", scene, function (newMeshes){// , particleSystems, skeletons) {

                       link1 = newMeshes[0];
                        link1.position = new BABYLON.Vector3(0, -2, 0);
                        link1.scaling = new BABYLON.Vector3(1.5, 1.5, 1.5);
                    }); 
Link to comment
Share on other sites

Ya dude, I tried adding console.log before and inside the import mesh.

Before Import mesh its calling once but inside (callback) it is calling twice. This issue is coming only in windows store app but the same is working fine in browser.

Please help me.

Link to comment
Share on other sites

Finally did a bad fix  :(

This issue is coming because of the following method calling twice "importMeshFromData(data)" in bababylon.js. Don't know whats happening before this call. The fix here is as follows in babylon.2.1.debug.js

 

Before:

BABYLON.Tools.LoadFile(rootUrl + sceneFilename, function (data) {     
                        importMeshFromData(data);
                    }                        
                }, progressCallBack, database);

------------------------------------------------------------------------------------------------

After : Added a new variable "scene_Filename"

BABYLON.Tools.LoadFile(rootUrl + sceneFilename, function (data) {                    
                    if (scene_Filename == "") {
                        scene_Filename = rootUrl + sceneFilename;
                        importMeshFromData(data);
                    }
                        
                }, progressCallBack, database);
 
I know its a bad fix, can anybody help me in finding the root course ?
*remember its happening only in windows store app
Link to comment
Share on other sites

Guys,

 

Attaching the sample project.

I have added a console.log inside import mesh in default.js. The below code is running twice and adding two meshes instead of one.

Please find the default.js inside "JSUniversalAPP.shared"

 

 BABYLON.SceneLoader.ImportMesh("", "scene/", "base.babylon", scene, function (newMeshes, particleSystems, skeletons) {
            console.log("----------- base mesh loaded -------------");
 });
 
 

 

JSUniversalApp.zip

Link to comment
Share on other sites

The problem is in method Database.prototype.checkManifestFile.

I run the demo app in debug, and here it what is done:

-checkManifestFile

   - creating xhr request : https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.database.ts#L64

   - try {xhr.send()} : https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.database.ts#L96

   - Entering in the catch block : https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.database.ts#L99

   - Later, entering in the 'load' event : https://github.com/BabylonJS/Babylon.js/blob/master/src/Tools/babylon.database.ts#L70

 

The last step should not happen. Maybe a bug only on Windows apps ?

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.

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

Loading...
 Share

  • Recently Browsing   0 members

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