I have a scene in which i want to remove a meshed once it has been dragged onto another mesh. I use the pointerDragBehavior.onDragEndObservable and call mesh.dipose() which seems to generate some kind of recursion error in Firefox and Chrome.
When you dispose the sphere, the behaviour is also disposed. Because you are in a dragging state, the onDragEndObservable observable is called in the dispose method, leading to the recursive calls.
You can either dispose the sphere outside of the onDragEndObservable observable or set pointerDragBehavior.dragging = false; just before calling sphere.dispose():
I see, thanks for explaining. That workaround should do it for me. Although it seems a bit counterintuitive to me that itās still in the dragging state when the onDragEndObservable is called.
In fact the same releaseDrag function is called when a drag ends and when disposing of the behaviour. And this is the function that checks the state of dragging and iftrue raises the onDragEnd observable.
The system canāt know when you call dispose, so canāt set dragging = false before calling releaseDrag in the dispose method.
Thanks again for explainig and sorry for nitpicking, but couldnāt the releaseDrag function set dragging = false before raising the onDragEnd observable? Donāt get me wrong, Iām fine with the workaround of setting it on my own Iām just under the impression that would make the behavior more intuitive. But since I havenāt looked into the code Iām most likely missing something.