Hi,
I written the function to pickup the x,y,z points from gameoject in Babylon, its working fine and i could could get the world coordiantes from that.
Similarly i have created the Input text field in babylon and through the event function i am reading the text what user typing in.
Here is the code for getting an points from model:
we don’t officially support react, so we can’t really say what’s working or not working, but I am sure the community (and the team) would be able to help if you would explain what the actual issue is. You should probably set a react’s component state on click / change. But this is of course an uneducated answer.
have you already integrated your project with React? If so, it looks like the main thing will be to get the references in React (or babylon) to communicate, since the input text changes the mesh label.
If you want to render the the pick result and text in babylon GUI input field to html (react), I think the cleanest way is to use a central state management library like redux or mobx. In the event listener code, you update the state that holds the pick result and text. React will react to the value changes in the central state.
I would rewrite above equivalent source with hooks and an FC as that source code is circa 2018, but anyway here is the working demo of that source: live demo
I would import useRef and use that to track object references to the meshes or from the meshPicked callback. That will work in any project even without react-babylonjs. If you are using babylonjs-hook NPM then there is a useScene hook.
edit: Here is maybe a better example - it uses FCs and hooks and persistent application state: source (github.com)
These same questions were cross posted as issues, so adding those solutions here in case some future person finds them useful. Both issues have screenshots and code sandboxes.