-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[proposal]hooks #55
Comments
Most definitely - great use of action manager and very useful! The only thing I don't know is if we should be returning a method to de-register before the mesh disposes (like |
When the mesh is disposed (which happens when it is removed) the action manager is disposed: So, under normal conditions likely wouldn't need this. One issue may arise when referencing a mesh in parent hierarchy (like a forwardRef), as it will keep registering actions if the effect is re-created. Does this look right? useEffect(() => {
if (ref.current) {
// what you have now...
const registeredAction: Nullable<IAction> = mesh.actionManager.registerAction(
// ...
);
return () => {
// called when component is unmounted?
mesh.actionManager!.unregisterAction(registeredAction!)
}
}
}, [ref.current])
} |
Also, I will add it separately, but it needs a guard clause - can check the metadata. GUI have a different hover:
If you make a PR I will accept with or without those extra changes. Thanks Hooke! |
Thanks for your remind. I will add this code. |
…d ActionManager vs 2D `onPointerEnterObservable`. #55
@brianzinn
Do you think we need to add some other hooks?
For example:
useClick
useClick(onClick: Function<event>): [ref]
https://github.com/hookex/bviz/blob/master/src/hooks.ts
useHover
useHover(over: Function<event>, out: Function<event>): [ref, isHovering]
https://github.com/hookex/bviz/blob/master/src/hooks.ts
...
The text was updated successfully, but these errors were encountered: