-
-
Notifications
You must be signed in to change notification settings - Fork 35.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for typing in EventDispatcher #17134
Comments
As mentioned here #15545
You can implement the same logic with JS, just differently (e.g. put the message type information in the event object). However, I don't think this stuff is necessary in the engine. |
Ha, interesting discussion. At some point three.js started to create actual objects and send them as events, right now they are of form: {
type:"add"
} but the reason why I know is, I re-populate my scene every frame, because of custom culling mechanism, and I found, via profiling, that three.js was generating a decent amount of 🗑 garbage, so I thought to myself 🤔 "hey, three.js is usually super good at keeping GC to a minimum, what gives?" turns out - new event objects. Now I bypass My point is - I would prefer not to see more of an event framework in three.js, it's just about too heavy from my perspective as is. 🏋️♀️ |
This is interesting -- I hadn't considered that. Classes like OrbitControls create objects once and reuse them to dispatch events. It seems like that would be a reasonable improvement to the |
I think so, too. I'm not sure if there was a specific reason to create new objects. Reusing event objects for both methods seems to make more sense. |
Anyway, we've got sidetracked. The issue itself can be closed. The idea of reusing event objects is important and should be discussed in another topic (it has nothing to do with TS). |
Or take it a step further:
I would consider migrating the whole library to typescript and adding the rxjs library.
With rxjs you will be able to subscribe to different changes such as position changes etc
Also you will be able to know which type of messages are emitted from different events and be able to thorttle messages and buffer them
The text was updated successfully, but these errors were encountered: