-
-
Notifications
You must be signed in to change notification settings - Fork 35.3k
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
Cannot override methods when extending WebGLRenderer #25598
Comments
Looking at the WebGLRenderer class more deeply, I believe this can be achieved when we can use private class properties. |
You can override in this way but of course is not clean
|
Yup, I ended up calling the |
Grab a reference to the original dispose method, replace dispose method on original, use the reference in the body of your replacement to do an effective call to super. |
@marcofugaro Did #25599 address this? |
No, not yet. After #25599 we are still defining three.js/src/renderers/WebGLRenderer.js Line 574 in 8571a82
To fix this issue we need to define |
We can't use private class fields since we want to stick to ECMA2018. So if |
Yup, should we refactor using |
We have lately decided to stick to ECMAScript 2018 (see #25185) and I would prefer to not revisit this topic in the next time. |
@Mugen87 you misread my question. I asked if we should use |
Sorry, you're right! We can use the I'm just hesitating since refactoring big classes always introduces the risk of breaking something. But I guess sooner or later the mentioned inheritance issue with the renderer would come up again. My hope was to avoid the rewrite as long as possible^^. |
Description
In my case, I have a
CustomRenderer
class that extendsWebGLRenderer
. I want to dispose of other things in thedispose()
call, so I created an override method that disposes of my resources and also callssuper.dispose()
.However, in WebGLRenderer, the method doesn't ever get called, and instead the
WebGLRenderer.dispose()
is called directly.This is because the
WebGLRenderer.dispose()
, is not a class method per se.Reproduction steps
WebGLRenderer
WebGLRenderer
methodCode
Live example
Screenshots
No response
Version
r150
Device
No response
Browser
No response
OS
No response
The text was updated successfully, but these errors were encountered: