Since your model is already big enough I also would advise to highlight on mouse down (or up, or onClick) but not on mouse over (which is more perf expensive).
The trick is that when you point to the instanced mesh which should be highlighted (for example) you substitute this instance with cloned mesh which could be highlighted with no problems.
You can use Transform nodes to get info which instance is hit and make some logic out of it.
There were some threads where this approach was described more detailed.
O wow that sounds extremely complicated but I guess that’s what I need. I’m a complete novice as Labris will tell you
it’s not so bad, here’ a quick example using instances of a sphere mesh. (Edit: I filled in a few missing parts)
Would that still work with 500 buildings of which about 150 are unique?
You would need a separate, non-instanced mesh for each of the 150 unique meshes. The cloning to create them could be done at run-time thou…
Ah I’m afraid I can’t do that with my model then it’s already maxed out. the city is all created via blender and instanced as optimal as I can possibly get it to fit all what you can see in there at the moment. If I non-instanced meshes it would barely load
Is there any chance you could show me how this is done in the playground I have please with two set’s of instanced buildings that are different. https://playground.babylonjs.com/#9Z476P#8
This and the pop up we talked on the other forum are the two last things I need to understand before I can launch my website and the model
You may reduce the file size and load time if you’ll leave only transform nodes for instances in your model and after loading put there instanced (or ever thin instanced) objects programatically.
I wish I knew what you meant. I may have to come back to this thread after I can get the pop-up working as that is the must have and this is the should have requirement for the model.
Let’s start pop-up things with GUI, it will be easier to debug (better in other thread for better readability).
I’ll prepare some example later to show what I meant with model size reduction. It is may be not so complicated as it sounds
Thank you appreciate your help as always by the way - I’ll need to import widget shortcodes from my actual website as the information will change from time to time (I’m guessing that may be a problem with GUI’s in the model). That wordpress site you showed me may be the way if I can figure it all out.
Only one of the clones is enabled at a time thou so performance/FPS shouldn’t be affected too much and they can be created at run time so it doesn’t affect the file size either…
I don’t really understand how to do that if I’m honest. I’ve only just got started with Blender let alone Babylon coding I like the idea. If you can show me in the playground I have I might be able to understand it a bit better (the one with a few buildings) https://playground.babylonjs.com/#9Z476P#8
PHP runs before JS so it shouldn’t be a problem.
Here’s an example based on your PG that creates one clone for each of the unique source meshes at runtime. IDK if the highlighted mesh will be moved/rotated/scaled like for an editor, so I left out the part to copy those values back over, but let me know and I can make a little update for that.
It gets a little complicated at parts, but basically if there’s instances of meshA and instances of meshB, then only 1 clone will be created of meshA and used for meshA and its instances. Same for meshB, with one clone being created for meshB and its instances…
(Editted to add some comments and simplify a little more)
Thank you so much for helping, it’s morning here in the UK now so I’ll check in an hour or two
It works perfectly thank you. A few small issues though, the framerate has dropped quite a bit and I need to disable highlighting some of the meshes like the ground and base if that’s possible to exclude them? See below
Docs - Highlighting Meshes | Babylon.js Documentation
The syntax is extremely simple:
hl.addExcludedMesh(ground);
Awesome, thank you @labris
That’s pretty much this part done then I think. Just refining the map even further in Blender to help with the frame rate.
That didn’t seem to want to work for some reason: