Open
Conversation
Author
|
Hmm after testing this further, I realized that this doesn't work in the case of <Canvas>
<Selection>
<Select enabled>
<Box name="box" />
</Select>
<Select enabled={false}>
</Select>
</Selection>
</Canvas>I will look into this some more... |
Author
|
I've played with this a bit more and I believe this fix is now working as intended. |
Member
|
is it ready to go in? did you notice any adverse effects on older boxes? |
Comment on lines
-25
to
+33
| if (api && enabled) { | ||
| let changed = false | ||
| const current: THREE.Object3D<THREE.Event>[] = [] | ||
| group.current.traverse((o) => { | ||
| o.type === 'Mesh' && current.push(o) | ||
| if (api.selected.indexOf(o) === -1) changed = true | ||
| }) | ||
| if (changed) { | ||
| api.select((state) => [...state, ...current]) | ||
| return () => { | ||
| api.select((state) => state.filter((selected) => !current.includes(selected))) | ||
| } | ||
| } | ||
| if (!api) return | ||
| const current: THREE.Object3D<THREE.Event>[] = [] | ||
| group.current.traverse((o) => { | ||
| if (o.type === 'Mesh') current.push(o) | ||
| }) | ||
| if (enabled && current.some(o => !api.selected.includes(o))) { | ||
| api.select(state => [...state, ...current]) | ||
| } else if (!enabled && current.some(o => api.selected.includes(o))) { | ||
| api.select(state => state.filter(o => !current.includes(o))) |
Member
There was a problem hiding this comment.
Why remove the cleanup handler? I'm not sure I understand when L33 is supposed to happen in the case of a Select unmounting with any number of siblings rather than parents who rerender when children change (e.g. <Selection> <Select /> <Select /> </Selection>).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See #236 for additional details
Would be great to hear your feedback on this. This code
is only correct if there are no duplicates in any of the two arrays (otherwise, they would have to be de-duped first) - but I believe that is the case here.