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