Add searchbar to scene

Hi guys,

I have a scene with many different meshes in it. Now i want to implement a searchbar to look up certain meshes. For example I want to type in the name of a mesh and after pressing enter this mesh is highlighted.

Do you now if that’s possible? Is there a possibility to implement a searchbar?

Thanks!

Since Babylon.js is and extension to Javascript there are several ways to do it. For example

https://doc.babylonjs.com/how_to/gui#inputtext
or use HTML for your own search bar.

All meshes in a scene can be found using https://doc.babylonjs.com/api/classes/babylon.scene#meshes

An individual (if named uniquely) mesh using https://doc.babylonjs.com/api/classes/babylon.scene#getmeshbyname

2 Likes

Great, that worked!
Now i want to start my search with the “enter”-button. But unfortunatly that wont work. Im using this code:

new BABYLON.ExecuteCodeAction(
{
trigger: BABYLON.ActionManager.OnKeyDownTrigger,
parameter: ‘+’
},
function () {…

With the + oder any other key it works fine. Maybe Babylon.js uses a different name? I tried “return” but that doesnt work either.
Any suggestions?

Remember to click with mouse pointer on scene before using keys. This PG Babylon.js Playground will give you names and codes for the key.