Skip to content

add option to stop event-propagation of tree vs ray #30

@bigmistqke

Description

@bigmistqke

in react-three-fiber events propagate in 2 different ways: bubbling up the tree and objects sorted in 3d space via the cast ray (see playground). In 2d these are directly related to each other (you can only hit an object behind if it's also behind the parent), but in 3d these feel as 2 separate, unrelated concepts.

To mimick the browser's API, react-three-fiber has only a single way of stopping the event from propagating: event.stopPropagation(). When stopping propagation this stops both the bubbling up via the tree and via the cast ray.

I propose to offer control which type of propagation you want to stop:

// Implicitly stops both
event.stopPropagation()

// Stop propagation via the tree
event.stopPropagation('tree')

// Stop propagation via the ray 
event.stopPropagation('ray')

I am very much open for naming suggestions. especially 'ray' is a bit ambiguous

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestnextIssues related to next pre-release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions