satguru Posted January 16, 2018 Share Posted January 16, 2018 I see that the babylonjs loader does not convert the glb or gltf meshes from right-handed system (their native format) to left handed system. Instead it seems it parents them with "__root__" nodes to handle them in a left handed system. Is it not possible to convert them entirely to left handed-system? Quote Link to comment Share on other sites More sharing options...
bghgary Posted January 16, 2018 Share Posted January 16, 2018 @satguru The loader does not currently convert the data from right-handed to left-handed. It is computationally expensive to do this. glTF is intended to be a runtime format, so it is intended to load fast. You have two choices with the loader. Either continue with the "__root__" transform that flips the z scale or change the coordinate system of BabylonJS to right-handed. Do you have a scenario that requires the data to be converted? Quote Link to comment Share on other sites More sharing options...
satguru Posted January 16, 2018 Author Share Posted January 16, 2018 @bghgary What if there are multiple meshes in the file and I want to import just one mesh? Also I tried using right using BabylonJS using right handed system but ran into a problem. see this post Also, with right handed system I still see __root__ nodes. Quote Link to comment Share on other sites More sharing options...
bghgary Posted January 16, 2018 Share Posted January 16, 2018 @satguru The loader always creates a "__root__" node right now. If you just want to import one mesh, pass in the name of the node in the glTF to the importMesh function of the SceneLoader. Quote Link to comment Share on other sites More sharing options...
satguru Posted January 18, 2018 Author Share Posted January 18, 2018 @bghgary __root__ and a scaling of -z doesn't seem right. A quick way to bring gltf to babylonjs perhaps but not sure if it is a good long term solution. It makes gltf feel like a special case. People will have to take special care to handle it. They will have to remember that in babylonjs each gltf mesh comes with am extra parent node of __root__. Every time they scale they would need to make sure scale in z is -ve. Rotation around z would be counterclockwise , baking seems to be an issue and so on. A gltf mesh will feel different from other babylonjs meshes. Not a good idea if we want to make gltf native to babylonjs. Quote Link to comment Share on other sites More sharing options...
bghgary Posted January 22, 2018 Share Posted January 22, 2018 @satguru We can add an option to convert the data on load, but it will be expensive. @Deltakosh What do you think? Quote Link to comment Share on other sites More sharing options...
satguru Posted January 23, 2018 Author Share Posted January 23, 2018 An option would be nice. How expensive can it get? Also what about an offline converter? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 23, 2018 Share Posted January 23, 2018 Not a problem for me as long as it stays off by default Quote Link to comment Share on other sites More sharing options...
bghgary Posted January 23, 2018 Share Posted January 23, 2018 Quote How expensive can it get? The cost is iterating through every single float of positions, normals, tangents, indices, etc. Depending on the model, it can be quite expensive. It certainly does not scale well. Quote Also what about an offline converter? This isn't possible. glTF is expected to use right-handed data. If you are going to convert offline, might as well convert to a .babylon file. Pryme8 1 Quote Link to comment Share on other sites More sharing options...
satguru Posted January 24, 2018 Author Share Posted January 24, 2018 1) won't we have to iterate through each of the elements anyway, to move them from gltf data structure to babylon data structure? Or is the gltf data structure so similar to the babylon data structure that that won't be an issue? 2) by offline I did mean creating a .babylon file 3) not sure about making the option off by default. In a right handed scene I am assuming we won't be adding a "__root__" node. So by default in right handed scene the meshes would show up without "__root__". Whereas, if the default is off, then by default in a left handed scene meshes will show up with "__root__" node. Potential for confusion? Quote Link to comment Share on other sites More sharing options...
bghgary Posted January 24, 2018 Share Posted January 24, 2018 1) No. Once the array is created, we can put it straight into Babylon vertex buffer. This is not fully happening yet though. 3) "__root__" is always added to ensure consistency. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted January 24, 2018 Share Posted January 24, 2018 You might be better suited to just run all your meshes through a batch and get them converted to a more BJS usable convention. Quote Link to comment Share on other sites More sharing options...
satguru Posted January 24, 2018 Author Share Posted January 24, 2018 3) One of the reason I was advocating converting to left handed system was to avoid adding extraneous nodes. In other words keep things as close as possible to the original. We don't want users scratching their head wondering "from where did this node come from? I didn't have this in my gltf file". So I was thinking that there should be something like a "fast-left-handed-load" option which should be off by default. That option would come with the caveat that if the user turns it on then they would get faster load time but at the cost of having to deal with an extra nodes called "__root__" and -ve scaling. Quote Link to comment Share on other sites More sharing options...
Fenk Posted July 6, 2023 Share Posted July 6, 2023 Hi there! Was this ever elaborated? Would be a great non-default option to convert the coordinate system of the loaded assets. Usecase: Upload .glb to a private server -> import .glb into a scene -> convert it to left handed -> export as .babylon -> provide on server -> use .babylon-asset in different scenes. This way the expensiveness would be "hidden" in the upload/conversion process. Wouldn't even need to be a loader option. Just a "apply(bake)-glb-transforms" or something like that. I tried to do the conversion myself in code, and it seems possible, but unfortunately I'm not that experienced yet. Going to proceed in this direction if you say this is never going to be an option. Any help or pointing in the right direction would be much appreciated as well in this case. Thanks! 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.