Need to be able to pick child component (node) with click instead of material reference
I am trying to build an app to allow users to click components in a GLTF assembly and highlight the selected component (among other things).
I am aware of using materialFromPoint(x,y) to get the material attached to the clicked item, but this is not sufficient for my use case for a few reasons:
-
most 3D models (at least in my experience) do NOT have unique materials assigned to each component, in fact many 3D editing systems explicitly try to optimize model files by merging and reusing materials as much as possible. For example, if I have a gizmo that has 20 components, and 10 of them are stainless steel, usually they will share a common material definition. That means with the current API, I can't select any of those items individually--selecting any of them means selecting all of them.
-
Unfortunately, the suggestion to "open your model in Blender and give every item its own material" is not practical for me--Aside from creating (in my view) a lot of low value busy work, we intend for this project to allow folks to upload their own models. So we won't have control over how they attach or optimize their materials--as long as it's valid GLTF we would like to support it.
As a CAD user, the choice to base selection (click target) on material rather than mesh seems odd. Maybe there's an implementation reason that it's easier to do it that way, but IMO it doesn't really fit the use case of "click an item and do something with it".
Any chance we could get a true "click object to select it" feature?