[Suggestion] Replace EventDispatcher with native EventTarget and CustomEvents
See original GitHub issueIs your feature request related to a problem? Please describe.
The current EventDispatcher is lacking a lot of functionality that the native EventTarget supports, such as .stopPropagation
.
Describe the solution you’d like
I suggest that the custom EventDispatcher is replaced and having classes like Object3D extend the native EventTarget instead.
This would affect the event objects currently being dispatched, because they would have to be replaced with CustomEvent instances instead.
This would be a breaking change.
As for browser support, then it is the following for extending EventTarget:
- Chrome: 64
- Edge: 79
- Firefox: 58
- Internet Explorer: None
- Safari: 14
Describe alternatives you’ve considered
Alternatively I think the EventDispatcher should be further developed to support relevant APIs like .stopPropagation
.
Additional context
It was previously mentioned in #12854, that it would be able to be removed “soon”.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
I must admit I had completed missed that PR thread when looking into previous issues regarding this. The performance does look quite bad.
I checked the fiddle and it seems there have been quite some improvements on both Chrome and Firefox since the original test, but yes, it is still significantly worse.
I will close this issue, but I do think it’s worth keeping an eye on any performance improvements that the browsers make over time, since the native events come with a lot of features which could significantly improve developer ergonomics.
Here is the fiddle: https://jsfiddle.net/xm3jnkzd/ Three is still about 20 times faster than native on Chrome.