How can I use debounce in camera.onViewMatrixChangedObservable?

Please do not forget to add a link to a Playground to get a faster answer:

I try to add a debounce in camera.onViewMatrixChangedObservable , but it didnot work

notice the text you haven’t deleted from the template? :slight_smile:
Show us what you are trying to do, we might be able to help. debounce? on a callback, or on the notify process itself? what exactly are you trying to achieve?

2 Likes

微信截图_20230314104257
thanks for your reply! I’m not sure :sweat_smile:,like this in my code

that’s not how debounce work. Not a babylon issue though :slight_smile:

debounce returns a new function that does the magic for you. What you need to do is create the debounce callback before adding it to the observable and use the returns function as callback. you can also do it directly in the add function if you want, something like:

observable.add(debounce(functionToDebounce))
1 Like