brianzinn / react-babylonjs

React for Babylon 3D engine
https://brianzinn.github.io/react-babylonjs/
812 stars 102 forks source link

rectangle onPointerDownObservable removed after first pointerDown event #225

Closed AJamesPhillips closed 1 year ago

AJamesPhillips commented 2 years ago

I don't know if this is intentional but a <rectangle onPointerDownObservable={() => { /*...*/ }} and the onPointerDownObservable handler is only triggered once. Further pointer down events are ignored.

If rectangle is replaced by babylon-button then it can be clicked multiple times and fire the handler each time.

A demo of this is here.

brianzinn commented 2 years ago

Here is the code that is updating the observable callback: https://github.com/brianzinn/react-babylonjs/blob/master/packages/react-babylonjs/src/UpdateInstance.ts#L58

Looks like it should work. Since you have a key prop then the reconciler should keep that one and re-assign the callback. Calling set_chosen_home triggers a re-render. I can see the code, but not what is happening in practice - I wonder if resizing and changing padding is a bug in GUI package for the pointer down event. Do you have time to make a regular imperative babylon.js PG or inspect the observables?

brianzinn commented 1 year ago

closing as it appears to be a bug in downstream project in babylon 4.2 only. not going to add a workaround in this library. please re-open if your question is still unanswered.