-
-
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
Split InputNode into ConstNode and UniformNode #23663
Conversation
I think the NodeEditor also requires a fix for InputNode, but I think I will do it tomorrow. |
@sunag now this PR passes all the tests but not all examples are working - e.g. https://raw.githack.com/LeviPesin/three.js-1/split-input-node/examples/webgl_materials_standard_nodes.html (gun does not show even without serialization code). Not sure what is the problem with it... |
const value = new THREE.Vector3();
// current
const vec3 = new Nodes.Vector3Node( value );
const vec3Const = new Nodes.Vector3Node( value ).setConst( true );
// proposed by @LeviPesin
const vec3 = new Nodes.UniformNode( 'vec3', value );
const vec3Const = new Nodes.ConstNode( 'vec3', value );
// proposed by @LeviPesin with my cleanup
const vec3 = new Nodes.UniformNode( value );
const vec3Const = new Nodes.ConstNode( value ); @mrdoob do you have any thoughts on this? |
If you remove the |
I don't think in remove it entirely. It can be auto-detected and used as second parameter if needed. |
For me, this breaks the current class style. I think it would be a valid update to do in this PR is: UniformNode( value, type = null ) |
I still think that for the class approach it is better to always specify the type. But the ShaderNode approach is much better than the class one, I think - it is much easier to write and understand. |
This is unnecessary most of the time, I don't see why. If the users puts a |
If user e.g. puts a Vector3(1, 1, 1) as a value, it could be vec3, ivec3, or uvec3. |
These are exceptions, it is unusual to use |
OK, so you are suggesting |
Exactly, and |
@sunag I've managed to fix serialization/deserialization in the https://raw.githack.com/LeviPesin/three.js-1/split-input-node/examples/webgl_materials_standard_nodes.html, but for some reason NodeObjectLoader.parse.onLoad is called twice there (as it also was before this PR), but now the first call throws an error for some reason... Could you please look into it and fix it? |
This one looks good to me: const value = new THREE.Vector3();
const vec3 = new Nodes.UniformNode( value );
const vec3Const = new Nodes.ConstNode( value );
That sounds good too! |
Ok, I will test this. |
@sunag Your last commit breaks serialization/deserialization. You can write |
Or you can inline the body of |
cleanup(2)
@LeviPesin I commit a possible fix but didn't test it. I will make a revision of this later. |
I think it works. Then you can also remove .slice(4) from |
@sunag Is there any progress on fixing that example? |
It's been revised and fixed! There were other broken examples too. |
@mrdoob Can we merge? |
Thanks! |
A slight mention of this breaking change in the |
We have not documented breaking changes of the node material so far because of its novel character. A lot of things have changed in the recent past. But it seems the node material is now mature enough to change this policy. |
* Split InputNode into ConstNode and UniformNode * ArrayInputNode -> ArrayUniformNode * Fix nodes * Fix examples * Fix * Fix NodeEditor * Fix b/u/ivec constants * Fix * Fix webgpu_instance_uniform.html * Change signature * Fix serialization/deserialization * Fixes * Fix for nodeType * cleanup * Update InputNode.js cleanup(2) * More cleanup * fix class name * reuse uniformNode * fix uniform * fix non-node params * fix updateUniforms default values * intro to InputNode.getInputType() * cleanup Co-authored-by: sunag <[email protected]>
Related issue: #23646
Description
Split InputNode into ConstNode and UniformNode.
Breaking changes: