-
-
Notifications
You must be signed in to change notification settings - Fork 35.8k
Nodes module uses class names to register nodes (addNodeClass) which crashes in production #26518
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
Comments
Would it be acceptable to use a static property for each node class? class BitangentNode extends Node {
static type = "BitangentNode";
…
} and then for export function addNodeClass( nodeClass ) {
if ( typeof nodeClass !== 'function' || ! nodeClass.type ) throw new Error( `Node class ${ nodeClass.type } is not a class` );
if ( NodeClasses.has( nodeClass.type ) ) throw new Error( `Redefinition of node class ${ nodeClass.type }` );
NodeClasses.set( nodeClass.type, nodeClass );
}
Therefore, the code would not require predefined class names and the node loader would be unchanged. |
There is the same issue with |
Terser removes the class name entirely. Here is my work around for now placing them in an exemption list. https://github.com/danrossi/three-webgpu-renderer/blob/master/rollup.config.js#L75 |
Terser settings are not always available. e.g. NextJS |
That does use Terser also so there should be a config for adding something like this
|
Nextjs actually now uses SWC by default but like for Terser, the options are handled internally by the framework and cannot be changed. I know that this is not threejs problem, but I have the feeling that this small change would make the life easier and save troubleshooting time for anybody willing to use the node system seriously in production at the moment. |
I think we can do it like so: export function addNodeClass( nodeClass, name ) {
if ( typeof nodeClass !== 'function' || ! name ) throw new Error( `Node class ${ name } is not a class` );
if ( NodeClasses.has( name ) ) throw new Error( `Redefinition of node class ${ name }` );
NodeClasses.set( name, nodeClass );
}
addNodeClass( BitangentNode, 'BitangentNode' ); @njarraud Would this solve your issue? |
Just looking at it, yes I believe I would work. |
We must consider serialization in this fix as well. three.js/examples/jsm/nodes/core/Node.js Lines 29 to 33 in d930553
|
It's not much, but I am offering a $50 bounty for fixing WebGPU minification-related issues. Hopefully this is the only one! That's the last missing bit for shipping WebGPU support to MiniMana.io :) |
With r157, running in production is now causing a new kind of bug. It works fine in development mode, but when I build the app in production mode (with Next.js), I am now getting:
This is coming from: Does that seem minification-related? |
I'll send the bounty either way. @LeviPesin, is it fine to send the money to your GH sponsor account? If not please get in touch! On Twitter or Discord as verekia, or the email on verekia.com. |
I think it could happen from tree-shaking node materials (and
Sure! |
Uh oh!
There was an error while loading. Please reload this page.
Description
The
addNodeClass
function exported fromnodes/core/Nodes.js
uses the name property of the nodes classes to register the nodes. The node module works well in development however when the code is packed for production, class names are often modified by the compiler and therefore the whole module crashes.I believe that this function is mainly used by NodeLoader, but because of this test
it crashes as soon as any call to this module is made which makes it unusable for production.
Reproduction steps
Code
None
Live example
None
Screenshots
No response
Version
r155
Device
No response
Browser
No response
OS
No response
The text was updated successfully, but these errors were encountered: