chore(InteractorStyleMPRSlice): fix recursion error in example - #3554
chore(InteractorStyleMPRSlice): fix recursion error in example#3554Jo-Byr wants to merge 2 commits into
Conversation
finetjul
left a comment
There was a problem hiding this comment.
It should be fixed in InteractorStyleMPRSlice instead of the example.
dd8aeba to
2ed5a8a
Compare
There was a problem hiding this comment.
I'm glad this fixes the example.
However, I think it does not fix the root of the problem.
The InteractorStyleMPRSlice is temporarilly notifying observers of an invalid "slice".
The problem is that it triggers a modify event between line 174 and line 175. When the state is unstable.
A proper fix should be to prevent such notification while the camera is being updated.
2286a95 to
476b547
Compare
I moved the first updateUI call and the istyle.onModified callback to after the first render call. |
While you may have fixed the example. You have not fixed all the consumers of InteractorStyleMPRSlice. It would be better to fix InteractorStyleMPRSlice in the first place (rather than the example (i.e. a consumer of InteractorStyleMPRSlice)). |
I did this too. The block In InteractorStyleMPRSlice's setSlice is responsible for that. The modification in the example is to fix this problem you mentioned:
|
|
From what I remember, |
The issue actually comes from getSlice not returning the exact same value as setSlice by a few digits, which triggers a set on the controller in the UI, which in turn retriggers setSlice which will again be slightly off. We just need to block the UI update in updateUI: Do you agree ? |
No, I disagree :-) It should not be fixed in the example but in |
It seems just adding |
It is enough for the example, but it may not be enough for other consumers of |
I think that fundamentally, it's an example problem. It's the example that implements a listener that's also a setter, which of course can create a recursion error if we decide to display the data differently from what we get. But with the setter guard mentionned, there's no more erorr in the example. What else would you want to add ? There just seems to be another bug due to the calls to |
|
I think the example is fine. It does what To me, the problem is that |
I disagree. For me the fix is to
The NaN issue is a bit tedious to understand. It comes from the fact that we don't explicitely initialize the slider range at the initialization which makes it so that the first call to lil-gui sliders have a lil-gui has no guard against incoherent min and max. We can have min > max and then the step is negative (i.e. up-arrow decreases the slider value), but for min == max, we then have _step = 0 which makes it so that So I see 2 solutions:
I prefer 2 as it maintains a step to 0.1% of the range, rather than the (1-0) / 1000. |
But it is not sufficient. Say you call: |
|
So replacing the double set by ? |
It would have to be I guess we could create a convenient |
Should I create a separate PR for that ? |
no, it's part of the fix. It can be another commit in the same PR. |
Add setPositionAndFocalPoint method to allow setting position and focal point in one call without trigerring modified and computeDistance in between
476b547 to
01542f3
Compare
Do early return in setSlice if the target is the current value of getSlice
01542f3 to
c925a49
Compare
Context
InteractorStyleMPRSlice example fails due to a recursion error.
Results
The error is fixed so the example works.
Changes
Added a difference threshold on the interactor Stume slice update to avoid recursion error
PR and Code Checklist
npm run reformatto have correctly formatted code