there is nothing āwrongā with it, it is just very big, and generated more than 8000 draw calls:
Making the meshes not-pickable does improve things ( Model Speed Problem | Babylon.js Playground (babylonjs.com)), and there are other things you can do (like freezing the world matrix and the materials), but that depends on your use-case
I wouldnāt say that looking at this object. In fact, I donāt understand how it can contain 12k meshes or generate 8k draw calls. I believe many of these meshes could be merged, since itās unlikely that even the real object is actually made out of 12k parts. This would be four times the number of parts you can find on a car (the real one, the eng version). I cannot see this in this object.
Huh (joke) Get a real 3D edit app
Jokes apart, I donāt know this āthingā but there might be some export options you can try.
Or try export to another format/other app.
Last, you could merge meshes in BJS but seriously, I wouldnāt have the patience nor time to select from 12k meshes to create merges. My limit is at around 2k (for an offroad vehicle) and already with this, I want to kill the design team from the manufacturer
Stackoverflow, really? If you get an answer from there that is not just a complete piece of crap, Iād say itās incidental.
Do you have any export options for GLB? Do you have gltf? Or obj?
Once converted, have you tried opening it in i.e. Blender, see if you can somehow find your way around groups of meshes? How many meshes do you have initially in your app? I guess no more than about 500. It really all comes from the export, so you need to focus on that.
Hope you are well.
I am sorry for yesterday (end of day) I didnāt really take the time to have a closer look at it and provide better insight. I shouldnāt work in the evening and reply to posts. It always ends up with crap or rough answers Also, I stopped just looking at the numbers thinking I will certainly not investigate 12k meshes. But then, I thought back this morning, remembering the structure of the file.
It appears that each group of meshes is attached to a transform node, which is likely to be (i checked two nodes) the mesh or group of object meshes converted all to polys. What the (sry) crap program export is doing is converting all tesselation (and likely vertices) to meshes and place all in a transformNode. Now, if you donāt find a way to make a proper export or re-import (i.e. in blender to remerge the children of these transformNodes), there would still be a solution, not perfect, that would drastically reduce the number of meshes and draw calls, on BJS import. But best would certainly be to preserve these meshes on export, so let me know if you managed to do that or not. If not, we can still call on all children of each transformNode, merge them and dispose of the parent. In the end we should have less than 100 meshes (from a rough count). As I said, it would not be perfect (still about 10 times higher than what it should be) but nothing compared to what you have now.
Not a problem at all, I apreciate your helps. I want to give more detail. Opencascade is a C++ library. I am using that library to convert uploaded STEP files by users to GLB file with GLTFWriter function. Then import to BJS.
So I am trying to reduce mesh count since you warned about this. At least I know the problem now.
t
So reducing on BJS import can be my only option. Does it take long time and can you guide me on how to do it?
Itās actually quite simple (but as I said not perfect). So I expect it will give a fairly good result on this object but if your scene have dozens of these, you would definetely need to find another approach that preserves the integrity of the original meshes. I am also not sure what visual result it will give on shapes like spirals. May be weāll need to recreate some materials. Materials will have to be assigned anyways since some transformNodes seem to contain not just one object but a group of object.
Sure. At least for a start. I will give it a try later (in a few hours) simply selecting from all transformNodes and merge all children and if thatās ok with you, weāll see what this does, for a startā¦
Actually I am only using scene.transformNodes. So these transformNodes are parts from assembly. So I only need parts not meshes. I want to make users able to attach mesh when click on a part. Since there is a ārootā mesh avoids this, after importing the model I set parent of all transformNodes to ānullā.
So I guess merging children of these transformNodes is even better .
Hello again,
I have some news for you. Good and bad news.
The good news is it will work and we will likely not have to reassign materials. And the other good news is that you will indeed be able to make your new remerged meshes pickable.
The bad news is for now I only had little time to make a quick attempt and draft the base script. I still need to make it dynamic and run through all nodes. Problem is I donāt have more time right now and would only be able to do it from tomorrow morning. If you canāt wait you can still try yourself if you know how to create a routine on all transform nodes and build an array of child meshes and use in the contructor for merging meshes. Nothing extremely complex itās just that (sry) iām running out of time for today.
Edit: If you want to do yourself, the idea of mine is to
create a numbered index for the 52 transform nodes (luckily they all have the same name and following number, so this should be easy.
have a routine doing basically what I did hard coded; this time using the index to perform the following operations
get all child meshes from a transform node
rename them from 0 to x
unparent from transform node
merge all childs of this transformNode and assign the merge the name of the transformNode
dispose of parent
For each. On end, make a promise for all or use on scene ready observable, as required.
Well, I sort of started 30min ago but LOL Iām having an issue inserting either my Array or String in the merge mesh constructor.
I am getting an error. I must be doing something w rong but I donāt know what. May be you know? Else, I guess I will just quickly reach out to someone who will likely fix it in a minute.
This is actual state/attempt
Let me know in the next hour if you feel like taking over or if you (also) struggle with it.
Looks like I still have things to learn
THANK YOU. I guess you understand that when I said āI know a person that will fix it in a minuteā I was of course thinking of you Youāre just so amazing. Have an awesome day
@omerization : Are you all good with this now? The last part should be ez (hopefully
Else, let us knowā¦
Yes, I was afraid of that. Reason I would have checked with just this object first.
But I guess you could fix it (or improve it a lot) using a web worker (doing the job outside the engine/scene).
Actually multiple web workers if you have more of these in one scene.
Edit: Iām not sure you can do it for merging meshes. I am not much of a backend dev, sry. Just a simple designer. But I can callin some people who will know or can may be propose some other solution for this part. Would you have a new PG to share with this new base?