-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
WebGPURenderer: Fix NodeLibrary Logic for Minified Builds #29501
WebGPURenderer: Fix NodeLibrary Logic for Minified Builds #29501
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
||
} | ||
|
||
set type( _value ) { /* */ } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a big fan of this but since we're using es2018 we can't do:
class Material extends EventDispatcher {
static type = 'MeshBasicMaterial';
...
}
and:
class Material extends EventDispatcher {
...
}
Material.type = 'Material';
would break treeshaking I believe.
Let's merge this and get it into r170, if there are no objections — It would be really nice to support bundlers with WebGPU, blocked by this and #29156. |
@RenaudRohlinger Just a heads up since I've almost overlooked the post of @FarazzShaikh in the commit: ac963e2#r148635345 We might want to partly revert this PR by keeping the Granted, it is supposed to be a read-only property and there is an easy workaround (ac963e2#r148640959) but I wonder if it's better to not confront users with a migration task by restoring the previous code. |
Related issue: #29187
Description
Issue:
Minifiers mangle class names like MeshStandardMaterial.name to shorter identifiers (e.g., a2), causing errors such as:
NodeMaterial: Material "MeshStandardMaterial" is not compatible.
Solution:
This PR fixes the issue by introducing a static type property on material classes. By using materialClass.type instead of materialClass.name, we prevent minification from breaking material compatibility checks.
PS:
Note: I strongly recommend merging this or a similar fix before releasing r169, as this issue currently breaks all Vite applications using the WebGPURenderer.
This contribution is funded by Utsubo