Jump to content

Is it possible to load a Mesh without showing it in scene ?


 Share

Recommended Posts

Hi,

I'm loading a mesh like this :

Quote

BABYLON.SceneLoader.ImportMesh("", this.baseFolderUrl, this.fileName, this._refScene, function (newMeshes) {
    

Is it possible to load the mesh without displaying it immediatly on scene ?

Idealy, I would like to be able to load all the mesh data, store it in a var, and then load/unload it frome the scene.

The idea behind it it that i don't need the base mesh, but i would like to be able to .clone() it and set it's data before displaying it.

 

Thanks a lot for your ideas.

 

Link to comment
Share on other sites

Or you can load them into second scene and clone them.

var loaderScene = new BABYLON.Scene(engine);
var loader = new BABYLON.AssetsManager(loaderScene);
var assets = {
"your_mesh_name":loader.addMeshTask("name", "", "/static/models/hand/", "hand.babylon")
};
loader.load();
loader.onFinish = function (tasks) {
    scene = createScene();
};

var clone = function (name) {
    var clone = assets[name].loadedMeshes[0].clone("");
    clone._scene = scene;
    
    if(clone.material)
    {
        clone.material._scene = scene;
        if(clone.material.subMaterials)
        {
            for (var i = 0; i < clone.material.subMaterials.length; i++) {
                clone.material.subMaterials[i]._scene = scene;
            }
        }
    }
    scene.addMesh(clone);
    
    return clone;
}

var mesh = clone('your_mesh_name');

 

Link to comment
Share on other sites

You can also put / adjust visibilty in the .babylon file.  You can also set enable to false.  Enable also affects children.  The Blender exporter supports editing visibilty, saving in .blend, & exporting.

outlinerSettings.png

I am not a fan of .babylon files, but even less impressed with ImportMesh.  To do all meshes, unless you have cameras or lights in the .babylon file, Append does the same thing.  You get an array of the new meshes with ImportMesh, but better to look them up by name.  The forum is littered with problems where the someone assumed newMeshes[0] was "it", but they screwed it up.

Link to comment
Share on other sites

  • 2 months later...

This help me out well since I using the scene assets and other into the main scene. But it odd that it doesn't copy mesh to current scene when scene.addMesh doesn't work well. Had to used mesh._scene to deal with the render update scene to get it working. Plus some odd error like it freeze or lag or frame stop when try to look up camera free style.

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