Looks like you accidentally passed the variable camera that doesn’t exist. It works if you pass scene.activeCamera that was created with createDefaultCameraOrLight() - or you can just let the param default to scene.activeCamera like below.
@James1 Having the console open (F12 with Chrome) really helps a lot with debugging.
In your example there is even a hint at which line you did some mistake which is now corrected by @Blake
Better to use mesh names.
I believe the problem is related to how your model is done.
Probably you’ll need to prepare it for the desired functionality in some 3D editor.
For example, rename meshes so they wouldn’t have identical names.
Hi, it uses instances to so it duplicates the meshes across the map I have. Using meshes with this highlight method highlights 10 or so buildings when one mesh is selected.
Hi, I’m in blender and as they are instances - if I rename one, it renames them all unfortunately so I have to go for an alternative solution (UniqueId’s if possible).
Well, I don’t know much about Blender but in C4D you can create instances and name them as you need to.
I believe that more experienced Blender users could help you.
Here is what I’ve got in Blender (please note that I don’t use it in my work so I don’t know much about it). Seems that all objects have different names now.
My new babylon example has all different names as far as I can see and it doesn’t seem to want to select each object individually. I will look into the blender option - there must be a way to rename but keep the instances the same, thanks.
The source points to it being the same Mesh but I would have thought stating the name would have been enough to make it unique.
I think the problem is that instances are all drawn together so either they’re all highlighted or none of them are highlighted, but if you use clones instead you can highlight just the one that’s hovered over since they’re drawn separately, one at a time.
Also you can check that the mesh isn’t named “someName” like this, you might want to make the mesh un-pickable or check the name in the pick predicate instead thou (if you don’t want the mesh to block the pick).
if (result.pickedMesh && result.pickedMesh.name !== "someName")
Unfortunately I need them to be instanced. The model size exponentially increases if I use clones rather than instanced. I can’t change the object data in blender either unless i remove the relationship. I tested with just 10 buildings and it doubled the file size. I have over 500 buildings in the model and it’s already a 100mb file that has been repolyed to the max.
A common approach that works well IMO is to create a single clone of the building to use for highlighting and then on mouse over, disable the instance and enable the clone and copy the transform over…
I mean you can use a separate, non instanced building for the highlighting. Then disable the selected instance that the mouse went over and enable the clone and copy its position, scaling, rotation from the instance.