How to add click events to the entire model

Hi all, this is my model file structure,It consists of many meshes,
i want to add click events to the entire model .So I can click anywhere in the model.what need i do ?

You can wrap the model in a BoundingBoxGizmo.

BABYLON.BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox(model)

Docs

1 Like

sorry i don’t quite follow .do you have demo? this function looks like only works on one mesh.This is how I solved it:

Sorry I don’t have a working demo right now.

You have to add the top root as the mesh. In your first screenshot you have the top mesh named root just pass it to the function.

1 Like

You can check this playground.
https://playground.babylonjs.com/#K7TJIG#90

4 Likes

It’s very clear,thank you !

I want a TransformNode as an overall trigger object
glb outline | Babylon.js Playground (babylonjs.com)

When I use ABYLON.BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox , report wrong .
If a TransformNode as an overall trigger object, what should I do?


example: glb outline | Babylon.js Playground (babylonjs.com)

The error you are seeing is because the function MakeNotPickableAndWrapInBoundingBox only accepts mesh obj. You are passing it a TransformNode.

Doc

Can you explain a bit more what you are trying to do.

1 Like

There are many elements in this TransformNode .
I want to pick up this TransformNode as a whole

I want to mouse click this TransformNode Z41H_40_250_ZZ_012, and the prompt pops up .

I don’t know a direct way of making a TransformNode pickable using pointer events. But you can check if the mesh clicked is a descendant of a certain Node.

Check this playground: Playground

2 Likes

This can indeed be realized, thank you vary much

1 Like