Mesh.isPickable issues probably a very easy answer

Hi, I’m having more trouble than I should with getting this right.

I have a mesh names with either a space or a full stop in between (I.e. circle.001). How should I write this out for this code:

“circle.001”.isPickable = false;

I have a edge render for my model but I don’t want it to show for a certain selection of meshes. I thought I would need to put the mesh name in quotations i.e. “circle.001” but that doesn’t seem to work. Is that even the right way to stop a mesh from being highlighted? It’s a glb file.

Thanks

const mesh = scene.getMeshByName(“circle.001”);
mesh.isPickable = false;
1 Like

Thank you :slight_smile: I’ll try that

Hi, I’ve tried to use that but I get mesh is Null. I’ve created a playground as an example. How would this work in the example excluding the two circlexxx mesh’s. In my main model there are 100’s of buildings by the way that I’d need to keep as pickable. Is it not working due to the way it loads and checks for that mesh before it’s loaded?

Hi @James1

Circle.007 is not a mesh. If you check with the inspector, you can see it is a transform node. And the transform node has 2 child meshes.

You can get the transform node by name and then iterate through each child mesh and update the property of each child mesh:

        const tn007 = scene.getTransformNodeByName('Circle.007');
        tn007.getChildMeshes().forEach((mesh) => {
            mesh.isPickable = false;
        });

Code is added to line 16-19 in the callback when glb model loading is completed.

I see, thank you! Is there a clean way of doing it for a lot of transform nodes (more than 1). I couldn’t stop the bridge from being highlighted by replicating that code for Circle.027

You can do something like this if you want to update property for all the meshes in your glb.

Hi, I need 600 odd buildings in my scene to be selectable unfortunately and about 25 or so not to be. So a bit of a mix.

Then you need to maintain a list of the name of these TransformNode or Meshes, and apply a filter. Or if the names of unselectable entities follow a pattern, you can apply a regexp filter.

Another way that might be easier than changing the name or name convention is to make two imports and assign an ‘id’ for each group of meshes. Or you can also do through material and assign an ‘id’ to the material. Both would work.

Thanks for the replies @slin and @mawa. I love both ideas but the coding sounds far too complicated for me to draft up. I have a working solution with a basic duplication:
const tn007 = scene.getTransformNodeByName(‘Circle.027’);

    tn007.getChildMeshes().forEach((mesh) => {

        mesh.isPickable = false;

      });

     const tn008 = scene.getTransformNodeByName('Circle.007');

    tn008.getChildMeshes().forEach((mesh) => {

        mesh.isPickable = false;

    });

So I may stick to that one for now. Regex sounds like it would be the right option as a lot of the mesh’s I have to mark as unpickable are in groups with the same naming convention like circle.0xx and Tree.0xx.

Regards

James

1 Like

Just for an update, I’ve managed to merge 200 odd meshes into about 10 meshes so it removes the need to reference so many :slight_smile: I had to research how to do that in blender as I wasn’t aware that was possible.

Sure is. And btw, merging meshes also works at BJS level.

3 Likes