hen Posted December 13, 2015 Share Posted December 13, 2015 Hello, is it actually possible to load a gltf mesh in to Babylon? I noticed that gltf mesh loading is not working so far, but isnt it possible to add a loaded mesh from scene A to scene B like with the code below? BABYLON.SceneLoader.Load("./assets/", "character.gltf", this.engine, function (gltf) { myotherscene.addMesh(gltf.meshes[0]) });Actually this is resulting in to a freezed screen... Am I doing something wrong here or is this just not supported? Cheers Hen Quote Link to comment Share on other sites More sharing options...
RaananW Posted December 13, 2015 Share Posted December 13, 2015 Hi hen,A mesh belongs to a certain scene and I'm not sure what the consequences are, if you add it to another. I guess you just found out :-)There are two ways to solve this -Use the append function, instead of load. This function accepts a scene as a variable, instead of the engine. It will load the objects to this scene, instead of creating a new one.The second option is to use the mesh's clone function. You could clone it to another scene.BTW - I am assuming here that the loader is working correctly. You could have the same question for any other file type. Quote Link to comment Share on other sites More sharing options...
hen Posted December 14, 2015 Author Share Posted December 14, 2015 Hi RaananW, the append function works actually to load the asset, but it seems that theres no way to track what has been loaded, such as mesh IDs, materials etc... Using sceneloader.load i did add a loop over the loaded meshes, cloned each and added it to the scene using scene.addMesh(mesh), but this ends up with a freezed screen. Maybe i need to clone the bones separately? Quote Link to comment Share on other sites More sharing options...
RaananW Posted December 14, 2015 Share Posted December 14, 2015 scene.addMesh won't probably be enough. the mesh has a private scene reference.This won't be as easy as I thought. You will need to add the materials, geometries, skeletons etc' to the new scene as well. I really think the append function (or the ImportMesh, which can import specific meshes) would be the safest choice. You can use tags, and add a tag to any object that was already processed by you. Then scan the scene for meshes / other nodes that don't have this tag. This way you can easily tell what was appended. julien-moreau 1 Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted December 14, 2015 Share Posted December 14, 2015 Hi hen, Happy that you use the glTF format Unfortunately, the ImportMesh function (that returns the loaded meshes, particle systems and skeletons) is not yet available in the glTF loader.Can you confirm that the loader works well with the assets ? Except the logic you need to manage your assets after loading Quote Link to comment Share on other sites More sharing options...
hen Posted December 14, 2015 Author Share Posted December 14, 2015 Hi Luaacro, yes the loader works well when I append the whole scene, even with more complicated animated meshes. The application i work on allows collaborative editing of the game levels. To make this work right with gltf, i would need somehow to set the IDs to the meshes. Actually i dont need to load all content from gltf. Could i maybe clone the geometry and skeleton to create a new mesh in that other scene? Another question is about attaching skinned mesh props to a skeleton.Ive seen a demo about bone attachments, but is that working for skinned meshes like character clothings as well? Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted December 14, 2015 Share Posted December 14, 2015 Sounds good I think the "ImportMesh" function is the perfect candidate for you. I'm going to work on and come back when it is working well Then, you'll be able to retrieve an array of the loaded meshes and skeletons. RaananW 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted December 14, 2015 Share Posted December 14, 2015 excellent Quote Link to comment Share on other sites More sharing options...
hen Posted December 14, 2015 Author Share Posted December 14, 2015 Perfect.. thanks Luaacro! Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted December 15, 2015 Share Posted December 15, 2015 Thanks to @RaananW, the pull request was merged: https://github.com/BabylonJS/Babylon.js/tree/master/loaders/glTFIt contains the latest version of the glTF loader with the support of the ImportMesh function. You can read the README for more informations and how to use this function Quote Link to comment Share on other sites More sharing options...
hen Posted December 15, 2015 Author Share Posted December 15, 2015 Thanks for updating the loader! Actually I still have problems using it, maybe its because im using the babylon alpha?The code below is freezing the scene and causes a browser crash.BABYLON.SceneLoader.ImportMesh(null, "./assets/", "man.gltf", this.scene, function (meshes, particleSystems, skeletons) { console.log(meshes, skeletons) // never reached }); Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted December 15, 2015 Share Posted December 15, 2015 Hum, looks good Can you send me the 3D model you use by PM ? And share here the errors in the console ? Thanks ! Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted December 15, 2015 Share Posted December 15, 2015 Thanks hen for the modelI think it is related to the camera view (badly set by the loader or badly set in the file). I'm taking a look on it. I used this workflow to test your 3D model (created my own camera instead of the one in the glTF file)var scene = new BABYLON.Scene(engine);var camera = new BABYLON.ArcRotateCamera("camera", 0, 0, 20, BABYLON.Vector3.Zero(), scene);camera.attachControl(canvas);BABYLON.SceneLoader.ImportMesh(null, "Tests/glTF/", "man.gltf", scene, function (meshes) { camera.target = meshes[0];}); RaananW 1 Quote Link to comment Share on other sites More sharing options...
hen Posted December 15, 2015 Author Share Posted December 15, 2015 While i wrote the pm to you, the model was loaded.It tooked about 5 minutes to load the sample model i sent you. Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted December 15, 2015 Share Posted December 15, 2015 Ah ! Lol ! Are you loading the model throught a server or localhost ? Quote Link to comment Share on other sites More sharing options...
hen Posted December 15, 2015 Author Share Posted December 15, 2015 Ah ! Lol ! Are you loading the model throught a server or localhost ? Local node.js server. Oh i see, it works when loading it from dropbox. Quote Link to comment Share on other sites More sharing options...
julien-moreau Posted December 15, 2015 Share Posted December 15, 2015 I think you should allow the mimetypes on your local serverLike this (with IIS):<mimeMap fileExtension=".gltf" mimeType="application/gltf" /> 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.