Skip to content

Commit

Permalink
feat: support interactableDescendants to shortcut traversing the scen…
Browse files Browse the repository at this point in the history
…e graph when interacting with instanced UIs for example
  • Loading branch information
bbohlender committed Oct 30, 2024
1 parent f85f45e commit 5c132e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 8 additions & 3 deletions packages/pointer-events/src/intersections/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,15 @@ export function intersectPointerEventTargets(
}
}

const childrenLength = object.children.length
for (let i = 0; i < childrenLength; i++) {
if (object.intersectChildren === false) {
return
}

const descendants = object.interactableDescendants ?? object.children
const descendantsLength = descendants.length
for (let i = 0; i < descendantsLength; i++) {
intersectPointerEventTargets(
object.children[i],
descendants[i],
pointers,
hasListener,
pointerEvents,
Expand Down
3 changes: 3 additions & 0 deletions packages/pointer-events/src/pointer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ declare module 'three' {
setPointerCapture(pointerId: number): void
releasePointerCapture(pointerId: number): void
hasPointerCapture(pointerId: number): boolean

intersectChildren?: boolean
interactableDescendants?: Array<Object3D>
}
}

Expand Down

0 comments on commit 5c132e8

Please sign in to comment.