CoBry
March 16, 2020, 12:40pm
1
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!
JohnK
March 16, 2020, 1:47pm
2
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
CoBry
March 17, 2020, 2:20pm
3
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?
JohnK
March 17, 2020, 5:27pm
4
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.