Replies: 2 comments 2 replies
-
hi @obolland what about the import { useScene } from 'react-babylonjs';
const YourComponent = () => {
// this component needs to be inside <Scene>...</Scene> otherwise will be null
const scene = useScene();
console.log('scene', scene);
// likely you use `useCallback` with scene dependency for your onModelLoaded callback?
return <Model .../>
} Otherwise in your callback your mesh has a scene property - it's not public, but I don't suspect that would change anytime soon. Otherwise maybe you can share further your scenario and there is another way. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I think another approach is to get the scene from the mesh itself. I guess you can get the mesh within the onModelLoaded function and then call getScene() https://doc.babylonjs.com/typedoc/classes/babylon.mesh#getscene But useScene() is imo the better approach. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I would like to get access to the scene from outside of the onSceneMount callback on the Scene component.
For example, I have child models with their respective onModelLoaded callbacks, I would like ideally like direct access to the scene from within these callbacks. Is this possible?
Beta Was this translation helpful? Give feedback.
All reactions